From 2e58904189afc2045baaa343e1c8ac7fc31cf207 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Mon, 10 Aug 2020 21:26:08 +0800 Subject: [PATCH] WIP: add collections for Ecal Barrel/Endcaps/EndcapRing. --- .../src/Edm4hepWriterAnaElemTool.cpp | 24 ++++++++++++++++--- .../DetSimAna/src/Edm4hepWriterAnaElemTool.h | 17 +++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp index b2930227..1efe317d 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp @@ -49,6 +49,13 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { auto tpccols = m_TPCCol.createAndPut(); auto setcols = m_SETCol.createAndPut(); + auto ecalbarrelcol = m_EcalBarrelCol.createAndPut(); + auto ecalbarrelcontribcols = m_EcalBarrelContributionCol.createAndPut(); + auto ecalendcapscol = m_EcalEndcapsCol.createAndPut(); + auto ecalendcapscontribcols = m_EcalEndcapsContributionCol.createAndPut(); + auto ecalendcapringcol = m_EcalEndcapRingCol.createAndPut(); + auto ecalendcapringcontribcol = m_EcalEndcapRingContributionCol.createAndPut(); + // readout defined in DD4hep auto lcdd = &(dd4hep::Detector::getInstance()); auto allReadouts = lcdd->readouts(); @@ -82,6 +89,7 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { edm4hep::SimTrackerHitCollection* tracker_col_ptr = nullptr; edm4hep::SimCalorimeterHitCollection* calo_col_ptr = nullptr; + edm4hep::CaloHitContributionCollection* calo_contrib_col_ptr = nullptr; // the mapping between hit collection and the data handler if (collect->GetName() == "VXDCollection") { @@ -98,10 +106,20 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { tracker_col_ptr = setcols; } else if (collect->GetName() == "CaloHitsCollection") { calo_col_ptr = calorimetercols; + calo_contrib_col_ptr = calocontribcols; + } else if (collect->GetName() == "EcalBarrelCollection") { + calo_col_ptr = ecalbarrelcol; + calo_contrib_col_ptr = ecalbarrelcontribcols; + } else if (collect->GetName() == "EcalEndcapsCollection") { + calo_col_ptr = ecalendcapscol; + calo_contrib_col_ptr = ecalendcapscontribcols; + } else if (collect->GetName() == "EcalEndcapRingCollection") { + calo_col_ptr = ecalendcapringcol; + calo_contrib_col_ptr = ecalendcapringcontribcol; } else { warning() << "Unknown collection name: " << collect->GetName() - << ". The SimTrackerCol will be used. " << endmsg; - tracker_col_ptr = trackercols; + << ". Please register in Edm4hepWriterAnaElemTool. " << endmsg; + continue; } @@ -191,7 +209,7 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { const Contribution& c = *j; // The legacy Hit object does not contains positions of contributions. // float contrib_pos[] = {float(c.x/mm), float(c.y/mm), float(c.z/mm)}; - auto edm_calo_contrib = calocontribcols->create(); + auto edm_calo_contrib = calo_contrib_col_ptr->create(); edm_calo_contrib.setPDG(c.pdgID); edm_calo_contrib.setEnergy(c.deposit/CLHEP::GeV); edm_calo_contrib.setTime(c.time/CLHEP::ns); diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h index 365078ac..2e69d24e 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h @@ -64,6 +64,23 @@ private: DataHandle<edm4hep::SimTrackerHitCollection> m_SETCol{"SETCollection", Gaudi::DataHandle::Writer, this}; + // Ecal + DataHandle<edm4hep::SimCalorimeterHitCollection> m_EcalBarrelCol{"EcalBarrelCollection", + Gaudi::DataHandle::Writer, this}; + DataHandle<edm4hep::CaloHitContributionCollection> m_EcalBarrelContributionCol{ + "EcalBarrelContributionCollection", + Gaudi::DataHandle::Writer, this}; + DataHandle<edm4hep::SimCalorimeterHitCollection> m_EcalEndcapsCol{"EcalEndcapsCollection", + Gaudi::DataHandle::Writer, this}; + DataHandle<edm4hep::CaloHitContributionCollection> m_EcalEndcapsContributionCol{ + "EcalEndcapsContributionCollection", + Gaudi::DataHandle::Writer, this}; + DataHandle<edm4hep::SimCalorimeterHitCollection> m_EcalEndcapRingCol{"EcalEndcapRingCollection", + Gaudi::DataHandle::Writer, this}; + DataHandle<edm4hep::CaloHitContributionCollection> m_EcalEndcapRingContributionCol{ + "EcalEndcapRingContributionCollection", + Gaudi::DataHandle::Writer, this}; + private: // in order to associate the hit contribution with the primary track, // we have a bookkeeping of every track. -- GitLab