CGEM BOSS 6.6.5.i
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) - R. Farinelli (INFN Ferrara, 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
16
17using 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 general = (TTree*) f->Get("general");
75 int First_RUN;
76 int Last_RUN;
78 int Energy_mode;
79 int HV_L1_G3; int HV_L2_G3; int HV_L3_G3;
80 int HV_L1_G2; int HV_L2_G2; int HV_L3_G2;
81 int HV_L1_G1; int HV_L2_G1; int HV_L3_G1;
82 int HV_L1_In; int HV_L2_In; int HV_L3_In;
83 int HV_L1_T2; int HV_L2_T2; int HV_L3_T2;
84 int HV_L1_T1; int HV_L2_T1; int HV_L3_T1;
85 int HV_L1_Dr; int HV_L2_Dr; int HV_L3_Dr;
86 general->SetBranchAddress("First_RUN", &First_RUN);
87 general->SetBranchAddress("Last_RUN", &Last_RUN);
88 general->SetBranchAddress("Integration_time", &Integration_time);
89 general->SetBranchAddress("Energy_mode", &Energy_mode);
90 general->SetBranchAddress("HV_L1_G3", &HV_L1_G3);
91 general->SetBranchAddress("HV_L1_G2", &HV_L1_G2);
92 general->SetBranchAddress("HV_L1_G1", &HV_L1_G1);
93 general->SetBranchAddress("HV_L2_G3", &HV_L2_G3);
94 general->SetBranchAddress("HV_L2_G2", &HV_L2_G2);
95 general->SetBranchAddress("HV_L2_G1", &HV_L2_G1);
96 general->SetBranchAddress("HV_L3_G3", &HV_L3_G3);
97 general->SetBranchAddress("HV_L3_G2", &HV_L3_G2);
98 general->SetBranchAddress("HV_L3_G1", &HV_L3_G1);
99 general->SetBranchAddress("HV_L1_Dr", &HV_L1_Dr);
100 general->SetBranchAddress("HV_L2_Dr", &HV_L2_Dr);
101 general->SetBranchAddress("HV_L3_Dr", &HV_L3_Dr);
102 general->SetBranchAddress("HV_L1_T1", &HV_L1_T1);
103 general->SetBranchAddress("HV_L2_T1", &HV_L2_T1);
104 general->SetBranchAddress("HV_L3_T1", &HV_L3_T1);
105 general->SetBranchAddress("HV_L1_T2", &HV_L1_T2);
106 general->SetBranchAddress("HV_L2_T2", &HV_L2_T2);
107 general->SetBranchAddress("HV_L3_T2", &HV_L3_T2);
108 general->SetBranchAddress("HV_L1_In", &HV_L1_In);
109 general->SetBranchAddress("HV_L2_In", &HV_L2_In);
110 general->SetBranchAddress("HV_L3_In", &HV_L3_In);
111 general->GetEntry(0);
112 // ----------------------------------------
113
114 int nchannel_off=0;
115
116 for(int ientry=0; ientry<tree->GetEntries(); ientry++) {
117 tree->GetEntry(ientry);
118
119 std::pair<int, int> pairx(strip_x_boss, ientry);
120 std::pair<int, int> pairv(strip_v_boss, ientry);
121
122 if(strip_x_boss != -1) {
123 if(layer == 0 && sheet == 0) map_L1_S1_stripx_to_entry.insert(pairx);
124 else if(layer == 1 && sheet == 0) map_L2_S1_stripx_to_entry.insert(pairx); // sheet 1 and 2 are swapped
125 else if(layer == 1 && sheet == 1) map_L2_S2_stripx_to_entry.insert(pairx); // 1 now is 0 and viceversa
126 else if(layer == 2 && sheet == 0) map_L3_S1_stripx_to_entry.insert(pairx);
127 else if(layer == 2 && sheet == 1) map_L3_S2_stripx_to_entry.insert(pairx);
128 }
129 else if(strip_v_boss != -1) {
130 if(layer == 0 && sheet == 0) map_L1_S1_stripv_to_entry.insert(pairv);
131 else if(layer == 1 && sheet == 0) map_L2_S1_stripv_to_entry.insert(pairv); // sheet 1 and 2 are swapped
132 else if(layer == 1 && sheet == 1) map_L2_S2_stripv_to_entry.insert(pairv); // 1 now is 0 and viceversa
133 else if(layer == 2 && sheet == 0) map_L3_S1_stripv_to_entry.insert(pairv);
134 else if(layer == 2 && sheet == 1) map_L3_S2_stripv_to_entry.insert(pairv);
135 }
136 else nchannel_off++;
137
138 // std::cout << "entry " << ientry << " channel " << channel << " layer " << layer << " sheet " << sheet << " ROC " << ROC << std::endl;
139 }
140
141 std::cout <<"The number of channels not connected to strips is: " << nchannel_off << "(i.e. strip X&V = -1)" <<std::endl;
142
143}
144
145
146
147
148std::map<int, int> * CgemLUTReader::GetMap(int ilayer, int isheet, int iview) {
149
150 if(iview==0) {
151 if(ilayer == 0 && isheet == 0) return &map_L1_S1_stripx_to_entry;
152 else if(ilayer == 1 && isheet == 0) return &map_L2_S1_stripx_to_entry; // unswapped - farinelli
153 else if(ilayer == 1 && isheet == 1) return &map_L2_S2_stripx_to_entry; // unswapped - farinelli
154 else if(ilayer == 2 && isheet == 0) return &map_L3_S1_stripx_to_entry;
155 else if(ilayer == 2 && isheet == 1) return &map_L3_S2_stripx_to_entry;
156 }
157 else if(iview==1) {
158 if(ilayer == 0 && isheet == 0) return &map_L1_S1_stripv_to_entry;
159 else if(ilayer == 1 && isheet == 0) return &map_L2_S1_stripv_to_entry; // unswapped - farinelli
160 else if(ilayer == 1 && isheet == 1) return &map_L2_S2_stripv_to_entry; // unswapped - farinelli
161 else if(ilayer == 2 && isheet == 0) return &map_L3_S1_stripv_to_entry;
162 else if(ilayer == 2 && isheet == 1) return &map_L3_S2_stripv_to_entry;
163 }
164 else return NULL;
165}
166
167bool CgemLUTReader::LoadStripInfo(int ilayer, int isheet, int iview, int istrip) {
168 std::map<int, int> *mappa = GetMap(ilayer, isheet, iview);
169 if(mappa == NULL) return false;
170 std::map<int, int>::iterator it = mappa->find(istrip);
171 if (it != mappa->end()) {
172 int ientry = it->second;
173 tree->GetEntry(ientry);
174 return true;
175 }
176 return false;;
177}
178
179// --------------------------------
180int CgemLUTReader::GetROC(int ilayer, int isheet, int iview, int istrip) {
181 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
182 if(doesexist == false) return -1;
183 return ROC;
184}
185
186int CgemLUTReader::GetTIGER(int ilayer, int isheet, int iview, int istrip) {
187 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
188 if(doesexist == false) return -1;
189 return TIGER;
190}
191
192int CgemLUTReader::GetFEB(int ilayer, int isheet, int iview, int istrip) {
193 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
194 if(doesexist == false) return -1;
195 return FEB;
196}
197
198int CgemLUTReader::GetChip(int ilayer, int isheet, int iview, int istrip) {
199 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
200 if(doesexist == false) return -1;
201 return chip;
202}
203
204int CgemLUTReader::GetChannel(int ilayer, int isheet, int iview, int istrip) {
205 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
206 if(doesexist == false) return -1;
207 return channel;
208}
209
210int CgemLUTReader::GetLayer(int ilayer, int isheet, int iview, int istrip) {
211 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
212 if(doesexist == false) return -1;
213 return layer;
214}
215
216int CgemLUTReader::GetSheet(int ilayer, int isheet, int iview, int istrip) {
217 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
218 if(doesexist == false) return -1;
219 return sheet;
220}
221
222int CgemLUTReader::GetSide(int ilayer, int isheet, int iview, int istrip) {
223 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
224 if(doesexist == false) return -1;
225 return side;
226}
227
228int CgemLUTReader::GetStrip_x_GRAAL(int ilayer, int isheet, int iview, int istrip) {
229 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
230 if(doesexist == false) return -1;
231 return strip_x_graal;
232}
233
234int CgemLUTReader::GetStrip_v_GRAAL(int ilayer, int isheet, int iview, int istrip) {
235 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
236 if(doesexist == false) return -1;
237 return strip_v_graal;
238}
239
240int CgemLUTReader::GetStrip_x_BOSS(int ilayer, int isheet, int iview, int istrip) {
241 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
242 if(doesexist == false) return -1;
243 return strip_x_boss;
244}
245
246int CgemLUTReader::GetStrip_v_BOSS(int ilayer, int isheet, int iview, int istrip) {
247 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
248 if(doesexist == false) return 0.;
249 return strip_v_boss;
250}
251
252float CgemLUTReader::GetCalib_QCD_slope(int ilayer, int isheet, int iview, int istrip) {
253 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
254 if(doesexist == false) return 0.;
255 return calib_QDC_slope;
256}
257
258float CgemLUTReader::GetCalib_QCD_const(int ilayer, int isheet, int iview, int istrip) {
259 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
260 if(doesexist == false) return 0.;
261 return calib_QDC_const;
262}
263
264float CgemLUTReader::GetCalib_QCD_saturation(int ilayer, int isheet, int iview, int istrip) {
265 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
266 if(doesexist == false) return 0.;
268}
269
270float CgemLUTReader::GetV_thr_T_mV(int ilayer, int isheet, int iview, int istrip) {
271 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
272 if(doesexist == false) return 0.;
273 return v_thr_T_mV;
274}
275
276float CgemLUTReader::GetV_thr_E_mV(int ilayer, int isheet, int iview, int istrip) {
277 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
278 if(doesexist == false) return 0.;
279 return v_thr_E_mV;
280}
281
282float CgemLUTReader::Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip) {
283 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
284 if(doesexist == false) return 0.;
285 return thr_T_fC;
286}
287
288float CgemLUTReader::Get_thr_E_fC(int ilayer, int isheet, int iview, int istrip) {
289 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
290 if(doesexist == false) return 0.;
291 return thr_E_fC;
292}
293
294float CgemLUTReader::GetBaseline_T_mV(int ilayer, int isheet, int iview, int istrip) {
295 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
296 if(doesexist == false) return 0.;
297 return baseline_T_mV;
298}
299
300float CgemLUTReader::GetBaseline_E_mV(int ilayer, int isheet, int iview, int istrip) {
301 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
302 if(doesexist == false) return 0.;
303 return baseline_E_mV;
304}
305
306float CgemLUTReader::Get_thr_fC(int ilayer, int isheet, int iview, int istrip) {
307 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
308 if(doesexist == false) return 0.;
309 return thr_fC;
310}
311
312float CgemLUTReader::GetNoise_Rate_Hz(int ilayer, int isheet, int iview, int istrip) {
313 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
314 if(doesexist == false) return 0.;
315 return noise_rate_Hz;
316}
317
318float CgemLUTReader::GetNoise_MeanQ_fC(int ilayer, int isheet, int iview, int istrip) {
319 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
320 if(doesexist == false) return 0.;
321 return noise_meanQ_fC;
322}
323
324float CgemLUTReader::GetSignal_MeanQ_fC(int ilayer, int isheet, int iview, int istrip) {
325 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
326 if(doesexist == false) return 0.;
327 return signal_meanQ_fC;
328}
329
330float CgemLUTReader::GetSignal_MaxQ_fC(int ilayer, int isheet, int iview, int istrip) {
331 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
332 if(doesexist == false) return 0.;
333 return signal_maxQ_fC;
334}
335
336float CgemLUTReader::GetSignal_Rate_Hz(int ilayer, int isheet, int iview, int istrip) {
337 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
338 if(doesexist == false) return 0.;
339 return signal_rate_Hz;
340}
341
342float CgemLUTReader::GetSignal_StartTime_ns(int ilayer, int isheet, int iview, int istrip) {
343 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
344 if(doesexist == false) return 0.;
345 return signal_startTime_ns;
346}
347
348float CgemLUTReader::GetSignal_StopTime_ns(int ilayer, int isheet, int iview, int istrip) {
349 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
350 if(doesexist == false) return 0.;
351 return signal_stopTime_ns;
352}
353
354float CgemLUTReader::GetSignal_SigmaTime_ns(int ilayer, int isheet, int iview, int istrip) {
355 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
356 if(doesexist == false) return 0.;
357 return signal_sigmaTime_ns;
358}
359
360float CgemLUTReader::GetSignal_FEBStartTime_ns(int ilayer, int isheet, int iview, int istrip) {
361 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
362 if(doesexist == false) return 0.;
364}
365
366float CgemLUTReader::GetSignal_FEBStopTime_ns(int ilayer, int isheet, int iview, int istrip) {
367 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
368 if(doesexist == false) return 0.;
370}
371
372float CgemLUTReader::GetSignal_FEBSigmaTime_ns(int ilayer, int isheet, int iview, int istrip) {
373 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
374 if(doesexist == false) return 0.;
376}
377
378int CgemLUTReader::GetQuality(int ilayer, int isheet, int iview, int istrip) {
379 bool doesexist = LoadStripInfo(ilayer, isheet, iview, istrip);
380 if(doesexist == false) return -1;
381 return quality;
382}
383// ------------------------------------------------
384bool CgemLUTReader::PrintMap(int ilayer, int isheet, int iview) {
385
386 std::map<int, int> *mappa = GetMap(ilayer, isheet, iview);
387 if(mappa == NULL) return false;
388
389 int nstrip = mappa->size();
390 std::cout << "MAPPING STRIPS of view " << iview << " on sheet " << isheet << " of layer " << ilayer << std::endl;
391 std::cout << "N. OF STRIP " << nstrip << std::endl;
392
393 std::map<int, int>::iterator it;
394 for(int istrip=0; istrip < nstrip; istrip++) {
395 it = mappa->find(istrip);
396 int ientry = it->second;
397 tree->GetEntry(ientry);
398 std::cout << "strip " << istrip << " channel " << channel << " ROC " << ROC << " TIGER " << TIGER << " FEB " << FEB << std::endl;
399 }
400
401 return true;
402}
std::map< int, int > map_L3_S2_stripx_to_entry
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)
std::map< int, int > map_L1_S1_stripx_to_entry
float signal_startTime_ns
float calib_QDC_saturation
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)
std::map< int, int > map_L2_S2_stripx_to_entry
float signal_FEBstopTime_ns
float GetNoise_Rate_Hz(int ilayer, int isheet, int iview, int istrip)
bool LoadStripInfo(int ilayer, int isheet, int iview, int istrip)
std::map< int, int > map_L2_S1_stripv_to_entry
float Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip)
std::map< int, int > map_L3_S1_stripx_to_entry
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)
std::map< int, int > map_L1_S1_stripv_to_entry
float signal_sigmaTime_ns
int GetStrip_x_GRAAL(int ilayer, int isheet, int iview, int istrip)
float GetSignal_MaxQ_fC(int ilayer, int isheet, int iview, int istrip)
std::map< int, int > map_L2_S1_stripx_to_entry
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)
TString CosmicRayLUTName
int GetSheet(int ilayer, int isheet, int iview, int istrip)
std::map< int, int > map_L3_S1_stripv_to_entry
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 signal_FEBsigmaTime_ns
float GetSignal_SigmaTime_ns(int ilayer, int isheet, int iview, int istrip)
float signal_stopTime_ns
int GetTIGER(int ilayer, int isheet, int iview, int istrip)
int GetSide(int ilayer, int isheet, int iview, int istrip)
float signal_FEBstartTime_ns
float GetBaseline_E_mV(int ilayer, int isheet, int iview, int istrip)
int GetLayer(int ilayer, int isheet, int iview, int istrip)
std::map< int, int > map_L3_S2_stripv_to_entry
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)
std::map< int, int > map_L2_S2_stripv_to_entry
float GetBaseline_T_mV(int ilayer, int isheet, int iview, int istrip)