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

WIP: rename the MCParticle collections names at gen and sim phases.

parent c9647705
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
DECLARE_COMPONENT(GenAlgo)
GenAlgo::GenAlgo(const std::string& name, ISvcLocator* pSvcLocator): GaudiAlgorithm(name, pSvcLocator) {
declareProperty("MCParticle", m_hdl, "MCParticle collection (output)");
declareProperty("MCParticleGen", m_hdl, "MCParticle collection (at Generator phase)");
declareProperty("GenTools", m_genToolNames, "List of GenTools");
m_evtid = 0;
......
......@@ -36,7 +36,7 @@ private:
int m_evtid;
int m_evtMax;
//MyHepMC::GenEvent m_event;
DataHandle<edm4hep::MCParticleCollection> m_hdl{"MCParticle", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::MCParticleCollection> m_hdl{"MCParticleGen", Gaudi::DataHandle::Writer, this};
};
......
#include "GenWriter.h"
#include "GenEvent.h"
#include "podio/EventStore.h" //podio
#include "podio/ROOTWriter.h"
#include "plcio/MCParticleCollection.h"//plico
#include "plcio/EventHeaderCollection.h"
GenWriter::GenWriter(string name){
m_output_name = name;
store = new podio::EventStore();
writer = new podio::ROOTWriter(m_output_name, store);
ehc = &store->create<plcio::EventHeaderCollection>("EvtHeaders");
mcc = &store->create<plcio::MCParticleCollection>("MCParticles");
writer->registerForWrite("EvtHeaders");
writer->registerForWrite("MCParticles");
}
GenWriter::~GenWriter(){
}
bool GenWriter::mutate(MyHepMC::GenEvent& event){
std::cout << "write mc info for event "<< event.getID() << ", mc size ="<< event.m_mc_vec.size() << std::endl;
mcc=&event.m_mc_vec;
auto header = plcio::EventHeader(event.getID(), event.getRun(), event.getTime(), event.getName());
ehc->push_back(header);
writer->writeEvent();
store->clearCollections();
return true;
}
bool GenWriter::configure(){
return true;
}
bool GenWriter::finish(){
writer->finish();
std::cout<<"Saved root "<<m_output_name<<std::endl;
return true;
}
#ifndef GenWriter_h
#define GenWriter_h 1
#include "GenEvent.h"
#include "IGenTool.h"
#include "podio/EventStore.h" //podio
#include "podio/ROOTWriter.h"
#include "plcio/MCParticleCollection.h"//plico
#include "plcio/EventHeaderCollection.h"
using namespace std;
class GenWriter: public IGenTool{
public:
GenWriter(string name);
~GenWriter();
bool configure() override;
bool mutate(MyHepMC::GenEvent& event) override;
bool finish() override;
private:
string m_output_name;
podio::EventStore* store ;
podio::ROOTWriter* writer;
plcio::EventHeaderCollection* ehc ;
plcio::MCParticleCollection* mcc ;
};
#endif
......@@ -42,10 +42,10 @@ public:
private:
// In order to associate MCParticle with contribution, we need to access MC Particle.
// - collection MCParticle: the particles in Generator
DataHandle<edm4hep::MCParticleCollection> m_mcParGenCol{"MCParticle",
DataHandle<edm4hep::MCParticleCollection> m_mcParGenCol{"MCParticleGen",
Gaudi::DataHandle::Writer, this};
// - collection MCParticleG4: the simulated particles in Geant4
DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticleG4",
DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle",
Gaudi::DataHandle::Writer, this};
edm4hep::MCParticleCollection* mcCol;
......
......@@ -16,7 +16,7 @@ public:
bool mutate(G4Event* anEvent) override;
private:
DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticleGen", Gaudi::DataHandle::Reader, this};
Gaudi::Property<double> m_chargedgeantino_mass{this, "ChargedGeantinoMass"};
};
......
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