@@ -810,39 +810,44 @@ class pidTPCModule
810810 // if this is a MC process function, go for MC tune on data processing
811811 if constexpr (requires { trk.mcParticleId (); }) {
812812 // Perform TuneOnData sampling for MC dE/dx
813- float mcTunedTPCSignal = 0 .;
814- if (!trk. hasTPC ()) {
815- mcTunedTPCSignal = -999 .f ;
813+ if (!trk. has_mcParticle ()) {
814+ products. tableTuneOnData (- 999 . f );
815+ tpcSignalToEvaluatePID = -999 .f ; // pass this for further eval
816816 } else {
817- if (pidTPCopts.skipTPCOnly ) {
818- if (!trk.hasITS () && !trk.hasTRD () && !trk.hasTOF ()) {
819- mcTunedTPCSignal = -999 .f ;
820- }
821- }
822- int pid = getPIDIndex (trk.mcParticle ().pdgCode ());
823-
824- auto expSignal = response->GetExpectedSignal (trk, pid);
825- auto expSigma = response->GetExpectedSigmaAtMultiplicity (multTPC, trk, pid);
826- if (expSignal < 0 . || expSigma < 0 .) { // if expectation invalid then give undefined signal
817+ float mcTunedTPCSignal = 0 .;
818+ if (!trk.hasTPC ()) {
827819 mcTunedTPCSignal = -999 .f ;
828- }
829- float bg = trk.tpcInnerParam () / o2::track::pid_constants::sMasses [pid]; // estimated beta-gamma for network cutoff
820+ } else {
821+ if (pidTPCopts.skipTPCOnly ) {
822+ if (!trk.hasITS () && !trk.hasTRD () && !trk.hasTOF ()) {
823+ mcTunedTPCSignal = -999 .f ;
824+ }
825+ }
826+ int pid = getPIDIndex (trk.mcParticle ().pdgCode ());
830827
831- if (pidTPCopts.useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision () && bg > pidTPCopts.networkBetaGammaCutoff ) {
832- 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
833- auto sigma = (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1 ] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) * expSignal;
834- if (mean < 0 .f || sigma < 0 .f ) {
828+ auto expSignal = response->GetExpectedSignal (trk, pid);
829+ auto expSigma = response->GetExpectedSigmaAtMultiplicity (multTPC, trk, pid);
830+ if (expSignal < 0 . || expSigma < 0 .) { // if expectation invalid then give undefined signal
835831 mcTunedTPCSignal = -999 .f ;
832+ }
833+ float bg = trk.tpcInnerParam () / o2::track::pid_constants::sMasses [pid]; // estimated beta-gamma for network cutoff
834+
835+ if (pidTPCopts.useNetworkCorrection && speciesNetworkFlags[pid] && trk.has_collision () && bg > pidTPCopts.networkBetaGammaCutoff ) {
836+ 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
837+ auto sigma = (network_prediction[2 * (count_tracks + tracksForNet_size * pid) + 1 ] - network_prediction[2 * (count_tracks + tracksForNet_size * pid)]) * expSignal;
838+ if (mean < 0 .f || sigma < 0 .f ) {
839+ mcTunedTPCSignal = -999 .f ;
840+ } else {
841+ mcTunedTPCSignal = gRandom ->Gaus (mean, sigma);
842+ }
836843 } else {
837- mcTunedTPCSignal = gRandom ->Gaus (mean, sigma );
844+ mcTunedTPCSignal = gRandom ->Gaus (expSignal, expSigma );
838845 }
839- } else {
840- mcTunedTPCSignal = gRandom ->Gaus (expSignal, expSigma);
841846 }
847+ tpcSignalToEvaluatePID = mcTunedTPCSignal; // pass this for further eval
848+ if (pidTPCopts.enableTuneOnDataTable )
849+ products.tableTuneOnData (mcTunedTPCSignal);
842850 }
843- tpcSignalToEvaluatePID = mcTunedTPCSignal; // pass this for further eval
844- if (pidTPCopts.enableTuneOnDataTable )
845- products.tableTuneOnData (mcTunedTPCSignal);
846851 }
847852
848853 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