Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PWGLF] store wd mother pdg info in mask #9285

Merged
merged 4 commits into from
Jan 14, 2025
Merged
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
68 changes: 63 additions & 5 deletions PWGLF/TableProducer/Nuspex/ebyeMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#include "PWGLF/DataModel/LFEbyeTables.h"

#include "TDatabasePDG.h"

Check warning on line 47 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/database]

Direct use of TDatabasePDG is not allowed. Use o2::constants::physics::Mass... or Service<o2::framework::O2DatabasePDG>.
#include "TFormula.h"

using namespace o2;
Expand Down Expand Up @@ -159,6 +159,7 @@
float genpt = -999.f;
float geneta = -999.f;
int pdgcode = -999;
int pdgcodemoth = -999;
bool isreco = 0;
int64_t mcIndex = -999;
int64_t globalIndex = -999;
Expand All @@ -179,6 +180,12 @@
kTPCPIDMid = BIT(11)
};

enum PartTypes {
kLa = BIT(20),
kSig = BIT(21),
kPhysPrim = BIT(22)
};

struct tagRun2V0MCalibration {
bool mCalibrationStored = false;
TH1* mhVtxAmpCorrV0A = nullptr;
Expand Down Expand Up @@ -313,6 +320,37 @@
Preslice<aod::V0s> perCollisionV0 = o2::aod::v0::collisionId;
Preslice<aod::McParticles> perCollisionMcParts = o2::aod::mcparticle::mcCollisionId;

template <class P>
int getPartTypeMother(P const& mcPart)
{
for (auto& mother : mcPart.template mothers_as<aod::McParticles>()) {

Check warning on line 326 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (!mother.isPhysicalPrimary())
return -1;
int pdgCode = mother.pdgCode();
switch (std::abs(pdgCode)) {
case 3122: {
int foundPi = 0;
for (auto& mcDaught : mother.template daughters_as<aod::McParticles>()) {

Check warning on line 333 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (std::abs(mcDaught.pdgCode()) == 211) {
foundPi = mcDaught.pdgCode();
break;
}
}
if (foundPi * mcPart.pdgCode() < -0.5)
return PartTypes::kLa;
return -1;
}
// case 3222:
// return PartTypes::kSig;
// case 3112:
// return PartTypes::kSig;
default:
return -1;
}
}
return -1;
}

template <class T>
bool selectV0Daughter(T const& track)
{
Expand Down Expand Up @@ -493,17 +531,17 @@
auto fv0c = fv0cs.rawIteratorAt(id);
float multFV0A = 0;
float multFV0C = 0;
for (float amplitude : fv0a.amplitude()) {

Check warning on line 534 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
multFV0A += amplitude;
}

for (float amplitude : fv0c.amplitude()) {

Check warning on line 538 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
multFV0C += amplitude;
}

float v0m = -1;
auto scaleMC = [](float x, float pars[6]) {
return pow(((pars[0] + pars[1] * pow(x, pars[2])) - pars[3]) / pars[4], 1.0f / pars[5]);

Check warning on line 544 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
};

if (Run2V0MInfo.mMCScale != nullptr) {
Expand Down Expand Up @@ -867,23 +905,32 @@
}

template <class C, class T>
void fillMcEvent(C const& collision, T const& tracks, aod::V0s const& V0s, float const& centrality, aod::McParticles const&, aod::McTrackLabels const& mcLabels)
void fillMcEvent(C const& collision, T const& tracks, aod::V0s const& V0s, float const& centrality, aod::McParticles const& particlesMC, aod::McTrackLabels const& mcLabels)
{
fillRecoEvent<C, T>(collision, tracks, V0s, centrality);

for (int iP{0}; iP < kNpart; ++iP) {
for (auto& candidateTrack : candidateTracks[iP]) {

Check warning on line 913 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
candidateTrack.isreco = true;

auto mcLab = mcLabels.rawIteratorAt(candidateTrack.globalIndex);

if (mcLab.mcParticleId() < -1 || mcLab.mcParticleId() >= particlesMC.size()) {
continue;
}
if (mcLab.has_mcParticle()) {
auto mcTrack = mcLab.template mcParticle_as<aod::McParticles>();
if (std::abs(mcTrack.pdgCode()) != partPdg[iP])
continue;
if (((mcTrack.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcTrack.flags() & 0x2) || (mcTrack.flags() & 0x1))
if (((mcTrack.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcTrack.flags() & 0x2) || ((mcTrack.flags() & 0x1) && !doprocessMiniMcRun2))
continue;
if (!mcTrack.isPhysicalPrimary())

if (!mcTrack.isPhysicalPrimary() && !doprocessMiniMcRun2)
continue;
if (mcTrack.isPhysicalPrimary())
candidateTrack.pdgcodemoth = PartTypes::kPhysPrim;
else if (mcTrack.has_mothers() && iP == 0)
candidateTrack.pdgcodemoth = getPartTypeMother(mcTrack);

auto genPt = std::hypot(mcTrack.px(), mcTrack.py());
candidateTrack.pdgcode = mcTrack.pdgCode();
Expand All @@ -893,7 +940,7 @@
}
}
}
for (auto& candidateV0 : candidateV0s) {

Check warning on line 943 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
candidateV0.isreco = true;
auto mcLabPos = mcLabels.rawIteratorAt(candidateV0.globalIndexPos);
auto mcLabNeg = mcLabels.rawIteratorAt(candidateV0.globalIndexNeg);
Expand All @@ -902,8 +949,8 @@
auto mcTrackPos = mcLabPos.template mcParticle_as<aod::McParticles>();
auto mcTrackNeg = mcLabNeg.template mcParticle_as<aod::McParticles>();
if (mcTrackPos.has_mothers() && mcTrackNeg.has_mothers()) {
for (auto& negMother : mcTrackNeg.template mothers_as<aod::McParticles>()) {

Check warning on line 952 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
for (auto& posMother : mcTrackPos.template mothers_as<aod::McParticles>()) {

Check warning on line 953 in PWGLF/TableProducer/Nuspex/ebyeMaker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (posMother.globalIndex() != negMother.globalIndex())
continue;
if (!((mcTrackPos.pdgCode() == 2212 && mcTrackNeg.pdgCode() == -211) || (mcTrackPos.pdgCode() == 211 && mcTrackNeg.pdgCode() == -2212)))
Expand Down Expand Up @@ -936,7 +983,7 @@
if (std::abs(genEta) > etaMax) {
continue;
}
if (((mcPart.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcPart.flags() & 0x2) || (mcPart.flags() & 0x1))
if (((mcPart.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcPart.flags() & 0x2) || ((mcPart.flags() & 0x1) && !doprocessMiniMcRun2))
continue;
auto pdgCode = mcPart.pdgCode();
if (std::abs(pdgCode) == 3122) {
Expand Down Expand Up @@ -969,13 +1016,18 @@
if (std::abs(pdgCode) == partPdg[0]) {
iP = 0;
}
if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers())
if ((!mcPart.isPhysicalPrimary() && !doprocessMiniMcRun2))
continue;
auto genPt = std::hypot(mcPart.px(), mcPart.py());
CandidateTrack candTrack;
candTrack.genpt = genPt;
candTrack.geneta = mcPart.eta();
candTrack.pdgcode = pdgCode;
if (mcPart.isPhysicalPrimary())
candTrack.pdgcodemoth = PartTypes::kPhysPrim;
else if (mcPart.has_mothers() && iP == 0)
candTrack.pdgcodemoth = getPartTypeMother(mcPart);

auto it = find_if(candidateTracks[iP].begin(), candidateTracks[iP].end(), [&](CandidateTrack trk) { return trk.mcIndex == mcPart.globalIndex(); });
if (it != candidateTracks[iP].end()) {
continue;
Expand Down Expand Up @@ -1385,7 +1437,13 @@
selMask = getTrackSelMask(candidateTrack);
// if (candidateTrack.outerPID < -4)
// continue;
if (candidateTrack.pdgcodemoth > 0)
selMask |= candidateTrack.pdgcodemoth;
} else if (candidateTrack.pdgcodemoth > 0) {
selMask = candidateTrack.pdgcodemoth;
}
if (selMask < 0)
continue;
mcMiniTrkTable(
miniCollTable.lastIndex(),
candidateTrack.pt,
Expand Down
Loading