Skip to content

Commit

Permalink
Refined way to generate random seed (#1841)
Browse files Browse the repository at this point in the history
* Enable DPMJET

* Refined seeding

* Split of Dpmjet processe and fix in decay tables
  • Loading branch information
mbroz84 authored Dec 12, 2024
1 parent 2f69c38 commit 920b341
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Decay tau+
0.25 pi+ anti-nu_tau TAUSCALARNU; #[Reconstructed PDG2011]
0.25 pi+ pi0 anti-nu_tau TAUHADNU -0.108 0.775 0.149 1.364 0.400; #[Reconstructed PDG2011]
0.25 pi0 pi0 pi+ anti-nu_tau TAUHADNU -0.108 0.775 0.149 1.364 0.400 1.23 0.4; #[Reconstructed PDG2011]
0.25 anti-nu_tau pi+ pi0 pi0 pi0 PYTHIA 41; #[Reconstructed PDG2011]
0.25 anti-nu_tau pi+ pi0 pi0 pi0 PHSP; #[Reconstructed PDG2011]
Enddecay
End
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Decay tau-
0.25 pi- nu_tau TAUSCALARNU; #[Reconstructed PDG2011]
0.25 pi- pi0 nu_tau TAUHADNU -0.108 0.775 0.149 1.364 0.400; #[Reconstructed PDG2011]
0.25 pi0 pi0 pi- nu_tau TAUHADNU -0.108 0.775 0.149 1.364 0.400 1.23 0.4; #[Reconstructed PDG2011]
0.25 nu_tau pi- pi0 pi0 pi0 PYTHIA 41; #[Reconstructed PDG2011]
0.25 nu_tau pi- pi0 pi0 pi0 PHSP; #[Reconstructed PDG2011]
Enddecay
End
34 changes: 24 additions & 10 deletions MC/config/PWGUD/external/generator/GeneratorStarlight.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ R__ADD_INCLUDE_PATH($STARlight_ROOT/include)

// usage: o2-sim -g external --configKeyValues 'GeneratorExternal.fileName=GeneratorStarlight.C;GeneratorExternal.funcName=GeneratorStarlight("kCohJpsiToMu")'

unsigned int generateRandomSeed() {
// Use high-resolution clock for time-based seed
auto timeNow = std::chrono::high_resolution_clock::now();
auto timeSeed = static_cast<unsigned int>(timeNow.time_since_epoch().count());

// Random device for system entropy
std::random_device rd;

// Add process ID and thread ID for additional entropy
unsigned int pid = static_cast<unsigned int>(getpid());
unsigned int tid = static_cast<unsigned int>(std::hash<std::thread::id>()(std::this_thread::get_id()));

// Combine all entropy sources
unsigned int seed = timeSeed ^ (rd() << 1) ^ (pid << 2) ^ (tid << 3);
return seed;
}

namespace o2
{
namespace eventgen
Expand Down Expand Up @@ -104,7 +121,8 @@ class GeneratorStarlight_class : public Generator
{"kIncohPsi2sToElPi", 4, 444011, 20, -1.0, -1.0, 100443, 1 }, //
{"kIncohUpsilonToMu", 4, 553013, 20, -1.0, -1.0, 553, 0 }, //
{"kIncohUpsilonToEl", 4, 553011, 20, -1.0, -1.0, 553, 0 }, //
{"kDpmjetSingle", 5, 113, 20, -1.0, -1.0, -1, 0 }, //
{"kDpmjetSingleA", 5, 113, 20, -1.0, -1.0, -1, 0 }, //
{"kDpmjetSingleC", 5, 113, 20, -1.0, -1.0, -1, 0 }, //
{"kTauLowToEl3Pi", 1, 15, 990, 3.5, 20.0, -1, 1 }, // from 0.4 to 15 GeV
{"kTauLowToPo3Pi", 1, 15, 990, 3.5, 20.0, -1, 1 }, // from 0.4 to 15 GeV
{"kTauLowToElMu", 1, 15, 990, 3.5, 20.0, -1, 1 }, // from 0.4 to 15 GeV
Expand All @@ -128,12 +146,9 @@ class GeneratorStarlight_class : public Generator

mPdgMother = slConfig[idx].pdg_mother;
mDecayEvtGen = slConfig[idx].decay_EvtGen;

uint random_seed;
unsigned long long int random_value = 0;
ifstream urandom("/dev/urandom", ios::in|ios::binary);
urandom.read(reinterpret_cast<char*>(&random_value), sizeof(random_seed));


unsigned int random_seed = generateRandomSeed();

setParameter(Form("BEAM_1_Z = %3i #Z of target",targZ));
setParameter(Form("BEAM_1_A = %3i #A of target",targA));
setParameter(Form("BEAM_2_Z = %3i #Z of projectile",projZ));
Expand Down Expand Up @@ -278,7 +293,7 @@ class GeneratorStarlight_class : public Generator
-1,
slPart->GetPx(),
slPart->GetPy(),
slPart->GetPz(),
(mSelectedConfiguration.compare("kDpmjetSingleC") == 0 ? -1.0*slPart->GetPz() : slPart->GetPz()),
slPart->GetE(),
vtx,vty,vtz,vtt);
//particle.Print();
Expand Down Expand Up @@ -321,8 +336,7 @@ FairGenerator*
system(TString::Format("cp %s ./my.input",dpmjetconf.c_str()));

//Reset four seeds of the DPMJET random generator in the config
std::random_device rd;
std::mt19937 gen(rd());
std::mt19937 gen(generateRandomSeed());
std::uniform_int_distribution<> dist(1, 168);

std::string command = "awk -i inplace -v nums=\"";
Expand Down
2 changes: 1 addition & 1 deletion MC/config/PWGUD/ini/makeStarlightConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
parser.add_argument('--rapidity', default='cent', choices=['cent_rap', 'muon_rap', 'cent_eta', 'muon_eta'],
help='Rapidity to select')

parser.add_argument('--process',default=None, choices=['kTwoGammaToMuLow', 'kTwoGammaToElLow', 'kTwoGammaToMuMedium', 'kTwoGammaToElMedium', 'kTwoGammaToMuHigh', 'kTwoGammaToElHigh', 'kTwoGammaToRhoRho', 'kTwoGammaToF2', 'kCohRhoToPi', 'kCohRhoToElEl', 'kCohRhoToMuMu', 'kCohRhoToPiWithCont', 'kCohRhoToPiFlat', 'kCohPhiToKa', 'kDirectPhiToKaKa', 'kCohPhiToEl', 'kCohOmegaTo2Pi', 'kCohOmegaTo3Pi', 'kCohOmegaToPiPiPi', 'kCohRhoPrimeTo4Pi', 'kCohJpsiToMu', 'kCohJpsiToEl', 'kCohJpsiToElRad', 'kCohJpsiToProton', 'kCohPsi2sToMu','kCohPsi2sToEl', 'kCohPsi2sToMuPi', 'kCohPsi2sToElPi', 'kCohUpsilonToMu', 'kCohUpsilonToEl', 'kIncohRhoToPi', 'kIncohRhoToElEl', 'kIncohRhoToMuMu', 'kIncohRhoToPiWithCont', 'kIncohRhoToPiFlat', 'kIncohPhiToKa', 'kIncohOmegaTo2Pi', 'kIncohOmegaTo3Pi', 'kIncohOmegaToPiPiPi', 'kIncohRhoPrimeTo4Pi', 'kIncohJpsiToMu', 'kIncohJpsiToEl', 'kIncohJpsiToElRad', 'kIncohJpsiToProton', 'kIncohJpsiToLLbar', 'kIncohPsi2sToMu', 'kIncohPsi2sToEl', 'kIncohPsi2sToMuPi', 'kIncohPsi2sToElPi', 'kIncohUpsilonToMu', 'kIncohUpsilonToEl', 'kDpmjetSingle', 'kTauLowToEl3Pi', 'kTauLowToPo3Pi', 'kTauMediumToEl3Pi', 'kTauMediumToPo3Pi', 'kTauHighToEl3Pi', 'kTauHighToPo3Pi', 'kTauLowToElMu', 'kTauLowToElPiPi0', 'kTauLowToPoPiPi0'],
parser.add_argument('--process',default=None, choices=['kTwoGammaToMuLow', 'kTwoGammaToElLow', 'kTwoGammaToMuMedium', 'kTwoGammaToElMedium', 'kTwoGammaToMuHigh', 'kTwoGammaToElHigh', 'kTwoGammaToRhoRho', 'kTwoGammaToF2', 'kCohRhoToPi', 'kCohRhoToElEl', 'kCohRhoToMuMu', 'kCohRhoToPiWithCont', 'kCohRhoToPiFlat', 'kCohPhiToKa', 'kDirectPhiToKaKa', 'kCohPhiToEl', 'kCohOmegaTo2Pi', 'kCohOmegaTo3Pi', 'kCohOmegaToPiPiPi', 'kCohRhoPrimeTo4Pi', 'kCohJpsiToMu', 'kCohJpsiToEl', 'kCohJpsiToElRad', 'kCohJpsiToProton', 'kCohPsi2sToMu','kCohPsi2sToEl', 'kCohPsi2sToMuPi', 'kCohPsi2sToElPi', 'kCohUpsilonToMu', 'kCohUpsilonToEl', 'kIncohRhoToPi', 'kIncohRhoToElEl', 'kIncohRhoToMuMu', 'kIncohRhoToPiWithCont', 'kIncohRhoToPiFlat', 'kIncohPhiToKa', 'kIncohOmegaTo2Pi', 'kIncohOmegaTo3Pi', 'kIncohOmegaToPiPiPi', 'kIncohRhoPrimeTo4Pi', 'kIncohJpsiToMu', 'kIncohJpsiToEl', 'kIncohJpsiToElRad', 'kIncohJpsiToProton', 'kIncohJpsiToLLbar', 'kIncohPsi2sToMu', 'kIncohPsi2sToEl', 'kIncohPsi2sToMuPi', 'kIncohPsi2sToElPi', 'kIncohUpsilonToMu', 'kIncohUpsilonToEl', 'kDpmjetSingleA', 'kDpmjetSingleC', 'kTauLowToEl3Pi', 'kTauLowToPo3Pi', 'kTauMediumToEl3Pi', 'kTauMediumToPo3Pi', 'kTauHighToEl3Pi', 'kTauHighToPo3Pi', 'kTauLowToElMu', 'kTauLowToElPiPi0', 'kTauLowToPoPiPi0'],
help='Process to switch on')


Expand Down

0 comments on commit 920b341

Please sign in to comment.