|
13 | 13 | /// \brief Tasks creates bitmasks for femtodream collisions |
14 | 14 | /// \author Anton Riedel, TU München, [email protected] |
15 | 15 |
|
| 16 | +#include <cstdint> |
16 | 17 | #include <vector> |
17 | 18 | #include <bitset> |
18 | 19 | #include <algorithm> |
19 | 20 | #include <random> |
| 21 | +#include <chrono> |
20 | 22 |
|
21 | 23 | #include "fairlogger/Logger.h" |
22 | 24 | #include "Framework/Configurable.h" |
@@ -54,7 +56,7 @@ struct femoDreamCollisionMasker { |
54 | 56 |
|
55 | 57 | // configurable for downsampling |
56 | 58 | Configurable<float> ConfDownsampling{"ConfDownsampling", -1., "Fraction of events to be used in mixed event sample. Factor should be between 0 and 1. Deactivate with negative value"}; |
57 | | - Configurable<uint> ConfSeed{"ConfSeed", 29012024, "Seed for downsampling"}; |
| 59 | + Configurable<uint64_t> ConfSeed{"ConfSeed", 0, "Seed for downsampling. Set to 0 for using a seed unique in time."}; |
58 | 60 |
|
59 | 61 | std::mt19937* rng = nullptr; |
60 | 62 |
|
@@ -94,8 +96,14 @@ struct femoDreamCollisionMasker { |
94 | 96 | { |
95 | 97 |
|
96 | 98 | // seed rng for downsampling |
97 | | - if (ConfSeed.value > 0) { |
98 | | - rng = new std::mt19937(ConfSeed.value); |
| 99 | + if (ConfDownsampling.value > 0) { |
| 100 | + uint64_t randomSeed = 0; |
| 101 | + if (ConfSeed.value == 0) { |
| 102 | + randomSeed = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()); |
| 103 | + } else { |
| 104 | + randomSeed = ConfSeed.value; |
| 105 | + } |
| 106 | + rng = new std::mt19937(randomSeed); |
99 | 107 | } |
100 | 108 |
|
101 | 109 | std::vector<std::string> MatchedWorkflows; |
@@ -356,7 +364,7 @@ struct femoDreamCollisionMasker { |
356 | 364 | bool UseInMixedEvent = true; |
357 | 365 | std::uniform_real_distribution<> dist(0, 1); |
358 | 366 |
|
359 | | - if (ConfSeed.value > 0 && (1 - dist(*rng)) > ConfDownsampling.value) { |
| 367 | + if (ConfDownsampling.value > 0 && (1 - dist(*rng)) > ConfDownsampling.value) { |
360 | 368 | UseInMixedEvent = false; |
361 | 369 | } |
362 | 370 |
|
|
0 commit comments