27 #include "CLHEP/Vector/LorentzVector.h"
100 ATH_MSG_ERROR(
" ==>> 'B_PDGCode = 0'! Please define the PDGid of the B-meson/hadron signal!");
102 return StatusCode::FAILURE;
110 bool acceptEvent =
true;
111 const HepMC::GenEvent* genEvt = (*itr);
115 bool LVL1Passed =
false;
119 for(
const auto&
part: *genEvt){
132 bool LVL2Passed =
false;
136 for(
const auto&
part: *genEvt)
141 if (
part != LVL1Muon )
175 for(
const auto&
part: *genEvt)
186 bool SignalPassedCuts=
false;
187 if ( LVL1Passed && LVL2Passed )
190 for(
const auto&
part: *genEvt)
192 const int particleID =
part->pdg_id();
194 bool motherIsB =
false;
195 bool newBChain =
false;
202 auto firstParent =
part->production_vertex()->particles_in().begin();
203 auto lastParent =
part->production_vertex()->particles_in().end();
208 for (
auto thisParent = firstParent; thisParent != lastParent; ++thisParent ) {
217 else{ newBChain =
false; }
222 const HepPDT::ParticleData* HadronData =
particleData(particleID);
223 std::string HadronName =
"unknown particle";
225 HadronName = HadronData->name();
226 if (particleID < 0) HadronName =
"anti - " + HadronName;
229 ATH_MSG_DEBUG(
" ------------------------------------------ ");
230 ATH_MSG_DEBUG(
" *** BSignalFilter.cxx: B-signal found *** ");
231 ATH_MSG_DEBUG(
" ------------------------------------------ ");
241 ATH_MSG_DEBUG(
" *** KINEMATIC CUTS ON PARTICLES ACTIVATED *** ");
249 bool havePassedCuts=
true;
250 TLorentzVector CandPart1, CandPart2, total_4mom;
252 FindAllChildren(
part,
"",
false,isSignal,havePassedCuts,CandPart1,CandPart2,
false,total_4mom);
260 SignalPassedCuts = ( isSignal && havePassedCuts );
266 if ( SignalPassedCuts )
268 bool accept_mass =
false;
269 bool accept_total_mass =
false;
271 ATH_MSG_DEBUG(
" *** INVARIANT MASS CUTS ON PARTICLES ACTIVATED! *** ");
275 double invMass = ( CandPart1 + CandPart2 ).M();
276 double invMass_total = total_4mom.M();
289 ATH_MSG_DEBUG(
" ==>> Event has NOT passed the mass filter!");
292 SignalPassedCuts = SignalPassedCuts && accept_mass;
296 ATH_MSG_DEBUG(
" -- Total invariant mass of the final-state particles = " << invMass_total <<
" MeV");
299 ATH_MSG_DEBUG(
" ==>> Event has passed the total mass filter!");
301 accept_total_mass =
true;
303 ATH_MSG_DEBUG(
" ==>> Event has NOT passed the total mass filter!");
306 SignalPassedCuts = SignalPassedCuts && accept_total_mass;
310 ATH_MSG_DEBUG(
" *** INVARIANT MASS CUTS ON PARTICLES NOT APPLIED (since the event is not a signal that passed cuts)! *** ");
314 ATH_MSG_DEBUG(
" *** INVARIANT MASS CUTS ON PARTICLES NOT ACTIVATED *** ");
318 SignalPassedCuts =
true;
320 ATH_MSG_DEBUG(
" *** KINEMATIC CUTS ON PARTICLES NOT ACTIVATED ==>> ACCEPT ALL EVENTS! *** ");
324 if ( SignalPassedCuts )
break;
327 if ( SignalPassedCuts )
329 ATH_MSG_DEBUG(
" -->> All signal children have passed cuts on particles!");
331 ATH_MSG_DEBUG(
" -->> Signal children have NOT passed cuts on particles!");
341 if ( (!LVL1Passed) || (!LVL2Passed) ){
348 acceptEvent = acceptEvent && SignalPassedCuts;
355 setFilterPassed(
false);
362 setFilterPassed(
true);
371 return StatusCode::SUCCESS;
377 return ( (myPT >= testPT) && (std::abs(myEta) <= testEta) );
384 int pID = child->pdg_id();
385 double myPT = child->momentum().perp();
386 double myEta = child->momentum().pseudoRapidity();
399 int pID = child->pdg_id();
400 double myPT = child->momentum().perp();
401 double myEta = child->momentum().pseudoRapidity();
413 bool fromFinalB,
bool &foundSignal,
bool &passedAllCuts,
414 TLorentzVector &p1, TLorentzVector &p2,
bool fromSelectedB, TLorentzVector &total_4mom)
const
416 int pID = mother->pdg_id();
420 bool hasChildGoodParent = fromFinalB && (fromSelectedB ||
m_B_pdgid==0);
422 if( fromFinalB && hasChildGoodParent )
426 if (
m_cuts_f_e_on && std::abs(pID)==11 ) passedAllCuts = passedAllCuts && passedCut;
427 if (
m_cuts_f_mu_on && std::abs(pID)==13 ) passedAllCuts = passedAllCuts && passedCut;
429 if (
m_cuts_f_gam_on && std::abs(pID)==22 ) passedAllCuts = passedAllCuts && passedCut;
430 if (
m_cuts_f_K0_on && std::abs(pID)==311 ) passedAllCuts = passedAllCuts && passedCut;
434 if (
m_InvMass_PartFakeMass1 < 0.) p1.SetPxPyPzE(mother->momentum().x(),mother->momentum().y(),mother->momentum().z(),mother->momentum().e() );
436 total_4mom = total_4mom + p1;
438 if (
m_InvMass_PartFakeMass2 < 0.) p2.SetPxPyPzE(mother->momentum().x(),mother->momentum().y(),mother->momentum().z(),mother->momentum().e() );
440 total_4mom = total_4mom + p2;
442 TLorentzVector current_4p;
443 current_4p.SetPxPyPzE(mother->momentum().x(),mother->momentum().y(),mother->momentum().z(),mother->momentum().e());
444 total_4mom = total_4mom + current_4p;
450 if ( !(mother->end_vertex()) )
453 ATH_MSG_DEBUG(
" Inconsistent entry in HepMC (status 2 particle not decayed), chain rejected!");
458 auto firstChild = mother->end_vertex()->particles_out().begin();
459 auto lastChild = mother->end_vertex()->particles_out().end();
461 auto firstChild = mother->end_vertex()->particles_begin(
HepMC::children);
466 std::string childIDStr;
467 if( !( treeIDStr==
"" ) ) treeIDStr = treeIDStr +
".";
474 for (
auto thisChild = firstChild; thisChild != lastChild; ++thisChild)
476 pID = (*thisChild)->pdg_id();
485 for (
auto thisChild = firstChild; thisChild != lastChild; ++thisChild)
488 std::stringstream childCntSS; childCntSS << childCnt;
489 childIDStr = treeIDStr + childCntSS.str();
490 PrintChild( (*thisChild), childIDStr, fromFinalB );
491 FindAllChildren( (*thisChild),childIDStr,fromFinalB,foundSignal,passedAllCuts,p1,p2,(pID==
m_B_pdgid) || fromSelectedB,total_4mom);
505 int pID = child->pdg_id();
506 double myPT = child->momentum().perp();
507 double myEta = child->momentum().pseudoRapidity();
518 if ( std::abs(pID) == 11 )
524 ATH_MSG_DEBUG(
" ==>> Found an electron which passed the pT and eta cuts!");
533 ATH_MSG_DEBUG(
" ==>> The electron has NOT passed the pT and eta cuts!");
540 if ( std::abs(pID) == 13 )
546 ATH_MSG_DEBUG(
" ==>> Found a muon which passed the pT and eta cuts!");
555 ATH_MSG_DEBUG(
" ==>> The muon has NOT passed the pT and eta cuts!");
568 ATH_MSG_DEBUG(
" ==>> Found a charged hadron which passed the pT and eta cuts!");
577 ATH_MSG_DEBUG(
" ==>> The charged hadron has NOT passed the pT and eta cuts!");
584 if ( std::abs(pID) == 22 )
590 ATH_MSG_DEBUG(
" ==>> Found a gamma which passed the pT and eta cuts!");
599 ATH_MSG_DEBUG(
" ==>> The gamma has NOT passed the pT and eta cuts!");
606 if ( std::abs(pID) == 311 )
612 ATH_MSG_DEBUG(
" ==>> Found a K0 which passed the pT and eta cuts!");
621 ATH_MSG_DEBUG(
" ==>> The K0 has NOT passed the pT and eta cuts!");
633 const std::string& treeIDStr,
const bool fromFinalB)
const
635 int pID = child->pdg_id();
637 const HepPDT::ParticleData* pData =
particleData(std::abs(pID));
638 std::string pName =
"unknown particle";
640 pName = pData->name();
641 if (pID < 0) pName =
"anti - " + pName;
644 <<
") " << child<<
" , from final B = " << fromFinalB);
653 ATH_MSG_ALWAYS(
" I===============================================================================================");
655 ATH_MSG_ALWAYS(
" I===============================================================================================");
659 ATH_MSG_ALWAYS(
" I Muon pT cut " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I" <<
'\t'
661 ATH_MSG_ALWAYS(
" I Muon pseudo-rapidity cut" <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I" <<
'\t'
663 ATH_MSG_ALWAYS(
" I No of events containing at least " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I");
664 ATH_MSG_ALWAYS(
" I one particle satisfying these cuts " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I" <<
'\t'
669 ATH_MSG_ALWAYS(
" I Muon pT cut " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I" <<
'\t'
671 ATH_MSG_ALWAYS(
" I Muon pseudo-rapidity cut " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I" <<
'\t'
677 ATH_MSG_ALWAYS(
" I Electron pT cut " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
679 ATH_MSG_ALWAYS(
" I Electron pseudo-rapidity cut " <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
'\t' <<
"I"
684 ATH_MSG_ALWAYS(
" I No of events containing at least one muon satisfying LVL1 cut" <<
'\t' <<
"I");
685 ATH_MSG_ALWAYS(
" I and at least one separate particle passing these LVL2 cuts " <<
'\t' <<
'\t' <<
"I" <<
'\t'
689 ATH_MSG_ALWAYS(
" I Total no of input events " <<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t' <<
"I" <<
'\t'
691 ATH_MSG_ALWAYS(
" I No of events rejected by trigger " <<
'\t' <<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t' <<
"I" <<
'\t'
693 ATH_MSG_ALWAYS(
" I No of events rejected in total " <<
'\t' <<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t'<<
'\t' <<
"I" <<
'\t'
696 ATH_MSG_ALWAYS(
" I To obtain correct cross section, multiply BX in PythiaB report by " <<
'\t' <<
'\t' <<
"I" <<
'\t'
699 ATH_MSG_ALWAYS(
" I To obtain correct cross section, multiply BX in PythiaB report by " <<
'\t' <<
'\t' <<
"I" <<
'\t'
704 ATH_MSG_ALWAYS(
" I=========================================== End of report =====================================");
706 return StatusCode::SUCCESS;