diff --git a/Reconstruction/RecFCCeeCalorimeter/CMakeLists.txt b/Reconstruction/RecFCCeeCalorimeter/CMakeLists.txt index f7ce61e52..90b08756d 100644 --- a/Reconstruction/RecFCCeeCalorimeter/CMakeLists.txt +++ b/Reconstruction/RecFCCeeCalorimeter/CMakeLists.txt @@ -5,6 +5,16 @@ gaudi_subdir(RecFCCeeCalorimeter v1r0) gaudi_depends_on_subdirs(GaudiAlg FWCore Detector/DetInterface Detector/DetSegmentation Detector/DetCommon Reconstruction/RecInterface Reconstruction/RecCalorimeter) +find_package(FastJet) +find_package(ROOT COMPONENTS Physics Tree) +find_package(FCCEDM) +find_package(PODIO) +find_package(HepMC) +gaudi_add_module(RecFCCeeCalorimeterPlugins + src/components/*.cpp + INCLUDE_DIRS FWCore FastJet ROOT FWCore HepMC FCCEDM PODIO DD4hep DetInterface DetSegmentation Geant4 DetCommon RecInterface RecCalorimeter RecFCCeeCalorimeter + LINK_LIBRARIES FWCore Fastjet ROOT GaudiAlgLib FCCEDM PODIO HepMC DD4hep DetSegmentation DetCommon) +target_link_libraries(RecFCCeeCalorimeterPlugins ${Geant4_LIBRARIES}) install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/options DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/RecFCCeeCalorimeter) diff --git a/Reconstruction/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp b/Reconstruction/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp new file mode 100644 index 000000000..bf9bcdc9c --- /dev/null +++ b/Reconstruction/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.cpp @@ -0,0 +1,85 @@ +#include "CreateCaloCellPositionsFCCee.h" + +// FCCSW +#include "DetCommon/DetUtils.h" +#include "DetInterface/IGeoSvc.h" + +// DD4hep +#include "DD4hep/Detector.h" + +// EDM +#include "datamodel/CaloHitCollection.h" +#include "datamodel/PositionedCaloHitCollection.h" +#include "datamodel/PositionedTrackHitCollection.h" +#include "datamodel/TrackHitCollection.h" + +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"); +} + +StatusCode CreateCaloCellPositionsFCCee::initialize() { + StatusCode sc = GaudiAlgorithm::initialize(); + if (sc.isFailure()) return sc; + return StatusCode::SUCCESS; +} + +StatusCode CreateCaloCellPositionsFCCee::execute() { + // Get the input hit collection + const auto* hits = m_hits.get(); + debug() << "Input hit collection size: " << hits->size() << endmsg; + // Initialize output collection + auto edmPositionedHitCollection = m_positionedHits.createAndPut(); + + for (const auto& hit : *hits) { + dd4hep::DDSegmentation::CellID cellId = hit.core().cellId; + // identify calo system + auto systemId = m_decoder->get(cellId, "system"); + dd4hep::Position posCell; + + if (systemId == 4) // ECAL BARREL system id + posCell = m_cellPositionsECalBarrelTool->xyzPosition(cellId); + else if (systemId == 10) // HCAL BARREL system id + posCell = m_cellPositionsHCalBarrelTool->xyzPosition(cellId); + else if (systemId == 9) // HCAL EXT BARREL system id + posCell = m_cellPositionsHCalExtBarrelTool->xyzPosition(cellId); + else if (systemId == 6) // EMEC system id + posCell = m_cellPositionsEMECTool->xyzPosition(cellId); + else if (systemId == 7) // HEC system id + posCell = m_cellPositionsHECTool->xyzPosition(cellId); + else if (systemId == 10) // EMFWD system id + posCell = m_cellPositionsEMFwdTool->xyzPosition(cellId); + else if (systemId == 11) // HFWD system id + posCell = m_cellPositionsHFwdTool->xyzPosition(cellId); + + auto edmPos = fcc::Point(); + edmPos.x = posCell.x() / dd4hep::mm; + edmPos.y = posCell.y() / dd4hep::mm; + edmPos.z = posCell.z() / dd4hep::mm; + + auto positionedHit = edmPositionedHitCollection->create(edmPos, hit.core()); + + // Debug information about cell position + debug() << "Cell energy (GeV) : " << hit.core().energy << "\tcellID " << hit.core().cellId << endmsg; + debug() << "Position of cell (mm) : \t" << posCell.x() / dd4hep::mm << "\t" << posCell.y() / dd4hep::mm << "\t" + << posCell.z() / dd4hep::mm << endmsg; + } + + debug() << "Output positions collection size: " << edmPositionedHitCollection->size() << endmsg; + return StatusCode::SUCCESS; +} + +StatusCode CreateCaloCellPositionsFCCee::finalize() { return GaudiAlgorithm::finalize(); } diff --git a/Reconstruction/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h b/Reconstruction/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h new file mode 100644 index 000000000..338798abf --- /dev/null +++ b/Reconstruction/RecFCCeeCalorimeter/src/components/CreateCaloCellPositionsFCCee.h @@ -0,0 +1,69 @@ +#ifndef DETCOMPONENTS_CREATECELLPOSITIONSFCCEE_H +#define DETCOMPONENTS_CREATECELLPOSITIONSFCCEE_H + +// FCCSW +#include "FWCore/DataHandle.h" +#include "RecInterface/ICellPositionsTool.h" + +// Gaudi +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" + +#include "datamodel/CaloHit.h" +#include "datamodel/CaloHitCollection.h" +#include "datamodel/PositionedCaloHit.h" +#include "datamodel/PositionedCaloHitCollection.h" + +class IGeoSvc; + +/** @class CreateCaloCellPositions Reconstruction/RecCalorimeter/src/components/CreateCaloCellPositions.h + * CreateCaloCellPositions.h + * + * Retrieve positions of the cells from cell ID. + * This algorithm saves the centre position of the volume. Defined for all Calo-Subsystems within tools. + * + * @author Coralie Neubueser + * + */ + +class CreateCaloCellPositionsFCCee : public GaudiAlgorithm { + +public: + CreateCaloCellPositionsFCCee(const std::string& name, ISvcLocator* svcLoc); + /** Initialize. + * @return status code + */ + StatusCode initialize(); + /** Execute. + * @return status code + */ + StatusCode execute(); + /** Finalize. + * @return status code + */ + StatusCode finalize(); + +private: + /// Handle for tool to get positions in ECal Barrel + ToolHandle m_cellPositionsECalBarrelTool; + /// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation + ToolHandle m_cellPositionsHCalBarrelTool; + /// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation + ToolHandle m_cellPositionsHCalExtBarrelTool; + /// Handle for tool to get positions in Calo Discs + ToolHandle m_cellPositionsEMECTool; + /// Handle for tool to get positions in Calo Discs + ToolHandle m_cellPositionsHECTool; + /// Handle for tool to get positions in Calo Discs + ToolHandle m_cellPositionsEMFwdTool; + /// Handle for tool to get positions in Calo Discs + ToolHandle m_cellPositionsHFwdTool; + /// Decoder for system ID + dd4hep::DDSegmentation::BitFieldCoder* m_decoder = new dd4hep::DDSegmentation::BitFieldCoder("system:4"); + /// Input collection + DataHandle m_hits{"hits/hits", Gaudi::DataHandle::Reader, this}; + /// Output collection + DataHandle m_positionedHits{"hits/positionedHits", Gaudi::DataHandle::Writer, this}; +}; + +#endif /* DETCOMPONENTS_CREATECELLPOSITIONSFCCEE_H */