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>
28 #include <TDirectory.h>
34 #include <boost/iostreams/filter/bzip2.hpp>
35 #include <boost/iostreams/filter/gzip.hpp>
45 static const double toMM = 1.e-12;
49 , topNodeName(topnodename)
88 std::cout <<
"Call fileopen only after you registered your Input Manager " <<
Name() <<
" with the Fun4AllServer" << std::endl;
93 std::cout <<
"Closing currently open file "
95 <<
" and opening " << filenam << std::endl;
103 std::cout <<
Name() <<
": opening file " <<
fname << std::endl;
113 TPRegexp bzip_ext(
".bz2$");
114 TPRegexp gzip_ext(
".gz$");
115 if (tstr.Contains(bzip_ext))
119 zinbuffer.push(boost::iostreams::bzip2_decompressor());
124 else if (tstr.Contains(gzip_ext))
128 zinbuffer.push(boost::iostreams::gzip_decompressor());
141 static bool run_number_forced = rc->
FlagExist(
"RUNNUMBER");
142 if (run_number_forced)
168 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name() <<
": No Input file open" << std::endl;
176 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name() <<
": No Input file from filelist opened" << std::endl;
205 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name()
206 <<
": error type: " <<
ascii_in->error_type()
207 <<
", rdstate: " <<
ascii_in->rdstate() << std::endl;
216 std::cout <<
"Fun4AllHepMCInputManager::run::" <<
Name()
217 <<
": hepmc evt no: " <<
evt->event_number() << std::endl;
224 ievt->second->addEvent(
evt);
254 std::cout <<
Name() <<
": fileclose: No Input file open" << std::endl;
276 std::cout <<
Name() <<
" Vertex Settings: " << std::endl;
307 std::cout <<
Name() <<
": pushing back evt no " << evt->event_number() << std::endl;
312 <<
" Fun4AllHepMCInputManager cannot pop back more than 1 event"
319 <<
" no file opened yet" << std::endl;
327 while (nevents > 0 && !errorflag)
332 std::cout <<
"Error after skipping " << i - nevents << std::endl;
333 std::cout <<
"error type: " <<
ascii_in->error_type()
334 <<
", rdstate: " <<
ascii_in->rdstate() << std::endl;
343 std::cout <<
"Skipping evt no: " <<
evt->event_number() << std::endl;
362 evt =
new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::CM);
367 std::vector<std::vector<double> > theEventVec;
368 std::vector<HepMC::FourVector> theVtxVec;
371 if (theLine.compare(0, 1,
"#") == 0)
continue;
372 std::vector<double> theInfo;
374 for (std::istringstream numbers_iss(theLine); numbers_iss >> number;)
376 theInfo.push_back(number);
379 if (theInfo.size() == 2 && theInfo[0] == 0 && theInfo[1] == 0)
383 else if (theInfo.size() == 2 && theInfo[0] == 0 && theInfo[1] > 0)
389 theEventVec.push_back(theInfo);
390 HepMC::FourVector vert(theInfo[8] *
toMM, theInfo[9] * toMM, theInfo[10] * toMM, theInfo[11]);
391 theVtxVec.push_back(vert);
400 for (
unsigned int i = 0; i < theEventVec.size(); i++)
403 int pid = (
int) theEventVec[i][1];
404 double px = theEventVec[i][3];
405 double py = theEventVec[i][4];
406 double pz = theEventVec[i][5];
407 double E = theEventVec[i][6];
408 double m = theEventVec[i][7];
411 HepMC::GenVertex *
v =
new HepMC::GenVertex(theVtxVec[i]);
414 HepMC::GenParticle *
p =
new HepMC::GenParticle(HepMC::FourVector(px, py, pz, E), pid, status);
415 p->setGeneratedMass(m);
416 p->suggest_barcode(i + 1);
417 v->add_particle_out(p);