diff --git a/Examples/options/edm4hep_read.py b/Examples/options/edm4hep_read.py index 998b300ec72179a375eb687f25dcbc09a742108b..fa8edc535d3e94e8e4b28105279fdcddb8e6f339 100644 --- a/Examples/options/edm4hep_read.py +++ b/Examples/options/edm4hep_read.py @@ -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], diff --git a/Examples/options/edm4hep_write.py b/Examples/options/edm4hep_write.py index f5ad0bef5550d9cab2a7d6e451bb189fefa6120b..935440fc0dadf111ce6fae9f3396398b3f8cb3a6 100644 --- a/Examples/options/edm4hep_write.py +++ b/Examples/options/edm4hep_write.py @@ -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") diff --git a/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp b/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp index f41d333b18a5da763b0c7d21ce7f879f29cda822..c2c70be13e5b4ddc704d8b3c883c0817812056ab 100644 --- a/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp +++ b/Examples/src/Edm4hepTest/Edm4hepReadAlg.cpp @@ -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() diff --git a/Examples/src/Edm4hepTest/Edm4hepWriteAlg.cpp b/Examples/src/Edm4hepTest/Edm4hepWriteAlg.cpp index b33d5e8045507a7514a7358aa8375f7e9326b544..39273600d4763e015fe011c0a70397bbc9d9301a 100644 --- a/Examples/src/Edm4hepTest/Edm4hepWriteAlg.cpp +++ b/Examples/src/Edm4hepTest/Edm4hepWriteAlg.cpp @@ -1,14 +1,18 @@ #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; diff --git a/Examples/src/Edm4hepTest/Edm4hepWriteAlg.h b/Examples/src/Edm4hepTest/Edm4hepWriteAlg.h index 8058747476ab106edd3cdca52be0d04ba3110f33..2d980885b538d77fa56e26c177dba78211e115d5 100644 --- a/Examples/src/Edm4hepTest/Edm4hepWriteAlg.h +++ b/Examples/src/Edm4hepTest/Edm4hepWriteAlg.h @@ -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