Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions PWGDQ/Core/MCProng.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ MCProng::MCProng() : fNGenerations(0),
fExcludePDG({}),
fSourceBits({}),
fExcludeSource({}),
fUseANDonSourceBitMap({})
fUseANDonSourceBitMap({}),
fCheckGenerationsInTime(0)
{
}

//________________________________________________________________________________________________________________
MCProng::MCProng(int n) : fNGenerations(n)
MCProng::MCProng(int n) : fNGenerations(n),
fCheckGenerationsInTime(0)
{
fPDGcodes.reserve(n);
fCheckBothCharges.reserve(n);
Expand All @@ -49,13 +51,14 @@ MCProng::MCProng(int n) : fNGenerations(n)
//________________________________________________________________________________________________________________
MCProng::MCProng(int n, const std::vector<int> pdgs, const std::vector<bool> checkBothCharges, const std::vector<bool> excludePDG,
const std::vector<uint64_t> sourceBits, const std::vector<uint64_t> excludeSource,
const std::vector<bool> useANDonSourceBitMap) : fNGenerations(n),
fPDGcodes(pdgs),
fCheckBothCharges(checkBothCharges),
fExcludePDG(excludePDG),
fSourceBits(sourceBits),
fExcludeSource(excludeSource),
fUseANDonSourceBitMap(useANDonSourceBitMap){};
const std::vector<bool> useANDonSourceBitMap, bool checkGenerationsInTime) : fNGenerations(n),
fPDGcodes(pdgs),
fCheckBothCharges(checkBothCharges),
fExcludePDG(excludePDG),
fSourceBits(sourceBits),
fExcludeSource(excludeSource),
fUseANDonSourceBitMap(useANDonSourceBitMap),
fCheckGenerationsInTime(checkGenerationsInTime){};

//________________________________________________________________________________________________________________
void MCProng::SetPDGcode(int generation, int code, bool checkBothCharges /*= false*/, bool exclude /*= false*/)
Expand Down Expand Up @@ -100,13 +103,19 @@ void MCProng::SetUseANDonSourceBits(int generation, bool option /*=true*/)
fUseANDonSourceBitMap[generation] = option;
}

//________________________________________________________________________________________________________________
void MCProng::SetSignalInTime(bool intime /*=false*/)
{
fCheckGenerationsInTime = intime;
}

//________________________________________________________________________________________________________________
void MCProng::Print() const
{
for (int i = 0; i < fNGenerations; i++) {
std::cout << "Generation #" << i << " PDGcode(" << fPDGcodes[i] << ") CheckBothCharges(" << fCheckBothCharges[i]
<< ") ExcludePDG(" << fExcludePDG[i] << ") SourceBits(" << fSourceBits[i] << ") ExcludeSource(" << fExcludeSource[i]
<< ") UseANDonSource(" << fUseANDonSourceBitMap[i] << ")" << std::endl;
<< ") UseANDonSource(" << fUseANDonSourceBitMap[i] << ") CheckGenerationsInTime(" << fCheckGenerationsInTime << ")" << std::endl;
}
}

Expand Down
10 changes: 6 additions & 4 deletions PWGDQ/Core/MCProng.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// bit maps with a bit dedicated to each source (MCProng::Source), bit map on whether the specified source to be excluded,
// whether to use AND among all specified source requirements

/* The PDG codes us the PYTHIA standard.
A few non-existent PYTHIA codes are used to select more than one PYTHIA code.
/* The PDG codes us the PYTHIA standard.
A few non-existent PYTHIA codes are used to select more than one PYTHIA code.

0 - default, accepts all PYTHIA codes
100 - light unflavoured mesons in the code range 100-199
Expand Down Expand Up @@ -79,14 +79,15 @@ class MCProng
MCProng();
MCProng(int n);
MCProng(int n, std::vector<int> pdgs, std::vector<bool> checkBothCharges, std::vector<bool> excludePDG,
std::vector<uint64_t> sourceBits, std::vector<uint64_t> excludeSource, std::vector<bool> useANDonSourceBitMap);
std::vector<uint64_t> sourceBits, std::vector<uint64_t> excludeSource, std::vector<bool> useANDonSourceBitMap, bool fCheckGenerationsInTime = false);
MCProng(const MCProng& c) = default;
virtual ~MCProng() = default;

void SetPDGcode(int generation, int code, bool checkBothCharges = false, bool exclude = false);
void SetSources(int generation, uint64_t bits, uint64_t exclude = 0, bool useANDonSourceBits = true);
void SetSourceBit(int generation, int sourceBit, bool exclude = false);
void SetUseANDonSourceBits(int generation, bool option = true);
void SetSignalInTime(bool intime = false); // set variable to check generations in time or back in time (default)
void Print() const;
bool TestPDG(int i, int pdgCode) const;
bool ComparePDG(int pdg, int prongPDG, bool checkBothCharges = false, bool exclude = false) const;
Expand All @@ -98,7 +99,8 @@ class MCProng
std::vector<uint64_t> fSourceBits;
std::vector<uint64_t> fExcludeSource;
std::vector<bool> fUseANDonSourceBitMap;
bool fCheckGenerationsInTime;

ClassDef(MCProng, 1);
ClassDef(MCProng, 2);
};
#endif
86 changes: 63 additions & 23 deletions PWGDQ/Core/MCSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,36 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
}
}
}
// make sure that a mother exists in the stack before moving one generation further in history
if (!currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
return false;
}
if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {

// if checking back in time: look for mother
// else (checking in time): look for daughter
if (!fProngs[i].fCheckGenerationsInTime) {
// make sure that a mother exists in the stack before moving one generation further in history
if (!currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
return false;
}
/*for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
}*/
currentMCParticle = currentMCParticle.template mothers_first_as<U>();
// currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
// currentMCParticle = currentMCParticle.template mother0_as<U>();
if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
currentMCParticle = currentMCParticle.template mothers_first_as<U>();
// currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
// currentMCParticle = currentMCParticle.template mother0_as<U>();
}
} else {
// make sure that a daughter exists in the stack before moving one generation younger

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here, mentioning that the prong history will move on the branch of the first daughter that matches the PDG requirement

if (!currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) {
return false;
}
if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) {
const auto& daughtersSlice = currentMCParticle.template daughters_as<U>();
for (auto& d : daughtersSlice) {
if (fProngs[i].TestPDG(j + 1, d.pdgCode())) {
currentMCParticle = d;
break;
}
}
}
}
}

Expand Down Expand Up @@ -202,23 +221,44 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
if (fProngs[i].fUseANDonSourceBitMap[j] && (sourcesDecision != fProngs[i].fSourceBits[j])) {
return false;
}
// move one generation back in history
// make sure that a mother exists in the stack before moving one generation further in history
if (!currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
return false;
}
if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
/*for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());

// if checking back in time: look for mother
// else (checking in time): look for daughter
if (!fProngs[i].fCheckGenerationsInTime) {
// move one generation back in history
// make sure that a mother exists in the stack before moving one generation further in history
if (!currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
return false;
}
if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) {
/*for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
}*/
currentMCParticle = currentMCParticle.template mothers_first_as<U>();
// currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
// currentMCParticle = currentMCParticle.template mother0_as<U>();
}
/*if (j < fProngs[i].fNGenerations - 1) {
currentMCParticle = mcStack.iteratorAt(currentMCParticle.mother0Id());
//currentMCParticle = currentMCParticle.template mother0_as<U>();
}*/
currentMCParticle = currentMCParticle.template mothers_first_as<U>();
// currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
// currentMCParticle = currentMCParticle.template mother0_as<U>();
} else {
// move one generation further in history
// pong history will be moved to the branch of the first daughter that matches the PDG requirement
// make sure that a daughter exists in the stack before moving one generation younger
if (!currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) {
return false;
}
if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) {
const auto& daughtersSlice = currentMCParticle.template daughters_as<U>();
for (auto& d : daughtersSlice) {
if (fProngs[i].TestPDG(j + 1, d.pdgCode())) {
currentMCParticle = d;
break;
}
}
}
}
/*if (j < fProngs[i].fNGenerations - 1) {
currentMCParticle = mcStack.iteratorAt(currentMCParticle.mother0Id());
//currentMCParticle = currentMCParticle.template mother0_as<U>();
}*/
}
}

Expand Down
64 changes: 47 additions & 17 deletions PWGDQ/Core/MCSignalLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
signal = new MCSignal(name, "Primary electrons", {prong}, {-1}); // define the signal using the full constructor
return signal;
}
if (!nameStr.compare("photon")) {
MCProng prong(1, {22}, {true}, {false}, {0}, {0}, {false}); // define 1-generation prong using the full constructor
signal = new MCSignal(name, "Photon", {prong}, {-1}); // define the signal using the full constructor
return signal;
}
if (!nameStr.compare("kaonFromPhi")) {
MCProng prong(2, {321, 333}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); // define 2-generation prong using the full constructor
signal = new MCSignal(name, "Kaons from phi-mesons", {prong}, {-1}); // define the signal using the full constructor
Expand Down Expand Up @@ -173,22 +178,28 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
signal = new MCSignal(name, "Electrons from pi0 decays", {prong}, {-1});
return signal;
}
if (!nameStr.compare("Pi0decayTOe")) {
MCProng prong(2, {111, 11}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
prong.SetSignalInTime(true); // set direction to check for daughters (true, in time) or for mothers (false, back in time)
signal = new MCSignal(name, "Pi0 decays into an electron", {prong}, {-1});
return signal;
}
if (!nameStr.compare("Pi0")) {
MCProng prong(1, {111}, {true}, {false}, {0}, {0}, {false});
//prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
// prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "Pi0", {prong}, {-1});
return signal;
}
if (!nameStr.compare("LMeeLFQ")) {
MCProng prong(1, {900}, {true}, {false}, {0}, {0}, {false});
//prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "light flavor mesons + quarkonia", {prong}, {-1}); //pi0,eta,eta',rho,omega,phi,jpsi,psi2s
// prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "light flavor mesons + quarkonia", {prong}, {-1}); // pi0,eta,eta',rho,omega,phi,jpsi,psi2s
return signal;
}
if (!nameStr.compare("LMeeLF")) {
MCProng prong(1, {901}, {true}, {false}, {0}, {0}, {false});
//prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "ligh flavor mesons", {prong}, {-1}); //pi0,eta,eta',rho,omega,phi
// prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "ligh flavor mesons", {prong}, {-1}); // pi0,eta,eta',rho,omega,phi
return signal;
}
if (!nameStr.compare("electronFromDs")) {
Expand All @@ -201,6 +212,11 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
signal = new MCSignal(name, "Ds mesons", {prong}, {-1});
return signal;
}
if (!nameStr.compare("electronFromPC")) {
MCProng prong(2, {11, 22}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
signal = new MCSignal(name, "electron from a photon conversion", {prong}, {-1});
return signal;
}

// 2-prong signals
if (!nameStr.compare("dielectron")) {
Expand Down Expand Up @@ -230,7 +246,7 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
return signal;
}

//LMEE single signals
// LMEE single signals
if (!nameStr.compare("eFromPi0")) {
MCProng prong(2, {11, 111}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
signal = new MCSignal(name, "Electrons from pi0 decays", {prong}, {-1});
Expand Down Expand Up @@ -283,14 +299,22 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
}
if (!nameStr.compare("eFromLMeeLFQ")) {
MCProng prong(2, {11, 900}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
//prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "Electrons from LF meson + quarkonia decays", {prong}, {-1}); //pi0,eta,eta',rho,omega,phi,jpsi,psi2s mesons
// prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
prong.SetSignalInTime(false); // set direction to check generation in time (true) or back in time (false)
signal = new MCSignal(name, "Electrons from LF meson + quarkonia decays", {prong}, {-1}); // pi0,eta,eta',rho,omega,phi,jpsi,psi2s mesons
return signal;
}
if (!nameStr.compare("LFQdecayToE")) {
MCProng prong(2, {900, 11}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
// prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
prong.SetSignalInTime(true); // set direction to check for daughters (true, in time) or for mothers (false, back in time)
signal = new MCSignal(name, "LF meson + quarkonia decays into e", {prong}, {-1}); // pi0,eta,eta',rho,omega,phi,jpsi,psi2s mesons
return signal;
}
if (!nameStr.compare("eFromLMeeLF")) {
MCProng prong(2, {11, 901}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
//prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "Electrons from LF meson decays", {prong}, {-1}); //pi0,eta,eta',rho,omega,phi mesons
// prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles
signal = new MCSignal(name, "Electrons from LF meson decays", {prong}, {-1}); // pi0,eta,eta',rho,omega,phi mesons
return signal;
}
if (!nameStr.compare("eFromHc")) {
Expand Down Expand Up @@ -333,9 +357,15 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
signal = new MCSignal(name, "Electrons from open charmed hadron decays from b hadron decays", {prong}, {-1});
return signal;
}
// if (!nameStr.compare("LFQtoPC")) {
// MCProng prong(3, {900, 22, 11}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false});
// prong.SetSignalInTime(true); // set direction to check for daughters (true, in time) or for mothers (false, back in time)
// signal = new MCSignal(name, "LF meson + quarkonia decays into photon conversion electron", {prong}, {-1});
// return signal;
// }

//_________________________________________________________________________________________________________________________
//LMEE pair signals for LF, same mother
// LMEE pair signals for LF, same mother
if (!nameStr.compare("eeFromPi0")) {
MCProng prong(2, {11, 111}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
signal = new MCSignal(name, "ee pairs from pi0 decays", {prong, prong}, {1, 1}); // signal at pair level
Expand Down Expand Up @@ -397,37 +427,37 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name)
return signal;
}

//LMEE pair signals for HF
//c->e and c->e (prompt)
// LMEE pair signals for HF
// c->e and c->e (prompt)
if (!nameStr.compare("eeFromCC")) {
MCProng prong(3, {11, 402, 502}, {true, true, true}, {false, false, true}, {0, 0, 0}, {0, 0, 0}, {false, false, false});
signal = new MCSignal(name, "ee pairs from c->e and c->e", {prong, prong}, {-1, -1}); // signal at pair level
return signal;
}

//b->e and b->e
// b->e and b->e
if (!nameStr.compare("eeFromBB")) {
MCProng prong(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
signal = new MCSignal(name, "ee pairs from b->e and b->e", {prong, prong}, {-1, -1}); // signal at pair level
return signal;
}

//b->c->e and b->c->e
// b->c->e and b->c->e
if (!nameStr.compare("eeFromBtoC")) {
MCProng prong(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false});
signal = new MCSignal(name, "ee pairs from b->c->e and b->c->e", {prong, prong}, {-1, -1}); // signal at pair level
return signal;
}

//b->e and b->c->e
// b->e and b->c->e
if (!nameStr.compare("eeFromBandBtoC")) {
MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false});
signal = new MCSignal(name, "ee pairs from b->e and b->c->e", {prongB, prongBtoC}, {-1, -1}); // signal at pair level
return signal;
}

//b->e and b->c->e (single b)
// b->e and b->c->e (single b)
if (!nameStr.compare("eeFromSingleBandBtoC")) {
MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false});
MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false});
Expand Down