25 #include <TClonesArray.h>
42 , fPixelEventHeader(0)
44 , fOutputFileName(
"test.root")
60 Int_t nofDigis = fDigis->GetEntriesFast();
62 for (Int_t ifile = 0; ifile < fNofOutputFiles; ifile++) {
63 fPixelDigiVector.clear();
64 fPixelEventHeader->
fRunId = fRunId;
66 fPixelEventHeader->
fPartNo = ifile;
69 for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) {
74 if (fDivideLevel == 1) {
75 fileToSave = detId / 256 - 1;
76 }
else if (fDivideLevel == 2) {
77 fileToSave = (detId / 256 - 1) * 4 + (detId % 256 - 1);
80 if (fileToSave != ifile)
83 int feId = (int)currentDigi->
GetFeID();
84 int col = (int)currentDigi->
GetCol();
85 int row = (int)currentDigi->
GetRow();
90 tempDigi.
fFeID = feId;
94 fPixelDigiVector.push_back(tempDigi);
96 fPixelDigiVector.shrink_to_fit();
98 fOutputRootTree[ifile]->Fill();
103 void PixelAltDigiWriteToRootVector::SetParContainers() {}
105 InitStatus PixelAltDigiWriteToRootVector::Init()
112 LOG(fatal) <<
"No FairRootManager";
113 fDigis =
static_cast<TClonesArray*
>(ioman->
GetObject(
"PixelDigis"));
116 LOG(warn) <<
"PixelAltDigiWriteToRootVector::Init() No input PixelDigis array!";
118 LOG(info) <<
"-I- " << fName.Data() <<
"::Init(). Initialization succesfull.";
122 if (fDivideLevel == 0) {
125 if (fDivideLevel == 1) {
127 }
else if (fDivideLevel == 2) {
128 fNofOutputFiles = 12;
130 LOG(fatal) <<
"PixelAltDigiWriteToRootVector::Init(), fDivideLevel = " << fDivideLevel
131 <<
" unknown, it has to be in the range <0,2>";
137 for (Int_t ifile = 0; ifile < fNofOutputFiles; ifile++) {
138 TString fileName = fOutputFileName;
140 (fDivideLevel == 0 ?
"." : (fDivideLevel == 1 ? Form(
".s%d.", ifile) : Form(
".c%d.", ifile)));
141 fileName.Replace(fileName.Last(
'.'), 1, uniqFile.Data());
143 fOutputRootFile[ifile] =
new TFile(fileName.Data(),
"RECREATE");
144 fOutputRootTree[ifile] =
new TTree(
"fairdata",
"example MQ 9 Pixel data");
145 LOG(debug) <<
"trying to create branch in file >>" << fOutputRootFile[ifile]->GetName() <<
"<<";
146 fOutputRootTree[ifile]->Branch(
"EventHeader.",
"PixelPayload::EventHeader", &fPixelEventHeader, 0);
147 fOutputRootTree[ifile]->Branch(
"DigiVector.", &fPixelDigiVector, 32000, 0);
148 LOG(debug) <<
"branches created, fPixelDigiVector = >>" << &fPixelDigiVector <<
"<<";
154 InitStatus PixelAltDigiWriteToRootVector::ReInit()
159 LOG(fatal) <<
"No FairRootManager found.";
168 void PixelAltDigiWriteToRootVector::Reset() {}
170 void PixelAltDigiWriteToRootVector::Finish()
172 for (Int_t ifile = 0; ifile < fNofOutputFiles; ifile++) {
173 fOutputRootFile[ifile]->Write();
174 fOutputRootFile[ifile]->Close();
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
virtual ~PixelAltDigiWriteToRootVector()
PixelAltDigiWriteToRootVector()
virtual void Exec(Option_t *opt)