fix for seed
This commit is contained in:
+8
-4
@@ -152,8 +152,9 @@ def _run_mini_batch(
|
||||
from G4Calo import __G4System
|
||||
G4System = __G4System()
|
||||
seed = int(batch_seed + counter)
|
||||
#truncate to 32 bit, lower 32 bit are used in G4
|
||||
seed = seed & 0xFFFFFFFF
|
||||
|
||||
print(f"Running mini batch with seed {seed}")
|
||||
|
||||
G4System.init(cw, seed) #counter gives random seed offset
|
||||
|
||||
df = G4System.run_batch(nEvents, particleSpec, minEnergy_GeV, maxEnergy_GeV,"")
|
||||
@@ -188,8 +189,11 @@ def run_batch(
|
||||
|
||||
nevents = [nEventsPerCore if i < nCores - 1 else nEventsLastCore for i in range(nCores)]
|
||||
|
||||
batch_seed = int(time.time()*1000)
|
||||
|
||||
batch_seed = int(time.time()) #this is seconds
|
||||
# make sure that the seed is different for next run. This is not perfect but should be good enough
|
||||
# given the course takes a week this should be sufficient (10^7 seconds ~ 4 months)
|
||||
time.sleep(1)
|
||||
batch_seed = batch_seed % 10000000
|
||||
print(f"Batch seed: {batch_seed}")
|
||||
#use a multiprocessing pool to run the mini batches in parallel
|
||||
with multiprocessing.Pool(nCores) as pool:
|
||||
|
||||
Reference in New Issue
Block a user