From 8ba6190a10e5fbaafd3d3de952e8dd75bdd2f4c0 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Sat, 20 Jun 2020 15:26:55 +0800 Subject: [PATCH] WIP: Update the example to read the output of ECAL matrix. --- Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp | 29 ++++++++++++++++++--- Examples/src/Edm4hepTest/Edm4hepReadAlg.h | 6 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp b/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp index 8ab3ed0e..f41d333b 100644 --- a/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp +++ b/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp @@ -1,6 +1,8 @@ #include "Edm4hepReadAlg.h" #include "edm4hep/EventHeaderCollection.h" #include "edm4hep/MCParticleCollection.h" +#include "edm4hep/SimCalorimeterHitCollection.h" +#include "edm4hep/CaloHitContributionCollection.h" DECLARE_COMPONENT(Edm4hepReadAlg) @@ -21,11 +23,7 @@ StatusCode Edm4hepReadAlg::execute() { debug() << "begin execute Edm4hepReadAlg" << endmsg; - auto headers = m_headerCol.get(); - auto header = headers->at(0); auto mcCol = m_mcParCol.get(); - - info() << "Run " << header.getRunNumber() << " Event " << header.getEventNumber() << " { "; for ( auto p : *mcCol ) { info() << p.getObjectID().index << " : ["; for ( auto it = p.daughters_begin(), end = p.daughters_end(); it != end; ++it ) { @@ -35,6 +33,29 @@ StatusCode Edm4hepReadAlg::execute() } info() << "}" << endmsg; + auto caloCol = m_calorimeterCol.get(); + for (auto calohit : *caloCol) { + unsigned int contrib_size = calohit.contributions_size(); + info() << " contributions_size: " + << contrib_size + << endmsg; + for (unsigned int i = 0; i < contrib_size; ++i) { + auto contrib = calohit.getContributions(i); + auto primary_particle = contrib.getParticle(); + + info() << " - #" << i << ": " + << " track with " + << " PDG: " << contrib.getPDG() // current track + << ". " + << " primary track with " + << " PDG: " << primary_particle.getPDG() + << endmsg; + + + } + + } + return StatusCode::SUCCESS; } diff --git a/Examples/src/Edm4hepTest/Edm4hepReadAlg.h b/Examples/src/Edm4hepTest/Edm4hepReadAlg.h index a5a5e14e..8a194a64 100644 --- a/Examples/src/Edm4hepTest/Edm4hepReadAlg.h +++ b/Examples/src/Edm4hepTest/Edm4hepReadAlg.h @@ -7,6 +7,8 @@ namespace edm4hep { class EventHeaderCollection; class MCParticleCollection; + class SimCalorimeterHitCollection; + class CaloHitContributionCollection; } class Edm4hepReadAlg : public GaudiAlgorithm @@ -24,6 +26,10 @@ class Edm4hepReadAlg : public GaudiAlgorithm DataHandle<edm4hep::EventHeaderCollection> m_headerCol{"EventHeader", Gaudi::DataHandle::Reader, this}; DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle", Gaudi::DataHandle::Reader, this}; + DataHandle<edm4hep::SimCalorimeterHitCollection> m_calorimeterCol{"SimCalorimeterCol", + Gaudi::DataHandle::Reader, this}; + DataHandle<edm4hep::CaloHitContributionCollection> m_caloContribCol{"SimCaloContributionCol", + Gaudi::DataHandle::Reader, this}; }; -- GitLab