BmnRoot
Loading...
Searching...
No Matches
BmnRawDataDecoder.h
Go to the documentation of this file.
1#ifndef BMNRAWDATADECODER_H
2#define BMNRAWDATADECODER_H 1
3// STL
4#include <deque>
5#include <filesystem>
6#include <fstream>
7#include <map>
8#include <vector>
9// Boost
10#pragma GCC system_header
11#include <boost/property_tree/json_parser.hpp>
12#include <boost/property_tree/ptree.hpp>
13// ROOT
14#include "TClonesArray.h"
15#include "TFile.h"
16#include "TString.h"
17#include "TTimeStamp.h"
18#include "TTree.h"
19// BmnRoot
20#include "BmnAdcQA.h"
21#include "BmnConverter.h"
22#include "BmnCscRaw2Digit.h"
23#include "BmnDchRaw2Digit.h"
24#include "BmnDecoder.h"
25#include "BmnECALRaw2Digit.h"
26#include "BmnEventHeader.h"
27#include "BmnFHCalRaw2Digit.h"
28#include "BmnGemRaw2Digit.h"
29#include "BmnHodoRaw2Digit.h"
30#include "BmnMscRaw2Digit.h"
31#include "BmnMwpcRaw2Digit.h"
32#include "BmnNdetRaw2Digit.h"
33#include "BmnRawSource.h"
34#include "BmnScWallRaw2Digit.h"
35#include "BmnSiBTRaw2Digit.h"
36#include "BmnSiliconRaw2Digit.h"
37#include "BmnTof1Raw2Digit.h"
38// #include "BmnTof2Raw2DigitNew.h"
39#include "BmnTof701Raw2Digit.h"
40#include "BmnTrigRaw2Digit.h"
41#include "BmnZDCRaw2Digit.h"
42#include "DigiArrays.h"
43#include "RawTypes.h"
44
45/********************************************************/
46// wait limit for input data (ms)
47#define WAIT_LIMIT 40000000
48// Debug ADC processor
49// #define ADC_QA true
50
51using std::map;
52using std::vector;
53namespace pt = boost::property_tree;
54
56
58{
59 public:
61 static double threshGem, threshCsc, threshSil;
62 static int samplesGem, samplesCsc, samplesSil;
63
64 BmnRawDataDecoder(TString file = "", TString outfile = "", ULong_t nEvents = 0, ULong_t period = 8);
66
68 void FillAdcQa();
69 void SaveAdcQa();
75
76 BmnStatus InitConverter(TString FileName);
80
81 BmnStatus ConvertRawToRootIterate(UInt_t* buf, UInt_t len);
83
84 void SetRunId(UInt_t v)
85 {
86 fRunId = v;
87 if (fRawSource)
88 fRawSource->SetRunId(fRunId);
89 if (fDecoder)
90 fDecoder->SetRunId(fRunId);
91 }
92
93 void SetPeriodId(UInt_t v)
94 {
95 fPeriodId = v;
96 if (fRawSource)
97 fRawSource->SetPeriodId(fPeriodId);
98 if (fDecoder)
99 fDecoder->SetPeriodId(fPeriodId);
100 }
101
102 void SetApplyThreshold(bool b) { fApplyThreshold = b; }
103
104 // map<UInt_t, Long64_t> GetTimeShifts() {
105 // return fTimeShifts;
106 // }
107
108 UInt_t GetRunId() const { return fRunId; }
109
110 UInt_t GetPeriodId() const { return fPeriodId; }
111
112 UInt_t GetNevents() const { return fNTotalEvents; }
113
114 UInt_t GetEventId() const
115 {
116 if (fDecoder)
117 return fDecoder->GetEventId();
118 if (fRawSource)
119 return fRawSource->GetEventId();
120 }
121
122 TTimeStamp GetRunStartTime() const
123 {
124 if (fDecoder)
125 return fDecoder->GetRunStartTime();
126 if (fRawSource)
127 return fRawSource->GetRunStartTime();
128 }
129
130 TTimeStamp GetRunEndTime() const
131 {
132 if (fDecoder)
133 return fDecoder->GetRunEndTime();
134 if (fRawSource)
135 return fRawSource->GetRunEndTime();
136 }
137
138 TString GetRootFileName() { return fRootFileName; }
139
140 void SetDetectorSetup(std::map<DetectorId, bool> setup)
141 {
142 fDetectorSetup = setup;
143 if (fDecoder)
144 fDecoder->SetDetectorSetup(fDetectorSetup);
145 }
146
147 void SetDecoderConfigFileName(string FileName)
148 {
149 fDecoderConfigFileName = FileName;
150 if (fRawSource)
151 fRawSource->SetDecoderConfigFileName(fDecoderConfigFileName);
152 if (fDecoder)
153 fDecoder->SetDecoderConfigFileName(fDecoderConfigFileName);
154 }
155
156 void SetEvForPedestals(UInt_t v)
157 {
158 fEvForPedestals = v;
159 if (fDecoder)
160 fDecoder->SetEvForPedestals(fEvForPedestals);
161 }
162
163 UInt_t GetEvForPedestals() { return fEvForPedestals; }
164
165 void SetBmnSetup(BmnSetup v) { fBmnSetup = v; }
166
167 BmnSetup GetBmnSetup() const { return fBmnSetup; }
168
169 void SetVerbose(Int_t v) { fVerbose = v; }
170
171 Int_t GetVerbose() const { return fVerbose; }
172
173 void SetUseCalibFile(bool v) { fUseCalibFile = v; }
174
175 bool GetUseCalibFile() const { return fUseCalibFile; }
176
177 void SetRawRootDirPath(TString path)
178 {
179 fRootDirPath = path;
180 fRootFileName = Form("%sbmn_run%d%s_raw.root", fRootDirPath.Data(), fRunId, fSubName.Data());
181 }
182
183 void SetRawRootFile(TString filename) { fRootFileName = filename; }
184
185 void SetDigiRootFile(TString filename) { fDigiFileName = filename; }
186
187 static Int_t GetRunIdFromFile(TString name);
188 static Bool_t IsRootFile(TString name);
189 static Bool_t IsRawFile(TString name);
190
191 BmnRawSource* GetRawConverter() const { return fRawSource; }
192
193 BmnDecoder* GetDecoder() const { return fDecoder; }
194
195 void SetTaskMode(bool v = true)
196 {
197 isTaskMode = v;
198 if (fRawSource)
199 fRawSource->SetTaskMode(isTaskMode);
200 if (fDecoder)
201 fDecoder->SetTaskMode(isTaskMode);
202 }
203
204 bool GetTaskMode() const { return isTaskMode; }
205
206 /***
207 Set forward mode (without intermediate raw root file)
208 */
209 void SetForwardMode(bool v = true)
210 {
211 isForwardMode = v;
212 if (fRawSource)
213 fRawSource->SetForwardMode(isForwardMode);
214 if (fDecoder)
215 fDecoder->SetForwardMode(isForwardMode);
216 }
217
218 bool GetForwardMode() const { return isForwardMode; }
219
220 private:
221 BmnRawSource* fRawSource;
222 BmnDecoder* fDecoder;
223
224 Bool_t isTaskMode;
225 Bool_t isForwardMode;
226
227 const TTimeStamp TimeZero = TTimeStamp(time_t(0), 0);
228 Double_t workTime_cpu = 0.0;
229 Double_t workTime_real = 0.0;
230
231 std::map<DetectorId, bool> fDetectorSetup;
232 bool isRawRootInputFile;
233 bool fApplyThreshold;
234
235 UInt_t fRunId;
236 UInt_t fPeriodId;
237 // UInt_t fEventId;
238 UInt_t fNTotalEvents;
239 UInt_t fNSignalEvents;
240 UInt_t fStartEventId;
241
242 string fDecoderConfigFileName;
243 TString fRootFileName;
244 TString fRootDirPath;
245 TString fDigiDirPath;
246 TString fRawFileName;
247 TString fDigiFileName;
248 TString fCalibFileName;
249 TString fSubName;
250
251 ULong_t fMaxEvent;
252
253 UInt_t fDat; // current 32-bits word
254 UInt_t syncCounter;
255 BmnSetup fBmnSetup;
256 UInt_t fPedEvCntrBySpill;
257 UInt_t fPedEvCntr;
258 UInt_t fNoiseEvCntr;
259 Int_t fEvForPedestals;
260 Bool_t fPedEnough;
261 Bool_t fNoiseEnough;
262 Bool_t fUseCalibFile;
263 UInt_t fT0Serial;
264
265 Int_t fVerbose;
266};
267
268#endif
__m128 v
Definition P4_F32vec4.h:1
BmnStatus
Definition BmnEnums.h:24
BmnSetup
Definition BmnEnums.h:89
void SetRunId(UInt_t v)
Definition BmnDecoder.h:124
void SetForwardMode(bool v=true)
Definition BmnDecoder.h:258
void SetDetectorSetup(std::map< DetectorId, bool > setup)
Definition BmnDecoder.h:229
TTimeStamp GetRunEndTime() const
Definition BmnDecoder.h:142
void SetDecoderConfigFileName(string FileName)
Definition BmnDecoder.h:276
void SetPeriodId(UInt_t v)
Definition BmnDecoder.h:126
void SetEvForPedestals(UInt_t v)
Definition BmnDecoder.h:231
UInt_t GetEventId() const
Definition BmnDecoder.h:138
TTimeStamp GetRunStartTime() const
Definition BmnDecoder.h:140
void SetTaskMode(bool v=true)
Definition BmnDecoder.h:251
void SetDetectorSetup(std::map< DetectorId, bool > setup)
BmnSetup GetBmnSetup() const
static double threshCsc
void SetPeriodId(UInt_t v)
static double correctionSil
void SetTaskMode(bool v=true)
virtual ~BmnRawDataDecoder()
BmnDecoder * GetDecoder() const
UInt_t GetEventId() const
static double correctionGem
BmnStatus ConvertRawToRoot()
static Bool_t IsRootFile(TString name)
static double correctionCsc
void SetVerbose(Int_t v)
static Int_t GetRunIdFromFile(TString name)
BmnStatus DecodeDataToDigiIterate()
static double threshSil
void SetDigiRootFile(TString filename)
void SetEvForPedestals(UInt_t v)
void SetBmnSetup(BmnSetup v)
BmnStatus InitConverter(TString FileName)
UInt_t GetNevents() const
static Bool_t IsRawFile(TString name)
BmnStatus InitConverter()
void SetRunId(UInt_t v)
UInt_t GetRunId() const
BmnStatus ConvertRawToRootIterate(UInt_t *buf, UInt_t len)
BmnRawSource * GetRawConverter() const
UInt_t GetPeriodId() const
void SetApplyThreshold(bool b)
TTimeStamp GetRunStartTime() const
BmnStatus InitDecoder()
void SetRawRootDirPath(TString path)
void SetForwardMode(bool v=true)
bool GetUseCalibFile() const
static double threshGem
BmnStatus DecodeDataToDigi()
TTimeStamp GetRunEndTime() const
void SetDecoderConfigFileName(string FileName)
void SetUseCalibFile(bool v)
BmnRawDataDecoder(TString file="", TString outfile="", ULong_t nEvents=0, ULong_t period=8)
void SetRawRootFile(TString filename)
bool GetForwardMode() const
void FillNoisyChannels()
Int_t GetVerbose() const
void SetPeriodId(UInt_t v)
void SetDecoderConfigFileName(string FileName)
void SetTaskMode(bool v=true)
void SetForwardMode(bool v=true)
void SetRunId(UInt_t v)
TTimeStamp GetRunEndTime() const
TTimeStamp GetRunStartTime() const
UInt_t GetEventId() const
a class to store JSON values
Definition json.hpp:17282
basic_json<> json
default specialization
Definition json.hpp:3337
Definition setup.py:1