Skip to content

Commit

Permalink
Removing specialized handles for positions tool (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt authored Oct 26, 2023
1 parent 25bf476 commit a0d919e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 110 deletions.
71 changes: 11 additions & 60 deletions RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,20 @@ DECLARE_COMPONENT(CreateCaloCellPositionsFCCee)
CreateCaloCellPositionsFCCee::CreateCaloCellPositionsFCCee(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc) {
declareProperty("hits", m_hits, "Hit collection (input)");
declareProperty("positionsECalBarrelTool", m_cellPositionsECalBarrelTool,
"Handle for tool to retrieve cell positions in ECal Barrel");
declareProperty("positionsHCalBarrelTool", m_cellPositionsHCalBarrelTool,
"Handle for tool to retrieve cell positions in HCal Barrel and ext Barrel");
declareProperty("positionsHCalExtBarrelTool", m_cellPositionsHCalExtBarrelTool,
"Handle for tool to retrieve cell positions in HCal Barrel and 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");
declareProperty("positionsEMFwdTool", m_cellPositionsEMFwdTool, "Handle for tool to retrieve cell positions EM Fwd");
declareProperty("positionsHFwdTool", m_cellPositionsHFwdTool, "Handle for tool to retrieve cell positions Had Fwd");
declareProperty("positionedHits", m_positionedHits, "Output cell positions collection");
declareProperty("positionsTool", m_cellPositionsTool,
"Handle for tool to retrieve cell positions from");
declareProperty("positionedHits", m_positionedHits,
"Output cell positions collection");
}

StatusCode CreateCaloCellPositionsFCCee::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) return sc;

if (!m_cellPositionsECalBarrelTool) {
error() << "CellPositionsTool for ECal Barrel is missing!" << endmsg;
return StatusCode::FAILURE;
}
if (!m_cellPositionsHCalBarrelTool) {
error() << "CellPositionsTool for HCal Barrel is missing!" << endmsg;
return StatusCode::FAILURE;
{
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) return sc;
}
if (!m_cellPositionsHCalExtBarrelTool) {
error() << "CellPositionsTool for HCal Ext Barrel is missing!" << endmsg;
return StatusCode::FAILURE;
}
if (!m_cellPositionsEMECTool) {
error() << "CellPositionsTool for EMEC is missing!" << endmsg;
return StatusCode::FAILURE;
}
if (!m_cellPositionsHECTool) {
error() << "CellPositionsTool for HEC is missing!" << endmsg;
return StatusCode::FAILURE;
}
if (!m_cellPositionsEMFwdTool) {
error() << "CellPositionsTool for EMFwd is missing!" << endmsg;
return StatusCode::FAILURE;
}
if (!m_cellPositionsHFwdTool) {
error() << "CellPositionsTool for HFwd is missing!" << endmsg;

if (!m_cellPositionsTool) {
error() << "CellPositionsTool is missing!" << endmsg;
return StatusCode::FAILURE;
}

Expand All @@ -82,27 +53,7 @@ StatusCode CreateCaloCellPositionsFCCee::execute() {
auto cached_pos = m_positions_cache.find(cellId);
if(cached_pos == m_positions_cache.end()) {
// identify calo system
auto systemId = m_decoder->get(cellId, m_system_id);
dd4hep::Position posCell;

if (systemId == m_systemIdECalBarrel) { // ECAL BARREL system id
posCell = m_cellPositionsECalBarrelTool->xyzPosition(cellId);
} else if (systemId == m_systemIdHCalBarrel) { // HCAL BARREL system id
posCell = m_cellPositionsHCalBarrelTool->xyzPosition(cellId);
} else if (systemId == m_systemIdHCalExtBarrel) { // HCAL EXT BARREL
posCell = m_cellPositionsHCalExtBarrelTool->xyzPosition(cellId);
} else if (systemId == m_systemIdEMEC) { // EMEC system id
posCell = m_cellPositionsEMECTool->xyzPosition(cellId);
} else if (systemId == m_systemIdHEC) { // HEC system id
posCell = m_cellPositionsHECTool->xyzPosition(cellId);
} else if (systemId == m_systemIdEMFwd) { // EMFWD system id
posCell = m_cellPositionsEMFwdTool->xyzPosition(cellId);
} else if (systemId == m_systemIdHFwd) { // HFWD system id
posCell = m_cellPositionsHFwdTool->xyzPosition(cellId);
} else {
error() << "Unknown system ID!" << endmsg;
return StatusCode::FAILURE;
}
dd4hep::Position posCell = m_cellPositionsTool->xyzPosition(cellId);

edm4hep::Vector3f edmPos;
edmPos.x = posCell.x() / dd4hep::mm;
Expand Down
51 changes: 5 additions & 46 deletions RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,59 +45,18 @@ class CreateCaloCellPositionsFCCee : public GaudiAlgorithm {
StatusCode finalize();

private:
/// ECal Barrel System ID
Gaudi::Property<size_t> m_systemIdECalBarrel {
this, "systemIdECalBarrel", 4, "System ID of ECal Barrel"
};
/// HCal Barrel System ID
Gaudi::Property<size_t> m_systemIdHCalBarrel {
this, "systemIdHCalBarrel", 8, "System ID of HCal Barrel"
};
/// HCal Extended Barrel System ID
Gaudi::Property<size_t> m_systemIdHCalExtBarrel {
this, "systemIdHCalExtBarrel", 9, "System ID of HCal Extended Barrel"
};
/// EMEC System ID
Gaudi::Property<size_t> m_systemIdEMEC {
this, "systemIdEMEC", 6, "System ID of EMEC"
};
/// HEC System ID
Gaudi::Property<size_t> m_systemIdHEC {
this, "systemIdHEC", 7, "System ID of HEC"
};
/// EMFwd System ID
Gaudi::Property<size_t> m_systemIdEMFwd {
this, "systemIdEMFwd", 999, "System ID of EMFwd"
};
/// HFwd System ID
Gaudi::Property<size_t> m_systemIdHFwd {
this, "systemIdHFwd", 999, "System ID of HFwd"
};

/// Handle for tool to get positions in ECal Barrel
ToolHandle<ICellPositionsTool> m_cellPositionsECalBarrelTool{"CellPositionsECalBarrelTool/CellPositionsTool"};
/// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation
ToolHandle<ICellPositionsTool> m_cellPositionsHCalBarrelTool{"CellPositionsHCalBarrelTool/CellPositionsTool"};
/// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation
ToolHandle<ICellPositionsTool> m_cellPositionsHCalExtBarrelTool{"CellPositionsHCalBarrelNoSegTool/CellPositionsTool"};
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsEMECTool{"CellPositionsCaloDiscsTool/CellPositionsTool"};
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsHECTool{"CellPositionsCaloDiscsTool/CellPositionsTool"};
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsEMFwdTool{"CellPositionsCaloDiscsTool/CellPositionsTool"};
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsHFwdTool{"CellPositionsCaloDiscsTool/CellPositionsTool"};
/// Decoder for system ID
dd4hep::DDSegmentation::BitFieldCoder* m_decoder = new dd4hep::DDSegmentation::BitFieldCoder("system:4");
/// Handle for tool to get positions width
ToolHandle<ICellPositionsTool> m_cellPositionsTool{};
/// Input collection
DataHandle<edm4hep::CalorimeterHitCollection> m_hits{"hits/hits", Gaudi::DataHandle::Reader, this};
/// Input collection metadata handle
MetaDataHandle<std::string> m_hitsCellIDEncoding{m_hits, "CellIDEncodingString", Gaudi::DataHandle::Reader};
/// Output collection
DataHandle<edm4hep::CalorimeterHitCollection> m_positionedHits{"hits/positionedHits", Gaudi::DataHandle::Writer, this};
/// Output collection metadata handle
MetaDataHandle<std::string> m_positionedHitsCellIDEncoding{m_positionedHits, "CellIDEncodingString", Gaudi::DataHandle::Writer};

int m_system_id = m_decoder->index("system");
// Cache
std::unordered_map<dd4hep::DDSegmentation::CellID, edm4hep::Vector3f> m_positions_cache{};
};

Expand Down
4 changes: 2 additions & 2 deletions RecFCCeeCalorimeter/tests/options/reproduceSegfault.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@

from Configurables import CreateCaloCellPositionsFCCee
createEcalBarrelPositionedCells = CreateCaloCellPositionsFCCee("ECalBarrelPositionedCells", OutputLevel = INFO)
createEcalBarrelPositionedCells.positionsECalBarrelTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCells.positionsTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCells.hits.Path = EcalBarrelCellsName
createEcalBarrelPositionedCells.positionedHits.Path = "ECalBarrelPositionedCells"

Expand Down Expand Up @@ -269,7 +269,7 @@


createEcalBarrelPositionedCaloClusterCells = CreateCaloCellPositionsFCCee("ECalBarrelPositionedCaloClusterCells", OutputLevel = INFO)
createEcalBarrelPositionedCaloClusterCells.positionsECalBarrelTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCaloClusterCells.positionsTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCaloClusterCells.hits.Path = "CaloClusterCells"
createEcalBarrelPositionedCaloClusterCells.positionedHits.Path = "PositionedCaloClusterCells"

Expand Down
4 changes: 2 additions & 2 deletions RecFCCeeCalorimeter/tests/options/runCaloSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@

from Configurables import CreateCaloCellPositionsFCCee
createEcalBarrelPositionedCells = CreateCaloCellPositionsFCCee("ECalBarrelPositionedCells")
createEcalBarrelPositionedCells.positionsECalBarrelTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCells.positionsTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCells.hits.Path = "ECalBarrelCells"
createEcalBarrelPositionedCells.positionedHits.Path = "ECalBarrelPositionedCells"
ApplicationMgr().TopAlg += [createEcalBarrelPositionedCells]
Expand Down Expand Up @@ -272,7 +272,7 @@

# Add position to the cells attached to the cluster
createEcalBarrelPositionedCaloClusterCells = CreateCaloCellPositionsFCCee("ECalBarrelPositionedCaloClusterCells")
createEcalBarrelPositionedCaloClusterCells.positionsECalBarrelTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCaloClusterCells.positionsTool = cellPositionEcalBarrelTool
createEcalBarrelPositionedCaloClusterCells.hits.Path = "CaloClusterCells"
createEcalBarrelPositionedCaloClusterCells.positionedHits.Path = "PositionedCaloClusterCells"

Expand Down

0 comments on commit a0d919e

Please sign in to comment.