Skip to content

Commit 8a67d61

Browse files
committed
o2-sim: Promote random seed to 64bit int (or ULong_t)
more naturally since type of TRandom::SetSeed takes ULong_t in any case
1 parent bea9901 commit 8a67d61

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct SimConfigData {
5656
// but will themselves be overridden by any values given in mKeyValueTokens.
5757
int mPrimaryChunkSize; // defining max granularity for input primaries of a sim job
5858
int mInternalChunkSize; //
59-
int mStartSeed; // base for random number seeds
59+
ULong_t mStartSeed; // base for random number seeds
6060
int mSimWorkers = 1; // number of parallel sim workers (when it applies)
6161
bool mFilterNoHitEvents = false; // whether to filter out events not leaving any response
6262
std::string mCCDBUrl; // the URL where to find CCDB
@@ -137,7 +137,7 @@ class SimConfig
137137
std::string getConfigFile() const { return mConfigData.mConfigFile; }
138138
int getPrimChunkSize() const { return mConfigData.mPrimaryChunkSize; }
139139
int getInternalChunkSize() const { return mConfigData.mInternalChunkSize; }
140-
int getStartSeed() const { return mConfigData.mStartSeed; }
140+
ULong_t getStartSeed() const { return mConfigData.mStartSeed; }
141141
int getNSimWorkers() const { return mConfigData.mSimWorkers; }
142142
bool isFilterOutNoHitEvents() const { return mConfigData.mFilterNoHitEvents; }
143143
bool asService() const { return mConfigData.mAsService; }
@@ -173,7 +173,7 @@ struct SimReconfigData {
173173
// values within the config file will override values set in code by the param classes
174174
// but will themselves be overridden by any values given in mKeyValueTokens.
175175
unsigned int primaryChunkSize; // defining max granularity for input primaries of a sim job
176-
int startSeed; // base for random number seeds
176+
ULong_t startSeed; // base for random number seeds
177177
bool stop; // to shut down the service
178178

179179
ClassDefNV(SimReconfigData, 1);

Common/SimConfig/src/SimConfig.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void SimConfig::initOptions(boost::program_options::options_description& options
4848
"configFile", bpo::value<std::string>()->default_value(""), "Path to an INI or JSON configuration file")(
4949
"chunkSize", bpo::value<unsigned int>()->default_value(500), "max size of primary chunk (subevent) distributed by server")(
5050
"chunkSizeI", bpo::value<int>()->default_value(-1), "internalChunkSize")(
51-
"seed", bpo::value<int>()->default_value(-1), "initial seed (default: -1 random)")(
51+
"seed", bpo::value<ULong_t>()->default_value(0), "initial seed as ULong_t (default: 0 == random)")(
5252
"field", bpo::value<std::string>()->default_value("-5"), "L3 field rounded to kGauss, allowed values +-2,+-5 and 0; +-<intKGaus>U for uniform field; \"ccdb\" for taking it from CCDB ")(
5353
"nworkers,j", bpo::value<int>()->default_value(nsimworkersdefault), "number of parallel simulation workers (only for parallel mode)")(
5454
"noemptyevents", "only writes events with at least one hit")(
@@ -171,7 +171,7 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
171171
mConfigData.mConfigFile = vm["configFile"].as<std::string>();
172172
mConfigData.mPrimaryChunkSize = vm["chunkSize"].as<unsigned int>();
173173
mConfigData.mInternalChunkSize = vm["chunkSizeI"].as<int>();
174-
mConfigData.mStartSeed = vm["seed"].as<int>();
174+
mConfigData.mStartSeed = vm["seed"].as<ULong_t>();
175175
mConfigData.mSimWorkers = vm["nworkers"].as<int>();
176176
if (vm.count("timestamp")) {
177177
mConfigData.mTimestamp = vm["timestamp"].as<uint64_t>();
@@ -286,7 +286,7 @@ bool parseSimReconfigFromString(std::string const& argumentstring, SimReconfigDa
286286
"configKeyValues", bpo::value<std::string>(&data.keyValueTokens)->default_value(""), "semicolon separated key=value strings (e.g.: 'TPC.gasDensity=1;...")(
287287
"configFile", bpo::value<std::string>(&data.configFile)->default_value(""), "Path to an INI or JSON configuration file")(
288288
"chunkSize", bpo::value<unsigned int>(&data.primaryChunkSize)->default_value(500), "max size of primary chunk (subevent) distributed by server")(
289-
"seed", bpo::value<int>(&data.startSeed)->default_value(-1), "initial seed (default: -1 random)")(
289+
"seed", bpo::value<ULong_t>(&data.startSeed)->default_value(0L), "initial seed as ULong_t (default: 0 == random)")(
290290
"stop", bpo::value<bool>(&data.stop)->default_value(false), "control command to shut down daemon");
291291

292292
bpo::variables_map vm;

Common/Utils/include/CommonUtils/RngHelper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class RngHelper
3232
{
3333
public:
3434
// sets the state of the currently active ROOT gRandom Instance
35-
// if -1 (or negative) is given ... we will init with a random seed
35+
// if 0 is given ... we will init with a random seed
3636
// returns seed set to TRandom
37-
static unsigned int setGRandomSeed(int seed = -1)
37+
static ULong_t setGRandomSeed(ULong_t seed = 0)
3838
{
39-
unsigned int s = seed < 0 ? readURandom<unsigned int>() : seed;
39+
const auto s = seed == 0 ? readURandom<ULong_t>() : seed;
4040
gRandom->SetSeed(s);
4141
return s;
4242
}

DataFormats/simulation/include/SimulationDataFormat/PrimaryChunk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ struct SubEventInfo {
2929
int32_t runID = 0; // the runID of this run
3030
uint16_t part = 0; // which part of the eventID
3131
uint16_t nparts = 0; // out of how many parts
32-
uint32_t seed = 0; // seed for RNG
32+
uint64_t seed = 0; // seed for RNG
3333
uint32_t index = 0;
3434
int32_t npersistenttracks = -1; // the number of persistent tracks for this SubEvent (might be set to cache it)
3535
int32_t nprimarytracks = -1; // the number of primary tracks for this SubEvent
3636
// might add more fields (such as which process treated this chunk etc)
3737

3838
o2::dataformats::MCEventHeader mMCEventHeader; // associated FairMC header for vertex information
3939

40-
ClassDefNV(SubEventInfo, 1);
40+
ClassDefNV(SubEventInfo, 2);
4141
};
4242

4343
inline bool operator<(SubEventInfo const& a, SubEventInfo const& b)

run/O2PrimaryServerDevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class O2PrimaryServerDevice final : public fair::mq::Device
221221
LOG(info) << "CHUNK SIZE SET TO " << mChunkGranularity;
222222

223223
// initial initial seed --> we should store this somewhere
224-
mInitialSeed = vm["seed"].as<int>();
224+
mInitialSeed = vm["seed"].as<ULong_t>();
225225
mInitialSeed = o2::utils::RngHelper::setGRandomSeed(mInitialSeed);
226226
LOG(info) << "RNG INITIAL SEED " << mInitialSeed;
227227

@@ -556,7 +556,7 @@ class O2PrimaryServerDevice final : public fair::mq::Device
556556
int mPartCounter = 0;
557557
bool mNeedNewEvent = true;
558558
int mMaxEvents = 2;
559-
int mInitialSeed = -1;
559+
ULong_t mInitialSeed = 0;
560560
int mPipeToDriver = -1; // handle for direct piper to driver (to communicate meta info)
561561
int mEventCounter = 0;
562562

0 commit comments

Comments
 (0)