diff --git a/Generators/EvtGen_i/EvtGen_i/EvtInclusiveDecay.h b/Generators/EvtGen_i/EvtGen_i/EvtInclusiveDecay.h index 573a844fa6b135d981e74ca35ad76ebd5fcd8faa..cfd13ef5ec81a4ddda544bd58c27e73d48cba986 100644 --- a/Generators/EvtGen_i/EvtGen_i/EvtInclusiveDecay.h +++ b/Generators/EvtGen_i/EvtGen_i/EvtInclusiveDecay.h @@ -98,12 +98,14 @@ class EvtInclusiveDecay:public GenBase { // coloring by status code and highlighting of particles in a specific list of barcodes #ifdef HEPMC3 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 void printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcodeList = nullptr); -#endif unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited, int level, std::set<int>* barcodeList = 0); std::string pdgName(const HepMC::GenParticlePtr p, bool statusHighlighting = false, std::set<int>* barcodeList = nullptr); +#endif // StoreGate access // StoreGateSvc* m_sgSvc; diff --git a/Generators/EvtGen_i/src/EvtInclusiveDecay.cxx b/Generators/EvtGen_i/src/EvtInclusiveDecay.cxx index f9d16e3248ba06111759dbfe5750d91657688c27..1cef870bcb653db1d4f766f6ba8c6eeb5c56b1fc 100644 --- a/Generators/EvtGen_i/src/EvtInclusiveDecay.cxx +++ b/Generators/EvtGen_i/src/EvtInclusiveDecay.cxx @@ -727,6 +727,36 @@ void EvtInclusiveDecay::printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcod } #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, std::set<HepMC::GenVertexPtr>& visited, int level, std::set<int>* barcodeList) { unsigned int nParticlesVisited = 1; @@ -782,10 +812,31 @@ unsigned int EvtInclusiveDecay::printTree(HepMC::GenParticlePtr p, #endif 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) { - // 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; if (statusHighlighting) { if ( ((barcodeList!=0) && (barcodeList->find(HepMC::barcode(p)) != barcodeList->end())) || @@ -799,8 +850,6 @@ std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statu } } buf << p->pdg_id(); - //if (pData) - // buf << "/" << pData->name(); buf << "/" << HepPID::particleName(p->pdg_id()); if (statusHighlighting) { buf << "\033[0m"; // revert color attributes @@ -808,6 +857,7 @@ std::string EvtInclusiveDecay::pdgName(const HepMC::GenParticlePtr p, bool statu return buf.str(); } +#endif //