ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtDecoder2Task.cxx
Go to the documentation of this file.
1 #include "AtDecoder2Task.h"
2 
3 // FAIRROOT classes
4 #include <FairRootManager.h>
5 #include <FairRun.h>
6 #include <FairRunAna.h>
7 #include <FairRunOnline.h>
8 #include <FairRuntimeDb.h>
9 
10 constexpr auto cRED = "\033[1;31m";
11 constexpr auto cYELLOW = "\033[1;33m";
12 constexpr auto cNORMAL = "\033[0m";
13 constexpr auto cGREEN = "\033[1;32m";
14 
16 
18 {
19  fDecoder = nullptr;
20  fDataNum = 0;
21 
22  fFPNPedestalRMS = -1;
23 
24  fExternalNumTbs = kFALSE;
25  fNumTbs = 512;
26 
27  // fUseGainCalibration = kFALSE;
28  // fGainCalibrationFile = "";
29  // fGainConstant = -9999;
30  // fGainLinear = -9999;
31  // fGainQuadratic = 0;
32 
33  fIsPersistence = kFALSE;
34  fIsPositive = kFALSE;
35 
36  fPar = nullptr;
37  fRawEventArray = new TClonesArray("AtRawEvent");
38  fRawEvent = nullptr;
39 
40  fIsSeparatedData = kFALSE;
41  fIsPseudoTopology = kFALSE;
42 
43  fInternalID = 0;
44 
45  fEventID = -1;
46  fNumCobo = 40;
47 
48  fMask = 0xF;
49 }
50 
52 
54 {
55  fIsPersistence = value;
56 }
57 void AtDecoder2Task::SetNumTbs(Int_t numTbs)
58 {
59  fNumTbs = numTbs;
60  fExternalNumTbs = kTRUE;
61 }
62 void AtDecoder2Task::AddData(TString filename, Int_t coboIdx)
63 {
64  fDataList[coboIdx].push_back(filename);
65 }
66 void AtDecoder2Task::SetData(Int_t value)
67 {
68  fDataNum = value;
69 }
70 void AtDecoder2Task::SetFPNPedestal(Double_t pedestalRMS)
71 {
72  fFPNPedestalRMS = pedestalRMS;
73 }
75 {
76  fIsPositive = value;
77 }
78 // void AtDecoder2Task::SetUseGainCalibration(Bool_t value) { fUseGainCalibration
79 // = value; } void AtDecoder2Task::SetGainCalibrationData(TString filename) {
80 // fGainCalibrationFile = filename; } void AtDecoder2Task::SetGainReference(Double_t constant, Double_t linear, Double_t
81 // quadratic) { fGainConstant = constant; fGainLinear = linear; fGainQuadratic = quadratic; }
83 {
84  fIsSeparatedData = value;
85 }
86 void AtDecoder2Task::SetEventID(Long64_t eventid)
87 {
88  fEventID = eventid;
89 }
91 {
92  fIsPseudoTopology = value;
93 }
94 
95 void AtDecoder2Task::SetNumCobo(Int_t numCobo)
96 {
97  fNumCobo = numCobo;
98 }
100 {
101  fMask = mask;
102 }
103 
105 {
106  return fEventIDLast;
107 }
108 
110 {
111 
112  std::cout << " ==== AtDecoder2Task::Init() "
113  << "\n";
114  std::cout << " Number of Cobo/Asad : " << fNumCobo << "\n";
115 
116  FairRootManager *ioMan = FairRootManager::Instance();
117  if (ioMan == 0) {
118  LOG(error) << "Cannot find RootManager!";
119 
120  return kERROR;
121  }
122 
123  ioMan->Register("AtRawEvent", "AtTPC", fRawEventArray, fIsPersistence);
124 
125  fDecoder = new AtCore2(fMap, fNumCobo);
126  fDecoder->SetNumCobo(fNumCobo);
127  fDecoder->SetUseSeparatedData(fIsSeparatedData);
128 
129  for (Int_t iFile = 0; iFile < fDataList[0].size(); iFile++)
130  fDecoder->AddData(fDataList[0].at(iFile));
131 
132  if (fIsSeparatedData)
133  for (Int_t iCobo = 1; iCobo < fNumCobo; iCobo++)
134  for (Int_t iFile = 0; iFile < fDataList[iCobo].size(); iFile++)
135  fDecoder->AddData(fDataList[iCobo].at(iFile), iCobo);
136 
137  if (fIsPseudoTopology)
138  fDecoder->SetPseudoTopologyFrame(fMask, kFALSE);
139 
140  fDecoder->SetData(fDataNum);
141 
142  if (fExternalNumTbs)
143  fDecoder->SetNumTbs(fNumTbs);
144  else
145  fDecoder->SetNumTbs(fPar->GetNumTbs());
146 
147  if (fFPNPedestalRMS == -1)
148  // fFPNPedestalRMS = fPar -> GetFPNPedestalRMS();
149  fFPNPedestalRMS = 5;
150 
151  fDecoder->SetFPNPedestal(fFPNPedestalRMS);
152 
153  return kSUCCESS;
154 }
155 
157 {
158  FairRun *run = FairRun::Instance();
159  if (!run)
160  LOG(fatal) << "No analysis run!";
161 
162  FairRuntimeDb *db = run->GetRuntimeDb();
163  if (!db)
164  LOG(fatal) << "No runtime database!";
165 
166  fPar = (AtDigiPar *)db->getContainer("AtDigiPar");
167  if (!fPar)
168  LOG(fatal) << "Cannot find AtDigiPar!";
169 }
170 
171 void AtDecoder2Task::Exec(Option_t *opt)
172 {
173  //#ifdef TASKTIMER
174  // STDebugLogger::Instance() -> TimerStart("DecoderTask");
175  //#endif
176  fRawEventArray->Delete();
177 
178  if (fRawEvent == nullptr)
179  fRawEvent = fDecoder->GetRawEvent(fEventID++);
180  fInternalID++;
181  if (fInternalID % 1 == 0)
182  std::cout << " Event Number " << fEventID << " Internal ID : " << fInternalID
183  << " Number of Pads : " << fRawEvent->GetNumPads() << std::endl;
184 
185  new ((*fRawEventArray)[0]) AtRawEvent(*fRawEvent);
186 
187  fRawEvent = nullptr;
188  //#ifdef TASKTIMER
189  // STDebugLogger::Instance() -> TimerStop("DecoderTask");
190  //#endif
191 }
192 
193 Int_t AtDecoder2Task::ReadEvent(Int_t eventID)
194 {
195  fRawEventArray->Delete();
196 
197  fRawEvent = fDecoder->GetRawEvent(eventID);
198  fEventIDLast = fDecoder->GetEventID();
199 
200  if (fRawEvent == nullptr)
201  return 1;
202 
203  new ((*fRawEventArray)[0]) AtRawEvent(*fRawEvent);
204 
205  return 0;
206 }
207 
209 {
210  fRawEvent = fDecoder->GetRawEvent();
211 
212  if (fRawEvent == nullptr) {
213  LOG(info) << "End of file. Terminating FairRun.";
214  FairRootManager::Instance()->SetFinishRun();
215  }
216 }
AtDecoder2Task::ReadEvent
Int_t ReadEvent(Int_t eventID)
Read event for AtSource.
Definition: AtDecoder2Task.cxx:193
AtDecoder2Task::SetFPNPedestal
void SetFPNPedestal(Double_t rms)
Setting the FPN RMS value cut for pedestal region taking.
Definition: AtDecoder2Task.cxx:70
AtDecoder2Task::AddData
void AddData(TString filename, Int_t coboIdx=0)
Adding raw data file to the list.
Definition: AtDecoder2Task.cxx:62
AtCore2::GetEventID
Int_t GetEventID()
Returns the current event ID.
Definition: AtCore2.cxx:378
cGREEN
constexpr auto cGREEN
Definition: AtDecoder2Task.cxx:13
AtDecoder2Task::SetParContainers
virtual void SetParContainers()
Setting parameter containers. This will be called inbetween Init() and Run().
Definition: AtDecoder2Task.cxx:156
AtDecoder2Task::SetPseudoTopologyFrame
void SetPseudoTopologyFrame(Bool_t value)
Definition: AtDecoder2Task.cxx:90
AtCore2
Definition: AtCore2.h:26
AtCore2::SetNumCobo
void SetNumCobo(Int_t numCobo)
Definition: AtCore2.cxx:531
AtCore2::SetData
Bool_t SetData(Int_t value)
Definition: AtCore2.cxx:99
cNORMAL
constexpr auto cNORMAL
Definition: AtDecoder2Task.cxx:12
AtRawEvent
Definition: AtRawEvent.h:34
cRED
constexpr auto cRED
Definition: AtDecoder2Task.cxx:10
AtCore2::SetFPNPedestal
void SetFPNPedestal(Double_t sigmaThreshold=5)
Definition: AtCore2.cxx:158
AtDecoder2Task::Exec
virtual void Exec(Option_t *opt)
Running the task. This will be called when Run() method invoked from FairRun.
Definition: AtDecoder2Task.cxx:171
AtCore2::AddData
Bool_t AddData(TString filename, Int_t coboIdx=0)
Definition: AtCore2.cxx:89
AtCore2::SetPseudoTopologyFrame
void SetPseudoTopologyFrame(Int_t asadMask, Bool_t check=kFALSE)
Definition: AtCore2.cxx:419
AtCore2::SetNumTbs
void SetNumTbs(Int_t value)
Definition: AtCore2.cxx:148
AtDigiPar
Definition: AtDigiPar.h:14
AtDecoder2Task::SetUseSeparatedData
void SetUseSeparatedData(Bool_t value=kTRUE)
Setting to use not merged data files.
Definition: AtDecoder2Task.cxx:82
AtCore2::GetRawEvent
AtRawEvent * GetRawEvent(Long64_t eventID=-1)
Returns STRawEvent object filled with the data.
Definition: AtCore2.cxx:302
cYELLOW
constexpr auto cYELLOW
Definition: AtDecoder2Task.cxx:11
AtCore2::SetUseSeparatedData
void SetUseSeparatedData(Bool_t value=kTRUE)
Definition: AtCore2.cxx:388
AtDecoder2Task::SetPTFMask
void SetPTFMask(Int_t mask)
Definition: AtDecoder2Task.cxx:99
AtRawEvent::GetNumPads
Int_t GetNumPads() const
Definition: AtRawEvent.h:122
AtDecoder2Task::SetNumCobo
void SetNumCobo(Int_t numCobo)
Definition: AtDecoder2Task.cxx:95
AtDecoder2Task::SetEventID
void SetEventID(Long64_t eventid=-1)
Setting event id for STSource.
Definition: AtDecoder2Task.cxx:86
AtDecoder2Task.h
ClassImp
ClassImp(AtDecoder2Task)
AtDecoder2Task::GetEventID
Long64_t GetEventID()
Definition: AtDecoder2Task.cxx:104
AtDecoder2Task::SetPositivePolarity
void SetPositivePolarity(Bool_t value=kFALSE)
Definition: AtDecoder2Task.cxx:74
AtDecoder2Task::SetPersistence
void SetPersistence(Bool_t value=kTRUE)
If set, decoded raw data is written in ROOT file with AtRawEvent class.
Definition: AtDecoder2Task.cxx:53
AtDecoder2Task::SetData
void SetData(Int_t value)
Setting which data to be decoded.
Definition: AtDecoder2Task.cxx:66
AtDecoder2Task
Definition: AtDecoder2Task.h:23
AtDecoder2Task::Init
virtual InitStatus Init()
Initializing the task. This will be called when Init() method invoked from FairRun.
Definition: AtDecoder2Task.cxx:109
AtDecoder2Task::~AtDecoder2Task
~AtDecoder2Task()
Destructor.
Definition: AtDecoder2Task.cxx:51
AtDecoder2Task::SetNumTbs
void SetNumTbs(Int_t numTbs)
Setting the number of time buckets used when taking data.
Definition: AtDecoder2Task.cxx:57
AtDecoder2Task::AtDecoder2Task
AtDecoder2Task()
Constructor.
Definition: AtDecoder2Task.cxx:17
AtDecoder2Task::FinishEvent
virtual void FinishEvent()
Finishing the event.
Definition: AtDecoder2Task.cxx:208