|
| 1 | +R__ADD_INCLUDE_PATH($O2DPG_ROOT) |
| 2 | +#include <TParticle.h> |
| 3 | +#include "Generators/Trigger.h" |
| 4 | + |
| 5 | +/// ================================================================================================================================= |
| 6 | +/// Select daughters from HF particles produced in a given rapidity window |
| 7 | +/// pdgPartForAccCut: pdg of the particle (coming from c / b) requested within the rapidity window [rapidityMin, rapidityMax] |
| 8 | +/// cutOnSingleChild: if true the condition on the rapidity is required for only one of the child particles (e.g. bb -> J/psi J/psi, bb -> ee,...) |
| 9 | +/// Tested for: |
| 10 | +/// - non-prompt J/psi / Psi(2S) |
| 11 | +/// - dielectron / dimuon pairs from cc and bb |
| 12 | +/// - single electrons / muons from b and b -> c -> e |
| 13 | +/// ================================================================================================================================= |
| 14 | +Int_t GetFlavour(Int_t pdgCode); |
| 15 | + |
| 16 | +o2::eventgen::Trigger selectDaughterFromHFwithinAcc(Int_t pdgPartForAccCut=443, Bool_t cutOnSingleChild = kTRUE, double rapidityMin = -1., double rapidityMax = -1.) |
| 17 | +{ |
| 18 | + return [pdgPartForAccCut,cutOnSingleChild,rapidityMin,rapidityMax](const std::vector<TParticle>& particles) -> bool { |
| 19 | + |
| 20 | + int nsig = 0; int mpdg = -1; int mpdgUpperFamily = -1; double rapidity = -999.; |
| 21 | + Bool_t isSelectedY = kFALSE; if(!cutOnSingleChild) isSelectedY = kTRUE; |
| 22 | + Bool_t isHF = kFALSE; |
| 23 | + for (const auto& particle : particles) { |
| 24 | + if(cutOnSingleChild && TMath::Abs(particle.GetPdgCode()) == pdgPartForAccCut){ |
| 25 | + Int_t mi = particle.GetMother(0); |
| 26 | + if(mi<0) continue; |
| 27 | + TParticle mother = particles.at(mi); |
| 28 | + mpdg=TMath::Abs(mother.GetPdgCode()); |
| 29 | + mpdgUpperFamily=(mpdg>1000 ? mpdg+1000 : mpdg+100); |
| 30 | + if(GetFlavour(mpdg) == 5 || GetFlavour(mpdgUpperFamily) == 5){ // keep particles from (b->) c |
| 31 | + rapidity = particle.Y(); |
| 32 | + if( (rapidity > rapidityMin) && (rapidity < rapidityMax) ) isSelectedY = kTRUE; |
| 33 | + } |
| 34 | + } |
| 35 | + /////// |
| 36 | + if(!cutOnSingleChild && TMath::Abs(particle.GetPdgCode()) == pdgPartForAccCut){ |
| 37 | + Int_t mi = particle.GetMother(0); |
| 38 | + if(mi<0) continue; |
| 39 | + TParticle mother = particles.at(mi); |
| 40 | + mpdg=TMath::Abs(mother.GetPdgCode()); |
| 41 | + if( (GetFlavour(mpdg) == 5) || (GetFlavour(mpdg) == 4)){ |
| 42 | + isHF = kTRUE; |
| 43 | + rapidity = particle.Y(); |
| 44 | + if( (rapidity < rapidityMin) || (rapidity > rapidityMax) ) isSelectedY = kFALSE; |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + // |
| 49 | + if(cutOnSingleChild && !isSelectedY) return kFALSE; |
| 50 | + if(!cutOnSingleChild && !(isHF && isSelectedY)) return kFALSE; |
| 51 | + return kTRUE; |
| 52 | + }; |
| 53 | + |
| 54 | +} |
| 55 | + |
| 56 | +Int_t GetFlavour(Int_t pdgCode) |
| 57 | + { |
| 58 | + // |
| 59 | + // return the flavour of a particle |
| 60 | + // input: pdg code of the particle |
| 61 | + // output: Int_t |
| 62 | + // 3 in case of strange (open and hidden) |
| 63 | + // 4 in case of charm (") |
| 64 | + // 5 in case of beauty (") |
| 65 | + // |
| 66 | + Int_t pdg = TMath::Abs(pdgCode); |
| 67 | + //Resonance |
| 68 | + if (pdg > 100000) pdg %= 100000; |
| 69 | + if(pdg > 10000) pdg %= 10000; |
| 70 | + // meson ? |
| 71 | + if(pdg > 10) pdg/=100; |
| 72 | + // baryon ? |
| 73 | + if(pdg > 10) pdg/=10; |
| 74 | + return pdg; |
| 75 | + } |
| 76 | + |
0 commit comments