1313// / \file mcPidTof.cxx
1414// / \author Fabrizio Grosa [email protected] 1515// / \brief Task to produce PID tables for TOF split for pi, K, p, copied from https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/PID/pidTOFFull.cxx
16- // / In addition, it applies postcalibrations for MC.
16+ // / It works only for MC and adds the possibility to apply postcalibrations for MC.
1717// /
1818
19+ #include < TPDGCode.h>
20+
1921// O2 includes
2022#include < CCDB/BasicCCDBManager.h>
2123#include " TOFBase/EventTimeMaker.h"
@@ -248,6 +250,10 @@ struct mcPidTof {
248250 template <typename T>
249251 T applyMcRecalib (int pidId, T trackPt, T nSigma)
250252 {
253+ if (nSigma < -998 ) {
254+ return nSigma;
255+ }
256+
251257 float shift{0 .f }, scaleWidth{0 .f };
252258 int nPoints = gMcPostCalibMean [pidId]->GetN ();
253259 double ptMin = gMcPostCalibMean [pidId]->GetX ()[0 ];
@@ -267,12 +273,12 @@ struct mcPidTof {
267273 return nSigmaCorr;
268274 }
269275
270- using Trks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TOFSignal, aod::TOFEvTime, aod::pidEvTimeFlags>;
276+ using Trks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TOFSignal, aod::TOFEvTime, aod::pidEvTimeFlags, aod::McTrackLabels >;
271277 // Define slice per collision
272278 Preslice<Trks> perCollision = aod::track::collisionId;
273279 template <o2::track::PID::ID pid>
274280 using ResponseImplementation = o2::pid::tof::ExpTimes<Trks::iterator, pid>;
275- void processWSlice (Trks const & tracks, aod::Collisions const &, aod::BCsWithTimestamps const &)
281+ void processWSlice (Trks const & tracks, aod::Collisions const &, aod::BCsWithTimestamps const &, aod::McParticles const & )
276282 {
277283 constexpr auto responsePi = ResponseImplementation<PID::Pion>();
278284 constexpr auto responseKa = ResponseImplementation<PID::Kaon>();
@@ -328,24 +334,30 @@ struct mcPidTof {
328334 case 2 :
329335 resolution = responsePi.GetExpectedSigma (mRespParamsV2 , trkInColl);
330336 nSigma = responsePi.GetSeparation (mRespParamsV2 , trkInColl, resolution);
331- if (mcRecalib.enable ) {
332- nSigma = applyMcRecalib (pidId, trkInColl.pt (), nSigma);
337+ if (mcRecalib.enable && trkInColl.has_mcParticle ()) {
338+ if (std::abs (trkInColl.mcParticle ().pdgCode ()) == kPiPlus ) { // we rescale only true signal
339+ nSigma = applyMcRecalib (pidId, trkInColl.pt (), nSigma);
340+ }
333341 }
334342 tablePIDPi (resolution, nSigma);
335343 break ;
336344 case 3 :
337345 resolution = responseKa.GetExpectedSigma (mRespParamsV2 , trkInColl);
338346 nSigma = responseKa.GetSeparation (mRespParamsV2 , trkInColl, resolution);
339- if (mcRecalib.enable ) {
340- nSigma = applyMcRecalib (pidId, trkInColl.pt (), nSigma);
347+ if (mcRecalib.enable && trkInColl.has_mcParticle ()) {
348+ if (std::abs (trkInColl.mcParticle ().pdgCode ()) == kKPlus ) { // we rescale only true signal
349+ nSigma = applyMcRecalib (pidId, trkInColl.pt (), nSigma);
350+ }
341351 }
342352 tablePIDKa (resolution, nSigma);
343353 break ;
344354 case 4 :
345355 resolution = responsePr.GetExpectedSigma (mRespParamsV2 , trkInColl);
346356 nSigma = responsePr.GetSeparation (mRespParamsV2 , trkInColl, resolution);
347- if (mcRecalib.enable ) {
348- nSigma = applyMcRecalib (pidId, trkInColl.pt (), nSigma);
357+ if (mcRecalib.enable && trkInColl.has_mcParticle ()) {
358+ if (std::abs (trkInColl.mcParticle ().pdgCode ()) == kProton ) { // we rescale only true signal
359+ nSigma = applyMcRecalib (pidId, trkInColl.pt (), nSigma);
360+ }
349361 }
350362 tablePIDPr (resolution, nSigma);
351363 break ;
@@ -359,10 +371,10 @@ struct mcPidTof {
359371 }
360372 PROCESS_SWITCH (mcPidTof, processWSlice, " Process with track slices" , true );
361373
362- using TrksIU = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TOFSignal, aod::TOFEvTime, aod::pidEvTimeFlags>;
374+ using TrksIU = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TOFSignal, aod::TOFEvTime, aod::pidEvTimeFlags, aod::McTrackLabels >;
363375 template <o2::track::PID::ID pid>
364376 using ResponseImplementationIU = o2::pid::tof::ExpTimes<TrksIU::iterator, pid>;
365- void processWoSlice (TrksIU const & tracks, aod::Collisions const &, aod::BCsWithTimestamps const &)
377+ void processWoSlice (TrksIU const & tracks, aod::Collisions const &, aod::BCsWithTimestamps const &, aod::McParticles const & )
366378 {
367379 constexpr auto responsePi = ResponseImplementationIU<PID::Pion>();
368380 constexpr auto responseKa = ResponseImplementationIU<PID::Kaon>();
@@ -409,24 +421,30 @@ struct mcPidTof {
409421 case 2 :
410422 resolution = responsePi.GetExpectedSigma (mRespParamsV2 , track);
411423 nSigma = responsePi.GetSeparation (mRespParamsV2 , track, resolution);
412- if (mcRecalib.enable ) {
413- nSigma = applyMcRecalib (pidId, track.pt (), nSigma);
424+ if (mcRecalib.enable && track.has_mcParticle ()) {
425+ if (std::abs (track.mcParticle ().pdgCode ()) == kPiPlus ) { // we rescale only true signal
426+ nSigma = applyMcRecalib (pidId, track.pt (), nSigma);
427+ }
414428 }
415429 tablePIDPi (resolution, nSigma);
416430 break ;
417431 case 3 :
418432 resolution = responseKa.GetExpectedSigma (mRespParamsV2 , track);
419433 nSigma = responseKa.GetSeparation (mRespParamsV2 , track, resolution);
420- if (mcRecalib.enable ) {
421- nSigma = applyMcRecalib (pidId, track.pt (), nSigma);
434+ if (mcRecalib.enable && track.has_mcParticle ()) {
435+ if (std::abs (track.mcParticle ().pdgCode ()) == kKPlus ) { // we rescale only true signal
436+ nSigma = applyMcRecalib (pidId, track.pt (), nSigma);
437+ }
422438 }
423439 tablePIDKa (resolution, nSigma);
424440 break ;
425441 case 4 :
426442 resolution = responsePr.GetExpectedSigma (mRespParamsV2 , track);
427443 nSigma = responsePr.GetSeparation (mRespParamsV2 , track, resolution);
428- if (mcRecalib.enable ) {
429- nSigma = applyMcRecalib (pidId, track.pt (), nSigma);
444+ if (mcRecalib.enable && track.has_mcParticle ()) {
445+ if (std::abs (track.mcParticle ().pdgCode ()) == kProton ) { // we rescale only true signal
446+ nSigma = applyMcRecalib (pidId, track.pt (), nSigma);
447+ }
430448 }
431449 tablePIDPr (resolution, nSigma);
432450 break ;
0 commit comments