HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hmdcwirestat.cc
Go to the documentation of this file.
1 //_HADES_CLASS_DESCRIPTION
2 ////////////////////////////////////////////////////////////////////////////
3 //*-- AUTHOR : J. Markert
4 // Modify 05.04.2013: O.Pechenova
5 ////////////////////////////////////////////////////////////////////////////
6 // HMdcWireStat
7 //
8 // Container class for lookup parameters of the status of the
9 // wire (working or dead + noise + efficiency).
10 // The parameters are stored in TH2F histograms which can be plotted.
11 // This container is needed by HMdcDigitizer and HMdcTrackFinder
12 //
13 // THe Status value is coded in the following way
14 //
15 // status of the wire: 1=working,
16 // -1=not connected,
17 // -3=no correct offset,
18 // -5=drop in efficiency,
19 // -7=dead,
20 // -10=init
21 //
22 //
23 ////////////////////////////////////////////////////////////////////////////
24 #include "hmdcwirestat.h"
25 #include "hmessagemgr.h"
26 #include "hparamlist.h"
27 #include "TStyle.h"
28 #include "TObjArray.h"
29 #include "TH1.h"
30 #include "TH2F.h"
31 #include <stdlib.h>
32 
34 
35 HMdcWireStat::HMdcWireStat(const Char_t* name,const Char_t* title,
36  const Char_t* context)
37  : HParCond(name,title,context)
38 {
39  //
40  Int_t size = 6*4*6*220;
41  statusmap .Set(size);
42  efficiency.Set(size);
43  offset .Set(size);
44  mb .Set(size);
45  tdc .Set(size);
46  clear();
47 }
49 {
50  // destructor
51 }
53 {
54  statusmap .Reset(-10);
55  efficiency.Reset(-10);
56  offset .Reset(-10);
57  mb .Reset(-10);
58  tdc .Reset(-10);
59 
60  status=kFALSE;
62  changed=kFALSE;
63 }
65 {
66  Int_t working; // 1
67  Int_t notconnected; // -1
68  Int_t nooffset; // -3
69  Int_t dropeffic; // -5
70  Int_t dead; // -7
71 
72  Int_t workingsum = 0;
73  Int_t notconnectedsum = 0;
74  Int_t nooffsetsum = 0;
75  Int_t dropefficsum = 0;
76  Int_t deadsum = 0;
77  Int_t stat;
78  for(Int_t s = 0; s < 6; s ++){
79  for(Int_t m = 0; m < 4; m ++){
80  working = 0;
81  notconnected = 0;
82  nooffset = 0;
83  dropeffic = 0;
84  dead = 0;
85  for(Int_t l = 0; l < 6; l ++){
86  for(Int_t c = 0; c < 220; c ++){
87 
88  stat = statusmap[index(s,m,l,c)];
89  if(stat == 1) working ++;
90  if(stat == -1) notconnected ++;
91  if(stat == -3) nooffset ++;
92  if(stat == -5) dropeffic ++;
93  if(stat == -7) dead ++;
94  }
95  }
96  workingsum = workingsum + working;
97  notconnectedsum= notconnectedsum + notconnected;
98  nooffsetsum = nooffsetsum + nooffset;
99  dropefficsum = dropefficsum + dropeffic;
100  deadsum = deadsum + dead;
101  printf("s %i m %i \n" ,s,m);
102  printf(" working: %i \n",working);
103  printf(" not connected: %i \n",notconnected);
104  printf(" no calibration: %i \n",nooffset);
105  printf("drop in efficiency: %i \n",dropeffic);
106  printf(" dead: %i \n",dead);
107  }
108  }
109 
110  printf("SUM\n");
111  printf(" working: %i \n",workingsum);
112  printf(" not connected: %i \n",notconnectedsum);
113  printf(" no calibration: %i \n",nooffsetsum);
114  printf("drop in efficiency: %i \n",dropefficsum);
115  printf(" dead: %i \n",deadsum);
116 
117 }
119 {
120  Int_t working; // 1
121  Int_t notconnected; // -1
122  Int_t nooffset; // -3
123  Int_t dropeffic; // -5
124  Int_t dead; // -7
125 
126  Int_t workingsum = 0;
127  Int_t notconnectedsum = 0;
128  Int_t nooffsetsum = 0;
129  Int_t dropefficsum = 0;
130  Int_t deadsum = 0;
131  Int_t stat;
132  for(Int_t s = 0; s < 6; s ++){
133  for(Int_t m = 0; m < 4; m ++){
134  working = 0;
135  notconnected = 0;
136  nooffset = 0;
137  dropeffic = 0;
138  dead = 0;
139  for(Int_t l = 0; l < 6; l ++){
140  for(Int_t c = 0; c< 220; c ++){
141 
142  stat=statusmap[index(s,m,l,c)];
143  if(stat == 1) working ++;
144  if(stat == -1) notconnected ++;
145  if(stat == -3) nooffset ++;
146  if(stat == -5) dropeffic ++;
147  if(stat == -7) dead ++;
148  }
149  }
150  workingsum = workingsum + working;
151  notconnectedsum= notconnectedsum + notconnected;
152  nooffsetsum = nooffsetsum + nooffset;
153  dropefficsum = dropefficsum + dropeffic;
154  deadsum = deadsum + dead;
155  }
156  }
157 
158  printf("SUM\n");
159  printf(" working: %i \n",workingsum);
160  printf(" not connected: %i \n",notconnectedsum);
161  printf(" no calibration: %i \n",nooffsetsum);
162  printf("drop in efficiency: %i \n",dropefficsum);
163  printf(" dead: %i \n",deadsum);
164 
165 }
167 {
168  Int_t working; // 1
169  Int_t notconnected; // -1
170  Int_t nooffset; // -3
171  Int_t dead; // -7
172 
173  Int_t workingsum = 0;
174  Int_t notconnectedsum = 0;
175  Int_t nooffsetsum = 0;
176  Int_t deadsum = 0;
177  Int_t stat;
178  for(Int_t s = 0; s < 6; s ++){
179  for(Int_t m = 0; m < 4; m ++){
180  working = 0;
181  notconnected = 0;
182  nooffset = 0;
183  dead = 0;
184  for(Int_t l = 0; l < 6; l ++){
185  for(Int_t c = 0; c < 220; c ++){
186 
187  stat = statusmap[index(s,m,l,c)];
188  if(stat == 1) working ++;
189  if(stat == -1) notconnected ++;
190  if(stat == -3) nooffset ++;
191  if(stat == -7) dead ++;
192  }
193  }
194  workingsum = workingsum + working;
195  notconnectedsum = notconnectedsum + notconnected;
196  nooffsetsum = nooffsetsum + nooffset;
197  deadsum = deadsum + dead;
198  }
199  }
200  return nooffsetsum;
201 }
202 Int_t HMdcWireStat::getDeadWires(Int_t sec,Int_t mod)
203 {
204  Int_t working = 0;
205  Int_t notconnected = 0;
206  Int_t nooffset = 0;
207  Int_t dead = 0;
208  Int_t s = sec;
209  Int_t m = mod;
210  Int_t stat;
211  for(Int_t l = 0; l < 6; l ++){
212  for(Int_t c = 0; c <220; c ++){
213 
214  stat = statusmap[index(s,m,l,c)];
215  if(stat == 1) working ++;
216  if(stat == -1) notconnected ++;
217  if(stat == -3) nooffset ++;
218  if(stat == -7) dead ++;
219  }
220  }
221  return nooffset;
222 }
224 {
225  // prints the parameters of HMdcWireStat to the screen.
226  SEPERATOR_msg("#",60);
227  INFO_msg(10,HMessageMgr::DET_MDC,"HMdcWireStat:");
228  INFO_msg(10,HMessageMgr::DET_MDC,"Status:");
229  for(Int_t s = 0; s < 6; s ++){
230  for(Int_t m = 0; m < 4; m ++){
231  for(Int_t l = 0; l < 6; l ++){
232  for(Int_t c = 0; c < 220; c ++){
233  Int_t ind = index(s,m,l,c);
234  gHades->getMsg()->info(10,HMessageMgr::DET_MDC,GetName(),
235  "s %i m %i l %i c %3i mb %2i tdc %2i status %i efficiency %5.4f offset %5.4f",
236  s,m,l,c, mb[ind], tdc[ind], statusmap[ind], efficiency[ind], offset[ind]);
237  }
238  }
239  }
240  }
241  SEPERATOR_msg("#",60);
242 }
244 {
245  // Puts all params of HMdcWireStat to the parameter list of
246  // HParamList (which ist used by the io);
247  if (!l) return;
248 
249  l->add("mb" ,mb);
250  l->add("tdc" ,tdc);
251  l->add("status" ,statusmap);
252  l->add("efficiency",efficiency);
253  l->add("offset" ,offset);
254 }
256 {
257  if (!l) return kFALSE;
258 
259  if(!( l->fill("mb" ,&mb ))) return kFALSE;
260  if(!( l->fill("tdc" ,&tdc))) return kFALSE;
261  if(!( l->fill("status" ,&statusmap))) return kFALSE;
262  if(!( l->fill("efficiency",&efficiency)))return kFALSE;
263  if(!( l->fill("offset" ,&offset )))return kFALSE;
264 
265 
266  return kTRUE;
267 }
269 {
270  gStyle->SetOptStat(0);
271  Char_t name[400];
272  sprintf(name,"%s","Mb_vs_Tdc");
273  TCanvas* result = new TCanvas(name,name,1000,800);
274  result->Divide(6,4);
275 
276  TH2F* hmb_vs_tdc[6][4];
277  Int_t mbo,t,st;
278  for(Int_t sec = 0; sec < 6; sec ++){
279  for(Int_t mod = 0; mod < 4; mod ++){
280  sprintf(name,"%s%i%s%i","hStatusMb_vs_Tdc_sec",sec,"_mod",mod);
281  hmb_vs_tdc[sec][mod] = new TH2F(name,name,96,0,96,16,0,16);
282  hmb_vs_tdc[sec][mod]->SetXTitle("tdc channel");
283  hmb_vs_tdc[sec][mod]->SetYTitle("Mbo");
284  for(Int_t bx = 0; bx < 96; bx ++){
285  for(Int_t by = 0; by < 16; by ++){
286  hmb_vs_tdc[sec][mod]->SetBinContent(bx+1,by+1,-10);
287  }
288  }
289  for(Int_t l = 0; l < 6; l ++){
290  for(Int_t c = 0; c < 220; c ++){
291  Int_t ind = index(sec,mod,l,c);
292  mbo = mb [ind];
293  t = tdc [ind];
294  st = statusmap[ind];
295  hmb_vs_tdc[sec][mod]->SetBinContent(t+1,mbo+1,st);
296  }
297  }
298  hmb_vs_tdc[sec][mod]->SetMinimum(-4);
299  result->cd(mod*6+sec+1);
300  hmb_vs_tdc[sec][mod]->DrawCopy("Colz");
301  }
302  }
303  return result;
304 }
306 {
307  gStyle->SetOptStat(0);
308  Char_t name[400];
309  sprintf(name,"%s","Mb_vs_Tdc");
310  TCanvas* result = new TCanvas(name,name,1000,800);
311  result->Divide(6,4);
312 
313  TH2F* hmb_vs_tdc[6][4];
314  Int_t mbo,t;
315  Float_t eff;
316  for(Int_t sec = 0; sec < 6; sec ++){
317  for(Int_t mod = 0; mod < 4; mod ++){
318  sprintf(name,"%s%i%s%i","hEfficiencyMb_vs_Tdc_sec",sec,"_mod",mod);
319  hmb_vs_tdc[sec][mod] = new TH2F(name,name,96,0,96,16,0,16);
320  hmb_vs_tdc[sec][mod]->SetXTitle("tdc channel");
321  hmb_vs_tdc[sec][mod]->SetYTitle("Mbo");
322 
323  for(Int_t bx = 0; bx < 96; bx ++){
324  for(Int_t by = 0; by < 16; by ++){
325  hmb_vs_tdc[sec][mod]->SetBinContent(bx+1,by+1,-10);
326  }
327  }
328 
329  for(Int_t l = 0; l < 6; l ++){
330  for(Int_t c = 0; c < 220; c ++){
331  Int_t ind = index(sec,mod,l,c);
332  mbo = mb [ind];
333  t = tdc [ind];
334  eff = efficiency[ind];
335  hmb_vs_tdc[sec][mod]->SetBinContent(t+1,mbo+1,eff);
336  }
337  }
338  result->cd(mod*6+sec+1);
339  hmb_vs_tdc[sec][mod]->DrawCopy("Colz");
340  }
341  }
342  return result;
343 }
344 
346 {
347  gStyle->SetOptStat(0);
348  Char_t name[400];
349  sprintf(name,"%s","Mb_vs_Tdc");
350  TCanvas* result = new TCanvas(name,name,1000,800);
351  result->Divide(6,4);
352 
353  TH2F* hmb_vs_tdc[6][4];
354  Int_t mbo,t;
355  Float_t off;
356  for(Int_t sec = 0; sec < 6; sec ++){
357  for(Int_t mod = 0; mod < 4; mod ++){
358  sprintf(name,"%s%i%s%i","hOffsetMb_vs_Tdc_sec",sec,"_mod",mod);
359  hmb_vs_tdc[sec][mod] = new TH2F(name,name,96,0,96,16,0,16);
360  hmb_vs_tdc[sec][mod]->SetXTitle("tdc channel");
361  hmb_vs_tdc[sec][mod]->SetYTitle("Mbo");
362 
363  for(Int_t bx = 0; bx < 96; bx ++){
364  for(Int_t by = 0; by < 16; by ++){
365  hmb_vs_tdc[sec][mod]->SetBinContent(bx+1,by+1,-10);
366  }
367  }
368 
369  for(Int_t l = 0; l < 6; l ++){
370  for(Int_t c = 0; c < 220; c ++){
371  Int_t ind = index(sec,mod,l,c);
372  mbo = mb [ind];
373  t = tdc [ind];
374  off = offset[ind];
375  hmb_vs_tdc[sec][mod]->SetBinContent(t+1,mbo+1,off);
376  }
377  }
378  result->cd(mod*6+sec+1);
379  hmb_vs_tdc[sec][mod]->DrawCopy("Colz");
380  }
381  }
382  return result;
383 }
384 TCanvas* HMdcWireStat::plotStatus(Int_t sec,Int_t mod)
385 {
386  gStyle->SetOptStat(0);
387  Char_t name[400];
388  sprintf(name,"status_s%i_m%i",sec,mod);
389  TCanvas* result = new TCanvas(name,name,1000,800);
390  result->Divide(1,6);
391 
392  TH1F* hmdcstatus[6];
393  Int_t st;
394  for(Int_t l = 0; l < 6; l ++){
395  sprintf(name,"%s%i%s%i%s%i","hmdcstatus_sec",sec,"_mod",mod,"_layer",l);
396  hmdcstatus[l] = new TH1F(name,name,220,0,220);
397  hmdcstatus[l]->SetXTitle("wire number");
398  hmdcstatus[l]->SetYTitle("status");
399  hmdcstatus[l]->SetFillColor(8);
400  for(Int_t c = 0; c < 220; c ++){
401  Int_t ind = index(sec,mod,l,c);
402  st = statusmap[ind];
403  hmdcstatus[l]->SetBinContent(c+1,st);
404  }
405  result->cd(l+1);
406  hmdcstatus[l]->DrawCopy();
407  }
408  return result;
409 }
410 TCanvas* HMdcWireStat::plotEfficiency(Int_t sec,Int_t mod)
411 {
412  gStyle->SetOptStat(0);
413  Char_t name[400];
414  sprintf(name,"efficiency_s%i_m%i",sec,mod);
415  TCanvas* result = new TCanvas(name,name,1000,800);
416  result->Divide(1,6);
417 
418  TH1F* hmdcefficiency[6];
419  Float_t eff;
420  for(Int_t l = 0; l < 6; l ++){
421  sprintf(name,"%s%i%s%i%s%i","hmdcefficiency_sec",sec,"_mod",mod,"_layer",l);
422  hmdcefficiency[l] = new TH1F(name,name,220,0,220);
423  hmdcefficiency[l]->SetXTitle("wire number");
424  hmdcefficiency[l]->SetYTitle("efficiency");
425  for(Int_t c = 0; c < 220; c ++){
426  Int_t ind = index(sec,mod,l,c);
427  eff = efficiency[ind];
428  hmdcefficiency[l]->SetBinContent(c+1,eff);
429  }
430  result->cd(l+1);
431  hmdcefficiency[l]->DrawCopy();
432  }
433  return result;
434 }
435 TCanvas* HMdcWireStat::plotOffset(Int_t sec,Int_t mod)
436 {
437  gStyle->SetOptStat(0);
438  Char_t name[400];
439  sprintf(name,"offset_s%i_m%i",sec,mod);
440  TCanvas* result = new TCanvas(name,name,1000,800);
441  result->Divide(1,6);
442 
443  TH1F* hmdcoffset[6];
444  Float_t off;
445  for(Int_t l = 0; l < 6; l ++){
446  sprintf(name,"%s%i%s%i%s%i","hmdcoffset_sec",sec,"_mod",mod,"_layer",l);
447  hmdcoffset[l] = new TH1F(name,name,220,0,220);
448  hmdcoffset[l]->SetXTitle("wire number");
449  hmdcoffset[l]->SetYTitle("offset [ns]");
450  for(Int_t c = 0; c < 220; c ++){
451  Int_t ind = index(sec,mod,l,c);
452  off = offset[ind];
453  hmdcoffset[l]->SetBinContent(c+1,off);
454  }
455  result->cd(l+1);
456  hmdcoffset[l]->DrawCopy();
457  }
458  return result;
459 }
460 
TCanvas * plotEfficiency(Int_t, Int_t)
TArrayF offset
Definition: hmdcwirestat.h:18
void putParams(HParamList *)
TArrayI mb
Definition: hmdcwirestat.h:14
TCanvas * plotEfficiencyMbVsTdc()
TArrayI statusmap
Definition: hmdcwirestat.h:16
Int_t index(Int_t s, Int_t m, Int_t l, Int_t c)
Definition: hmdcwirestat.h:21
void info(Char_t level, Int_t det, const Char_t *className, const Char_t *text)
Definition: hmessagemgr.cc:473
void resetInputVersions()
Definition: hparset.cc:144
void add(HParamObj &)
Definition: hparamlist.cc:415
TCanvas * plotOffsetMbVsTdc()
void printStats()
Definition: hmdcwirestat.cc:64
Bool_t getParams(HParamList *)
Bool_t changed
static flag
Definition: hparset.h:14
Hades * gHades
Definition: hades.cc:1213
TArrayI tdc
Definition: hmdcwirestat.h:15
#define INFO_msg(level, det, text)
Definition: hmessagemgr.h:54
Bool_t status
versions of container in the 2 possible inputs
Definition: hparset.h:13
TCanvas * plotStatus(Int_t, Int_t)
void printStatsSum()
TArrayF efficiency
Definition: hmdcwirestat.h:17
ClassImp(HMdcWireStat) HMdcWireStat
Definition: hmdcwirestat.cc:33
#define SEPERATOR_msg(sep, num)
Definition: hmessagemgr.h:63
Bool_t fill(const Text_t *, Text_t *, const Int_t)
Definition: hparamlist.cc:561
TCanvas * plotOffset(Int_t, Int_t)
TCanvas * plotStatusMbVsTdc()
Int_t getDeadWires()
void printParam(void)
HMessageMgr * getMsg(void)
Definition: hades.h:113