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
19 changes: 18 additions & 1 deletion ALICE3/Core/FlatTrackSmearer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, cons
return false;
}

// Keep the MC parameters in case smearing fails
const O2Track mcTrack = o2track;

// Transform params vector and smear
EigenArrayDouble params;
for (int i = 0; i < kNumEigenModes; ++i) {
Expand Down Expand Up @@ -349,6 +352,20 @@ bool TrackSmearer::smearTrack(O2Track& o2track, const lutEntry_t* lutEntry, cons
o2track.setCov(lutEntry->covm[i], i);
}

// If requested, fall back to the MC parameters (keeping the LUT covariance) when smearing gives NaN
if (mAllowSmearingFailures) {
bool hasNaN = false;
for (int i = 0; i < kNumEigenModes; ++i) {
hasNaN = hasNaN || std::isnan(o2track.getParam(i));
}
if (hasNaN) {
LOG(debug) << "smearTrack gave NaN parameters, keeping MC parameters";
for (int i = 0; i < kNumEigenModes; ++i) {
o2track.setParam(mcTrack.getParam(i), i);
}
}
}

return isReconstructed;
}

Expand All @@ -367,7 +384,7 @@ bool TrackSmearer::smearTrack(O2Track& o2track, const int pdg, const float nch)
const lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0.f, eta, pt, interpolatedEff);

if (!lutEntry || !lutEntry->valid) {
return false;
return mAllowSmearingFailures; // if allowed, keep the track with MC parameters
}

return smearTrack(o2track, lutEntry, interpolatedEff);
Expand Down
2 changes: 2 additions & 0 deletions ALICE3/Core/FlatTrackSmearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TrackSmearer
void useEfficiency(bool val) { mUseEfficiency = val; }
void interpolateEfficiency(bool val) { mInterpolateEfficiency = val; }
void skipUnreconstructed(bool val) { mSkipUnreconstructed = val; }
void allowSmearingFailures(bool val) { mAllowSmearingFailures = val; }
enum EfficiencyType : uint8_t {
kWhatEfficiencyReco = 0,
kWhatEfficiencyRecoAndTOF = 1
Expand Down Expand Up @@ -73,6 +74,7 @@ class TrackSmearer
bool mUseEfficiency = true;
bool mInterpolateEfficiency = false;
bool mSkipUnreconstructed = true; // don't smear tracks that are not reco'ed
bool mAllowSmearingFailures = false; // keep MC parameters if there is no valid LUT entry or smearing gives NaN
EfficiencyType mWhatEfficiency = kWhatEfficiencyReco;

private:
Expand Down
10 changes: 8 additions & 2 deletions ALICE3/Core/SecondaryTrackSmearer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ bool SecondaryTrackSmearer::smearTrack(O2Track& track, const SecondaryLutEntry*
}
if (!entry || !entry->valid) {
LOG(debug) << "Cannot smear a track with a missing or invalid secondary LUT entry";
return false;
if (mAllowSmearingFailures && wasSmeared) {
*wasSmeared = true; // track is kept with MC parameters
}
return mAllowSmearingFailures;
}
const float selectedEfficiency = mInterpolateEfficiency ? interpolatedEff : efficiency(*entry);
if (mUseEfficiency && (!std::isfinite(selectedEfficiency) || selectedEfficiency < 0.f || selectedEfficiency > 1.f)) {
Expand All @@ -205,7 +208,10 @@ bool SecondaryTrackSmearer::smearTrack(O2Track& track, const SecondaryLutEntry*
!std::all_of(entry->eigvec.begin(), entry->eigvec.end(), finite) ||
!std::all_of(entry->eiginv.begin(), entry->eiginv.end(), finite)) {
LOG(error) << "Cannot smear a track with non-finite secondary LUT parameters";
return false;
if (mAllowSmearingFailures && wasSmeared) {
*wasSmeared = true; // track is kept with MC parameters
}
return mAllowSmearingFailures;
}
lutEntry_t flatEntry;
flatEntry.valid = entry->valid;
Expand Down
6 changes: 6 additions & 0 deletions ALICE3/Core/SecondaryTrackSmearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class SecondaryTrackSmearer
mSkipUnreconstructed = value;
mSmearer.skipUnreconstructed(value);
}
void allowSmearingFailures(bool value)
{
mAllowSmearingFailures = value;
mSmearer.allowSmearingFailures(value);
}
void setWhatEfficiency(EfficiencyType value);
void setCcdbManager(o2::ccdb::BasicCCDBManager* manager) { mCcdbManager = manager; }

Expand Down Expand Up @@ -79,6 +84,7 @@ class SecondaryTrackSmearer
bool mUseEfficiency = true;
bool mInterpolateEfficiency = false;
bool mSkipUnreconstructed = true;
bool mAllowSmearingFailures = false; // keep MC parameters if there is no valid LUT entry or smearing gives NaN
EfficiencyType mWhatEfficiency = kWhatEfficiencyReco;
};

Expand Down
5 changes: 5 additions & 0 deletions ALICE3/TableProducer/OTF/onTheFlyTracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ struct OnTheFlyTracker {
Configurable<bool> populateTrackSelection{"populateTrackSelection", false, "populate TrackSelection table (legacy)"};

Configurable<bool> processUnreconstructedTracks{"processUnreconstructedTracks", false, "process (smear) unreco-ed tracks"};
Configurable<bool> allowSmearingFailures{"allowSmearingFailures", false, "keep tracks with MC parameters if LUT smearing fails (no valid LUT entry or NaN); only the efficiency rejects tracks"};
Configurable<bool> doExtraQA{"doExtraQA", false, "do extra 2D QA plots"};
Configurable<bool> extraQAwithoutDecayDaughters{"extraQAwithoutDecayDaughters", false, "remove decay daughters from qa plots (yes/no)"};

Expand Down Expand Up @@ -487,6 +488,7 @@ struct OnTheFlyTracker {
smearer.setCcdbManager(ccdb.operator->());
smearer.interpolateEfficiency(interpolateLutEfficiencyVsNch.value);
smearer.skipUnreconstructed(!processUnreconstructedTracks.value);
smearer.allowSmearingFailures(allowSmearingFailures.value);
const std::map<std::string, int> species = {{"secondaryLutEl", kElectron},
{"secondaryLutMu", kMuonMinus},
{"secondaryLutPi", kPiPlus},
Expand Down Expand Up @@ -588,6 +590,9 @@ struct OnTheFlyTracker {
// smear un-reco'ed tracks if asked to do so
mSmearer[igeo]->skipUnreconstructed(!processUnreconstructedTracks.value);

// keep tracks with MC parameters if smearing fails, if asked to do so
mSmearer[igeo]->allowSmearingFailures(allowSmearingFailures.value);

insertHist(histPath + "hPtGenerated", "hPtGenerated;#it{p}_{T} (GeV/c);Counts", kTH1D, {{axes.axisMomentum}});
insertHist(histPath + "hPhiGenerated", "hPhiGenerated;#phi (rad);Counts", kTH1D, {{100, 0.0f, o2::constants::math::TwoPI, "#phi (rad)"}});

Expand Down
Loading