diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a52c6a3..662823bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ find_package(Gaudi) find_package(k4FWCore) # implicit: Gaudi find_package(EDM4HEP 0.10.1) # implicit: Podio find_package(DD4hep) -find_package(FCCDetectors) +find_package(k4geo) #--------------------------------------------------------------- diff --git a/README.md b/README.md index f305787b..3a196e6c 100644 --- a/README.md +++ b/README.md @@ -12,5 +12,5 @@ source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh * EDM4HEP * k4FWCore * DD4hep -* FCCDetectors -* FCC-EDM (will be replaced by EDM4HEP) +* k4geo + diff --git a/RecCalorimeter/CMakeLists.txt b/RecCalorimeter/CMakeLists.txt index 934fcd96..e1e117a7 100644 --- a/RecCalorimeter/CMakeLists.txt +++ b/RecCalorimeter/CMakeLists.txt @@ -15,8 +15,8 @@ gaudi_add_module(k4RecCalorimeterPlugins EDM4HEP::edm4hep ROOT::Core ROOT::Hist - FCCDetectors::DetSegmentation - FCCDetectors::DetCommon + k4geo::detectorSegmentations + k4geo::detectorCommon ) install(TARGETS k4RecCalorimeterPlugins diff --git a/RecCalorimeter/src/components/CalibrateCaloHitsTool.h b/RecCalorimeter/src/components/CalibrateCaloHitsTool.h index 5a0da50b..4afc4c47 100644 --- a/RecCalorimeter/src/components/CalibrateCaloHitsTool.h +++ b/RecCalorimeter/src/components/CalibrateCaloHitsTool.h @@ -4,7 +4,7 @@ // from Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4Interface/ICalibrateCaloHitsTool.h" #include diff --git a/RecCalorimeter/src/components/CalibrateInLayersTool.cpp b/RecCalorimeter/src/components/CalibrateInLayersTool.cpp index 743ab8b6..f8ae7437 100644 --- a/RecCalorimeter/src/components/CalibrateInLayersTool.cpp +++ b/RecCalorimeter/src/components/CalibrateInLayersTool.cpp @@ -1,6 +1,6 @@ #include "CalibrateInLayersTool.h" -// FCCSW +// k4FWCore #include "k4Interface/IGeoSvc.h" // DD4hep diff --git a/RecCalorimeter/src/components/CalibrateInLayersTool.h b/RecCalorimeter/src/components/CalibrateInLayersTool.h index a2bfd767..dde6576a 100644 --- a/RecCalorimeter/src/components/CalibrateInLayersTool.h +++ b/RecCalorimeter/src/components/CalibrateInLayersTool.h @@ -5,7 +5,7 @@ #include "GaudiAlg/GaudiTool.h" #include "GaudiKernel/ServiceHandle.h" -// FCCSW +// k4FWCore #include "k4Interface/ICalibrateCaloHitsTool.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/CaloTopoCluster.cpp b/RecCalorimeter/src/components/CaloTopoCluster.cpp index 602c1b39..d8e96a53 100644 --- a/RecCalorimeter/src/components/CaloTopoCluster.cpp +++ b/RecCalorimeter/src/components/CaloTopoCluster.cpp @@ -1,10 +1,12 @@ #include "CaloTopoCluster.h" #include "NoiseCaloCellsFromFileTool.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4FWCore #include "k4Interface/IGeoSvc.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + // datamodel #include "edm4hep/Cluster.h" #include "edm4hep/ClusterCollection.h" diff --git a/RecCalorimeter/src/components/CaloTopoCluster.h b/RecCalorimeter/src/components/CaloTopoCluster.h index fd5d6fdf..d4d8a930 100644 --- a/RecCalorimeter/src/components/CaloTopoCluster.h +++ b/RecCalorimeter/src/components/CaloTopoCluster.h @@ -5,7 +5,7 @@ #include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiKernel/ToolHandle.h" -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4Interface/ICaloReadCellNoiseMap.h" #include "k4Interface/ICaloReadNeighboursMap.h" diff --git a/RecCalorimeter/src/components/CaloTopoClusterInputTool.cpp b/RecCalorimeter/src/components/CaloTopoClusterInputTool.cpp index 079a8de3..04823118 100644 --- a/RecCalorimeter/src/components/CaloTopoClusterInputTool.cpp +++ b/RecCalorimeter/src/components/CaloTopoClusterInputTool.cpp @@ -1,9 +1,9 @@ #include "CaloTopoClusterInputTool.h" -// FCCSW +// k4FWCore #include "k4Interface/IGeoSvc.h" -// datamodel +// edm4hep #include "edm4hep/CalorimeterHit.h" #include "edm4hep/CalorimeterHitCollection.h" diff --git a/RecCalorimeter/src/components/CaloTopoClusterInputTool.h b/RecCalorimeter/src/components/CaloTopoClusterInputTool.h index 2c8fa5d8..c67b91c3 100644 --- a/RecCalorimeter/src/components/CaloTopoClusterInputTool.h +++ b/RecCalorimeter/src/components/CaloTopoClusterInputTool.h @@ -3,7 +3,7 @@ // from Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4Interface/ITopoClusterInputTool.h" @@ -77,7 +77,8 @@ class CaloTopoClusterInputTool : public GaudiTool, virtual public ITopoClusterIn Gaudi::Property m_ecalEndcapReadoutName{this, "ecalEndcapReadoutName", "", "name of the ecal endcap readout"}; /// Name of the ecal forward calorimeter readout - Gaudi::Property m_ecalFwdReadoutName{this, "ecalFwdReadoutName", "", "name of the ecal fwd readout"}; + Gaudi::Property m_ecalFwdReadoutName{this, "ecalFwdReadoutName", "", + "name of the ecal fwd readout"}; /// Name of the hadronic barrel readout Gaudi::Property m_hcalBarrelReadoutName{this, "hcalBarrelReadoutName", "", "name of the hcal barrel readout"}; diff --git a/RecCalorimeter/src/components/CaloTowerTool.cpp b/RecCalorimeter/src/components/CaloTowerTool.cpp index ee1d0596..4e7044c9 100644 --- a/RecCalorimeter/src/components/CaloTowerTool.cpp +++ b/RecCalorimeter/src/components/CaloTowerTool.cpp @@ -1,9 +1,9 @@ #include "CaloTowerTool.h" -// FCCSW +// k4FWCore #include "k4Interface/IGeoSvc.h" -// datamodel +// edm4hep #include "edm4hep/CalorimeterHitCollection.h" #include "edm4hep/Cluster.h" #include "edm4hep/MutableCluster.h" @@ -113,12 +113,12 @@ StatusCode CaloTowerTool::finalize() { std::pair CaloTowerTool::retrievePhiEtaExtrema(dd4hep::DDSegmentation::Segmentation* aSegmentation, SegmentationType aType) { double phiMax = -1; double etaMax = -1; - dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation = nullptr; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation = nullptr; if (aSegmentation != nullptr) { switch (aType) { case SegmentationType::kPhiEta: { info() << "== Retrieving phi-eta segmentation " << aSegmentation->name() << endmsg; - segmentation = dynamic_cast(aSegmentation); + segmentation = dynamic_cast(aSegmentation); phiMax = fabs(segmentation->offsetPhi()) + M_PI / (double)segmentation->phiBins(); etaMax = fabs(segmentation->offsetEta()) + segmentation->gridSizeEta() * 0.5; break; @@ -128,7 +128,7 @@ std::pair CaloTowerTool::retrievePhiEtaExtrema(dd4hep::DDSegment double eta = -1; info() << "== Retrieving multi segmentation " << aSegmentation->name() << endmsg; for (const auto& subSegm: dynamic_cast(aSegmentation)->subSegmentations()) { - segmentation = dynamic_cast(subSegm.segmentation); + segmentation = dynamic_cast(subSegm.segmentation); phi = fabs(segmentation->offsetPhi()) + M_PI / (double)segmentation->phiBins(); eta = fabs(segmentation->offsetEta()) + segmentation->gridSizeEta() * 0.5; if (eta > etaMax) { etaMax = eta;} @@ -320,10 +320,10 @@ void CaloTowerTool::CellsIntoTowers(std::vector>& aTowers, float fracEtaMin = 1.0, fracEtaMax = 1.0, fracEtaMiddle = 1.0; float fracPhiMin = 1.0, fracPhiMax = 1.0, fracPhiMiddle = 1.0; float epsilon = 0.0001; - const dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation = nullptr; + const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation = nullptr; const dd4hep::DDSegmentation::MultiSegmentation* multisegmentation = nullptr; if( aType == SegmentationType::kPhiEta) { - segmentation = dynamic_cast(aSegmentation); + segmentation = dynamic_cast(aSegmentation); } else if( aType == SegmentationType::kMulti) { multisegmentation = dynamic_cast(aSegmentation); } @@ -332,7 +332,7 @@ void CaloTowerTool::CellsIntoTowers(std::vector>& aTowers, pass = true; // if multisegmentation is used - first find out which segmentation to use if( aType == SegmentationType::kMulti) { - segmentation = dynamic_cast(&multisegmentation->subsegmentation(cell.getCellID())); + segmentation = dynamic_cast(&multisegmentation->subsegmentation(cell.getCellID())); } if (m_useHalfTower) { uint layerId = m_decoder->get(cell.getCellID(), "layer"); @@ -416,7 +416,7 @@ std::pair( + segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(aReadoutName).segmentation().segmentation()); if (segmentation == nullptr) { segmentation = dynamic_cast( @@ -427,7 +427,7 @@ std::pair(segmentation)->subSegmentations()) { - subsegmentation = dynamic_cast(subSegm.segmentation); + subsegmentation = dynamic_cast(subSegm.segmentation); if (subsegmentation == nullptr) { error() << "At least one of the sub-segmentations in MultiSegmentation named " << aReadoutName << " is not a phi-eta grid." << endmsg; return std::make_pair(nullptr, SegmentationType::kWrong); diff --git a/RecCalorimeter/src/components/CaloTowerTool.h b/RecCalorimeter/src/components/CaloTowerTool.h index a47f7ec5..cb014790 100644 --- a/RecCalorimeter/src/components/CaloTowerTool.h +++ b/RecCalorimeter/src/components/CaloTowerTool.h @@ -4,20 +4,16 @@ // from Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW -#include "DetSegmentation/FCCSWGridPhiEta.h" +// k4geo +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" + +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4Interface/ITowerTool.h" - class IGeoSvc; -#include "DDSegmentation/MultiSegmentation.h" -// datamodel -namespace edm4hep { -class CalorimeterHitCollection; -class CalorimeterHit; -class Cluster; -} +// dd4hep +#include "DDSegmentation/MultiSegmentation.h" namespace dd4hep { namespace DDSegmentation { @@ -26,6 +22,14 @@ class BitFieldCoder; } } +// edm4hep +namespace edm4hep { +class CalorimeterHitCollection; +class CalorimeterHit; +class Cluster; +} + + /** @class CaloTowerTool Reconstruction/RecCalorimeter/src/components/CaloTowerTool.h * CaloTowerTool.h * diff --git a/RecCalorimeter/src/components/ConeSelection.cpp b/RecCalorimeter/src/components/ConeSelection.cpp index 9214abe8..ad7a28fb 100644 --- a/RecCalorimeter/src/components/ConeSelection.cpp +++ b/RecCalorimeter/src/components/ConeSelection.cpp @@ -1,7 +1,7 @@ #include "ConeSelection.h" // FCC Detectors -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" // DD4hep #include "DD4hep/Detector.h" diff --git a/RecCalorimeter/src/components/ConstNoiseTool.cpp b/RecCalorimeter/src/components/ConstNoiseTool.cpp index 591a86b6..7c64d9f1 100644 --- a/RecCalorimeter/src/components/ConstNoiseTool.cpp +++ b/RecCalorimeter/src/components/ConstNoiseTool.cpp @@ -1,7 +1,9 @@ #include "ConstNoiseTool.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" // DD4hep diff --git a/RecCalorimeter/src/components/ConstNoiseTool.h b/RecCalorimeter/src/components/ConstNoiseTool.h index 2b6350e7..bc62195f 100644 --- a/RecCalorimeter/src/components/ConstNoiseTool.h +++ b/RecCalorimeter/src/components/ConstNoiseTool.h @@ -5,8 +5,10 @@ #include "GaudiAlg/GaudiTool.h" class IRndmGenSvc; -// FCCSW -#include "DetSegmentation/FCCSWGridPhiEta.h" +// k4geo +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" + +// k4FWCore #include "k4Interface/INoiseConstTool.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/CorrectCaloClusters.cpp b/RecCalorimeter/src/components/CorrectCaloClusters.cpp index fb24e5c9..adb1bccb 100644 --- a/RecCalorimeter/src/components/CorrectCaloClusters.cpp +++ b/RecCalorimeter/src/components/CorrectCaloClusters.cpp @@ -7,8 +7,8 @@ #include "k4Interface/IGeoSvc.h" // FCC Detectors -#include "DetCommon/DetUtils.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" +#include "detectorCommon/DetUtils_k4geo.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" // DD4hep #include "DD4hep/Detector.h" diff --git a/RecCalorimeter/src/components/CorrectCaloClusters.h b/RecCalorimeter/src/components/CorrectCaloClusters.h index c5a29d2d..6696ce71 100644 --- a/RecCalorimeter/src/components/CorrectCaloClusters.h +++ b/RecCalorimeter/src/components/CorrectCaloClusters.h @@ -29,7 +29,7 @@ namespace edm4hep { // DD4HEP namespace dd4hep { namespace DDSegmentation { - class FCCSWGridPhiEta; + class FCCSWGridPhiEta_k4geo; class MultiSegmentation; class BitFieldCoder; } diff --git a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp index 66cb5c03..b587809b 100644 --- a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp +++ b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp @@ -1,28 +1,32 @@ #include "CorrectECalBarrelSliWinCluster.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" + +// Gaudi #include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/MsgStream.h" // DD4hep #include "DD4hep/Detector.h" #include "DDSegmentation/MultiSegmentation.h" -// our EDM4HEP +// edm4hep #include "edm4hep/Cluster.h" #include "edm4hep/ClusterCollection.h" #include "edm4hep/CalorimeterHitCollection.h" #include "edm4hep/MCParticleCollection.h" #include "edm4hep/VertexCollection.h" -// Root +// ROOT #include "TFile.h" #include "TLorentzVector.h" #include "TFitResult.h" #include "TGraphErrors.h" -#include DECLARE_COMPONENT(CorrectECalBarrelSliWinCluster) @@ -147,7 +151,7 @@ StatusCode CorrectECalBarrelSliWinCluster::initialize() { return StatusCode::FAILURE; } // retrieve PhiEta segmentation - m_segmentationPhiEta[m_systemId[iSys]] = dynamic_cast( + m_segmentationPhiEta[m_systemId[iSys]] = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName[iSys]).segmentation().segmentation()); m_segmentationMulti[m_systemId[iSys]] = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName[iSys]).segmentation().segmentation()); @@ -235,7 +239,7 @@ StatusCode CorrectECalBarrelSliWinCluster::execute() { // TODO change that so all systems can be used uint systemId = m_systemId[0]; - const dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation = nullptr; + const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation = nullptr; if (m_segmentationPhiEta[systemId] != nullptr) { segmentation = m_segmentationPhiEta[systemId]; } @@ -267,7 +271,7 @@ StatusCode CorrectECalBarrelSliWinCluster::execute() { newCluster.setPosition(cluster.getPosition()); for (auto cell = cluster.hits_begin(); cell != cluster.hits_end(); cell++) { if (m_segmentationMulti[systemId] != nullptr) { - segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); + segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); oldEtaId = int(floor((oldEta + 0.5 * segmentation->gridSizeEta() - segmentation->offsetEta()) / segmentation->gridSizeEta())); oldPhiId = int(floor((oldPhi + 0.5 * segmentation->gridSizePhi() - segmentation->offsetPhi()) / segmentation->gridSizePhi())); } @@ -319,7 +323,7 @@ StatusCode CorrectECalBarrelSliWinCluster::execute() { // repeat but calculating eta barycentre in each layer for (auto cell = newCluster.hits_begin(); cell != newCluster.hits_end(); cell++) { if (m_segmentationMulti[systemId] != nullptr) { - segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); + segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); } dd4hep::DDSegmentation::CellID cID = cell->getCellID(); uint layer = m_decoder[systemId]->get(cID, m_layerFieldName) + m_firstLayerId; diff --git a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h index 74746056..f26401fc 100644 --- a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h +++ b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h @@ -22,7 +22,7 @@ class VertexCollection; namespace dd4hep { namespace DDSegmentation { -class FCCSWGridPhiEta; +class FCCSWGridPhiEta_k4geo; class MultiSegmentation; class BitFieldCoder; } @@ -153,7 +153,7 @@ class CorrectECalBarrelSliWinCluster : public GaudiAlgorithm { Gaudi::Property> m_readoutName{ this, "readoutName", {"ECalBarrelPhiEta"}, "Names of the detector readout, corresponding to systemId"}; /// map of system Id to segmentation, created based on m_readoutName and m_systemId - std::map m_segmentationPhiEta; + std::map m_segmentationPhiEta; std::map m_segmentationMulti; /// map of system Id to decoder, created based on m_readoutName and m_systemId std::map m_decoder; diff --git a/RecCalorimeter/src/components/CreateCaloCells.cpp b/RecCalorimeter/src/components/CreateCaloCells.cpp index cc12b1a4..59139bc5 100644 --- a/RecCalorimeter/src/components/CreateCaloCells.cpp +++ b/RecCalorimeter/src/components/CreateCaloCells.cpp @@ -1,7 +1,9 @@ #include "CreateCaloCells.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" // DD4hep @@ -9,7 +11,7 @@ #include "DD4hep/Volumes.h" #include "TGeoManager.h" -// EDM4HEP +// edm4hep #include "edm4hep/CalorimeterHit.h" DECLARE_COMPONENT(CreateCaloCells) diff --git a/RecCalorimeter/src/components/CreateCaloCells.h b/RecCalorimeter/src/components/CreateCaloCells.h index fe0afc52..2606bc1c 100644 --- a/RecCalorimeter/src/components/CreateCaloCells.h +++ b/RecCalorimeter/src/components/CreateCaloCells.h @@ -1,7 +1,7 @@ #ifndef RECCALORIMETER_CREATECALOCELLS_H #define RECCALORIMETER_CREATECALOCELLS_H -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4FWCore/MetaDataHandle.h" #include "k4Interface/ICalibrateCaloHitsTool.h" @@ -12,7 +12,7 @@ #include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiKernel/ToolHandle.h" -// EDM4HEP +// edm4hep #include "edm4hep/CalorimeterHitCollection.h" #include "edm4hep/SimCalorimeterHitCollection.h" #include "edm4hep/Constants.h" diff --git a/RecCalorimeter/src/components/CreateCaloCellsNoise.cpp b/RecCalorimeter/src/components/CreateCaloCellsNoise.cpp index 3ca52015..d44d8243 100644 --- a/RecCalorimeter/src/components/CreateCaloCellsNoise.cpp +++ b/RecCalorimeter/src/components/CreateCaloCellsNoise.cpp @@ -1,12 +1,16 @@ #include "CreateCaloCellsNoise.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" // DD4hep #include "DD4hep/Detector.h" #include "DD4hep/Volumes.h" + +// ROOT #include "TGeoManager.h" // EDM4HEP diff --git a/RecCalorimeter/src/components/CreateCaloCellsNoise.h b/RecCalorimeter/src/components/CreateCaloCellsNoise.h index 3ec81f01..9aedacce 100644 --- a/RecCalorimeter/src/components/CreateCaloCellsNoise.h +++ b/RecCalorimeter/src/components/CreateCaloCellsNoise.h @@ -1,7 +1,7 @@ #ifndef RECCALORIMETER_CREATECALOCELLSNOISE_H #define RECCALORIMETER_CREATECALOCELLSNOISE_H -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4Interface/ICalibrateCaloHitsTool.h" #include "k4Interface/ICalorimeterTool.h" @@ -18,6 +18,8 @@ // DD4hep #include "DD4hep/Detector.h" #include "DD4hep/Volumes.h" + +// ROOT #include "TGeoManager.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/CreateCaloClusters.cpp b/RecCalorimeter/src/components/CreateCaloClusters.cpp index 38ae17bc..4a37ff25 100644 --- a/RecCalorimeter/src/components/CreateCaloClusters.cpp +++ b/RecCalorimeter/src/components/CreateCaloClusters.cpp @@ -4,7 +4,7 @@ #include "k4Interface/IGeoSvc.h" // FCC Detectors -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" // DD4hep #include "DD4hep/Detector.h" diff --git a/RecCalorimeter/src/components/CreateCaloClustersSlidingWindow.h b/RecCalorimeter/src/components/CreateCaloClustersSlidingWindow.h index 7fca912f..6ef7836b 100644 --- a/RecCalorimeter/src/components/CreateCaloClustersSlidingWindow.h +++ b/RecCalorimeter/src/components/CreateCaloClustersSlidingWindow.h @@ -5,11 +5,11 @@ #include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiKernel/ToolHandle.h" -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4Interface/ITowerTool.h" -// datamodel +// edm4hep namespace edm4hep { class ClusterCollection; } diff --git a/RecCalorimeter/src/components/CreateEmptyCaloCellsCollection.h b/RecCalorimeter/src/components/CreateEmptyCaloCellsCollection.h index b26811e8..ace72737 100644 --- a/RecCalorimeter/src/components/CreateEmptyCaloCellsCollection.h +++ b/RecCalorimeter/src/components/CreateEmptyCaloCellsCollection.h @@ -1,14 +1,14 @@ #ifndef RECCALORIMETER_CREATEEMPTYCALOCELLSCOLLECTION_H #define RECCALORIMETER_CREATEEMPTYCALOCELLSCOLLECTION_H -//FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" // Gaudi #include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiKernel/ToolHandle.h" -//EDM +// edm4hep #include "edm4hep/CalorimeterHitCollection.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/LayerPhiEtaCaloTool.cpp b/RecCalorimeter/src/components/LayerPhiEtaCaloTool.cpp index 45465ebe..cb1c25ba 100644 --- a/RecCalorimeter/src/components/LayerPhiEtaCaloTool.cpp +++ b/RecCalorimeter/src/components/LayerPhiEtaCaloTool.cpp @@ -2,7 +2,7 @@ // segm #include "DD4hep/Detector.h" -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" DECLARE_COMPONENT(LayerPhiEtaCaloTool) @@ -48,16 +48,16 @@ StatusCode LayerPhiEtaCaloTool::prepareEmptyCells(std::unordered_map( + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation; + segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; return StatusCode::FAILURE; } - info() << "FCCSWGridPhiEta: size in eta " << segmentation->gridSizeEta() << " , bins in phi " << segmentation->phiBins() + info() << "FCCSWGridPhiEta_k4geo: size in eta " << segmentation->gridSizeEta() << " , bins in phi " << segmentation->phiBins() << endmsg; - info() << "FCCSWGridPhiEta: offset in eta " << segmentation->offsetEta() << " , offset in phi " + info() << "FCCSWGridPhiEta_k4geo: offset in eta " << segmentation->offsetEta() << " , offset in phi " << segmentation->offsetPhi() << endmsg; // Take readout bitfield decoder from GeoSvc diff --git a/RecCalorimeter/src/components/LayerPhiEtaCaloTool.h b/RecCalorimeter/src/components/LayerPhiEtaCaloTool.h index a9816019..b15cc756 100644 --- a/RecCalorimeter/src/components/LayerPhiEtaCaloTool.h +++ b/RecCalorimeter/src/components/LayerPhiEtaCaloTool.h @@ -1,10 +1,10 @@ #ifndef RECCALORIMETER_TUBELAYERPHIETACALOTOOL_H #define RECCALORIMETER_TUBELAYERPHIETACALOTOOL_H -// from Gaudi +// Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4Interface/ICalorimeterTool.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/LayeredCaloTowerTool.cpp b/RecCalorimeter/src/components/LayeredCaloTowerTool.cpp index 8cb148cb..5a8d33cc 100644 --- a/RecCalorimeter/src/components/LayeredCaloTowerTool.cpp +++ b/RecCalorimeter/src/components/LayeredCaloTowerTool.cpp @@ -37,7 +37,7 @@ StatusCode LayeredCaloTowerTool::initialize() { return StatusCode::FAILURE; } // retrieve PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation." << endmsg; diff --git a/RecCalorimeter/src/components/LayeredCaloTowerTool.h b/RecCalorimeter/src/components/LayeredCaloTowerTool.h index 10c16859..240a7e37 100644 --- a/RecCalorimeter/src/components/LayeredCaloTowerTool.h +++ b/RecCalorimeter/src/components/LayeredCaloTowerTool.h @@ -1,22 +1,25 @@ #ifndef RECCALORIMETER_LAYEREDCALOTOWERTOOL_H #define RECCALORIMETER_LAYEREDCALOTOWERTOOL_H -// from Gaudi +// Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW -#include "DetSegmentation/FCCSWGridPhiEta.h" +// k4geo +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" + +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4Interface/ITowerTool.h" class IGeoSvc; -// datamodel +// edm4hep namespace edm4hep { class CalorimeterHitCollection; class Cluster; class MutableCluster; } +// DD4hep namespace dd4hep { namespace DDSegmentation { class Segmentation; @@ -137,7 +140,7 @@ class LayeredCaloTowerTool : public GaudiTool, virtual public ITowerTool { /// Name of the detector readout Gaudi::Property m_readoutName{this, "readoutName", "", "Name of the detector readout"}; /// PhiEta segmentation (owned by DD4hep) - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; /// Radius used to calculate cluster position from eta and phi (in mm) Gaudi::Property m_radius{this, "radiusForPosition", 1.0, "Radius used to calculate cluster position from eta and phi (in mm)"}; diff --git a/RecCalorimeter/src/components/MassInv.cpp b/RecCalorimeter/src/components/MassInv.cpp index 98974e5f..3c87b8f1 100644 --- a/RecCalorimeter/src/components/MassInv.cpp +++ b/RecCalorimeter/src/components/MassInv.cpp @@ -6,9 +6,9 @@ // Key4HEP #include "k4Interface/IGeoSvc.h" -// FCC Detectors -#include "DetCommon/DetUtils.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" // DD4hep #include "DD4hep/Detector.h" @@ -308,7 +308,7 @@ StatusCode MassInv::initialize() { return StatusCode::FAILURE; } // retrieve PhiEta segmentation - m_segmentationPhiEta[m_systemId[iSys]] = dynamic_cast( + m_segmentationPhiEta[m_systemId[iSys]] = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName[iSys]).segmentation().segmentation()); m_segmentationMulti[m_systemId[iSys]] = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName[iSys]).segmentation().segmentation()); @@ -405,7 +405,7 @@ StatusCode MassInv::execute() { // TODO change that so all systems can be used uint systemId = m_systemId[0]; - const dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation = nullptr; + const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation = nullptr; if (m_segmentationPhiEta[systemId] != nullptr) { segmentation = m_segmentationPhiEta[systemId]; } @@ -441,7 +441,7 @@ StatusCode MassInv::execute() { newCluster.setPosition(cluster.getPosition()); for (auto cell = cluster.hits_begin(); cell != cluster.hits_end(); cell++) { if (m_segmentationMulti[systemId] != nullptr) { - segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); + segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); oldEtaId = int(floor((oldEta + 0.5 * segmentation->gridSizeEta() - segmentation->offsetEta()) / segmentation->gridSizeEta())); oldPhiId = int(floor((oldPhi + 0.5 * segmentation->gridSizePhi() - segmentation->offsetPhi()) / segmentation->gridSizePhi())); } @@ -488,7 +488,7 @@ StatusCode MassInv::execute() { // repeat but calculating eta barycentre in each layer for (auto cell = newCluster.hits_begin(); cell != newCluster.hits_end(); cell++) { if (m_segmentationMulti[systemId] != nullptr) { - segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); + segmentation = dynamic_cast(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID())); } dd4hep::DDSegmentation::CellID cID = cell->getCellID(); uint layer = m_decoder[systemId]->get(cID, m_layerFieldName) + m_firstLayerId; diff --git a/RecCalorimeter/src/components/MassInv.h b/RecCalorimeter/src/components/MassInv.h index 4f35615d..833b6763 100644 --- a/RecCalorimeter/src/components/MassInv.h +++ b/RecCalorimeter/src/components/MassInv.h @@ -22,7 +22,7 @@ namespace edm4hep { namespace dd4hep { namespace DDSegmentation { -class FCCSWGridPhiEta; +class FCCSWGridPhiEta_k4geo; class MultiSegmentation; class BitFieldCoder; } @@ -186,7 +186,7 @@ class MassInv : public GaudiAlgorithm { Gaudi::Property> m_readoutName{ this, "readoutName", {"ECalBarrelPhiEta"}, "Names of the detector readout, corresponding to systemId"}; /// map of system Id to segmentation, created based on m_readoutName and m_systemId - std::map m_segmentationPhiEta; + std::map m_segmentationPhiEta; std::map m_segmentationMulti; /// map of system Id to decoder, created based on m_readoutName and m_systemId std::map m_decoder; diff --git a/RecCalorimeter/src/components/NestedVolumesCaloTool.cpp b/RecCalorimeter/src/components/NestedVolumesCaloTool.cpp index 86efba55..5d78d777 100644 --- a/RecCalorimeter/src/components/NestedVolumesCaloTool.cpp +++ b/RecCalorimeter/src/components/NestedVolumesCaloTool.cpp @@ -2,7 +2,7 @@ // segm #include "DD4hep/Detector.h" -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" DECLARE_COMPONENT(NestedVolumesCaloTool) diff --git a/RecCalorimeter/src/components/NestedVolumesCaloTool.h b/RecCalorimeter/src/components/NestedVolumesCaloTool.h index 33749894..5c33899e 100644 --- a/RecCalorimeter/src/components/NestedVolumesCaloTool.h +++ b/RecCalorimeter/src/components/NestedVolumesCaloTool.h @@ -1,10 +1,10 @@ #ifndef RECCALORIMETER_NESTEDVOLUMESCALOTOOL_H #define RECCALORIMETER_NESTEDVOLUMESCALOTOOL_H -// from Gaudi +// Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4Interface/ICalorimeterTool.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h index a4df3676..aa5ee8f3 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h +++ b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h @@ -1,13 +1,12 @@ #ifndef RECCALORIMETER_NOISECALOCELLSFLATTOOL_H #define RECCALORIMETER_NOISECALOCELLSFLATTOOL_H -// from Gaudi +// Gaudi #include "GaudiAlg/GaudiTool.h" #include "GaudiKernel/RndmGenerators.h" #include "GaudiKernel/IRndmGenSvc.h" -//class IRndmGenSvc; -// FCCSW +// k4FWCore #include "k4Interface/INoiseCaloCellsTool.h" /** @class NoiseCaloCellsFlatTool diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp index 2666625d..e44edbd3 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp +++ b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp @@ -1,13 +1,15 @@ #include "NoiseCaloCellsFromFileTool.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" // DD4hep #include "DD4hep/Detector.h" -// Root +// ROOT #include "TFile.h" #include "TH1F.h" #include "TMath.h" @@ -50,7 +52,7 @@ StatusCode NoiseCaloCellsFromFileTool::initialize() { if (!m_cellPositionsTool.retrieve() and !m_useSeg) { info() << "Unable to retrieve cell positions tool, try eta-phi segmentation." << endmsg; // Get PhiEta segmentation - m_segmentationPhiEta = dynamic_cast( + m_segmentationPhiEta = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentationPhiEta == nullptr) { error() << "There is no phi-eta segmentation." << endmsg; @@ -60,7 +62,7 @@ StatusCode NoiseCaloCellsFromFileTool::initialize() { info() << "Found phi-eta segmentation." << endmsg; } // Get PhiEta segmentation - m_segmentationPhiEta = dynamic_cast( + m_segmentationPhiEta = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentationPhiEta == nullptr) { m_segmentationMulti = dynamic_cast( @@ -70,9 +72,9 @@ StatusCode NoiseCaloCellsFromFileTool::initialize() { return StatusCode::FAILURE; } else { // check if multisegmentation contains only phi-eta sub-segmentations - const dd4hep::DDSegmentation::FCCSWGridPhiEta* subsegmentation = nullptr; + const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* subsegmentation = nullptr; for (const auto& subSegm: m_segmentationMulti->subSegmentations()) { - subsegmentation = dynamic_cast(subSegm.segmentation); + subsegmentation = dynamic_cast(subSegm.segmentation); if (subsegmentation == nullptr) { error() << "At least one of the sub-segmentations in MultiSegmentation named " << m_readoutName << " is not a phi-eta grid." << endmsg; return StatusCode::FAILURE; @@ -168,9 +170,9 @@ StatusCode NoiseCaloCellsFromFileTool::initNoiseFromFile() { } double NoiseCaloCellsFromFileTool::getNoiseConstantPerCell(int64_t aCellId) { - const dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation = m_segmentationPhiEta; + const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation = m_segmentationPhiEta; if (segmentation == nullptr) { - segmentation = dynamic_cast(&m_segmentationMulti->subsegmentation(aCellId)); + segmentation = dynamic_cast(&m_segmentationMulti->subsegmentation(aCellId)); } double elecNoise = 0.; diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h index 23bb0732..237b3d1e 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h +++ b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h @@ -6,8 +6,10 @@ #include "GaudiKernel/RndmGenerators.h" #include "GaudiKernel/IRndmGenSvc.h" -// FCCSW -#include "DetSegmentation/FCCSWGridPhiEta.h" +// k4geo +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" + +// k4FWCore #include "k4Interface/INoiseCaloCellsTool.h" #include "k4Interface/ICellPositionsTool.h" class IGeoSvc; @@ -95,7 +97,7 @@ class NoiseCaloCellsFromFileTool : public GaudiTool, virtual public INoiseCaloCe /// Pointer to the geometry service ServiceHandle m_geoSvc; /// PhiEta segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentationPhiEta; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentationPhiEta; /// Multi segmentation dd4hep::DDSegmentation::MultiSegmentation* m_segmentationMulti; diff --git a/RecCalorimeter/src/components/PreparePileup.cpp b/RecCalorimeter/src/components/PreparePileup.cpp index 884c5dd0..e9024290 100644 --- a/RecCalorimeter/src/components/PreparePileup.cpp +++ b/RecCalorimeter/src/components/PreparePileup.cpp @@ -42,7 +42,7 @@ StatusCode PreparePileup::initialize() { return StatusCode::FAILURE; } // retrieve PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation." << endmsg; diff --git a/RecCalorimeter/src/components/PreparePileup.h b/RecCalorimeter/src/components/PreparePileup.h index f7a993d8..ebf0561f 100644 --- a/RecCalorimeter/src/components/PreparePileup.h +++ b/RecCalorimeter/src/components/PreparePileup.h @@ -8,7 +8,7 @@ class IGeoSvc; // FCC Detectors -#include "DetSegmentation/FCCSWGridPhiEta.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" // Gaudi #include "GaudiAlg/GaudiAlgorithm.h" @@ -118,7 +118,7 @@ class PreparePileup : public GaudiAlgorithm { // Recalculatee to half size N (window size = 2*N+1) std::vector m_halfEtaFin; /// PhiEta segmentation (owned by DD4hep) - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; dd4hep::DDSegmentation::BitFieldCoder* m_decoder; /// Sum of energy of optimised cluster centred around each eta/phi cell std::vector> m_energyOptimised; diff --git a/RecCalorimeter/src/components/ReadNoiseFromFileTool.cpp b/RecCalorimeter/src/components/ReadNoiseFromFileTool.cpp index 032b88b9..8b2a0c92 100644 --- a/RecCalorimeter/src/components/ReadNoiseFromFileTool.cpp +++ b/RecCalorimeter/src/components/ReadNoiseFromFileTool.cpp @@ -1,15 +1,17 @@ #include "ReadNoiseFromFileTool.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" -#include "DDSegmentation/Segmentation.h" // DD4hep #include "DD4hep/Detector.h" #include "DD4hep/Readout.h" +#include "DDSegmentation/Segmentation.h" -// Root +// ROOT #include "TFile.h" #include "TH1F.h" #include "TMath.h" @@ -29,7 +31,7 @@ StatusCode ReadNoiseFromFileTool::initialize() { << "Make sure you have GeoSvc and SimSvc in the right order in the configuration." << endmsg; return StatusCode::FAILURE; } - m_segmentation = dynamic_cast(m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); + m_segmentation = dynamic_cast(m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; return StatusCode::FAILURE; diff --git a/RecCalorimeter/src/components/ReadNoiseFromFileTool.h b/RecCalorimeter/src/components/ReadNoiseFromFileTool.h index fbbc55b0..9fa5e1cc 100644 --- a/RecCalorimeter/src/components/ReadNoiseFromFileTool.h +++ b/RecCalorimeter/src/components/ReadNoiseFromFileTool.h @@ -5,13 +5,15 @@ #include "GaudiAlg/GaudiTool.h" #include "GaudiKernel/ToolHandle.h" -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" #include "k4Interface/ICalorimeterTool.h" #include "k4Interface/INoiseConstTool.h" #include "k4Interface/ICellPositionsTool.h" +// k4geo +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" + class IGeoSvc; // Root @@ -86,7 +88,7 @@ class ReadNoiseFromFileTool : public GaudiTool, virtual public INoiseConstTool { /// Pointer to the geometry service SmartIF m_geoSvc; /// PhiEta segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; // Decoder dd4hep::DDSegmentation::BitFieldCoder* m_decoder; diff --git a/RecCalorimeter/src/components/SplitClusters.cpp b/RecCalorimeter/src/components/SplitClusters.cpp index 41b32195..f169eac9 100644 --- a/RecCalorimeter/src/components/SplitClusters.cpp +++ b/RecCalorimeter/src/components/SplitClusters.cpp @@ -4,7 +4,7 @@ #include "k4Interface/IGeoSvc.h" // FCC Detectors -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" // DD4hep #include "DD4hep/Detector.h" diff --git a/RecCalorimeter/src/components/TopoCaloNeighbours.h b/RecCalorimeter/src/components/TopoCaloNeighbours.h index 9cd70f61..bafd3807 100644 --- a/RecCalorimeter/src/components/TopoCaloNeighbours.h +++ b/RecCalorimeter/src/components/TopoCaloNeighbours.h @@ -4,7 +4,7 @@ // from Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4Interface/ICaloReadNeighboursMap.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/TopoCaloNoisyCells.h b/RecCalorimeter/src/components/TopoCaloNoisyCells.h index 5fe2357f..af191678 100644 --- a/RecCalorimeter/src/components/TopoCaloNoisyCells.h +++ b/RecCalorimeter/src/components/TopoCaloNoisyCells.h @@ -4,7 +4,7 @@ // from Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4Interface/ICaloReadCellNoiseMap.h" class IGeoSvc; diff --git a/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.cpp b/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.cpp index 0553ec8c..33953024 100644 --- a/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.cpp +++ b/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.cpp @@ -3,7 +3,7 @@ // segm #include "DD4hep/Detector.h" #include "DD4hep/MultiSegmentation.h" -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" DECLARE_COMPONENT(TubeLayerPhiEtaCaloTool) @@ -49,9 +49,9 @@ StatusCode TubeLayerPhiEtaCaloTool::prepareEmptyCells(std::unordered_map( + segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (segmentation == nullptr) { segmentationMulti = dynamic_cast( @@ -61,9 +61,9 @@ StatusCode TubeLayerPhiEtaCaloTool::prepareEmptyCells(std::unordered_mapsubSegmentations()) { - subsegmentation = dynamic_cast(subSegm.segmentation); + subsegmentation = dynamic_cast(subSegm.segmentation); if (subsegmentation == nullptr) { error() << "At least one of the sub-segmentations in MultiSegmentation named " << m_readoutName << " is not a phi-eta grid." << endmsg; return StatusCode::FAILURE; @@ -75,9 +75,9 @@ StatusCode TubeLayerPhiEtaCaloTool::prepareEmptyCells(std::unordered_mapgridSizeEta() << " , bins in phi " << segmentation->phiBins() + info() << "FCCSWGridPhiEta_k4geo: size in eta " << segmentation->gridSizeEta() << " , bins in phi " << segmentation->phiBins() << endmsg; - info() << "FCCSWGridPhiEta: offset in eta " << segmentation->offsetEta() << " , offset in phi " + info() << "FCCSWGridPhiEta_k4geo: offset in eta " << segmentation->offsetEta() << " , offset in phi " << segmentation->offsetPhi() << endmsg; } // Take readout bitfield decoder from GeoSvc @@ -100,7 +100,7 @@ StatusCode TubeLayerPhiEtaCaloTool::prepareEmptyCells(std::unordered_mapset(volumeID, "phi", 0); if (segmentationMulti != nullptr) { - segmentation = dynamic_cast(&segmentationMulti->subsegmentation(volumeID)); + segmentation = dynamic_cast(&segmentationMulti->subsegmentation(volumeID)); } // Get number of segmentation cells within the active volume diff --git a/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.h b/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.h index 8205d15a..d00304ad 100644 --- a/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.h +++ b/RecCalorimeter/src/components/TubeLayerPhiEtaCaloTool.h @@ -4,7 +4,7 @@ // from Gaudi #include "GaudiAlg/GaudiTool.h" -// FCCSW +// k4FWCore #include "k4Interface/ICalorimeterTool.h" class IGeoSvc; diff --git a/RecFCCeeCalorimeter/CMakeLists.txt b/RecFCCeeCalorimeter/CMakeLists.txt index 0c7f74ec..2e7bae6c 100644 --- a/RecFCCeeCalorimeter/CMakeLists.txt +++ b/RecFCCeeCalorimeter/CMakeLists.txt @@ -11,8 +11,8 @@ gaudi_add_module(k4RecFCCeeCalorimeterPlugins Gaudi::GaudiKernel DD4hep::DDCore EDM4HEP::edm4hep - FCCDetectors::DetSegmentation - FCCDetectors::DetCommon + k4geo::detectorSegmentations + k4geo::detectorCommon DD4hep::DDG4 ROOT::Core ROOT::Hist diff --git a/RecFCCeeCalorimeter/src/components/CaloTopoClusterFCCee.cpp b/RecFCCeeCalorimeter/src/components/CaloTopoClusterFCCee.cpp index ebeb9d8e..7181aaf3 100644 --- a/RecFCCeeCalorimeter/src/components/CaloTopoClusterFCCee.cpp +++ b/RecFCCeeCalorimeter/src/components/CaloTopoClusterFCCee.cpp @@ -1,11 +1,13 @@ #include "CaloTopoClusterFCCee.h" #include "../../../RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" -// datamodel +// edm4hep #include "edm4hep/Cluster.h" #include "edm4hep/ClusterCollection.h" #include "edm4hep/CalorimeterHit.h" @@ -15,6 +17,7 @@ #include "DD4hep/Detector.h" #include "DD4hep/Readout.h" +// std C++ includes #include #include #include @@ -31,11 +34,11 @@ CaloTopoClusterFCCee::CaloTopoClusterFCCee(const std::string& name, ISvcLocator* declareProperty("neigboursTool", m_neighboursTool, "Handle for tool to retrieve cell neighbours"); declareProperty("positionsECalBarrelTool", m_cellPositionsECalBarrelTool, "Handle for tool to retrieve cell positions in ECal Barrel"); - declareProperty("positionsHCalBarrelTool", m_cellPositionsHCalBarrelTool, + declareProperty("positionsHCalBarrelTool", m_cellPositionsHCalBarrelTool=0, "Handle for tool to retrieve cell positions in HCal Barrel"); - declareProperty("positionsHCalBarrelNoSegTool", m_cellPositionsHCalBarrelNoSegTool, + declareProperty("positionsHCalBarrelNoSegTool", m_cellPositionsHCalBarrelNoSegTool=0, "Handle for tool to retrieve cell positions in HCal Barrel without DD4hep segmentation"); - declareProperty("positionsHCalExtBarrelTool", m_cellPositionsHCalExtBarrelTool, + declareProperty("positionsHCalExtBarrelTool", m_cellPositionsHCalExtBarrelTool=0, "Handle for tool to retrieve cell positions in HCal ext Barrel"); //declareProperty("positionsEMECTool", m_cellPositionsEMECTool, "Handle for tool to retrieve cell positions in EMEC"); //declareProperty("positionsHECTool", m_cellPositionsHECTool, "Handle for tool to retrieve cell positions in HEC"); @@ -44,6 +47,7 @@ CaloTopoClusterFCCee::CaloTopoClusterFCCee(const std::string& name, ISvcLocator* declareProperty("clusters", m_clusterCollection, "Handle for calo clusters (output collection)"); declareProperty("clusterCells", m_clusterCellsCollection, "Handle for clusters (output collection)"); } + StatusCode CaloTopoClusterFCCee::initialize() { if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE; m_geoSvc = service("GeoSvc"); @@ -69,11 +73,16 @@ StatusCode CaloTopoClusterFCCee::initialize() { error() << "Unable to retrieve ECal Barrel cell positions tool!!!" << endmsg; return StatusCode::FAILURE; } - // Check if cell position HCal Barrel tool available - if (!m_cellPositionsHCalBarrelTool.retrieve()) { - error() << "Unable to retrieve HCal Barrel cell positions tool!!!" << endmsg; + // Check if cell position HCal Barrel tool available (if name is set) + if (!m_cellPositionsHCalBarrelTool.empty()) { + if (!m_cellPositionsHCalBarrelTool.retrieve()) { + error() << "Unable to retrieve HCal Barrel cell positions tool!!!" << endmsg; + return StatusCode::FAILURE; + } + } + if (!m_cellPositionsHCalBarrelNoSegTool.empty()) { if (!m_cellPositionsHCalBarrelNoSegTool.retrieve()) { - error() << "Also unable to retrieve HCal Barrel no segmentation cell positions tool!!!" << endmsg; + error() << "Unable to retrieve HCal Barrel no segmentation cell positions tool!!!" << endmsg; return StatusCode::FAILURE; } } @@ -85,7 +94,7 @@ StatusCode CaloTopoClusterFCCee::initialize() { } StatusCode CaloTopoClusterFCCee::execute() { - + //std::unordered_map allCells; // transform it into a member variable to avoid // recreating such a huge map at every event. Only update the energy values std::vector> firstSeeds; @@ -148,7 +157,7 @@ StatusCode CaloTopoClusterFCCee::execute() { for (auto pair : i.second) { dd4hep::DDSegmentation::CellID cID = pair.first; - // auto cellID = pair.first; + // auto cellID = pair.first; // get CalorimeterHit by cellID auto newCell = edmClusterCells->create(); newCell.setEnergy(m_allCells[cID]); @@ -165,10 +174,10 @@ StatusCode CaloTopoClusterFCCee::execute() { posCell = m_cellPositionsECalBarrelTool->xyzPosition(cID); else if (systemId == 8){ // HCAL BARREL system id if (m_noSegmentationHCalUsed) - posCell = m_cellPositionsHCalBarrelNoSegTool->xyzPosition(cID); - else - posCell = m_cellPositionsHCalBarrelTool->xyzPosition(cID); - } + posCell = m_cellPositionsHCalBarrelNoSegTool->xyzPosition(cID); + else + posCell = m_cellPositionsHCalBarrelTool->xyzPosition(cID); + } //else if (systemId == 9) // HCAL EXT BARREL system id // posCell = m_cellPositionsHCalExtBarrelTool->xyzPosition(cID); //else if (systemId == 6) // EMEC system id @@ -182,6 +191,7 @@ StatusCode CaloTopoClusterFCCee::execute() { else warning() << "No cell positions tool found for system id " << systemId << ". " << endmsg; + newCell.setPosition(edm4hep::Vector3f(posCell.X(), posCell.Y(), posCell.Z())); posX += posCell.X() * newCell.getEnergy(); posY += posCell.Y() * newCell.getEnergy(); posZ += posCell.Z() * newCell.getEnergy(); @@ -195,7 +205,7 @@ StatusCode CaloTopoClusterFCCee::execute() { auto er = m_allCells.erase(cID); if (er!=1) - info() << "Problem in erasing cell ID from map." << endmsg; + info() << "Problem in erasing cell ID from map." << endmsg; } cluster.setEnergy(energy); cluster.setPosition(edm4hep::Vector3f(posX / energy, posY / energy, posZ / energy)); @@ -220,7 +230,7 @@ StatusCode CaloTopoClusterFCCee::execute() { vecEnergy.clear(); } - + m_clusterCellsCollection.put(std::move(edmClusterCells)); debug() << "Number of clusters with cells in E and HCal: " << clusterWithMixedCells << endmsg; debug() << "Total energy of clusters: " << checkTotEnergy << endmsg; @@ -317,15 +327,15 @@ StatusCode CaloTopoClusterFCCee::buildingProtoCluster( } // last try with different condition on neighbours if (vecNextNeighbours[it].size() == 0) { - auto clusteredCells = aPreClusterCollection[clusterId]; - // loop over all clustered cells - for (auto& id : clusteredCells) { - if (id.second <= 2){ - verbose() << "Add neighbours of " << id.first << " in last round with thr = " << aLastNumSigma << " x sigma." << endmsg; - auto lastNeighours = CaloTopoClusterFCCee::searchForNeighbours(id.first, clusterId, aLastNumSigma, aCells, clusterOfCell, - aPreClusterCollection, false); - } - } + auto clusteredCells = aPreClusterCollection[clusterId]; + // loop over all clustered cells + for (auto& id : clusteredCells) { + if (id.second <= 2){ + verbose() << "Add neighbours of " << id.first << " in last round with thr = " << aLastNumSigma << " x sigma." << endmsg; + auto lastNeighours = CaloTopoClusterFCCee::searchForNeighbours(id.first, clusterId, aLastNumSigma, aCells, clusterOfCell, + aPreClusterCollection, false); + } + } } } } @@ -339,7 +349,7 @@ CaloTopoClusterFCCee::searchForNeighbours(const uint64_t aCellId, const std::unordered_map& aCells, std::map& aClusterOfCell, std::map>>& aPreClusterCollection, - bool aAllowClusterMerge) { + bool aAllowClusterMerge) { // Fill vector to be returned, next cell ids and cluster id for which neighbours are found std::vector> addedNeighbourIds; // Retrieve cellIDs of neighbours @@ -359,45 +369,45 @@ CaloTopoClusterFCCee::searchForNeighbours(const uint64_t aCellId, // Find the neighbour in the Calo cells list auto itAllCells = aCells.find(neighbourID); auto itAllUsedCells = aClusterOfCell.find(neighbourID); - + // If cell is hit.. and is not assigned to a cluster if (itAllCells != aCells.end() && itAllUsedCells == aClusterOfCell.end()) { verbose() << "Found neighbour with CellID: " << neighbourID << endmsg; auto neighbouringCellEnergy = itAllCells->second; bool addNeighbour = false; - int cellType = 2; - // retrieve the cell noise level [GeV] - // - // first try to use the cache - bool is_below = false; - int system = m_decoder->get(neighbourID, m_index_system); - if (system == 4) { //ECal barrel - int layer = m_decoder_ecal->get(neighbourID, m_index_layer_ecal); - double min_threshold = m_min_offset[layer] + m_min_noise[layer] * aNumSigma; - if (abs(neighbouringCellEnergy) < min_threshold) { - // if we are below the minimum threshold for the full layer, no need to retrieve the exact value - is_below = true; - } - } - - if (is_below) { - addNeighbour = false; - } - else { - double thr = m_noiseTool->noiseOffset(neighbourID) + (aNumSigma * m_noiseTool->noiseRMS(neighbourID)); - if (abs(neighbouringCellEnergy) > thr) - addNeighbour = true; - else - addNeighbour = false; - } - // give cell type according to threshold - if (aNumSigma == m_lastNeighbourSigma){ - cellType = 3; + int cellType = 2; + // retrieve the cell noise level [GeV] + // + // first try to use the cache + bool is_below = false; + int system = m_decoder->get(neighbourID, m_index_system); + if (system == 4) { //ECal barrel + int layer = m_decoder_ecal->get(neighbourID, m_index_layer_ecal); + double min_threshold = m_min_offset[layer] + m_min_noise[layer] * aNumSigma; + if (abs(neighbouringCellEnergy) < min_threshold) { + // if we are below the minimum threshold for the full layer, no need to retrieve the exact value + is_below = true; + } + } + + if (is_below) { + addNeighbour = false; } - // if threshold is 0, collect the cell independent on its energy - if (aNumSigma == 0){ - addNeighbour = true; + else { + double thr = m_noiseTool->noiseOffset(neighbourID) + (aNumSigma * m_noiseTool->noiseRMS(neighbourID)); + if (abs(neighbouringCellEnergy) > thr) + addNeighbour = true; + else + addNeighbour = false; } + // give cell type according to threshold + if (aNumSigma == m_lastNeighbourSigma){ + cellType = 3; + } + // if threshold is 0, collect the cell independent on its energy + if (aNumSigma == 0){ + addNeighbour = true; + } // if neighbour is validated if (addNeighbour) { // retrieve the cell @@ -410,13 +420,13 @@ CaloTopoClusterFCCee::searchForNeighbours(const uint64_t aCellId, // If cell is hit.. but is assigned to another cluster else if (itAllUsedCells != aClusterOfCell.end() && itAllUsedCells->second != aClusterID && aAllowClusterMerge) { uint clusterIDToMerge = itAllUsedCells->second; - if (msgLevel() <= MSG::VERBOSE){ - verbose() << "This neighbour was found in cluster " << clusterIDToMerge << ", cluster " << aClusterID - << " will be merged!" << endmsg; - verbose() << "Assigning all cells ( " << aPreClusterCollection.find(aClusterID)->second.size() << " ) to Cluster " - << clusterIDToMerge << " with ( " << aPreClusterCollection.find(clusterIDToMerge)->second.size() - << " ). " << endmsg; - } + if (msgLevel() <= MSG::VERBOSE){ + verbose() << "This neighbour was found in cluster " << clusterIDToMerge << ", cluster " << aClusterID + << " will be merged!" << endmsg; + verbose() << "Assigning all cells ( " << aPreClusterCollection.find(aClusterID)->second.size() << " ) to Cluster " + << clusterIDToMerge << " with ( " << aPreClusterCollection.find(clusterIDToMerge)->second.size() + << " ). " << endmsg; + } // Fill all cells into cluster, and assigned cells to new cluster aClusterOfCell[neighbourID] = clusterIDToMerge; for (auto& i : aPreClusterCollection.find(aClusterID)->second) { @@ -481,4 +491,3 @@ void CaloTopoClusterFCCee::createCache(const std::unordered_map m_cellPositionsHCalBarrelTool{"CellPositionsHCalBarrelTool", this}; /// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation - ToolHandle m_cellPositionsHCalExtBarrelTool{"CellPositionsHCalBarrelNoSegTool", this}; + ToolHandle m_cellPositionsHCalExtBarrelTool{"CellPositionsHCalExtBarrelTool", this}; ///// Handle for tool to get positions in Calo Discs //ToolHandle m_cellPositionsEMECTool{"CellPositionsCaloDiscsTool", this}; ///// Handle for tool to get positions in Calo Discs diff --git a/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.cpp b/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.cpp index 96163d64..7d97fe09 100644 --- a/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.cpp +++ b/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.cpp @@ -23,7 +23,7 @@ StatusCode CellPositionsECalBarrelModuleThetaSegTool::initialize() { } // get segmentation - m_segmentation = dynamic_cast(m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); + m_segmentation = dynamic_cast(m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no module-theta segmentation!!!!" << endmsg; return StatusCode::FAILURE; diff --git a/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.h b/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.h index 4164a512..9e9dfbe0 100644 --- a/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.h +++ b/RecFCCeeCalorimeter/src/components/CellPositionsECalBarrelModuleThetaSegTool.h @@ -5,13 +5,15 @@ #include "GaudiAlg/GaudiTool.h" #include "GaudiKernel/ServiceHandle.h" -// FCCSW -#include "DetCommon/DetUtils.h" -#include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" +// k4FWCore #include "k4FWCore/DataHandle.h" +#include "k4Interface/IGeoSvc.h" #include "k4Interface/ICellPositionsTool.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" +#include "detectorSegmentations/FCCSWGridModuleThetaMerged_k4geo.h" + // DD4hep #include "DD4hep/Readout.h" #include "DD4hep/Volumes.h" @@ -56,7 +58,7 @@ class CellPositionsECalBarrelModuleThetaSegTool : public GaudiTool, virtual publ /// Name of the electromagnetic calorimeter readout Gaudi::Property m_readoutName{this, "readoutName", "ECalBarrelModuleThetaMerged"}; /// Merged module-theta segmentation - dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo* m_segmentation; /// Cellid decoder dd4hep::DDSegmentation::BitFieldCoder* m_decoder; /// Volume manager diff --git a/RecFCCeeCalorimeter/src/components/CellPositionsHCalBarrelPhiThetaSegTool.cpp b/RecFCCeeCalorimeter/src/components/CellPositionsHCalBarrelPhiThetaSegTool.cpp new file mode 100644 index 00000000..78a3327e --- /dev/null +++ b/RecFCCeeCalorimeter/src/components/CellPositionsHCalBarrelPhiThetaSegTool.cpp @@ -0,0 +1,105 @@ +#include "CellPositionsHCalBarrelPhiThetaSegTool.h" + +#include "edm4hep/CalorimeterHitCollection.h" + +DECLARE_COMPONENT(CellPositionsHCalBarrelPhiThetaSegTool) + +CellPositionsHCalBarrelPhiThetaSegTool::CellPositionsHCalBarrelPhiThetaSegTool( + const std::string &type, + const std::string &name, + const IInterface *parent) + : GaudiTool(type, name, parent) +{ + declareInterface(this); +} + +StatusCode CellPositionsHCalBarrelPhiThetaSegTool::initialize() +{ + StatusCode sc = GaudiTool::initialize(); + if (sc.isFailure()) + return sc; + m_geoSvc = service("GeoSvc"); + if (!m_geoSvc) + { + error() << "Unable to locate Geometry service." << endmsg; + return StatusCode::FAILURE; + } + // get PhiTheta segmentation + m_segmentation = dynamic_cast( + m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); + if (m_segmentation == nullptr) + { + error() << "There is no phi-theta segmentation!!!!" << endmsg; + // return StatusCode::FAILURE; + } + // Take readout bitfield decoder from GeoSvc + m_decoder = m_geoSvc->getDetector()->readout(m_readoutName).idSpec().decoder(); + m_volman = m_geoSvc->getDetector()->volumeManager(); + // check if decoder contains "layer" + std::vector fields; + for (uint itField = 0; itField < m_decoder->size(); itField++) + { + fields.push_back((*m_decoder)[itField].name()); + } + auto iter = std::find(fields.begin(), fields.end(), "layer"); + if (iter == fields.end()) + { + error() << "Readout does not contain field: 'layer'" << endmsg; + } + return sc; +} + +void CellPositionsHCalBarrelPhiThetaSegTool::getPositions(const edm4hep::CalorimeterHitCollection &aCells, + edm4hep::CalorimeterHitCollection &outputColl) +{ + debug() << "Input collection size : " << aCells.size() << endmsg; + // Loop through cell collection + for (const auto &cell : aCells) + { + auto outSeg = CellPositionsHCalBarrelPhiThetaSegTool::xyzPosition(cell.getCellID()); + + auto edmPos = edm4hep::Vector3f(); + edmPos.x = outSeg.x() / dd4hep::mm; + edmPos.y = outSeg.y() / dd4hep::mm; + edmPos.z = outSeg.z() / dd4hep::mm; + + auto positionedHit = cell.clone(); + positionedHit.setPosition(edmPos); + outputColl.push_back(positionedHit); + + // Debug information about cell position + debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg; + debug() << "Position of cell (mm) : \t" << outSeg.x() / dd4hep::mm << "\t" << outSeg.y() / dd4hep::mm << "\t" + << outSeg.z() / dd4hep::mm << endmsg; + } + debug() << "Output positions collection size: " << outputColl.size() << endmsg; +} + +dd4hep::Position CellPositionsHCalBarrelPhiThetaSegTool::xyzPosition(const uint64_t &aCellId) const +{ + dd4hep::DDSegmentation::CellID volumeId = aCellId; + m_decoder->set(volumeId, "phi", 0); + m_decoder->set(volumeId, "theta", 0); + + int layer = m_decoder->get(volumeId, "layer"); + // get radius in cm + double radius = m_radii[layer]; + debug() << "Layer : " << layer << "\tradius : " << radius << " cm" << endmsg; + // get local position (for r=1) + auto inSeg = m_segmentation->position(aCellId); + debug() << "Local position : x = " << inSeg.x() << " y = " << inSeg.y() << " z = " << inSeg.z() << endmsg; + + // scale by radius to get global position + dd4hep::Position outSeg(inSeg.x() * radius, inSeg.y() * radius, inSeg.z() * radius); + debug() << "Global position : x = " << outSeg.x() << " y = " << outSeg.y() << " z = " << outSeg.z() << endmsg; + return outSeg; +} + +int CellPositionsHCalBarrelPhiThetaSegTool::layerId(const uint64_t &aCellId) +{ + int layer; + layer = m_decoder->get(aCellId, "layer"); + return layer; +} + +StatusCode CellPositionsHCalBarrelPhiThetaSegTool::finalize() { return GaudiTool::finalize(); } diff --git a/RecFCCeeCalorimeter/src/components/CellPositionsHCalBarrelPhiThetaSegTool.h b/RecFCCeeCalorimeter/src/components/CellPositionsHCalBarrelPhiThetaSegTool.h new file mode 100644 index 00000000..64ceb635 --- /dev/null +++ b/RecFCCeeCalorimeter/src/components/CellPositionsHCalBarrelPhiThetaSegTool.h @@ -0,0 +1,63 @@ +#ifndef RECCALORIMETER_CellPositionsHCalBarrelPhiThetaSegTool_H +#define RECCALORIMETER_CellPositionsHCalBarrelPhiThetaSegTool_H + +// Gaudi +#include "GaudiAlg/GaudiTool.h" +#include "GaudiKernel/ServiceHandle.h" + +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" +#include "detectorSegmentations/FCCSWGridPhiTheta_k4geo.h" + +// k4FWCore +#include "k4FWCore/DataHandle.h" +#include "k4Interface/IGeoSvc.h" +#include "k4Interface/ICellPositionsTool.h" + +// DD4hep +#include "DD4hep/Readout.h" +#include "DD4hep/Volumes.h" +#include "DDSegmentation/Segmentation.h" + +// ROOT +#include "TGeoManager.h" + +class IGeoSvc; +namespace DD4hep { +namespace DDSegmentation { +class Segmentation; +} +} + +/** @class CellPositionsHCalBarrelPhiThetaSegTool + * + */ + +class CellPositionsHCalBarrelPhiThetaSegTool : public GaudiTool, virtual public ICellPositionsTool { +public: + CellPositionsHCalBarrelPhiThetaSegTool(const std::string& type, const std::string& name, const IInterface* parent); + ~CellPositionsHCalBarrelPhiThetaSegTool() = default; + + virtual StatusCode initialize() final; + + virtual StatusCode finalize() final; + + virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final; + + virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final; + + virtual int layerId(const uint64_t& aCellId) final; + +private: + /// Pointer to the geometry service + SmartIF m_geoSvc; + /// Name of the electromagnetic calorimeter readout + Gaudi::Property m_readoutName{this, "readoutName", "HCalBarrelReadout"}; + /// segmentation for FCCee cell dimensions: 4x50mm, 6x100mm, 3x200mm + /// GM: risky to put the numbers here... better to get them from the geometry in memory... + Gaudi::Property> m_radii{this, "radii", {283.55, 288.55, 293.55, 298.55, 306.05, 316.05, 326.05, 336.05, 346.05, 356.05, 371.05, 391.05, 411.05}}; + dd4hep::DDSegmentation::FCCSWGridPhiTheta_k4geo* m_segmentation; + dd4hep::DDSegmentation::BitFieldCoder* m_decoder; + dd4hep::VolumeManager m_volman; +}; +#endif /* RECCALORIMETER_CellPositionsHCalBarrelPhiThetaSegTool_H */ diff --git a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp index 40503a05..4f19b705 100644 --- a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp +++ b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp @@ -1,13 +1,15 @@ #include "CreateCaloCellPositionsFCCee.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4FWCore #include "k4Interface/IGeoSvc.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + // DD4hep #include "DD4hep/Detector.h" -// EDM +// edm4hep #include "edm4hep/CalorimeterHitCollection.h" DECLARE_COMPONENT(CreateCaloCellPositionsFCCee) @@ -62,6 +64,10 @@ StatusCode CreateCaloCellPositionsFCCee::execute() { m_positions_cache[cellId] = edmPos; positionedHit.setPosition(edmPos); + + debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg; + debug() << "Position of cell (mm) : \t" << edmPos.x << "\t" << edmPos.y << "\t" << edmPos.z << endmsg; + } else { positionedHit.setPosition(cached_pos->second); diff --git a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h index 35073ecd..a146ffd8 100644 --- a/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h +++ b/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h @@ -1,7 +1,7 @@ #ifndef DETCOMPONENTS_CREATECELLPOSITIONSFCCEE_H #define DETCOMPONENTS_CREATECELLPOSITIONSFCCEE_H -// FCCSW +// k4FWCore #include "k4FWCore/DataHandle.h" #include "k4FWCore/MetaDataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -10,6 +10,7 @@ #include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiKernel/ToolHandle.h" +// edm4hep #include "edm4hep/CalorimeterHit.h" #include "edm4hep/CalorimeterHitCollection.h" #include "edm4hep/Constants.h" diff --git a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.cpp b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.cpp index ab796a07..26273200 100644 --- a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.cpp +++ b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.cpp @@ -1,408 +1,416 @@ #include "CreateFCCeeCaloNeighbours.h" +// DD4hep #include "DD4hep/Detector.h" -#include "DetCommon/DetUtils.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" +#include "detectorSegmentations/GridTheta_k4geo.h" +#include "detectorSegmentations/FCCSWGridPhiTheta_k4geo.h" +#include "detectorSegmentations/FCCSWGridModuleThetaMerged_k4geo.h" + +// ROOT #include "TFile.h" #include "TTree.h" DECLARE_COMPONENT(CreateFCCeeCaloNeighbours) -CreateFCCeeCaloNeighbours::CreateFCCeeCaloNeighbours(const std::string& aName, ISvcLocator* aSL) - : base_class(aName, aSL) { - declareProperty( "outputFileName", m_outputFileName, "Name of the output file"); +CreateFCCeeCaloNeighbours::CreateFCCeeCaloNeighbours(const std::string &aName, ISvcLocator *aSL) + : base_class(aName, aSL) +{ + declareProperty("outputFileName", m_outputFileName, "Name of the output file"); } CreateFCCeeCaloNeighbours::~CreateFCCeeCaloNeighbours() {} -StatusCode CreateFCCeeCaloNeighbours::initialize() { +StatusCode CreateFCCeeCaloNeighbours::initialize() +{ // Initialize necessary Gaudi components - if (Service::initialize().isFailure()) { + if (Service::initialize().isFailure()) + { error() << "Unable to initialize Service()" << endmsg; return StatusCode::FAILURE; } m_geoSvc = service("GeoSvc"); - if (!m_geoSvc) { + if (!m_geoSvc) + { error() << "Unable to locate Geometry Service. " << "Make sure you have GeoSvc and SimSvc in the right order in the configuration." << endmsg; return StatusCode::FAILURE; } std::unordered_map> map; - + // will be used for volume connecting - //int eCalLastLayer; + int eCalLastLayer; + std::pair extremaECalLastLayerPhi; std::pair extremaECalLastLayerModule; std::pair extremaECalLastLayerTheta; - //double eCalThetaOffset = 0; - //double eCalThetaSize = 0; - //double eCalPhiOffset = 0; - //double eCalModuleSize = 0; - //double hCalThetaOffset = 0; - //double hCalThetaSize = 0; - //double hCalPhiOffset = 0; - //dd4hep::DDSegmentation::BitFieldCoder* decoderECalBarrel = nullptr; - // will be used for volume connecting + // double eCalThetaOffset = 0; + // double eCalThetaSize = 0; + // double eCalPhiOffset = 0; + // double eCalModuleSize = 0; + // double hCalThetaOffset = 0; + // double hCalThetaSize = 0; + // double hCalPhiOffset = 0; + dd4hep::DDSegmentation::BitFieldCoder *decoderECalBarrel = nullptr; + // will be used for volume connecting std::pair extremaHCalFirstLayerPhi; std::pair extremaHCalFirstLayerTheta; std::pair extremaHCalFirstLayerZ; - //dd4hep::DDSegmentation::BitFieldCoder* decoderHCalBarrel = nullptr; + dd4hep::DDSegmentation::BitFieldCoder *decoderHCalBarrel = nullptr; - //////////////////////////////////// - /// SEGMENTED THETA-MODULE VOLUMES /// - //////////////////////////////////// - - for (uint iSys = 0; iSys < m_readoutNamesSegmented.size(); iSys++) { + for (uint iSys = 0; iSys < m_readoutNamesSegmented.size(); iSys++) + { // Check if readouts exist info() << "Readout: " << m_readoutNamesSegmented[iSys] << endmsg; - if (m_geoSvc->getDetector()->readouts().find(m_readoutNamesSegmented[iSys]) == m_geoSvc->getDetector()->readouts().end()) { + if (m_geoSvc->getDetector()->readouts().find(m_readoutNamesSegmented[iSys]) == m_geoSvc->getDetector()->readouts().end()) + { error() << "Readout <<" << m_readoutNamesSegmented[iSys] << ">> does not exist." << endmsg; return StatusCode::FAILURE; } - - // get Theta-Module Merged segmentation - dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged* segmentation; - segmentation = dynamic_cast( - m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).segmentation().segmentation()); - if (segmentation == nullptr) { - error() << "There is no Theta-Module Merged segmentation!!!!" << endmsg; + + // get Theta-based segmentation + dd4hep::DDSegmentation::Segmentation *aSegmentation = m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).segmentation().segmentation(); + if (aSegmentation == nullptr) + { + error() << "Segmentation does not exist." << endmsg; return StatusCode::FAILURE; } - info() << "FCCSWGridModuleThetaMerged: size in Theta " << segmentation->gridSizeTheta() << " , bins in Module " << segmentation->nModules() - << endmsg; - info() << "FCCSWGridModuleThetaMerged: offset in Theta " << segmentation->offsetTheta() << endmsg; - // retrieve decoders and other info needed for volume (ECal-HCal) connection - auto decoder = m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).idSpec().decoder(); - if (m_fieldNamesSegmented[iSys] == "system" && m_fieldValuesSegmented[iSys] == 5) { - //decoderECalBarrel = decoder; - //eCalThetaSize = segmentation->gridSizeTheta(); - //eCalModuleSize = 2 * M_PI / segmentation->nModules(); - //eCalModuleSize = 2 * M_PI / segmentation->phiBins(); - //eCalThetaOffset = segmentation->offsetTheta(); - //eCalPhiOffset = segmentation->offsetPhi(); - } - if (m_fieldNamesSegmented[iSys] == "system" && m_fieldValuesSegmented[iSys] == 8) { - //decoderHCalBarrel = decoder; - //hCalThetaSize = segmentation->gridSizeTheta(); - //hCalThetaOffset = segmentation->offsetTheta(); - //hCalPhiOffset = segmentation->offsetPhi(); - } + std::string segmentationType = aSegmentation->type(); + info() << "Segmentation type : " << segmentationType << endmsg; - // Loop over all cells in the calorimeter and retrieve existing cellIDs - // Loop over active layers - std::vector> extrema; - // extrema[0]: min layer, n layers - extrema.push_back(std::make_pair(0, m_activeVolumesNumbersSegmented[iSys] - 1)); - extrema.push_back(std::make_pair(0, 0)); - extrema.push_back(std::make_pair(0, 0)); - for (unsigned int ilayer = 0; ilayer < m_activeVolumesNumbersSegmented[iSys]; ilayer++) { - dd4hep::DDSegmentation::CellID volumeId = 0; - // Get VolumeID - // m_fieldValuesSegmented: in .py systemValuesModuleTheta = [4] - // m_activeFieldNamesSegmented: in .py activeFieldNamesModuleTheta = ["layer"] - (*decoder)[m_fieldNamesSegmented[iSys]].set(volumeId, m_fieldValuesSegmented[iSys]); - (*decoder)[m_activeFieldNamesSegmented[iSys]].set(volumeId, ilayer); - (*decoder)["theta"].set(volumeId, 0); - (*decoder)["module"].set(volumeId, 0); - // Get number of segmentation cells within the active volume - // numberOfCells: return Array of the number of cells in (module, theta) and the minimum theta ID. - auto numCells = det::utils::numberOfCells(volumeId, *segmentation); - // extrema 1: min module number (0), max module number - extrema[1] = std::make_pair(0, (numCells[0] - 1)*segmentation->mergedModules(ilayer)); - // extrema[2]: min theta ID, n (merged) theta cells - extrema[2] = std::make_pair(numCells[2], numCells[2] + (numCells[1] - 1)*segmentation->mergedThetaCells(ilayer)); - - // for layer N-1 of ECal barrel, will be used for volume connecting - // should 5 be systemValuesModuleTheta instead? - if (ilayer == (m_activeVolumesNumbersSegmented[iSys] - 1) && m_fieldNamesSegmented[iSys] == "system" && - m_fieldValuesSegmented[iSys] == 5) { - //eCalLastLayer = m_activeVolumesNumbersSegmented[iSys] - 1; - extremaECalLastLayerModule = std::make_pair(0, numCells[0] - 1); - extremaECalLastLayerTheta = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); - } - else if(m_fieldNamesSegmented[iSys] == "system" && - m_fieldValuesSegmented[iSys] == 8 && m_readoutNamesSegmented[iSys]=="BarHCal_Readout_phitheta"){ -//// - uint cellsTheta = ceil(( 2*m_activeVolumesTheta[ilayer] - segmentation->gridSizeTheta() ) / 2 / segmentation->gridSizeTheta()) * 2 + 1; //ceil( 2*m_activeVolumesRadii[ilayer] / segmentation->gridSizeTheta()); - uint minThetaID = int(floor(( - m_activeVolumesTheta[ilayer] + 0.5 * segmentation->gridSizeTheta() - segmentation->offsetTheta()) / segmentation->gridSizeTheta())); - numCells[1]=cellsTheta; - numCells[2]=minThetaID; - // for layer 0 of HCal barrel, will be used for volume connecting - if (ilayer == 0){ - extremaHCalFirstLayerPhi = std::make_pair(0, numCells[0] - 1); - extremaHCalFirstLayerTheta = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); - } - } - debug() << "Layer: " << ilayer << endmsg; - debug() << "Extrema[0]: " << extrema[0].first << " , " << extrema[0].second << endmsg; - debug() << "Extrema[1]: " << extrema[1].first << " , " << extrema[1].second << endmsg; - debug() << "Extrema[2]: " << extrema[2].first << " , " << extrema[2].second << endmsg; - debug() << "Number of segmentation cells in (module,theta): " << numCells << endmsg; - // Loop over segmentation cells - for (int imodule = extrema[1].first; imodule <= extrema[1].second; imodule += segmentation->mergedModules(ilayer)) { - for (int itheta = extrema[2].first; itheta <= extrema[2].second; itheta += segmentation->mergedThetaCells(ilayer)) { - dd4hep::DDSegmentation::CellID cellId = volumeId; - decoder->set(cellId, "module", imodule); - decoder->set(cellId, "theta", itheta); // start from the minimum existing theta cell in this layer - uint64_t id = cellId; - map.insert(std::pair>( - id, - det::utils::neighbours_ModuleThetaMerged( - *segmentation, - *decoder, - {m_activeFieldNamesSegmented[iSys], - "module", "theta"}, - extrema, - id, - m_includeDiagonalCells - ))); - } - } + dd4hep::DDSegmentation::GridTheta_k4geo *segmentation = nullptr; + dd4hep::DDSegmentation::FCCSWGridPhiTheta_k4geo *phiThetaSegmentation = nullptr; + dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo *moduleThetaSegmentation = nullptr; + if (segmentationType == "FCCSWGridModuleThetaMerged_k4geo") + { + segmentation = dynamic_cast(aSegmentation); + moduleThetaSegmentation = dynamic_cast(aSegmentation); } - if (msgLevel() <= MSG::DEBUG) { - std::vector counter; - counter.assign(40, 0); - for (const auto& item : map) { - counter[item.second.size()]++; - } - for (uint iCount = 0; iCount < counter.size(); iCount++) { - if (counter[iCount] != 0) { - info() << counter[iCount] << " cells have " << iCount << " neighbours" << endmsg; - } - } + else if (segmentationType == "FCCSWGridPhiTheta_k4geo") + { + segmentation = dynamic_cast(aSegmentation); + phiThetaSegmentation = dynamic_cast(aSegmentation); } - info() << "total number of cells: " << map.size() << endmsg; - } - - ////////////////////////////////// - /// NESTED VOLUMES /// - ////////////////////////////////// - - for (uint iSys = 0; iSys < m_readoutNamesNested.size(); iSys++) { - // Sanity check - if (m_activeFieldNamesNested.size() != 3) { - error() << "Property activeFieldNamesNested requires 3 names." << endmsg; + else + { + error() << "Segmentation type not handled." << endmsg; return StatusCode::FAILURE; } - // Check if readouts exist - info() << "Readout: " << m_readoutNamesNested[iSys] << endmsg; - if (m_geoSvc->getDetector()->readouts().find(m_readoutNamesNested[iSys]) == m_geoSvc->getDetector()->readouts().end()) { - error() << "Readout <<" << m_readoutNamesNested[iSys] << ">> does not exist." << endmsg; + + if (segmentation == nullptr || (phiThetaSegmentation == nullptr && moduleThetaSegmentation == nullptr)) + { + error() << "Unable to cast segmentation pointer!!!!" << endmsg; return StatusCode::FAILURE; } - auto decoder = m_geoSvc->getDetector()->readout(m_readoutNamesNested[iSys]).idSpec().decoder(); - // will be used for volume connecting - if (m_fieldNameNested == "system" && m_fieldValuesNested[iSys] == 8) { - //decoderHCalBarrel = decoder; - } - //hCalPhiOffset = m_hCalPhiOffset; - // Get VolumeID - dd4hep::DDSegmentation::CellID volumeId = 0; - decoder->set(volumeId, m_fieldNameNested, m_fieldValuesNested[iSys]); - // Get the total number of given hierarchy of active volumes - auto highestVol = gGeoManager->GetTopVolume(); - std::vector numVolumes; - numVolumes.reserve(m_activeVolumeNamesNested.size()); - for (const auto& volName : m_activeVolumeNamesNested) { - numVolumes.push_back(det::utils::countPlacedVolumes(highestVol, volName)); - info() << "Number of active volumes named " << volName << " is " << numVolumes.back() << endmsg; - if (numVolumes.back() == 0) { - error() << "Volume name " << volName << " not found! Check naming in detector description." << endmsg; - return StatusCode::FAILURE; - } + + info() << "Segmentation: size in Theta " << segmentation->gridSizeTheta() << endmsg; + info() << "Segmentation: offset in Theta " << segmentation->offsetTheta() << endmsg; + if (segmentationType == "FCCSWGridModuleThetaMerged_k4geo") + { + info() << "Segmentation: bins in Module " << moduleThetaSegmentation->nModules() << endmsg; } - // First sort to figure out which volume is inside which one - std::vector> numVolumesMap; - for (unsigned int it = 0; it < m_activeVolumeNamesNested.size(); it++) { - // names of volumes (m_activeVolumeNamesNested) not needed anymore, only corresponding bitfield names are used - // (m_activeFieldNamesNested) - numVolumesMap.push_back(std::pair(m_activeFieldNamesNested[it], numVolumes[it])); + else if (segmentationType == "FCCSWGridPhiTheta_k4geo") + { + info() << "Segmentation: size in Phi " << phiThetaSegmentation->gridSizePhi() << endmsg; + info() << "Segmentation: offset in Phi " << phiThetaSegmentation->offsetPhi() << endmsg; } - std::sort( - numVolumesMap.begin(), numVolumesMap.end(), - [](std::pair vol1, std::pair vol2) { return vol1.second < vol2.second; }); - // now recompute how many volumes exist within the larger volume - for (unsigned int it = numVolumesMap.size() - 1; it > 0; it--) { - if (numVolumesMap[it].second % numVolumesMap[it - 1].second != 0) { - error() << "Given volumes are not nested in each other!" << endmsg; - return StatusCode::FAILURE; - } - numVolumesMap[it].second /= numVolumesMap[it - 1].second; + + // retrieve decoders and other info needed for volume (ECal-HCal) connection + auto decoder = m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).idSpec().decoder(); + // hardcoding values (4,8) for ECal and HCal barrel systems looks quite error prone.. + // to be fixed in the future + if (m_fieldNamesSegmented[iSys] == "system" && m_fieldValuesSegmented[iSys] == 4) + { + decoderECalBarrel = decoder; + // eCalThetaSize = segmentation->gridSizeTheta(); + // eCalModuleSize = 2 * M_PI / segmentation->nModules(); + // eCalModuleSize = 2 * M_PI / segmentation->phiBins(); + // eCalThetaOffset = segmentation->offsetTheta(); + // eCalPhiOffset = segmentation->offsetPhi(); } - // Debug calculation of total number of cells - if (msgLevel() <= MSG::DEBUG) { - unsigned int checkTotal = 1; - for (const auto& vol : numVolumesMap) { - debug() << "Number of active volumes named " << vol.first << " is " << vol.second << endmsg; - checkTotal *= vol.second; - } - debug() << "Total number of cells ( " << numVolumesMap.back().first << " ) is " << checkTotal << endmsg; + if (m_fieldNamesSegmented[iSys] == "system" && m_fieldValuesSegmented[iSys] == 8) + { + decoderHCalBarrel = decoder; + // hCalThetaSize = segmentation->gridSizeTheta(); + // hCalThetaOffset = segmentation->offsetTheta(); + // hCalPhiOffset = segmentation->offsetPhi(); } - // make sure the ordering above is as in property activeFieldNamesNested - std::map activeVolumesNumbersNested; - for (const auto& name : m_activeFieldNamesNested) { - for (const auto& number : numVolumesMap) { - if (name == number.first) { - activeVolumesNumbersNested.insert(std::make_pair(number.first, number.second)); + + if (segmentationType == "FCCSWGridPhiTheta_k4geo") + { + // GM: code copied from RecFCChhCalorimeter, just replacing Eta->Theta + // did not review the code itself + + // Loop over all cells in the calorimeter and retrieve existing cellIDs + // Loop over active layers + std::vector> extrema; + extrema.push_back(std::make_pair(0, m_activeVolumesNumbersSegmented[iSys] - 1)); + extrema.push_back(std::make_pair(0, 0)); + extrema.push_back(std::make_pair(0, 0)); + for (unsigned int ilayer = 0; ilayer < m_activeVolumesNumbersSegmented[iSys]; ilayer++) + { + dd4hep::DDSegmentation::CellID volumeId = 0; + // Get VolumeID + // for ECAL OK (volume extends along z) + // for HCAL not OK.. need to find HCalLayerVol.. + (*decoder)[m_fieldNamesSegmented[iSys]].set(volumeId, m_fieldValuesSegmented[iSys]); + (*decoder)[m_activeFieldNamesSegmented[iSys]].set(volumeId, ilayer); + (*decoder)["theta"].set(volumeId, 0); + (*decoder)["phi"].set(volumeId, 0); + // Get number of segmentation cells within the active volume + std::array numCells; + // for HCAL use theta range passed via activeVolumesTheta option + if (m_fieldValuesSegmented[iSys]==8) { + int nPhiCells = TMath::TwoPi()/phiThetaSegmentation->gridSizePhi(); + double thetaCellSize = phiThetaSegmentation->gridSizeTheta(); + double thetaOffset = phiThetaSegmentation->offsetTheta(); + double thetaMin = m_activeVolumesTheta[ilayer]; + double thetaMax = TMath::Pi() - thetaMin; + // debug + std::cout << "thetaMin, thetaMax = " << thetaMin << " " << thetaMax << std::endl; + uint minThetaID = int(floor((thetaMin + 0.5 * thetaCellSize - thetaOffset) / thetaCellSize)); + uint maxThetaID = int(floor((thetaMax + 0.5 * thetaCellSize - thetaOffset) / thetaCellSize)); + uint nThetaCells = 1 + maxThetaID - minThetaID; + numCells[0] = nPhiCells; + numCells[1] = nThetaCells; + numCells[2] = minThetaID; } - } - } + else { + numCells = det::utils::numberOfCells(volumeId, *phiThetaSegmentation); + } + // extrema 1: 0, ID of last cell in phi + extrema[1] = std::make_pair(0, numCells[0] - 1); + // extrema[2]: min theta ID, n theta cells + extrema[2] = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); - // Loop over all cells in the calorimeter and retrieve existing cellIDs - // Loop over active layers - std::vector> extrema; - extrema.push_back(std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[0])->second - 1)); - extrema.push_back(std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[1])->second - 1)); - extrema.push_back(std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[2])->second - 1)); - // for layer 0 of HCal barrel - if (m_fieldNameNested == "system" && m_fieldValuesNested[iSys] == 8) { - extremaHCalFirstLayerPhi = - std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[1])->second - 1); - extremaHCalFirstLayerZ = - std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[2])->second - 1); + // for layer N-1 of ECal barrel, will be used for volume connecting + /* + if ( + m_fieldNamesSegmented[iSys] == "system" && + m_fieldValuesSegmented[iSys] == 4 && + ilayer == (m_activeVolumesNumbersSegmented[iSys] - 1) + ) + { + eCalLastLayer = m_activeVolumesNumbersSegmented[iSys] - 1; + // not really needed, same for all layers... unless we really restrict theta for each layer + // to the physical volume (not sure it's really needed, we can maybe allow for non-physical + // cells at edge in neighbour map, they simply won´t be added to the cluster since they do + // not exist in the list of cells) + extremaECalLastLayerPhi = std::make_pair(0, numCells[0] - 1); + extremaECalLastLayerTheta = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); + } + else if ( + m_fieldNamesSegmented[iSys] == "system" && + m_fieldValuesSegmented[iSys] == 8 && + m_readoutNamesSegmented[iSys] == "HCalBarrelReadout" // why is this needed? because there's also the HCAL endcap? + ) + { + uint cellsTheta = ceil((2 * m_activeVolumesTheta[ilayer] - segmentation->gridSizeTheta()) / 2 / segmentation->gridSizeTheta()) * 2 + 1; // ceil( 2*m_activeVolumesRadii[ilayer] / segmentation->gridSizeEta()) ; + uint minThetaID = int(floor((-m_activeVolumesTheta[ilayer] + 0.5 * segmentation->gridSizeTheta() - segmentation->offsetTheta()) / segmentation->gridSizeTheta())); + numCells[1] = cellsTheta; + numCells[2] = minThetaID; + // for layer 0 of HCal barrel, will be used for volume connecting + if (ilayer == 0) + { + extremaHCalFirstLayerPhi = std::make_pair(0, numCells[0] - 1); + extremaHCalFirstLayerTheta = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); + extrema[2] = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); + } + } + */ + debug() << "Layer: " << ilayer << endmsg; + debug() << "Extrema[0]: " << extrema[0].first << " , " << extrema[0].second << endmsg; + debug() << "Extrema[1]: " << extrema[1].first << " , " << extrema[1].second << endmsg; + debug() << "Extrema[2]: " << extrema[2].first << " , " << extrema[2].second << endmsg; + debug() << "Number of segmentation cells in phi, in theta, and min theta ID, : " << numCells << endmsg; + // Loop over segmentation cells + for (unsigned int iphi = 0; iphi < numCells[0]; iphi++) + { + for (unsigned int itheta = 0; itheta < numCells[1]; itheta++) + { + dd4hep::DDSegmentation::CellID cellId = volumeId; + decoder->set(cellId, "phi", iphi); + decoder->set(cellId, "theta", itheta + numCells[2]); // start from the minimum existing theta cell in this layer + uint64_t id = cellId; + if (ilayer==7 && iphi==95) debug() << itheta+numCells[2] << " " << cellId << endmsg; + map.insert(std::pair>( + id, det::utils::neighbours(*decoder, {m_activeFieldNamesSegmented[iSys], "phi", "theta"}, extrema, + id, {false, true, false}, m_includeDiagonalCells))); + } + } + } } - for (unsigned int ilayer = 0; ilayer < activeVolumesNumbersNested.find(m_activeFieldNamesNested[0])->second; - ilayer++) { - for (unsigned int iphi = 0; iphi < activeVolumesNumbersNested.find(m_activeFieldNamesNested[1])->second; iphi++) { - for (unsigned int iz = 0; iz < activeVolumesNumbersNested.find(m_activeFieldNamesNested[2])->second; iz++) { - dd4hep::DDSegmentation::CellID cID = volumeId; - decoder->set(cID, m_activeFieldNamesNested[0], ilayer); - decoder->set(cID, m_activeFieldNamesNested[1], iphi); - decoder->set(cID, m_activeFieldNamesNested[2], iz); - - map.insert(std::pair>( - cID, det::utils::neighbours(*decoder, {m_activeFieldNamesNested[0], m_activeFieldNamesNested[1], - m_activeFieldNamesNested[2]}, - extrema, cID, {false, true, false}, true))); + else if (segmentationType == "FCCSWGridModuleThetaMerged_k4geo") + { + std::vector> extrema; + // extrema[0]: min layer, n layers + extrema.push_back(std::make_pair(0, m_activeVolumesNumbersSegmented[iSys] - 1)); + extrema.push_back(std::make_pair(0, 0)); + extrema.push_back(std::make_pair(0, 0)); + for (unsigned int ilayer = 0; ilayer < m_activeVolumesNumbersSegmented[iSys]; ilayer++) + { + dd4hep::DDSegmentation::CellID volumeId = 0; + // Get VolumeID + // m_fieldValuesSegmented: in .py systemValuesModuleTheta = [4] + // m_activeFieldNamesSegmented: in .py activeFieldNamesModuleTheta = ["layer"] + (*decoder)[m_fieldNamesSegmented[iSys]].set(volumeId, m_fieldValuesSegmented[iSys]); + (*decoder)[m_activeFieldNamesSegmented[iSys]].set(volumeId, ilayer); + (*decoder)["theta"].set(volumeId, 0); + (*decoder)["module"].set(volumeId, 0); + // Get number of segmentation cells within the active volume + // numberOfCells: return Array of the number of cells in (module, theta) and the minimum theta ID. + auto numCells = det::utils::numberOfCells(volumeId, *moduleThetaSegmentation); + // extrema 1: min module number (0), max module number + extrema[1] = std::make_pair(0, (numCells[0] - 1) * moduleThetaSegmentation->mergedModules(ilayer)); + // extrema[2]: min theta ID, n (merged) theta cells + extrema[2] = std::make_pair(numCells[2], numCells[2] + (numCells[1] - 1) * moduleThetaSegmentation->mergedThetaCells(ilayer)); + // for layer N-1 of ECal barrel, will be used for volume connecting + // should 4 be systemValuesModuleTheta instead? + if (ilayer == (m_activeVolumesNumbersSegmented[iSys] - 1) && m_fieldNamesSegmented[iSys] == "system" && + m_fieldValuesSegmented[iSys] == 4) + { + // eCalLastLayer = m_activeVolumesNumbersSegmented[iSys] - 1; + extremaECalLastLayerModule = std::make_pair(0, numCells[0] - 1); + extremaECalLastLayerTheta = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); + } + else if (m_fieldNamesSegmented[iSys] == "system" && + m_fieldValuesSegmented[iSys] == 8 && m_readoutNamesSegmented[iSys] == "BarHCal_Readout_phitheta") + { + //// + uint cellsTheta = ceil((2 * m_activeVolumesTheta[ilayer] - segmentation->gridSizeTheta()) / 2 / segmentation->gridSizeTheta()) * 2 + 1; // ceil( 2*m_activeVolumesRadii[ilayer] / segmentation->gridSizeTheta()); + uint minThetaID = int(floor((-m_activeVolumesTheta[ilayer] + 0.5 * segmentation->gridSizeTheta() - segmentation->offsetTheta()) / segmentation->gridSizeTheta())); + numCells[1] = cellsTheta; + numCells[2] = minThetaID; + // for layer 0 of HCal barrel, will be used for volume connecting + if (ilayer == 0) + { + extremaHCalFirstLayerPhi = std::make_pair(0, numCells[0] - 1); + extremaHCalFirstLayerTheta = std::make_pair(numCells[2], numCells[1] + numCells[2] - 1); + } + } + debug() << "Layer: " << ilayer << endmsg; + debug() << "Extrema[0]: " << extrema[0].first << " , " << extrema[0].second << endmsg; + debug() << "Extrema[1]: " << extrema[1].first << " , " << extrema[1].second << endmsg; + debug() << "Extrema[2]: " << extrema[2].first << " , " << extrema[2].second << endmsg; + debug() << "Number of segmentation cells in (module,theta): " << numCells << endmsg; + // Loop over segmentation cells + for (int imodule = extrema[1].first; imodule <= extrema[1].second; imodule += moduleThetaSegmentation->mergedModules(ilayer)) + { + for (int itheta = extrema[2].first; itheta <= extrema[2].second; itheta += moduleThetaSegmentation->mergedThetaCells(ilayer)) + { + dd4hep::DDSegmentation::CellID cellId = volumeId; + decoder->set(cellId, "module", imodule); + decoder->set(cellId, "theta", itheta); // start from the minimum existing theta cell in this layer + uint64_t id = cellId; + map.insert(std::pair>( + id, + det::utils::neighbours_ModuleThetaMerged( + *moduleThetaSegmentation, + *decoder, + {m_activeFieldNamesSegmented[iSys], + "module", "theta"}, + extrema, + id, + m_includeDiagonalCells))); + } } } } - if (msgLevel() <= MSG::DEBUG) { + + if (msgLevel() <= MSG::DEBUG) + { std::vector counter; counter.assign(40, 0); - for (const auto& item : map) { + for (const auto &item : map) + { counter[item.second.size()]++; } - for (uint iCount = 0; iCount < counter.size(); iCount++) { - if (counter[iCount] != 0) { + for (uint iCount = 0; iCount < counter.size(); iCount++) + { + if (counter[iCount] != 0) + { info() << counter[iCount] << " cells have " << iCount << " neighbours" << endmsg; } } } + info() << "total number of cells: " << map.size() << endmsg; } ////////////////////////////////////////////////// /// BARREL: connection ECAL + HCAL /// ///////////////////////////////////////////////// - int count=0; -/* - if (m_connectBarrels) { + int count = 0; + + if (m_connectBarrels) + { + /* // first check if ECAL barrel (system==5) and HCal barrel (system==8) are configured - if (decoderECalBarrel == nullptr || decoderHCalBarrel == nullptr) { + if (decoderECalBarrel == nullptr || decoderHCalBarrel == nullptr) + { error() << "ECAL barrel and/or HCal barrel are not configured correctly!" << endmsg; return StatusCode::FAILURE; } // print how many cells in each dimensions will be matched - if(m_readoutNamesNested.size()!=0){ - info() << "ECAL layer " << eCalLastLayer << " is a neighbour of HCAL layer 0." << endmsg; - info() << "ECAL phi cells " << extremaECalLastLayerModule.first << " - " << extremaECalLastLayerModule.second - << " will be matched to HCAL " << m_activeFieldNamesNested[1] << "(s) " << extremaHCalFirstLayerPhi.first - << " - " << extremaHCalFirstLayerPhi.second << endmsg; - info() << "ECAL theta cells " << extremaECalLastLayerTheta.first << " - " << extremaECalLastLayerTheta.second - << " will be matched to HCAL " << m_activeFieldNamesNested[2] << "(s) " << extremaHCalFirstLayerZ.first - << " - " << extremaHCalFirstLayerZ.second << endmsg; - } - else{ - info() << "ECAL layer " << eCalLastLayer << " is a neighbour of HCAL layer 0." << endmsg; - info() << "ECAL phi cells " << extremaECalLastLayerModule.first << " - " << extremaECalLastLayerModule.second - << " will be matched to HCAL cells " << extremaHCalFirstLayerPhi.first - << " - " << extremaHCalFirstLayerPhi.second << endmsg; - info() << "ECAL theta cells " << extremaECalLastLayerTheta.first << " - " << extremaECalLastLayerTheta.second - << " will be matched to HCAL " << extremaHCalFirstLayerTheta.first - << " - " << extremaHCalFirstLayerTheta.second << endmsg; - } - + info() << "ECAL layer " << eCalLastLayer << " is a neighbour of HCAL layer 0." << endmsg; + info() << "ECAL phi cells " << extremaECalLastLayerModule.first << " - " << extremaECalLastLayerModule.second + << " will be matched to HCAL cells " << extremaHCalFirstLayerPhi.first + << " - " << extremaHCalFirstLayerPhi.second << endmsg; + info() << "ECAL theta cells " << extremaECalLastLayerTheta.first << " - " << extremaECalLastLayerTheta.second + << " will be matched to HCAL " << extremaHCalFirstLayerTheta.first + << " - " << extremaHCalFirstLayerTheta.second << endmsg; + std::unordered_map> thetaNeighbours; std::unordered_map> phiNeighbours; double hCalPhiSize = 2 * M_PI / (extremaHCalFirstLayerPhi.second - extremaHCalFirstLayerPhi.first + 1); - // loop over z and find which theta cells to add - if (m_readoutNamesNested.size()!=0){ - for (int iZ = 0; iZ < extremaHCalFirstLayerZ.second + 1; iZ++) { - double lowZ = m_hCalZOffset + iZ * m_hCalZSize; - double highZ = m_hCalZOffset + (iZ + 1) * m_hCalZSize; - double lowTheta = 0, highTheta = 0; - if (fabs(lowZ) < 1e-3) { - lowTheta = 0; - } else { - lowTheta = -////TODO - lowZ / fabs(lowZ) * atan(m_hCalRinner / lowZ); - //lowZ / fabs(lowZ) * (-log(fabs(tan(atan(m_hCalRinner / lowZ) / 2.)))); // theta = atan(m_hCalRinner / lowZ) - } - if (fabs(highZ) < 1e-3) { - highTheta = 0; - } else { - highTheta = highZ / fabs(highZ) * (-log(fabs(tan(atan(m_hCalRinner / highZ) / 2.)))); - } - debug() << "HCal z id : " << iZ << endmsg; - debug() << "HCal theta range : " << lowTheta << " - " << highTheta << endmsg; - int lowId = floor((lowTheta - 0.5 * eCalThetaSize - eCalThetaOffset) / eCalThetaSize); - int highId = floor((highTheta + 0.5 * eCalThetaSize - eCalThetaOffset) / eCalThetaSize); - debug() << "ECal theta range : " << lowId * eCalThetaSize + eCalThetaOffset << " - " - << highId * eCalThetaSize + eCalThetaOffset << endmsg; - std::vector neighbours; - for (int idThetaToAdd = lowId; idThetaToAdd <= highId; idThetaToAdd++) { - if (idThetaToAdd >= extremaECalLastLayerTheta.first && idThetaToAdd <= extremaECalLastLayerTheta.second) { - neighbours.push_back(idThetaToAdd); - } - } - debug() << "HCal z id : " << iZ << endmsg; - debug() << "Found ECal Neighbours in theta : " << neighbours.size() << endmsg; - for (auto id : neighbours) { - debug() << "ECal Neighbours id : " << id << endmsg; - } - thetaNeighbours.insert(std::pair>(iZ, neighbours)); + // loop over theta cells to match in theta + for (int iTheta = extremaHCalFirstLayerTheta.first; iTheta < extremaHCalFirstLayerTheta.second + 1; iTheta++) + { + double lowTheta = hCalThetaOffset + iTheta * hCalThetaSize; + double highTheta = hCalThetaOffset + (iTheta + 1) * hCalThetaSize; + debug() << "HCal theta range : " << lowTheta << " - " << highTheta << endmsg; + int lowId = floor((lowTheta - 0.5 * eCalThetaSize - eCalThetaOffset) / eCalThetaSize); + int highId = floor((highTheta + 0.5 * eCalThetaSize - eCalThetaOffset) / eCalThetaSize); + debug() << "ECal theta range : " << lowId * eCalThetaSize + eCalThetaOffset << " - " + << highId * eCalThetaSize + eCalThetaOffset << endmsg; + std::vector neighbours; + for (int idThetaToAdd = lowId; idThetaToAdd <= highId; idThetaToAdd++) + { + neighbours.push_back(det::utils::cyclicNeighbour(idThetaToAdd, extremaECalLastLayerTheta)); } - } - else{ // loop over theta cells to match in theta - for (int iTheta = extremaHCalFirstLayerTheta.first; iTheta < extremaHCalFirstLayerTheta.second + 1; iTheta++) { - double lowTheta = hCalThetaOffset + iTheta * hCalThetaSize; - double highTheta = hCalThetaOffset + (iTheta + 1) * hCalThetaSize; - debug() << "HCal theta range : " << lowTheta << " - " << highTheta << endmsg; - int lowId = floor((lowTheta - 0.5 * eCalThetaSize - eCalThetaOffset) / eCalThetaSize); - int highId = floor((highTheta + 0.5 * eCalThetaSize - eCalThetaOffset) / eCalThetaSize); - debug() << "ECal theta range : " << lowId * eCalThetaSize + eCalThetaOffset << " - " - << highId * eCalThetaSize + eCalThetaOffset << endmsg; - std::vector neighbours; - for (int idThetaToAdd = lowId; idThetaToAdd <= highId; idThetaToAdd++) { - neighbours.push_back(det::utils::cyclicNeighbour(idThetaToAdd, extremaECalLastLayerTheta)); - } - debug() << "HCal theta id : " << iTheta << endmsg; - debug() << "Found ECal Neighbours in theta : " << neighbours.size() << endmsg; - for (auto id : neighbours) { - debug() << "ECal Neighbours id : " << id << endmsg; - } - thetaNeighbours.insert(std::pair>(iTheta, neighbours)); + debug() << "HCal theta id : " << iTheta << endmsg; + debug() << "Found ECal Neighbours in theta : " << neighbours.size() << endmsg; + for (auto id : neighbours) + { + debug() << "ECal Neighbours id : " << id << endmsg; } + thetaNeighbours.insert(std::pair>(iTheta, neighbours)); } + // loop over phi and find which phi cells to add - for (int iPhi = 0; iPhi < extremaHCalFirstLayerPhi.second +1; iPhi++) { + for (int iPhi = 0; iPhi < extremaHCalFirstLayerPhi.second + 1; iPhi++) + { double lowPhi = hCalPhiOffset + iPhi * hCalPhiSize; double highPhi = hCalPhiOffset + (iPhi + 1) * hCalPhiSize; debug() << "HCal phi range : " << lowPhi << " - " << highPhi << endmsg; int lowId = floor((lowPhi - 0.5 * eCalModuleSize - eCalPhiOffset) / eCalModuleSize); int highId = floor((highPhi + 0.5 * eCalModuleSize - eCalPhiOffset) / eCalModuleSize); debug() << "ECal phi range : " << lowId * eCalModuleSize + eCalPhiOffset << " - " - << highId * eCalModuleSize + eCalPhiOffset << endmsg; + << highId * eCalModuleSize + eCalPhiOffset << endmsg; std::vector neighbours; - for (int idPhiToAdd = lowId; idPhiToAdd <= highId; idPhiToAdd++) { + for (int idPhiToAdd = lowId; idPhiToAdd <= highId; idPhiToAdd++) + { neighbours.push_back(det::utils::cyclicNeighbour(idPhiToAdd, extremaECalLastLayerModule)); } debug() << "HCal phi id : " << iPhi << endmsg; debug() << "Found ECal Neighbours in phi : " << neighbours.size() << endmsg; - for (auto id : neighbours) { + for (auto id : neighbours) + { debug() << "ECal Neighbours id : " << id << endmsg; } phiNeighbours.insert(std::pair>(iPhi, neighbours)); @@ -413,54 +421,43 @@ StatusCode CreateFCCeeCaloNeighbours::initialize() { (*decoderECalBarrel)["system"].set(ecalCellId, 5); (*decoderECalBarrel)[m_activeFieldNamesSegmented[0]].set(ecalCellId, eCalLastLayer); (*decoderHCalBarrel)["system"].set(hcalCellId, 8); - // loop over nested hcal cells - if (m_readoutNamesNested.size()!=0){ - (*decoderHCalBarrel)[m_activeFieldNamesNested[0]].set(hcalCellId, 0); - for (auto iZ : thetaNeighbours) { - (*decoderHCalBarrel)[m_activeFieldNamesNested[2]].set(hcalCellId, iZ.first); - for (auto iMod : phiNeighbours) { - (*decoderHCalBarrel)[m_activeFieldNamesNested[1]].set(hcalCellId, iMod.first); - for (auto iTheta : iZ.second) { - (*decoderECalBarrel)["theta"].set(ecalCellId, iTheta); - for (auto iPhi : iMod.second) { - (*decoderECalBarrel)["phi"].set(ecalCellId, iPhi); - map.find(hcalCellId)->second.push_back(ecalCellId); - map.find(ecalCellId)->second.push_back(hcalCellId); - count++; - } - } - } - } - } + (*decoderHCalBarrel)[m_activeFieldNamesSegmented[1]].set(hcalCellId, 0); // loop over segmented hcal cells - else { - (*decoderHCalBarrel)[m_activeFieldNamesSegmented[1]].set(hcalCellId, 0); - for (auto iThetaHCal : thetaNeighbours) { - (*decoderHCalBarrel)["theta"].set(hcalCellId, iThetaHCal.first); - for (auto iPhiHCal : phiNeighbours) { - (*decoderHCalBarrel)["phi"].set(hcalCellId, iPhiHCal.first); - for (auto iTheta : iThetaHCal.second) { - (*decoderECalBarrel)["theta"].set(ecalCellId, iTheta); - for (auto iPhi : iPhiHCal.second) { - (*decoderECalBarrel)["phi"].set(ecalCellId, iPhi); - map.find(hcalCellId)->second.push_back(ecalCellId); - map.find(ecalCellId)->second.push_back(hcalCellId); - count ++; - } - } - } + for (auto iThetaHCal : thetaNeighbours) + { + (*decoderHCalBarrel)["theta"].set(hcalCellId, iThetaHCal.first); + for (auto iPhiHCal : phiNeighbours) + { + (*decoderHCalBarrel)["phi"].set(hcalCellId, iPhiHCal.first); + for (auto iTheta : iThetaHCal.second) + { + (*decoderECalBarrel)["theta"].set(ecalCellId, iTheta); + for (auto iPhi : iPhiHCal.second) + { + (*decoderECalBarrel)["phi"].set(ecalCellId, iPhi); + map.find(hcalCellId)->second.push_back(ecalCellId); + map.find(ecalCellId)->second.push_back(hcalCellId); + count++; + } + } } } + */ } -*/ - if (msgLevel() <= MSG::DEBUG) { + // end of connectBarrels + + if (msgLevel() <= MSG::DEBUG) + { std::vector counter; counter.assign(40, 0); - for (const auto& item : map) { + for (const auto &item : map) + { counter[item.second.size()]++; } - for (uint iCount = 0; iCount < counter.size(); iCount++) { - if (counter[iCount] != 0) { + for (uint iCount = 0; iCount < counter.size(); iCount++) + { + if (counter[iCount] != 0) + { debug() << counter[iCount] << " cells have " << iCount << " neighbours" << endmsg; } } @@ -474,7 +471,8 @@ StatusCode CreateFCCeeCaloNeighbours::initialize() { std::vector saveNeighbours; tree.Branch("cellId", &saveCellId, "cellId/l"); tree.Branch("neighbours", &saveNeighbours); - for (const auto& item : map) { + for (const auto &item : map) + { saveCellId = item.first; saveNeighbours = item.second; tree.Fill(); diff --git a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.h b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.h index 07bed908..2f60de9b 100644 --- a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.h +++ b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNeighbours.h @@ -3,19 +3,22 @@ // Gaudi #include "GaudiKernel/Service.h" -#include "k4Interface/ICaloCreateMap.h" -#include "DetCommon/DetUtils.h" +// k4FWCore +#include "k4Interface/ICaloCreateMap.h" #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" -#include "DetSegmentation/FCCSWGridPhiTheta.h" -#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// DD4hep #include "DD4hep/Readout.h" #include "DD4hep/Volumes.h" #include "DDSegmentation/Segmentation.h" + +// ROOT #include "TGeoManager.h" class IGeoSvc; @@ -24,7 +27,6 @@ class IGeoSvc; * * Service building a map of neighbours for all existing cells in the geometry. * The volumes for which the neighbour map is created can be either segmented in theta-module (e.g. ECal inclined), - * or can contain nested volumes (e.g. HCal barrel). * * @author Giovanni Marchiori */ @@ -49,13 +51,13 @@ class CreateFCCeeCaloNeighbours : public extends1 { SmartIF m_geoSvc; /// Names of the detector readout for volumes with theta-module segmentation - Gaudi::Property> m_readoutNamesSegmented{this, "readoutNamesModuleTheta", {"ECalBarrelModuleThetaMerged"}}; + Gaudi::Property> m_readoutNamesSegmented{this, "readoutNames", {"ECalBarrelModuleThetaMerged"}}; /// Name of the fields describing the segmented volume - Gaudi::Property> m_fieldNamesSegmented{this, "systemNamesModuleTheta", {"system"}}; + Gaudi::Property> m_fieldNamesSegmented{this, "systemNames", {"system"}}; /// Values of the fields describing the segmented volume - Gaudi::Property> m_fieldValuesSegmented{this, "systemValuesModuleTheta", {5}}; - /// Names of the active volume in geometry along radial axis (e.g. layer), the others are "module", "theta" - Gaudi::Property> m_activeFieldNamesSegmented{this, "activeFieldNamesModuleTheta", {"layer"}}; + Gaudi::Property> m_fieldValuesSegmented{this, "systemValues", {5}}; + /// Names of the active volume in geometry along radial axis (e.g. layer), the others are "module"/"phi", "theta" + Gaudi::Property> m_activeFieldNamesSegmented{this, "activeFieldNames", {"layer"}}; /// Number of layers in the segmented volume Gaudi::Property> m_activeVolumesNumbersSegmented{this, "activeVolumesNumbers", {12}}; // Radii of layers in the segmented volume @@ -63,20 +65,6 @@ class CreateFCCeeCaloNeighbours : public extends1 { /// Whether to create the geant4 geometry or not Gaudi::Property m_includeDiagonalCells{this, "includeDiagonalCells", false, "If True will consider also diagonal neighbours in volumes with theta-module segmentation"}; - /// Names of the detector readout for volumes with nested volume structure and no segmentation - Gaudi::Property> m_readoutNamesNested{this, "readoutNamesVolumes"}; - /// Name of the field describing the nested volume - Gaudi::Property m_fieldNameNested{this, "systemNameNested"}; - /// Values of the fields describing the nested volume - Gaudi::Property> m_fieldValuesNested{this, "systemValuesNested"}; - /// Names of the active volume in geometry: along radial axis, azimuthal angle, and along z axis - Gaudi::Property> m_activeFieldNamesNested{ - this, "activeFieldNamesNested"}; - /// Names of the nested volumes - to retrieve the number of active volumes, need to correspond to m_activeFieldNamesNested - Gaudi::Property> m_activeVolumeNamesNested{ - this, - "activeVolumeNamesNested", - {"layerVolume", "moduleVolume", "wedgeVolume"}}; // to find out number of volumes /// Name of output file std::string m_outputFileName; diff --git a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.cpp b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.cpp index deaf2261..ac751338 100644 --- a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.cpp +++ b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.cpp @@ -1,9 +1,9 @@ #include "CreateFCCeeCaloNoiseLevelMap.h" #include "DD4hep/Detector.h" -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" +#include "detectorSegmentations/FCCSWGridModuleThetaMerged_k4geo.h" #include "TFile.h" #include "TTree.h" @@ -37,17 +37,15 @@ StatusCode CreateFCCeeCaloNoiseLevelMap::initialize() { return StatusCode::FAILURE; } - if (!m_hcalBarrelNoiseTool.retrieve()) { - error() << "Unable to retrieve the HCAL noise tool!!!" << endmsg; - return StatusCode::FAILURE; + if (!m_hcalBarrelNoiseTool.empty()){ + if (!m_hcalBarrelNoiseTool.retrieve()) { + error() << "Unable to retrieve the HCAL noise tool!!!" << endmsg; + return StatusCode::FAILURE; + } } std::unordered_map> map; - /////////////////////////////////////// - /// SEGMENTED MODULE-THETA VOLUMES /// - /////////////////////////////////////// - for (uint iSys = 0; iSys < m_readoutNamesSegmented.size(); iSys++) { // Check if readouts exist info() << "Readout: " << m_readoutNamesSegmented[iSys] << endmsg; @@ -56,11 +54,11 @@ StatusCode CreateFCCeeCaloNoiseLevelMap::initialize() { return StatusCode::FAILURE; } // get segmentation - dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged* segmentation; - segmentation = dynamic_cast( + dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo* segmentation; + segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).segmentation().segmentation()); if (segmentation == nullptr) { - error() << "There is no Module-Theta segmentation!!!!" << endmsg; + error() << "There is no Module-theta segmentation!!!!" << endmsg; return StatusCode::FAILURE; } @@ -88,8 +86,8 @@ StatusCode CreateFCCeeCaloNoiseLevelMap::initialize() { extrema[1] = std::make_pair(0, (numCells[0] - 1)*segmentation->mergedModules(ilayer)); // Range and min of theta ID // for HCAL use alternative calculation - if(m_fieldNamesSegmented[iSys] == "system" && - m_fieldValuesSegmented[iSys] == m_hcalBarrelSysId){ + if (m_fieldNamesSegmented[iSys] == "system" && + m_fieldValuesSegmented[iSys] == m_hcalBarrelSysId){ uint cellsTheta = ceil(( 2*m_activeVolumesTheta[ilayer] - segmentation->gridSizeTheta() ) / 2 / segmentation->gridSizeTheta()) * 2 + 1; //ceil( 2*m_activeVolumesRadii[ilayer] / segmentation->gridSizeTheta()); uint minThetaID = int(floor(( - m_activeVolumesTheta[ilayer] + 0.5 * segmentation->gridSizeTheta() - segmentation->offsetTheta()) / segmentation->gridSizeTheta())); numCells[1]=cellsTheta; @@ -118,101 +116,7 @@ StatusCode CreateFCCeeCaloNoiseLevelMap::initialize() { } } } - } // end of SEGMENTED MODULE-THETA VOLUMES - - ////////////////////////////////// - /// NESTED VOLUMES /// - ////////////////////////////////// - - for (uint iSys = 0; iSys < m_readoutNamesNested.size(); iSys++) { - // Sanity check - if (m_activeFieldNamesNested.size() != 3) { - error() << "Property activeFieldNamesNested requires 3 names." << endmsg; - return StatusCode::FAILURE; - } - // Check if readouts exist - info() << "Readout: " << m_readoutNamesNested[iSys] << endmsg; - if (m_geoSvc->getDetector()->readouts().find(m_readoutNamesNested[iSys]) == m_geoSvc->getDetector()->readouts().end()) { - error() << "Readout <<" << m_readoutNamesNested[iSys] << ">> does not exist." << endmsg; - return StatusCode::FAILURE; - } - auto decoder = m_geoSvc->getDetector()->readout(m_readoutNamesNested[iSys]).idSpec().decoder(); - // Get VolumeID - dd4hep::DDSegmentation::CellID volumeId = 0; - decoder->set(volumeId, m_fieldNameNested, m_fieldValuesNested[iSys]); - // Get the total number of given hierarchy of active volumes - auto highestVol = gGeoManager->GetTopVolume(); - std::vector numVolumes; - numVolumes.reserve(m_activeVolumeNamesNested.size()); - for (const auto& volName : m_activeVolumeNamesNested) { - numVolumes.push_back(det::utils::countPlacedVolumes(highestVol, volName)); - info() << "Number of active volumes named " << volName << " is " << numVolumes.back() << endmsg; - if (numVolumes.back() == 0) { - error() << "Volume name " << volName << " not found! Check naming in detector description." << endmsg; - return StatusCode::FAILURE; - } - } - // First sort to figure out which volume is inside which one - std::vector> numVolumesMap; - for (unsigned int it = 0; it < m_activeVolumeNamesNested.size(); it++) { - // names of volumes (m_activeVolumeNamesNested) not needed anymore, only corresponding bitfield names are used - // (m_activeFieldNamesNested) - numVolumesMap.push_back(std::pair(m_activeFieldNamesNested[it], numVolumes[it])); - } - std::sort( - numVolumesMap.begin(), numVolumesMap.end(), - [](std::pair vol1, std::pair vol2) { return vol1.second < vol2.second; }); - // now recompute how many volumes exist within the larger volume - for (unsigned int it = numVolumesMap.size() - 1; it > 0; it--) { - if (numVolumesMap[it].second % numVolumesMap[it - 1].second != 0) { - error() << "Given volumes are not nested in each other!" << endmsg; - return StatusCode::FAILURE; - } - numVolumesMap[it].second /= numVolumesMap[it - 1].second; - } - // Debug calculation of total number of cells - if (msgLevel() <= MSG::DEBUG) { - unsigned int checkTotal = 1; - for (const auto& vol : numVolumesMap) { - debug() << "Number of active volumes named " << vol.first << " is " << vol.second << endmsg; - checkTotal *= vol.second; - } - debug() << "Total number of cells ( " << numVolumesMap.back().first << " ) is " << checkTotal << endmsg; - } - // make sure the ordering above is as in property activeFieldNamesNested - std::map activeVolumesNumbersNested; - for (const auto& name : m_activeFieldNamesNested) { - for (const auto& number : numVolumesMap) { - if (name == number.first) { - activeVolumesNumbersNested.insert(std::make_pair(number.first, number.second)); - } - } - } - - // Loop over all cells in the calorimeter and retrieve existing cellIDs - // Loop over active layers - std::vector> extrema; - extrema.push_back(std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[0])->second - 1)); - extrema.push_back(std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[1])->second - 1)); - extrema.push_back(std::make_pair(0, activeVolumesNumbersNested.find(m_activeFieldNamesNested[2])->second - 1)); - for (unsigned int ilayer = 0; ilayer < activeVolumesNumbersNested.find(m_activeFieldNamesNested[0])->second; - ilayer++) { - for (unsigned int iphi = 0; iphi < activeVolumesNumbersNested.find(m_activeFieldNamesNested[1])->second; iphi++) { - for (unsigned int iz = 0; iz < activeVolumesNumbersNested.find(m_activeFieldNamesNested[2])->second; iz++) { - - dd4hep::DDSegmentation::CellID cID = volumeId; - decoder->set(cID, m_activeFieldNamesNested[0], ilayer); - decoder->set(cID, m_activeFieldNamesNested[1], iphi); - decoder->set(cID, m_activeFieldNamesNested[2], iz); - - double noise = m_hcalBarrelNoiseTool->getNoiseConstantPerCell(cID); - double noiseOffset = m_hcalBarrelNoiseTool->getNoiseOffsetPerCell(cID); - - map.insert( std::pair >(cID, std::make_pair(noise, noiseOffset) ) ); - } - } - } - } // end of NESTED VOLUMES + } std::unique_ptr file(TFile::Open(m_outputFileName.c_str(), "RECREATE")); file->cd(); diff --git a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.h b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.h index da65dbfb..44f7eb4e 100644 --- a/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.h +++ b/RecFCCeeCalorimeter/src/components/CreateFCCeeCaloNoiseLevelMap.h @@ -13,7 +13,7 @@ class IGeoSvc; * * Service building a map from cellIds to noise level per cell. * The volumes for which the neighbour map is created can be either segmented in Module-Theta (e.g. ECal inclined), - * or can contain nested volumes (e.g. HCal barrel). + * or phi-theta (e.g. HCal barrel). * * @author Coralie Neubueser */ @@ -37,6 +37,7 @@ class CreateFCCeeCaloNoiseLevelMap : public extends1 { /// Pointer to the geometry service SmartIF m_geoSvc; + /// ideally could replace with vector of handles (so that we can also have ecal endcap and so on) /// Handle for the cells noise tool in ECal ToolHandle m_ecalBarrelNoiseTool{"ReadNoiseFromFileTool", this}; Gaudi::Property m_ecalBarrelSysId{this, "ecalBarrelSysId", 5}; @@ -44,35 +45,19 @@ class CreateFCCeeCaloNoiseLevelMap : public extends1 { ToolHandle m_hcalBarrelNoiseTool{"ReadNoiseFromFileTool", this}; Gaudi::Property m_hcalBarrelSysId{this, "hcalBarrelSysId", 8}; - /// Names of the detector readout for volumes with Module-Theta segmentation - Gaudi::Property> m_readoutNamesSegmented{this, "readoutNamesModuleTheta", {"ECalBarrelModuleThetaMerged"}}; + /// Names of the detector readout for the volumes + Gaudi::Property> m_readoutNamesSegmented{this, "readoutNames", {"ECalBarrelModuleThetaMerged", "BarHCal_Readout_phitheta"}}; /// Name of the fields describing the segmented volume - Gaudi::Property> m_fieldNamesSegmented{this, "systemNamesModuleTheta", {"system"}}; + Gaudi::Property> m_fieldNamesSegmented{this, "systemNames", {"system", "system"}}; /// Values of the fields describing the segmented volume - Gaudi::Property> m_fieldValuesSegmented{this, "systemValuesModuleTheta", {5}}; - /// Names of the active volume in geometry along radial axis (e.g. layer), the others are "module", "theta" - Gaudi::Property> m_activeFieldNamesSegmented{this, "activeFieldNamesModuleTheta", {"layer"}}; + Gaudi::Property> m_fieldValuesSegmented{this, "systemValues", {4, 8}}; + /// Names of the active volume in geometry along radial axis (e.g. layer), the others are "module" or "phi", "theta" + Gaudi::Property> m_activeFieldNamesSegmented{this, "activeFieldNames", {"layer"}}; /// Number of layers in the segmented volume - Gaudi::Property> m_activeVolumesNumbersSegmented{this, "activeVolumesNumbers", {8}}; + Gaudi::Property> m_activeVolumesNumbersSegmented{this, "activeVolumesNumbers", {12, 13}}; // Radii of layers in the segmented volume Gaudi::Property> m_activeVolumesTheta{this, "activeVolumesTheta"}; - /// Names of the detector readout for volumes with nested volume structure and no segmentation - Gaudi::Property> m_readoutNamesNested{this, "readoutNamesVolumes", {"HCalBarrelReadout"}}; - /// Name of the field describing the nested volume - Gaudi::Property m_fieldNameNested{this, "systemNameNested", "system"}; - /// Values of the fields describing the nested volume - Gaudi::Property> m_fieldValuesNested{this, "systemValuesNested", {8}}; - /// Names of the active volume in geometry: along radial axis, azimuthal angle, and along z axis - Gaudi::Property> m_activeFieldNamesNested{ - this, "activeFieldNamesNested", {"layer", "module", "row"}}; - /// Names of the nested volumes - to retrieve the number of active volumes, need to correspond to - /// m_activeFieldNamesNested - Gaudi::Property> m_activeVolumeNamesNested{ - this, - "activeVolumeNamesNested", - {"layerVolume", "moduleVolume", "wedgeVolume"}}; // to find out number of volumes - /// Name of output file std::string m_outputFileName; }; diff --git a/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.cpp b/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.cpp index 3ae2c2e7..112ecf03 100644 --- a/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.cpp +++ b/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.cpp @@ -1,15 +1,18 @@ #include "ReadNoiseVsThetaFromFileTool.h" -// FCCSW -#include "DetCommon/DetUtils.h" +// k4geo +#include "detectorCommon/DetUtils_k4geo.h" + +// k4FWCore #include "k4Interface/IGeoSvc.h" -#include "DDSegmentation/Segmentation.h" + // DD4hep #include "DD4hep/Detector.h" #include "DD4hep/Readout.h" +#include "DDSegmentation/Segmentation.h" -// Root +// ROOT #include "TFile.h" #include "TH1F.h" @@ -41,7 +44,7 @@ StatusCode ReadNoiseVsThetaFromFileTool::initialize() { // Get segmentation if (m_useSeg) { - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no module-theta segmentation." << endmsg; diff --git a/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.h b/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.h index c39c4cb5..2e31669a 100644 --- a/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.h +++ b/RecFCCeeCalorimeter/src/components/ReadNoiseVsThetaFromFileTool.h @@ -1,17 +1,16 @@ #ifndef RECFCCEECALORIMETER_READNOISEVSTHETAFROMFILETOOL_H #define RECFCCEECALORIMETER_READNOISEVSTHETAFROMFILETOOL_H -// from Gaudi +// Gaudi #include "GaudiAlg/GaudiTool.h" #include "GaudiKernel/ToolHandle.h" -// FCCSW -//#include "k4FWCore/DataHandle.h" -//#include "k4Interface/ICalorimeterTool.h" +// k4FWCore #include "k4Interface/INoiseConstTool.h" #include "k4Interface/ICellPositionsTool.h" -#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" +// k4geo +#include "detectorSegmentations/FCCSWGridModuleThetaMerged_k4geo.h" class IGeoSvc; @@ -90,7 +89,7 @@ class ReadNoiseVsThetaFromFileTool : public GaudiTool, virtual public INoiseCons /// Pointer to the geometry service SmartIF m_geoSvc; /// Theta-Module segmentation - dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo* m_segmentation; // Decoder for ECal layers dd4hep::DDSegmentation::BitFieldCoder* m_decoder; diff --git a/RecFCChhCalorimeter/CMakeLists.txt b/RecFCChhCalorimeter/CMakeLists.txt index ee0b30dd..8e14e9f7 100644 --- a/RecFCChhCalorimeter/CMakeLists.txt +++ b/RecFCChhCalorimeter/CMakeLists.txt @@ -11,8 +11,8 @@ gaudi_add_module(k4RecFCChhCalorimeterPlugins Gaudi::GaudiKernel DD4hep::DDCore EDM4HEP::edm4hep - FCCDetectors::DetSegmentation - FCCDetectors::DetCommon + k4geo::detectorSegmentations + k4geo::detectorCommon DD4hep::DDG4 ROOT::Core ROOT::Hist diff --git a/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.cpp b/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.cpp index 324ab092..988d28ca 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.cpp +++ b/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.cpp @@ -19,7 +19,7 @@ StatusCode CellPositionsCaloDiscsTool::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName.value()).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.h b/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.h index cc34e6b4..5f851217 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsCaloDiscsTool.h @@ -6,9 +6,9 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -57,7 +57,7 @@ class CellPositionsCaloDiscsTool : public GaudiTool, virtual public ICellPositio /// Name of the electromagnetic calorimeter readout Gaudi::Property m_readoutName{this, "readoutName", "EMECPhiEtaReco", "name of the readout"}; /// Eta-phi segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; /// Cellid decoder dd4hep::DDSegmentation::BitFieldCoder* m_decoder; /// Volume manager diff --git a/RecFCChhCalorimeter/src/components/CellPositionsDummyTool.h b/RecFCChhCalorimeter/src/components/CellPositionsDummyTool.h index 8edf347e..9d49a2f2 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsDummyTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsDummyTool.h @@ -6,7 +6,7 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" diff --git a/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.cpp b/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.cpp index f195817a..d7f2feca 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.cpp +++ b/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.cpp @@ -20,7 +20,7 @@ StatusCode CellPositionsECalBarrelTool::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.h b/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.h index d339832e..92ede5bf 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsECalBarrelTool.h @@ -6,9 +6,9 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -56,7 +56,7 @@ class CellPositionsECalBarrelTool : public GaudiTool, virtual public ICellPositi /// Name of the electromagnetic calorimeter readout Gaudi::Property m_readoutName{this, "readoutName", "ECalBarrelPhiEta"}; /// Eta-phi segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; /// Cellid decoder dd4hep::DDSegmentation::BitFieldCoder* m_decoder; /// Volume manager diff --git a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.cpp b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.cpp index cb070705..6714cc55 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.cpp +++ b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.cpp @@ -19,7 +19,7 @@ StatusCode CellPositionsHCalBarrelNoSegTool::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.h b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.h index 97f08795..18c71212 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelNoSegTool.h @@ -6,7 +6,7 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -59,7 +59,7 @@ class CellPositionsHCalBarrelNoSegTool : public GaudiTool, virtual public ICellP /// Position of layers in radius Gaudi::Property> m_radii{this, "radii", {291.05, 301.05, 313.55, 328.55, 343.55, 358.55, 378.55, 413.55, 428.55, 453.55}}; /// Segementation - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; /// Volume manager dd4hep::VolumeManager m_volman; }; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.cpp b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.cpp index da989fd1..3fd4f259 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.cpp +++ b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.cpp @@ -19,7 +19,7 @@ StatusCode CellPositionsHCalBarrelPhiSegTool::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.h b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.h index 82ba2f03..7dcf8a97 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelPhiSegTool.h @@ -6,7 +6,7 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -58,7 +58,7 @@ class CellPositionsHCalBarrelPhiSegTool : public GaudiTool, virtual public ICell dd4hep::DDSegmentation::BitFieldCoder* m_decoder; /// Volume manager dd4hep::VolumeManager m_volman; - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; Gaudi::Property> m_radii{this, "radii", {291.05, 301.05, 313.55, 328.55, 343.55, 358.55, 378.55, 413.55, 428.55, 453.55}}; }; #endif /* RECCALORIMETER_CELLPOSITIONSHCALBARRELPHISEGTOOL_H */ diff --git a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.cpp b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.cpp index aa502939..d5553144 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.cpp +++ b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.cpp @@ -19,7 +19,7 @@ StatusCode CellPositionsHCalBarrelTool::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.h b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.h index 92cfbd91..4e7f94d3 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsHCalBarrelTool.h @@ -6,9 +6,9 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -53,7 +53,7 @@ class CellPositionsHCalBarrelTool : public GaudiTool, virtual public ICellPositi /// Gaudi::Property> m_radii{this, "radii", {291.05, 301.05, 313.55, 328.55, 343.55, 358.55, 378.55, 413.55, 428.55, 453.55}}; /// segmentation for FCCee cell dimensions: 4x50mm, 6x100mm, 3x200mm Gaudi::Property> m_radii{this, "radii", {283.55, 288.55, 293.55, 298.55, 306.05, 316.05, 326.05, 336.05, 346.05, 356.05, 371.05, 391.05, 411.05}}; - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; dd4hep::DDSegmentation::BitFieldCoder* m_decoder; dd4hep::VolumeManager m_volman; }; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.cpp b/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.cpp index 9a11d11a..63f57ff0 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.cpp +++ b/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.cpp @@ -20,7 +20,7 @@ StatusCode CellPositionsTailCatcherTool::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - m_segmentation = dynamic_cast( + m_segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutName).segmentation().segmentation()); if (m_segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.h b/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.h index e4f764c9..595a0dd7 100644 --- a/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.h +++ b/RecFCChhCalorimeter/src/components/CellPositionsTailCatcherTool.h @@ -6,9 +6,9 @@ #include "GaudiKernel/ServiceHandle.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" -#include "DetSegmentation/FCCSWGridPhiEta.h" +#include "detectorSegmentations/FCCSWGridPhiEta_k4geo.h" #include "k4FWCore/DataHandle.h" #include "k4Interface/ICellPositionsTool.h" @@ -58,7 +58,7 @@ class CellPositionsTailCatcherTool : public GaudiTool, virtual public ICellPosit /// Radius of central Tail Catcher cylinder Gaudi::Property m_centralRadius{this, "centralRadius", {}, "radius in cm"}; /// Eta-phi segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* m_segmentation; + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* m_segmentation; /// Cellid decoder dd4hep::DDSegmentation::BitFieldCoder* m_decoder; /// Volume manager diff --git a/RecFCChhCalorimeter/src/components/CreateCaloCellPositions.cpp b/RecFCChhCalorimeter/src/components/CreateCaloCellPositions.cpp index 4d1d0df3..cd2e9f80 100644 --- a/RecFCChhCalorimeter/src/components/CreateCaloCellPositions.cpp +++ b/RecFCChhCalorimeter/src/components/CreateCaloCellPositions.cpp @@ -1,7 +1,7 @@ #include "CreateCaloCellPositions.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" // DD4hep diff --git a/RecFCChhCalorimeter/src/components/CreateCellPositions.cpp b/RecFCChhCalorimeter/src/components/CreateCellPositions.cpp index 2dbb5a5a..b932a6c5 100644 --- a/RecFCChhCalorimeter/src/components/CreateCellPositions.cpp +++ b/RecFCChhCalorimeter/src/components/CreateCellPositions.cpp @@ -1,7 +1,7 @@ #include "CreateCellPositions.h" // FCCSW -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" // DD4hep diff --git a/RecFCChhCalorimeter/src/components/CreateFCChhCaloNeighbours.cpp b/RecFCChhCalorimeter/src/components/CreateFCChhCaloNeighbours.cpp index 15e18327..22ed58f6 100644 --- a/RecFCChhCalorimeter/src/components/CreateFCChhCaloNeighbours.cpp +++ b/RecFCChhCalorimeter/src/components/CreateFCChhCaloNeighbours.cpp @@ -1,7 +1,7 @@ #include "CreateFCChhCaloNeighbours.h" #include "DD4hep/Detector.h" -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" #include "TFile.h" @@ -60,8 +60,8 @@ StatusCode CreateFCChhCaloNeighbours::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation; - segmentation = dynamic_cast( + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation; + segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).segmentation().segmentation()); if (segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg; diff --git a/RecFCChhCalorimeter/src/components/CreateFCChhCaloNoiseLevelMap.cpp b/RecFCChhCalorimeter/src/components/CreateFCChhCaloNoiseLevelMap.cpp index 40ab14e3..3c7e7a1f 100644 --- a/RecFCChhCalorimeter/src/components/CreateFCChhCaloNoiseLevelMap.cpp +++ b/RecFCChhCalorimeter/src/components/CreateFCChhCaloNoiseLevelMap.cpp @@ -1,7 +1,7 @@ #include "CreateFCChhCaloNoiseLevelMap.h" #include "DD4hep/Detector.h" -#include "DetCommon/DetUtils.h" +#include "detectorCommon/DetUtils_k4geo.h" #include "k4Interface/IGeoSvc.h" #include "TFile.h" @@ -44,8 +44,8 @@ StatusCode CreateFCChhCaloNoiseLevelMap::initialize() { return StatusCode::FAILURE; } // get PhiEta segmentation - dd4hep::DDSegmentation::FCCSWGridPhiEta* segmentation; - segmentation = dynamic_cast( + dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo* segmentation; + segmentation = dynamic_cast( m_geoSvc->getDetector()->readout(m_readoutNamesSegmented[iSys]).segmentation().segmentation()); if (segmentation == nullptr) { error() << "There is no phi-eta segmentation!!!!" << endmsg;