Skip to content
Snippets Groups Projects
Commit 098abc48 authored by Andrii Verbytskyi's avatar Andrii Verbytskyi Committed by Walter Lampl
Browse files

Implement PID replacement in FixHEPMC

Implement PID replacement in FixHEPMC
parent 08e3fd7b
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,10 @@ private: ...@@ -59,7 +59,10 @@ private:
long m_pdg0Killed; long m_pdg0Killed;
long m_decayCleaned; long m_decayCleaned;
long m_totalSeen; long m_totalSeen;
long m_replacedPIDs;
//@} //@}
std::map<int,int> m_pidmap; //!< map of pids to change.
}; };
......
...@@ -17,11 +17,13 @@ FixHepMC::FixHepMC(const std::string& name, ISvcLocator* pSvcLocator) ...@@ -17,11 +17,13 @@ FixHepMC::FixHepMC(const std::string& name, ISvcLocator* pSvcLocator)
, m_pdg0Killed(0) , m_pdg0Killed(0)
, m_decayCleaned(0) , m_decayCleaned(0)
, m_totalSeen(0) , m_totalSeen(0)
, m_replacedPIDs(0)
{ {
declareProperty("KillLoops", m_killLoops = true, "Remove particles in loops?"); declareProperty("KillLoops", m_killLoops = true, "Remove particles in loops?");
declareProperty("KillPDG0", m_killPDG0 = true, "Remove particles with PDG ID 0?"); declareProperty("KillPDG0", m_killPDG0 = true, "Remove particles with PDG ID 0?");
declareProperty("CleanDecays", m_cleanDecays = true, "Clean decay chains from non-propagating particles?"); declareProperty("CleanDecays", m_cleanDecays = true, "Clean decay chains from non-propagating particles?");
declareProperty("LoopsByBarcode", m_loopByBC = false, "Detect loops based on barcodes as well as vertices?"); declareProperty("LoopsByBarcode", m_loopByBC = false, "Detect loops based on barcodes as well as vertices?");
declareProperty("PIDmap", m_pidmap = std::map<int,int>(), "Map of PDG IDs to replace");
} }
#ifndef HEPMC3 #ifndef HEPMC3
//---->//This is copied from MCUtils //---->//This is copied from MCUtils
...@@ -91,6 +93,15 @@ StatusCode FixHepMC::execute() { ...@@ -91,6 +93,15 @@ StatusCode FixHepMC::execute() {
for (McEventCollection::const_iterator ievt = events()->begin(); ievt != events()->end(); ++ievt) { for (McEventCollection::const_iterator ievt = events()->begin(); ievt != events()->end(); ++ievt) {
// FIXME: const_cast // FIXME: const_cast
HepMC::GenEvent* evt = const_cast<HepMC::GenEvent*>(*ievt); HepMC::GenEvent* evt = const_cast<HepMC::GenEvent*>(*ievt);
if (!m_pidmap.empty()) {
for (auto ip: *evt) {
// Skip this particle if (somehow) its pointer is null
if (!ip) continue;
auto newpid = m_pidmap.find(ip->pdg_id());
if (newpid == m_pidmap.end()) continue;
ip->set_pdg_id(newpid->second);
}
}
#ifdef HEPMC3 #ifdef HEPMC3
// Add a unit entry to the event weight vector if it's currently empty // Add a unit entry to the event weight vector if it's currently empty
if (evt->weights().empty()) { if (evt->weights().empty()) {
...@@ -467,6 +478,7 @@ StatusCode FixHepMC::finalize() { ...@@ -467,6 +478,7 @@ StatusCode FixHepMC::finalize() {
if (m_killLoops ) ATH_MSG_INFO( "Removed " << m_loopKilled << " of " << m_totalSeen << " particles because of loops." ); if (m_killLoops ) ATH_MSG_INFO( "Removed " << m_loopKilled << " of " << m_totalSeen << " particles because of loops." );
if (m_killPDG0 ) ATH_MSG_INFO( "Removed " << m_pdg0Killed << " of " << m_totalSeen << " particles because of PDG ID 0." ); if (m_killPDG0 ) ATH_MSG_INFO( "Removed " << m_pdg0Killed << " of " << m_totalSeen << " particles because of PDG ID 0." );
if (m_cleanDecays) ATH_MSG_INFO( "Removed " << m_decayCleaned << " of " << m_totalSeen << " particles while cleaning decay chains." ); if (m_cleanDecays) ATH_MSG_INFO( "Removed " << m_decayCleaned << " of " << m_totalSeen << " particles while cleaning decay chains." );
if (!m_pidmap.empty()) ATH_MSG_INFO( "Replaced " << m_replacedPIDs << "PIDs of particles." );
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
......
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