Skip to content

Commit 0927591

Browse files
authored
[Common,DPG] TPC PID workflows: provide reproducibility of randomization (#18634)
1 parent 6443e94 commit 0927591

3 files changed

Lines changed: 43 additions & 17 deletions

File tree

‎Common/Tools/PID/pidTPCModule.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,11 @@ class pidTPCModule
723723
}
724724
auto trackiterator = tracks.begin();
725725
if constexpr (requires { trackiterator.mcParticleId(); }) {
726-
gRandom->SetSeed(0); // Ensure unique seed from UUID for each process call
726+
if (bcs.size() != 0) {
727+
const auto timestamp = bcs.begin().timestamp();
728+
LOG(info) << "gRandom is seeded with timestamp of the 0-th bunch crossing (" << timestamp << ")";
729+
gRandom->SetSeed(timestamp);
730+
}
727731
}
728732

729733
// preparatory step: we need the multiplicities for each collision

‎DPG/Tasks/TPC/tpcSkimsTableCreator.cxx‎

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct TreeWriterTpcV0 {
166166

167167
o2::aod::rctsel::RCTFlagsChecker rctChecker{};
168168

169-
TRandom3* fRndm = new TRandom3(0);
169+
TRandom3* fRndm = new TRandom3();
170170

171171
using Trks = soa::Join<aod::Tracks, aod::V0Bits, aod::TracksExtra, aod::pidTPCFullEl, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTOFFullEl, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr, aod::TrackSelection>;
172172
using TrksWithDEdxCorrection = soa::Join<Trks, aod::DEdxsCorrected>;
@@ -420,6 +420,12 @@ struct TreeWriterTpcV0 {
420420
template <bool IsCorrectedDeDx, int ModeId, typename TrksType, typename BCType, typename TrkQAType>
421421
void runV0(Colls const& collisions, TrksType const& myTracks, V0sWithID const& myV0s, CascsWithID const& myCascs, TrkQAType const& tracksQA)
422422
{
423+
if (collisions.size() != 0) {
424+
const auto timestamp = collisions.begin().bc_as<BCType>().timestamp();
425+
LOG(info) << "fRndm is seeded with timestamp of the 0-th bunch crossing (" << timestamp << ")";
426+
fRndm->SetSeed(timestamp);
427+
}
428+
423429
constexpr bool IsWithTrackQa = ModeId != ModeStandard;
424430

425431
std::vector<int64_t> labelTrack2TrackQA;
@@ -692,20 +698,20 @@ struct TreeWriterTpcTof {
692698
HistogramRegistry registry{"registry", {}};
693699

694700
struct TofTrack {
695-
bool isApplyHardCutOnly;
696-
double maxMomHardCutOnly;
697-
double maxMomTPCOnly;
698-
double tpcNSigma;
699-
double nSigmaTPCOnly;
700-
double downsamplingTsalis;
701-
double mass;
702-
double tofNSigma;
703-
double itsNSigma;
704-
double tpcExpSignal;
705-
o2::track::PID::ID pid;
706-
double dwnSmplFactor;
707-
double nSigmaTofTpctof;
708-
double nSigmaTpcTpctof;
701+
bool isApplyHardCutOnly{false};
702+
double maxMomHardCutOnly{UndefValueDouble};
703+
double maxMomTPCOnly{UndefValueDouble};
704+
double tpcNSigma{UndefValueDouble};
705+
double nSigmaTPCOnly{UndefValueDouble};
706+
double downsamplingTsalis{UndefValueDouble};
707+
double mass{UndefValueDouble};
708+
double tofNSigma{UndefValueDouble};
709+
double itsNSigma{UndefValueDouble};
710+
double tpcExpSignal{UndefValueDouble};
711+
o2::track::PID::ID pid{0};
712+
double dwnSmplFactor{UndefValueDouble};
713+
double nSigmaTofTpctof{UndefValueDouble};
714+
double nSigmaTpcTpctof{UndefValueDouble};
709715
};
710716

711717
Service<o2::ccdb::BasicCCDBManager> ccdb{};
@@ -714,7 +720,7 @@ struct TreeWriterTpcTof {
714720

715721
o2::aod::rctsel::RCTFlagsChecker rctChecker{};
716722

717-
TRandom3* fRndm = new TRandom3(0);
723+
TRandom3* fRndm = new TRandom3();
718724

719725
using Trks = soa::Join<aod::Tracks, aod::TracksExtra,
720726
aod::pidTPCFullEl, aod::pidTPCFullPi, aod::pidTPCFullKa,
@@ -850,6 +856,12 @@ struct TreeWriterTpcTof {
850856
template <bool IsCorrectedDeDx, int ModeId, typename TrksType, typename BCType, typename TrkQAType, typename TMOType>
851857
void runTof(Colls const& collisions, TrksType const& myTracks, TrkQAType const& tracksQA, Preslice<TrksType> const& perCollisionTracksType, TMOType const& trackMeanOccs)
852858
{
859+
if (collisions.size() != 0) {
860+
const auto timestamp = collisions.begin().bc_as<BCType>().timestamp();
861+
LOG(info) << "fRndm is seeded with timestamp of the 0-th bunch crossing (" << timestamp << ")";
862+
fRndm->SetSeed(timestamp);
863+
}
864+
853865
constexpr bool IsWithTrackQa = ModeId != ModeStandard;
854866

855867
std::vector<int64_t> labelTrack2TrackQA;

‎DPG/Tasks/TPC/treeCreatorPidTpcDiagnostics.cxx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ struct TreeCreatorPidTpcDiagnostics {
293293
}
294294
}
295295

296+
void process(const aod::Collisions& collisions,
297+
const aod::BCsWithTimestamps&)
298+
{
299+
if (collisions.size() != 0) {
300+
const auto timestamp = collisions.begin().bc_as<aod::BCsWithTimestamps>().timestamp();
301+
LOG(info) << "mRnd is seeded with timestamp of the 0-th bunch crossing (" << timestamp << ")";
302+
mRnd.SetSeed(timestamp);
303+
}
304+
}
305+
296306
#define MAKE_PROCESS_FUNCTIONS(ParticleNameShort, ParticleNameLong, Unused) \
297307
void process##ParticleNameLong(CollisionsExtra const& collisions, \
298308
soa::Join<TrackCandidates, aod::pidTPC##ParticleNameShort> const& tracks, \

0 commit comments

Comments
 (0)