diff --git a/k4Gen/src/components/GenAlg.cpp b/k4Gen/src/components/GenAlg.cpp index d21f6a4..b6be67f 100644 --- a/k4Gen/src/components/GenAlg.cpp +++ b/k4Gen/src/components/GenAlg.cpp @@ -1,60 +1,110 @@ - +// GenAlg #include "GenAlg.h" +// Gaudi #include "GaudiKernel/IEventProcessor.h" #include "GaudiKernel/IIncidentSvc.h" #include "GaudiKernel/Incident.h" +// HepMC3 #include "HepMC3/GenEvent.h" DECLARE_COMPONENT(GenAlg) GenAlg::GenAlg(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { + declareProperty("SignalProvider", m_signalProvider, + "Signal events provider tool"); + declareProperty("PileUpTool", m_pileUpTool, "Pileup tool"); + declareProperty("PileUpProvider", m_pileUpProvider, + "Pileup events provider tool"); + declareProperty("VertexSmearingTool", m_vertexSmearingTool, + "Vertex smearing tool"); + declareProperty("HepMCMergeTool", m_HepMCMergeTool, "Event merge tool"); + declareProperty("hepmc", m_hepmcHandle, "HepMC event handle (output)"); +} + +StatusCode GenAlg::initialize() { + { + StatusCode sc = GaudiAlgorithm::initialize(); + if (!sc.isSuccess()) return sc; + } - declareProperty("PileUpTool", m_pileUpTool); + if (!m_signalProvider) { + error() << "Signal event provider is missing!" << endmsg; + return StatusCode::FAILURE; + } - declareProperty("VertexSmearingTool", m_vertexSmearingTool); + if (!m_vertexSmearingTool) { + error() << "Vertex smearing tool is missing!" << endmsg; + return StatusCode::FAILURE; + } - declareProperty("HepMCMergeTool", m_HepMCMergeTool); + if (!m_pileUpTool) { + error() << "Pileup tool is missing!" << endmsg; + return StatusCode::FAILURE; + } - declareProperty("SignalProvider", m_signalProvider); - declareProperty("PileUpProvider", m_pileUpProvider); + if (!m_pileUpProvider) { + error() << "Pileup provider is missing!" << endmsg; + return StatusCode::FAILURE; + } - declareProperty("hepmc", m_hepmchandle, "HepMC event handle (output)"); -} + if (!m_HepMCMergeTool) { + error() << "Event merge tool is missing!" << endmsg; + return StatusCode::FAILURE; + } -StatusCode GenAlg::initialize() { - StatusCode sc = GaudiAlgorithm::initialize(); - if (!sc.isSuccess()) return sc; - return sc; + return StatusCode::SUCCESS; } StatusCode GenAlg::execute() { - HepMC3::GenEvent* theEvent = m_hepmchandle.createAndPut(); + // Create empty event + auto theEvent = m_hepmcHandle.createAndPut(); theEvent->set_units(HepMC3::Units::GEV, HepMC3::Units::MM); + + // Get the event from the signal provider + { + StatusCode sc = m_signalProvider->getNextEvent(*theEvent); + if (!sc.isSuccess()) return sc; + } + + // Smear vertex + { + StatusCode sc = m_vertexSmearingTool->smearVertex(*theEvent); + if (!sc.isSuccess()) return sc; + } + + // Get number of pileup events const unsigned int numPileUp = m_pileUpTool->numberOfPileUp(); - std::vector eventVector; - eventVector.reserve(numPileUp + 1); - StatusCode sc; - if (!m_signalProvider.empty()) { - sc = m_signalProvider->getNextEvent(*theEvent); - } - if (StatusCode::SUCCESS != sc) { - return sc; - } - m_vertexSmearingTool->smearVertex(*theEvent).ignore(); - if (!m_pileUpProvider.empty()) { - for (unsigned int i_pileUp = 0; i_pileUp < numPileUp; ++i_pileUp) { - auto puEvt = HepMC3::GenEvent(); - sc = m_pileUpProvider->getNextEvent(puEvt); - if (StatusCode::SUCCESS != sc) { - return sc; + debug() << "Number of pileup events: " << numPileUp << endmsg; + + // Merge in pileup + if (numPileUp > 0) { + std::vector eventVector; + eventVector.reserve(numPileUp + 1); + + if (!m_pileUpProvider.empty()) { + for (unsigned int i_pileUp = 0; i_pileUp < numPileUp; ++i_pileUp) { + auto puEvt = HepMC3::GenEvent(); + StatusCode sc = m_pileUpProvider->getNextEvent(puEvt); + if (!sc.isSuccess()) return sc; + + m_vertexSmearingTool->smearVertex(puEvt).ignore(); + eventVector.push_back(std::move(puEvt)); } - m_vertexSmearingTool->smearVertex(puEvt).ignore(); - eventVector.push_back(std::move(puEvt)); } + + StatusCode sc = m_HepMCMergeTool->merge(*theEvent, eventVector); + if (!sc.isSuccess()) return sc; } - return m_HepMCMergeTool->merge(*theEvent, eventVector); + + debug() << "Event number: " << theEvent->event_number() << endmsg; + debug() << "Number of particles in the event: " << theEvent->particles().size() + << endmsg; + debug() << "Number of vertices in the event: " << theEvent->vertices().size() + << endmsg; + + return StatusCode::SUCCESS; } StatusCode GenAlg::finalize() { return GaudiAlgorithm::finalize(); } diff --git a/k4Gen/src/components/GenAlg.h b/k4Gen/src/components/GenAlg.h index 271237b..2218751 100644 --- a/k4Gen/src/components/GenAlg.h +++ b/k4Gen/src/components/GenAlg.h @@ -1,20 +1,21 @@ - #ifndef GENERATION_GENALG_H #define GENERATION_GENALG_H +// Gaudi +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" + +// k4FWCore +#include "k4FWCore/DataHandle.h" + +// k4Gen #include "Generation/IHepMCMergeTool.h" #include "Generation/IHepMCProviderTool.h" #include "Generation/IPileUpTool.h" #include "Generation/IVertexSmearingTool.h" - -#include "GaudiAlg/GaudiAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" - - -#include "k4FWCore/DataHandle.h" namespace HepMC3 { -class GenEvent; + class GenEvent; } class GenAlg : public GaudiAlgorithm { @@ -30,17 +31,18 @@ class GenAlg : public GaudiAlgorithm { virtual StatusCode finalize(); private: - /// Tools to handle input from HepMC-file + /// Tool to provide signal event ToolHandle m_signalProvider{"MomentumRangeParticleGun/HepMCProviderTool", this}; - ToolHandle m_pileUpProvider{"MomentumRangeParticleGun/HepMCProviderTool", this}; + /// Tool to determine number of pileup events ToolHandle m_pileUpTool{"ConstPileUp/PileUpTool", this}; - + /// Tool to provide pile up event(s) + ToolHandle m_pileUpProvider{"MomentumRangeParticleGun/HepMCProviderTool", this}; + // Tool to smear vertex + ToolHandle m_vertexSmearingTool{"FlatSmearVertex/VertexSmearingTool", this}; /// Tool to merge HepMC events ToolHandle m_HepMCMergeTool{"HepMCSimpleMerge/HepMCMergeTool", this}; - // Tool to smear vertices - ToolHandle m_vertexSmearingTool{"FlatSmearVertex/VertexSmearingTool", this}; - // output handle for finished event - DataHandle m_hepmchandle{"hepmc", Gaudi::DataHandle::Writer, this}; + // Output handle for finished event + DataHandle m_hepmcHandle{"hepmc", Gaudi::DataHandle::Writer, this}; }; #endif // GENERATION_GENALG_H diff --git a/k4Gen/src/components/HepMCToEDMConverter.cpp b/k4Gen/src/components/HepMCToEDMConverter.cpp index 399a84d..44eeba3 100644 --- a/k4Gen/src/components/HepMCToEDMConverter.cpp +++ b/k4Gen/src/components/HepMCToEDMConverter.cpp @@ -56,10 +56,10 @@ StatusCode HepMCToEDMConverter::execute() { const HepMC3::GenEvent* evt = m_hepmchandle.get(); edm4hep::MCParticleCollection* particles = new edm4hep::MCParticleCollection(); - std::unordered_map _map; for (auto _p:evt->particles()) { - debug() << "Converting hepmc particle with Pdg_ID \t" << _p->pdg_id() << "and id \t" << _p->id() << endmsg; + verbose() << "Converting hepmc particle with Pdg_ID " << _p->pdg_id() + << " and id " << _p->id() << endmsg; if (_map.find(_p->id()) == _map.end()) { edm4hep::MutableMCParticle edm_particle = convert(_p); _map.insert({_p->id(), edm_particle}); diff --git a/k4Gen/src/components/PythiaInterface.cpp b/k4Gen/src/components/PythiaInterface.cpp index 6ab607b..fb171e8 100644 --- a/k4Gen/src/components/PythiaInterface.cpp +++ b/k4Gen/src/components/PythiaInterface.cpp @@ -19,22 +19,18 @@ DECLARE_COMPONENT(PythiaInterface) PythiaInterface::PythiaInterface(const std::string& type, const std::string& name, const IInterface* parent) : GaudiTool(type, name, parent), m_pythiaSignal(nullptr), - m_nAbort(0), - m_iAbort(0), - m_iEvent(0), + m_maxAborts(0), m_doMePsMatching(0), m_doMePsMerging(0), m_matching(nullptr), - m_setting(nullptr) { - - auto sc = declareProperty("VertexSmearingTool", m_vertexSmearingTool); - auto sc2 = declareTool(m_vertexSmearingTool, "FlatSmearVertex/VertexSmearingTool"); -} + m_setting(nullptr) {} StatusCode PythiaInterface::initialize() { + { + StatusCode sc = GaudiTool::initialize(); + if (!sc.isSuccess()) return sc; + } - StatusCode sc = GaudiTool::initialize(); - if (!sc.isSuccess()) return sc; if (m_pythiacard.empty() && m_pythia_extrasettings.size() < 2) { return Error("Define Pythia8 configuration file (*.cmd)!"); } @@ -43,10 +39,10 @@ StatusCode PythiaInterface::initialize() { std::string xmlpath = ""; if (System::getEnv("PYTHIA8_XML") != "UNKNOWN") xmlpath = System::getEnv("PYTHIA8_XML"); - // Initialize pythia + // Initialize Pythia8 m_pythiaSignal = std::make_unique(xmlpath); - //add settings for resonance decay filter + // Add settings for resonance decay filter m_pythiaSignal->settings.addFlag("ResonanceDecayFilter:filter", false); m_pythiaSignal->settings.addFlag("ResonanceDecayFilter:exclusive", false); m_pythiaSignal->settings.addFlag("ResonanceDecayFilter:eMuAsEquivalent", false); @@ -58,20 +54,16 @@ StatusCode PythiaInterface::initialize() { m_pythiaSignal->settings.addMVec("ResonanceDecayFilter:mothers", std::vector(), false, false, 0, 0); m_pythiaSignal->settings.addMVec("ResonanceDecayFilter:daughters", std::vector(), false, false, 0, 0); - - - // Read Pythia configuration files + // Read Pythia configuration file m_pythiaSignal->readFile(m_pythiacard.value().c_str()); - // Apply any extra pythia8 settings + // Apply any extra Pythia8 settings for (auto pythiacommand: m_pythia_extrasettings) { m_pythiaSignal->settings.readString(pythiacommand); } // Initialize variables from configuration file - m_nAbort = m_pythiaSignal->settings.mode("Main:timesAllowErrors"); // how many aborts before run stops - m_iAbort = 0; - m_iEvent = 0; + m_maxAborts = m_pythiaSignal->settings.mode("Main:timesAllowErrors"); // how many aborts before run stops // Begin ME/PS Matching specific code // Check if jet matching should be applied. @@ -101,11 +93,7 @@ StatusCode PythiaInterface::initialize() { } m_setting = std::unique_ptr(new Pythia8::amcnlo_unitarised_interface(scheme)); - #if PYTHIA_VERSION_INTEGER < 8300 - m_pythiaSignal->setUserHooksPtr(m_setting.get()); - #else m_pythiaSignal->setUserHooksPtr((Pythia8::UserHooksPtr) m_setting.get()); - #endif } // For jet matching, initialise the respective user hooks code. @@ -114,14 +102,10 @@ StatusCode PythiaInterface::initialize() { if (!m_matching) { return Error(" Failed to initialise jet matching structures."); } - #if PYTHIA_VERSION_INTEGER < 8300 - m_pythiaSignal->setUserHooksPtr(m_matching.get()); - #else m_pythiaSignal->setUserHooksPtr((Pythia8::UserHooksPtr) m_matching.get()); - #endif } - // jet clustering needed for matching + // Jet clustering needed for matching m_slowJet = std::make_unique(1, 0.4, 0, 4.4, 2, 2, nullptr, false); // End ME/PS Matching specific code @@ -134,10 +118,9 @@ StatusCode PythiaInterface::initialize() { // Add in user hooks for shower vetoing if (m_doPowheg) { - // Counters for number of ISR/FSR emissions vetoed - m_nISRveto = 0, m_nFSRveto = 0; - + m_nISRveto = 0, m_nFSRveto = 0; + // Set ISR and FSR to start at the kinematical limit if (vetoMode > 0) { m_pythiaSignal->readString("SpaceShower:pTmaxMatch = 2"); @@ -149,80 +132,53 @@ StatusCode PythiaInterface::initialize() { m_pythiaSignal->readString("MultipartonInteractions:pTmaxMatch = 2"); } - m_powhegHooks = new Pythia8::PowhegHooks(); - #if PYTHIA_VERSION_INTEGER < 8300 - m_pythiaSignal->addUserHooksPtr(m_powhegHooks); - #else m_pythiaSignal->setUserHooksPtr((Pythia8::UserHooksPtr)m_powhegHooks); - #endif } bool resonanceDecayFilter = m_pythiaSignal->settings.flag("ResonanceDecayFilter:filter"); if (resonanceDecayFilter) { m_resonanceDecayFilterHook = new ResonanceDecayFilterHook(); - #if PYTHIA_VERSION_INTEGER < 8300 - m_pythiaSignal->addUserHooksPtr(m_resonanceDecayFilterHook); - #else m_pythiaSignal->addUserHooksPtr((Pythia8::UserHooksPtr)m_resonanceDecayFilterHook); - #endif } // Set up evtGen if (m_doEvtGenDecays) { - #if PYTHIA_VERSION_INTEGER < 8300 - m_evtgen = new EvtGenDecays( - m_pythiaSignal.get(), // the pythia instance - m_EvtGenDecayFile.value(), // the file name of the evtgen decay file - m_EvtGenParticleDataFile.value(), // the file name of the evtgen data file - nullptr, // the optional EvtExternalGenList pointer (must be be provided if the next argument is provided to avoid double initializations) - nullptr, // the EvtAbsRadCorr pointer to pass to EvtGen - 1, // the mixing type to pass to EvtGen - false, // a flag to use XML files to pass to EvtGen - true, // a flag to limit decays based on the Pythia criteria (based on the particle decay vertex) - true, // a flag to use external models with EvtGen - false); // a flag if an FSR model should be passed to EvtGen (pay attention to this, default is true) - #else m_evtgen = new Pythia8::EvtGenDecays( m_pythiaSignal.get(), // the pythia instance m_EvtGenDecayFile.value(), // the file name of the evtgen decay file m_EvtGenParticleDataFile.value(), // the file name of the evtgen data file - nullptr, // the optional EvtExternalGenList pointer (must be be provided if the next argument is provided to avoid double initializations) - nullptr, // the EvtAbsRadCorr pointer to pass to EvtGen - 1, // the mixing type to pass to EvtGen - false, // a flag to use XML files to pass to EvtGen - true, // a flag to limit decays based on the Pythia criteria (based on the particle decay vertex) - true, // a flag to use external models with EvtGen - false); // a flag if an FSR model should be passed to EvtGen (pay attention to this, default is true) - #endif + nullptr, // the optional EvtExternalGenList pointer (must be be provided if the next argument is provided to avoid double initializations) + nullptr, // the EvtAbsRadCorr pointer to pass to EvtGen + 1, // the mixing type to pass to EvtGen + false, // a flag to use XML files to pass to EvtGen + true, // a flag to limit decays based on the Pythia criteria (based on the particle decay vertex) + true, // a flag to use external models with EvtGen + false); // a flag if an FSR model should be passed to EvtGen (pay attention to this, default is true) if (!m_UserDecayFile.empty()) { m_evtgen->readDecayFile(m_UserDecayFile); } - // possibility to force pythia to do decays + // Possibility to force Pythia8 to do decays for (auto _pdgid: m_evtGenExcludes) { m_evtgen->exclude(_pdgid); } } - - m_pythiaSignal->init(); - // Return the status code - return sc; + return StatusCode::SUCCESS; } StatusCode PythiaInterface::getNextEvent(HepMC3::GenEvent& theEvent) { - - Pythia8::Event sumEvent; - // Generate events. Quit if many failures in a row + // Generate events. Quit if many failures in a row + int nAborts = 0; while (!m_pythiaSignal->next()) { - if (++m_iAbort > m_nAbort) { + if (++nAborts > m_maxAborts) { IIncidentSvc* incidentSvc; StatusCode sc = service("IncidentSvc", incidentSvc); incidentSvc->fireIncident(Incident(name(), IncidentType::AbortEvent)); return Error("Event generation aborted prematurely, owing to error!"); } else { - warning() << "PythiaInterface Pythia8 abort : " << m_iAbort << "/" << m_nAbort << std::endl; + warning() << "PythiaInterface Pythia8 abort : " << nAborts << "/" << m_maxAborts << std::endl; } } @@ -230,7 +186,6 @@ StatusCode PythiaInterface::getNextEvent(HepMC3::GenEvent& theEvent) { m_evtgen->decay(); } if (m_doMePsMatching || m_doMePsMerging) { - auto mePsMatchingVars = m_handleMePsMatchingVars.createAndPut(); int njetNow = 0; std::vector dijVec; @@ -301,71 +256,67 @@ StatusCode PythiaInterface::getNextEvent(HepMC3::GenEvent& theEvent) { } } - // Reset the counter to count failed events in a row - m_iAbort = 0; - // Print debug: Pythia event info - if (msgLevel() <= MSG::DEBUG) { - + if (msgLevel() <= MSG::VERBOSE) { for (int i = 0; i < m_pythiaSignal->event.size(); ++i) { - debug() << "PythiaInterface Pythia8 abort : " << m_iAbort << "/" << m_nAbort << endmsg; - - debug() << "Pythia: " - << " Id: " << std::setw(3) << i << " PDG: " << std::setw(5) << m_pythiaSignal->event[i].id() - << " Mothers: " << std::setw(3) << m_pythiaSignal->event[i].mother1() << " -> " << std::setw(3) - << m_pythiaSignal->event[i].mother2() << " Daughters: " << std::setw(3) - << m_pythiaSignal->event[i].daughter1() << " -> " << std::setw(3) << m_pythiaSignal->event[i].daughter2() - << " Stat: " << std::setw(2) << m_pythiaSignal->event[i].status() << std::scientific - << std::setprecision(2) << " Px: " << std::setw(9) << m_pythiaSignal->event[i].px() - << std::setprecision(2) << " Py: " << std::setw(9) << m_pythiaSignal->event[i].py() - << std::setprecision(2) << " Pz: " << std::setw(9) << m_pythiaSignal->event[i].pz() - << std::setprecision(2) << " E: " << std::setw(9) << m_pythiaSignal->event[i].e() << std::setprecision(2) - << " M: " << std::setw(9) << m_pythiaSignal->event[i].m() << std::fixed << endmsg; + verbose() << "PythiaInterface Pythia8 aborts : " << nAborts << "/" << m_maxAborts << endmsg; + + verbose() << "Pythia: " + << " Id: " << std::setw(3) << i << " PDG: " << std::setw(5) << m_pythiaSignal->event[i].id() + << " Mothers: " << std::setw(3) << m_pythiaSignal->event[i].mother1() << " -> " << std::setw(3) + << m_pythiaSignal->event[i].mother2() << " Daughters: " << std::setw(3) + << m_pythiaSignal->event[i].daughter1() << " -> " << std::setw(3) << m_pythiaSignal->event[i].daughter2() + << " Stat: " << std::setw(2) << m_pythiaSignal->event[i].status() << std::scientific + << std::setprecision(2) << " Px: " << std::setw(9) << m_pythiaSignal->event[i].px() + << std::setprecision(2) << " Py: " << std::setw(9) << m_pythiaSignal->event[i].py() + << std::setprecision(2) << " Pz: " << std::setw(9) << m_pythiaSignal->event[i].pz() + << std::setprecision(2) << " E: " << std::setw(9) << m_pythiaSignal->event[i].e() << std::setprecision(2) + << " M: " << std::setw(9) << m_pythiaSignal->event[i].m() << std::fixed << endmsg; } } // Debug - // Define HepMC event and convert Pythia event into this HepMC event type - m_pythiaToHepMC.fill_next_event(*m_pythiaSignal, &theEvent, m_iEvent); + m_pythiaToHepMC.fill_next_event(*m_pythiaSignal, theEvent); // Print debug: HepMC event info - if (msgLevel() <= MSG::DEBUG) { + if (msgLevel() <= MSG::VERBOSE) { - //for (auto ipart = theEvent.particles_begin(); ipart != theEvent.particles_end(); ++ipart) { for (auto ipart: theEvent.particles()) { int motherID = -1; int motherIDRange = 0; if (ipart->production_vertex() != nullptr) { - - motherID = ipart->production_vertex()->particles_in()[0]->id(); - motherIDRange = ipart->production_vertex()->particles_in().size() - 1; + if (!ipart->production_vertex()->particles_in().empty()) { + motherID = ipart->production_vertex()->particles_in()[0]->id(); + motherIDRange = ipart->production_vertex()->particles_in().size() - 1; + } } int daughterID = -1; int daughterIDRange = 0; if (ipart->end_vertex() != nullptr) { - - daughterID = ipart->end_vertex()->particles_out()[0]->id(); - daughterIDRange = ipart->end_vertex()->particles_out().size() - 1; + if (!ipart->end_vertex()->particles_out().empty()) { + daughterID = ipart->end_vertex()->particles_out()[0]->id(); + daughterIDRange = ipart->end_vertex()->particles_out().size() - 1; + } } - debug() << "HepMC: " - << " Id: " << std::setw(3) << ipart->id() << " Pdg: " << std::setw(5) << ipart->pdg_id() - << " Mothers: " << std::setw(3) << motherID << " -> " << std::setw(3) << motherID + motherIDRange - << " Daughters: " << std::setw(3) << daughterID << " -> " << std::setw(3) << daughterID + daughterIDRange - << " Stat: " << std::setw(2) << ipart->status() << std::scientific << " Px: " << std::setprecision(2) - << std::setw(9) << ipart->momentum().px() << " Py: " << std::setprecision(2) << std::setw(9) - << ipart->momentum().py() << " Pz: " << std::setprecision(2) << std::setw(9) - << ipart->momentum().pz() << " E: " << std::setprecision(2) << std::setw(9) << ipart->momentum().e() - << " M: " << std::setprecision(2) << std::setw(9) << ipart->momentum().m() << std::fixed; + verbose() << "HepMC: " + << " Id: " << std::setw(3) << ipart->id() << " Pdg: " << std::setw(5) << ipart->pdg_id() + << " Mothers: " << std::setw(3) << motherID << " -> " << std::setw(3) << motherID + motherIDRange + << " Daughters: " << std::setw(3) << daughterID << " -> " << std::setw(3) << daughterID + daughterIDRange + << " Stat: " << std::setw(2) << ipart->status() << std::scientific << " Px: " << std::setprecision(2) + << std::setw(9) << ipart->momentum().px() << " Py: " << std::setprecision(2) << std::setw(9) + << ipart->momentum().py() << " Pz: " << std::setprecision(2) << std::setw(9) + << ipart->momentum().pz() << " E: " << std::setprecision(2) << std::setw(9) << ipart->momentum().e() + << " M: " << std::setprecision(2) << std::setw(9) << ipart->momentum().m() << std::fixed; if (ipart->production_vertex() != nullptr) { - debug() << std::scientific << " Vx: " << std::setprecision(2) << std::setw(9) - << ipart->production_vertex()->position().x() << " Vy: " << std::setprecision(2) << std::setw(9) - << ipart->production_vertex()->position().y() << " Vz: " << std::setprecision(2) << std::setw(9) - << ipart->production_vertex()->position().z() << " T: " << std::setprecision(2) << std::setw(9) - << ipart->production_vertex()->position().t() << std::fixed; + verbose() << std::scientific << " Vx: " << std::setprecision(2) << std::setw(9) + << ipart->production_vertex()->position().x() << " Vy: " << std::setprecision(2) << std::setw(9) + << ipart->production_vertex()->position().y() << " Vz: " << std::setprecision(2) << std::setw(9) + << ipart->production_vertex()->position().z() << " T: " << std::setprecision(2) << std::setw(9) + << ipart->production_vertex()->position().t() << std::fixed; } - debug() << endmsg; + verbose() << endmsg; } } // Debug @@ -378,9 +329,6 @@ StatusCode PythiaInterface::getNextEvent(HepMC3::GenEvent& theEvent) { m_pythiaSignal->stat(); } - // Handle event via standard Gaudi mechanism - m_iEvent++; - return StatusCode::SUCCESS; } diff --git a/k4Gen/src/components/PythiaInterface.h b/k4Gen/src/components/PythiaInterface.h index fb7c6a9..6435915 100644 --- a/k4Gen/src/components/PythiaInterface.h +++ b/k4Gen/src/components/PythiaInterface.h @@ -5,7 +5,6 @@ #include "k4FWCore/DataHandle.h" #include "GaudiAlg/GaudiTool.h" #include "Generation/IHepMCProviderTool.h" -#include "Generation/IVertexSmearingTool.h" #include "ResonanceDecayFilterHook.h" #include "Pythia8Plugins/PowhegHooks.h" #include "Pythia8Plugins/HepMC3.h" @@ -50,22 +49,24 @@ class PythiaInterface : public GaudiTool, virtual public IHepMCProviderTool { std::unique_ptr m_pythiaSignal; /// Interface for conversion from Pythia8::Event to HepMC event. HepMC3::Pythia8ToHepMC3 m_pythiaToHepMC; - /// Name of Pythia configuration file with Pythia simulation settings & input LHE file (if required) - Gaudi::Property m_pythiacard{this, "pythiacard", "Pythia_minbias_pp_100TeV.cmd" - "Name of the Pythia cmd file"}; + /// Name of Pythia configuration file with Pythia simulation + /// settings & input LHE file (if required) + Gaudi::Property m_pythiacard{ + this, "pythiacard", "Pythia_minbias_pp_100TeV.cmd", + "Name of the Pythia cmd file"}; + + /// Extra settings for Pythia + Gaudi::Property> m_pythia_extrasettings{ + this, "pythiaExtraSettings", {""}, + "Additional strings with Pythia settings, applied after the card."}; - Gaudi::Property> m_pythia_extrasettings{this, "pythiaExtraSettings", {""}, - "Additional strings with Pythia settings, applied after the card."}; /// Pythia8 engine for jet clustering std::unique_ptr m_slowJet{nullptr}; - // Tool to smear vertices - ToolHandle m_vertexSmearingTool; // Output handle for ME/PS matching variables DataHandle> m_handleMePsMatchingVars{"mePsMatchingVars", Gaudi::DataHandle::Writer, this}; - int m_nAbort{0}; - int m_iAbort{0}; - int m_iEvent{0}; + // Maximum number of aborts before giving up + int m_maxAborts{0}; // -- aMCatNLO bool m_doMePsMatching{false}; @@ -78,7 +79,7 @@ class PythiaInterface : public GaudiTool, virtual public IHepMCProviderTool { // Powheg bool m_doPowheg{false}; unsigned long int m_nISRveto{0}; - unsigned long int m_nFSRveto{0}; + unsigned long int m_nFSRveto{0}; /// Pythia8 engine for Powheg ME/PS merging Pythia8::PowhegHooks* m_powhegHooks{nullptr}; @@ -99,11 +100,7 @@ class PythiaInterface : public GaudiTool, virtual public IHepMCProviderTool { Gaudi::Property> m_evtGenExcludes{this, "EvtGenExcludes", {}, "Pdg IDs of particles not to decay with EvtGen"}; - #if PYTHIA_VERSION_INTEGER < 8300 - EvtGenDecays* m_evtgen = nullptr; - #else Pythia8::EvtGenDecays* m_evtgen = nullptr; - #endif }; #endif // GENERATION_PYTHIAINTERFACE_H