4242#include < Framework/HistogramSpec.h>
4343#include < Framework/InitContext.h>
4444#include < Framework/O2DatabasePDGPlugin.h>
45+ #include < Framework/ProcessingContext.h>
4546#include < Framework/runDataProcessing.h>
4647#include < ReconstructionDataFormats/DCA.h>
4748#include < ReconstructionDataFormats/Track.h>
@@ -110,6 +111,8 @@ struct NPCascCandidate {
110111 float pionDCAz;
111112 float bachDCAxy;
112113 float bachDCAz;
114+ float cascDCADaughters;
115+ float v0DCADaughters;
113116 float casccosPA;
114117 float v0cosPA;
115118 double massXi;
@@ -233,6 +236,7 @@ struct NonPromptCascadeTask {
233236 Configurable<float > cfgMaxMult{" cfgMaxMult" , 8000 .f , " Upper range of multiplicty histo" };
234237 Configurable<float > cfgMaxMultFV0{" cfgMaxMultFV0" , 10000 .f , " Upper range of multiplicty FV0 histo" };
235238 Configurable<std::string> cfgPtEdgesdNdeta{" ptEdges" , " 0,0.2,0.4,0.6,0.8,1,1.2,1.6,2.0,2.4,2.8,3.2,3.6,4,4.5,5,5.5,6,7,8,10" , " Pt bin edges (comma-separated)" };
239+ Configurable<int > cfgDownscaleCascTF{" cfgDownscaleCascTF" , 1 , " Keep one in every N input timeframes for cascade reco and generator output (1 keeps all)" };
236240 Configurable<int > cfgDownscaleMB{" cfgDownscaleMB" , 1 , " Downscaling for pile up study sample" };
237241 Configurable<double > cfgEtaCutdNdeta{" cfgEtaCutdNdeta" , 0.8 , " Eta cut for charged tracks" };
238242
@@ -241,6 +245,8 @@ struct NonPromptCascadeTask {
241245 SliceCache cache;
242246
243247 Service<o2::ccdb::BasicCCDBManager> mCCDB ;
248+ uint64_t mTimeframeCount = 0 ;
249+ bool mKeepTimeframe = true ;
244250 int mRunNumber = 0 ;
245251 float mBz = 0 .f;
246252 o2::vertexing::DCAFitterN<2 > mDCAFitter ;
@@ -272,8 +278,21 @@ struct NonPromptCascadeTask {
272278 }
273279 }
274280
281+ // The framework calls run once before all enabled process functions for a timeframe.
282+ void run (ProcessingContext&)
283+ {
284+ mKeepTimeframe = (mTimeframeCount ++ % static_cast <uint64_t >(cfgDownscaleCascTF.value )) == 0 ;
285+ mRegistry .fill (HIST (" hTimeframeSelection" ), mKeepTimeframe ? 1 .f : 0 .f );
286+ }
287+
275288 void init (InitContext& context)
276289 {
290+ if (cfgDownscaleCascTF.value < 1 ) {
291+ LOG (fatal) << " cfgDownscaleCascTF must be at least 1" ;
292+ }
293+ auto timeframeSelection = mRegistry .add <TH1 >(" hTimeframeSelection" , " ;Timeframe selection;Timeframes" , HistType::kTH1D , {{2 , -0.5 , 1.5 }});
294+ timeframeSelection->GetXaxis ()->SetBinLabel (1 , " Skipped" );
295+ timeframeSelection->GetXaxis ()->SetBinLabel (2 , " Kept" );
277296 mZorroSummary .setObject (mZorro .getZorroSummary ());
278297 mCCDB ->setURL (ccdbUrl);
279298 mCCDB ->setFatalWhenNull (true );
@@ -529,11 +548,14 @@ struct NonPromptCascadeTask {
529548 o2::math_utils::SVector<double , 3 > cascadePos, v0Pos;
530549
531550 float cascCpa = -1 , v0Cpa = -1 ;
551+ float cascDCADaughters = -1 .f , v0DCADaughters = -1 .f ;
532552 o2::track::TrackParCov ntCascadeTrack;
533553 if (mDCAFitter .process (pionTrkParCov, protonTrkParCov)) {
554+ v0DCADaughters = std::sqrt (mDCAFitter .getChi2AtPCACandidate ());
534555 auto trackParCovV0 = mDCAFitter .createParentTrackParCov (0 ); // V0 track retrieved from p and pi daughters
535556 v0Pos = mDCAFitter .getPCACandidate ();
536557 if (mDCAFitter .process (trackParCovV0, bachTrkParCov)) {
558+ cascDCADaughters = std::sqrt (mDCAFitter .getChi2AtPCACandidate ());
537559 mDCAFitter .getTrackParamAtPCA (0 ).getPxPyPzGlo (momenta[0 ]);
538560 mDCAFitter .getTrackParamAtPCA (1 ).getPxPyPzGlo (momenta[1 ]);
539561 ntCascadeTrack = mDCAFitter .createParentTrackParCov ();
@@ -655,7 +677,7 @@ struct NonPromptCascadeTask {
655677 cascadeLvector.pt (), cascadeLvector.eta (), cascadeLvector.phi (),
656678 protonTrack.pt (), protonTrack.eta (), pionTrack.pt (), pionTrack.eta (), bachelor.pt (), bachelor.eta (),
657679 motherDCA.getY (), motherDCA.getZ (), protonDCA.getY (), protonDCA.getZ (), pionDCA.getY (), pionDCA.getZ (), bachDCA.getY (), bachDCA.getZ (),
658- cascCpa, v0Cpa, massXi, massOmega, v0mass,
680+ cascDCADaughters, v0DCADaughters, cascCpa, v0Cpa, massXi, massOmega, v0mass,
659681 static_cast <float >(std::hypot (cascadePos[0 ], cascadePos[1 ])), static_cast <float >(std::hypot (v0Pos[0 ], v0Pos[1 ])), static_cast <float >(std::hypot (cascadePos[0 ], cascadePos[1 ], cascadePos[2 ])), static_cast <float >(std::hypot (v0Pos[0 ], v0Pos[1 ], v0Pos[2 ])),
660682 cascITSclusters, protonTrack.itsNCls (), pionTrack.itsNCls (), bachelor.itsNCls (), protonTrack.tpcNClsFound (), pionTrack.tpcNClsFound (), bachelor.tpcNClsFound (),
661683 protonTrack.tpcNSigmaPr (), pionTrack.tpcNSigmaPi (), bachelor.tpcNSigmaKa (), bachelor.tpcNSigmaPi (),
@@ -673,7 +695,7 @@ struct NonPromptCascadeTask {
673695 c.cascPt , c.cascEta , c.cascPhi ,
674696 c.protonPt , c.protonEta , c.pionPt , c.pionEta , c.bachPt , c.bachEta ,
675697 c.cascDCAxy , c.cascDCAz , c.protonDCAxy , c.protonDCAz , c.pionDCAxy , c.pionDCAz , c.bachDCAxy , c.bachDCAz ,
676- c.casccosPA , c.v0cosPA ,
698+ c.cascDCADaughters , c. v0DCADaughters , c. casccosPA , c.v0cosPA ,
677699 c.massXi , c.massOmega , c.massV0 ,
678700 c.cascRadius , c.v0radius , c.cascLength , c.v0length ,
679701 c.cascNClusITS , c.protonNClusITS , c.pionNClusITS , c.bachNClusITS , c.protonNClusTPC , c.pionNClusTPC , c.bachNClusTPC ,
@@ -712,7 +734,7 @@ struct NonPromptCascadeTask {
712734 c.pvContributors , c.cascPVContribs , c.pvTimeResolution , c.pvX , c.pvY , c.pvZ , c.cascPt , c.cascEta , c.cascPhi ,
713735 c.protonPt , c.protonEta , c.pionPt , c.pionEta , c.bachPt , c.bachEta ,
714736 c.cascDCAxy , c.cascDCAz , c.protonDCAxy , c.protonDCAz , c.pionDCAxy , c.pionDCAz , c.bachDCAxy , c.bachDCAz ,
715- c.casccosPA , c.v0cosPA , c.massXi , c.massOmega , c.massV0 , c.cascRadius , c.v0radius , c.cascLength , c.v0length ,
737+ c.cascDCADaughters , c. v0DCADaughters , c. casccosPA , c.v0cosPA , c.massXi , c.massOmega , c.massV0 , c.cascRadius , c.v0radius , c.cascLength , c.v0length ,
716738 c.cascNClusITS , c.protonNClusITS , c.pionNClusITS , c.bachNClusITS , c.protonNClusTPC , c.pionNClusTPC , c.bachNClusTPC , c.protonTPCNSigma ,
717739 c.pionTPCNSigma , c.bachKaonTPCNSigma , c.bachPionTPCNSigma , c.protonHasTOF , c.pionHasTOF , c.bachHasTOF ,
718740 c.protonTOFNSigma , c.pionTOFNSigma , c.bachKaonTOFNSigma , c.bachPionTOFNSigma ,
@@ -748,6 +770,9 @@ struct NonPromptCascadeTask {
748770 aod::V0s const & /* v0s*/ , TracksExtMC const & tracks,
749771 aod::McParticles const & mcParticles, aod::McCollisions const &, aod::BCsWithTimestamps const &)
750772 {
773+ if (!mKeepTimeframe ) {
774+ return ;
775+ }
751776 fillCandidatesVector<TracksExtMC>(collisions, tracks, trackedCascades, gCandidates );
752777 fillMCtable<aod::AssignedTrackedCascades>(mcParticles, collisions, gCandidates );
753778 }
@@ -757,6 +782,9 @@ struct NonPromptCascadeTask {
757782 aod::V0s const & /* v0s*/ , TracksExtMC const & tracks,
758783 aod::McParticles const & mcParticles, aod::McCollisions const &, aod::BCsWithTimestamps const &)
759784 {
785+ if (!mKeepTimeframe ) {
786+ return ;
787+ }
760788 fillCandidatesVector<TracksExtMC>(collisions, tracks, cascades, gCandidatesNT );
761789 fillMCtable<aod::Cascades>(mcParticles, collisions, gCandidatesNT );
762790 // fillMultHistos<CollisionCandidatesRun3MC>(collisions);
@@ -765,6 +793,9 @@ struct NonPromptCascadeTask {
765793
766794 void processGenParticles (aod::McParticles const & mcParticles, aod::McCollisions const &)
767795 {
796+ if (!mKeepTimeframe ) {
797+ return ;
798+ }
768799 for (const auto & p : mcParticles) {
769800 auto absCode = std::abs (p.pdgCode ());
770801 if (absCode != 3312 && absCode != 3334 ) {
@@ -795,6 +826,9 @@ struct NonPromptCascadeTask {
795826 aod::V0s const & /* v0s*/ , TracksExtData const & tracks,
796827 aod::BCsWithTimestamps const &)
797828 {
829+ if (!mKeepTimeframe ) {
830+ return ;
831+ }
798832 mProcessCounter [0 ]++;
799833 zorroAccounting (collisions);
800834 fillCandidatesVector<TracksExtData>(collisions, tracks, trackedCascades, gCandidates );
@@ -806,6 +840,9 @@ struct NonPromptCascadeTask {
806840 aod::V0s const & /* v0s*/ , TracksExtData const & tracks,
807841 aod::BCsWithTimestamps const &)
808842 {
843+ if (!mKeepTimeframe ) {
844+ return ;
845+ }
809846 mProcessCounter [1 ]++;
810847 zorroAccounting (collisions);
811848 fillCandidatesVector<TracksExtData>(collisions, tracks, cascades, gCandidatesNT );
0 commit comments