1717// / \author Tanu Gahlaut <tanu.gahlaut@cern.ch>
1818
1919#include " Common/CCDB/EventSelectionParams.h"
20+ #include " Common/Core/TrackSelection.h"
2021#include " Common/DataModel/Centrality.h"
2122#include " Common/DataModel/EventSelection.h"
2223#include " Common/DataModel/Multiplicity.h"
3031#include < Framework/AnalysisHelpers.h>
3132#include < Framework/AnalysisTask.h>
3233#include < Framework/Configurable.h>
34+ #include < Framework/DataTypes.h>
3335#include < Framework/HistogramRegistry.h>
3436#include < Framework/HistogramSpec.h>
3537#include < Framework/InitContext.h>
@@ -65,24 +67,31 @@ struct MeanPtFlucId {
6567 Configurable<float > cfgCutPtMax{" cfgCutPtMax" , 2.0 , " maximum pT" };
6668 Configurable<float > cfgCutPtMin{" cfgCutPtMin" , 0.2 , " minimum pT" };
6769 Configurable<float > cfgCutEta{" cfgCutEta" , 0.8 , " Eta cut" };
68- Configurable<float > cfgCutITSChi2NCl{" cfgCutITSChi2NCl" , 36.0 , " ITS Chi2/NCl cut" };
69- Configurable<float > cfgCutTPCChi2NCl{" cfgCutTPCChi2NCl" , 4.0 , " TPC Chi2/NCl cut" };
70- Configurable<float > cfgCutTPCNCls{" cfgCutTPCNCls" , 70.0 , " TPC NCls cut" };
7170 Configurable<float > cfgCutDCAxy{" cfgCutDCAxy" , 0.1 , " DCAxy cut" };
7271 Configurable<float > cfgCutDCAz{" cfgCutDCAz" , 0.2 , " DCAz cut" };
7372 Configurable<float > cfgDcaPtDepOffset{" cfgDcaPtDepOffset" , 0.004 , " Offset of the pT-dependent DCA cut (cm)" };
7473 Configurable<float > cfgDcaPtDepScale{" cfgDcaPtDepScale" , 0.013 , " 1/pT coefficient of the pT-dependent DCA cut (cm GeV/c)" };
75- Configurable<int > cfgCutNCrossedRowsTPC{" cfgCutNCrossedRowsTPC" , 70 , " Minimum number of crossed TPC rows" };
7674 Configurable<bool > cfgGlobalTrack{" cfgGlobalTrack" , true , " Require the standard global-track selection (includes its DCA cuts)" };
7775 Configurable<bool > cfgGlobalTrackWoDCA{" cfgGlobalTrackWoDCA" , false , " Require global-track quality without built-in DCA cuts; disable cfgGlobalTrack to use only this selection" };
78- Configurable<bool > cfgDcaXYPtDep{" cfgDcaXYPtDep" , true , " Apply the pT-dependent absolute DCAxy cut; takes precedence over cfgDcaXY" };
79- Configurable<bool > cfgNTPCCrossedRows{" cfgNTPCCrossedRows" , false , " Apply the minimum number of crossed TPC rows" };
80- Configurable<bool > cfgTPCChi2NCl{" cfgTPCChi2NCl" , false , " Chi2 per N_{TPC} Clusters Cut " };
81- Configurable<bool > cfgITSChi2NCl{" cfgITSChi2NCl" , false , " Chi2 per N_{ITS} Clusters Cut " };
8276 Configurable<bool > cfgDcaXY{" cfgDcaXY" , false , " DCA XY Cut " };
8377 Configurable<bool > cfgDcaZ{" cfgDcaZ" , false , " DCA Z Cut " };
78+ Configurable<bool > cfgDcaXYPtDep{" cfgDcaXYPtDep" , true , " Apply the pT-dependent absolute DCAxy cut; takes precedence over cfgDcaXY" };
8479 Configurable<bool > cfgDcaZPtDep{" cfgDcaZPtDep" , false , " DCA Z pT dependent Cut " };
8580 } trackCuts;
81+ struct : ConfigurableGroup {
82+ Configurable<bool > cfgUseCustomTrackSelection{" cfgUseCustomTrackSelection" , false , " Use custom Run 3 quality instead of global flags; shared acceptance and DCA cuts still apply" };
83+ Configurable<int > cfgCustomMinTPCClusters{" cfgCustomMinTPCClusters" , 0 , " Custom minimum TPC found clusters (global default: no additional minimum)" };
84+ Configurable<int > cfgCustomMinTPCCrossedRows{" cfgCustomMinTPCCrossedRows" , 70 , " Custom minimum TPC crossed rows" };
85+ Configurable<float > cfgCustomMinTPCCrossedRowsOverFindable{" cfgCustomMinTPCCrossedRowsOverFindable" , 0 .8f , " Custom minimum crossed rows / findable TPC clusters" };
86+ Configurable<float > cfgCustomMaxTPCChi2{" cfgCustomMaxTPCChi2" , 4 .f , " Custom maximum TPC chi2 per cluster" };
87+ Configurable<int > cfgCustomMinITSClusters{" cfgCustomMinITSClusters" , 0 , " Custom minimum ITS clusters, in addition to the selected hit pattern" };
88+ Configurable<float > cfgCustomMaxITSChi2{" cfgCustomMaxITSChi2" , 36 .f , " Custom maximum ITS chi2 per cluster" };
89+ Configurable<int > cfgCustomITSMatching{" cfgCustomITSMatching" , 1 , " Custom ITS hits: 1=any inner 3, 2=any of 7, 3=all 7, 4=first layer, 5=at least 2 inner" };
90+ Configurable<bool > cfgCustomRequireITS{" cfgCustomRequireITS" , true , " Require ITS information (Run 3 ITS-refit criterion)" };
91+ Configurable<bool > cfgCustomRequireTPC{" cfgCustomRequireTPC" , true , " Require TPC information (Run 3 TPC-refit criterion)" };
92+ } customTrackCuts;
93+
94+ TrackSelection mySelection;
8695 struct : ConfigurableGroup {
8796 Configurable<float > cfgCutPosZ{" cfgCutPosZ" , 7.0 , " cut for vertex Z" };
8897 Configurable<float > cfgP0U{" cfgP0U" , 6.36269 , " p_{0} for upper cut for N_{TPC} vs N{sim}" };
@@ -281,8 +290,67 @@ struct MeanPtFlucId {
281290 std::vector<double > matrixWInBin;
282291 std::vector<double > matrixW2InBin;
283292
293+ // Run 3 global quality baseline, with each systematic threshold set explicitly.
294+ TrackSelection myTrackSelection ()
295+ {
296+ constexpr int MinITSMatchingMode = 1 ;
297+ constexpr int MaxITSMatchingMode = 5 ;
298+ constexpr int NumberOfITSLayers = 7 ;
299+ const auto & cuts = customTrackCuts;
300+ auto finiteNonnegative = [](float value) { return std::isfinite (value) && value >= 0 .f ; };
301+ if (cuts.cfgCustomITSMatching .value < MinITSMatchingMode || cuts.cfgCustomITSMatching .value > MaxITSMatchingMode ||
302+ cuts.cfgCustomMinTPCClusters .value < 0 || cuts.cfgCustomMinTPCCrossedRows .value < 0 ||
303+ cuts.cfgCustomMinITSClusters .value < 0 || cuts.cfgCustomMinITSClusters .value > NumberOfITSLayers ||
304+ !finiteNonnegative (cuts.cfgCustomMinTPCCrossedRowsOverFindable .value ) ||
305+ !finiteNonnegative (cuts.cfgCustomMaxTPCChi2 .value ) || !finiteNonnegative (cuts.cfgCustomMaxITSChi2 .value )) {
306+ LOGF (fatal, " Invalid custom track-selection settings: check hit counts, ITS matching and nonnegative finite thresholds" );
307+ }
308+ if (!std::isfinite (trackCuts.cfgCutPtMin .value ) || !std::isfinite (trackCuts.cfgCutPtMax .value ) ||
309+ !std::isfinite (trackCuts.cfgCutEta .value ) || trackCuts.cfgCutPtMin .value <= 0 .f ||
310+ trackCuts.cfgCutPtMin .value >= trackCuts.cfgCutPtMax .value || trackCuts.cfgCutEta .value <= 0 .f ) {
311+ LOGF (fatal, " Custom selection requires finite 0 < pTmin < pTmax and etaMax > 0" );
312+ }
313+ TrackSelection selectedTracks;
314+ selectedTracks.SetTrackType (aod::track::TrackTypeEnum::Track); // Run 3 propagated tracks
315+ // Run 3 ITS layers: no Run 2 SPD requirement.
316+ switch (cuts.cfgCustomITSMatching .value ) {
317+ case 1 :
318+ selectedTracks.SetRequireHitsInITSLayers (1 , {0 , 1 , 2 });
319+ break ;
320+ case 2 :
321+ selectedTracks.SetRequireHitsInITSLayers (1 , {0 , 1 , 2 , 3 , 4 , 5 , 6 });
322+ break ;
323+ case 3 :
324+ selectedTracks.SetRequireHitsInITSLayers (7 , {0 , 1 , 2 , 3 , 4 , 5 , 6 });
325+ break ;
326+ case 4 :
327+ selectedTracks.SetRequireHitsInITSLayers (1 , {0 });
328+ break ;
329+ case 5 :
330+ selectedTracks.SetRequireHitsInITSLayers (2 , {0 , 1 , 2 });
331+ break ;
332+ default :
333+ LOGF (fatal, " Invalid custom ITS matching mode: %d" , cuts.cfgCustomITSMatching .value );
334+ break ;
335+ }
336+ selectedTracks.SetRequireITSRefit (cuts.cfgCustomRequireITS .value );
337+ selectedTracks.SetRequireTPCRefit (cuts.cfgCustomRequireTPC .value );
338+ selectedTracks.SetMinNClustersTPC (cuts.cfgCustomMinTPCClusters .value );
339+ selectedTracks.SetMinNCrossedRowsTPC (cuts.cfgCustomMinTPCCrossedRows .value );
340+ selectedTracks.SetMinNCrossedRowsOverFindableClustersTPC (cuts.cfgCustomMinTPCCrossedRowsOverFindable .value );
341+ selectedTracks.SetMaxChi2PerClusterTPC (cuts.cfgCustomMaxTPCChi2 .value );
342+ selectedTracks.SetMinNClustersITS (cuts.cfgCustomMinITSClusters .value );
343+ selectedTracks.SetMaxChi2PerClusterITS (cuts.cfgCustomMaxITSChi2 .value );
344+ return selectedTracks;
345+ }
346+
284347 void init (InitContext const &)
285348 {
349+ if (customTrackCuts.cfgUseCustomTrackSelection ) {
350+ mySelection = myTrackSelection ();
351+ LOGF (info, " Custom Run 3 quality replaces global flags; pT, eta and DCA cuts are applied in selTrack" );
352+ mySelection.print ();
353+ }
286354 if (!std::isfinite (pidConfig.cfgTofShiftPi .value ) || !std::isfinite (pidConfig.cfgTofShiftKa .value ) || !std::isfinite (pidConfig.cfgTofShiftPr .value )) {
287355 LOGF (fatal, " TOF nSigma shifts must be finite: pion=%g, kaon=%g, proton=%g" ,
288356 pidConfig.cfgTofShiftPi .value , pidConfig.cfgTofShiftKa .value , pidConfig.cfgTofShiftPr .value );
@@ -364,7 +432,7 @@ struct MeanPtFlucId {
364432 const AxisSpec axisMultMC{multMCBins, " N_{Gen} " };
365433 const AxisSpec axisMultFT0M{multFT0MBins, " N_{FT0M}" };
366434 // Match the estimator precedence used by getConfiguredCentrality().
367- const std::string centralityLabel = eventCuts.cfgCentFT0C ? " FT0C (%)" : (eventCuts.cfgCentFV0A ? " FV0A (%)" : " FT0M (%)" );
435+ const std::string centralityLabel = eventCuts.cfgCentFT0C ? std::string{ " FT0C (%)" } : (eventCuts.cfgCentFV0A ? std::string{ " FV0A (%)" } : std::string{ " FT0M (%)" } );
368436 const AxisSpec axisCentFT0M{101 , 0 , 101 , centralityLabel};
369437 const AxisSpec axisCent{centBins, centralityLabel};
370438 const AxisSpec axisVtxZ{80 , -20 ., 20 ., " V_{Z} (cm)" };
@@ -611,7 +679,7 @@ struct MeanPtFlucId {
611679 if (genConfig.cfgGenCutPosZ && (!std::isfinite (genConfig.cfgGenMaxPosZ .value ) || genConfig.cfgGenMaxPosZ <= 0 .f )) {
612680 LOGF (fatal, " cfgGenMaxPosZ must be finite and positive" );
613681 }
614- const std::string estimator = eventCuts.cfgCentFT0C ? " FT0C" : (eventCuts.cfgCentFV0A ? " FV0A" : " FT0M" );
682+ const std::string estimator = eventCuts.cfgCentFT0C ? std::string{ " FT0C" } : (eventCuts.cfgCentFV0A ? std::string{ " FV0A" } : std::string{ " FT0M" } );
615683 constexpr size_t MinimumCentralityLookupEntries = 2 ;
616684 constexpr double MinimumCentralityPercentile = 0 .;
617685 constexpr double MaximumCentralityPercentile = 100 .;
@@ -642,6 +710,12 @@ struct MeanPtFlucId {
642710 hist.get <TH1 >(HIST (" Model/h_EventCount" ))->GetXaxis ()->SetBinLabel (2 , " Accepted" );
643711 hist.add (" Model/h_VtxZ" , " Generated vertex Z" , kTH1D , {axisVtxZ});
644712 hist.add (" Model/h_Nch" , " Accepted events (including zero selected particles)" , kTH1D , {axisModelMult});
713+ hist.add (" Model/h2_Nch_Cent" , " Generated charged multiplicity vs centrality (including zero selected particles)" , kTH2D , {axisModelCent, axisModelMult});
714+ // The profile retains exact integer multiplicities, independent of the
715+ // possibly coarse multiplicity bins in h2_Nch_Cent. Use the same event
716+ // weights and calibrated event ensemble as the particle matrices.
717+ const std::string modelNchProfileTitle = " Mean generated charged physical-primary multiplicity, all pT, |eta| < " + std::to_string (trackCuts.cfgCutEta .value );
718+ hist.add (" Model/p_Nch_Cent" , modelNchProfileTitle.c_str (), kTProfile , {axisModelCent});
645719 auto addModelSpecies = [&](const std::string& directory, const AxisSpec& axisPtId) {
646720 hist.add (directory + " h_Pt" , " Generated physical primaries" , kTH1D , {axisPtId});
647721 hist.add (directory + " h_Eta" , " Generated physical primaries" , kTH1D , {axisEta});
@@ -753,27 +827,41 @@ struct MeanPtFlucId {
753827 template <typename T>
754828 bool selTrack (T const & track)
755829 {
756- if (trackCuts.cfgGlobalTrack && !track.isGlobalTrack ()) {
757- return false ;
758- }
759-
760- if (trackCuts.cfgGlobalTrackWoDCA && !track.isGlobalTrackWoDCA ()) {
761- return false ;
762- }
763-
764- if (track.pt () < trackCuts.cfgCutPtMin ) {
765- return false ;
766- }
767-
768- if (track.pt () >= trackCuts.cfgCutPtMax ) {
830+ // Shared analysis acceptance, evaluated once for either selection mode.
831+ if (!std::isfinite (track.pt ()) || !std::isfinite (track.eta ()) || track.pt () <= 0 .f ||
832+ track.pt () < trackCuts.cfgCutPtMin || track.pt () >= trackCuts.cfgCutPtMax ||
833+ std::abs (track.eta ()) >= trackCuts.cfgCutEta || track.sign () == 0 ) {
769834 return false ;
770835 }
771836
772- if (track.sign () == 0 ) {
773- return false ;
837+ if (customTrackCuts.cfgUseCustomTrackSelection ) {
838+ // Acceptance is checked above with the analysis's exclusive upper bounds.
839+ // Only quality cuts belong to the custom selector; DCA is applied below.
840+ const bool isRun2 = TrackSelection::IsRun2Track (track);
841+ for (int i = 0 ; i < static_cast <int >(TrackSelection::TrackCuts::kNCuts ); ++i) {
842+ const auto cut = static_cast <TrackSelection::TrackCuts>(i);
843+ if (cut == TrackSelection::TrackCuts::kPtRange || cut == TrackSelection::TrackCuts::kEtaRange ||
844+ cut == TrackSelection::TrackCuts::kDCAxy || cut == TrackSelection::TrackCuts::kDCAz ) {
845+ continue ;
846+ }
847+ if (!mySelection.IsSelected (track, cut, isRun2)) {
848+ return false ;
849+ }
850+ }
851+ } else if (trackCuts.cfgGlobalTrack ) {
852+ if (!track.isGlobalTrack ()) {
853+ return false ;
854+ }
855+ } else if (trackCuts.cfgGlobalTrackWoDCA ) {
856+ if (!track.isGlobalTrackWoDCA ()) {
857+ return false ;
858+ }
774859 }
775860
776- const float maxDca = trackCuts.cfgDcaPtDepOffset + trackCuts.cfgDcaPtDepScale / track.pt ();
861+ // Shared DCA cuts, applied after either custom or standard quality selection.
862+ const float maxDca = (trackCuts.cfgDcaXYPtDep || trackCuts.cfgDcaZPtDep )
863+ ? trackCuts.cfgDcaPtDepOffset + trackCuts.cfgDcaPtDepScale / track.pt ()
864+ : 0 .f ;
777865
778866 if (trackCuts.cfgDcaXYPtDep ) {
779867 if (std::abs (track.dcaXY ()) >= maxDca) {
@@ -795,22 +883,6 @@ struct MeanPtFlucId {
795883 }
796884 }
797885
798- if (std::abs (track.eta ()) >= trackCuts.cfgCutEta ) {
799- return false ;
800- }
801-
802- if (trackCuts.cfgTPCChi2NCl && track.tpcChi2NCl () > trackCuts.cfgCutTPCChi2NCl ) {
803- return false ;
804- }
805-
806- if (trackCuts.cfgITSChi2NCl && track.itsChi2NCl () > trackCuts.cfgCutITSChi2NCl ) {
807- return false ;
808- }
809-
810- if (trackCuts.cfgNTPCCrossedRows && track.tpcNClsCrossedRows () < trackCuts.cfgCutNCrossedRowsTPC ) {
811- return false ;
812- }
813-
814886 return true ;
815887 }
816888
@@ -1498,11 +1570,12 @@ struct MeanPtFlucId {
14981570 eta = mcPart.eta ();
14991571 phi = mcPart.phi ();
15001572
1501- if (std::abs (eta) < trackCuts.cfgCutEta ) {
1502- nSim++ ;
1573+ if (!( std::abs (eta) < trackCuts.cfgCutEta ) ) {
1574+ continue ;
15031575 }
1576+ nSim++;
15041577
1505- if (pt >= trackCuts.cfgCutPtMin && pt < trackCuts.cfgCutPtMax && std::abs (eta) < trackCuts. cfgCutEta ) {
1578+ if (pt >= trackCuts.cfgCutPtMin && pt < trackCuts.cfgCutPtMax ) {
15061579 chargedTracksGen.push_back ({pt});
15071580 hist.fill (HIST (" Gen/Charged/h_PtTruth" ), pt);
15081581 hist.fill (HIST (" Gen/Charged/h_PtTruth_e" ), pt);
@@ -1669,6 +1742,8 @@ struct MeanPtFlucId {
16691742 hist.fill (HIST (" Model/h_Centrality" ), centrality, eventWeight);
16701743 const int multiplicity = countSimMultiplicity (mcParts);
16711744 hist.fill (HIST (" Model/h_Nch" ), multiplicity, eventWeight);
1745+ hist.fill (HIST (" Model/h2_Nch_Cent" ), centrality, multiplicity, eventWeight);
1746+ hist.fill (HIST (" Model/p_Nch_Cent" ), centrality, multiplicity, eventWeight);
16721747
16731748 std::array<std::vector<TrackInfo>, 4 > modelTracks;
16741749 for (auto const & particle : mcParts) {
0 commit comments