23 #include <TClonesArray.h>
31 , fEventHeader(nullptr)
36 , fInputFileName(inputFileName)
43 LOG(debug) <<
"PixelDigiBinSource created------------";
53 LOG(info) <<
"PixelDigiBinSource::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 | std::fstream::binary);
67 if (!fInputFile.is_open()) {
68 LOG(fatal) <<
"PixelDigiBinSource::Init() fInputFile \"" << fInputFileName.Data() <<
"\" could not be open!";
86 fInputFile.seekg(0, std::ios::beg);
92 LOG(debug) <<
"PixelDigiBinSource::ReadEvent() Begin of (" << fDigis->GetEntries() <<
")";
95 fInputFile.read((
char*)head,
sizeof(head));
97 if (fInputFile.eof()) {
98 LOG(info) <<
"End of file reached!";
104 const Int_t constNofData = head[3] * dataSize;
105 short int dataCont[constNofData];
106 fInputFile.read((
char*)dataCont,
sizeof(dataCont));
109 fMCEntryNo = head[1];
115 for (Int_t idata = 0; idata < head[3]; idata++) {
116 LOG(debug) <<
" --/" << idata <<
"/--> " << dataCont[idata * dataSize + 0] <<
" / "
117 << dataCont[idata * dataSize + 1] <<
" / " << dataCont[idata * dataSize + 2] <<
" / "
118 << dataCont[idata * dataSize + 3] <<
" / "
121 (Int_t)dataCont[idata * dataSize + 0],
122 (Int_t)dataCont[idata * dataSize + 1],
123 (Int_t)dataCont[idata * dataSize + 2],
124 (Int_t)dataCont[idata * dataSize + 3],
129 LOG(debug) <<
"PixelDigiBinSource::ReadEvent() End of";
140 if (strcmp(BrName,
"PixelDigis") == 0)
141 *obj = (TObject*)fDigis;
142 else if (strcmp(BrName,
"EventHeader.") == 0)
143 *obj = (TObject*)fEventHeader;
virtual ~PixelDigiBinSource()
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
virtual Int_t CheckMaxEventNo(Int_t EvtEnd=0)
Int_t ReadEvent(UInt_t i=0)
PixelDigiBinSource(TString inputFileName="test.dat")
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
virtual Bool_t ActivateObject(TObject **obj, const char *BrName)
virtual void FillEventHeader(FairEventHeader *feh)