@@ -28,8 +28,8 @@ GeneratorHybrid::GeneratorHybrid(const std::string& inputgens)
2828 LOG (fatal) << " Number of configurations does not match the number of generators" ;
2929 exit (1 );
3030 }
31- if (mConfigs .size () == 0 ){
32- for (auto gen : mInputGens ){
31+ if (mConfigs .size () == 0 ) {
32+ for (auto gen : mInputGens ) {
3333 mConfigs .push_back (" " );
3434 }
3535 }
@@ -40,16 +40,15 @@ GeneratorHybrid::GeneratorHybrid(const std::string& inputgens)
4040 return ;
4141 }
4242 // Check if all elements of mFractions are 0
43- if (std::all_of (mFractions .begin (), mFractions .end (), [](int i){ return i == 0 ; })) {
43+ if (std::all_of (mFractions .begin (), mFractions .end (), [](int i) { return i == 0 ; })) {
4444 LOG (fatal) << " All fractions provided are 0, no simulation will be performed" ;
4545 return ;
4646 }
4747 }
4848 for (auto gen : mInputGens ) {
4949 // Search if the generator name is inside generatorNames (which is a vector of strings)
5050 LOG (info) << " Checking if generator " << gen << " is in the list of available generators \n " ;
51- if (std::find (generatorNames.begin (), generatorNames.end (), gen) != generatorNames.end ())
52- {
51+ if (std::find (generatorNames.begin (), generatorNames.end (), gen) != generatorNames.end ()) {
5352 LOG (info) << " Found generator " << gen << " in the list of available generators \n " ;
5453 if (gen.compare (" boxgen" ) == 0 ) {
5554 if (mConfigs [index].compare (" " ) == 0 ) {
@@ -64,15 +63,14 @@ GeneratorHybrid::GeneratorHybrid(const std::string& inputgens)
6463 // Check if mConfigs[index] contains pythia8_ and a number
6564 if (mConfigs [index].compare (" " ) == 0 ) {
6665 gens.push_back (std::make_unique<o2::eventgen::GeneratorPythia8>());
67- }
68- else {
66+ } else {
6967 // Get the index of pythia8 configuration
7068 int confPythia8Index = std::stoi (mConfigs [index].substr (8 ));
7169 gens.push_back (std::make_unique<o2::eventgen::GeneratorPythia8>(*mPythia8GenConfigs [confPythia8Index]));
7270 }
7371 mConfsPythia8 .push_back (mConfigs [index]);
7472 mGens .push_back (gen);
75- } else if (gen.compare (" extkinO2" ) == 0 ){
73+ } else if (gen.compare (" extkinO2" ) == 0 ) {
7674 int confO2KineIndex = std::stoi (mConfigs [index].substr (9 ));
7775 gens.push_back (std::make_unique<o2::eventgen::GeneratorFromO2Kine>(*mO2KineGenConfigs [confO2KineIndex]));
7876 mGens .push_back (gen);
@@ -106,8 +104,7 @@ Bool_t GeneratorHybrid::Init()
106104{
107105 // init all sub-gens
108106 int count = 0 ;
109- for (auto & gen : mGens )
110- {
107+ for (auto & gen : mGens ) {
111108 if (gen == " pythia8pp" ) {
112109 auto config = std::string (std::getenv (" O2_ROOT" )) + " /share/Generators/egconfig/pythia8_inel.cfg" ;
113110 LOG (info) << " Setting \' Pythia8\' base configuration: " << config << std::endl;
@@ -134,28 +131,28 @@ Bool_t GeneratorHybrid::Init()
134131
135132Bool_t GeneratorHybrid::generateEvent ()
136133{
137- // Order randomisation or sequence of generators
138- // following provided fractions, if not generators are used in proper sequence
139- if (mRandomize ) {
140- mIndex = gRandom ->Integer (mGens .size ());
141- } else {
142- while (mFractions [mCurrentFraction ] == 0 || mseqCounter == mFractions [mCurrentFraction ]) {
143- if (mFractions [mCurrentFraction ] != 0 )
144- mseqCounter = 0 ;
145- mCurrentFraction = (mCurrentFraction + 1 ) % mFractions .size ();
146- }
147- mIndex = mCurrentFraction ;
134+ // Order randomisation or sequence of generators
135+ // following provided fractions, if not generators are used in proper sequence
136+ if (mRandomize ) {
137+ mIndex = gRandom ->Integer (mGens .size ());
138+ } else {
139+ while (mFractions [mCurrentFraction ] == 0 || mseqCounter == mFractions [mCurrentFraction ]) {
140+ if (mFractions [mCurrentFraction ] != 0 )
141+ mseqCounter = 0 ;
142+ mCurrentFraction = (mCurrentFraction + 1 ) % mFractions .size ();
148143 }
149- if (mConfigs [mIndex ].compare (" " ) == 0 )
150- LOG (info) << " GeneratorHybrid: generating event with generator " << mGens [mIndex ];
151- else
152- LOG (info) << " GeneratorHybrid: generating event with generator " << mConfigs [mIndex ];
153- gens[mIndex ]->clearParticles (); // clear container of this class
154- gens[mIndex ]->generateEvent ();
155- // notify the sub event generator
156- notifySubGenerator (mIndex );
157- mseqCounter++;
158- return true ;
144+ mIndex = mCurrentFraction ;
145+ }
146+ if (mConfigs [mIndex ].compare (" " ) == 0 )
147+ LOG (info) << " GeneratorHybrid: generating event with generator " << mGens [mIndex ];
148+ else
149+ LOG (info) << " GeneratorHybrid: generating event with generator " << mConfigs [mIndex ];
150+ gens[mIndex ]->clearParticles (); // clear container of this class
151+ gens[mIndex ]->generateEvent ();
152+ // notify the sub event generator
153+ notifySubGenerator (mIndex );
154+ mseqCounter++;
155+ return true ;
159156}
160157
161158Bool_t GeneratorHybrid::importParticles ()
@@ -165,8 +162,7 @@ Bool_t GeneratorHybrid::importParticles()
165162 std::copy (gens[mIndex ]->getParticles ().begin (), gens[mIndex ]->getParticles ().end (), std::back_insert_iterator (mParticles ));
166163
167164 // we need to fix particles statuses --> need to enforce this on the importParticles level of individual generators
168- for (auto & p : mParticles )
169- {
165+ for (auto & p : mParticles ) {
170166 auto st = o2::mcgenstatus::MCGenStatusEncoding (p.GetStatusCode (), p.GetStatusCode ()).fullEncoding ;
171167 p.SetStatusCode (st);
172168 p.SetBit (ParticleStatus::kToBeDone , true );
@@ -209,7 +205,7 @@ Bool_t GeneratorHybrid::parseJSON(const std::string& path)
209205 std::string name = gen[" name" ].GetString ();
210206 mInputGens .push_back (name);
211207 if (gen.HasMember (" config" )) {
212- // Check if config is an array
208+ // Check if config is an array
213209 if (name == " boxgen" ) {
214210 const auto & boxconf = gen[" config" ];
215211 auto boxConfig = TBufferJSON::FromJSON<o2::eventgen::BoxGenConfig>(jsonValueToString (boxconf).c_str ());
@@ -247,13 +243,11 @@ Bool_t GeneratorHybrid::parseJSON(const std::string& path)
247243 } else {
248244 mConfigs .push_back (" " );
249245 }
250- }
251- else {
252- if (name == " boxgen" || name == " pythia8" || name == " extkinO2" || name == " external" || name == " hepmc" ){
246+ } else {
247+ if (name == " boxgen" || name == " pythia8" || name == " extkinO2" || name == " external" || name == " hepmc" ) {
253248 LOG (fatal) << " No configuration provided for generator " << name;
254249 return false ;
255- }
256- else
250+ } else
257251 mConfigs .push_back (" " );
258252 }
259253 }
@@ -265,8 +259,7 @@ Bool_t GeneratorHybrid::parseJSON(const std::string& path)
265259 for (const auto & frac : fractions.GetArray ()) {
266260 mFractions .push_back (frac.GetInt ());
267261 }
268- }
269- else {
262+ } else {
270263 // Set fractions to unity for all generators in case they are not provided
271264 const auto & gens = doc[" generators" ];
272265 for (const auto & gen : gens.GetArray ()) {
0 commit comments