Skip to content

Commit

Permalink
removal of bool member variables and change to interface of retrieveP…
Browse files Browse the repository at this point in the history
…hiThetaExtrema
  • Loading branch information
Erich Varnes committed Jul 22, 2024
1 parent 64b0569 commit 21f8a41
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions RecFCCeeCalorimeter/src/components/CaloTowerToolFCCee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,51 +43,37 @@ StatusCode CaloTowerToolFCCee::initialize() {
return StatusCode::FAILURE;
}

std::vector<double> listPhiMax;
std::vector<double> listPhiMax;
std::vector<double> listThetaMax;
listPhiMax.reserve(7);
listThetaMax.reserve(7);

std::pair<double, double> tmpPair;
tmpPair = retrievePhiThetaExtrema(m_ecalBarrelReadoutName);
m_ecalBarrelSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_ecalBarrelSegmentationOK) {
if (retrievePhiThetaExtrema(m_ecalBarrelReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
tmpPair = retrievePhiThetaExtrema(m_ecalEndcapReadoutName);
m_ecalEndcapSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_ecalEndcapSegmentationOK) {
if (retrievePhiThetaExtrema(m_ecalEndcapReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
tmpPair = retrievePhiThetaExtrema(m_ecalFwdReadoutName);
m_ecalFwdSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_ecalFwdSegmentationOK) {
if (retrievePhiThetaExtrema(m_ecalFwdReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
tmpPair = retrievePhiThetaExtrema(m_hcalBarrelReadoutName);
m_hcalBarrelSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_hcalBarrelSegmentationOK) {
if (retrievePhiThetaExtrema(m_hcalBarrelReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
tmpPair = retrievePhiThetaExtrema(m_hcalExtBarrelReadoutName);
m_hcalExtBarrelSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_hcalExtBarrelSegmentationOK) {
if (retrievePhiThetaExtrema(m_hcalExtBarrelReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
tmpPair = retrievePhiThetaExtrema(m_hcalEndcapReadoutName);
m_hcalEndcapSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_hcalEndcapSegmentationOK) {
if (retrievePhiThetaExtrema(m_hcalEndcapReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
tmpPair = retrievePhiThetaExtrema(m_hcalFwdReadoutName);
m_hcalFwdSegmentationOK = tmpPair.first > -1 ? true : false;
if (m_hcalFwdSegmentationOK) {
if (retrievePhiThetaExtrema(m_hcalFwdReadoutName, tmpPair) == StatusCode::SUCCESS) {
listPhiMax.push_back(tmpPair.first);
listThetaMax.push_back(tmpPair.second);
}
Expand Down Expand Up @@ -117,28 +103,28 @@ StatusCode CaloTowerToolFCCee::finalize() {
return GaudiTool::finalize();
}

std::pair<double, double> CaloTowerToolFCCee::retrievePhiThetaExtrema(Gaudi::Property<std::string> aReadoutName) {
StatusCode CaloTowerToolFCCee::retrievePhiThetaExtrema(std::string aReadoutName, std::pair<double, double> &phiThetaPair) {
double phiMax = -1;
double thetaMax = -1;


// check if readout exists & retrieve Module-Theta segmentation
// if readout does not exist, reconstruction without this calorimeter part will be performed
std::pair<dd4hep::DDSegmentation::Segmentation*, SegmentationType> tmpPair;

std::pair<dd4hep::DDSegmentation::Segmentation*, SegmentationType> tmpPair;
tmpPair = retrieveSegmentation(aReadoutName);
dd4hep::DDSegmentation::Segmentation* aSegmentation = tmpPair.first;
SegmentationType aType= tmpPair.second;
if (aSegmentation != nullptr && aType == SegmentationType::kWrong) {
error() << "Wrong type of segmentation" << endmsg;
return std::make_pair(-1,-1);
return StatusCode::FAILURE;
}
if (m_useHalfTower) {
m_decoder = m_geoSvc->getDetector()->readout(aReadoutName).idSpec().decoder();
}

if (aSegmentation != nullptr) {

switch (aType) {
case SegmentationType::kModuleTheta: {

Expand Down Expand Up @@ -177,16 +163,18 @@ std::pair<double, double> CaloTowerToolFCCee::retrievePhiThetaExtrema(Gaudi::Pro
info() << "== Retrieving WRONG segmentation" << endmsg;
phiMax = -1;
thetaMax = -1;
break;
return StatusCode::FAILURE;
}
default: {
error() << " Unsupported segmentation" << endmsg;
phiMax = -1;
thetaMax = -1;
return StatusCode::FAILURE;
}
}
}
return std::make_pair(phiMax, thetaMax);
phiThetaPair = std::make_pair(phiMax, thetaMax);
return StatusCode::SUCCESS;
}

void CaloTowerToolFCCee::towersNumber(int& nTheta, int& nPhi) {
Expand All @@ -205,7 +193,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* ecalBarrelCells = m_ecalBarrelCells.get();
debug() << "Input Ecal barrel cell collection size: " << ecalBarrelCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_ecalBarrelSegmentationOK) {
if (ecalBarrelCells->size() >0) {
CellsIntoTowers(aTowers, ecalBarrelCells, fillTowersCells);
totalNumberOfCells += ecalBarrelCells->size();
}
Expand All @@ -214,7 +202,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* ecalEndcapCells = m_ecalEndcapCells.get();
debug() << "Input Ecal endcap cell collection size: " << ecalEndcapCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_ecalEndcapSegmentationOK) {
if (ecalEndcapCells->size() > 0) {
CellsIntoTowers(aTowers, ecalEndcapCells, fillTowersCells);
totalNumberOfCells += ecalEndcapCells->size();
}
Expand All @@ -223,7 +211,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* ecalFwdCells = m_ecalFwdCells.get();
debug() << "Input Ecal forward cell collection size: " << ecalFwdCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_ecalFwdSegmentationOK) {
if (ecalFwdCells->size() > 0) {
CellsIntoTowers(aTowers, ecalFwdCells, fillTowersCells);
totalNumberOfCells += ecalFwdCells->size();
}
Expand All @@ -232,7 +220,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* hcalBarrelCells = m_hcalBarrelCells.get();
debug() << "Input hadronic barrel cell collection size: " << hcalBarrelCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_hcalBarrelSegmentationOK) {
if (hcalBarrelCells->size()>0) {
CellsIntoTowers(aTowers, hcalBarrelCells, fillTowersCells);
totalNumberOfCells += hcalBarrelCells->size();
}
Expand All @@ -241,7 +229,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* hcalExtBarrelCells = m_hcalExtBarrelCells.get();
debug() << "Input hadronic extended barrel cell collection size: " << hcalExtBarrelCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_hcalExtBarrelSegmentationOK) {
if (hcalExtBarrelCells->size() >0) {
CellsIntoTowers(aTowers, hcalExtBarrelCells, fillTowersCells);
totalNumberOfCells += hcalExtBarrelCells->size();
}
Expand All @@ -250,7 +238,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* hcalEndcapCells = m_hcalEndcapCells.get();
debug() << "Input Hcal endcap cell collection size: " << hcalEndcapCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_hcalEndcapSegmentationOK) {
if (hcalEndcapCells->size() > 0) {
CellsIntoTowers(aTowers, hcalEndcapCells, fillTowersCells);
totalNumberOfCells += hcalEndcapCells->size();
}
Expand All @@ -259,7 +247,7 @@ uint CaloTowerToolFCCee::buildTowers(std::vector<std::vector<float>>& aTowers, b
const edm4hep::CalorimeterHitCollection* hcalFwdCells = m_hcalFwdCells.get();
debug() << "Input Hcal forward cell collection size: " << hcalFwdCells->size() << endmsg;
// Loop over a collection of calorimeter cells and build calo towers
if (m_hcalFwdSegmentationOK) {
if (hcalFwdCells->size()>0) {
CellsIntoTowers(aTowers, hcalFwdCells, fillTowersCells);
totalNumberOfCells += hcalFwdCells->size();
}
Expand Down

0 comments on commit 21f8a41

Please sign in to comment.