11 #include <TDatabasePDG.h>
16 #include <TLorentzVector.h>
19 #include <g4jets/Jet.h>
20 #include <g4jets/JetMap.h>
22 #include <HepMC/GenEvent.h>
23 #include <HepMC/GenRanges.h>
24 #include <HepMC/GenVertex.h>
28 #include <gsl/gsl_const.h>
48 , m_DRapidity(nullptr)
51 , m_tSingleLc(nullptr)
80 m_hNorm =
new TH1D(
"hNormalization",
81 "Normalization;Items;Summed quantity", 10, .5, 10.5);
83 m_hNorm->GetXaxis()->SetBinLabel(i++,
"IntegratedLumi");
84 m_hNorm->GetXaxis()->SetBinLabel(i++,
"Event");
85 m_hNorm->GetXaxis()->SetBinLabel(i++,
"D0");
86 m_hNorm->GetXaxis()->SetBinLabel(i++,
"D0->PiK");
87 m_hNorm->GetXaxis()->SetBinLabel(i++,
"D0-Pair");
88 m_hNorm->GetXaxis()->SetBinLabel(i++,
"D0->PiK-Pair");
89 m_hNorm->GetXaxis()->SetBinLabel(i++,
"Lc");
90 m_hNorm->GetXaxis()->SetBinLabel(i++,
"Lc->pPiK");
91 m_hNorm->GetXaxis()->SetBinLabel(i++,
"Accepted");
93 m_hNorm->GetXaxis()->LabelsOption(
"v");
96 "hDRapidity;Rapidity of D0 meson;Accepted", 1000, -5, 5, 2, -.5, 1.5);
98 _h2 =
new TH2D(
"h2",
"", 100, 0, 100.0, 40, -2, +2);
99 _h2_b =
new TH2D(
"h2_b",
"", 100, 0, 100.0, 40, -2, +2);
100 _h2_c =
new TH2D(
"h2_c",
"", 100, 0, 100.0, 40, -2, +2);
101 _h2all =
new TH2D(
"h2all",
"", 100, 0, 100.0, 40, -2, +2);
103 m_tSingleD =
new TTree(
"TSingleD",
"TSingleD");
118 int max_abs_q_pid = 0;
125 TParticlePDG* pdg_p = TDatabasePDG::Instance()->GetParticle((p)->pdg_id());
128 chain = TString(
" -> ") + TString(pdg_p->GetName()) + chain;
130 if (TString(pdg_p->ParticleClass()).BeginsWith(
"B-"))
132 pidabs = TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode();
134 else if (TString(pdg_p->ParticleClass()).BeginsWith(
"Charmed"))
136 pidabs = TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode();
141 chain = TString(
" -> ") + Form(
"%d", (p)->pdg_id()) + chain;
144 if (pidabs > max_abs_q_pid) max_abs_q_pid = pidabs;
146 const HepMC::GenVertex* vtx = p->production_vertex();
149 if (vtx->particles_in_size() == 1)
152 p = *(vtx->particles_in_const_begin());
164 return make_pair(max_abs_q_pid, chain);
171 const double mom_factor = HepMC::Units::conversion_factor(theEvent->momentum_unit(), HepMC::Units::GEV);
172 const double length_factor = HepMC::Units::conversion_factor(theEvent->length_unit(), HepMC::Units::CM);
175 TDatabasePDG*
pdg = TDatabasePDG::Instance();
177 int targetPID = std::abs(pdg->GetParticle(
"D0")->PdgCode());
178 int daughter1PID = std::abs(pdg->GetParticle(
"pi+")->PdgCode());
179 int daughter2PID = std::abs(pdg->GetParticle(
"K+")->PdgCode());
182 unsigned int nD0PiK(0);
184 auto range = theEvent->particle_range();
185 for (HepMC::GenEvent::particle_const_iterator
piter = range.begin();
piter != range.end(); ++
piter)
187 const HepMC::GenParticle*
p = *
piter;
190 if (std::abs(p->pdg_id()) == targetPID)
194 cout <<
"process_D02PiK - Accept signal particle : ";
203 const double rapidity = 0.5 * log((p->momentum().e() + p->momentum().z()) /
204 (p->momentum().e() - p->momentum().z()));
208 const HepMC::GenVertex* decayVertex = p->end_vertex();
212 int hasDecayOther(0);
216 for (
auto diter = decayVertex->particles_out_const_begin();
217 diter != decayVertex->particles_out_const_end();
221 const HepMC::GenParticle* pd = *diter;
226 cout <<
"process_D02PiK - Testing daughter particle: ";
231 if (std::abs(pd->pdg_id()) == daughter1PID)
233 const double eta = pd->momentum().eta();
238 else if (std::abs(pd->pdg_id()) == daughter2PID)
240 const double eta = pd->momentum().eta();
250 if (hasDecay1 == 1 and hasDecay2 == 1 and hasDecayOther == 0)
261 m_singleD->
prodL = p->production_vertex()->point3d().r() * length_factor;
269 cout <<
"process_D02PiK - Found D0->piK:";
271 cout <<
"m_singleD->y = " <<
m_singleD->
y <<
", ";
286 cout <<
"process_D02PiK - Warning - target particle did not have decay vertex : ";
297 cout <<
"process_D02PiK - D0-Pair with nD0 = " << nD0 << endl;
298 m_hNorm->Fill(
"D0-Pair", nD0 * (nD0 - 1) / 2);
302 m_hNorm->Fill(
"D0->PiK-Pair", nD0PiK * (nD0PiK - 1) / 2);
312 const double mom_factor = HepMC::Units::conversion_factor(theEvent->momentum_unit(), HepMC::Units::GEV);
313 const double length_factor = HepMC::Units::conversion_factor(theEvent->length_unit(), HepMC::Units::CM);
316 TDatabasePDG*
pdg = TDatabasePDG::Instance();
318 const int targetPID = std::abs(pdg->GetParticle(
"Lambda_c+")->PdgCode());
319 assert(targetPID == 4122);
320 const int daughter1PID = std::abs(pdg->GetParticle(
"pi+")->PdgCode());
321 assert(daughter1PID == 211);
322 const int daughter2PID = std::abs(pdg->GetParticle(
"K+")->PdgCode());
323 assert(daughter2PID == 321);
324 const int daughter3PID = std::abs(pdg->GetParticle(
"proton")->PdgCode());
325 assert(daughter3PID == 2212);
328 unsigned int nLc2pPiK(0);
330 auto range = theEvent->particle_range();
331 for (HepMC::GenEvent::particle_const_iterator
piter = range.begin();
piter != range.end(); ++
piter)
333 const HepMC::GenParticle*
p = *
piter;
336 if (std::abs(p->pdg_id()) == targetPID)
340 cout <<
"HFFastSim::process_Lc2pPiK - Accept signal particle : ";
348 const double rapidity = 0.5 * log((p->momentum().e() + p->momentum().z()) /
349 (p->momentum().e() - p->momentum().z()));
351 const HepMC::GenVertex* decayVertex = p->end_vertex();
356 int hasDecayOther(0);
360 for (
auto diter = decayVertex->particles_out_const_begin();
361 diter != decayVertex->particles_out_const_end();
365 const HepMC::GenParticle* pd = *diter;
370 cout <<
"HFFastSim::process_Lc2pPiK - Testing daughter particle: ";
375 if (std::abs(pd->pdg_id()) == daughter1PID)
377 const double eta = pd->momentum().eta();
382 else if (std::abs(pd->pdg_id()) == daughter2PID)
384 const double eta = pd->momentum().eta();
389 else if (std::abs(pd->pdg_id()) == daughter3PID)
391 const double eta = pd->momentum().eta();
401 if (hasDecay1 == 1 and hasDecay2 == 1 and hasDecay3 == 1 and hasDecayOther == 0)
412 m_singleLc->
prodL = p->production_vertex()->point3d().r() * length_factor;
420 cout <<
"HFFastSim::process_Lc2pPiK - Found D0->piK:";
422 cout <<
"m_singleLc->y = " <<
m_singleLc->
y <<
", ";
437 cout <<
"HFFastSim::process_Lc2pPiK - Warning - target particle did not have decay vertex : ";
445 return nLc2pPiK >= 1;
453 PHHepMCGenEventMap* geneventmap = findNode::getClass<PHHepMCGenEventMap>(topNode,
"PHHepMCGenEventMap");
456 std::cout <<
PHWHERE <<
" - Fatal error - missing node PHHepMCGenEventMap" << std::endl;
463 std::cout <<
PHWHERE <<
" - Fatal error - node PHHepMCGenEventMap missing subevent with embedding ID " <<
_embedding_id;
464 std::cout <<
". Print PHHepMCGenEventMap:";
469 HepMC::GenEvent* theEvent = genevt->
getEvent();
475 cout <<
"HFFastSim::process_event - process HepMC::GenEvent with signal_process_id = "
476 << theEvent->signal_process_id();
477 if (theEvent->signal_process_vertex())
479 cout <<
" and signal_process_vertex : ";
480 theEvent->signal_process_vertex()->print();
482 cout <<
" - Event record:" << endl;
487 for (HepMC::GenEvent::particle_const_iterator
p = theEvent->particles_begin();
488 p != theEvent->particles_end(); ++
p)
490 int pidabs = abs((*p)->pdg_id());
491 if (pidabs == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode()
492 or pidabs == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode()
493 or pidabs == TDatabasePDG::Instance()->GetParticle(
"t")->PdgCode())
495 if (pidabs == TDatabasePDG::Instance()->GetParticle(
"b")->PdgCode())
498 std::cout << __PRETTY_FUNCTION__
499 <<
" --BOTTOM--> pt / eta / phi = "
500 << ((*p)->momentum().perp()) <<
" / "
501 << (*p)->momentum().pseudoRapidity() <<
" / "
502 << (*p)->momentum().phi() << std::endl;
504 _h2_b->Fill((*p)->momentum().perp(), (*p)->momentum().pseudoRapidity());
506 else if (pidabs == TDatabasePDG::Instance()->GetParticle(
"c")->PdgCode())
509 std::cout << __PRETTY_FUNCTION__
510 <<
" --CHARM --> pt / eta / phi = "
511 << (*p)->momentum().perp() <<
" / "
512 << (*p)->momentum().pseudoRapidity() <<
" / "
513 << (*p)->momentum().phi() << std::endl;
515 _h2_c->Fill((*p)->momentum().perp(), (*p)->momentum().pseudoRapidity());
527 std::cout << __PRETTY_FUNCTION__ <<
" --> FAIL due to max events = "
536 std::cout << __PRETTY_FUNCTION__ <<
" --> PASS, total = " <<
_total_pass
545 std::cout << __PRETTY_FUNCTION__ <<
" --> FAIL " << std::endl;
554 std::cout << __PRETTY_FUNCTION__ <<
" PASSED " <<
_total_pass
555 <<
" events" << std::endl;
557 PHGenIntegral* integral_node = findNode::getClass<PHGenIntegral>(topNode,
"PHGenIntegral");