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

Fix system id for caloCellPosition [temporary, should refactor this] #429

Merged
merged 2 commits into from
Dec 3, 2020
Merged
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
10 changes: 10 additions & 0 deletions Reconstruction/RecFCCeeCalorimeter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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(); }
Original file line number Diff line number Diff line change
@@ -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<ICellPositionsTool> m_cellPositionsECalBarrelTool;
/// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation
ToolHandle<ICellPositionsTool> m_cellPositionsHCalBarrelTool;
/// Handle for tool to get positions in HCal Barrel and Ext Barrel, no Segmentation
ToolHandle<ICellPositionsTool> m_cellPositionsHCalExtBarrelTool;
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsEMECTool;
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsHECTool;
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsEMFwdTool;
/// Handle for tool to get positions in Calo Discs
ToolHandle<ICellPositionsTool> m_cellPositionsHFwdTool;
/// Decoder for system ID
dd4hep::DDSegmentation::BitFieldCoder* m_decoder = new dd4hep::DDSegmentation::BitFieldCoder("system:4");
/// Input collection
DataHandle<fcc::CaloHitCollection> m_hits{"hits/hits", Gaudi::DataHandle::Reader, this};
/// Output collection
DataHandle<fcc::PositionedCaloHitCollection> m_positionedHits{"hits/positionedHits", Gaudi::DataHandle::Writer, this};
};

#endif /* DETCOMPONENTS_CREATECELLPOSITIONSFCCEE_H */