4 #include <FairRootManager.h>
6 #include <FairRunAna.h>
7 #include <FairRunOnline.h>
8 #include <FairRuntimeDb.h>
10 constexpr
auto cRED =
"\033[1;31m";
13 constexpr
auto cGREEN =
"\033[1;32m";
19 fLogger = FairLogger::GetLogger();
27 fExternalNumTbs = kFALSE;
36 fIsPersistence = kFALSE;
39 fRawEventArray =
new TClonesArray(
"AtRawEvent");
42 fIsSeparatedData = kFALSE;
43 fIsPseudoTopology = kFALSE;
51 for (Int_t i = 0; i < fNumCobo; i++) {
52 fIsCoboPadPlane[i] = kTRUE;
53 fIsPositive[i] = kTRUE;
61 fIsPersistence = value;
66 fExternalNumTbs = kTRUE;
70 LOG(debug) <<
"In task adding file " << filename <<
" to cobo " << coboIdx;
71 fDataList[coboIdx].push_back(filename);
79 fFPNPedestalRMS = pedestalRMS;
83 for (Int_t i = 0; i < fNumCobo; i++) {
84 fIsPositive[i] = value[i];
96 fIsSeparatedData = value;
133 fIsPseudoTopology = value;
143 for (Int_t i = 0; i < fNumCobo; i++) {
144 fIsCoboPadPlane[i] = IsPadPlane[i];
159 FairRootManager *ioMan = FairRootManager::Instance();
161 LOG(error) <<
"Cannot find RootManager!";
166 fDecoder = std::make_unique<AtCoreSpecMAT>(fMap);
167 fDecoder->SetNumCobo(fNumCobo);
168 fDecoder->SetIsPadPlaneCobo(fIsCoboPadPlane);
169 fDecoder->SetPositivePolarity(fIsPositive);
171 for (Int_t iFile = 0; iFile < fDataList[0].size(); iFile++)
172 fDecoder->AddData(fDataList[0].at(iFile));
174 LOG(debug) <<
"After adding data filename is: " << fDecoder->GetFileName();
176 if (fIsPseudoTopology)
177 fDecoder->SetPseudoTopologyFrame(fMask, kFALSE);
179 fDecoder->SetData(fDataNum);
181 LOG(debug) <<
"After setting data filename is: " << fDecoder->GetFileName();
184 fDecoder->SetNumTbs(fNumTbs);
186 fDecoder->SetNumTbs(fPar->GetNumTbs());
188 if (fFPNPedestalRMS == -1)
192 fDecoder->SetFPNPedestal(fFPNPedestalRMS);
194 if (fMap ==
nullptr) {
195 LOG(error) <<
"SpecMAT Map was never set!";
198 fDecoder->SetMap(fMap);
200 ioMan->Register(
"AtRawEvent",
"AtTPC", fRawEventArray, fIsPersistence);
201 LOG(debug) <<
"At end of init filename is: " << fDecoder->GetFileName();
207 FairRun *run = FairRun::Instance();
209 LOG(fatal) <<
"No analysis run!";
211 FairRuntimeDb *db = run->GetRuntimeDb();
213 LOG(fatal) <<
"No runtime database!";
215 fPar = (
AtDigiPar *)db->getContainer(
"AtDigiPar");
217 LOG(fatal) <<
"Cannot find AtDigiPar!";
222 fRawEventArray->Delete();
223 std::cout <<
"Start of SpecMAT decoder task for event " << fEventID + 1 << std::endl;
224 if (fRawEvent ==
nullptr)
225 fRawEvent = fDecoder->GetRawEvent(fEventID++);
228 std::cout <<
" Event Number " << fEventID <<
" Internal ID : " << fInternalID
229 <<
" Number of Pads : " << fRawEvent->
GetNumPads() << std::endl;
231 new ((*fRawEventArray)[0])
AtRawEvent(*fRawEvent);
235 LOG(debug) <<
"Finished unpacking event";
240 fRawEventArray->Delete();
242 fRawEvent = fDecoder->GetRawEvent(eventID);
243 fEventIDLast = fDecoder->GetEventID();
245 if (fRawEvent ==
nullptr)
248 new ((*fRawEventArray)[0])
AtRawEvent(*fRawEvent);
255 fRawEvent = fDecoder->GetRawEvent();
257 if (fRawEvent ==
nullptr) {
258 LOG(info) <<
"End of file. Terminating FairRun.";
259 FairRootManager::Instance()->SetFinishRun();