From 536e59060ade6da0723c8d437995c38181f12593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Wed, 22 Oct 2025 11:18:53 +0200 Subject: [PATCH 1/8] Changed minimum required version to 3.5 because of deprecated errors using newer CMAKE versions --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8615163..35b0f2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # CMAKE CONFIG -CMAKE_MINIMUM_REQUIRED( VERSION 2.6 FATAL_ERROR ) +CMAKE_MINIMUM_REQUIRED( VERSION 3.5 FATAL_ERROR ) project(RapidSim) set(CMAKE_VERBOSE_MAKEFILE ON) From 5262ff357a578ddc1cc6aad67c94560764743797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Wed, 22 Oct 2025 11:24:09 +0200 Subject: [PATCH 2/8] Changed all instances of gRandom->GetSeed() and gRandom->SetSeed() to gRandom->TRandom::GetSeed() / gRandom->TRandom::SetSeed() --- src/RapidConfig.cc | 6 +++--- src/RapidExternalEvtGen.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/RapidConfig.cc b/src/RapidConfig.cc index 2ba85f6..4af94ce 100644 --- a/src/RapidConfig.cc +++ b/src/RapidConfig.cc @@ -297,7 +297,7 @@ bool RapidConfig::loadDecay() { bool RapidConfig::loadConfig() { std::cout << "INFO in RapidConfig::loadConfig : attempting to load configuration from file: " << fileName_+".config" << std::endl; - gRandom->SetSeed(0.); + gRandom->TRandom::SetSeed(0.); std::ifstream fin; fin.open(fileName_+".config", std::ifstream::in); @@ -447,9 +447,9 @@ bool RapidConfig::configParticle(unsigned int part, TString command, TString val bool RapidConfig::configGlobal(TString command, TString value) { if(command=="seed") { int seed = value.Atoi(); - gRandom->SetSeed(seed); + gRandom->TRandom::SetSeed(seed); std::cout << "INFO in RapidConfig::configGlobal : setting seed for random number generation to " << seed << "." << std::endl - << " seed is now " << gRandom->GetSeed() << "." << std::endl; + << " seed is now " << gRandom->TRandom::GetSeed() << "." << std::endl; } else if(command=="acceptance") { std::cout << "INFO in RapidConfig::configGlobal : setting acceptance type to " << value << "." << std::endl; acceptanceType_ = RapidAcceptance::typeFromString(value); diff --git a/src/RapidExternalEvtGen.cc b/src/RapidExternalEvtGen.cc index 0c44beb..63405c1 100644 --- a/src/RapidExternalEvtGen.cc +++ b/src/RapidExternalEvtGen.cc @@ -124,7 +124,7 @@ bool RapidExternalEvtGen::setupGenerator() { std::list extraModels; // Define the random number generator - uint seed = gRandom->GetSeed(); + uint seed = gRandom->TRandom::GetSeed(); randomEngine = new EvtMTRandomEngine(seed); bool useEvtGenRandom(false); From a54f3e2ab7b4df019374fb553df53400eeb05edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Mon, 8 Dec 2025 17:09:58 +0100 Subject: [PATCH 3/8] Added 'nToSelect' argument that stops generation early if the number of event to select is reached. --- src/RapidSim.C | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/RapidSim.C b/src/RapidSim.C index 6ab24a2..c67218d 100644 --- a/src/RapidSim.C +++ b/src/RapidSim.C @@ -9,7 +9,7 @@ #include "RapidDecay.h" #include "RapidHistWriter.h" -int rapidSim(const TString mode, const int nEvtToGen, bool saveTree=false, int nToReDecay=0) { +int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1, bool saveTree=false, int nToReDecay=0) { clock_t t0,t1,t2; @@ -21,6 +21,21 @@ int rapidSim(const TString mode, const int nEvtToGen, bool saveTree=false, int n return 1; } + std::cout << "INFO in RapidSim : nEvtToGenerate set to " << nEvtToGen << std::endl; + + if(nEvtToSelect==-1) { + std::cout << "INFO in RapidSim : nEvtToSelect set to -1 --> will select all possible events" << std::endl + << " Specify nEvtToSelect if you want to limit the number of selected events" << std::endl; + nEvtToSelect = nEvtToGen; + } else if (nEvtToSelect>nEvtToGen) { + std::cout << "ERROR in RapidSim : nEvtToSelect (" << nEvtToSelect << ") is larger than nEvtToGenerate (" << nEvtToGen << ")" << std::endl + << " If you want to select as many events as possible, set nEvtToSelect to -1" << std::endl + << " Terminating" << std::endl; + return 1; + } else { + std::cout << "INFO in RapidSim : nEvtToSelect set to " << nEvtToSelect << std::endl; + } + TString configEnv=getenv("RAPIDSIM_CONFIG"); if(configEnv!="") { std::cout << "INFO in rapidSim : environment variable RAPIDSIM_CONFIG is set" << std::endl @@ -53,6 +68,7 @@ int rapidSim(const TString mode, const int nEvtToGen, bool saveTree=false, int n t1=clock(); int ngenerated = 0; int nselected = 0; + bool stopGeneration = false; for (Int_t n=0; nsetNEvent(n); if (!decay->generate()) continue; @@ -61,7 +77,12 @@ int rapidSim(const TString mode, const int nEvtToGen, bool saveTree=false, int n if(acceptance->isSelected()) { ++nselected; writer->fill(); + if (nselected>=nEvtToSelect) { + std::cout << "INFO in rapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; + stopGeneration = true; + } } + if (stopGeneration) break; for (Int_t nrd=0; nrdgenerate(false)) continue; @@ -71,7 +92,17 @@ int rapidSim(const TString mode, const int nEvtToGen, bool saveTree=false, int n ++nselected; writer->fill(); + if (nselected>=nEvtToSelect) { + std::cout << "INFO in rapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; + stopGeneration = true; + } + if (stopGeneration) break; } + if (stopGeneration) break; + } + if (nselected < nEvtToSelect && nEvtToSelect != -1) { + std::cout << "WARNING in rapidSim : Only selected " << nselected << " events out of requested " << nEvtToSelect << std::endl; + std::cout << " Consider increasing nEvtToGenerate" << std::endl; } writer->save(); @@ -89,23 +120,27 @@ int rapidSim(const TString mode, const int nEvtToGen, bool saveTree=false, int n int main(int argc, char * argv[]) { if (argc < 3) { - printf("Usage: %s mode numberToGenerate [saveTree=0] [numberToRedecay=0]\n", argv[0]); + printf("Usage: %s mode numberToGenerate [numberToSelect=-1 (select all possible events)] [saveTree=0] [numberToRedecay=0]\n", argv[0]); return 1; } const TString mode = argv[1]; - const int number = static_cast(atof(argv[2])); + const int numberToGenerate = static_cast(atoll(argv[2])); + signed int numberToSelect = numberToGenerate; bool saveTree = false; int nToReDecay = 0; if(argc>3) { - saveTree = atoi(argv[3]); + numberToSelect = static_cast(atoll(argv[3])); } if(argc>4) { - nToReDecay = atoi(argv[4]); + saveTree = atoi(argv[4]); + } + if(argc>5) { + nToReDecay = atoi(argv[5]); } - int status = rapidSim(mode, number, saveTree, nToReDecay); + int status = rapidSim(mode, numberToGenerate, numberToSelect, saveTree, nToReDecay); return status; } From 1e6e29d06ad800dd327819070cce4d0549ed57bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Mon, 8 Dec 2025 17:37:52 +0100 Subject: [PATCH 4/8] Update documentation + added checks --- README.md | 7 ++++--- src/RapidSim.C | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc065d7..87b99ce 100644 --- a/README.md +++ b/README.md @@ -38,19 +38,20 @@ $ # Setup the RAPIDSIM_ROOT environment variable (or add to .bashrc) $ export RAPIDSIM_ROOT= $ # Optionally setup the RAPIDSIM_CONFIG environment variable $ export RAPIDSIM_CONFIG=/path/to/additional/configuration/files -$ $RAPIDSIM_ROOT/build/src/RapidSim.exe +$ $RAPIDSIM_ROOT/build/src/RapidSim.exe ``` +If the max event to save/select is specified and >0, the generation will be stopped early if this number is reached. To run an example try: ```shell -$ $RAPIDSIM_ROOT/build/src/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 1 +$ $RAPIDSIM_ROOT/build/src/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 -1 1 ``` or ```shell -$ $RAPIDSIM_ROOT/bin/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 1 +$ $RAPIDSIM_ROOT/bin/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 -1 1 ``` To run the full system validation: diff --git a/src/RapidSim.C b/src/RapidSim.C index c67218d..3598ea7 100644 --- a/src/RapidSim.C +++ b/src/RapidSim.C @@ -21,6 +21,16 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 return 1; } + if(nEvtToGen==0) { + std::cout << "ERROR in RapidSim : nEvtToGenerate cannot be 0" << std::endl + << " Terminating" << std::endl; + return 1; + } else if (nEvtToGen<0) { + std::cout << "ERROR in RapidSim : nEvtToGenerate cannot be negative (" << nEvtToGen << ")" << std::endl + << " Terminating" << std::endl; + return 1; + } + std::cout << "INFO in RapidSim : nEvtToGenerate set to " << nEvtToGen << std::endl; if(nEvtToSelect==-1) { @@ -32,6 +42,14 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 << " If you want to select as many events as possible, set nEvtToSelect to -1" << std::endl << " Terminating" << std::endl; return 1; + } else if (nEvtToSelect < 0) { + std::cout << "ERROR in RapidSim : nEvtToSelect set to negative value other than -1 (" << nEvtToSelect << ")" << std::endl + << " Terminating" << std::endl; + return 1; + } else if (nEvtToSelect==0) { + std::cout << "ERROR in RapidSim : nEvtToSelect cannot be 0" << std::endl + << " Terminating" << std::endl; + return 1; } else { std::cout << "INFO in RapidSim : nEvtToSelect set to " << nEvtToSelect << std::endl; } From 48c4108ac9f9f673c86347d71811f4aa0cce920d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Tue, 9 Dec 2025 10:01:46 +0100 Subject: [PATCH 5/8] added gitignore to untrack the build folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file From 905fbbb60a60d64e653f51211e747d89e3edb614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Thu, 11 Dec 2025 11:48:53 +0100 Subject: [PATCH 6/8] changed argument order for backwards-compability + update README --- README.md | 10 +++++++--- src/RapidSim.C | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 87b99ce..46e65d9 100644 --- a/README.md +++ b/README.md @@ -38,20 +38,20 @@ $ # Setup the RAPIDSIM_ROOT environment variable (or add to .bashrc) $ export RAPIDSIM_ROOT= $ # Optionally setup the RAPIDSIM_CONFIG environment variable $ export RAPIDSIM_CONFIG=/path/to/additional/configuration/files -$ $RAPIDSIM_ROOT/build/src/RapidSim.exe +$ $RAPIDSIM_ROOT/build/src/RapidSim.exe ``` If the max event to save/select is specified and >0, the generation will be stopped early if this number is reached. To run an example try: ```shell -$ $RAPIDSIM_ROOT/build/src/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 -1 1 +$ $RAPIDSIM_ROOT/build/src/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 1 0 ``` or ```shell -$ $RAPIDSIM_ROOT/bin/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 -1 1 +$ $RAPIDSIM_ROOT/bin/RapidSim.exe $RAPIDSIM_ROOT/validation/Bs2Jpsiphi 10000 1 ``` To run the full system validation: @@ -322,6 +322,10 @@ EvtGen may be used to generate decays allowing for non-phasespace decay models. * Dan Craik 2016 * Matt Needham 2015 +## Additional contributions + + * Léa Dreyfus 2025 + [tgenphasespace]: https://root.cern.ch/doc/master/classTGenPhaseSpace.html [fonll]: http://cacciari.web.cern.ch/cacciari/fonll/ [fonll_dir]: rootfiles/fonll diff --git a/src/RapidSim.C b/src/RapidSim.C index 3598ea7..11d80c4 100644 --- a/src/RapidSim.C +++ b/src/RapidSim.C @@ -16,7 +16,7 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 t0=clock(); if(!getenv("RAPIDSIM_ROOT")) { - std::cout << "ERROR in rapidSim : environment variable RAPIDSIM_ROOT is not set" << std::endl + std::cout << "ERROR in RapidSim : environment variable RAPIDSIM_ROOT is not set" << std::endl << " Terminating" << std::endl; return 1; } @@ -51,31 +51,32 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 << " Terminating" << std::endl; return 1; } else { - std::cout << "INFO in RapidSim : nEvtToSelect set to " << nEvtToSelect << std::endl; + std::cout << "INFO in RapidSim : nEvtToSelect set to " << nEvtToSelect + << " --> will stop event loop early if this number is reached" << std::endl; } TString configEnv=getenv("RAPIDSIM_CONFIG"); if(configEnv!="") { - std::cout << "INFO in rapidSim : environment variable RAPIDSIM_CONFIG is set" << std::endl + std::cout << "INFO in RapidSim : environment variable RAPIDSIM_CONFIG is set" << std::endl << " Settings in " << configEnv << " will be used" << std::endl; } RapidConfig config; if(!config.load(mode)) { - std::cout << "ERROR in rapidSim : failed to load configuration for decay mode " << mode << std::endl + std::cout << "ERROR in RapidSim : failed to load configuration for decay mode " << mode << std::endl << " Terminating" << std::endl; return 1; } RapidDecay* decay = config.getDecay(); if(!decay) { - std::cout << "ERROR in rapidSim : failed to setup decay for decay mode " << mode << std::endl + std::cout << "ERROR in RapidSim : failed to setup decay for decay mode " << mode << std::endl << " Terminating" << std::endl; return 1; } if(nToReDecay>0) { - std::cout << "INFO in rapidSim : re-decay mode is active" << std::endl + std::cout << "INFO in RapidSim : re-decay mode is active" << std::endl << " Each parent will be re-decayed " << nToReDecay << " times" << std::endl; } @@ -96,7 +97,7 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 ++nselected; writer->fill(); if (nselected>=nEvtToSelect) { - std::cout << "INFO in rapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; + std::cout << "INFO in RapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; stopGeneration = true; } } @@ -111,26 +112,26 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 writer->fill(); if (nselected>=nEvtToSelect) { - std::cout << "INFO in rapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; + std::cout << "INFO in RapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; stopGeneration = true; } if (stopGeneration) break; } if (stopGeneration) break; } - if (nselected < nEvtToSelect && nEvtToSelect != -1) { - std::cout << "WARNING in rapidSim : Only selected " << nselected << " events out of requested " << nEvtToSelect << std::endl; - std::cout << " Consider increasing nEvtToGenerate" << std::endl; - } - + writer->save(); - + t2=clock(); - - std::cout << "INFO in rapidSim : Generated " << ngenerated << std::endl; - std::cout << "INFO in rapidSim : Selected " << nselected << std::endl; - std::cout << "INFO in rapidSim : " << (float(t1) - float(t0)) / CLOCKS_PER_SEC << " seconds to initialise." << std::endl; - std::cout << "INFO in rapidSim : " << (float(t2) - float(t1)) / CLOCKS_PER_SEC << " seconds to generate." << std::endl; + + std::cout << "INFO in RapidSim : Generated " << ngenerated << std::endl; + std::cout << "INFO in RapidSim : Selected " << nselected << std::endl; + if (nselected < nEvtToSelect && nEvtToSelect != -1) { + std::cout << "WARNING in RapidSim : Only selected " << nselected << " events out of requested " << nEvtToSelect << std::endl; + std::cout << " Consider increasing nEvtToGenerate" << std::endl; + } + std::cout << "INFO in RapidSim : " << (float(t1) - float(t0)) / CLOCKS_PER_SEC << " seconds to initialise." << std::endl; + std::cout << "INFO in RapidSim : " << (float(t2) - float(t1)) / CLOCKS_PER_SEC << " seconds to generate." << std::endl; return 0; } @@ -138,7 +139,7 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 int main(int argc, char * argv[]) { if (argc < 3) { - printf("Usage: %s mode numberToGenerate [numberToSelect=-1 (select all possible events)] [saveTree=0] [numberToRedecay=0]\n", argv[0]); + printf("Usage: %s mode numberToGenerate [saveTree=0] [numberToRedecay=0] [numberToSelect=-1 (select all possible events)]\n", argv[0]); return 1; } @@ -149,15 +150,15 @@ int main(int argc, char * argv[]) int nToReDecay = 0; if(argc>3) { - numberToSelect = static_cast(atoll(argv[3])); + saveTree = atoi(argv[3]); } if(argc>4) { - saveTree = atoi(argv[4]); + nToReDecay = atoi(argv[4]); } if(argc>5) { - nToReDecay = atoi(argv[5]); + numberToSelect = static_cast(atoll(argv[5])); } - + int status = rapidSim(mode, numberToGenerate, numberToSelect, saveTree, nToReDecay); return status; From 4e64dbfb6bc6a6c5875b2106a1438fb56f1acfc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Thu, 11 Dec 2025 16:42:36 +0100 Subject: [PATCH 7/8] changed base values of numberToSelect to -1 (convention for 'all possible') --- src/RapidSim.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RapidSim.C b/src/RapidSim.C index 11d80c4..262ecd0 100644 --- a/src/RapidSim.C +++ b/src/RapidSim.C @@ -145,7 +145,7 @@ int main(int argc, char * argv[]) const TString mode = argv[1]; const int numberToGenerate = static_cast(atoll(argv[2])); - signed int numberToSelect = numberToGenerate; + signed int numberToSelect = -1; bool saveTree = false; int nToReDecay = 0; From 7da80850f5f658a94c23f994b2e6372f784ca54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Fri, 12 Dec 2025 22:38:59 +0100 Subject: [PATCH 8/8] minor change for cleaner log --- src/RapidSim.C | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/RapidSim.C b/src/RapidSim.C index 262ecd0..22a84a6 100644 --- a/src/RapidSim.C +++ b/src/RapidSim.C @@ -36,7 +36,6 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 if(nEvtToSelect==-1) { std::cout << "INFO in RapidSim : nEvtToSelect set to -1 --> will select all possible events" << std::endl << " Specify nEvtToSelect if you want to limit the number of selected events" << std::endl; - nEvtToSelect = nEvtToGen; } else if (nEvtToSelect>nEvtToGen) { std::cout << "ERROR in RapidSim : nEvtToSelect (" << nEvtToSelect << ") is larger than nEvtToGenerate (" << nEvtToGen << ")" << std::endl << " If you want to select as many events as possible, set nEvtToSelect to -1" << std::endl @@ -96,7 +95,7 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 if(acceptance->isSelected()) { ++nselected; writer->fill(); - if (nselected>=nEvtToSelect) { + if (nselected>=nEvtToSelect && nEvtToSelect != -1) { std::cout << "INFO in RapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; stopGeneration = true; } @@ -111,7 +110,7 @@ int rapidSim(const TString mode, const int nEvtToGen, signed int nEvtToSelect=-1 ++nselected; writer->fill(); - if (nselected>=nEvtToSelect) { + if (nselected>=nEvtToSelect && nEvtToSelect != -1) { std::cout << "INFO in RapidSim : Selected " << nselected << " events. Stopping generation early." << std::endl; stopGeneration = true; }