Skip to content

Commit 0f8077f

Browse files
committed
Add protection to TPC tune on data for filtered MC productions
1 parent ab304ff commit 0f8077f

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

Common/Tools/PID/pidTPCModule.h

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -744,39 +744,44 @@ class pidTPCModule
744744
// if this is a MC process function, go for MC tune on data processing
745745
if constexpr (requires { trk.mcParticleId(); }) {
746746
// Perform TuneOnData sampling for MC dE/dx
747-
float mcTunedTPCSignal = 0.;
748-
if (!trk.hasTPC()) {
749-
mcTunedTPCSignal = -999.f;
747+
if (!trk.has_mcParticle()) {
748+
products.tableTuneOnData(-999.f);
749+
tpcSignalToEvaluatePID = -999.f; // pass this for further eval
750750
} else {
751-
if (pidTPCopts.skipTPCOnly) {
752-
if (!trk.hasITS() && !trk.hasTRD() && !trk.hasTOF()) {
753-
mcTunedTPCSignal = -999.f;
754-
}
755-
}
756-
int pid = getPIDIndex(trk.mcParticle().pdgCode());
757-
758-
auto expSignal = response->GetExpectedSignal(trk, pid);
759-
auto expSigma = response->GetExpectedSigmaAtMultiplicity(multTPC, trk, pid);
760-
if (expSignal < 0. || expSigma < 0.) { // if expectation invalid then give undefined signal
751+
float mcTunedTPCSignal = 0.;
752+
if (!trk.hasTPC()) {
761753
mcTunedTPCSignal = -999.f;
762-
}
763-
float bg = trk.tpcInnerParam() / o2::track::pid_constants::sMasses[pid]; // estimated beta-gamma for network cutoff
754+
} else {
755+
if (pidTPCopts.skipTPCOnly) {
756+
if (!trk.hasITS() && !trk.hasTRD() && !trk.hasTOF()) {
757+
mcTunedTPCSignal = -999.f;
758+
}
759+
}
760+
int pid = getPIDIndex(trk.mcParticle().pdgCode());
764761

765-
if (pidTPCopts.useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision() && bg > pidTPCopts.networkBetaGammaCutoff) {
766-
auto mean = network_prediction[2 * (count_tracks + tracksForNet_size * pid)] * expSignal; // Absolute mean, i.e. the mean dE/dx value of the data in that slice, not the mean of the NSigma distribution
767-
auto sigma = (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) * expSignal;
768-
if (mean < 0.f || sigma < 0.f) {
762+
auto expSignal = response->GetExpectedSignal(trk, pid);
763+
auto expSigma = response->GetExpectedSigmaAtMultiplicity(multTPC, trk, pid);
764+
if (expSignal < 0. || expSigma < 0.) { // if expectation invalid then give undefined signal
769765
mcTunedTPCSignal = -999.f;
766+
}
767+
float bg = trk.tpcInnerParam() / o2::track::pid_constants::sMasses[pid]; // estimated beta-gamma for network cutoff
768+
769+
if (pidTPCopts.useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision() && bg > pidTPCopts.networkBetaGammaCutoff) {
770+
auto mean = network_prediction[2 * (count_tracks + tracksForNet_size * pid)] * expSignal; // Absolute mean, i.e. the mean dE/dx value of the data in that slice, not the mean of the NSigma distribution
771+
auto sigma = (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) * expSignal;
772+
if (mean < 0.f || sigma < 0.f) {
773+
mcTunedTPCSignal = -999.f;
774+
} else {
775+
mcTunedTPCSignal = gRandom->Gaus(mean, sigma);
776+
}
770777
} else {
771-
mcTunedTPCSignal = gRandom->Gaus(mean, sigma);
778+
mcTunedTPCSignal = gRandom->Gaus(expSignal, expSigma);
772779
}
773-
} else {
774-
mcTunedTPCSignal = gRandom->Gaus(expSignal, expSigma);
775780
}
781+
tpcSignalToEvaluatePID = mcTunedTPCSignal; // pass this for further eval
782+
if (pidTPCopts.enableTuneOnDataTable)
783+
products.tableTuneOnData(mcTunedTPCSignal);
776784
}
777-
tpcSignalToEvaluatePID = mcTunedTPCSignal; // pass this for further eval
778-
if (pidTPCopts.enableTuneOnDataTable)
779-
products.tableTuneOnData(mcTunedTPCSignal);
780785
}
781786

782787
auto makePidTablesDefault = [&trk, &tpcSignalToEvaluatePID, &multTPC, &network_prediction, &count_tracks, &tracksForNet_size, this](const int flagFull, auto& tableFull, const int flagTiny, auto& tableTiny, const o2::track::PID::ID pid) {

0 commit comments

Comments
 (0)