|
25 | 25 | #include "Framework/HistogramSpec.h" |
26 | 26 |
|
27 | 27 | #include <array> |
| 28 | +#include <chrono> |
28 | 29 | #include <cmath> |
29 | 30 | #include <cstddef> |
30 | 31 | #include <map> |
31 | 32 | #include <numeric> |
| 33 | +#include <random> |
32 | 34 | #include <string> |
33 | 35 | #include <vector> |
34 | 36 |
|
@@ -68,6 +70,7 @@ struct ConfCpr : o2::framework::ConfigurableGroup { |
68 | 70 | o2::framework::Configurable<float> kinematicMax{"kinematicMax", -1.f, "Maximum kstar/Q3 of pair/triplet for plotting (Set to negative value to turn off the cut)"}; |
69 | 71 | o2::framework::ConfigurableAxis binningDeta{"binningDeta", {{250, -0.5, 0.5}}, "deta"}; |
70 | 72 | o2::framework::ConfigurableAxis binningDphistar{"binningDphistar", {{250, -0.5, 0.5}}, "dphi"}; |
| 73 | + o2::framework::Configurable<int> seed{"seed", -1, "Seed to randomize particle 1 and particle 2. Set to negative value to deactivate. Set to 0 to generate unique seed in time."}; |
71 | 74 | }; |
72 | 75 |
|
73 | 76 | constexpr const char PrefixCprTrackTrack[] = "CprTrackTrack"; |
@@ -174,6 +177,17 @@ class CloseTrackRejection |
174 | 177 | mPlotAverage = confCpr.plotAverage.value; |
175 | 178 | mPlotAllRadii = confCpr.plotAllRadii.value; |
176 | 179 |
|
| 180 | + if (confCpr.seed.value >= 0) { |
| 181 | + uint64_t randomSeed; |
| 182 | + mRandomizeTracks = true; |
| 183 | + if (confCpr.seed.value == 0) { |
| 184 | + randomSeed = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()); |
| 185 | + } else { |
| 186 | + randomSeed = static_cast<uint64_t>(confCpr.seed.value); |
| 187 | + } |
| 188 | + mRng = std::mt19937(randomSeed); |
| 189 | + } |
| 190 | + |
177 | 191 | // check if we need to apply any cut a plot is requested |
178 | 192 | mIsActivated = mCutAverage || mCutAnyRadius || mPlotAverage || mPlotAllRadii; |
179 | 193 |
|
@@ -210,11 +224,19 @@ class CloseTrackRejection |
210 | 224 | mDphistar.fill(0.f); |
211 | 225 | mDphistarMask.fill(false); |
212 | 226 |
|
213 | | - mDeta = track1.eta() - track2.eta(); |
| 227 | + bool swapTracks = false; |
| 228 | + if (mRandomizeTracks) { |
| 229 | + swapTracks = (mSwapDist(mRng) == 1); |
| 230 | + } |
| 231 | + |
| 232 | + auto const& t1 = swapTracks ? track2 : track1; |
| 233 | + auto const& t2 = swapTracks ? track1 : track2; |
| 234 | + |
| 235 | + mDeta = t1.eta() - t2.eta(); |
214 | 236 |
|
215 | 237 | for (size_t i = 0; i < TpcRadii.size(); i++) { |
216 | | - auto phistar1 = phistar(mMagField, TpcRadii[i], mChargeAbsTrack1 * track1.signedPt(), track1.phi()); |
217 | | - auto phistar2 = phistar(mMagField, TpcRadii[i], mChargeAbsTrack2 * track2.signedPt(), track2.phi()); |
| 238 | + auto phistar1 = phistar(mMagField, TpcRadii[i], mChargeAbsTrack1 * t1.signedPt(), t1.phi()); |
| 239 | + auto phistar2 = phistar(mMagField, TpcRadii[i], mChargeAbsTrack2 * t2.signedPt(), t2.phi()); |
218 | 240 | if (phistar1 && phistar2) { |
219 | 241 | mDphistar.at(i) = RecoDecay::constrainAngle(phistar1.value() - phistar2.value(), -o2::constants::math::PI); // constrain angular difference between -pi and pi |
220 | 242 | mDphistarMask.at(i) = true; |
@@ -342,6 +364,10 @@ class CloseTrackRejection |
342 | 364 | float mDeta = 0.f; |
343 | 365 | std::array<float, Nradii> mDphistar = {0.f}; |
344 | 366 | std::array<bool, Nradii> mDphistarMask = {false}; |
| 367 | + |
| 368 | + bool mRandomizeTracks = false; |
| 369 | + std::mt19937 mRng; |
| 370 | + std::uniform_int_distribution<int> mSwapDist{0, 1}; |
345 | 371 | }; |
346 | 372 |
|
347 | 373 | template <const char* prefix> |
|
0 commit comments