@@ -18,7 +18,7 @@ namespace o2
1818{
1919 namespace eventgen
2020 {
21- GeneratorHybrid::GeneratorHybrid (std::vector<std::string> inputgens)
21+ GeneratorHybrid::GeneratorHybrid (const std::vector<std::string>& inputgens)
2222 {
2323 auto configs = GeneratorHybridParam::Instance ().Configs ;
2424 mRandomize = GeneratorHybridParam::Instance ().Randomize ;
@@ -88,33 +88,49 @@ namespace o2
8888 gens.push_back (std::make_unique<o2::eventgen::GeneratorPythia8>());
8989 mConfsPythia8 .push_back (mConfigs [index]);
9090 mGens .push_back (gen);
91- } else if (gen.compare (" extkinO2" ) == 0 ){
92- gens.push_back (std::make_unique<o2::eventgen::GeneratorFromO2Kine>(mConfigs [index].c_str ()));
93- mGens .push_back (gen);
91+ } else if (gen.compare (" extkinO2" ) == 0 ){
92+ gens.push_back (std::make_unique<o2::eventgen::GeneratorFromO2Kine>(mConfigs [index].c_str ()));
93+ mGens .push_back (gen);
9494 } else if (gen.compare (" external" ) == 0 ) {
95- if (mConfigs [index].compare (" " ) == 0 ) {
96- LOG (fatal) << " No configuration provided" ;
97- exit (1 );
98- } else {
99- std::stringstream ss (mConfigs [index]);
100- std::string pars;
101- std::vector<std::string> params;
102- while (std::getline (ss, pars, ' ,' )) {
103- params.push_back (pars);
95+ if (mConfigs [index].compare (" " ) == 0 ) {
96+ LOG (fatal) << " No configuration provided" ;
97+ exit (1 );
98+ } else {
99+ std::stringstream ss (mConfigs [index]);
100+ std::string pars;
101+ std::vector<std::string> params;
102+ while (std::getline (ss, pars, ' ,' )) {
103+ params.push_back (pars);
104+ }
105+ auto & extgen_filename = params[0 ];
106+ auto & extgen_func = params[1 ];
107+ auto extGen = std::unique_ptr<o2::eventgen::Generator>(o2::conf::GetFromMacro<o2::eventgen::Generator*>(extgen_filename, extgen_func, " FairGenerator*" , " extgen" ));
108+ if (!extGen) {
109+ LOG (fatal) << " Failed to load external generator from " << extgen_filename << " with function " << extgen_func;
110+ exit (1 );
111+ }
112+ gens.push_back (std::move (extGen));
113+ mGens .push_back (gen);
104114 }
105- auto & extgen_filename = params[0 ];
106- auto & extgen_func = params[1 ];
107- auto extGen = std::unique_ptr<o2::eventgen::Generator>(o2::conf::GetFromMacro<o2::eventgen::Generator*>(extgen_filename, extgen_func, " FairGenerator*" , " extgen" ));
108- if (!extGen) {
109- LOG (fatal) << " Failed to load external generator from " << extgen_filename << " with function " << extgen_func;
115+ } else if (gen.compare (" hepmc" ) == 0 ) {
116+ if (mConfigs [index].compare (" " ) == 0 ) {
117+ LOG (fatal) << " No configuration provided" ;
110118 exit (1 );
119+ } else {
120+ std::stringstream ss (mConfigs [index]);
121+ std::string pars;
122+ std::vector<std::string> params;
123+ while (std::getline (ss, pars, ' ,' )) {
124+ params.push_back (pars);
125+ }
126+ gens.push_back (std::make_unique<o2::eventgen::GeneratorHepMC>());
127+ dynamic_cast <o2::eventgen::GeneratorHepMC*>(gens.back ().get ())->setFileNames (std::string (params[0 ]));
128+ dynamic_cast <o2::eventgen::GeneratorHepMC*>(gens.back ().get ())->setVersion (std::stoi (params[1 ]));
129+ mGens .push_back (gen);
130+ }
131+ } else {
132+ LOG (info) << " Generator " << gen << " not found in the list of available generators \n " ;
111133 }
112- gens.push_back (std::move (extGen));
113- mGens .push_back (gen);
114- }
115- } else {
116- LOG (info) << " Generator " << gen << " not found in the list of available generators \n " ;
117- }
118134 }
119135 index++;
120136 }
0 commit comments