diff --git a/Generator/src/GenAlgo.cpp b/Generator/src/GenAlgo.cpp index 58f9d4e8b438085a5322e565f778506830e7ec14..2d8ec8972668e5565960654176bd71d3d11d870c 100644 --- a/Generator/src/GenAlgo.cpp +++ b/Generator/src/GenAlgo.cpp @@ -13,19 +13,12 @@ #include "IGenTool.h" #include "GenEvent.h" -// #include "StdHepRdr.h" -// #include "HepevtRdr.h"// not correct still -// #include "SLCIORdr.h" -// #include "HepMCRdr.h" -// #include "GenPrinter.h" -// #include "GenWriter.h" -using namespace std; 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; @@ -42,25 +35,6 @@ GenAlgo::initialize() { m_genTools.push_back(gtname); } - // cout << "initialize start" << endl; - // string generatorName = m_input_file.value(); - // string outputName = m_output_file.value(); - // string format = m_input_format.value(); - // IGenTool* gen_reader; - // if(format=="stdhep") gen_reader = new StdHepRdr(generatorName); - // else if(format=="slcio") gen_reader = new SLCIORdr(generatorName); - // else if(format=="hepmc") gen_reader = new HepMCRdr(generatorName); - // else{cout << "Error : unsupport format for generator input file" << endl; return StatusCode::FAILURE; } - // //IGenTool* gen_reader = new HepevtRdr(generatorName); - // m_genTools.push_back(gen_reader); - // if(m_print.value()) { - // IGenTool* gen_printer = new GenPrinter(generatorName); - // m_genTools.push_back(gen_printer); - // } - //IGenTool* gen_writer = new GenWriter (outputName); - //m_genTools.push_back(gen_writer); - - // cout << "initialize done" << endl; return StatusCode::SUCCESS; } @@ -74,16 +48,16 @@ GenAlgo::execute() { for(auto gentool: m_genTools) { if (gentool->mutate(m_event)) {} else { - cout << "Have read all events, stop now." << endl; + warning() << "Have read all events, stop now." << endmsg; auto ep = serviceLocator()->as<IEventProcessor>(); if ( !ep ) { - error() << "Cannot get IEventProcessor" << endmsg; - return StatusCode::FAILURE; + error() << "Cannot get IEventProcessor" << endmsg; + return StatusCode::FAILURE; } ep->stopRun(); return StatusCode::SUCCESS; - } + } } return StatusCode::SUCCESS; @@ -92,10 +66,5 @@ GenAlgo::execute() { StatusCode GenAlgo::finalize() { - // cout << "finalize" << endl; - // for(auto gentool: m_genTools) { - // if (gentool->finish()) {} - // else {cout << "finish Failed" << endl; return StatusCode::FAILURE; } - // } return StatusCode::SUCCESS; } diff --git a/Generator/src/GenAlgo.h b/Generator/src/GenAlgo.h index 2eb6ac616f0a54f9acca641d197016b0fadf6b1f..2fa42bfa2af8eb4e9615ec3663fff798083373bf 100644 --- a/Generator/src/GenAlgo.h +++ b/Generator/src/GenAlgo.h @@ -12,12 +12,6 @@ #include "GenEvent.h" class IGenTool; -namespace plcio { - class MCParticleCollection; -} - - -using namespace std; class GenAlgo: public GaudiAlgorithm { @@ -42,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}; }; diff --git a/Generator/src/GenWriter.cpp b/Generator/src/GenWriter.cpp deleted file mode 100644 index f1f93a571dabc98f710c660754ae6507248c0212..0000000000000000000000000000000000000000 --- a/Generator/src/GenWriter.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#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; -} diff --git a/Generator/src/GenWriter.h b/Generator/src/GenWriter.h deleted file mode 100644 index 30e6db4365343c44f0f7de97781774f0e5700db3..0000000000000000000000000000000000000000 --- a/Generator/src/GenWriter.h +++ /dev/null @@ -1,35 +0,0 @@ -#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 diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h index 7b992d3076c0ddfa7b7bd9f5d8639274ba0538b1..937869b4a7a1f19d0c26c7828976934f12e8e8c2 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h @@ -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; diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.h b/Simulation/DetSimCore/src/G4PrimaryCnvTool.h index 1e47772177fd0c5f2e57029bae512a2c12f7813e..70b143fc57409b0f1010a86636b5db84d3391855 100644 --- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.h +++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.h @@ -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"}; };