Skip to content
Snippets Groups Projects
Commit 240f544f authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'evtgen_cleanup' into 'master'

Evtgen cleanup and migration to Hepmc3

See merge request atlas/athena!34854
parents 13acea40 24c35e30
No related branches found
No related tags found
No related merge requests found
...@@ -98,12 +98,14 @@ class EvtInclusiveDecay:public GenBase { ...@@ -98,12 +98,14 @@ class EvtInclusiveDecay:public GenBase {
// coloring by status code and highlighting of particles in a specific list of barcodes // coloring by status code and highlighting of particles in a specific list of barcodes
#ifdef HEPMC3 #ifdef HEPMC3
void printHepMC(HepMC::GenEvent* hepMC, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr); void printHepMC(HepMC::GenEvent* hepMC, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr);
unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited, int level, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr);
std::string pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting = false, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr);
#else #else
void printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcodeList = nullptr); void printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcodeList = nullptr);
#endif
unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited, unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited,
int level, std::set<int>* barcodeList = 0); int level, std::set<int>* barcodeList = 0);
std::string pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting = false, std::set<int>* barcodeList = nullptr); std::string pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting = false, std::set<int>* barcodeList = nullptr);
#endif
// StoreGate access // StoreGate access
// StoreGateSvc* m_sgSvc; // StoreGateSvc* m_sgSvc;
......
...@@ -727,6 +727,36 @@ void EvtInclusiveDecay::printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcod ...@@ -727,6 +727,36 @@ void EvtInclusiveDecay::printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcod
} }
#endif #endif
#ifdef HEPMC3
unsigned int EvtInclusiveDecay::printTree(HepMC::GenParticlePtr p,
std::set<HepMC::GenVertexPtr>& visited, int level, std::set<HepMC::GenParticlePtr>* barcodeList) {
unsigned int nParticlesVisited = 1;
for (int i=0; i<level; i++) std::cout << " ";
std::cout << pdgName(p,m_printHepMCHighlighted,barcodeList);
auto v = p->end_vertex();
if (v) {
if (v->particles_in().size() > 1)
std::cout << " [interaction: " << v->particles_in().size() << " particles, barcode " << HepMC::barcode(v) << "] --> ";
else
std::cout << " --> ";
if (visited.insert(v).second) {
for (auto itp: v->particles_out()) {
std::cout << pdgName(itp,m_printHepMCHighlighted,barcodeList) << " ";
}
std::cout << std::endl;
for (auto itp: v->particles_out()) {
if (itp->end_vertex())
nParticlesVisited += printTree(itp, visited, level+1, barcodeList);
else
nParticlesVisited++;
}
} else
std::cout << "see above" << std::endl;
} else
std::cout << " no decay vertex\n" << std::endl;
return nParticlesVisited;
}
#else
unsigned int EvtInclusiveDecay::printTree(HepMC::GenParticlePtr p, unsigned int EvtInclusiveDecay::printTree(HepMC::GenParticlePtr p,
std::set<HepMC::GenVertexPtr>& visited, int level, std::set<int>* barcodeList) { std::set<HepMC::GenVertexPtr>& visited, int level, std::set<int>* barcodeList) {
unsigned int nParticlesVisited = 1; unsigned int nParticlesVisited = 1;
...@@ -782,10 +812,31 @@ unsigned int EvtInclusiveDecay::printTree(HepMC::GenParticlePtr p, ...@@ -782,10 +812,31 @@ unsigned int EvtInclusiveDecay::printTree(HepMC::GenParticlePtr p,
#endif #endif
return nParticlesVisited; return nParticlesVisited;
} }
#endif
#ifdef HEPMC3
std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting, std::set<HepMC::GenParticlePtr>* barcodeList) {
std::ostringstream buf;
if (statusHighlighting) {
if ( ((barcodeList!=0) && (barcodeList->find(p) != barcodeList->end())) ||
((barcodeList==0) && isToBeDecayed(p,false)) )
buf << "\033[7m"; // reverse
if (p->status() != 1) {
if (p->status() == m_decayedStatus)
buf << "\033[33m"; // yellow
else
buf << "\033[31m"; // red
}
}
buf << p->pdg_id();
buf << "/" << HepPID::particleName(p->pdg_id());
if (statusHighlighting) {
buf << "\033[0m"; // revert color attributes
}
return buf.str();
}
#else
std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting, std::set<int>* barcodeList) { std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting, std::set<int>* barcodeList) {
// Note: HepPDT doesn't seem to know anti-particle names
// const HepPDT::ParticleData* pData = m_pdt->particle(HepPDT::ParticleID(abs(p->pdg_id())));
std::ostringstream buf; std::ostringstream buf;
if (statusHighlighting) { if (statusHighlighting) {
if ( ((barcodeList!=0) && (barcodeList->find(HepMC::barcode(p)) != barcodeList->end())) || if ( ((barcodeList!=0) && (barcodeList->find(HepMC::barcode(p)) != barcodeList->end())) ||
...@@ -799,8 +850,6 @@ std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statu ...@@ -799,8 +850,6 @@ std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statu
} }
} }
buf << p->pdg_id(); buf << p->pdg_id();
//if (pData)
// buf << "/" << pData->name();
buf << "/" << HepPID::particleName(p->pdg_id()); buf << "/" << HepPID::particleName(p->pdg_id());
if (statusHighlighting) { if (statusHighlighting) {
buf << "\033[0m"; // revert color attributes buf << "\033[0m"; // revert color attributes
...@@ -808,6 +857,7 @@ std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statu ...@@ -808,6 +857,7 @@ std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statu
return buf.str(); return buf.str();
} }
#endif
// //
......
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