CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemLUTReader.cxx
Go to the documentation of this file.
1// **************************************************************************/
2// authors: L. Lavezzi (univ. of Torino & INFN, Italy)
3//
4
5
6//include system lib
7#include <iostream>
8#include <iomanip>
9#include <string>
10#include <cmath>
11#include <csignal>
12
13#include "TSystem.h"
14
15#include "ReadCosmicRayData/CgemLUTReader.h"
16
17//using namespace std;
18
21}
22
23CgemLUTReader::CgemLUTReader(TString lutname) : tree(NULL) {
24 CosmicRayLUTName = lutname;
25}
26
28
30
31 const int nlayer = 3; // CHECK hardcoded
32 const int nsheet[nlayer] = {1, 2, 2}; // CHECK hardcoded
33 const int nview = 2; // CHECK hardcoded
34 int nstrip[nlayer][nview] = {{856, 1173}, {630, 1077}, {832, 1395}}; // CHECK hardcoded
35
36 // ----------------------------------------
37 f = new TFile(CosmicRayLUTName, "READ");
38 tree = (TTree*) f->Get("tree");
39 tree->SetBranchAddress("ROC",&ROC);
40 tree->SetBranchAddress("SW_FEB",&TIGER);
41 tree->SetBranchAddress("FEB",&FEB);
42 tree->SetBranchAddress("chip",&chip);
43 tree->SetBranchAddress("channel",&channel);
44 tree->SetBranchAddress("layer",&layer);
45 tree->SetBranchAddress("side",&side);
46 tree->SetBranchAddress("strip_x_graal",&strip_x_graal);
47 tree->SetBranchAddress("strip_v_graal",&strip_v_graal);
48 tree->SetBranchAddress("strip_x_boss",&strip_x_boss);
49 tree->SetBranchAddress("strip_v_boss",&strip_v_boss);
50 tree->SetBranchAddress("sheet",&sheet);
51 tree->SetBranchAddress("calib_QDC_slope",&calib_QDC_slope);
52 tree->SetBranchAddress("calib_QDC_const",&calib_QDC_const);
53 tree->SetBranchAddress("calib_QDC_saturation",&calib_QDC_saturation);
54 tree->SetBranchAddress("v_thr_T_mV",&v_thr_T_mV);
55 tree->SetBranchAddress("v_thr_E_mV",&v_thr_E_mV);
56 tree->SetBranchAddress("thr_T_fC",&thr_T_fC);
57 tree->SetBranchAddress("thr_E_fC",&thr_E_fC);
58 tree->SetBranchAddress("baseline_T_mV",&baseline_T_mV);
59 tree->SetBranchAddress("baseline_E_mV",&baseline_E_mV);
60 tree->SetBranchAddress("thr_fC",&thr_fC);
61 tree->SetBranchAddress("noise_rate_Hz",&noise_rate_Hz);
62 tree->SetBranchAddress("noise_meanQ_fC",&noise_meanQ_fC);
63 tree->SetBranchAddress("signal_meanQ_fC",&signal_meanQ_fC);
64 tree->SetBranchAddress("signal_maxQ_fC",&signal_maxQ_fC);
65 tree->SetBranchAddress("signal_rate_Hz",&signal_rate_Hz);
66 tree->SetBranchAddress("signal_startTime_ns",&signal_startTime_ns);
67 tree->SetBranchAddress("signal_stopTime_ns",&signal_stopTime_ns);
68 tree->SetBranchAddress("signal_sigmaTime_ns",&signal_sigmaTime_ns);
69 tree->SetBranchAddress("signal_FEBstartTime_ns",&signal_FEBstartTime_ns);
70 tree->SetBranchAddress("signal_FEBstopTime_ns",&signal_FEBstopTime_ns);
71 tree->SetBranchAddress("signal_FEBsigmaTime_ns",&signal_FEBsigmaTime_ns);
72 tree->SetBranchAddress("quality",&quality);
73
74 // ----------------------------------------
75 general = (TTree*) f->Get("general");
76 int First_RUN;
77 int Last_RUN;
79 int Energy_mode;
80 int HV_L1_G3; int HV_L2_G3; int HV_L3_G3;
81 int HV_L1_G2; int HV_L2_G2; int HV_L3_G2;
82 int HV_L1_G1; int HV_L2_G1; int HV_L3_G1;
83 int HV_L1_In; int HV_L2_In; int HV_L3_In;
84 int HV_L1_T2; int HV_L2_T2; int HV_L3_T2;
85 int HV_L1_T1; int HV_L2_T1; int HV_L3_T1;
86 int HV_L1_Dr; int HV_L2_Dr; int HV_L3_Dr;
87 general->SetBranchAddress("First_RUN", &First_RUN);
88 general->SetBranchAddress("Last_RUN", &Last_RUN);
89 general->SetBranchAddress("Integration_time", &Integration_time);
90 general->SetBranchAddress("Energy_mode", &Energy_mode);
91 general->SetBranchAddress("HV_L1_G3", &HV_L1_G3);
92 general->SetBranchAddress("HV_L1_G2", &HV_L1_G2);
93 general->SetBranchAddress("HV_L1_G1", &HV_L1_G1);
94 general->SetBranchAddress("HV_L2_G3", &HV_L2_G3);
95 general->SetBranchAddress("HV_L2_G2", &HV_L2_G2);
96 general->SetBranchAddress("HV_L2_G1", &HV_L2_G1);
97 general->SetBranchAddress("HV_L3_G3", &HV_L3_G3);
98 general->SetBranchAddress("HV_L3_G2", &HV_L3_G2);
99 general->SetBranchAddress("HV_L3_G1", &HV_L3_G1);
100 general->SetBranchAddress("HV_L1_Dr", &HV_L1_Dr);
101 general->SetBranchAddress("HV_L2_Dr", &HV_L2_Dr);
102 general->SetBranchAddress("HV_L3_Dr", &HV_L3_Dr);
103 general->SetBranchAddress("HV_L1_T1", &HV_L1_T1);
104 general->SetBranchAddress("HV_L2_T1", &HV_L2_T1);
105 general->SetBranchAddress("HV_L3_T1", &HV_L3_T1);
106 general->SetBranchAddress("HV_L1_T2", &HV_L1_T2);
107 general->SetBranchAddress("HV_L2_T2", &HV_L2_T2);
108 general->SetBranchAddress("HV_L3_T2", &HV_L3_T2);
109 general->SetBranchAddress("HV_L1_In", &HV_L1_In);
110 general->SetBranchAddress("HV_L2_In", &HV_L2_In);
111 general->SetBranchAddress("HV_L3_In", &HV_L3_In);
112 general->GetEntry(0);
113 // ----------------------------------------
114
115 int nchannel_off=0;
116
117 for(int ientry=0; ientry<tree->GetEntries(); ientry++) {
118 tree->GetEntry(ientry);
119
120 std::pair<int, int> pairx(strip_x_boss, ientry);
121 std::pair<int, int> pairv(strip_v_boss, ientry);
122
123 if(strip_x_boss != -1) {
124 if(layer == 0 && sheet == 0) map_L1_S1_stripx_to_entry.insert(pairx);
125 else if(layer == 1 && sheet == 0) map_L2_S2_stripx_to_entry.insert(pairx); // sheet 1 and 2 are swapped
126 else if(layer == 1 && sheet == 1) map_L2_S1_stripx_to_entry.insert(pairx); // 1 now is 0 and viceversa
127 }
128 else if(strip_v_boss != -1) {
129 if(layer == 0 && sheet == 0) map_L1_S1_stripv_to_entry.insert(pairv);
130 else if(layer == 1 && sheet == 0) map_L2_S2_stripv_to_entry.insert(pairv); // sheet 1 and 2 are swapped
131 else if(layer == 1 && sheet == 1) map_L2_S1_stripv_to_entry.insert(pairv); // 1 now is 0 and viceversa
132 }
133 else nchannel_off++;
134
135 // std::cout << "entry " << ientry << " channel " << channel << " layer " << layer << " sheet " << sheet << " ROC " << ROC << std::endl;
136 }
137
138 std::cout << "not connected TIGER channels " << nchannel_off << std::endl;
139
140}
141
142
143
144
145std::map<int, int> * CgemLUTReader::GetMap(int ilayer, int isheet, int iview) {
146
147 if(iview==0) {
148 if(ilayer == 0 && isheet == 0) return &map_L1_S1_stripx_to_entry;
149 else if(ilayer == 1 && isheet == 0) return &map_L2_S2_stripx_to_entry;
150 else if(ilayer == 1 && isheet == 1) return &map_L2_S1_stripx_to_entry;
151 }
152 else if(iview==1) {
153 if(ilayer == 0 && isheet == 0) return &map_L1_S1_stripv_to_entry;
154 else if(ilayer == 1 && isheet == 0) return &map_L2_S2_stripv_to_entry;
155 else if(ilayer == 1 && isheet == 1) return &map_L2_S1_stripv_to_entry;
156 }
157 else return NULL;
158}
159
160bool CgemLUTReader::LoadStripInfo(int ilayer, int isheet, int iview, int istrip) {
161 std::map<int, int> *mappa = GetMap(ilayer, isheet, iview);
162 if(mappa == NULL) return false;
163 std::map<int, int>::iterator it = mappa->find(istrip);
164 if (it != mappa->end()) {
165 int ientry = it->second;
166 tree->GetEntry(ientry);
167 return true;
168 }
169 return false;;
170}
171
172// --------------------------------
173int CgemLUTReader::GetROC(int ilayer, int isheet, int iview, int istrip) {
174 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
175 if(doesexist == false) return -1;
176 return ROC;
177}
178
179int CgemLUTReader::GetTIGER(int ilayer, int isheet, int iview, int istrip) {
180 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
181 if(doesexist == false) return -1;
182 return TIGER;
183}
184
185int CgemLUTReader::GetFEB(int ilayer, int isheet, int iview, int istrip) {
186 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
187 if(doesexist == false) return -1;
188 return FEB;
189}
190
191int CgemLUTReader::GetChip(int ilayer, int isheet, int iview, int istrip) {
192 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
193 if(doesexist == false) return -1;
194 return chip;
195}
196
197int CgemLUTReader::GetChannel(int ilayer, int isheet, int iview, int istrip) {
198 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
199 if(doesexist == false) return -1;
200 return channel;
201}
202
203int CgemLUTReader::GetLayer(int ilayer, int isheet, int iview, int istrip) {
204 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
205 if(doesexist == false) return -1;
206 return layer;
207}
208
209int CgemLUTReader::GetSheet(int ilayer, int isheet, int iview, int istrip) {
210 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
211 if(doesexist == false) return -1;
212 return sheet;
213}
214
215int CgemLUTReader::GetSide(int ilayer, int isheet, int iview, int istrip) {
216 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
217 if(doesexist == false) return -1;
218 return side;
219}
220
221int CgemLUTReader::GetStrip_x_GRAAL(int ilayer, int isheet, int iview, int istrip) {
222 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
223 if(doesexist == false) return -1;
224 return strip_x_graal;
225}
226
227int CgemLUTReader::GetStrip_v_GRAAL(int ilayer, int isheet, int iview, int istrip) {
228 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
229 if(doesexist == false) return -1;
230 return strip_v_graal;
231}
232
233int CgemLUTReader::GetStrip_x_BOSS(int ilayer, int isheet, int iview, int istrip) {
234 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
235 if(doesexist == false) return -1;
236 return strip_x_boss;
237}
238
239int CgemLUTReader::GetStrip_v_BOSS(int ilayer, int isheet, int iview, int istrip) {
240 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
241 if(doesexist == false) return 0.;
242 return strip_v_boss;
243}
244
245float CgemLUTReader::GetCalib_QCD_slope(int ilayer, int isheet, int iview, int istrip) {
246 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
247 if(doesexist == false) return 0.;
248 return calib_QDC_slope;
249}
250
251float CgemLUTReader::GetCalib_QCD_const(int ilayer, int isheet, int iview, int istrip) {
252 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
253 if(doesexist == false) return 0.;
254 return calib_QDC_const;
255}
256
257float CgemLUTReader::GetCalib_QCD_saturation(int ilayer, int isheet, int iview, int istrip) {
258 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
259 if(doesexist == false) return 0.;
261}
262
263float CgemLUTReader::GetV_thr_T_mV(int ilayer, int isheet, int iview, int istrip) {
264 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
265 if(doesexist == false) return 0.;
266 return v_thr_T_mV;
267}
268
269float CgemLUTReader::GetV_thr_E_mV(int ilayer, int isheet, int iview, int istrip) {
270 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
271 if(doesexist == false) return 0.;
272 return v_thr_E_mV;
273}
274
275float CgemLUTReader::Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip) {
276 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
277 if(doesexist == false) return 0.;
278 return thr_T_fC;
279}
280
281float CgemLUTReader::Get_thr_E_fC(int ilayer, int isheet, int iview, int istrip) {
282 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
283 if(doesexist == false) return 0.;
284 return thr_E_fC;
285}
286
287float CgemLUTReader::GetBaseline_T_mV(int ilayer, int isheet, int iview, int istrip) {
288 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
289 if(doesexist == false) return 0.;
290 return baseline_T_mV;
291}
292
293float CgemLUTReader::GetBaseline_E_mV(int ilayer, int isheet, int iview, int istrip) {
294 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
295 if(doesexist == false) return 0.;
296 return baseline_E_mV;
297}
298
299float CgemLUTReader::Get_thr_fC(int ilayer, int isheet, int iview, int istrip) {
300 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
301 if(doesexist == false) return 0.;
302 return thr_fC;
303}
304
305float CgemLUTReader::GetNoise_Rate_Hz(int ilayer, int isheet, int iview, int istrip) {
306 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
307 if(doesexist == false) return 0.;
308 return noise_rate_Hz;
309}
310
311float CgemLUTReader::GetNoise_MeanQ_fC(int ilayer, int isheet, int iview, int istrip) {
312 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
313 if(doesexist == false) return 0.;
314 return noise_meanQ_fC;
315}
316
317float CgemLUTReader::GetSignal_MeanQ_fC(int ilayer, int isheet, int iview, int istrip) {
318 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
319 if(doesexist == false) return 0.;
320 return signal_meanQ_fC;
321}
322
323float CgemLUTReader::GetSignal_MaxQ_fC(int ilayer, int isheet, int iview, int istrip) {
324 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
325 if(doesexist == false) return 0.;
326 return signal_maxQ_fC;
327}
328
329float CgemLUTReader::GetSignal_Rate_Hz(int ilayer, int isheet, int iview, int istrip) {
330 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
331 if(doesexist == false) return 0.;
332 return signal_rate_Hz;
333}
334
335float CgemLUTReader::GetSignal_StartTime_ns(int ilayer, int isheet, int iview, int istrip) {
336 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
337 if(doesexist == false) return 0.;
338 return signal_startTime_ns;
339}
340
341float CgemLUTReader::GetSignal_StopTime_ns(int ilayer, int isheet, int iview, int istrip) {
342 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
343 if(doesexist == false) return 0.;
344 return signal_stopTime_ns;
345}
346
347float CgemLUTReader::GetSignal_SigmaTime_ns(int ilayer, int isheet, int iview, int istrip) {
348 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
349 if(doesexist == false) return 0.;
350 return signal_sigmaTime_ns;
351}
352
353float CgemLUTReader::GetSignal_FEBStartTime_ns(int ilayer, int isheet, int iview, int istrip) {
354 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
355 if(doesexist == false) return 0.;
357}
358
359float CgemLUTReader::GetSignal_FEBStopTime_ns(int ilayer, int isheet, int iview, int istrip) {
360 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
361 if(doesexist == false) return 0.;
363}
364
365float CgemLUTReader::GetSignal_FEBSigmaTime_ns(int ilayer, int isheet, int iview, int istrip) {
366 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
367 if(doesexist == false) return 0.;
369}
370
371int CgemLUTReader::GetQuality(int ilayer, int isheet, int iview, int istrip) {
372 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
373 if(doesexist == false) return -1;
374 return quality;
375}
376// ------------------------------------------------
377bool CgemLUTReader::PrintMap(int ilayer, int isheet, int iview) {
378
379 std::map<int, int> *mappa = GetMap(ilayer, isheet, iview);
380 if(mappa == NULL) return false;
381
382 int nstrip = mappa->size();
383 std::cout << "MAPPING STRIPS of view " << iview << " on sheet " << isheet << " of layer " << ilayer << std::endl;
384 std::cout << "N. OF STRIP " << nstrip << std::endl;
385
386 std::map<int, int>::iterator it;
387 for(int istrip=0; istrip < nstrip; istrip++) {
388 it = mappa->find(istrip);
389 int ientry = it->second;
390 tree->GetEntry(ientry);
391 std::cout << "strip " << istrip << " channel " << channel << " ROC " << ROC << " TIGER " << TIGER << " FEB " << FEB << std::endl;
392 }
393
394 return true;
395}
int GetChip(int ilayer, int isheet, int iview, int istrip)
float GetSignal_StartTime_ns(int ilayer, int isheet, int iview, int istrip)
float GetCalib_QCD_const(int ilayer, int isheet, int iview, int istrip)
int GetQuality(int ilayer, int isheet, int iview, int istrip)
int GetROC(int ilayer, int isheet, int iview, int istrip)
float GetSignal_FEBStopTime_ns(int ilayer, int isheet, int iview, int istrip)
float GetCalib_QCD_saturation(int ilayer, int isheet, int iview, int istrip)
float GetNoise_Rate_Hz(int ilayer, int isheet, int iview, int istrip)
bool LoadStripInfo(int ilayer, int isheet, int iview, int istrip)
float Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip)
float GetSignal_FEBStartTime_ns(int ilayer, int isheet, int iview, int istrip)
float GetCalib_QCD_slope(int ilayer, int isheet, int iview, int istrip)
bool PrintMap(int ilayer, int isheet, int iview)
int GetStrip_x_GRAAL(int ilayer, int isheet, int iview, int istrip)
float GetSignal_MaxQ_fC(int ilayer, int isheet, int iview, int istrip)
float Get_thr_E_fC(int ilayer, int isheet, int iview, int istrip)
float GetV_thr_E_mV(int ilayer, int isheet, int iview, int istrip)
float GetV_thr_T_mV(int ilayer, int isheet, int iview, int istrip)
int GetSheet(int ilayer, int isheet, int iview, int istrip)
float GetSignal_MeanQ_fC(int ilayer, int isheet, int iview, int istrip)
float GetSignal_Rate_Hz(int ilayer, int isheet, int iview, int istrip)
int GetStrip_v_GRAAL(int ilayer, int isheet, int iview, int istrip)
int GetChannel(int ilayer, int isheet, int iview, int istrip)
float GetSignal_FEBSigmaTime_ns(int ilayer, int isheet, int iview, int istrip)
std::map< int, int > * GetMap(int ilayer, int isheet, int iview)
float GetSignal_SigmaTime_ns(int ilayer, int isheet, int iview, int istrip)
int GetTIGER(int ilayer, int isheet, int iview, int istrip)
int GetSide(int ilayer, int isheet, int iview, int istrip)
float GetBaseline_E_mV(int ilayer, int isheet, int iview, int istrip)
int GetLayer(int ilayer, int isheet, int iview, int istrip)
int GetStrip_x_BOSS(int ilayer, int isheet, int iview, int istrip)
float GetSignal_StopTime_ns(int ilayer, int isheet, int iview, int istrip)
float Get_thr_fC(int ilayer, int isheet, int iview, int istrip)
int GetStrip_v_BOSS(int ilayer, int isheet, int iview, int istrip)
int GetFEB(int ilayer, int isheet, int iview, int istrip)
float GetNoise_MeanQ_fC(int ilayer, int isheet, int iview, int istrip)
float GetBaseline_T_mV(int ilayer, int isheet, int iview, int istrip)