3 #include <resonancejettagging/ResonanceJetTagging.h>
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23 #include <HepMC/GenEvent.h>
24 #include <HepMC/GenVertex.h>
25 #pragma GCC diagnostic pop
41 #include <kfparticle_sphenix/KFParticle_truthAndDetTools.h>
44 #include <kfparticle_sphenix/KFParticle_Container.h>
68 , m_outfilename(filename)
69 , m_tagcontainer_name(
"")
70 , m_jetcontainer_name(
"")
71 , m_truth_jetcontainer_name(
"")
75 , m_svtx_evalstack(nullptr)
76 , m_trackeval(nullptr)
80 , m_eventcount_h(nullptr)
81 , m_taggedjettree(nullptr)
89 case ResonanceJetTagging::TAG::D0:
93 case ResonanceJetTagging::TAG::D0TOK3PI:
97 case ResonanceJetTagging::TAG::DPLUS:
101 case ResonanceJetTagging::TAG::DSTAR:
105 case ResonanceJetTagging::TAG::JPSY:
109 case ResonanceJetTagging::TAG::K0:
113 case ResonanceJetTagging::TAG::GAMMA:
117 case ResonanceJetTagging::TAG::ELECTRON:
121 case ResonanceJetTagging::TAG::LAMBDAC:
143 std::cout <<
"Beginning Init in BuildResonanceJetTaggingTree" << std::endl;
157 std::cout <<
"Beginning process_event in BuildResonanceJetTaggingTree" << std::endl;
162 std::cout<<
"ERROR: Number of Decay Daughters Not Set, ABORTING!";
169 case ResonanceJetTagging::TAG::D0:
171 case ResonanceJetTagging::TAG::D0TOK3PI:
173 case ResonanceJetTagging::TAG::DPLUS:
175 case ResonanceJetTagging::TAG::LAMBDAC:
179 std::cout<<
"ERROR: Fill Tree Function Not Set, ABORTING!";
195 std::cout <<
"Ending BuildResonanceJetTaggingTree analysis package" << std::endl;
202 PHGenIntegral *phgen = findNode::getClass<PHGenIntegral>(topNode,
"PHGenIntegral");
224 std::cout <<
"Finished BuildResonanceJetTaggingTree analysis package" << std::endl;
243 HepMC::GenEvent *hepMCGenEvent =
nullptr;
268 Jet *recTagJet =
nullptr;
269 Jet *genTagJet =
nullptr;
272 HepMC::GenParticle *genTag =
nullptr;
275 std::vector<int> recJetIndex;
283 if(!recTagJet)
continue;
289 if(
comp.first == Jet::SRC::VOID)
291 recTag = kfContainer->
get(
comp.second);
301 for (
int iDaughter = 0; iDaughter <
m_nDaughters; iDaughter++)
303 recDaughtersID[iDaughter] = (kfContainer->
get(tagID + iDaughter +1))->
Id();
333 if((genTagJet) && (genTag))
335 recJetIndex.push_back(genTagJet->
get_id());
370 if(!genTagJet)
continue;
383 if(
comp.first == Jet::SRC::VOID)
385 genTag = hepMCGenEvent->barcode_to_particle(
comp.second);
415 HepMC::GenParticle* constituent = hepMCGenEvent->barcode_to_particle(
comp.second);
417 if(constituent == genTag)
441 if(!hepMCGenEvent)
return;
450 SvtxPHG4ParticleMap_v1 *dst_reco_truth_map = findNode::getClass<SvtxPHG4ParticleMap_v1>(topNode,
"SvtxPHG4ParticleMap");
452 if (dst_reco_truth_map)
456 std::map<float, std::set<int>> truth_set = dst_reco_truth_map->
get(decays[idecay]);
457 const auto &best_weight = truth_set.rbegin();
458 int best_truth_id = *best_weight->second.rbegin();
459 g4particle = truthinfo->
GetParticle(best_truth_id);
460 mcTags[idecay] =
getMother(topNode, g4particle);
461 if (mcTags[idecay] ==
nullptr)
469 SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
470 if(!trackmap)
return;
485 if(g4parent ==
nullptr)
490 mcTags[idecay] = hepMCGenEvent->barcode_to_particle(g4parent->
get_barcode());
491 if(mcTags[idecay] ==
nullptr)
501 if (mcTags[idecay]->barcode() != mcTags[idecay - 1]->barcode())
511 for(
auto comp : mcJet->get_comp_vec())
513 if(
comp.first == Jet::SRC::VOID &&
int(
comp.second) == mcTag->barcode())
529 PHHepMCGenEventMap *hepmceventmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
535 <<
"HEPMC event map node is missing, can't collected HEPMC truth particles"
543 std::cout <<
"no hepmcevent!!!" << std::endl;
547 HepMC::GenEvent *hepMCGenEvent = hepmcevent->
getEvent();
553 HepMC::GenParticle *mcDaughter =
nullptr;
557 mcDaughter = hepMCGenEvent->barcode_to_particle(g4daughter->
get_barcode());
564 HepMC::GenVertex *TagVertex = mcDaughter->production_vertex();
565 for (HepMC::GenVertex::particle_iterator
it = TagVertex->particles_begin(HepMC::ancestors);
it != TagVertex->particles_end(HepMC::ancestors); ++
it)
567 if (std::abs((*it)->pdg_id()) ==
m_tag_pdg)
578 for(
auto indexRec : indexRecVector)
580 if(index == indexRec)
return true;
588 m_runinfo =
new TTree(
"m_runinfo",
"A tree with the run information");
596 m_taggedjettree =
new TTree(
"m_taggedjettree",
"A tree with Tagged-Jet info");
642 m_eventcount_h =
new TH1I(
"eventcount_h",
"Event Count", 2, -0.5, 1.5);
643 m_eventcount_h->GetXaxis()->SetBinLabel(1,
"N raw ev anal");
644 m_eventcount_h->GetXaxis()->SetBinLabel(2,
"N ev anal");
697 <<
"JetContainerv1 node is missing, can't collect jets"
711 <<
"KFParticle_Container node is missing, can't collect HF particles"
726 <<
"HEPMC event map node is missing, can't collected HEPMC truth particles"
736 <<
"PHHepMCGenEvent node is missing, can't collected HEPMC truth particles"
741 HepMC::GenEvent *hepMCGenEvent = hepmcevent->
getEvent();
746 <<
"HepMC::GenEvent node is missing, can't collected HEPMC truth particles"
751 return hepMCGenEvent;