@@ -455,7 +455,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
455455 tracksExtraCursor.reserve (nToReserve + tracksExtraCursor.lastIndex ());
456456 }
457457 for (int ti = start; ti < end; ti++) {
458- auto & trackIndex = GIndices[ti];
458+ const auto & trackIndex = GIndices[ti];
459459 if (GIndex::includesSource (src, mInputSources )) {
460460 if (src == GIndex::Source::MFT) { // MFT tracks are treated separately since they are stored in a different table
461461 if (trackIndex.isAmbiguous () && mGIDToTableMFTID .find (trackIndex) != mGIDToTableMFTID .end ()) { // was it already stored ?
@@ -477,11 +477,12 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
477477 if (trackIndex.isAmbiguous () && mGIDToTableID .find (trackIndex) != mGIDToTableID .end ()) { // was it already stored ?
478478 continue ;
479479 }
480- auto extraInfoHolder = processBarrelTrack (collisionID, collisionBC, trackIndex, data, bcsMap);
481480
482481 float weight = 0 ;
483- std::uniform_real_distribution<> distr (0 ., 1 .);
482+ static std::uniform_real_distribution<> distr (0 ., 1 .);
484483 bool writeQAData = o2::math_utils::Tsallis::downsampleTsallisCharged (data.getTrackParam (trackIndex).getPt (), mTrackQCFraction , mSqrtS , weight, distr (mGenerator ));
484+ auto extraInfoHolder = processBarrelTrack (collisionID, collisionBC, trackIndex, data, bcsMap);
485+
485486 if (writeQAData) {
486487 auto trackQAInfoHolder = processBarrelTrackQA (collisionID, collisionBC, trackIndex, data, bcsMap);
487488 if (std::bitset<8 >(trackQAInfoHolder.tpcClusterByteMask ).count () >= mTrackQCNTrCut ) {
@@ -490,17 +491,26 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
490491 trackQAInfoHolder.tpcTime0 = (trackQAInfoHolder.tpcTime0 * 8 - extraInfoHolder.diffBCRef ) * o2::constants::lhc::LHCBunchSpacingNS - extraInfoHolder.trackTime ;
491492 // difference between TPC track time0 and stored track nominal time in ns instead of TF start
492493 addToTracksQATable (tracksQACursor, trackQAInfoHolder);
494+ } else {
495+ writeQAData = false ;
493496 }
494497 }
495498
499+ if (mThinTracks && src == GIndex::Source::TPC && mGIDUsedBySVtx .find (trackIndex) == mGIDUsedBySVtx .end () && mGIDUsedByStr .find (trackIndex) == mGIDUsedByStr .end () && !writeQAData) {
500+ mGIDToTableID .emplace (trackIndex, -1 ); // pretend skipped tracks are stored; this is safe since they are are not written to disk and -1 indicates to all users to not use this track
501+ continue ;
502+ }
503+
496504 if (!extraInfoHolder.isTPConly && extraInfoHolder.trackTimeRes < 0 .f ) { // failed or rejected?
497505 LOG (warning) << " Barrel track " << trackIndex << " has no time set, rejection is not expected : time=" << extraInfoHolder.trackTime
498506 << " timeErr=" << extraInfoHolder.trackTimeRes << " BCSlice: " << extraInfoHolder.bcSlice [0 ] << " :" << extraInfoHolder.bcSlice [1 ];
499507 continue ;
500508 }
501509 const auto & trOrig = data.getTrackParam (trackIndex);
502510 bool isProp = false ;
503- if (mPropTracks && trOrig.getX () < mMinPropR && mGIDUsedBySVtx .find (trackIndex) == mGIDUsedBySVtx .end ()) { // Do not propagate track assoc. to V0s
511+ if (mPropTracks && trOrig.getX () < mMinPropR &&
512+ mGIDUsedBySVtx .find (trackIndex) == mGIDUsedBySVtx .end () &&
513+ mGIDUsedByStr .find (trackIndex) == mGIDUsedByStr .end ()) { // Do not propagate track assoc. to V0s and str. tracking
504514 auto trackPar (trOrig);
505515 isProp = propagateTrackToPV (trackPar, data, collisionID);
506516 if (isProp) {
@@ -511,7 +521,7 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID,
511521 addToTracksTable (tracksCursor, tracksCovCursor, trOrig, collisionID, aod::track::TrackIU);
512522 }
513523 addToTracksExtraTable (tracksExtraCursor, extraInfoHolder);
514- // addToTracksQATable(tracksQACursor, trackQAInfoHolder);
524+
515525 // collecting table indices of barrel tracks for V0s table
516526 if (extraInfoHolder.bcSlice [0 ] >= 0 && collisionID < 0 ) {
517527 ambigTracksCursor (mTableTrID , extraInfoHolder.bcSlice );
@@ -1334,7 +1344,7 @@ void AODProducerWorkflowDPL::fillStrangenessTrackingTables(const o2::globaltrack
13341344 int nCasc = 0 ;
13351345 int nD3Body = 0 ;
13361346
1337- for (auto & sTrk : recoData.getStrangeTracks ()) {
1347+ for (const auto & sTrk : recoData.getStrangeTracks ()) {
13381348 if (sTrk .mPartType == dataformats::kStrkV0 ) {
13391349 nV0++;
13401350 } else if (sTrk .mPartType == dataformats::kStrkCascade ) {
@@ -1348,13 +1358,13 @@ void AODProducerWorkflowDPL::fillStrangenessTrackingTables(const o2::globaltrack
13481358 cascCurs.reserve (nCasc);
13491359 d3BodyCurs.reserve (nD3Body);
13501360
1351- for (auto & sTrk : recoData.getStrangeTracks ()) {
1361+ for (const auto & sTrk : recoData.getStrangeTracks ()) {
13521362 auto ITSIndex = GIndex{sTrk .mITSRef , GIndex::ITS};
13531363 auto item = mGIDToTableID .find (ITSIndex);
13541364 if (item != mGIDToTableID .end ()) {
13551365 itsTableIdx = item->second ;
13561366 } else {
1357- LOG (warn) << " Could not find a ITS strange track index" ;
1367+ LOG (warn) << " Could not find a ITS strange track index " << ITSIndex ;
13581368 continue ;
13591369 }
13601370 if (sTrk .mPartType == dataformats::kStrkV0 ) {
@@ -1649,11 +1659,22 @@ void AODProducerWorkflowDPL::init(InitContext& ic)
16491659 mCTPReadout = ic.options ().get <int >(" ctpreadout-create" );
16501660 mNThreads = std::max (1 , ic.options ().get <int >(" nthreads" ));
16511661 mEMCselectLeading = ic.options ().get <bool >(" emc-select-leading" );
1662+ mThinTracks = ic.options ().get <bool >(" thin-tracks" );
16521663 mPropTracks = ic.options ().get <bool >(" propagate-tracks" );
16531664 mPropMuons = ic.options ().get <bool >(" propagate-muons" );
16541665 mTrackQCFraction = ic.options ().get <float >(" trackqc-fraction" );
16551666 mTrackQCNTrCut = ic.options ().get <int64_t >(" trackqc-NTrCut" );
1656- mGenerator = std::mt19937 (std::random_device{}());
1667+ if (auto seed = ic.options ().get <int >(" seed" ); seed == 0 ) {
1668+ LOGP (info, " Using random device for seeding" );
1669+ std::random_device rd;
1670+ std::array<int , std::mt19937::state_size> seed_data{};
1671+ std::generate (std::begin (seed_data), std::end (seed_data), std::ref (rd));
1672+ std::seed_seq seq (std::begin (seed_data), std::end (seed_data));
1673+ mGenerator = std::mt19937 (seq);
1674+ } else {
1675+ LOGP (info, " Using seed {} for sampling" , seed);
1676+ mGenerator .seed (seed);
1677+ }
16571678#ifdef WITH_OPENMP
16581679 LOGP (info, " Multi-threaded parts will run with {} OpenMP threads" , mNThreads );
16591680#else
@@ -2080,7 +2101,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
20802101 mGIDToTableFwdID .clear (); // reset the tables to be used by 'fillTrackTablesPerCollision'
20812102 mGIDToTableMFTID .clear ();
20822103
2083- if (mPropTracks ) {
2104+ if (mPropTracks || mThinTracks ) {
20842105 auto v0s = recoData.getV0sIdx ();
20852106 auto cascades = recoData.getCascadesIdx ();
20862107 auto decays3Body = recoData.getDecays3BodyIdx ();
@@ -2097,6 +2118,11 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
20972118 mGIDUsedBySVtx .insert (id3Body.getProngID (1 ));
20982119 mGIDUsedBySVtx .insert (id3Body.getProngID (2 ));
20992120 }
2121+
2122+ mGIDUsedByStr .reserve (recoData.getStrangeTracks ().size ());
2123+ for (const auto & sTrk : recoData.getStrangeTracks ()) {
2124+ mGIDUsedByStr .emplace (sTrk .mITSRef , GIndex::ITS);
2125+ }
21002126 }
21012127
21022128 // filling unassigned tracks first
@@ -2270,6 +2296,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
22702296 mBCLookup .clear ();
22712297
22722298 mGIDUsedBySVtx .clear ();
2299+ mGIDUsedByStr .clear ();
22732300
22742301 originCursor (tfNumber);
22752302
@@ -2985,8 +3012,10 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
29853012 ConfigParamSpec{" propagate-tracks" , VariantType::Bool, false , {" Propagate tracks (not used for secondary vertices) to IP" }},
29863013 ConfigParamSpec{" hepmc-update" , VariantType::String, " always" , {" When to update HepMC Aux tables: always - force update, never - never update, all - if all keys are present, any - when any key is present (not valid yet)" }},
29873014 ConfigParamSpec{" propagate-muons" , VariantType::Bool, false , {" Propagate muons to IP" }},
3015+ ConfigParamSpec{" thin-tracks" , VariantType::Bool, false , {" Produce thinned track tables" }},
29883016 ConfigParamSpec{" trackqc-fraction" , VariantType::Float, float (0.1 ), {" Fraction of tracks to QC" }},
29893017 ConfigParamSpec{" trackqc-NTrCut" , VariantType::Int64, 4L , {" Minimal length of the track - in amount of tracklets" }},
3018+ ConfigParamSpec{" seed" , VariantType::Int, 0 , {" Set seed for random generator used for sampling (0 (default) means using a random_device)" }},
29903019 }};
29913020}
29923021
0 commit comments