23 #include <TClonesArray.h>
31 , fEventHeader(nullptr)
36 , fInputFileName(inputFileName)
43 LOG(debug) <<
"PixelDigiSource created------------";
53 LOG(info) <<
"PixelDigiSource::Init";
55 LOG(fatal) <<
"No FairRootManager";
58 fDigis =
new TClonesArray(
"PixelDigi", 10000);
59 ioman->
Register(
"PixelDigis",
"Pixel", fDigis, kFALSE);
62 fEventHeader->SetName(
"EventHeader.");
63 ioman->
Register(
"EventHeader.",
"EvtHeader", fEventHeader, kFALSE);
65 fInputFile.open(fInputFileName.Data(), std::fstream::in);
67 if (!fInputFile.is_open()) {
68 LOG(fatal) <<
"PixelDigiSource::Init() fInputFile \"" << fInputFileName.Data() <<
"\" could not be open!";
77 std::string tempstr = wholestr;
78 tempstr.replace(0, tempstr.find(pattern) + pattern.length(),
"");
79 tempstr.replace(0, tempstr.find(
'=') + 1,
"");
80 return atoi(tempstr.c_str());
90 fInputFile.seekg(0, std::ios::beg);
96 LOG(debug) <<
"PixelDigiSource::ReadEvent() Begin of (" << fDigis->GetEntries() <<
")";
98 getline(fInputFile, buffer);
99 LOG(debug) <<
"read from file: \"" << buffer <<
"\"";
100 if (buffer.find(
"EVENT BEGIN") == 0) {
108 LOG(debug) <<
"GOT NEW EVENT " << fMCEntryNo <<
" (part " << fPartNo <<
") with run id = " << fRunId;
110 if (buffer.find(
"EVENT") == 0)
112 Int_t detId = atoi(buffer.c_str());
113 buffer.erase(0, buffer.find(
' ') + 1);
114 Int_t feId = atoi(buffer.c_str());
115 buffer.erase(0, buffer.find(
' ') + 1);
116 Int_t col = atoi(buffer.c_str());
117 buffer.erase(0, buffer.find(
' ') + 1);
118 Int_t row = atoi(buffer.c_str());
119 buffer.erase(0, buffer.find(
' ') + 1);
120 Double_t charge = atof(buffer.c_str());
121 LOG(debug) <<
" --/" << fNDigis <<
"/--> " << detId <<
" / " << feId <<
" / " << col <<
" / " << row
123 new ((*fDigis)[fNDigis])
PixelDigi(-1, detId, feId, col, row, charge, 0.);
125 }
while (fInputFile && buffer.compare(
"EVENT END"));
126 LOG(debug) <<
"PixelDigiSource::ReadEvent() End of";
137 if (strcmp(BrName,
"PixelDigis"))
138 *obj = (TObject*)fDigis;
139 else if (strcmp(BrName,
"EventHeader."))
140 *obj = (TObject*)fEventHeader;
virtual ~PixelDigiSource()
static FairRootManager * Instance()
int ReadIntFromString(const std::string &wholestr, const std::string &pattern)
ClassImp(FairEventBuilder)
virtual Int_t CheckMaxEventNo(Int_t EvtEnd=0)
virtual Bool_t ActivateObject(TObject **obj, const char *BrName)
Int_t ReadEvent(UInt_t i=0)
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
PixelDigiSource(TString inputFileName="test.dat")
virtual void FillEventHeader(FairEventHeader *feh)