15 #include <TDatabasePDG.h>
18 #include <TLorentzVector.h>
21 #include <g4jets/Jet.h>
22 #include <g4jets/JetMap.h>
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
25 #include <HepMC/GenEvent.h>
26 #include <HepMC/GenVertex.h>
29 #pragma GCC diagnostic pop
74 _h2 =
new TH2D(
"h2",
"", 100, 0, 100.0, 40, -2, +2);
75 _h2_b =
new TH2D(
"h2_b",
"", 100, 0, 100.0, 40, -2, +2);
76 _h2_c =
new TH2D(
"h2_c",
"", 100, 0, 100.0, 40, -2, +2);
77 _h2all =
new TH2D(
"h2all",
"", 100, 0, 100.0, 40, -2, +2);
84 PHHepMCGenEventMap* geneventmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
87 std::cout <<
PHWHERE <<
" - Fatal error - missing node PHHepMCGenEventMap" << std::endl;
94 std::cout <<
PHWHERE <<
" - Fatal error - node PHHepMCGenEventMap missing subevent with embedding ID " <<
_embedding_id;
95 std::cout <<
". Print PHHepMCGenEventMap:";
100 HepMC::GenEvent* theEvent = genevt->
getEvent();
106 std::cout <<
PHWHERE <<
" - Fatal error - node " <<
_jet_name <<
" JetMap missing." << std::endl;
109 const double jet_radius = truth_jets->
get_par();
112 std::cout << __PRETTY_FUNCTION__ <<
": truth jets has size "
113 << truth_jets->
size() <<
" and R = " << jet_radius << std::endl;
116 bool pass_event =
false;
120 Jet* this_jet = iter->second;
122 float this_pt = this_jet->
get_pt();
123 float this_eta = this_jet->
get_eta();
125 if (this_pt < 10 || fabs(this_eta) > 5)
142 const int jet_flavor =
parton_tagging(this_jet, theEvent, jet_radius);
144 if (abs(jet_flavor) ==
_flavor)
150 std::cout <<
" --> this is flavor " << jet_flavor
151 <<
" like I want " << std::endl;
159 std::cout <<
" --> this is flavor " << jet_flavor
160 <<
" which I do NOT want " << std::endl;
172 std::cout << __PRETTY_FUNCTION__ <<
" --> FAIL due to max events = "
181 std::cout << __PRETTY_FUNCTION__ <<
" --> PASS, total = " <<
_total_pass
189 std::cout << __PRETTY_FUNCTION__ <<
" --> FAIL " << std::endl;
198 std::cout << __PRETTY_FUNCTION__ <<
" DVP PASSED " <<
_total_pass
199 <<
" events" << std::endl;
210 const double match_radius)
212 float this_pt = this_jet->
get_pt();
213 float this_phi = this_jet->
get_phi();
214 float this_eta = this_jet->
get_eta();
217 double jet_parton_zt = 0;
222 for (HepMC::GenEvent::particle_const_iterator
p = theEvent->particles_begin();
223 p != theEvent->particles_end(); ++
p)
225 float dR =
deltaR((*p)->momentum().pseudoRapidity(), this_eta,
226 (*p)->momentum().phi(), this_phi);
227 if (dR > match_radius)
230 int pidabs = abs((*p)->pdg_id());
231 const double zt = (*p)->momentum().perp() / this_pt;
233 if (pidabs == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode()
234 or pidabs == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode()
235 or pidabs == TDatabasePDG::Instance()->GetParticle(
"t")->PdgCode())
237 if (pidabs > abs(jet_flavor))
240 jet_flavor = (*p)->pdg_id();
242 else if (pidabs == abs(jet_flavor))
244 if (zt > jet_parton_zt)
247 jet_flavor = (*p)->pdg_id();
251 if (pidabs == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode())
254 std::cout << __PRETTY_FUNCTION__
255 <<
" --BOTTOM--> pt / eta / phi = "
256 << (*p)->momentum().perp() <<
" / "
257 << (*p)->momentum().pseudoRapidity() <<
" / "
258 << (*p)->momentum().phi() << std::endl;
260 else if (pidabs == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode())
263 std::cout << __PRETTY_FUNCTION__
264 <<
" --CHARM --> pt / eta / phi = "
265 << (*p)->momentum().perp() <<
" / "
266 << (*p)->momentum().pseudoRapidity() <<
" / "
267 << (*p)->momentum().phi() << std::endl;
272 if (abs(jet_flavor) == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode())
276 else if (abs(jet_flavor) == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode())
291 const double match_radius)
293 float this_pt = this_jet->
get_pt();
294 float this_phi = this_jet->
get_phi();
295 float this_eta = this_jet->
get_eta();
298 double jet_parton_zt = 0;
302 for (HepMC::GenEvent::particle_const_iterator
p = theEvent->particles_begin();
303 p != theEvent->particles_end(); ++
p)
305 float dR =
deltaR((*p)->momentum().pseudoRapidity(), this_eta,
306 (*p)->momentum().phi(), this_phi);
307 if (dR > match_radius)
311 TParticlePDG* pdg_p = TDatabasePDG::Instance()->GetParticle((*p)->pdg_id());
314 if (TString(pdg_p->ParticleClass()).BeginsWith(
"B-"))
316 pidabs = TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode();
318 else if (TString(pdg_p->ParticleClass()).BeginsWith(
"Charmed"))
320 pidabs = TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode();
324 const double zt = (*p)->momentum().perp() / this_pt;
326 if (pidabs == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode()
327 or pidabs == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode())
329 if (pidabs > abs(jet_flavor))
334 else if (pidabs == abs(jet_flavor))
336 if (zt > jet_parton_zt)
343 if (pidabs == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode())
347 std::cout << __PRETTY_FUNCTION__
348 <<
" --BOTTOM--> pt / eta / phi = "
349 << (*p)->momentum().perp() <<
" / "
350 << (*p)->momentum().pseudoRapidity() <<
" / "
351 << (*p)->momentum().phi() <<
" with hadron ";
355 else if (pidabs == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode())
359 std::cout << __PRETTY_FUNCTION__
360 <<
" --CHARM --> pt / eta / phi = "
361 << (*p)->momentum().perp() <<
" / "
362 << (*p)->momentum().pseudoRapidity() <<
" / "
363 << (*p)->momentum().phi() <<
" with hadron ";
377 std::cout << __PRETTY_FUNCTION__ <<
" jet_flavor = " << jet_flavor