2626#include < fstream>
2727#include < locale>
2828#include < sstream>
29+ #include < ranges>
2930#include < functional>
3031#include < map>
3132
@@ -223,9 +224,9 @@ static constexpr o2::aod::track::TrackSelectionFlags::flagtype TrackSelectionDCA
223224 o2::aod::track::TrackSelectionFlags::kDCAz | o2::aod::track::TrackSelectionFlags::kDCAxy ;
224225
225226int tracktype = 1 ;
226- std::function< float ( float )> maxDcaZPtDep {}; // max dca in z axis as function of pT
227-
228- std::vector< TrackSelection*> trackFilters = {} ;
227+ std::vector<TrackSelection*> trackFilters = {}; // the vector of track selectors
228+ std::vector<std::function< float ( float )>> maxDcaZPtDeps = {}; // max dca in z axis as function of pT for each track selector
229+ TrackSelection* extraTrackFilter = nullptr ;
229230bool dca2Dcut = false ;
230231float sharedTpcClusters = 1.0 ; // /< max fraction of shared TPC clusters
231232float maxDCAz = 1e6f;
@@ -256,6 +257,18 @@ inline TList* getCCDBInput(auto& ccdb, const char* ccdbpath, const char* ccdbdat
256257
257258inline void initializeTrackSelection (TrackSelectionTuneCfg& tune)
258259{
260+ auto addTrackFilter = [](auto filter, std::function<float (float )> dcaZCutFunc = {}) {
261+ trackFilters.push_back (filter);
262+ maxDcaZPtDeps.push_back (dcaZCutFunc);
263+ };
264+ auto highQualityTpcTrack = []() {
265+ TrackSelection* tpcTrack = new TrackSelection (getGlobalTrackSelection ());
266+ tpcTrack->ResetITSRequirements ();
267+ tpcTrack->SetRequireITSRefit (false );
268+ tpcTrack->SetMinNClustersTPC (120 );
269+ sharedTpcClusters = 0.2 ;
270+ return tpcTrack;
271+ };
259272 switch (tracktype) {
260273 case 1 : { /* Run2 global track */
261274 TrackSelection* globalRun2 = new TrackSelection (getGlobalTrackSelection ());
@@ -264,8 +277,8 @@ inline void initializeTrackSelection(TrackSelectionTuneCfg& tune)
264277 TrackSelection* globalSDDRun2 = new TrackSelection (getGlobalTrackSelectionSDD ());
265278 globalSDDRun2->SetTrackType (o2::aod::track::Run2Track); // Run 2 track asked by default
266279 globalSDDRun2->SetMaxChi2PerClusterTPC (2 .5f );
267- trackFilters. push_back (globalRun2);
268- trackFilters. push_back (globalSDDRun2);
280+ addTrackFilter (globalRun2);
281+ addTrackFilter (globalSDDRun2);
269282 } break ;
270283 case 3 : { /* Run3 track */
271284 TrackSelection* globalRun3 = new TrackSelection (getGlobalTrackSelection ());
@@ -277,8 +290,8 @@ inline void initializeTrackSelection(TrackSelectionTuneCfg& tune)
277290 globalSDDRun3->ResetITSRequirements ();
278291 globalSDDRun3->SetRequireNoHitsInITSLayers ({0 , 1 , 2 });
279292 globalSDDRun3->SetRequireHitsInITSLayers (1 , {3 });
280- trackFilters. push_back (globalRun3);
281- trackFilters. push_back (globalSDDRun3);
293+ addTrackFilter (globalRun3);
294+ addTrackFilter (globalSDDRun3);
282295 } break ;
283296 case 5 : { /* Run2 TPC only track */
284297 TrackSelection* tpcOnly = new TrackSelection;
@@ -290,7 +303,7 @@ inline void initializeTrackSelection(TrackSelectionTuneCfg& tune)
290303 tpcOnly->SetMaxDcaXY (2 .4f );
291304 maxDCAxy = 2.4 ;
292305 dca2Dcut = true ;
293- trackFilters. push_back (tpcOnly);
306+ addTrackFilter (tpcOnly);
294307 } break ;
295308 case 7 : { /* Run3 TPC only track */
296309 TrackSelection* tpcOnly = new TrackSelection;
@@ -302,47 +315,72 @@ inline void initializeTrackSelection(TrackSelectionTuneCfg& tune)
302315 tpcOnly->SetMaxDcaXY (2 .4f );
303316 maxDCAxy = 2.4 ;
304317 dca2Dcut = true ;
305- trackFilters.push_back (tpcOnly);
318+ addTrackFilter (tpcOnly);
319+ } break ;
320+ case 10 : { /* Run3 track primary vertex contributor */
321+ TrackSelection* globalRun3 = new TrackSelection (getGlobalTrackSelection ());
322+ globalRun3->SetTrackType (o2::aod::track::TrackTypeEnum::Track);
323+ globalRun3->ResetITSRequirements ();
324+ globalRun3->SetRequireHitsInITSLayers (1 , {0 , 1 , 2 });
325+ TrackSelection* globalSDDRun3 = new TrackSelection (getGlobalTrackSelection ());
326+ globalSDDRun3->SetTrackType (o2::aod::track::TrackTypeEnum::Track);
327+ globalSDDRun3->ResetITSRequirements ();
328+ globalSDDRun3->SetRequireNoHitsInITSLayers ({0 , 1 , 2 });
329+ globalSDDRun3->SetRequireHitsInITSLayers (1 , {3 });
330+ addTrackFilter (globalRun3);
331+ addTrackFilter (globalSDDRun3);
306332 } break ;
307333 case 30 : { /* Run 3 default global track: kAny on 3 IB layers of ITS */
308- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
334+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
309335 } break ;
310336 case 31 : { /* Run 3 global track: kTwo on 3 IB layers of ITS */
311- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
337+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
312338 } break ;
313339 case 32 : { /* Run 3 global track: kAny on all 7 layers of ITS */
314- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
340+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
315341 } break ;
316342 case 33 : { /* Run 3 global track: kAll on all 7 layers of ITS */
317- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
343+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default)));
318344 } break ;
319345 case 40 : { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy */
320- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
346+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
321347 } break ;
322348 case 41 : { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy */
323- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
349+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
324350 } break ;
325351 case 42 : { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy */
326- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
352+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
327353 } break ;
328354 case 43 : { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy */
329- trackFilters. push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
355+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
330356 } break ;
331357 case 50 : { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz */
332- trackFilters.push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
333- maxDcaZPtDep = [](float pt) { return 0 .004f + 0 .013f / pt; };
358+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
334359 } break ;
335360 case 51 : { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz */
336- trackFilters.push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
337- maxDcaZPtDep = [](float pt) { return 0 .004f + 0 .013f / pt; };
361+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
338362 } break ;
339363 case 52 : { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz */
340- trackFilters.push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
341- maxDcaZPtDep = [](float pt) { return 0 .004f + 0 .013f / pt; };
364+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
342365 } break ;
343366 case 53 : { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz */
344- trackFilters.push_back (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)));
345- maxDcaZPtDep = [](float pt) { return 0 .004f + 0 .013f / pt; };
367+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
368+ } break ;
369+ case 60 : { /* Run 3 global track: kAny on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */
370+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
371+ extraTrackFilter = highQualityTpcTrack ();
372+ } break ;
373+ case 61 : { /* Run 3 global track: kTwo on 3 IB layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */
374+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibTwo, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
375+ extraTrackFilter = highQualityTpcTrack ();
376+ } break ;
377+ case 62 : { /* Run 3 global track: kAny on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */
378+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSallAny, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
379+ extraTrackFilter = highQualityTpcTrack ();
380+ } break ;
381+ case 63 : { /* Run 3 global track: kAll on all 7 layers of ITS, tighter DCAxy, tighter pT dep DCAz, plus TPC+TOF only tracks */
382+ addTrackFilter (new TrackSelection (getGlobalTrackSelectionRun3ITSMatch (TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::ppPass3)), [](float pt) { return 0 .004f + 0 .013f / pt; });
383+ extraTrackFilter = highQualityTpcTrack ();
346384 } break ;
347385 default :
348386 break ;
@@ -368,7 +406,9 @@ inline void initializeTrackSelection(TrackSelectionTuneCfg& tune)
368406 }
369407 }
370408 if (tune.mUseDCAz ) {
371- maxDcaZPtDep = [&tune](float ) { return tune.mDCAz ; };
409+ for (auto dcaZCut : maxDcaZPtDeps) { // o2-linter: disable=const-ref-in-for-loop
410+ dcaZCut = [&tune](float ) { return tune.mDCAz ; };
411+ }
372412 }
373413 if (tune.mUseFractionTpcSharedClusters ) {
374414 sharedTpcClusters = tune.mFractionTpcSharedClusters ;
@@ -1154,7 +1194,7 @@ struct TpcExcludeTrack {
11541194 {
11551195 method = kNOEXCLUSION ;
11561196 }
1157- explicit TpcExcludeTrack (TpcExclusionMethod m)
1197+ explicit TpcExcludeTrack (TpcExclusionMethod m) // o2-linter: disable=name/function-variable
11581198 {
11591199 switch (m) {
11601200 case kNOEXCLUSION :
@@ -1252,9 +1292,11 @@ inline bool matchTrackType(TrackObject const& track)
12521292 (!track.hasTPC () || ((track.trackCutFlag () & TrackSelectionTPC) == TrackSelectionTPC)) &&
12531293 ((track.trackCutFlag () & TrackSelectionDCA) == TrackSelectionDCA);
12541294 } else {
1255- for (auto const & filter : trackFilters) {
1295+ for (size_t i = 0 ; i < trackFilters.size (); ++i) {
1296+ auto const & filter = trackFilters[i];
1297+ auto const & maxDcaZPtDep = maxDcaZPtDeps[i];
12561298 if (filter->IsSelected (track)) {
1257- /* additional track cuts if needed */
1299+ /* additional more stringent track cuts if needed */
12581300 auto checkDca2Dcut = [&](auto const & track) {
12591301 if (dca2Dcut) {
12601302 if (track.dcaXY () * track.dcaXY () / maxDCAxy / maxDCAxy + track.dcaZ () * track.dcaZ () / maxDCAz / maxDCAz > 1 ) {
@@ -1276,16 +1318,39 @@ inline bool matchTrackType(TrackObject const& track)
12761318 }
12771319 /* 2D DCA xy-o-z cut */
12781320 if (!checkDca2Dcut (track)) {
1279- return false ;
1321+ continue ;
12801322 }
1323+ /* shared fraction of TPC clusters */
1324+ if (!(track.tpcFractionSharedCls () < sharedTpcClusters)) {
1325+ continue ;
1326+ }
1327+ /* primary vertex contributor */
1328+ if (tracktype == 10 ) {
1329+ if (!track.isPVContributor ()) {
1330+ continue ;
1331+ }
1332+ }
1333+ return true ;
1334+ }
1335+ }
1336+ /* check extra less stringent selections */
1337+ if (extraTrackFilter != nullptr ) {
1338+ if (extraTrackFilter->IsSelected (track)) {
12811339 /* shared fraction of TPC clusters */
12821340 if (!(track.tpcFractionSharedCls () < sharedTpcClusters)) {
12831341 return false ;
12841342 }
1343+ /* we require TOF */
1344+ if (!(track.hasTOF ())) {
1345+ return false ;
1346+ }
12851347 return true ;
1348+ } else {
1349+ return false ;
12861350 }
1351+ } else {
1352+ return false ;
12871353 }
1288- return false ;
12891354 }
12901355}
12911356
0 commit comments