BmnRoot
Loading...
Searching...
No Matches
BmnTof2Raw2DigitNew.h
Go to the documentation of this file.
1#ifndef BMNTOF2RAW2DIGITNEW_H
2#define BMNTOF2RAW2DIGITNEW_H
3
4#define NSLFIT0 "pol5"
5#define NSLFIT "pol8"
6#define HPTIMEBIN 0.02344
7#define INVHPTIMEBIN 42.6666
8
9#define TOF2_MAX_STRIPS_IN_CHAMBER 32
10#define TOF2_MAX_CHANNELS_IN_SLOT 64
11// #define TOF2_MAX_CHANNELS_IN_MODULE TOF2_MAX_CHANNELS_IN_SLOT
12#define TOF2_MAX_CHANNELS_IN_MODULE 64
13#define TOF2_MAX_CRATES 5
14#define TOF2_MAX_SLOTS_IN_CRATE 20
15// #define TOF2_MAX_CHAMBERS 24
16#define TOF2_MAX_CHAMBERS 59
17#define TOF2_MAX_CHANNEL 4000
18
19// #define TOF700_TDC_TYPE (0x11) //TDC32VL
20#define TOF700_TDC_TYPE (0x53) // TDC64VHLE
21
22#include "BmnADCDigit.h"
23#include "BmnEnums.h"
24#include "BmnSyncDigit.h"
25#include "BmnTDCDigit.h"
26#include "BmnTof2Digit.h"
27#include "Riostream.h"
28#include "TClonesArray.h"
29#include "TH2F.h"
30#include "TProfile.h"
31#include "TProfile2D.h"
32#include "TString.h"
33
34#include <bitset>
35#include <cstdlib>
36#include <iostream>
37#include <map>
38#include <unordered_map>
39
41{
42 public:
44 int crate;
45 int pair;
46 int plane;
47 int id, slot, tdc, chan, strip;
48 char side;
49};
50
52{
53 public:
54 BmnTof2Raw2DigitNew(TString mappingFile,
55 TString RunFile = "empty",
56 Int_t SlewingRun = 0,
57 UInt_t SlewingChamber = 0,
58 TString geomFile = "TOF700_geometry_run7.txt");
60
61 virtual ~BmnTof2Raw2DigitNew();
62
63 void print();
64 void getEventInfo(long long* ev, long long* t1, long long* t2);
65
66 int get_ch_tdc32vl(unsigned int tdc, unsigned int ch);
67 int get_ch_tdc64vhle(unsigned int tdc, unsigned int ch);
68 int get_ch_tdc72vhl(unsigned int tdc, unsigned int ch);
69
70 void DNL_read();
71
72 int get_t0() { return T0; }
73
74 void SetWcut(int wcut)
75 {
76 if (wcut != Wcut) {
77 Wcut = wcut;
78 for (int c = 0; c < MaxPlane; c++)
79 ReBook(c);
80 }
81 }
82 int GetWcut() { return Wcut; }
83 void SetWcutc(int c, int wcut)
84 {
85 if (c > 0 && c <= MaxPlane) {
86 if (wcut != Wcutc[c - 1]) {
87 Wcutc[c - 1] = wcut;
88 ReBook(c - 1);
89 }
90 }
91 }
92 int GetWcutc(int c)
93 {
94 if (c > 0 && c <= MaxPlane)
95 return Wcutc[c - 1];
96 else
97 return 0;
98 }
99
100 void SetWmax(int wm)
101 {
102 if (wm != Wmax) {
103 Wmax = wm;
104 for (int c = 0; c < MaxPlane; c++)
105 ReBook(c);
106 }
107 }
108 int GetWmax() { return Wmax; }
109 void SetWmaxc(int c, int wm)
110 {
111 if (c > 0 && c <= MaxPlane) {
112 if (wm != Wmaxc[c - 1]) {
113 Wmaxc[c - 1] = wm;
114 ReBook(c - 1);
115 }
116 }
117 }
118 int GetWmaxc(int c)
119 {
120 if (c > 0 && c <= MaxPlane)
121 return Wmaxc[c - 1];
122 else
123 return 0;
124 }
125
126 void SetW(int wcut, int wm)
127 {
128 if (wcut != Wcut || wm != Wmax) {
129 Wcut = wcut;
130 Wmax = wm;
131 for (int c = 0; c < MaxPlane; c++)
132 ReBook(c);
133 }
134 }
135
136 void SetWT0max(int wt0m)
137 {
138 if (wt0m != WT0max) {
139 WT0max = wt0m;
140 for (int c = 0; c < MaxPlane; c++)
141 ReBook(c);
142 }
143 }
144 int GetWT0max() { return WT0max; }
145
146 void SetWT0min(int wt0m)
147 {
148 if (wt0m != WT0min) {
149 WT0min = wt0m;
150 for (int c = 0; c < MaxPlane; c++)
151 ReBook(c);
152 }
153 }
154 int GetWT0min() { return WT0min; }
155
156 void SetT0shift(float shift) { T0shift = shift; }
157 int GetT0shift() { return T0shift; }
158
159 void SetWT0(int wt1, int wt2)
160 {
161 if (wt1 != WT0min || wt2 != WT0max) {
162 WT0min = wt1;
163 WT0max = wt2;
164 for (int c = 0; c < MaxPlane; c++)
165 ReBook(c);
166 }
167 }
168
169 void SetLeadMin(int c, int leadmin)
170 {
171 if (c > 0 && c <= MaxPlane)
172 if (leadmin != LeadMin[c - 1]) {
173 LeadMin[c - 1] = leadmin;
174 ReBook(c - 1);
175 }
176 }
177 int GetLeadMin(int c)
178 {
179 if (c > 0 && c <= MaxPlane)
180 return LeadMin[c - 1];
181 else
182 return 0;
183 }
184
185 void SetLeadMax(int c, int leadmax)
186 {
187 if (c > 0 && c <= MaxPlane)
188 if (leadmax != LeadMax[c - 1]) {
189 LeadMax[c - 1] = leadmax;
190 ReBook(c - 1);
191 }
192 }
193 int GetLeadMax(int c)
194 {
195 if (c > 0 && c <= MaxPlane)
196 return LeadMax[c - 1];
197 else
198 return 0;
199 }
200
201 void SetLeadMinMax(int c, int leadmin, int leadmax)
202 {
203 if (c > 0 && c <= MaxPlane)
204 if (leadmin != LeadMin[c - 1] || leadmax != LeadMax[c - 1]) {
205 LeadMin[c - 1] = leadmin;
206 LeadMax[c - 1] = leadmax;
207 ReBook(c - 1);
208 };
209 }
210
211 void fillPreparation(TClonesArray* data, unordered_map<UInt_t, Long64_t>* ts, Double_t t0, Double_t t0width);
212 void fillEvent(TClonesArray* data,
213 unordered_map<UInt_t, Long64_t>* ts,
214 Double_t t0,
215 Double_t t0width,
216 TClonesArray* tof2digit);
217 void fillSlewingT0(TClonesArray* data, unordered_map<UInt_t, Long64_t>* ts, Double_t t0, Double_t t0width);
218 void fillSlewing(TClonesArray* data, unordered_map<UInt_t, Long64_t>* ts, Double_t t0, Double_t t0width);
219 void fillEqualization(TClonesArray* data, unordered_map<UInt_t, Long64_t>* ts, Double_t t0, Double_t t0width);
220 void writeSlewingLimits();
221 void readSlewingLimits();
222 // void SlewingT0();
223 // void readSlewingT0();
224 // void Slewing();
225 void readSlewing(Bool_t update = false);
226 void SlewingResults();
227 // void InitEqualization();
228 void FitSlewing();
229 void Equalization();
230 void Equalization0();
231 // float slewingt0_correction(int chamber, double width, int peak);
232 // float slewing_correction(int chamber, double width, int peak);
233 void drawprep();
234 void drawprof();
235 void drawproft0();
236 int readGeom(const char* geomFile);
237 int readLRoffsets(char* LRoffsetsFile);
238 int readXYCalibration(char* xcalibration, char* ycalibration);
239 int readXYCalibrationNew(char* xcalibration, char* ycalibration);
240 int printGeom();
241 int get_strip_xyz(int chamber, int strip, float* x, float* y, float* z);
242 int get_chamber_z(int chamber, float* z);
243 int get_track_hits(float* xyz, float* cxyy, int* nhits, int* chamb, int* strip);
244 float get_hit_diff0(int chamber, int strip, float diff);
245 float get_hit_x0(int chamber, int strip, float diff);
246 void get_hit_xyz0(int chamber, int strip, float diff, float* x, float* y, float* z);
247 float get_hit_diff(int chamber, int strip, float diff_corrected);
248 float get_hit_x(int chamber, int strip, float diff_corrected);
249 void get_hit_xyz(int chamber, int strip, float diff_corrected, float* x, float* y, float* z);
250 float get_hit_xp(int chamber, int strip, float diff);
251 void get_hit_xyzp(int chamber, int strip, float diff, float* x, float* y, float* z);
252 float get_hit_xng(int chamber, int strip, float diff);
253 void get_hit_xyzng(int chamber, int strip, float diff, float* x, float* y, float* z);
254 float get_hit_xnl(int chamber, int strip, float diff);
255 void get_hit_xyznl(int chamber, int strip, float diff, float* x, float* y, float* z);
256 void ReBook(int i);
257 void Book();
258 void BookSlewing();
259 void BookSlewingResults();
260 void WriteSlewingResults();
263 Double_t* GetINL() { return &DNL_Table[0][0][0][0]; }
264
265 void SetSlewingReference(Int_t chamber, Int_t refrun, Int_t refchamber);
266
267 void SetPreparationFileName(TString prep) { fPreparationFileName = prep; }
268
269 private:
270 char filname_base[256];
271 char filname_base_results[256];
272 char filname_slewing[TOF2_MAX_CHAMBERS][256];
273 TString fPreparationFileName;
274 int chamber_slewing[TOF2_MAX_CHAMBERS];
275 int type_slewing[TOF2_MAX_CHAMBERS];
276 int fSlewCham;
277 int fSlewRun;
278 int fRUN;
279 int fPeriod;
280 int fSRC;
281 int n_rec;
283 long long EVENT, TIME_SEC, TIME_NS;
284 float T0;
285 float T0shift;
286 int Wcut;
287 int Wmax;
288 int Wcutc[TOF2_MAX_CHAMBERS];
289 int Wmaxc[TOF2_MAX_CHAMBERS];
290 int WT0min;
291 int WT0max;
292 int LeadMin[TOF2_MAX_CHAMBERS];
293 int LeadMax[TOF2_MAX_CHAMBERS];
294 int LeadMinW[TOF2_MAX_CHAMBERS][500];
295 int LeadMaxW[TOF2_MAX_CHAMBERS][500];
296 int MaxPlane;
297 int numstrip[TOF2_MAX_CHAMBERS];
299 int nslots, ncrates, nchambers;
300 float idchambers[TOF2_MAX_CHAMBERS];
302 int idcrates[TOF2_MAX_CRATES], numcrates[TOF2_MAX_CRATES];
303 double chtima[10][25][64];
304
305 unsigned devser[TOF2_MAX_CRATES][TOF2_MAX_SLOTS_IN_CRATE] = {{0}};
306 int devnum[TOF2_MAX_CRATES * TOF2_MAX_SLOTS_IN_CRATE] = {0};
307 int devcrate[TOF2_MAX_CRATES * TOF2_MAX_SLOTS_IN_CRATE] = {0};
308 int devslot[TOF2_MAX_CRATES * TOF2_MAX_SLOTS_IN_CRATE] = {0};
309
310 int numcrate(int id);
312
313 double DNL_Table[TOF2_MAX_CRATES][TOF2_MAX_SLOTS_IN_CRATE][72][1024];
315 char dnlname[TOF2_MAX_CRATES][TOF2_MAX_SLOTS_IN_CRATE][128];
316
317 TH2F *poffsets, *poffsets1, *poffsets2;
318 TProfile2D* TvsW[TOF2_MAX_CHAMBERS][4];
319 TProfile2D* TvsWt0[TOF2_MAX_CHAMBERS][4];
320 TProfile* TvsWr[TOF2_MAX_CHAMBERS][4];
321 TProfile* TvsWt0r[TOF2_MAX_CHAMBERS][4];
322 TH2F* TvsWp[TOF2_MAX_CHAMBERS][4];
323 TH2F* TvsWt0p[TOF2_MAX_CHAMBERS][4];
324 TH2F* TvsSm[TOF2_MAX_CHAMBERS][4];
325 TProfile* Toffsets[4];
326 TProfile* Toffsetsf[4];
327 TProfile* Toffsets0;
328 TProfile* pLeadMin;
329 TProfile* pLeadMax;
330 TProfile* pWlimits;
331 double Toffsets00[TOF2_MAX_CHANNEL];
332 double Toffsets00n[TOF2_MAX_CHANNEL];
333 double Toffsets00e[TOF2_MAX_CHANNEL];
334
335 TH2F* TvsS[TOF2_MAX_CHAMBERS];
336 TH2F* WvsS[TOF2_MAX_CHAMBERS];
337
338 TH1F* Nhit;
339 TH1F* Lt0;
340 TH1F* Wt0;
341 TH1F* Wts;
342 TH2F* Hchambrate;
343 TH1F* H1chambrate;
344 TH2F* Hstriprate;
345 TH2F* TvsWall[TOF2_MAX_CHAMBERS];
346 TH2F* TvsWallmax[TOF2_MAX_CHAMBERS];
347
348 float halfxwidth[TOF2_MAX_CHAMBERS];
349 float halfywidth[TOF2_MAX_CHAMBERS];
350 float xoffs, xoffs2, yoffs, zoffs;
351 int nstrips[TOF2_MAX_CHAMBERS];
352 float zchamb[TOF2_MAX_CHAMBERS];
359
362 float fVelosity;
363
366 float yslope[TOF2_MAX_CHAMBERS];
367 float yoffset[TOF2_MAX_CHAMBERS];
368
374
375 TFile* fSlewing;
376 TFile* fSlewingr;
377
378 ClassDef(BmnTof2Raw2DigitNew, 1);
379};
380#endif /* BMNTOF2RAW2DIGIT_H */
#define TOF2_MAX_STRIPS_IN_CHAMBER
#define TOF2_MAX_CHANNEL
#define TOF2_MAX_CHAMBERS
#define TOF2_MAX_SLOTS_IN_CRATE
#define TOF2_MAX_CRATES
#define TOF2_MAX_CHANNELS_IN_SLOT
int i
Definition P4_F32vec4.h:22
void fillEvent(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width, TClonesArray *tof2digit)
void getEventInfo(long long *ev, long long *t1, long long *t2)
float get_hit_diff(int chamber, int strip, float diff_corrected)
int readXYCalibrationNew(char *xcalibration, char *ycalibration)
int readXYCalibration(char *xcalibration, char *ycalibration)
int readGeom(const char *geomFile)
void get_hit_xyzp(int chamber, int strip, float diff, float *x, float *y, float *z)
void readSlewing(Bool_t update=false)
int get_strip_xyz(int chamber, int strip, float *x, float *y, float *z)
float get_hit_xp(int chamber, int strip, float diff)
int get_ch_tdc72vhl(unsigned int tdc, unsigned int ch)
void fillSlewing(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void SetLeadMin(int c, int leadmin)
float get_hit_diff0(int chamber, int strip, float diff)
void SetPreparationFileName(TString prep)
float get_hit_xnl(int chamber, int strip, float diff)
void get_hit_xyz0(int chamber, int strip, float diff, float *x, float *y, float *z)
int get_ch_tdc64vhle(unsigned int tdc, unsigned int ch)
int get_ch_tdc32vl(unsigned int tdc, unsigned int ch)
int readLRoffsets(char *LRoffsetsFile)
void SetWmaxc(int c, int wm)
void SetWcutc(int c, int wcut)
float get_hit_x(int chamber, int strip, float diff_corrected)
void get_hit_xyzng(int chamber, int strip, float diff, float *x, float *y, float *z)
void fillEqualization(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void SetW(int wcut, int wm)
float get_hit_x0(int chamber, int strip, float diff)
void get_hit_xyz(int chamber, int strip, float diff_corrected, float *x, float *y, float *z)
void fillSlewingT0(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void SetT0shift(float shift)
void fillPreparation(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void SetLeadMinMax(int c, int leadmin, int leadmax)
int get_chamber_z(int chamber, float *z)
void get_hit_xyznl(int chamber, int strip, float diff, float *x, float *y, float *z)
void SetWT0(int wt1, int wt2)
int get_track_hits(float *xyz, float *cxyy, int *nhits, int *chamb, int *strip)
void SetLeadMax(int c, int leadmax)
void SetSlewingReference(Int_t chamber, Int_t refrun, Int_t refchamber)
float get_hit_xng(int chamber, int strip, float diff)