Skip to content
Snippets Groups Projects
Commit f6dc4437 authored by John Chapman's avatar John Chapman
Browse files

Refactor calculation of etaBin variable in LArG4HEC/src/LocalGeometry.cc

`switch` statements used in the calculation of the `etaBin variable in
the `LocalGeometry::CalculateIdentifier` method contained dead code.
The calculation has been refactored slightly to remove the switch
statements. This should fix Coverity Defect 115128.


Former-commit-id: d2f5391eb7eb3b778b1497f19fcbc74ef3b9ce84
parent 2af83f04
No related branches found
No related tags found
No related merge requests found
......@@ -318,16 +318,17 @@ namespace LArG4 {
locy += locyadd;
// Region Identifier
// This will be computed from local Y coordinate
if( locy < m_pads[copyDepth][4] ) region = 1;
else region = 0;
if( locy < m_pads[copyDepth][4] ) {
region = 1;
etaBin = 3;
}
else {
region = 0;
etaBin = 13;
}
// eta_Bin Identifier
// Needs a table of coordinates of pad boundaries
switch(region) {
case 1: { etaBin = 3 - binSearch(locy, copyDepth, region); break; }
case 0: { etaBin = 13 - binSearch(locy, copyDepth, region); break; }
default: { assert(0<1); break; }
}
etaBin -= binSearch(locy, copyDepth, region);
LArG4Identifier result = LArG4Identifier();
......@@ -482,12 +483,16 @@ namespace LArG4 {
else
depthNum = 6;
}
if( locy < m_pads[depthNum][4] ) region = 1; else region = 0;
switch(region) {
case 1: { etaBin = 3 - binSearch(locy, depthNum, region); phiBin /= 2; break; }
case 0: { etaBin = 13 - binSearch(locy, depthNum, region); break; }
default: { assert(0<1); break; }
if( locy < m_pads[depthNum][4] ) {
region = 1;
etaBin = 3;
phiBin /= 2;
}
else {
region = 0;
etaBin = 13;
}
etaBin -= binSearch(locy, depthNum, region);
#ifdef DEBUG_HEC
std::cout <<"HEC::LocalGeometry zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region <<
" , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl;
......@@ -533,15 +538,18 @@ namespace LArG4 {
else
depthNum = 6;
}
if( locy < m_pads[depthNum][4] ) region = 3; else region = 2;
if( locy < m_pads[depthNum][4] ) {
region = 3;
etaBin = 3;
}
else {
region = 2;
etaBin = 13;
}
#ifdef DEBUG_HEC_OLD_DIAGNOSTIC
std::cout<<locy<<" "<<m_pads[depthNum][4]<<" "<<region<<std::endl;
#endif
switch(region) {
case 3: { etaBin = 3 - binSearch(locy, depthNum, region-2); break; }
case 2: { etaBin = 13 - binSearch(locy, depthNum, region-2); break; }
default: { assert(0<1); break; }
}
etaBin -= binSearch(locy, depthNum, region-2);
}
} else if (copyN==50 ) { // First Absorber - in front of HEC
copyModule = theTouchable->GetVolume(2)->GetCopyNo() - 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment