Skip to content

Commit 5b5f4b4

Browse files
committed
Fix and improve TPC Loopers implementation
1 parent ee2b995 commit 5b5f4b4

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

Generators/include/Generators/Generator.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
#include "FairGenerator.h"
1818
#include "TParticle.h"
1919
#include "Generators/Trigger.h"
20-
#ifdef GENERATORS_WITH_TPCLOOPERS
21-
#include "Generators/TPCLoopers.h"
22-
#include "Generators/TPCLoopersParam.h"
23-
#endif
2420
#include <functional>
2521
#include <vector>
2622
#include <unordered_map>
@@ -38,6 +34,8 @@ namespace o2
3834
namespace eventgen
3935
{
4036

37+
class GenTPCLoopers; // Forward declaration
38+
4139
/*****************************************************************/
4240
/*****************************************************************/
4341

@@ -60,7 +58,7 @@ class Generator : public FairGenerator
6058
/** constructor **/
6159
Generator(const Char_t* name, const Char_t* title = "ALICEo2 Generator");
6260
/** destructor **/
63-
~Generator() override = default;
61+
~Generator() override;
6462

6563
/** Initialize the generator if needed **/
6664
Bool_t Init() override;
@@ -169,9 +167,9 @@ class Generator : public FairGenerator
169167
// global static information about (upper limit of) number of events to be generated
170168
static unsigned int gTotalNEvents;
171169

172-
#ifdef GENERATORS_WITH_TPCLOOPERS
173170
// Loopers generator instance
174-
std::unique_ptr<o2::eventgen::GenTPCLoopers> mTPCLoopersGen = nullptr;
171+
o2::eventgen::GenTPCLoopers* mTPCLoopersGen = nullptr;
172+
#ifdef GENERATORS_WITH_TPCLOOPERS
175173
bool initTPCLoopersGen();
176174
#endif
177175

Generators/include/Generators/TPCLoopers.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
#ifdef GENERATORS_WITH_TPCLOOPERS
1818
#include <onnxruntime_cxx_api.h>
19-
#endif
2019
#include <vector>
2120
#include <rapidjson/document.h>
2221
#include "TRandom3.h"
2322
#include <SimulationDataFormat/DigitizationContext.h>
2423
#include "TParticle.h"
2524

26-
#ifdef GENERATORS_WITH_TPCLOOPERS
2725
// Static Ort::Env instance for multiple onnx model loading
2826
extern Ort::Env global_env;
2927

Generators/src/Generator.cxx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include "TGrid.h"
2828
#include "CCDB/BasicCCDBManager.h"
2929
#include <filesystem>
30+
#ifdef GENERATORS_WITH_TPCLOOPERS
31+
#include "Generators/TPCLoopers.h"
32+
#include "Generators/TPCLoopersParam.h"
33+
#endif
3034

3135
namespace o2
3236
{
@@ -94,6 +98,16 @@ Generator::Generator(const Char_t* name, const Char_t* title) : FairGenerator(na
9498
#endif
9599
}
96100

101+
/*****************************************************************/
102+
103+
Generator::~Generator()
104+
{
105+
/** destructor **/
106+
#ifdef GENERATORS_WITH_TPCLOOPERS
107+
delete mTPCLoopersGen;
108+
#endif
109+
}
110+
97111
/*****************************************************************/
98112
#ifdef GENERATORS_WITH_TPCLOOPERS
99113
bool Generator::initTPCLoopersGen()
@@ -171,7 +185,7 @@ bool Generator::initTPCLoopersGen()
171185
nclxrate = isAlien[2] || isCCDB[2] ? local_names[2] : nclxrate;
172186
try {
173187
// Create the TPC loopers generator with the provided parameters
174-
mTPCLoopersGen = std::make_unique<o2::eventgen::GenTPCLoopers>(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
188+
mTPCLoopersGen = new o2::eventgen::GenTPCLoopers(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
175189
const auto& intrate = loopersParam.intrate;
176190
// Configure the generator with flat gas loopers defined per orbit with clusters/track info
177191
// If intrate is negative (default), automatic IR from collisioncontext.root will be used
@@ -188,7 +202,8 @@ bool Generator::initTPCLoopersGen()
188202
LOG(info) << "TPC Loopers generator initialized successfully";
189203
} catch (const std::exception& e) {
190204
LOG(error) << "Failed to initialize TPC Loopers generator: " << e.what();
191-
mTPCLoopersGen.reset();
205+
delete mTPCLoopersGen;
206+
mTPCLoopersGen = nullptr;
192207
}
193208
return kTRUE;
194209
}

0 commit comments

Comments
 (0)