Skip to content

Commit

Permalink
Merge pull request #36312 from perrotta/avoidNestedDeadAssignmentsInV…
Browse files Browse the repository at this point in the history
…alidationEcalHits

Avoid nested dead assignments, as reported by the static analyzer
  • Loading branch information
cmsbuild committed Dec 1, 2021
2 parents d84761d + f2fa2cc commit f092dda
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 42 deletions.
26 changes: 12 additions & 14 deletions Validation/EcalHits/src/EcalBarrelSimHitsValidation.cc
Expand Up @@ -364,16 +364,15 @@ float EcalBarrelSimHitsValidation::eCluster2x2(MapType &themap) {
float e258 = themap[2] + themap[5] + themap[8];

if ((e012 > e678 || e012 == e678) && (e036 > e258 || e036 == e258))
return E22 = themap[0] + themap[1] + themap[3] + themap[4];
E22 = themap[0] + themap[1] + themap[3] + themap[4];
else if ((e012 > e678 || e012 == e678) && (e036 < e258 || e036 == e258))
return E22 = themap[1] + themap[2] + themap[4] + themap[5];
E22 = themap[1] + themap[2] + themap[4] + themap[5];
else if ((e012 < e678 || e012 == e678) && (e036 > e258 || e036 == e258))
return E22 = themap[3] + themap[4] + themap[6] + themap[7];
E22 = themap[3] + themap[4] + themap[6] + themap[7];
else if ((e012 < e678 || e012 == e678) && (e036 < e258 || e036 == e258))
return E22 = themap[4] + themap[5] + themap[7] + themap[8];
else {
return E22;
}
E22 = themap[4] + themap[5] + themap[7] + themap[8];

return E22;
}

float EcalBarrelSimHitsValidation::eCluster4x4(float e33, MapType &themap) {
Expand All @@ -384,16 +383,15 @@ float EcalBarrelSimHitsValidation::eCluster4x4(float e33, MapType &themap) {
float e0_24 = themap[20] + themap[21] + themap[22] + themap[23] + themap[24];

if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
else if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];
else {
return E44;
}
E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];

return E44;
}

uint32_t EcalBarrelSimHitsValidation::getUnitWithMaxEnergy(MapType &themap) {
Expand Down
26 changes: 12 additions & 14 deletions Validation/EcalHits/src/EcalEndcapSimHitsValidation.cc
Expand Up @@ -374,16 +374,15 @@ float EcalEndcapSimHitsValidation::eCluster2x2(MapType &themap) {
float e258 = themap[2] + themap[5] + themap[8];

if ((e012 > e678 || e012 == e678) && (e036 > e258 || e036 == e258))
return E22 = themap[0] + themap[1] + themap[3] + themap[4];
E22 = themap[0] + themap[1] + themap[3] + themap[4];
else if ((e012 > e678 || e012 == e678) && (e036 < e258 || e036 == e258))
return E22 = themap[1] + themap[2] + themap[4] + themap[5];
E22 = themap[1] + themap[2] + themap[4] + themap[5];
else if ((e012 < e678 || e012 == e678) && (e036 > e258 || e036 == e258))
return E22 = themap[3] + themap[4] + themap[6] + themap[7];
E22 = themap[3] + themap[4] + themap[6] + themap[7];
else if ((e012 < e678 || e012 == e678) && (e036 < e258 || e036 == e258))
return E22 = themap[4] + themap[5] + themap[7] + themap[8];
else {
return E22;
}
E22 = themap[4] + themap[5] + themap[7] + themap[8];

return E22;
}

float EcalEndcapSimHitsValidation::eCluster4x4(float e33, MapType &themap) {
Expand All @@ -394,16 +393,15 @@ float EcalEndcapSimHitsValidation::eCluster4x4(float e33, MapType &themap) {
float e0_24 = themap[20] + themap[21] + themap[22] + themap[23] + themap[24];

if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
else if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];
else {
return E44;
}
E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];

return E44;
}

uint32_t EcalEndcapSimHitsValidation::getUnitWithMaxEnergy(MapType &themap) {
Expand Down
26 changes: 12 additions & 14 deletions Validation/EcalHits/src/EcalSimHitsValidProducer.cc
Expand Up @@ -509,16 +509,15 @@ float EcalSimHitsValidProducer::eCluster2x2(MapType &themap) {
float e258 = themap[2] + themap[5] + themap[8];

if ((e012 > e678 || e012 == e678) && (e036 > e258 || e036 == e258))
return E22 = themap[0] + themap[1] + themap[3] + themap[4];
E22 = themap[0] + themap[1] + themap[3] + themap[4];
else if ((e012 > e678 || e012 == e678) && (e036 < e258 || e036 == e258))
return E22 = themap[1] + themap[2] + themap[4] + themap[5];
E22 = themap[1] + themap[2] + themap[4] + themap[5];
else if ((e012 < e678 || e012 == e678) && (e036 > e258 || e036 == e258))
return E22 = themap[3] + themap[4] + themap[6] + themap[7];
E22 = themap[3] + themap[4] + themap[6] + themap[7];
else if ((e012 < e678 || e012 == e678) && (e036 < e258 || e036 == e258))
return E22 = themap[4] + themap[5] + themap[7] + themap[8];
else {
return E22;
}
E22 = themap[4] + themap[5] + themap[7] + themap[8];

return E22;
}

float EcalSimHitsValidProducer::eCluster4x4(float e33, MapType &themap) {
Expand All @@ -529,16 +528,15 @@ float EcalSimHitsValidProducer::eCluster4x4(float e33, MapType &themap) {
float e0_24 = themap[20] + themap[21] + themap[22] + themap[23] + themap[24];

if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
else if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
return E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];
else {
return E44;
}
E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];

return E44;
}

float EcalSimHitsValidProducer::energyInEEMatrix(
Expand Down

0 comments on commit f092dda

Please sign in to comment.