Skip to content

Commit d1a8157

Browse files
committed
Revert "Various improvements"
This reverts commit 4b6530f.
1 parent fdce086 commit d1a8157

File tree

9 files changed

+220
-214
lines changed

9 files changed

+220
-214
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct SimConfigData {
5252
std::vector<std::string> mActiveModules; // list of active modules
5353
std::vector<std::string> mReadoutDetectors; // list of readout detectors
5454
std::string mMCEngine; // chosen VMC engine
55+
bool mNoLoopers = false; // Disable automatic TPC loopers
5556
std::string mGenerator; // chosen VMC generator
5657
std::string mTrigger; // chosen VMC generator trigger
5758
unsigned int mNEvents; // number of events to be simulated
@@ -138,6 +139,8 @@ class SimConfig
138139
// get selected active detectors
139140
std::vector<std::string> const& getActiveModules() const { return mConfigData.mActiveModules; }
140141
std::vector<std::string> const& getReadoutDetectors() const { return mConfigData.mReadoutDetectors; }
142+
// get loopers veto
143+
bool getLoopersVeto() const { return mConfigData.mNoLoopers; }
141144

142145
// static helper functions to determine list of active / readout modules
143146
// can also be used from outside

Common/SimConfig/src/SimConfig.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void SimConfig::initOptions(boost::program_options::options_description& options
7474
"run", bpo::value<int>()->default_value(-1), "ALICE run number")(
7575
"asservice", bpo::value<bool>()->default_value(false), "run in service/server mode")(
7676
"noGeant", bpo::bool_switch(), "prohibits any Geant transport/physics (by using tight cuts)")(
77+
"noLoopers", bpo::bool_switch(), "disable automatic TPC loopers")(
7778
"forwardKine", bpo::bool_switch(), "forward kinematics on a FairMQ channel")(
7879
"noDiscOutput", bpo::bool_switch(), "switch off writing sim results to disc (useful in combination with forwardKine)");
7980
options.add_options()("fromCollContext", bpo::value<std::string>()->default_value(""), "Use a pregenerated collision context to infer number of events to simulate, how to embedd them, the vertex position etc. Takes precedence of other options such as \"--nEvents\". The format is COLLISIONCONTEXTFILE.root[:SIGNALNAME] where SIGNALNAME is the event part in the context which is relevant.");
@@ -297,6 +298,7 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
297298
using o2::detectors::DetID;
298299
mConfigData.mMCEngine = vm["mcEngine"].as<std::string>();
299300
mConfigData.mNoGeant = vm["noGeant"].as<bool>();
301+
mConfigData.mNoLoopers = vm["noLoopers"].as<bool>();
300302

301303
// Reset modules and detectors as they are anyway re-parsed
302304
mConfigData.mReadoutDetectors.clear();

Generators/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if(HepMC3_FOUND)
6767
endif()
6868

6969
if(onnxruntime_FOUND)
70-
target_compile_definitions(${targetName} PUBLIC GENERATORS_WITH_TPCLOOPERS)
70+
target_compile_definitions(${targetName} PUBLIC GENERATORS_WITH_ONNXRUNTIME)
7171
endif()
7272

7373
set(headers
@@ -96,7 +96,7 @@ set(headers
9696
)
9797

9898
if(onnxruntime_FOUND)
99-
list(APPEND headers
99+
list(APPEND headers
100100
include/Generators/TPCLoopers.h
101101
include/Generators/TPCLoopersParam.h)
102102
endif()

Generators/include/Generators/Generator.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include "FairGenerator.h"
1818
#include "TParticle.h"
1919
#include "Generators/Trigger.h"
20-
#include "CCDB/BasicCCDBManager.h"
21-
#ifdef GENERATORS_WITH_TPCLOOPERS
20+
#ifdef GENERATORS_WITH_ONNXRUNTIME
2221
#include "Generators/TPCLoopers.h"
2322
#include "Generators/TPCLoopersParam.h"
2423
#endif
@@ -78,7 +77,7 @@ class Generator : public FairGenerator
7877
/** methods to override **/
7978
virtual Bool_t generateEvent() = 0; // generates event (in structure internal to generator)
8079
virtual Bool_t importParticles() = 0; // fills the mParticles vector (transfer from generator state)
81-
Bool_t finalizeEvent(); // final part of event generation that can be customised using external macros
80+
Bool_t loopers(); // adds loopers to the event in case TPC is used
8281
virtual void updateHeader(o2::dataformats::MCEventHeader* eventHeader) {};
8382
Bool_t triggerEvent();
8483

@@ -161,7 +160,7 @@ class Generator : public FairGenerator
161160
void updateSubGeneratorInformation(o2::dataformats::MCEventHeader* header) const;
162161

163162
// loopers flag
164-
Bool_t mAddTPCLoopers = kFALSE; // Flag is automatically set to true if TPC is in readout detectors, loopers are not vetoed and transport is enabled
163+
Bool_t mAddLoopers = kFALSE;
165164
// collect an ID and a short description of sub-generator entities
166165
std::unordered_map<int, std::string> mSubGeneratorsIdToDesc;
167166
// the current ID of the sub-generator used in the current event (if applicable)
@@ -170,11 +169,11 @@ class Generator : public FairGenerator
170169
// global static information about (upper limit of) number of events to be generated
171170
static unsigned int gTotalNEvents;
172171

173-
#ifdef GENERATORS_WITH_TPCLOOPERS
172+
#ifdef GENERATORS_WITH_ONNXRUNTIME
174173
// Loopers generator instance
175174
std::unique_ptr<o2::eventgen::GenTPCLoopers> mLoopersGen = nullptr;
176-
void initLoopersGen();
177175
#endif
176+
void initLoopersGen();
178177

179178
ClassDefOverride(Generator, 2);
180179

Generators/include/Generators/TPCLoopersParam.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ namespace eventgen
2828
** allow the user to modify them
2929
**/
3030
struct GenTPCLoopersParam : public o2::conf::ConfigurableParamHelper<GenTPCLoopersParam> {
31-
bool loopersVeto = false; // if true, no loopers are generated
3231
std::string model_pairs = "ccdb://Users/m/mgiacalo/WGAN_ExtGenPair"; // ONNX model for e+e- pair production
3332
std::string model_compton = "ccdb://Users/m/mgiacalo/WGAN_ExtGenCompton"; // ONNX model for Compton scattering
3433
std::string poisson = "${O2_ROOT}/share/Generators/egconfig/poisson_params.csv"; // file with Poissonian parameters
@@ -38,8 +37,8 @@ struct GenTPCLoopersParam : public o2::conf::ConfigurableParamHelper<GenTPCLoope
3837
bool flat_gas = true; // if true, the gas density is considered flat in the TPC volume
3938
int nFlatGasLoopers = 500; // number of loopers to be generated per event in case of flat gas
4039
float fraction_pairs = 0.08; // fraction of loopers
41-
float multiplier[2] = {1., 1.}; // multiplier for pairs and compton loopers for Poissonian and Gaussian sampling
42-
unsigned int fixedNLoopers[2] = {1, 1}; // fixed number of loopers coming from pairs and compton electrons - valid if flat gas is false and both Poisson and Gaussian params files are empty
40+
std::array<float, 2> multiplier = {1., 1.}; // multiplier for pairs and compton loopers for Poissonian and Gaussian sampling
41+
std::array<unsigned int, 2> fixedNLoopers = {1, 1}; // fixed number of loopers coming from pairs and compton electrons - valid if flat gas is false and both Poisson and Gaussian params files are empty
4342
O2ParamDef(GenTPCLoopersParam, "GenTPCLoopers");
4443
};
4544

Generators/include/TPCLoopers.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef ALICEO2_EVENTGEN_TPCLOOPERS_H_
22
#define ALICEO2_EVENTGEN_TPCLOOPERS_H_
33

4-
#ifdef GENERATORS_WITH_TPCLOOPERS
4+
#ifdef GENERATORS_WITH_ONNXRUNTIME
55
#include <onnxruntime_cxx_api.h>
66
#endif
77
#include <iostream>
@@ -19,10 +19,12 @@
1919
#include "TParticle.h"
2020
#include <filesystem>
2121

22-
#ifdef GENERATORS_WITH_TPCLOOPERS
22+
#ifdef GENERATORS_WITH_ONNXRUNTIME
2323
// Static Ort::Env instance for multiple onnx model loading
2424
extern Ort::Env global_env;
25+
#endif
2526

27+
#ifdef GENERATORS_WITH_ONNXRUNTIME
2628
// This class is responsible for loading the scaler parameters from a JSON file
2729
// and applying the inverse transformation to the generated data.
2830
struct Scaler
@@ -53,14 +55,14 @@ class ONNXGenerator
5355
Ort::Session session;
5456
TRandom3 rand_gen;
5557
};
56-
#endif // GENERATORS_WITH_TPCLOOPERS
58+
#endif // GENERATORS_WITH_ONNXRUNTIME
5759

5860
namespace o2
5961
{
6062
namespace eventgen
6163
{
6264

63-
#ifdef GENERATORS_WITH_TPCLOOPERS
65+
#ifdef GENERATORS_WITH_ONNXRUNTIME
6466
class GenTPCLoopers
6567
{
6668
public:
@@ -117,7 +119,7 @@ class GenTPCLoopers
117119
double mTimeEnd = 0.0; // Time limit for the last event
118120
float mLoopsFractionPairs = 0.08; // Fraction of loopers from Pairs
119121
};
120-
#endif // GENERATORS_WITH_TPCLOOPERS
122+
#endif // GENERATORS_WITH_ONNXRUNTIME
121123

122124
} // namespace eventgen
123125
} // namespace o2

0 commit comments

Comments
 (0)