Skip to content
Snippets Groups Projects
Commit 8ba6190a authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: Update the example to read the output of ECAL matrix.

parent 69625043
No related branches found
No related tags found
No related merge requests found
#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;
}
......
......@@ -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};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment