From a7a5002072c7810d38cb55a176216fbaa452f1fd Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Tue, 7 Jun 2022 16:02:39 +0200 Subject: [PATCH 1/9] Implement option to check MCSignal in time and back in time --- PWGDQ/Core/MCProng.cxx | 30 +++++++---- PWGDQ/Core/MCProng.h | 4 +- PWGDQ/Core/MCSignal.h | 99 ++++++++++++++++++++++++++---------- PWGDQ/Core/MCSignalLibrary.h | 1 + 4 files changed, 98 insertions(+), 36 deletions(-) diff --git a/PWGDQ/Core/MCProng.cxx b/PWGDQ/Core/MCProng.cxx index 426c84eb233..12082a7e3b5 100644 --- a/PWGDQ/Core/MCProng.cxx +++ b/PWGDQ/Core/MCProng.cxx @@ -18,6 +18,7 @@ ClassImp(MCProng); //________________________________________________________________________________________________________________ MCProng::MCProng() : fNGenerations(0), + fCheckGenerationsInTime(0), fPDGcodes({}), fCheckBothCharges({}), fExcludePDG({}), @@ -28,7 +29,8 @@ MCProng::MCProng() : fNGenerations(0), } //________________________________________________________________________________________________________________ -MCProng::MCProng(int n) : fNGenerations(n) +MCProng::MCProng(int n) : fNGenerations(n), + fCheckGenerationsInTime(0) { fPDGcodes.reserve(n); fCheckBothCharges.reserve(n); @@ -49,13 +51,14 @@ MCProng::MCProng(int n) : fNGenerations(n) //________________________________________________________________________________________________________________ MCProng::MCProng(int n, const std::vector pdgs, const std::vector checkBothCharges, const std::vector excludePDG, const std::vector sourceBits, const std::vector excludeSource, - const std::vector useANDonSourceBitMap) : fNGenerations(n), - fPDGcodes(pdgs), - fCheckBothCharges(checkBothCharges), - fExcludePDG(excludePDG), - fSourceBits(sourceBits), - fExcludeSource(excludeSource), - fUseANDonSourceBitMap(useANDonSourceBitMap){}; + const std::vector 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*/) @@ -100,13 +103,22 @@ void MCProng::SetUseANDonSourceBits(int generation, bool option /*=true*/) fUseANDonSourceBitMap[generation] = option; } +//________________________________________________________________________________________________________________ +void MCProng::SetDirectionOfGeneration(int generation, bool intime /*=false*/) +{ + if (generation < 0 || generation >= fNGenerations) { + return; + } + 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; } } diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index bc0b4cb5f1f..f015882a740 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -79,7 +79,7 @@ class MCProng MCProng(); MCProng(int n); MCProng(int n, std::vector pdgs, std::vector checkBothCharges, std::vector excludePDG, - std::vector sourceBits, std::vector excludeSource, std::vector useANDonSourceBitMap); + std::vector sourceBits, std::vector excludeSource, std::vector useANDonSourceBitMap, bool fCheckGenerationsInTime = false); MCProng(const MCProng& c) = default; virtual ~MCProng() = default; @@ -87,11 +87,13 @@ class MCProng 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 SetDirectionOfGeneration(int generation, 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; int fNGenerations; + bool fCheckGenerationsInTime; std::vector fPDGcodes; std::vector fCheckBothCharges; std::vector fExcludePDG; diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index 5ecde6f9826..7871754e79b 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -133,6 +133,15 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t auto currentMCParticle = track; // loop over the generations specified for this prong for (int j = 0; j < fProngs[i].fNGenerations; j++) { + // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end + if (fProngs[i].fCheckGenerationsInTime) { + std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); + std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); + std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); + std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); + std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); + std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); + } // check the PDG code if (!fProngs[i].TestPDG(j, currentMCParticle.pdgCode())) { return false; @@ -147,23 +156,46 @@ 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) { - /*for (auto& m : mcParticle.mothers_as()) { - LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); - }*/ - currentMCParticle = currentMCParticle.template mothers_first_as(); - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); - // currentMCParticle = currentMCParticle.template mother0_as(); + + // 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; + } + if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) { + /*for (auto& m : mcParticle.mothers_as()) { + LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); + }*/ + currentMCParticle = currentMCParticle.template mothers_first_as(); + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); + // currentMCParticle = currentMCParticle.template mother0_as(); + } + } else { + // 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) { + currentMCParticle = currentMCParticle.template mothers_first_as(); + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); + } } } if (checkSources) { currentMCParticle = track; for (int j = 0; j < fProngs[i].fNGenerations; j++) { + // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end + if (fProngs[i].fCheckGenerationsInTime) { + std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); + std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); + std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); + std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); + std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); + std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); + } if (!fProngs[i].fSourceBits[j]) { // no sources required for this generation continue; @@ -202,23 +234,38 @@ 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()) { - 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()) { + LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); + }*/ + currentMCParticle = currentMCParticle.template mothers_first_as(); + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); + // currentMCParticle = currentMCParticle.template mother0_as(); + } + /*if (j < fProngs[i].fNGenerations - 1) { + currentMCParticle = mcStack.iteratorAt(currentMCParticle.mother0Id()); + //currentMCParticle = currentMCParticle.template mother0_as(); }*/ - currentMCParticle = currentMCParticle.template mothers_first_as(); - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); - // currentMCParticle = currentMCParticle.template mother0_as(); + } else { + // move one generation further in history + // 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) { + currentMCParticle = currentMCParticle.template mothers_first_as(); + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); + } } - /*if (j < fProngs[i].fNGenerations - 1) { - currentMCParticle = mcStack.iteratorAt(currentMCParticle.mother0Id()); - //currentMCParticle = currentMCParticle.template mother0_as(); - }*/ } } diff --git a/PWGDQ/Core/MCSignalLibrary.h b/PWGDQ/Core/MCSignalLibrary.h index 11aa934dc65..7365d37dca8 100644 --- a/PWGDQ/Core/MCSignalLibrary.h +++ b/PWGDQ/Core/MCSignalLibrary.h @@ -284,6 +284,7 @@ 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 + prong.SetDirectionOfGeneration(0, true); // 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; } From 7be92dcb19c85b106ac956b82dd02656141a4f52 Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Tue, 21 Jun 2022 15:14:23 +0200 Subject: [PATCH 2/9] added some lines to pint MC signal to terminal --- PWGDQ/Core/MCProng.cxx | 2 +- PWGDQ/Core/MCProng.h | 2 +- PWGDQ/Core/MCSignal.h | 105 ++++++++++++++++++++++------------- PWGDQ/Core/MCSignalLibrary.h | 2 +- PWGEM/Tasks/CMakeLists.txt | 5 ++ 5 files changed, 75 insertions(+), 41 deletions(-) diff --git a/PWGDQ/Core/MCProng.cxx b/PWGDQ/Core/MCProng.cxx index 12082a7e3b5..b1535402931 100644 --- a/PWGDQ/Core/MCProng.cxx +++ b/PWGDQ/Core/MCProng.cxx @@ -104,7 +104,7 @@ void MCProng::SetUseANDonSourceBits(int generation, bool option /*=true*/) } //________________________________________________________________________________________________________________ -void MCProng::SetDirectionOfGeneration(int generation, bool intime /*=false*/) +void MCProng::SetSignalInTime(int generation, bool intime /*=false*/) { if (generation < 0 || generation >= fNGenerations) { return; diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index f015882a740..9703b345a9a 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -87,7 +87,7 @@ class MCProng 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 SetDirectionOfGeneration(int generation, bool intime = false); // set variable to check generations in time or back in time (default) + void SetSignalInTime(int generation, 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; diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index 7871754e79b..fcbb1d66620 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -130,18 +130,20 @@ class MCSignal : public TNamed template bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& track) { + // // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end + // if (fProngs[i].fCheckGenerationsInTime) { + // std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); + // std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); + // std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); + // std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); + // std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); + // std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); + // } + auto currentMCParticle = track; + // loop over the generations specified for this prong for (int j = 0; j < fProngs[i].fNGenerations; j++) { - // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end - if (fProngs[i].fCheckGenerationsInTime) { - std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); - std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); - std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); - std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); - std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); - std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); - } // check the PDG code if (!fProngs[i].TestPDG(j, currentMCParticle.pdgCode())) { return false; @@ -160,27 +162,54 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t // 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; - } - if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) { - /*for (auto& m : mcParticle.mothers_as()) { - LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); - }*/ - currentMCParticle = currentMCParticle.template mothers_first_as(); - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); - // currentMCParticle = currentMCParticle.template mother0_as(); - } + // if (currentMCParticle.has_mothers() > 0) { + // printf("CheckGenInTime = %i \n", fProngs[i].fCheckGenerationsInTime); + // printf("currentPart pdg = %i \n", currentMCParticle.pdgCode()); + // printf("fProng.NGenerations = %i \n", fProngs[i].fNGenerations); + // for (int k = 0; k < fProngs[i].fNGenerations; k++) { + // printf("fProng.pdg(kGen=%i) = %i \n", k, fProngs[i].fPDGcodes[k]); + // } + // printf("currentParticle.hasMothers = %i \n", currentMCParticle.has_mothers()); + + // 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()) { + LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); + }*/ + currentMCParticle = currentMCParticle.template mothers_first_as(); + // printf("changed to mother particle pdg = %i \n", currentMCParticle.pdgCode()); + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); + // currentMCParticle = currentMCParticle.template mother0_as(); + } + // } } else { - // 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) { - currentMCParticle = currentMCParticle.template mothers_first_as(); - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); - } + // if (currentMCParticle.has_daughters() > 0) { + // printf("CheckGenInTime = %i \n", fProngs[i].fCheckGenerationsInTime); + // printf("currentPart pdg = %i \n", currentMCParticle.pdgCode()); + // printf("fProng.NGenerations = %i \n", fProngs[i].fNGenerations); + // for (int k = 0; k < fProngs[i].fNGenerations; k++) { + // printf("fProng.pdg(kGen=%i) = %i \n", k, fProngs[i].fPDGcodes[k]); + // } + // printf("currentParticle.hasDaugthers = %i \n", currentMCParticle.has_daughters()); + // 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) { + auto daughtersSlice = currentMCParticle.template daughters_as(); + // printf("DaughtersSlice.size = %i \n", daughtersSlice.size()); + for (auto d : daughtersSlice) { + // printf("daughterPart pdg = %i \n", d.pdgCode()); + currentMCParticle = d; + // printf("changed currentPart pdg = %i \n", currentMCParticle.pdgCode()); + } + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.daughtersIds()[0]); + } + // printf(" -------------- \n"); + // } } } @@ -188,14 +217,14 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t currentMCParticle = track; for (int j = 0; j < fProngs[i].fNGenerations; j++) { // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end - if (fProngs[i].fCheckGenerationsInTime) { - std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); - std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); - std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); - std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); - std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); - std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); - } + // if (fProngs[i].fCheckGenerationsInTime) { + // std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); + // std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); + // std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); + // std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); + // std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); + // std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); + // } if (!fProngs[i].fSourceBits[j]) { // no sources required for this generation continue; @@ -262,7 +291,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t return false; } if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { - currentMCParticle = currentMCParticle.template mothers_first_as(); + // currentMCParticle = currentMCParticle.template mothers_first_as(); // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); } } diff --git a/PWGDQ/Core/MCSignalLibrary.h b/PWGDQ/Core/MCSignalLibrary.h index 7365d37dca8..e798a52002c 100644 --- a/PWGDQ/Core/MCSignalLibrary.h +++ b/PWGDQ/Core/MCSignalLibrary.h @@ -284,7 +284,7 @@ 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 - prong.SetDirectionOfGeneration(0, true); // set direction to check generation in time (true) or back in time (false) + prong.SetSignalInTime(0, 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; } diff --git a/PWGEM/Tasks/CMakeLists.txt b/PWGEM/Tasks/CMakeLists.txt index 840b6bfbbcf..7b398b1b6b6 100644 --- a/PWGEM/Tasks/CMakeLists.txt +++ b/PWGEM/Tasks/CMakeLists.txt @@ -18,3 +18,8 @@ o2physics_add_dpl_workflow(phoscluqa SOURCES phosCluQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::DetectorsVertexing O2::PHOSBase COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(analysemcsignal + SOURCES analysemcsignal.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) \ No newline at end of file From 89e46f045c76c47a738936385793630e30a89f80 Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Fri, 1 Jul 2022 11:49:44 +0200 Subject: [PATCH 3/9] option to check MC from Mother to daugther, sucessfull --- PWGDQ/Core/MCSignal.h | 98 ++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 63 deletions(-) diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index fcbb1d66620..83849dcab34 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -130,18 +130,7 @@ class MCSignal : public TNamed template bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& track) { - // // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end - // if (fProngs[i].fCheckGenerationsInTime) { - // std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); - // std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); - // std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); - // std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); - // std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); - // std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); - // } - auto currentMCParticle = track; - // loop over the generations specified for this prong for (int j = 0; j < fProngs[i].fNGenerations; j++) { // check the PDG code @@ -162,69 +151,43 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t // if checking back in time: look for mother // else (checking in time): look for daughter if (!fProngs[i].fCheckGenerationsInTime) { - // if (currentMCParticle.has_mothers() > 0) { - // printf("CheckGenInTime = %i \n", fProngs[i].fCheckGenerationsInTime); - // printf("currentPart pdg = %i \n", currentMCParticle.pdgCode()); - // printf("fProng.NGenerations = %i \n", fProngs[i].fNGenerations); - // for (int k = 0; k < fProngs[i].fNGenerations; k++) { - // printf("fProng.pdg(kGen=%i) = %i \n", k, fProngs[i].fPDGcodes[k]); - // } - // printf("currentParticle.hasMothers = %i \n", currentMCParticle.has_mothers()); - - // 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()) { - LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); - }*/ - currentMCParticle = currentMCParticle.template mothers_first_as(); - // printf("changed to mother particle pdg = %i \n", currentMCParticle.pdgCode()); - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); - // currentMCParticle = currentMCParticle.template mother0_as(); + // 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()) { + LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); + }*/ + // currentMCParticle = currentMCParticle.template mothers_first_as(); + if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) { + const auto& mothersSlice = currentMCParticle.template mothers_as(); + for (auto& mother : mothersSlice) { + currentMCParticle = mother; } - // } + // printf("changed to mother particle pdg = %i \n", currentMCParticle.pdgCode()); + // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); + // currentMCParticle = currentMCParticle.template mother0_as(); + } } else { - // if (currentMCParticle.has_daughters() > 0) { - // printf("CheckGenInTime = %i \n", fProngs[i].fCheckGenerationsInTime); - // printf("currentPart pdg = %i \n", currentMCParticle.pdgCode()); - // printf("fProng.NGenerations = %i \n", fProngs[i].fNGenerations); - // for (int k = 0; k < fProngs[i].fNGenerations; k++) { - // printf("fProng.pdg(kGen=%i) = %i \n", k, fProngs[i].fPDGcodes[k]); - // } - // printf("currentParticle.hasDaugthers = %i \n", currentMCParticle.has_daughters()); - // 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) { - auto daughtersSlice = currentMCParticle.template daughters_as(); - // printf("DaughtersSlice.size = %i \n", daughtersSlice.size()); - for (auto d : daughtersSlice) { - // printf("daughterPart pdg = %i \n", d.pdgCode()); + // 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(); + for (auto& d : daughtersSlice) { + if (abs(d.pdgCode()) == fProngs[i].fPDGcodes[j + 1]) { currentMCParticle = d; - // printf("changed currentPart pdg = %i \n", currentMCParticle.pdgCode()); + break; } - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.daughtersIds()[0]); } - // printf(" -------------- \n"); - // } + } } } if (checkSources) { currentMCParticle = track; for (int j = 0; j < fProngs[i].fNGenerations; j++) { - // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end - // if (fProngs[i].fCheckGenerationsInTime) { - // std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end()); - // std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end()); - // std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end()); - // std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end()); - // std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end()); - // std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end()); - // } if (!fProngs[i].fSourceBits[j]) { // no sources required for this generation continue; @@ -294,6 +257,15 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t // currentMCParticle = currentMCParticle.template mothers_first_as(); // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); } + if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { + const auto& daughtersSlice = currentMCParticle.template daughters_as(); + for (auto& d : daughtersSlice) { + if (abs(d.pdgCode()) == fProngs[i].fPDGcodes[j + 1]) { + currentMCParticle = d; + break; + } + } + } } } } From a83dbf0cd6b4204075e76a8f39a6b5db2fbbcfbe Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Mon, 4 Jul 2022 09:49:14 +0200 Subject: [PATCH 4/9] select mothers by mother_first_as() --- PWGDQ/Core/MCSignal.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index 83849dcab34..9498be60970 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -158,13 +158,8 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t /*for (auto& m : mcParticle.mothers_as()) { LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex()); }*/ - // currentMCParticle = currentMCParticle.template mothers_first_as(); if (currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) { - const auto& mothersSlice = currentMCParticle.template mothers_as(); - for (auto& mother : mothersSlice) { - currentMCParticle = mother; - } - // printf("changed to mother particle pdg = %i \n", currentMCParticle.pdgCode()); + currentMCParticle = currentMCParticle.template mothers_first_as(); // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); // currentMCParticle = currentMCParticle.template mother0_as(); } From b2c8daa2a7616bfaf5264877dad893de0effb892 Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Mon, 4 Jul 2022 10:28:11 +0200 Subject: [PATCH 5/9] checkout CMakeLists.txt, remove task from list --- PWGDQ/Core/MCProng.h | 4 ++-- PWGDQ/Core/MCSignalLibrary.h | 6 +++--- PWGEM/Tasks/CMakeLists.txt | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index 9703b345a9a..e7e59be06ff 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -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 diff --git a/PWGDQ/Core/MCSignalLibrary.h b/PWGDQ/Core/MCSignalLibrary.h index e798a52002c..37e7645dca0 100644 --- a/PWGDQ/Core/MCSignalLibrary.h +++ b/PWGDQ/Core/MCSignalLibrary.h @@ -283,9 +283,9 @@ 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 - prong.SetSignalInTime(0, 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 + // prong.SetSourceBit(0, MCProng::kPhysicalPrimary, false); // set source to be ALICE primary particles + prong.SetSignalInTime(0, 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("eFromLMeeLF")) { diff --git a/PWGEM/Tasks/CMakeLists.txt b/PWGEM/Tasks/CMakeLists.txt index 7b398b1b6b6..840b6bfbbcf 100644 --- a/PWGEM/Tasks/CMakeLists.txt +++ b/PWGEM/Tasks/CMakeLists.txt @@ -18,8 +18,3 @@ o2physics_add_dpl_workflow(phoscluqa SOURCES phosCluQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::DetectorsVertexing O2::PHOSBase COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(analysemcsignal - SOURCES analysemcsignal.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGDQCore - COMPONENT_NAME Analysis) \ No newline at end of file From 0a71e44f8cbde431000691b6effb5db25fcd3ca5 Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Mon, 4 Jul 2022 12:36:30 +0200 Subject: [PATCH 6/9] Increase ClassDef(), and add MC signal --- PWGDQ/Core/MCProng.h | 2 +- PWGDQ/Core/MCSignalLibrary.h | 59 +++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index e7e59be06ff..6a1e417a0c6 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -101,6 +101,6 @@ class MCProng std::vector fExcludeSource; std::vector fUseANDonSourceBitMap; - ClassDef(MCProng, 1); + ClassDef(MCProng, 2); }; #endif diff --git a/PWGDQ/Core/MCSignalLibrary.h b/PWGDQ/Core/MCSignalLibrary.h index 37e7645dca0..39e8c72a5cf 100644 --- a/PWGDQ/Core/MCSignalLibrary.h +++ b/PWGDQ/Core/MCSignalLibrary.h @@ -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 @@ -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(0, 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")) { @@ -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")) { @@ -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}); @@ -288,10 +304,17 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) 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(0, 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")) { @@ -334,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(0, 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 @@ -398,29 +427,29 @@ 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}); @@ -428,7 +457,7 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) 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}); From b59a4b8ada96f18747982d5746410d16c0eb431c Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Fri, 8 Jul 2022 10:20:21 +0200 Subject: [PATCH 7/9] change order of variables, fix o2 compiling error --- PWGDQ/Core/MCProng.cxx | 4 ++-- PWGDQ/Core/MCProng.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGDQ/Core/MCProng.cxx b/PWGDQ/Core/MCProng.cxx index b1535402931..93db0cf1a76 100644 --- a/PWGDQ/Core/MCProng.cxx +++ b/PWGDQ/Core/MCProng.cxx @@ -18,13 +18,13 @@ ClassImp(MCProng); //________________________________________________________________________________________________________________ MCProng::MCProng() : fNGenerations(0), - fCheckGenerationsInTime(0), fPDGcodes({}), fCheckBothCharges({}), fExcludePDG({}), fSourceBits({}), fExcludeSource({}), - fUseANDonSourceBitMap({}) + fUseANDonSourceBitMap({}), + fCheckGenerationsInTime(0) { } diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index 6a1e417a0c6..c7511af916d 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -93,13 +93,13 @@ class MCProng bool ComparePDG(int pdg, int prongPDG, bool checkBothCharges = false, bool exclude = false) const; int fNGenerations; - bool fCheckGenerationsInTime; std::vector fPDGcodes; std::vector fCheckBothCharges; std::vector fExcludePDG; std::vector fSourceBits; std::vector fExcludeSource; std::vector fUseANDonSourceBitMap; + bool fCheckGenerationsInTime; ClassDef(MCProng, 2); }; From c0a1f6138b862e1b9f611711d2b50ba5e9f1a79c Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Tue, 12 Jul 2022 12:12:21 +0200 Subject: [PATCH 8/9] Include comments --- PWGDQ/Core/MCProng.cxx | 5 +---- PWGDQ/Core/MCProng.h | 2 +- PWGDQ/Core/MCSignal.h | 5 +++-- PWGDQ/Core/MCSignalLibrary.h | 8 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/PWGDQ/Core/MCProng.cxx b/PWGDQ/Core/MCProng.cxx index 93db0cf1a76..b77fb469252 100644 --- a/PWGDQ/Core/MCProng.cxx +++ b/PWGDQ/Core/MCProng.cxx @@ -104,11 +104,8 @@ void MCProng::SetUseANDonSourceBits(int generation, bool option /*=true*/) } //________________________________________________________________________________________________________________ -void MCProng::SetSignalInTime(int generation, bool intime /*=false*/) +void MCProng::SetSignalInTime(bool intime /*=false*/) { - if (generation < 0 || generation >= fNGenerations) { - return; - } fCheckGenerationsInTime = intime; } diff --git a/PWGDQ/Core/MCProng.h b/PWGDQ/Core/MCProng.h index c7511af916d..8a7b732ee29 100644 --- a/PWGDQ/Core/MCProng.h +++ b/PWGDQ/Core/MCProng.h @@ -87,7 +87,7 @@ class MCProng 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(int generation, bool intime = false); // set variable to check generations in time or back in time (default) + 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; diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index 9498be60970..d5385f270ce 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -171,7 +171,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { const auto& daughtersSlice = currentMCParticle.template daughters_as(); for (auto& d : daughtersSlice) { - if (abs(d.pdgCode()) == fProngs[i].fPDGcodes[j + 1]) { + if (fProngs[i].TestPDG(j + 1, d.pdgCode())) { currentMCParticle = d; break; } @@ -244,6 +244,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t }*/ } 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; @@ -255,7 +256,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { const auto& daughtersSlice = currentMCParticle.template daughters_as(); for (auto& d : daughtersSlice) { - if (abs(d.pdgCode()) == fProngs[i].fPDGcodes[j + 1]) { + if (fProngs[i].TestPDG(j + 1, d.pdgCode())) { currentMCParticle = d; break; } diff --git a/PWGDQ/Core/MCSignalLibrary.h b/PWGDQ/Core/MCSignalLibrary.h index 39e8c72a5cf..58994d06f2e 100644 --- a/PWGDQ/Core/MCSignalLibrary.h +++ b/PWGDQ/Core/MCSignalLibrary.h @@ -180,7 +180,7 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) } if (!nameStr.compare("Pi0decayTOe")) { MCProng prong(2, {111, 11}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); - prong.SetSignalInTime(0, true); // set direction to check for daughters (true, in time) or for mothers (false, back in time) + 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; } @@ -300,14 +300,14 @@ 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 - prong.SetSignalInTime(0, false); // set direction to check generation in time (true) or back in time (false) + 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(0, true); // set direction to check for daughters (true, in time) or for mothers (false, back in time) + 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; } @@ -359,7 +359,7 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) } // 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(0, true); // set direction to check for daughters (true, in time) or for mothers (false, back in time) + // 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; // } From 456b52aef89300c40ba0284606ca85fb2a4e2506 Mon Sep 17 00:00:00 2001 From: Florian Eisenhut Date: Wed, 13 Jul 2022 08:02:04 +0200 Subject: [PATCH 9/9] remove empty if case --- PWGDQ/Core/MCSignal.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index d5385f270ce..bc9c4dec85d 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -249,10 +249,6 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t if (!currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { return false; } - if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { - // currentMCParticle = currentMCParticle.template mothers_first_as(); - // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]); - } if (currentMCParticle.has_daughters() && j < fProngs[i].fNGenerations - 1) { const auto& daughtersSlice = currentMCParticle.template daughters_as(); for (auto& d : daughtersSlice) {