Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate theta-module readout and related code to k4geo #56

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ find_package(Gaudi)
find_package(k4FWCore) # implicit: Gaudi
find_package(EDM4HEP) # implicit: Podio
find_package(DD4hep)
find_package(FCCDetectors)
find_package(k4geo)
#---------------------------------------------------------------


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions RecCalorimeter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/CalibrateCaloHitsTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// from Gaudi
#include "GaudiAlg/GaudiTool.h"

// FCCSW
// k4FWCore
#include "k4Interface/ICalibrateCaloHitsTool.h"

#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/CalibrateInLayersTool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "CalibrateInLayersTool.h"

// FCCSW
// k4FWCore
#include "k4Interface/IGeoSvc.h"

// DD4hep
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/CalibrateInLayersTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/ServiceHandle.h"

// FCCSW
// k4FWCore
#include "k4Interface/ICalibrateCaloHitsTool.h"
class IGeoSvc;

Expand Down
6 changes: 4 additions & 2 deletions RecCalorimeter/src/components/CaloTopoCluster.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/CaloTopoCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions RecCalorimeter/src/components/CaloTopoClusterInputTool.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "CaloTopoClusterInputTool.h"

// FCCSW
// k4FWCore
#include "k4Interface/IGeoSvc.h"

// datamodel
// edm4hep
#include "edm4hep/CalorimeterHit.h"
#include "edm4hep/CalorimeterHitCollection.h"

Expand Down
5 changes: 3 additions & 2 deletions RecCalorimeter/src/components/CaloTopoClusterInputTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// from Gaudi
#include "GaudiAlg/GaudiTool.h"

// FCCSW
// k4FWCore
#include "k4FWCore/DataHandle.h"
#include "k4Interface/ITopoClusterInputTool.h"

Expand Down Expand Up @@ -77,7 +77,8 @@ class CaloTopoClusterInputTool : public GaudiTool, virtual public ITopoClusterIn
Gaudi::Property<std::string> m_ecalEndcapReadoutName{this, "ecalEndcapReadoutName", "",
"name of the ecal endcap readout"};
/// Name of the ecal forward calorimeter readout
Gaudi::Property<std::string> m_ecalFwdReadoutName{this, "ecalFwdReadoutName", "", "name of the ecal fwd readout"};
Gaudi::Property<std::string> m_ecalFwdReadoutName{this, "ecalFwdReadoutName", "",
"name of the ecal fwd readout"};
/// Name of the hadronic barrel readout
Gaudi::Property<std::string> m_hcalBarrelReadoutName{this, "hcalBarrelReadoutName", "",
"name of the hcal barrel readout"};
Expand Down
20 changes: 10 additions & 10 deletions RecCalorimeter/src/components/CaloTowerTool.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -113,12 +113,12 @@ StatusCode CaloTowerTool::finalize() {
std::pair<double, double> 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<dd4hep::DDSegmentation::FCCSWGridPhiEta*>(aSegmentation);
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(aSegmentation);
phiMax = fabs(segmentation->offsetPhi()) + M_PI / (double)segmentation->phiBins();
etaMax = fabs(segmentation->offsetEta()) + segmentation->gridSizeEta() * 0.5;
break;
Expand All @@ -128,7 +128,7 @@ std::pair<double, double> CaloTowerTool::retrievePhiEtaExtrema(dd4hep::DDSegment
double eta = -1;
info() << "== Retrieving multi segmentation " << aSegmentation->name() << endmsg;
for (const auto& subSegm: dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(aSegmentation)->subSegmentations()) {
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta*>(subSegm.segmentation);
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(subSegm.segmentation);
phi = fabs(segmentation->offsetPhi()) + M_PI / (double)segmentation->phiBins();
eta = fabs(segmentation->offsetEta()) + segmentation->gridSizeEta() * 0.5;
if (eta > etaMax) { etaMax = eta;}
Expand Down Expand Up @@ -320,10 +320,10 @@ void CaloTowerTool::CellsIntoTowers(std::vector<std::vector<float>>& 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<const dd4hep::DDSegmentation::FCCSWGridPhiEta*>(aSegmentation);
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(aSegmentation);
} else if( aType == SegmentationType::kMulti) {
multisegmentation = dynamic_cast<const dd4hep::DDSegmentation::MultiSegmentation*>(aSegmentation);
}
Expand All @@ -332,7 +332,7 @@ void CaloTowerTool::CellsIntoTowers(std::vector<std::vector<float>>& aTowers,
pass = true;
// if multisegmentation is used - first find out which segmentation to use
if( aType == SegmentationType::kMulti) {
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridPhiEta*>(&multisegmentation->subsegmentation(cell.getCellID()));
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(&multisegmentation->subsegmentation(cell.getCellID()));
}
if (m_useHalfTower) {
uint layerId = m_decoder->get(cell.getCellID(), "layer");
Expand Down Expand Up @@ -416,7 +416,7 @@ std::pair<dd4hep::DDSegmentation::Segmentation*, CaloTowerTool::SegmentationType
info() << "Readout does not exist! Please check if it is correct. Processing without it." << endmsg;
} else {
info() << "Readout " << aReadoutName << " found." << endmsg;
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta*>(
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(
m_geoSvc->getDetector()->readout(aReadoutName).segmentation().segmentation());
if (segmentation == nullptr) {
segmentation = dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(
Expand All @@ -427,7 +427,7 @@ std::pair<dd4hep::DDSegmentation::Segmentation*, CaloTowerTool::SegmentationType
// check if multisegmentation contains only phi-eta sub-segmentations
dd4hep::DDSegmentation::Segmentation* subsegmentation = nullptr;
for (const auto& subSegm: dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(segmentation)->subSegmentations()) {
subsegmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta*>(subSegm.segmentation);
subsegmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(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);
Expand Down
24 changes: 14 additions & 10 deletions RecCalorimeter/src/components/CaloTowerTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/ConeSelection.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ConeSelection.h"

// FCC Detectors
#include "DetCommon/DetUtils.h"
#include "detectorCommon/DetUtils_k4geo.h"

// DD4hep
#include "DD4hep/Detector.h"
Expand Down
6 changes: 4 additions & 2 deletions RecCalorimeter/src/components/ConstNoiseTool.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "ConstNoiseTool.h"

// FCCSW
#include "DetCommon/DetUtils.h"
// k4geo
#include "detectorCommon/DetUtils_k4geo.h"

// k4FWCore
#include "k4Interface/IGeoSvc.h"

// DD4hep
Expand Down
6 changes: 4 additions & 2 deletions RecCalorimeter/src/components/ConstNoiseTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions RecCalorimeter/src/components/CorrectCaloClusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/CorrectCaloClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace edm4hep {
// DD4HEP
namespace dd4hep {
namespace DDSegmentation {
class FCCSWGridPhiEta;
class FCCSWGridPhiEta_k4geo;
class MultiSegmentation;
class BitFieldCoder;
}
Expand Down
24 changes: 14 additions & 10 deletions RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp
Original file line number Diff line number Diff line change
@@ -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 <GaudiKernel/MsgStream.h>

DECLARE_COMPONENT(CorrectECalBarrelSliWinCluster)

Expand Down Expand Up @@ -147,7 +151,7 @@ StatusCode CorrectECalBarrelSliWinCluster::initialize() {
return StatusCode::FAILURE;
}
// retrieve PhiEta segmentation
m_segmentationPhiEta[m_systemId[iSys]] = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta*>(
m_segmentationPhiEta[m_systemId[iSys]] = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(
m_geoSvc->getDetector()->readout(m_readoutName[iSys]).segmentation().segmentation());
m_segmentationMulti[m_systemId[iSys]] = dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(
m_geoSvc->getDetector()->readout(m_readoutName[iSys]).segmentation().segmentation());
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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<const dd4hep::DDSegmentation::FCCSWGridPhiEta*>(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID()));
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(&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()));
}
Expand Down Expand Up @@ -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<const dd4hep::DDSegmentation::FCCSWGridPhiEta*>(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID()));
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*>(&m_segmentationMulti[systemId]->subsegmentation(cell->getCellID()));
}
dd4hep::DDSegmentation::CellID cID = cell->getCellID();
uint layer = m_decoder[systemId]->get(cID, m_layerFieldName) + m_firstLayerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class VertexCollection;

namespace dd4hep {
namespace DDSegmentation {
class FCCSWGridPhiEta;
class FCCSWGridPhiEta_k4geo;
class MultiSegmentation;
class BitFieldCoder;
}
Expand Down Expand Up @@ -153,7 +153,7 @@ class CorrectECalBarrelSliWinCluster : public GaudiAlgorithm {
Gaudi::Property<std::vector<std::string>> 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<uint, dd4hep::DDSegmentation::FCCSWGridPhiEta*> m_segmentationPhiEta;
std::map<uint, dd4hep::DDSegmentation::FCCSWGridPhiEta_k4geo*> m_segmentationPhiEta;
std::map<uint, dd4hep::DDSegmentation::MultiSegmentation*> m_segmentationMulti;
/// map of system Id to decoder, created based on m_readoutName and m_systemId
std::map<uint, dd4hep::DDSegmentation::BitFieldCoder*> m_decoder;
Expand Down
8 changes: 5 additions & 3 deletions RecCalorimeter/src/components/CreateCaloCells.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include "CreateCaloCells.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"
#include "TGeoManager.h"

// EDM4HEP
// edm4hep
#include "edm4hep/CalorimeterHit.h"

DECLARE_COMPONENT(CreateCaloCells)
Expand Down
Loading
Loading