StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BEMCPlotsPresenter.cxx
1 #include "BEMCPlotsPresenter.h"
2 #include <iostream>
3 using namespace std;
4 #include <TH1F.h>
5 #include <TH2F.h>
6 #include <TCanvas.h>
7 #include <TLine.h>
8 #include <TArrow.h>
9 #include <TLatex.h>
10 #include <TString.h>
11 #include <TBox.h>
12 #include <TEnv.h>
13 #include <TObjArray.h>
14 
15 #include <StMessMgr.h>
16 #include <GenericFile.h>
17 
18 #include <StEmcUtil/database/StEmcDecoder.h>
19 
20 #include "BEMCPlotsNames.h"
21 #include "StRoot/StEmcPool/StBEMCPlots/BemcTwMask.h"
22 
23 #define min(A, B) (((A) < (B)) ? (A) : (B))
24 #define max(A, B) (((A) > (B)) ? (A) : (B))
25 
26 TObjArray *BEMCPlotsCleanUp = new TObjArray();
27 StEmcDecoder *BEMCDecoderPresenter = 0;
28 Bool_t useDecoderForBoundaries = false; // Use StEmcDecoder for showing ranges (the tower map bug fix mixes softIds between crates)
29 
30 //-------------------------------------------------------------------
31 TH1 *GetHisto(FileType &fd, const char *name) {
32  TH1 *hist = 0;
33  hist = fd.file() ? (TH1 *)fd.Get(name, 0) : 0;
34  if (hist) {
35  hist->SetDirectory(0);
36  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(hist);
37  }
38  return hist;
39 }
40 
41 #define FIND_HISTO(TYPE, NAME, FILE, TITLE) \
42 TYPE *NAME = (TYPE*)GetHisto((FILE), (TITLE)); \
43 if (!NAME) { \
44  LOG_ERROR << "Histogram " << #NAME << " not found: " << (TITLE) << endm; \
45 }
46 
47 //-------------------------------------------------------------------
48 void BEMCPlotsPresenter::displayStatus(FileType file, TPad *pad, int mDebug) {
49  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
50 
51  if (!pad) return;
52  pad->Clear();
53  pad->cd(0);
54 
55  FIND_HISTO(TH2F, Hist_TDC_status, file, Hist_TDC_statusName);
56  FIND_HISTO(TH2F, Hist_SMD_status, file, Hist_SMD_statusName);
57  FIND_HISTO(TH2F, Hist_PSD_status, file, Hist_PSD_statusName);
58  FIND_HISTO(TH1F, Hist_BTOW_Corruption, file, Hist_BTOW_CorruptionName);
59 
60  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
61  c->Draw();
62  c->cd(0);
63  c->Divide(2, 2, 0.001, 0.001);
64 
65  c->cd(1);
66  if (Hist_TDC_status) {
67  Hist_TDC_status->Draw("H COLZ");
68  }
69  c->cd(2);
70  if (Hist_SMD_status) {
71  Hist_SMD_status->Draw("H COLZ");
72  }
73  c->cd(3);
74  if (Hist_PSD_status) {
75  Hist_PSD_status->Draw("H COLZ");
76  }
77  c->cd(4);
78  if (Hist_BTOW_Corruption) {
79  Hist_BTOW_Corruption->Draw("H COLZ");
80  }
81 
82  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
83 }
84 
85 //-------------------------------------------------------------------
86 void BEMCPlotsPresenter::displayTowers(FileType file, TPad *pad, int mDebug) {
87  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
88 
89  if (!pad) return;
90  pad->Clear();
91  pad->cd(0);
92 
93  FIND_HISTO(TH2F, Hist_btow_spectra_1, file, Hist_btow_spectra_1Name);
94  FIND_HISTO(TH2F, Hist_btow_spectra_2, file, Hist_btow_spectra_2Name);
95  FIND_HISTO(TH2F, Hist_btow_spectra_3, file, Hist_btow_spectra_3Name);
96 
97  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
98  c->Draw();
99  c->cd(0);
100  c->Divide(1, 3, 0.001, 0.001);
101 
102  c->cd(1);
103  if (Hist_btow_spectra_1) {
104  Hist_btow_spectra_1->Draw("H COLZ");
105  }
106  c->cd(2);
107  if (Hist_btow_spectra_2) {
108  Hist_btow_spectra_2->Draw("H COLZ");
109  }
110  c->cd(3);
111  if (Hist_btow_spectra_3) {
112  Hist_btow_spectra_3->Draw("H COLZ");
113  }
114 
115  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
116 }
117 
118 //-------------------------------------------------------------------
119 void BEMCPlotsPresenter::displaySMDPSD(FileType file, TPad *pad, int mDebug) {
120  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
121 
122  if (!pad) return;
123  pad->Clear();
124  pad->cd(0);
125 
126  FIND_HISTO(TH1F, Hist_smd_spectra, file, Hist_smd_spectraName);
127  FIND_HISTO(TH1F, Hist_smd_spectraNonZS, file, Hist_smd_spectraNonZSName);
128  FIND_HISTO(TH2F, Hist_smd_capacitor, file, Hist_smd_capacitorName);
129  FIND_HISTO(TH2F, Hist_smd_sum, file, Hist_smd_sumName);
130  FIND_HISTO(TH1F, Hist_psd_spectra, file, Hist_psd_spectraName);
131  FIND_HISTO(TH1F, Hist_psd_spectraNonZS, file, Hist_psd_spectraNonZSName);
132  FIND_HISTO(TH2F, Hist_psd_capacitor, file, Hist_psd_capacitorName);
133  FIND_HISTO(TH2F, Hist_psd_sum, file, Hist_psd_sumName);
134 
135  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
136  c->Draw();
137  c->cd(0);
138  c->Divide(2, 3, 0.001, 0.001);
139 
140  c->cd(1);
141  if (Hist_smd_spectra) {
142  Hist_smd_spectra->Draw("H COLZ");
143  }
144  if (Hist_smd_spectraNonZS) {
145  Hist_smd_spectraNonZS->SetLineColor(kRed);
146  Hist_smd_spectraNonZS->Draw("SAME H COLZ");
147  }
148  c->cd(2);
149  if (Hist_psd_spectra) {
150  Hist_psd_spectra->Draw("H COLZ");
151  }
152  if (Hist_psd_spectraNonZS) {
153  Hist_psd_spectraNonZS->SetLineColor(kRed);
154  Hist_psd_spectraNonZS->Draw("SAME H COLZ");
155  }
156  c->cd(3);
157  if (Hist_smd_capacitor) {
158  Hist_smd_capacitor->Draw("H COLZ");
159  }
160  c->cd(4);
161  if (Hist_psd_capacitor) {
162  Hist_psd_capacitor->Draw("H COLZ");
163  }
164  c->cd(5);
165  if (Hist_smd_sum) {
166  Hist_smd_sum->Draw("H COLZ");
167  }
168  c->cd(6);
169  if (Hist_psd_sum) {
170  Hist_psd_sum->Draw("H COLZ");
171  }
172 
173  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
174 }
175 
176 //-------------------------------------------------------------------
177 void BEMCPlotsPresenter::displayTrigger(FileType file, TPad *pad, int mDebug) {
178  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
179 
180  if (!pad) return;
181  pad->Clear();
182  pad->cd(0);
183 
184  FIND_HISTO(TH2F, Hist_HTMAX_spectra, file, Hist_HTMAX_spectraName);
185  FIND_HISTO(TH2F, Hist_PAMAX_spectra, file, Hist_PAMAX_spectraName);
186  FIND_HISTO(TH1F, Hist_HTMAX_dist, file, Hist_HTMAX_distName);
187  FIND_HISTO(TH1F, Hist_PAMAX_dist, file, Hist_PAMAX_distName);
188 
189  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
190  c->Draw();
191  c->cd(0);
192  c->Divide(2, 2, 0.001, 0.001);
193 
194  c->cd(1);
195  if (Hist_HTMAX_spectra) {
196  Hist_HTMAX_spectra->Draw("H COLZ");
197  }
198  c->cd(2);
199  if (Hist_PAMAX_spectra) {
200  Hist_PAMAX_spectra->Draw("H COLZ");
201  }
202  c->cd(3);
203  if (Hist_HTMAX_dist) {
204  Hist_HTMAX_dist->Draw("H COLZ");
205  }
206  c->cd(4);
207  if (Hist_PAMAX_dist) {
208  Hist_PAMAX_dist->Draw("H COLZ");
209  }
210 
211  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
212 }
213 
214 //-------------------------------------------------------------------
215 void BEMCPlotsPresenter::displayJet(FileType file, TPad *pad, int mDebug) {
216  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
217 
218  if (!pad) return;
219  pad->Clear();
220  pad->cd(0);
221 
222  FIND_HISTO(TH2F, Hist_JET_ped, file, Hist_JET_pedName);
223  FIND_HISTO(TH2F, Hist_JET_spectra, file, Hist_JET_spectraName);
224  FIND_HISTO(TH2F, Hist_JETMAX_spectra, file, Hist_JETMAX_spectraName);
225  FIND_HISTO(TH1F, Hist_JETMAX_dist, file, Hist_JETMAX_distName);
226 
227  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
228  c->Draw();
229  c->cd(0);
230  c->Divide(2, 2, 0.001, 0.001);
231 
232  c->cd(1);
233  if (Hist_JET_ped) {
234  Hist_JET_ped->Draw("H COLZ");
235  }
236  c->cd(2);
237  if (Hist_JET_spectra) {
238  Hist_JET_spectra->Draw("H COLZ");
239  }
240  c->cd(3);
241  if (Hist_JETMAX_spectra) {
242  Hist_JETMAX_spectra->Draw("H COLZ");
243  }
244  c->cd(4);
245  if (Hist_JETMAX_dist) {
246  Hist_JETMAX_dist->Draw("H COLZ");
247  }
248 
249  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
250 }
251 
252 //-------------------------------------------------------------------
253 void BEMCPlotsPresenter::displayRawAdc(FileType file, TPad *pad, bool psd, bool zoom, BemcTwMask *twMask, Int_t mDebug) {
254  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
255 
256  FIND_HISTO(TH2F, HistRawAdc1, file, psd ? HistRawAdcPsd1Name : (zoom ? HistRawAdc1NameZoom : HistRawAdc1Name));
257  FIND_HISTO(TH2F, HistRawAdc2, file, psd ? HistRawAdcPsd2Name : (zoom ? HistRawAdc2NameZoom : HistRawAdc2Name));
258  FIND_HISTO(TH2F, HistRawAdc3, file, psd ? HistRawAdcPsd3Name : (zoom ? HistRawAdc3NameZoom : HistRawAdc3Name));
259  FIND_HISTO(TH2F, HistRawAdc4, file, psd ? HistRawAdcPsd4Name : (zoom ? HistRawAdc4NameZoom : HistRawAdc4Name));
260 
261  if (!pad) return;
262  pad->Clear();
263  pad->cd(0);
264 
265  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
266  c->Draw();
267  c->cd(0);
268  c->Divide(1, 4, 0.001, 0.001);
269 
270  // 12-19 are the grey shades dark-light
271  Int_t linesColor = 16;
272  Int_t crateMinSoftId[] = {4661, 2421, 2581, 2741, 2901, 3061, 3221, 3381, 3541, 3701, 3861, 4021, 4181, 4341, 4501, 2181, 2021, 1861, 1701, 1541, 1381, 1221, 1061, 901, 741, 581, 421, 261, 101, 1};
273  Int_t crateMaxSoftId[] = {4800, 2580, 2740, 2900, 3060, 3220, 3380, 3540, 3700, 3860, 4020, 4180, 4340, 4500, 4660, 2340, 2180, 2020, 1860, 1700, 1540, 1380, 1220, 1060, 900, 740, 580, 420, 260, 100};
274  Int_t pmtbxMinSoftId[] = {2261, 2181, 2101, 2021, 1941, 1861, 1781, 1701, 1621, 1541, 1461, 1381, 1301, 1221, 1141, 1061, 981, 901, 821, 741, 661, 581, 501, 421, 341, 261, 181, 101, 21, 2341/*and from 1*/,
275  4661, 4741, 2421, 2501, 2581, 2661, 2741, 2821, 2901, 2981, 3061, 3141, 3221, 3301, 3381, 3461, 3541, 3621, 3701, 3781, 3861, 3941, 4021, 4101, 4181, 4261, 4341, 4421, 4501, 4581
276  /*and from 2401*/
277  };
278  Int_t pmtbxMaxSoftId[] = {2340, 2260, 2180, 2100, 2020, 1940, 1860, 1780, 1700, 1620, 1540, 1460, 1380, 1300, 1220, 1140, 1060, 980, 900, 820, 740, 660, 580, 500, 420, 340, 260, 180, 100, 2400/*to 20*/,
279  4740, 4800, 2500, 2580, 2660, 2740, 2820, 2900, 2980, 3060, 3140, 3220, 3300, 3380, 3460, 3540, 3620, 3700, 3780, 3860, 3940, 4020, 4100, 4180, 4260, 4340, 4420, 4500, 4580, 4660
280  /*to 2420*/
281  };
282  if (useDecoderForBoundaries && BEMCDecoderPresenter) {
283  for (Int_t crate = 0;crate < 30;crate++) {
284  crateMinSoftId[crate] = 4800;
285  crateMaxSoftId[crate] = 1;
286  }
287  for (Int_t crate = 0;crate < 30;crate++) {
288  if (BEMCDecoderPresenter) {
289  for (Int_t crateSeq = 0;crateSeq < 160;crateSeq++) {
290  Int_t softId;
291  if (BEMCDecoderPresenter->GetTowerIdFromCrate(crate + 1, crateSeq, softId)) {
292  if (softId < crateMinSoftId[crate]) crateMinSoftId[crate] = softId;
293  if (softId > crateMaxSoftId[crate]) crateMaxSoftId[crate] = softId;
294  }
295  }
296  }
297  }
298  //for (Int_t crate = 0;crate < 30;crate++) cout << "Crate " << (crate+1) << ": SoftId " << crateMinSoftId[crate] << " - " << crateMaxSoftId[crate] << endl;
299  // no PMT boxes numeration scheme in decoder
300  }
301 
302  Int_t *boxMinSoftId = psd ? pmtbxMinSoftId : crateMinSoftId;
303  Int_t *boxMaxSoftId = psd ? pmtbxMaxSoftId : crateMaxSoftId;
304  const Char_t *boxLabelFormat = psd ? "%i" : "0x%.2X";
305  Int_t numBoxes = psd ? (sizeof(pmtbxMinSoftId)/sizeof(pmtbxMinSoftId[0])) : (sizeof(crateMinSoftId)/sizeof(crateMinSoftId[0]));
306 
307  c->cd(1);
308  if (HistRawAdc1) {
309  HistRawAdc1->SetStats(0);
310  HistRawAdc1->Draw("COLZ");
311  if (twMask) {
312  TGraph &g1 = twMask->crG[0];
313  if (g1.GetN() > 0) {
314  g1.Draw("L");
315  //g1.SetLineWidth(1);
316  g1.SetLineColor(2);
317  }
318  /*TLine *testline1=new TLine(0,0,0,10000);
319  if (testline1) {
320  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(testline1);
321  testline1->SetLineColor(1);
322  testline1->SetLineWidth(2);
323  testline1->Draw();
324  }*/
325  }
326  for (Int_t crate = 0;crate < numBoxes;crate++) {
327  if (!((boxMaxSoftId[crate] < HistRawAdc1->GetXaxis()->GetBinLowEdge(1))
328  || (boxMinSoftId[crate] > HistRawAdc1->GetXaxis()->GetBinUpEdge(HistRawAdc1->GetXaxis()->GetNbins())))
329  ) {
330  Float_t left = max(boxMinSoftId[crate], HistRawAdc1->GetXaxis()->GetBinCenter(1)) - 0.5;
331  Float_t right = 0.5 + min(boxMaxSoftId[crate], HistRawAdc1->GetXaxis()->GetBinCenter(HistRawAdc1->GetXaxis()->GetNbins()));
332  TLine *lCrates = new TLine(left, HistRawAdc1->GetYaxis()->GetBinLowEdge(1), left, HistRawAdc1->GetYaxis()->GetBinUpEdge(HistRawAdc1->GetYaxis()->GetNbins()));
333  if (lCrates) {
334  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrates);
335  lCrates->SetLineColor(linesColor);
336  lCrates->SetLineWidth(1);
337  lCrates->Draw();
338  }
339  TLine *rCrates = new TLine(right, HistRawAdc1->GetYaxis()->GetBinLowEdge(1), right, HistRawAdc1->GetYaxis()->GetBinUpEdge(HistRawAdc1->GetYaxis()->GetNbins()));
340  if (rCrates) {
341  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(rCrates);
342  rCrates->SetLineColor(linesColor);
343  rCrates->SetLineWidth(1);
344  rCrates->Draw();
345  }
346  TString crateLabel;
347  crateLabel = Form(boxLabelFormat, crate + 1);
348  TLatex *textCrate = new TLatex(left + 10, HistRawAdc1->GetYaxis()->GetBinUpEdge(HistRawAdc1->GetYaxis()->GetNbins()) * 0.8, crateLabel.Data());
349  if (textCrate) {
350  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
351  textCrate->SetTextColor(linesColor);
352  textCrate->SetTextSize(0.14);
353  textCrate->Draw();
354  }
355  }
356  }
357  }
358  c->cd(2);
359  if (HistRawAdc2) {
360  HistRawAdc2->SetStats(0);
361  HistRawAdc2->Draw("COLZ");
362  if (twMask) {
363  TGraph &g2 = twMask->crG[1];
364  if (g2.GetN() > 0) {
365  g2.Draw("L");
366  g2.SetLineColor(2);
367  }
368  }
369  for (Int_t crate = 0;crate < numBoxes;crate++) {
370  if (!((boxMaxSoftId[crate] < HistRawAdc2->GetXaxis()->GetBinLowEdge(1))
371  || (boxMinSoftId[crate] > HistRawAdc2->GetXaxis()->GetBinUpEdge(HistRawAdc2->GetXaxis()->GetNbins())))
372  ) {
373  Float_t left = max(boxMinSoftId[crate], HistRawAdc2->GetXaxis()->GetBinCenter(1)) - 0.5;
374  Float_t right = 0.5 + min(boxMaxSoftId[crate], HistRawAdc2->GetXaxis()->GetBinCenter(HistRawAdc2->GetXaxis()->GetNbins()));
375  TLine *lCrates = new TLine(left, HistRawAdc2->GetYaxis()->GetBinLowEdge(1), left, HistRawAdc2->GetYaxis()->GetBinUpEdge(HistRawAdc2->GetYaxis()->GetNbins()));
376  if (lCrates) {
377  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrates);
378  lCrates->SetLineColor(linesColor);
379  lCrates->SetLineWidth(1);
380  lCrates->Draw();
381  }
382  TLine *rCrates = new TLine(right, HistRawAdc2->GetYaxis()->GetBinLowEdge(1), right, HistRawAdc2->GetYaxis()->GetBinUpEdge(HistRawAdc2->GetYaxis()->GetNbins()));
383  if (rCrates) {
384  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(rCrates);
385  rCrates->SetLineColor(linesColor);
386  rCrates->SetLineWidth(1);
387  rCrates->Draw();
388  }
389  TString crateLabel;
390  crateLabel = Form(boxLabelFormat, crate + 1);
391  TLatex *textCrate = new TLatex(left + 10, HistRawAdc2->GetYaxis()->GetBinUpEdge(HistRawAdc2->GetYaxis()->GetNbins()) * 0.8, crateLabel.Data());
392  if (textCrate) {
393  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
394  textCrate->SetTextColor(linesColor);
395  textCrate->SetTextSize(0.14);
396  textCrate->Draw();
397  }
398  }
399  }
400  }
401 
402  c->cd(3);
403  if (HistRawAdc3) {
404  HistRawAdc3->SetStats(0);
405  HistRawAdc3->Draw("COLZ");
406  if (twMask) {
407  TGraph &g3 = twMask->crG[2];
408  if (g3.GetN() > 0) {
409  g3.Draw("L");
410  g3.SetLineColor(2);
411  }
412  }
413  for (Int_t crate = 0;crate < numBoxes;crate++) {
414  if (!((boxMaxSoftId[crate] < HistRawAdc3->GetXaxis()->GetBinLowEdge(1))
415  || (boxMinSoftId[crate] > HistRawAdc3->GetXaxis()->GetBinUpEdge(HistRawAdc3->GetXaxis()->GetNbins())))
416  ) {
417  Float_t left = max(boxMinSoftId[crate], HistRawAdc3->GetXaxis()->GetBinCenter(1)) - 0.5;
418  Float_t right = 0.5 + min(boxMaxSoftId[crate], HistRawAdc3->GetXaxis()->GetBinCenter(HistRawAdc3->GetXaxis()->GetNbins()));
419  TLine *lCrates = new TLine(left, HistRawAdc3->GetYaxis()->GetBinLowEdge(1), left, HistRawAdc3->GetYaxis()->GetBinUpEdge(HistRawAdc3->GetYaxis()->GetNbins()));
420  if (lCrates) {
421  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrates);
422  lCrates->SetLineColor(linesColor);
423  lCrates->SetLineWidth(1);
424  lCrates->Draw();
425  }
426  TLine *rCrates = new TLine(right, HistRawAdc3->GetYaxis()->GetBinLowEdge(1), right, HistRawAdc3->GetYaxis()->GetBinUpEdge(HistRawAdc3->GetYaxis()->GetNbins()));
427  if (rCrates) {
428  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(rCrates);
429  rCrates->SetLineColor(linesColor);
430  rCrates->SetLineWidth(1);
431  rCrates->Draw();
432  }
433  TString crateLabel;
434  crateLabel = Form(boxLabelFormat, crate + 1);
435  TLatex *textCrate = new TLatex(left + 10, HistRawAdc3->GetYaxis()->GetBinUpEdge(HistRawAdc3->GetYaxis()->GetNbins()) * 0.8, crateLabel.Data());
436  if (textCrate) {
437  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
438  textCrate->SetTextColor(linesColor);
439  textCrate->SetTextSize(0.14);
440  textCrate->Draw();
441  }
442  }
443  }
444  }
445 
446  c->cd(4);
447  if (HistRawAdc4) {
448  HistRawAdc4->SetStats(0);
449  HistRawAdc4->Draw("COLZ");
450  if (twMask) {
451  TGraph &g4 = twMask->crG[3];
452  if (g4.GetN() > 0) {
453  g4.Draw("L");
454  //g4.SetLineWidth(2);
455  g4.SetLineColor(2);
456  }
457  }
458  for (Int_t crate = 0;crate < numBoxes;crate++) {
459  if (!((boxMaxSoftId[crate] < HistRawAdc4->GetXaxis()->GetBinLowEdge(1))
460  || (boxMinSoftId[crate] > HistRawAdc4->GetXaxis()->GetBinUpEdge(HistRawAdc4->GetXaxis()->GetNbins())))
461  ) {
462  Float_t left = max(boxMinSoftId[crate], HistRawAdc4->GetXaxis()->GetBinCenter(1)) - 0.5;
463  Float_t right = 0.5 + min(boxMaxSoftId[crate], HistRawAdc4->GetXaxis()->GetBinCenter(HistRawAdc4->GetXaxis()->GetNbins()));
464  TLine *lCrates = new TLine(left, HistRawAdc4->GetYaxis()->GetBinLowEdge(1), left, HistRawAdc4->GetYaxis()->GetBinUpEdge(HistRawAdc4->GetYaxis()->GetNbins()));
465  if (lCrates) {
466  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrates);
467  lCrates->SetLineColor(linesColor);
468  lCrates->SetLineWidth(1);
469  lCrates->Draw();
470  }
471  TLine *rCrates = new TLine(right, HistRawAdc4->GetYaxis()->GetBinLowEdge(1), right, HistRawAdc4->GetYaxis()->GetBinUpEdge(HistRawAdc4->GetYaxis()->GetNbins()));
472  if (rCrates) {
473  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(rCrates);
474  rCrates->SetLineColor(linesColor);
475  rCrates->SetLineWidth(1);
476  rCrates->Draw();
477  }
478  TString crateLabel;
479  crateLabel = Form(boxLabelFormat, crate + 1);
480  TLatex *textCrate = new TLatex(left + 10, HistRawAdc4->GetYaxis()->GetBinUpEdge(HistRawAdc4->GetYaxis()->GetNbins()) * 0.8, crateLabel.Data());
481  if (textCrate) {
482  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
483  textCrate->SetTextColor(linesColor);
484  textCrate->SetTextSize(0.14);
485  textCrate->Draw();
486  }
487  }
488  }
489  }
490 }
491 
492 //-------------------------------------------------------------------
493 void BEMCPlotsPresenter::displayJetPatchHT(FileType file, TPad *pad, Int_t mDebug) {
494  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
495 
496  if (!pad) return;
497  pad->Clear();
498  pad->cd(0);
499 
500  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
501  c->Draw();
502  c->cd(0);
503  c->Divide(3, 4, 0.001, 0.001);
504 
505  for (Int_t jetPatch = 0;jetPatch < 12;jetPatch++) {
506  c->cd(jetPatch+1);
507  FIND_HISTO(TH1F, HistHighTowerSpectrum, file, Form(HistHighTowerSpectrumName "_%u", jetPatch));
508  if (HistHighTowerSpectrum) {
509  HistHighTowerSpectrum->SetStats(0);
510  HistHighTowerSpectrum->Draw();
511  if (HistHighTowerSpectrum->GetEntries()) gPad->SetLogy();
512  }
513  }
514 }
515 //-------------------------------------------------------------------
516 void BEMCPlotsPresenter::displayJetPatchSum(FileType file, TPad *pad, Int_t mDebug) {
517  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
518 
519  if (!pad) return;
520  pad->Clear();
521  pad->cd(0);
522 
523  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
524  c->Draw();
525  c->cd(0);
526  c->Divide(3, 4, 0.001, 0.001);
527 
528  for (Int_t jetPatch = 0;jetPatch < 12;jetPatch++) {
529  c->cd(jetPatch+1);
530  FIND_HISTO(TH1F, HistPatchSumSpectrum, file, Form(HistPatchSumSpectrumName "_%u", jetPatch));
531  if (HistPatchSumSpectrum) {
532  HistPatchSumSpectrum->SetStats(0);
533  HistPatchSumSpectrum->Draw();
534  if (HistPatchSumSpectrum->GetEntries()) gPad->SetLogy();
535  }
536  }
537 }
538 //-------------------------------------------------------------------
539 void BEMCPlotsPresenter::displayL0Input(FileType file, TPad *pad, Int_t mDebug) {
540  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
541 
542  FIND_HISTO(TH2F, HistDsmL0InputHighTower, file, HistDsmL0InputHighTowerName);
543  FIND_HISTO(TH2F, HistDsmL0InputPatchSum, file, HistDsmL0InputPatchSumName);
544 
545  if (!pad) return;
546  pad->Clear();
547  pad->cd(0);
548 
549  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
550  c->Draw();
551  c->cd(0);
552  c->Divide(1, 2, 0.001, 0.001);
553 
554  // 12-19 are the grey shades dark-light
555  Int_t linesColor = 16;
556  c->cd(1);
557  if (HistDsmL0InputHighTower && BEMCDecoderPresenter) {
558  HistDsmL0InputHighTower->SetStats(0);
559  HistDsmL0InputHighTower->Draw("COLZ");
560  TLine *lCrates = new TLine(0, 50, 300, 50);
561  if (lCrates) {
562  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrates);
563  lCrates->SetLineColor(linesColor);
564  lCrates->SetLineWidth(1);
565  lCrates->Draw();
566  }
567  TLatex *textCrates = new TLatex(1, 50, "BTOW Crates:");
568  if (textCrates) {
569  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrates);
570  textCrates->SetTextColor(linesColor);
571  textCrates->SetTextSize(0.0333);
572  textCrates->Draw();
573  }
574  for (Int_t icrate = 1;icrate <= 30;icrate++) {
575  Int_t triggerPatchBegin, triggerPatchEnd;
576  if (BEMCDecoderPresenter->GetTriggerPatchFromCrate(icrate, 0, triggerPatchBegin) && BEMCDecoderPresenter->GetTriggerPatchFromCrate(icrate, 159, triggerPatchEnd)) {
577  TLine *lCrateBegin = new TLine(triggerPatchBegin-0.5, 0, triggerPatchBegin-0.5, 50);
578  if (lCrateBegin) {
579  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrateBegin);
580  lCrateBegin->SetLineColor(linesColor);
581  lCrateBegin->SetLineWidth(1);
582  lCrateBegin->Draw();
583  }
584  TString crateLabel;
585  crateLabel = Form("%.2X", icrate);
586  TLatex *textCrate = new TLatex(triggerPatchBegin + 1, 45, crateLabel.Data());
587  if (textCrate) {
588  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
589  textCrate->SetTextColor(linesColor);
590  textCrate->SetTextSize(0.0333);
591  textCrate->Draw();
592  }
593  }
594  }
595  for (Int_t ijp = 0;ijp < 12;ijp++) {
596  Int_t maxTriggerPatch = 0;
597  Int_t minTriggerPatch = 300;
598  for (Int_t j = 0;j < 25;j++) {
599  Int_t triggerPatch;
600  if (BEMCDecoderPresenter->GetTriggerPatchFromJetPatch(ijp, j, triggerPatch)) {
601  if (maxTriggerPatch < triggerPatch) maxTriggerPatch = triggerPatch;
602  if (minTriggerPatch > triggerPatch) minTriggerPatch = triggerPatch;
603  }
604  }
605  maxTriggerPatch++;
606  Int_t height = (ijp%2) ? 55 : 60;
607  TArrow *arrow = new TArrow(minTriggerPatch-0.5, height, maxTriggerPatch-0.5, height, 0.02, "<>");
608  if (arrow) {
609  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(arrow);
610  arrow->SetLineColor(linesColor);
611  arrow->SetFillColor(linesColor);
612  arrow->Draw();
613  }
614  TString jpLabel;
615  jpLabel = Form("JetPatch %u", ijp);
616  TLatex *text = new TLatex(minTriggerPatch + 1, height + 1, jpLabel.Data());
617  if (text) {
618  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
619  text->SetTextColor(linesColor);
620  text->SetTextSize(0.0333);
621  text->Draw();
622  }
623  }
624  }
625  c->cd(2);
626  if (HistDsmL0InputPatchSum) {
627  HistDsmL0InputPatchSum->SetStats(0);
628  HistDsmL0InputPatchSum->Draw("COLZ");
629  for (Int_t icrate = 1;icrate <= 30;icrate++) {
630  Int_t triggerPatchBegin, triggerPatchEnd;
631  if (BEMCDecoderPresenter->GetTriggerPatchFromCrate(icrate, 0, triggerPatchBegin) && BEMCDecoderPresenter->GetTriggerPatchFromCrate(icrate, 159, triggerPatchEnd)) {
632  TLine *lCrateBegin = new TLine(triggerPatchBegin-0.5, 0, triggerPatchBegin-0.5, 64);
633  if (lCrateBegin) {
634  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lCrateBegin);
635  lCrateBegin->SetLineColor(linesColor);
636  lCrateBegin->SetLineWidth(1);
637  lCrateBegin->Draw();
638  }
639  TString crateLabel;
640  crateLabel = Form("%.2X", icrate);
641  TLatex *textCrate = new TLatex(triggerPatchBegin + 1, 60, crateLabel.Data());
642  if (textCrate) {
643  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
644  textCrate->SetTextColor(linesColor);
645  textCrate->SetTextSize(0.0333);
646  textCrate->Draw();
647  }
648  }
649  }
650  }
651  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
652 }
653 //-------------------------------------------------------------------
654 void BEMCPlotsPresenter::displayL1Input(FileType file, TPad *pad, Int_t mDebug) {
655  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
656 
657  FIND_HISTO(TH2F, HistDsmL1InputHighTowerBits, file, HistDsmL1InputHighTowerBitsName);
658  FIND_HISTO(TH2F, HistDsmL1InputPatchSum, file, HistDsmL1InputPatchSumName);
659 
660  if (!pad) return;
661  pad->Clear();
662  pad->cd(0);
663 
664  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
665  c->Draw();
666  c->cd(0);
667  c->Divide(1, 2, 0.001, 0.001);
668 
669  // 12-19 are the grey shades dark-light
670  Int_t linesColor = 16;
671  c->cd(1);
672  if (HistDsmL1InputHighTowerBits) {
673  HistDsmL1InputHighTowerBits->SetStats(0);
674  HistDsmL1InputHighTowerBits->Draw("COLZ");
675  HistDsmL1InputHighTowerBits->GetXaxis()->SetNdivisions(0, false);
676  HistDsmL1InputHighTowerBits->GetYaxis()->SetNdivisions(0, false);
677  TLatex *textHT0 = new TLatex(-3.5, 0.5, "HT < th0");
678  if (textHT0) {
679  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT0);
680  textHT0->SetTextColor(linesColor);
681  textHT0->SetTextSize(0.0333);
682  textHT0->Draw();
683  }
684  TLatex *textHT1 = new TLatex(-3.5, 1.5, "th0 < HT < th1");
685  if (textHT1) {
686  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT1);
687  textHT1->SetTextColor(linesColor);
688  textHT1->SetTextSize(0.0333);
689  textHT1->Draw();
690  }
691  TLatex *textHT2 = new TLatex(-3.5, 2.5, "th1 < HT < th2");
692  if (textHT2) {
693  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT2);
694  textHT2->SetTextColor(linesColor);
695  textHT2->SetTextSize(0.0333);
696  textHT2->Draw();
697  }
698  TLatex *textHT3 = new TLatex(-3.5, 3.5, "th2 < HT");
699  if (textHT3) {
700  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT3);
701  textHT3->SetTextColor(linesColor);
702  textHT3->SetTextSize(0.0333);
703  textHT3->Draw();
704  }
705  TLatex *textDsmsL0 = new TLatex(-3.5, 4.0, "#splitline{#splitline{DSM Level-0}{Boards}}{BTOW Crates}");
706  if (textDsmsL0) {
707  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textDsmsL0);
708  textDsmsL0->SetTextColor(linesColor);
709  textDsmsL0->SetTextSize(0.0333);
710  textDsmsL0->Draw();
711  }
712  /*TLatex *textCrates = new TLatex(-3.5, 4.45, "BTOW Crates");
713  if (textCrates) {
714  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrates);
715  textCrates->SetTextColor(linesColor);
716  textCrates->SetTextSize(0.0333);
717  textCrates->Draw();
718  }*/
719  /*TLine *lDsms = new TLine(0, 4.4, 36, 4.4);
720  if (lDsms) {
721  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lDsms);
722  lDsms->SetLineColor(linesColor);
723  lDsms->SetLineWidth(1);
724  lDsms->Draw();
725  }*/
726  Int_t dsmL0 = 0;
727  Int_t ch = 0;
728  for (Int_t idsmL1 = 0;idsmL1 < 6;idsmL1++) {
729  for (Int_t idsmL1ch = 0;idsmL1ch < 6;idsmL1ch++) {
730  TLine *lDsmL0Begin = new TLine(ch-0.5, 0, ch-0.5, 4.4);
731  if (lDsmL0Begin) {
732  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lDsmL0Begin);
733  lDsmL0Begin->SetLineColor(linesColor);
734  lDsmL0Begin->SetLineWidth(1);
735  lDsmL0Begin->Draw();
736  }
737  TString label;
738  Int_t crate = 0, crateSeq = 0;
739  if (BEMCDecoderPresenter) {
740  Int_t triggerPatch = dsmL0 * 10;
741  BEMCDecoderPresenter->GetCrateAndSequenceFromTriggerPatch(triggerPatch, crate, crateSeq);
742  }
743  if (idsmL1 < 3) {
744  label = Form("#splitline{#splitline{BW}{0%.2u}}{%.2X}", (dsmL0 % 15) + 1, crate);
745  } else {
746  label = Form("#splitline{#splitline{BE}{0%.2u}}{%.2X}", (dsmL0 % 15) + 1, crate);
747  }
748  TLatex *text = new TLatex(ch + 0.1-0.5, 4.0, label.Data());
749  if (text) {
750  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
751  text->SetTextColor(linesColor);
752  text->SetTextSize(0.0333);
753  text->Draw();
754  }
755  /*TString labelCrate;
756  if (BEMCDecoderPresenter) {
757  Int_t triggerPatch = dsmL0 * 10;
758  Int_t crate, crateSeq;
759  if (BEMCDecoderPresenter->GetCrateAndSequenceFromTriggerPatch(triggerPatch, crate, crateSeq)) {
760  labelCrate = Form("%.2X", crate);
761  }
762  }
763  TLatex *textCrate = new TLatex(ch + 0.1, 4.45, labelCrate.Data());
764  if (textCrate) {
765  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textCrate);
766  textCrate->SetTextColor(linesColor);
767  textCrate->SetTextSize(0.0333);
768  textCrate->Draw();
769  }*/
770  ch++;
771  if (idsmL1ch != 2) dsmL0++;
772  }
773  }
774  for (Int_t ijp = 0;ijp < 12;ijp++) {
775  Int_t maxCh = (ijp * 3) + 3;
776  Int_t minCh = (ijp * 3) + 0;
777  Float_t height = (ijp%2) ? 4.7 : 4.7;
778  TArrow *arrow = new TArrow(minCh-0.5, height, maxCh-0.5, height, 0.02, "<>");
779  if (arrow) {
780  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(arrow);
781  arrow->SetLineColor(linesColor);
782  arrow->SetFillColor(linesColor);
783  arrow->Draw();
784  }
785  TString jpLabel;
786  jpLabel = Form("JetPatch %u", ijp);
787  TLatex *text = new TLatex(minCh + 0.1-0.5, height + 0.1, jpLabel.Data());
788  if (text) {
789  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
790  text->SetTextColor(linesColor);
791  text->SetTextSize(0.0333);
792  text->Draw();
793  }
794  }
795  TLatex *textDsmsL1 = new TLatex(-3.5, -0.4, "#splitline{DSM Level-1}{Boards}");
796  if (textDsmsL1) {
797  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textDsmsL1);
798  textDsmsL1->SetTextColor(linesColor);
799  textDsmsL1->SetTextSize(0.0333);
800  textDsmsL1->Draw();
801  }
802  for (Int_t idsmL1 = 0;idsmL1 < 6;idsmL1++) {
803  TArrow *arrow = new TArrow((idsmL1 * 6)-0.5, -0.4, (idsmL1 * 6) + 6-0.5, -0.4, 0.02, "<>");
804  if (arrow) {
805  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(arrow);
806  arrow->SetLineColor(linesColor);
807  arrow->SetFillColor(linesColor);
808  arrow->Draw();
809  }
810  TString label;
811  if (idsmL1 < 3) {
812  label = Form("BW1%.2u", (idsmL1 % 3) + 1);
813  } else {
814  label = Form("BE1%.2u", (idsmL1 % 3) + 1);
815  }
816  TLatex *text = new TLatex((idsmL1 * 6) + 1-0.5, -0.35, label.Data());
817  if (text) {
818  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
819  text->SetTextColor(linesColor);
820  text->SetTextSize(0.0333);
821  text->Draw();
822  }
823  }
824  }
825 
826  c->cd(2);
827  if (HistDsmL1InputPatchSum) {
828  HistDsmL1InputPatchSum->SetStats(0);
829  HistDsmL1InputPatchSum->Draw("COLZ");
830  Int_t dsmL0 = 0;
831  Int_t ch = 0;
832  for (Int_t idsmL1 = 0;idsmL1 < 6;idsmL1++) {
833  for (Int_t idsmL1ch = 0;idsmL1ch < 6;idsmL1ch++) {
834  TLine *lDsmL0Begin = new TLine(ch-0.5, 0, ch-0.5, 1024);
835  if (lDsmL0Begin) {
836  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lDsmL0Begin);
837  lDsmL0Begin->SetLineColor(linesColor);
838  lDsmL0Begin->SetLineWidth(1);
839  lDsmL0Begin->Draw();
840  }
841  Int_t crate = 0, crateSeq = 0;
842  if (BEMCDecoderPresenter) {
843  Int_t triggerPatch = dsmL0 * 10;
844  BEMCDecoderPresenter->GetCrateAndSequenceFromTriggerPatch(triggerPatch, crate, crateSeq);
845  }
846  TString label;
847  label = Form("%.2X", crate);
848  TLatex *text = new TLatex(ch + 0.1-0.5, 900, label.Data());
849  if (text) {
850  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
851  text->SetTextColor(linesColor);
852  text->SetTextSize(0.0333);
853  text->Draw();
854  }
855  ch++;
856  if (idsmL1ch != 2) dsmL0++;
857  }
858  }
859  }
860  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
861 }
862 //-------------------------------------------------------------------
863 void BEMCPlotsPresenter::displayL2Input(FileType file, TPad *pad, Int_t mDebug) {
864  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
865 
866  FIND_HISTO(TH2F, HistDsmL2InputHighTowerBits, file, HistDsmL2InputHighTowerBitsName);
867  FIND_HISTO(TH2F, HistDsmL2InputPatchSumBits, file, HistDsmL2InputPatchSumBitsName);
868  FIND_HISTO(TH2F, HistDsmL2InputPatchSum, file, HistDsmL2InputPatchSumName);
869 
870  if (!pad) return;
871  pad->Clear();
872  pad->cd(0);
873 
874  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
875  c->Draw();
876  c->cd(0);
877  c->Divide(1, 3, 0.001, 0.001);
878 
879  // 12-19 are the grey shades dark-light
880  Int_t linesColor = 16;
881  c->cd(1);
882 
883  if (HistDsmL2InputHighTowerBits) {
884  HistDsmL2InputHighTowerBits->SetStats(0);
885  HistDsmL2InputHighTowerBits->Draw("COLZ");
886  HistDsmL2InputHighTowerBits->GetXaxis()->SetNdivisions(12, false);
887  HistDsmL2InputHighTowerBits->GetYaxis()->SetNdivisions(0, false);
888  TLatex *textHT0 = new TLatex(-1.4, 0.5, "HT < th0");
889  if (textHT0) {
890  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT0);
891  textHT0->SetTextColor(linesColor);
892  textHT0->SetTextSize(0.05);
893  textHT0->Draw();
894  }
895  TLatex *textHT1 = new TLatex(-1.4, 1.5, "th0 < HT < th1");
896  if (textHT1) {
897  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT1);
898  textHT1->SetTextColor(linesColor);
899  textHT1->SetTextSize(0.05);
900  textHT1->Draw();
901  }
902  TLatex *textHT2 = new TLatex(-1.4, 2.5, "th1 < HT < th2");
903  if (textHT2) {
904  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT2);
905  textHT2->SetTextColor(linesColor);
906  textHT2->SetTextSize(0.05);
907  textHT2->Draw();
908  }
909  TLatex *textHT3 = new TLatex(-1.4, 3.5, "th2 < HT");
910  if (textHT3) {
911  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT3);
912  textHT3->SetTextColor(linesColor);
913  textHT3->SetTextSize(0.05);
914  textHT3->Draw();
915  }
916  TLatex *textDsmsL1 = new TLatex(-1.4, 4.5, "#splitline{DSM Level-1}{Boards}");
917  if (textDsmsL1) {
918  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textDsmsL1);
919  textDsmsL1->SetTextColor(linesColor);
920  textDsmsL1->SetTextSize(0.05);
921  textDsmsL1->Draw();
922  }
923  for (Int_t ch = 0;ch < 12;ch += 2) {
924  TLine *lDsmL1Begin = new TLine(ch-0.5, 0, ch-0.5, 5);
925  if (lDsmL1Begin) {
926  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lDsmL1Begin);
927  lDsmL1Begin->SetLineColor(linesColor);
928  lDsmL1Begin->SetLineWidth(1);
929  lDsmL1Begin->Draw();
930  }
931  TString label;
932  if (ch < 6) {
933  label = Form("BW1%.2u", ((ch / 2) % 3) + 1);
934  } else {
935  label = Form("BE1%.2u", ((ch / 2) % 3) + 1);
936  }
937  TLatex *text = new TLatex(ch + 0.1-0.5, 4.5, label.Data());
938  if (text) {
939  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
940  text->SetTextColor(linesColor);
941  text->SetTextSize(0.05);
942  text->Draw();
943  }
944  }
945  }
946 
947  c->cd(2);
948  if (HistDsmL2InputPatchSumBits) {
949  HistDsmL2InputPatchSumBits->SetStats(0);
950  HistDsmL2InputPatchSumBits->Draw("COLZ");
951  HistDsmL2InputPatchSumBits->GetXaxis()->SetNdivisions(12, false);
952  HistDsmL2InputPatchSumBits->GetYaxis()->SetNdivisions(0, false);
953  TLatex *textHT0 = new TLatex(-1.4, 0.5, "Sum < th0");
954  if (textHT0) {
955  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT0);
956  textHT0->SetTextColor(linesColor);
957  textHT0->SetTextSize(0.05);
958  textHT0->Draw();
959  }
960  TLatex *textHT1 = new TLatex(-1.4, 1.5, "th0 < Sum < th1");
961  if (textHT1) {
962  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT1);
963  textHT1->SetTextColor(linesColor);
964  textHT1->SetTextSize(0.05);
965  textHT1->Draw();
966  }
967  TLatex *textHT2 = new TLatex(-1.4, 2.5, "th1 < Sum < th2");
968  if (textHT2) {
969  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT2);
970  textHT2->SetTextColor(linesColor);
971  textHT2->SetTextSize(0.05);
972  textHT2->Draw();
973  }
974  TLatex *textHT3 = new TLatex(-1.4, 3.5, "th2 < Sum");
975  if (textHT3) {
976  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(textHT3);
977  textHT3->SetTextColor(linesColor);
978  textHT3->SetTextSize(0.05);
979  textHT3->Draw();
980  }
981  for (Int_t ch = 0;ch < 12;ch += 2) {
982  TLine *lDsmL1Begin = new TLine(ch-0.5, 0, ch-0.5, 4);
983  if (lDsmL1Begin) {
984  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lDsmL1Begin);
985  lDsmL1Begin->SetLineColor(linesColor);
986  lDsmL1Begin->SetLineWidth(1);
987  lDsmL1Begin->Draw();
988  }
989  }
990  }
991 
992  c->cd(3);
993  if (HistDsmL2InputPatchSum) {
994  HistDsmL2InputPatchSum->SetStats(0);
995  //HistDsmL2InputPatchSum->GetXaxis()->SetNdivisions(0, false);
996  //HistDsmL2InputPatchSum->GetYaxis()->SetNdivisions(0, false);
997  HistDsmL2InputPatchSum->Draw("COLZ");
998  for (Int_t ch = 0;ch < 6;ch++) {
999  TLine *lDsmL1Begin = new TLine(ch-0.5, 0, ch-0.5, 256);
1000  if (lDsmL1Begin) {
1001  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lDsmL1Begin);
1002  lDsmL1Begin->SetLineColor(linesColor);
1003  lDsmL1Begin->SetLineWidth(1);
1004  lDsmL1Begin->Draw();
1005  }
1006  }
1007  }
1008 
1009  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1010 }
1011 //-------------------------------------------------------------------
1012 void BEMCPlotsPresenter::displayL3Input(FileType file, TPad *pad, Int_t mDebug) {
1013  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1014 
1015  FIND_HISTO(TH1F, HistDsmL3InputHighTowerBits, file, HistDsmL3InputHighTowerBitsName);
1016  FIND_HISTO(TH1F, HistDsmL3InputPatchSumBits, file, HistDsmL3InputPatchSumBitsName);
1017  FIND_HISTO(TH1F, HistDsmL3InputBackToBackBit, file, HistDsmL3InputBackToBackBitName);
1018  FIND_HISTO(TH1F, HistDsmL3InputJPsiTopoBit, file, HistDsmL3InputJPsiTopoBitName);
1019  FIND_HISTO(TH1F, HistDsmL3InputJetPatchTopoBit, file, HistDsmL3InputJetPatchTopoBitName);
1020 
1021  if (!pad) return;
1022  pad->Clear();
1023  pad->cd(0);
1024 
1025  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
1026  c->Draw();
1027  c->cd(0);
1028  c->Divide(2, 1, 0.001, 0.001);
1029 
1030  c->cd(1);
1031  if (HistDsmL3InputHighTowerBits) {
1032  //HistDsmL3InputHighTowerBits->SetStats(0);
1033  HistDsmL3InputHighTowerBits->Draw();
1034  }
1035 
1036  c->cd(2);
1037  if (HistDsmL3InputPatchSumBits) {
1038  //HistDsmL3InputPatchSumBits->SetStats(0);
1039  HistDsmL3InputPatchSumBits->Draw();
1040  }
1041 
1042 }
1043 //-------------------------------------------------------------------
1044 void BEMCPlotsPresenter::displaySmdFeeSum(FileType file, TPad *pad, Int_t mDebug) {
1045  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1046 
1047  if (!pad) return;
1048  pad->Clear();
1049  pad->cd(0);
1050 
1051  // 12-19 are the grey shades dark-light
1052  Int_t linesColor = 16;
1053  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
1054  c->Draw();
1055 
1056  c->Divide(1, 2, 0.001, 0.001);
1057 
1058  for (int nonzs = 0;nonzs <= 1;nonzs++) {
1059  c->cd(1 + nonzs);
1060  FIND_HISTO(TH2F, HistSmdFeeSum, file, nonzs ? HistSmdFeeSumNonZSName : HistSmdFeeSumName);
1061  if (HistSmdFeeSum) {
1062  HistSmdFeeSum->SetStats(0);
1063  HistSmdFeeSum->Draw("COLZ");
1064  Int_t moduleRdo[120];
1065  if(BEMCDecoderPresenter) {
1066  Int_t RDO, index;
1067  for (Int_t module = 1;module <= 120;module++) {
1068  moduleRdo[module - 1] = -1;
1069  if (BEMCDecoderPresenter->GetSmdRDO(3, module, 1, 1, RDO, index)) {
1070  moduleRdo[module - 1] = RDO;
1071  }
1072 //cout << "module " << module << ": RDO " << moduleRdo[module - 1] << endl;
1073  }
1074  }
1075  Int_t curmod = 1;
1076  Int_t currdo = -1;
1077  Int_t beginrdo = -1;
1078  Int_t endrdo = -1;
1079  while (curmod <= 121) {
1080 //cout << "curmod = " << curmod << ", currdo = " << currdo << ", beginrdo = " << beginrdo << ", endrdo = " << endrdo << endl;
1081  if (((curmod <= 120) && (moduleRdo[curmod - 1] != currdo)) || (curmod == 121)) {
1082  if ((currdo == -1) && (curmod <= 120)) {
1083  beginrdo = curmod;
1084  currdo = moduleRdo[curmod - 1];
1085  curmod++;
1086  } else {
1087  endrdo = curmod - 1;
1088  TLine *lRdoBegin = new TLine(beginrdo - 0.5, HistSmdFeeSum->GetYaxis()->GetBinLowEdge(1), beginrdo - 0.5, HistSmdFeeSum->GetYaxis()->GetBinUpEdge(HistSmdFeeSum->GetYaxis()->GetNbins()));
1089  if (lRdoBegin) {
1090  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lRdoBegin);
1091  lRdoBegin->SetLineColor(linesColor);
1092  lRdoBegin->SetLineWidth(1);
1093  lRdoBegin->Draw();
1094  }
1095  TLine *lRdoEnd = new TLine(endrdo + 0.5, HistSmdFeeSum->GetYaxis()->GetBinLowEdge(1), endrdo + 0.5, HistSmdFeeSum->GetYaxis()->GetBinUpEdge(HistSmdFeeSum->GetYaxis()->GetNbins()));
1096  if (lRdoEnd) {
1097  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lRdoEnd);
1098  lRdoEnd->SetLineColor(linesColor);
1099  lRdoEnd->SetLineWidth(1);
1100  lRdoEnd->Draw();
1101  }
1102  TString label;
1103  label = Form("RDO %i", currdo);
1104  TLatex *text = new TLatex(beginrdo + 1 -0.5, 0.8 * HistSmdFeeSum->GetYaxis()->GetBinUpEdge(HistSmdFeeSum->GetYaxis()->GetNbins()), label.Data());
1105  if (text) {
1106  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
1107  text->SetTextColor(linesColor);
1108  text->SetTextSize(0.03);
1109  text->Draw();
1110  }
1111  currdo = -1;
1112  if (curmod > 120) curmod++;
1113  }
1114  } else {
1115  curmod++;
1116  }
1117  }
1118  }
1119  } // for(nonzs)
1120 }
1121 //-------------------------------------------------------------------
1122 void BEMCPlotsPresenter::displayPsdFeeSum(FileType file, TPad *pad, Int_t mDebug) {
1123  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1124 
1125  if (!pad) return;
1126  pad->Clear();
1127  pad->cd(0);
1128 
1129  // 12-19 are the grey shades dark-light
1130  Int_t linesColor = 16;
1131  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
1132  c->Draw();
1133 
1134  c->Divide(1, 2, 0.001, 0.001);
1135 
1136  for (int nonzs = 0;nonzs <= 1;nonzs++) {
1137  c->cd(1 + nonzs);
1138  FIND_HISTO(TH2F, HistPsdFeeSum, file, nonzs ? HistPsdFeeSumNonZSName : HistPsdFeeSumName);
1139  if (HistPsdFeeSum) {
1140  HistPsdFeeSum->SetStats(0);
1141  HistPsdFeeSum->Draw("COLZ");
1142  Int_t pmtRdo[60];
1143  for (Int_t box = 0;box < 60;box++) pmtRdo[box] = -1;
1144  if(BEMCDecoderPresenter) {
1145  for (Int_t rdo = 0;rdo < 4;rdo++) {
1146  for (Int_t index = 0;index < 4800;index++) {
1147  Int_t id, box, wire, Avalue;
1148  if (BEMCDecoderPresenter->GetPsdId(rdo, index, id, box, wire, Avalue)) {
1149  if ((box >= 1) && (box <= 60)) {
1150  pmtRdo[box - 1] = rdo + 8;
1151  }
1152  }
1153  }
1154  }
1155  }
1156  Int_t curmod = 1;
1157  Int_t currdo = -1;
1158  Int_t beginrdo = -1;
1159  Int_t endrdo = -1;
1160  while (curmod <= 61) {
1161 //cout << "curmod = " << curmod << ", currdo = " << currdo << ", beginrdo = " << beginrdo << ", endrdo = " << endrdo << endl;
1162  if (((curmod <= 60) && (pmtRdo[curmod - 1] != currdo)) || (curmod == 61)) {
1163  if ((currdo == -1) && (curmod <= 60)) {
1164  beginrdo = curmod;
1165  currdo = pmtRdo[curmod - 1];
1166  curmod++;
1167  } else {
1168  endrdo = curmod - 1;
1169  TLine *lRdoBegin = new TLine(beginrdo - 0.5, HistPsdFeeSum->GetYaxis()->GetBinLowEdge(1), beginrdo - 0.5, HistPsdFeeSum->GetYaxis()->GetBinUpEdge(HistPsdFeeSum->GetYaxis()->GetNbins()));
1170  if (lRdoBegin) {
1171  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lRdoBegin);
1172  lRdoBegin->SetLineColor(linesColor);
1173  lRdoBegin->SetLineWidth(1);
1174  lRdoBegin->Draw();
1175  }
1176  TLine *lRdoEnd = new TLine(endrdo + 0.5, HistPsdFeeSum->GetYaxis()->GetBinLowEdge(1), endrdo + 0.5, HistPsdFeeSum->GetYaxis()->GetBinUpEdge(HistPsdFeeSum->GetYaxis()->GetNbins()));
1177  if (lRdoEnd) {
1178  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(lRdoEnd);
1179  lRdoEnd->SetLineColor(linesColor);
1180  lRdoEnd->SetLineWidth(1);
1181  lRdoEnd->Draw();
1182  }
1183  TString label;
1184  label = Form("RDO %i", currdo);
1185  TLatex *text = new TLatex(beginrdo + 0.5 -0.5, 0.8 * HistPsdFeeSum->GetYaxis()->GetBinUpEdge(HistPsdFeeSum->GetYaxis()->GetNbins()), label.Data());
1186  if (text) {
1187  if (BEMCPlotsCleanUp) BEMCPlotsCleanUp->Add(text);
1188  text->SetTextColor(linesColor);
1189  text->SetTextSize(0.03);
1190  text->Draw();
1191  }
1192  currdo = -1;
1193  if (curmod > 60) curmod++;
1194  }
1195  } else {
1196  curmod++;
1197  }
1198  }
1199  }
1200  } // for(nonzs)
1201 }
1202 //-------------------------------------------------------------------
1203 void BEMCPlotsPresenter::displayTriggerCorruption(FileType file, TPad *pad, bool hold, Int_t mDebug) {
1204  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1205 
1206  FIND_HISTO(TH1F, HistTriggerCorruptionHighTower, file, HistTriggerCorruptionHighTowerName);
1207  FIND_HISTO(TH1F, HistTriggerCorruptionPatchSum, file, HistTriggerCorruptionPatchSumName);
1208  FIND_HISTO(TH2F, HistDSM0HTCorr, file, HistDSM0HTCorrName);
1209  FIND_HISTO(TH2F, HistDSM0TPCorr, file, HistDSM0TPCorrName);
1210 
1211  if (!pad) return;
1212  pad->Clear();
1213  pad->cd(0);
1214 
1215  // 12-19 are the grey shades dark-light
1216  //Int_t linesColor = 16;
1217  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
1218  c->Draw();
1219  c->cd(0);
1220 
1221  //c->Divide(2, 2, 0.001, 0.001);
1222  c->Divide(2, 1, 0.001, 0.001);
1223 
1224  /*
1225  c->cd(1);
1226  if (HistTriggerCorruptionHighTower) {
1227  HistTriggerCorruptionHighTower->SetStats(0);
1228  HistTriggerCorruptionHighTower->Draw();
1229  }
1230  c->cd(2);
1231  if (HistTriggerCorruptionHighTowerCorr) {
1232  HistTriggerCorruptionHighTowerCorr->SetStats(0);
1233  HistTriggerCorruptionHighTowerCorr->Draw("COLZ");
1234  }
1235  */
1236  c->cd(1);
1237  if (HistDSM0HTCorr) {
1238  HistDSM0HTCorr->SetStats(0);
1239  HistDSM0HTCorr->Draw("COLZ");
1240  }
1241  c->cd(2);
1242  if (HistDSM0TPCorr) {
1243  HistDSM0TPCorr->SetStats(0);
1244  HistDSM0TPCorr->Draw("COLZ");
1245  }
1246 }
1247 
1248 
1249 //-------------------------------------------------------------------
1250 void BEMCPlotsPresenter::displayAdcEtaPhi( FileType file, TPad *pad, Int_t mDebug)
1251 {
1252  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1253 
1254  FIND_HISTO(TH2F, Hist_ADCEtaPhi_TowHits, file, Hist_ADCEtaPhi_TowHitsName);
1255  FIND_HISTO(TH2F, Hist_ADCEtaPhi_Pre1Hits, file, Hist_ADCEtaPhi_Pre1HitsName);
1256 
1257  if (!pad) return;
1258  pad->Clear();
1259  pad->cd(0);
1260 
1261  TPad* c = new TPad("pad2", "apd2",0.0,0.1,1.,1.);
1262  c->Draw();
1263  c->cd(0);
1264  c->Divide(1, 2);
1265 
1266  c->cd(1);
1267  if (Hist_ADCEtaPhi_TowHits) {
1268  Hist_ADCEtaPhi_TowHits->SetStats(0);
1269  Hist_ADCEtaPhi_TowHits->Draw("H COLZ");
1270  }
1271  c->cd(2);
1272  if (Hist_ADCEtaPhi_Pre1Hits) {
1273  Hist_ADCEtaPhi_Pre1Hits->SetStats(0);
1274  Hist_ADCEtaPhi_Pre1Hits->Draw("H COLZ");
1275  }
1276 
1277 }
1278 
1279 #undef FIND_HISTO
1280 
1281 //-------------------------------------------------------------------
1282 void BEMCPlotsPresenter::displayTab(Int_t tab, Int_t panel, FileType file, TPad *pad, const Char_t *bemcStatusFilename, Int_t mDebug) {
1283 //mDebug = 10;
1284  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1285  if (BEMCPlotsCleanUp) {
1286  BEMCPlotsCleanUp->Delete();
1287  }
1288  if (!BEMCDecoderPresenter) BEMCDecoderPresenter = new StEmcDecoder();
1289 
1290  static bool first = true;
1291  static BemcTwMask *twMask = 0;
1292  if (first) {
1293  twMask = new BemcTwMask;
1294  bool twMaskFound = useBtowMask(bemcStatusFilename, twMask);
1295  if (!twMaskFound) {
1296  delete twMask;
1297  twMask=0;
1298  }
1299  first = false;
1300  }
1301 
1302  if (mDebug >= 2) cout << "tab = " << tab << endl;
1303  if (mDebug >= 2) cout << "panel = " << panel << endl;
1304  if (!file.file() || (mDebug >= 2)) cout << "file = " << file.file() << endl;
1305  if (!pad || (mDebug >= 2)) cout << "pad = " << pad << endl;
1306  if (!BEMCDecoderPresenter || (mDebug >= 2)) cout << "BEMCDecoderPresenter = " << BEMCDecoderPresenter << endl;
1307 
1308  if (tab == 0) {
1309  if (panel == 0) {
1310  displayStatus(file, pad, mDebug);
1311  } else if (panel == 1) {
1312  displayTowers(file, pad, mDebug);
1313  } else if (panel == 2) {
1314  displaySMDPSD(file, pad, mDebug);
1315  } else if (panel == 3) {
1316  displayTrigger(file, pad, mDebug);
1317  } else if (panel == 4) {
1318  displayJet(file, pad, mDebug);
1319  } else if (panel == 5) {
1320  displayRawAdc(file, pad, false, false, twMask, mDebug);
1321  } else if (panel == 6) {
1322  displayJetPatchHT(file, pad, mDebug);
1323  } else if (panel == 7) {
1324  displayJetPatchSum(file, pad, mDebug);
1325  // } else if (panel == 8) {
1326  // displayL0Input(file, pad, mDebug);
1327  }
1328  else if (panel == 8) {
1329  displayL1Input(file, pad, mDebug);
1330  } else if (panel == 9) {
1331  displayL2Input(file, pad, mDebug);
1332  // } else if (panel == 10) {
1333  // displaySmdFeeSum(file, pad, mDebug);
1334  // } else if (panel == 11) {
1335  // displayTriggerCorruption(file, pad, true, mDebug);
1336  // } else if (panel == 12) {
1337  // displayPsdFeeSum(file, pad, mDebug);
1338  // } else if (panel == 13) {
1339  // displayRawAdc(file, pad, true, mDebug);
1340  }
1341  }
1342  if (tab == 1) {
1343  if (panel == 0) {
1344  displayRawAdc(file, pad, false, true, twMask, mDebug);
1345  } else if (panel == 1) {
1346  displayAdcEtaPhi(file, pad, mDebug);
1347  } else if (panel == 2) {
1348  displaySmdFeeSum(file, pad, mDebug);
1349  } else if (panel == 3) {
1350  displayPsdFeeSum(file, pad, mDebug);
1351  } else if (panel == 4) {
1352  displayRawAdc(file, pad, true, false, twMask, mDebug);
1353  } else if (panel == 5) {
1354  displayL0Input(file, pad, mDebug);
1355  } else if (panel == 6) {
1356  displayTriggerCorruption(file, pad, true, mDebug);
1357  }
1358  }
1359  if (mDebug >= 10) cout << __FILE__ << ":" << __LINE__ << endl;
1360 }
1361 //-------------------------------------------------------------------
1362 void BEMCPlotsPresenter::displayTab(int tab, int panel, FileType file, TPad *pad, int mDebug) {
1363  BEMCPlotsPresenter::displayTab(tab, panel, file, pad, gEnv->GetValue("Online.bemcStatus", "bemcStatus.txt"), mDebug);
1364 }
int GetTriggerPatchFromCrate(int crate, int sequence, int &patchId) const
returns the trigger patch from crate and sequence in the crate
int GetTriggerPatchFromJetPatch(int jetPatch, int sequence, int &patchId) const
returns the trigger patch from big jet patch and the sequence in it
int GetTowerIdFromCrate(int crate, int sequence, int &softId) const
Get Software Id from Crate number and position in crate for towers.
int GetCrateAndSequenceFromTriggerPatch(int patchId, int &crate, int &sequence) const
returns the crate number and start point for a given trigger patch
int GetPsdId(int RDO, int posInFiber, int &softId, bool print=false) const
Get PSD id.
int GetSmdRDO(int detector, int m, int e, int s, int &RDO, int &posInFiber) const
Get SMD fiber and position from detector number (3==SMDE, 4==SMDP), m, e, s.