Skip to content

Commit

Permalink
Improvements for generating events from O2 kine file
Browse files Browse the repository at this point in the history
* optionally allow round-robin
* be able to give file name via config key params
  • Loading branch information
sawenzel committed Nov 21, 2023
1 parent 736f443 commit ecb1375
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Generators/include/Generators/GeneratorFromFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class GeneratorFromO2Kine : public o2::eventgen::Generator
int mEventsAvailable = 0;
bool mSkipNonTrackable = true; //! whether to pass non-trackable (decayed particles) to the MC stack
bool mContinueMode = false; //! whether we want to continue simulation of previously inhibited tracks
ClassDefOverride(GeneratorFromO2Kine, 1);
bool mRoundRobin = false; //! whether we want to take events from file in a round robin fashion
ClassDefOverride(GeneratorFromO2Kine, 2);
};

} // end namespace eventgen
Expand Down
2 changes: 2 additions & 0 deletions Generators/include/Generators/GeneratorFromO2KineParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace eventgen
struct GeneratorFromO2KineParam : public o2::conf::ConfigurableParamHelper<GeneratorFromO2KineParam> {
bool skipNonTrackable = true;
bool continueMode = false;
bool roundRobin = false; // read events with period boundary conditions
std::string fileName = ""; // filename to read from - takes precedence over SimConfig if given
O2ParamDef(GeneratorFromO2KineParam, "GeneratorFromO2Kine");
};

Expand Down
4 changes: 3 additions & 1 deletion Generators/src/GeneratorFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
LOG(info) << "using external kinematics";
} else if (genconfig.compare("extkinO2") == 0) {
// external kinematics from previous O2 output
auto extGen = new o2::eventgen::GeneratorFromO2Kine(conf.getExtKinematicsFileName().c_str());
auto name1 = GeneratorFromO2KineParam::Instance().fileName;
auto name2 = conf.getExtKinematicsFileName();
auto extGen = new o2::eventgen::GeneratorFromO2Kine(name1.size() > 0 ? name1.c_str() : name2.c_str());
extGen->SetStartEvent(conf.getStartEvent());
primGen->AddGenerator(extGen);
if (GeneratorFromO2KineParam::Instance().continueMode) {
Expand Down
5 changes: 5 additions & 0 deletions Generators/src/GeneratorFromFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ bool GeneratorFromO2Kine::Init()
LOG(info) << param;
mSkipNonTrackable = param.skipNonTrackable;
mContinueMode = param.continueMode;
mRoundRobin = param.roundRobin;

return true;
}
Expand Down Expand Up @@ -259,6 +260,10 @@ bool GeneratorFromO2Kine::importParticles()
particlecounter++;
}
mEventCounter++;
if (mRoundRobin) {
LOG(info) << "Resetting event counter to 0; Reusing events from file";
mEventCounter = mEventCounter % mEventsAvailable;
}

if (tracks) {
delete tracks;
Expand Down

0 comments on commit ecb1375

Please sign in to comment.