24 #include <TClonesArray.h>
38 , fOutputFileName(
"test.dat")
56 Int_t nofDigis = fDigis->GetEntriesFast();
58 Int_t digisPerFile[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
60 for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) {
66 if (fDivideLevel == 1) {
67 fileToSave = detId / 256 - 1;
68 }
else if (fDivideLevel == 2) {
69 fileToSave = (detId / 256 - 1) * 4 + (detId % 256 - 1);
71 digisPerFile[fileToSave] += 1;
74 for (Int_t ifile = 0; ifile < fNofOutputFiles; ifile++) {
75 fOutputFiles[ifile].write((
char*)&fRunId,
sizeof(fRunId));
76 fOutputFiles[ifile].write((
char*)&fMCEntryNo,
sizeof(fMCEntryNo));
77 fOutputFiles[ifile].write((
char*)&ifile,
sizeof(ifile));
78 fOutputFiles[ifile].write((
char*)&digisPerFile[ifile],
sizeof(digisPerFile[ifile]));
81 for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) {
85 short int feId = (
short int)currentDigi->
GetFeID();
86 short int col = (
short int)currentDigi->
GetCol();
87 short int row = (
short int)currentDigi->
GetRow();
90 if (fDivideLevel == 1) {
91 fileToSave = detId / 256 - 1;
92 }
else if (fDivideLevel == 2) {
93 fileToSave = (detId / 256 - 1) * 4 + (detId % 256 - 1);
95 fOutputFiles[fileToSave].write((
char*)&detId,
sizeof(detId));
96 fOutputFiles[fileToSave].write((
char*)&feId,
sizeof(feId));
97 fOutputFiles[fileToSave].write((
char*)&col,
sizeof(col));
98 fOutputFiles[fileToSave].write((
char*)&row,
sizeof(row));
111 LOG(fatal) <<
"No FairRootManager";
112 fDigis =
static_cast<TClonesArray*
>(ioman->
GetObject(
"PixelDigis"));
115 LOG(warn) <<
"PixelDigiWriteToBinFile::Init() No input PixelDigis array!";
117 LOG(info) <<
"-I- " << fName.Data() <<
"::Init(). Initialization succesfull.";
121 if (fDivideLevel == 0) {
123 fOutputFiles[0].open(fOutputFileName.Data(), std::fstream::out | std::fstream::binary);
125 if (fDivideLevel == 1) {
127 }
else if (fDivideLevel == 2) {
128 fNofOutputFiles = 12;
130 LOG(fatal) <<
"PixelDigiWriteToBinFile::Init(), fDivideLevel = " << fDivideLevel
131 <<
" unknown, it has to be in the range <0,2>";
134 for (Int_t ifile = 0; ifile < fNofOutputFiles; ifile++) {
135 TString fileName = fOutputFileName;
136 TString uniqFile = Form(
".p%d.", ifile);
137 fileName.Replace(fileName.Last(
'.'), 1, uniqFile.Data());
138 fOutputFiles[ifile].open(fileName.Data(), std::fstream::out);
151 LOG(fatal) <<
"No FairRootManager found.";
160 void PixelDigiWriteToBinFile::Finish()
162 for (Int_t ifile = 0; ifile < fNofOutputFiles; ifile++) {
163 fOutputFiles[ifile].close();
PixelDigiWriteToBinFile()
virtual ~PixelDigiWriteToBinFile()
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
virtual void Exec(Option_t *opt)