21 #include <HepMC/GenEvent.h>
22 #include <HepMC/GenParticle.h>
23 #include <HepMC/GenVertex.h>
24 #include <HepMC/IO_GenEvent.h>
25 #include <HepMC/SimpleVector.h>
26 #include <HepMC/Units.h>
31 #include <boost/iostreams/filter/bzip2.hpp>
32 #include <boost/iostreams/filter/gzip.hpp>
42 static const double toMM = 1.e-12;
46 , topNodeName(topnodename)
85 std::cout <<
"Call fileopen only after you registered your Input Manager " <<
Name() <<
" with the Fun4AllServer" << std::endl;
90 std::cout <<
"Closing currently open file "
92 <<
" and opening " << filenam << std::endl;
100 std::cout <<
Name() <<
": opening file " <<
fname << std::endl;
110 TPRegexp bzip_ext(
".bz2$");
111 TPRegexp gzip_ext(
".gz$");
112 if (tstr.Contains(bzip_ext))
116 zinbuffer.push(boost::iostreams::bzip2_decompressor());
121 else if (tstr.Contains(gzip_ext))
125 zinbuffer.push(boost::iostreams::gzip_decompressor());
138 static bool run_number_forced = rc->
FlagExist(
"RUNNUMBER");
139 if (run_number_forced)
165 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name() <<
": No Input file open" << std::endl;
173 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name() <<
": No Input file from filelist opened" << std::endl;
202 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name()
203 <<
": error type: " <<
ascii_in->error_type()
204 <<
", rdstate: " <<
ascii_in->rdstate() << std::endl;
213 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name()
214 <<
": hepmc evt no: " <<
evt->event_number() << std::endl;
221 ievt->second->addEvent(
evt);
251 std::cout <<
Name() <<
": fileclose: No Input file open" << std::endl;
273 std::cout <<
Name() <<
" Vertex Settings: " << std::endl;
304 std::cout <<
Name() <<
": pushing back evt no " << evt->event_number() << std::endl;
309 <<
" Fun4AllHepMCInputManager cannot pop back more than 1 event"
316 <<
" no file opened yet" << std::endl;
324 while (nevents > 0 && !errorflag)
329 std::cout <<
"Error after skipping " << i - nevents << std::endl;
330 std::cout <<
"error type: " <<
ascii_in->error_type()
331 <<
", rdstate: " <<
ascii_in->rdstate() << std::endl;
340 std::cout <<
"Skipping evt no: " <<
evt->event_number() << std::endl;
359 evt =
new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::CM);
364 std::vector<std::vector<double> > theEventVec;
365 std::vector<HepMC::FourVector> theVtxVec;
368 if (theLine.compare(0, 1,
"#") == 0)
continue;
369 std::vector<double> theInfo;
371 for (std::istringstream numbers_iss(theLine); numbers_iss >> number;)
373 theInfo.push_back(number);
376 if (theInfo.size() == 2 && theInfo[0] == 0 && theInfo[1] == 0)
380 else if (theInfo.size() == 2 && theInfo[0] == 0 && theInfo[1] > 0)
386 theEventVec.push_back(theInfo);
387 HepMC::FourVector vert(theInfo[8] *
toMM, theInfo[9] * toMM, theInfo[10] * toMM, theInfo[11]);
388 theVtxVec.push_back(vert);
397 for (
unsigned int i = 0;
i < theEventVec.size();
i++)
400 int pid = (int) theEventVec[
i][1];
401 double px = theEventVec[
i][3];
402 double py = theEventVec[
i][4];
403 double pz = theEventVec[
i][5];
404 double E = theEventVec[
i][6];
405 double m = theEventVec[
i][7];
408 HepMC::GenVertex *
v =
new HepMC::GenVertex(theVtxVec[
i]);
411 HepMC::GenParticle *
p =
new HepMC::GenParticle(HepMC::FourVector(px, py, pz, E), pid, status);
412 p->setGeneratedMass(m);
413 p->suggest_barcode(i + 1);
414 v->add_particle_out(p);