Skip to content
Snippets Groups Projects
Commit 050f95a4 authored by zoujh@ihep.ac.cn's avatar zoujh@ihep.ac.cn
Browse files

make edm4hep read & write examples be consistency

parent 36fa9b36
No related branches found
No related tags found
No related merge requests found
......@@ -5,17 +5,19 @@ from Gaudi.Configuration import *
from Configurables import K4DataSvc
dsvc = K4DataSvc("EventDataSvc", input="test.root")
from Configurables import Edm4hepReadAlg
alg = Edm4hepReadAlg("Edm4hepReadAlg")
alg.HeaderCol.Path = "EventHeader"
alg.InputCol.Path = "MCParticle"
from Configurables import PodioInput
podioinput = PodioInput("PodioReader", collections=[
"EventHeader",
"MCParticle"
"MCParticle",
"SimCalorimeterHit"
])
from Configurables import Edm4hepReadAlg
alg = Edm4hepReadAlg("Edm4hepReadAlg")
#alg.HeaderCol.Path = "EventHeader"
#alg.MCParticleCol.Path = "MCParticle"
alg.SimCalorimeterHitCol.Path = "SimCalorimeterHit"
# ApplicationMgr
from Configurables import ApplicationMgr
ApplicationMgr( TopAlg = [podioinput, alg],
......
......@@ -7,8 +7,8 @@ dsvc = K4DataSvc("EventDataSvc")
from Configurables import Edm4hepWriteAlg
alg = Edm4hepWriteAlg("Edm4hepWriteAlg")
alg.HeaderCol.Path = "EventHeader"
alg.OutputCol.Path = "MCParticle"
alg.HeaderOut.Path = "EventHeader"
alg.MCParticleOut.Path = "MCParticle"
from Configurables import PodioOutput
out = PodioOutput("out")
......
......@@ -10,7 +10,8 @@ Edm4hepReadAlg::Edm4hepReadAlg(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc)
{
declareProperty("HeaderCol", m_headerCol);
declareProperty("InputCol", m_mcParCol, "MCParticle collection (input)");
declareProperty("MCParticleCol", m_mcParCol, "MCParticle collection (input)");
declareProperty("SimCalorimeterHitCol", m_calorimeterCol, "MCParticle collection (input)");
}
StatusCode Edm4hepReadAlg::initialize()
......
#include "Edm4hepWriteAlg.h"
#include "edm4hep/EventHeaderCollection.h"
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
#include "edm4hep/CaloHitContributionCollection.h"
DECLARE_COMPONENT(Edm4hepWriteAlg)
Edm4hepWriteAlg::Edm4hepWriteAlg(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc)
{
declareProperty("HeaderCol", m_headerCol);
declareProperty("OutputCol", m_mcParCol, "MCParticle collection (output)");
declareProperty("HeaderOut", m_headerCol);
declareProperty("MCParticleOut", m_mcParCol, "MCParticle collection (output)");
declareProperty("SimCalorimeterHitOut", m_simCaloHitCol, "SimCalorimeterHit collection (output)");
declareProperty("CaloHitContributionOut", m_caloHitContCol, "CaloHitContribution collection (output)");
}
StatusCode Edm4hepWriteAlg::initialize()
......@@ -32,6 +36,8 @@ StatusCode Edm4hepWriteAlg::execute()
//auto mcCol = new edm4hep::MCParticleCollection;
//m_mcParCol.put(mcCol);
auto mcCol = m_mcParCol.createAndPut();
auto simCaloCol = m_simCaloHitCol.createAndPut();
auto caloHitContCol = m_caloHitContCol.createAndPut();
auto p1 = mcCol->create();
auto p2 = mcCol->create();
......@@ -42,6 +48,13 @@ StatusCode Edm4hepWriteAlg::execute()
d.addToParents(p2);
p1.addToDaughters(d);
p2.addToDaughters(d);
auto hit = simCaloCol->create();
for ( int j = 0; j < i; ++j ) {
auto cont = caloHitContCol->create();
cont.setParticle(mcCol->at(j));
hit.addToContributions(cont);
}
}
return StatusCode::SUCCESS;
......
......@@ -7,6 +7,8 @@
namespace edm4hep {
class EventHeaderCollection;
class MCParticleCollection;
class SimCalorimeterHitCollection;
class CaloHitContributionCollection;
}
class Edm4hepWriteAlg : public GaudiAlgorithm
......@@ -24,7 +26,8 @@ class Edm4hepWriteAlg : public GaudiAlgorithm
DataHandle<edm4hep::EventHeaderCollection> m_headerCol{"EventHeader", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::SimCalorimeterHitCollection> m_simCaloHitCol{"SimCalorimeterHit", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::CaloHitContributionCollection> m_caloHitContCol{"CaloHitContribution", Gaudi::DataHandle::Writer, this};
};
#endif // TEST_EDM4HEP_WRITE_ALG_H
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