32 LOG(info) <<
"FairAsciiGenerator: Opening input file " << fileName;
33 fInputFile =
new std::ifstream(fFileName);
34 if (!fInputFile->is_open()) {
35 LOG(fatal) <<
"Cannot open input file.";
46 if (!fInputFile->is_open()) {
47 LOG(error) <<
"FairAsciiGenerator: Input file not open!";
52 Int_t ntracks = 0, eventID = 0;
53 Double_t vx = 0., vy = 0., vz = 0.;
57 Double_t px = 0., py = 0., pz = 0.;
60 *fInputFile >> ntracks;
61 if (fInputFile->fail() || ntracks < 0 || ntracks > (INT_MAX - 1))
62 LOG(fatal) <<
"Error reading the number of events from event header.";
63 *fInputFile >> eventID >> vx >> vy >> vz;
66 if (fInputFile->eof()) {
67 LOG(info) <<
"FairAsciiGenerator: End of input file reached ";
72 LOG(info) <<
"FairAsciiGenerator: Event " << eventID <<
", vertex = (" << vx <<
"," << vy <<
"," << vz
73 <<
") cm, multiplicity " << ntracks;
76 for (Int_t itrack = 0; itrack < ntracks; itrack++) {
79 *fInputFile >> pdgID >> px >> py >> pz;
85 primGen->
AddTrack(pdgID, px, py, pz, vx, vy, vz);
91 void FairAsciiGenerator::CloseInput()
94 if (fInputFile->is_open()) {
95 LOG(info) <<
"FairAsciiGenerator: Closing input file " << fFileName;
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
ClassImp(FairEventBuilder)
virtual ~FairAsciiGenerator()
virtual void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz, Double_t vx, Double_t vy, Double_t vz, Int_t parent=-1, Bool_t wanttracking=true, Double_t e=-9e9, Double_t tof=0., Double_t weight=0., TMCProcess proc=kPPrimary)