Skip to content

Commit e19fa37

Browse files
jesgumalibuild
andauthored
[ALICE3] Tag secondaries from otf decayer properly and add qa to otf tracker (#17130)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 0e48686 commit e19fa37

3 files changed

Lines changed: 62 additions & 20 deletions

File tree

ALICE3/Core/OTFParticle.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class OTFParticle
5555
mVt = particle.vt();
5656
mFlag = particle.flags();
5757
mStatusCode = particle.statusCode();
58-
mIsFromMcParticles = true;
58+
setBitOff(DecayerBits::ProducedByDecayer);
5959
if (particle.has_mothers()) {
6060
mIndicesMother = {particle.mothersIds().front(), particle.mothersIds().back()};
6161
}
@@ -72,7 +72,6 @@ class OTFParticle
7272
}
7373

7474
// Setters
75-
void setIsPrimary(const bool isPrimary) { mIsPrimary = isPrimary; }
7675
void setCollisionId(const int collisionId) { mCollisionId = collisionId; }
7776
void setPDG(const int pdg) { mPdgCode = pdg; }
7877
void setIndicesMother(const int start, const int stop) { mIndicesMother = {start, stop}; }
@@ -105,9 +104,9 @@ class OTFParticle
105104
int pdgCode() const { return mPdgCode; }
106105
int globalIndex() const { return mGlobalIndex; }
107106
int collisionId() const { return mCollisionId; }
108-
bool isAlive() const { return mIsAlive; }
109-
bool isPrimary() const { return mIsPrimary; }
110-
bool isFromMcParticles() const { return mIsFromMcParticles; }
107+
bool isAlive() const { return checkBit(DecayerBits::IsAlive); }
108+
bool isPrimary() const { return checkBit(DecayerBits::IsPrimary); }
109+
bool isFromMcParticles() const { return !checkBit(DecayerBits::ProducedByDecayer); }
111110
float weight() const
112111
{
113112
static constexpr float Weight = 1.f;
@@ -154,8 +153,8 @@ class OTFParticle
154153
int getMotherIndexStop() const { return mIndicesMother[1]; }
155154
int getDaughterIndexStart() const { return mIndicesDaughter[0]; }
156155
int getDaughterIndexStop() const { return mIndicesDaughter[1]; }
157-
std::array<int, 2> getMothers() const { return mIndicesMother; }
158-
std::array<int, 2> getDaughters() const { return mIndicesDaughter; }
156+
const std::array<int, 2>& getMothers() const { return mIndicesMother; }
157+
const std::array<int, 2>& getDaughters() const { return mIndicesDaughter; }
159158
std::span<const int> getMotherSpan() const { return hasMothers() ? std::span<const int>(mIndicesMother.data(), 2) : std::span<const int>(); }
160159

161160
// Checks
@@ -177,7 +176,7 @@ class OTFParticle
177176
void setBitOn(DecayerBits bit) { mBits.set(static_cast<size_t>(bit), true); }
178177
void setBitOff(DecayerBits bit) { mBits.set(static_cast<size_t>(bit), false); }
179178

180-
std::bitset<8> getBits() const { return mBits; }
179+
const std::bitset<8>& getBits() const { return mBits; }
181180
uint8_t getBitsValue() const { return static_cast<uint8_t>(mBits.to_ulong()); }
182181
void setBits(std::bitset<8> bits) { mBits = bits; }
183182

@@ -186,8 +185,6 @@ class OTFParticle
186185
int mCollisionId{-1};
187186
float mVx{}, mVy{}, mVz{}, mVt{};
188187
float mPx{}, mPy{}, mPz{}, mE{};
189-
bool mIsAlive{}, mIsFromMcParticles{false};
190-
bool mIsPrimary{};
191188

192189
int mStatusCode{};
193190
uint8_t mFlag{};

ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ struct OnTheFlyDecayer {
164164
for (auto& daughter : decayStack) {
165165
daughter.setIndicesMother(particlesInDataframe - indexOffset + i, particlesInDataframe - indexOffset + i);
166166
daughter.setCollisionId(particle.collisionId());
167+
daughter.setBitOn(o2::upgrade::DecayerBits::ProducedByDecayer);
167168
daughter.setBitOn(o2::upgrade::DecayerBits::IsAlive);
168169
daughter.setBitOff(o2::upgrade::DecayerBits::IsPrimary);
169170
daughter.setProductionTime(particle.vt() + trackTimeNS);

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,19 @@ struct OnTheFlyTracker {
587587
insertHist(histPath + "h2dBRPtResAbs", "h2dPtResAbs;Gen p_{T};#Delta p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
588588
}
589589

590+
if (doprocessDecayer) {
591+
insertHist(histPath + "h2dPrimaryPtRes", "h2dPrimaryPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
592+
insertHist(histPath + "h2dSecondaryPtRes", "h2dSecondaryPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
593+
insertHist(histPath + "h2dPrimaryElPtRes", "h2dPrimaryElPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
594+
insertHist(histPath + "h2dSecondaryElPtRes", "h2dSecondaryElPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
595+
insertHist(histPath + "h2dPrimaryPiPtRes", "h2dPrimaryPiPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
596+
insertHist(histPath + "h2dSecondaryPiPtRes", "h2dSecondaryPiPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
597+
insertHist(histPath + "h2dPrimaryKaPtRes", "h2dPrimaryKaPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
598+
insertHist(histPath + "h2dSecondaryKaPtRes", "h2dSecondaryKaPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
599+
insertHist(histPath + "h2dPrimaryPrPtRes", "h2dPrimaryPrPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
600+
insertHist(histPath + "h2dSecondaryPrPtRes", "h2dSecondaryPrPtRes;Gen p_{T};#Delta p_{T} / Reco p_{T}", {kTH2D, {{axes.axisMomentum, axes.axisPtRes}}});
601+
}
602+
590603
} // end config loop
591604

592605
// Basic QA
@@ -2043,6 +2056,7 @@ struct OnTheFlyTracker {
20432056
const bool pdgsToBeHandled = longLivedToBeHandled || (enableNucleiSmearing && nucleiToBeHandled);
20442057

20452058
o2::upgrade::OTFParticle otfParticle(mcParticle);
2059+
otfParticle.setBits(mcParticle.decayerBits_raw());
20462060
if (otfParticle.hasNaN()) {
20472061
continue;
20482062
}
@@ -2080,17 +2094,16 @@ struct OnTheFlyTracker {
20802094

20812095
multiplicityCounter++;
20822096
o2::track::TrackParCov trackParCov;
2083-
const bool isDecayDaughter = (mcParticle.getProcess() == TMCProcess::kPDecay);
20842097
const float time = (eventCollisionTimeNS + gRandom->Gaus(0., timeResolutionNs)) * nsToMus;
20852098

20862099
bool reconstructed = false;
20872100
int nTrkHits = 0;
2088-
if (enablePrimarySmearing && otfParticle.checkBit(o2::upgrade::DecayerBits::IsPrimary)) {
2101+
const bool isSecondary = !otfParticle.isPrimary() && otfParticle.checkBit(o2::upgrade::DecayerBits::ProducedByDecayer) && otfParticle.isAlive();
2102+
if (enablePrimarySmearing && otfParticle.isPrimary()) {
20892103
o2::upgrade::convertMCParticleToO2Track(mcParticle, trackParCov, pdgDB);
20902104
computeBremsstrahlungLoss(icfg, mcParticle, trackParCov);
20912105
reconstructed = mSmearer[icfg]->smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta);
2092-
nTrkHits = fastTrackerSettings.minSiliconHits;
2093-
} else if (enableSecondarySmearing && !otfParticle.checkBit(o2::upgrade::DecayerBits::IsPrimary) && otfParticle.checkBit(o2::upgrade::DecayerBits::ProducedByDecayer) && otfParticle.checkBit(o2::upgrade::DecayerBits::IsAlive)) {
2106+
} else if (enableSecondarySmearing && isSecondary) {
20942107
o2::track::TrackParCov perfectTrackParCov;
20952108
o2::upgrade::convertMCParticleToO2Track(mcParticle, perfectTrackParCov, pdgDB);
20962109
computeBremsstrahlungLoss(icfg, mcParticle, perfectTrackParCov);
@@ -2114,21 +2127,52 @@ struct OnTheFlyTracker {
21142127

21152128
histos.fill(HIST("hNaNBookkeeping"), 0.0f, 1.0f);
21162129
if (enablePrimarySmearing) {
2130+
const float ptResolution = (trackParCov.getPt() - mcParticle.pt()) / trackParCov.getPt();
21172131
getHist(TH1, histPath + "hPtReconstructed")->Fill(trackParCov.getPt());
2118-
if (std::abs(mcParticle.pdgCode()) == kElectron)
2132+
if (otfParticle.isPrimary()) {
2133+
getHist(TH2, histPath + "h2dPrimaryPtRes")->Fill(trackParCov.getPt(), ptResolution);
2134+
} else {
2135+
getHist(TH2, histPath + "h2dSecondaryPtRes")->Fill(trackParCov.getPt(), ptResolution);
2136+
}
2137+
if (std::abs(mcParticle.pdgCode()) == kElectron) {
21192138
getHist(TH1, histPath + "hPtReconstructedEl")->Fill(trackParCov.getPt());
2120-
if (std::abs(mcParticle.pdgCode()) == kPiPlus)
2139+
if (otfParticle.isPrimary()) {
2140+
getHist(TH2, histPath + "h2dPrimaryElPtRes")->Fill(trackParCov.getPt(), ptResolution);
2141+
} else {
2142+
getHist(TH2, histPath + "h2dSecondaryElPtRes")->Fill(trackParCov.getPt(), ptResolution);
2143+
}
2144+
}
2145+
if (std::abs(mcParticle.pdgCode()) == kPiPlus) {
21212146
getHist(TH1, histPath + "hPtReconstructedPi")->Fill(trackParCov.getPt());
2122-
if (std::abs(mcParticle.pdgCode()) == kKPlus)
2147+
if (otfParticle.isPrimary()) {
2148+
getHist(TH2, histPath + "h2dPrimaryPiPtRes")->Fill(trackParCov.getPt(), ptResolution);
2149+
} else {
2150+
getHist(TH2, histPath + "h2dSecondaryPiPtRes")->Fill(trackParCov.getPt(), ptResolution);
2151+
}
2152+
}
2153+
if (std::abs(mcParticle.pdgCode()) == kKPlus) {
21232154
getHist(TH1, histPath + "hPtReconstructedKa")->Fill(trackParCov.getPt());
2124-
if (std::abs(mcParticle.pdgCode()) == kProton)
2155+
if (otfParticle.isPrimary()) {
2156+
getHist(TH2, histPath + "h2dPrimaryKaPtRes")->Fill(trackParCov.getPt(), ptResolution);
2157+
} else {
2158+
getHist(TH2, histPath + "h2dSecondaryKaPtRes")->Fill(trackParCov.getPt(), ptResolution);
2159+
}
2160+
}
2161+
if (std::abs(mcParticle.pdgCode()) == kProton) {
21252162
getHist(TH1, histPath + "hPtReconstructedPr")->Fill(trackParCov.getPt());
2163+
if (otfParticle.isPrimary()) {
2164+
getHist(TH2, histPath + "h2dPrimaryPrPtRes")->Fill(trackParCov.getPt(), ptResolution);
2165+
} else {
2166+
getHist(TH2, histPath + "h2dSecondaryPrPtRes")->Fill(trackParCov.getPt(), ptResolution);
2167+
}
2168+
}
21262169
}
21272170

21282171
if (reconstructed) {
2129-
tracksAlice3.push_back(TrackAlice3{trackParCov, mcParticle.globalIndex(), time, timeResolutionUs, isDecayDaughter, false, 0, nTrkHits, kRecoPrimary});
2172+
tracksAlice3.push_back(TrackAlice3{trackParCov, mcParticle.globalIndex(), time, timeResolutionUs, isSecondary, false, 0, nTrkHits, kRecoPrimary});
2173+
getHist(TH1, histPath + "hPtReconstructedPr")->Fill(trackParCov.getPt());
21302174
} else {
2131-
ghostTracksAlice3.push_back(TrackAlice3{trackParCov, mcParticle.globalIndex(), time, timeResolutionUs, isDecayDaughter, false, 0, nTrkHits, kGhostPrimary});
2175+
ghostTracksAlice3.push_back(TrackAlice3{trackParCov, mcParticle.globalIndex(), time, timeResolutionUs, isSecondary, false, 0, nTrkHits, kGhostPrimary});
21322176
}
21332177
}
21342178

0 commit comments

Comments
 (0)