]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaGui/AliTRDqaGuiBlackChamber.cxx
Undoing changes to AliGlauberMC
[u/mrichter/AliRoot.git] / TRD / qaGui / AliTRDqaGuiBlackChamber.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id: AliTRDqaGuiBlackChamber.cxx 23871 2008-02-12 11:48:20Z hristov $ */
17
18 //////////////////////////////////////////////////////////////////////////////////
19 //
20 // This class is a Graphical User Interface for the Quality Monitorig 
21 // of black (non zero zuppresed) events from TRD. 
22 // It lets display and browse throu histograms created by the class 
23 // AliTRDqaBlackEvents.
24 // The class works in cooperation with AliTRDqaGuiMainBlack.
25 //
26 // S. Radomski 
27 // Uni-Heidelberg
28 // Feb. 2008
29 // 
30 //////////////////////////////////////////////////////////////////////////////////
31
32 #include "AliTRDqaGuiBlackChamber.h"
33
34 #include "TH1D.h"
35 #include "TH2D.h"
36 #include "TH3D.h"
37 #include "TFile.h"
38 #include "TCanvas.h"
39 #include "TString.h"
40 #include "TSystem.h"
41
42 #include "TLine.h"
43 #include "TPaveText.h"
44 #include "TGLabel.h"
45 #include "TGComboBox.h"
46 #include "TGButton.h"
47 #include "TRootEmbeddedCanvas.h"
48
49 ClassImp(AliTRDqaGuiBlackChamber)
50
51 const Int_t AliTRDqaGuiBlackChamber::fgknSM = 18;
52 const Int_t AliTRDqaGuiBlackChamber::fgknChamber = 30;
53 //const Int_t AliTRDqaGuiBlackChamber::fgknCh = 6;
54
55 //////////////////////////////////////////////////////////////////////////////////
56
57 AliTRDqaGuiBlackChamber::AliTRDqaGuiBlackChamber() 
58   : fView(0),
59     fSetRangePed(0),
60     fSetRangeNoise(0),
61     fIdxSM(0),
62     fIdxChamber(0),
63     fFileName(0x0),
64     fGPanel(0),
65     fGCanvas(0),
66     fGCanvasUp(0),
67     fGCanvasDown(0),
68     fGSelectSM(0),
69     fGSelectChamber(0),
70     fGSelectView(0),
71     fGPrevSM(0),
72     fGPrevChamber(0), 
73     fGNextSM(0),
74     fGNextChamber(0)
75 {
76   //
77   // Default constructor
78   //
79
80   for (Int_t i = 0; i < 2; i++) {
81     fRangePed[i]   = 0.0;
82     fRangeNoise[i] = 0.0;
83   }
84
85   for (Int_t j = 0; j < 5; j++) {
86     fCanvasList[j] = 0x0;
87     fHistList[j]   = 0x0;    
88   }
89
90   //strncpy(fFileName,"",256);
91
92 }
93
94 //////////////////////////////////////////////////////////////////////////////////
95
96 AliTRDqaGuiBlackChamber::AliTRDqaGuiBlackChamber(TGWindow *parent)
97   : TGCompositeFrame(parent, 720, 500), 
98     fView(0),
99     fSetRangePed(0),
100     fSetRangeNoise(0),
101     fIdxSM(0),
102     fIdxChamber(0),
103     fFileName(0x0),
104     fGPanel(0),
105     fGCanvas(0),
106     fGCanvasUp(0),
107     fGCanvasDown(0),
108     fGSelectSM(0),
109     fGSelectChamber(0),
110     fGSelectView(0),
111     fGPrevSM(0),
112     fGPrevChamber(0),
113     fGNextSM(0),
114     fGNextChamber(0)
115 {
116   //
117   // main constructor
118   // 
119   
120    // steering panel 
121   
122   SetLayoutManager(new TGVerticalLayout(this));
123   fGPanel = new TGHorizontalFrame(this);
124
125   // fGLabel = new TGLabel(fGPanel, "Current Chamber: ");
126   fGPrevSM = new TGTextButton(fGPanel, "Prev SM");
127   fGPrevChamber = new TGTextButton(fGPanel, "Prev Chamber");
128
129   fGNextSM = new TGTextButton(fGPanel, "Next SM");
130   fGNextChamber = new TGTextButton(fGPanel, "Next Chamber");
131
132   fGSelectSM = new TGComboBox(fGPanel);
133   for(int i=0; i<fgknSM; i++) fGSelectSM->AddEntry(Form("SM %d", i), i);
134   fGSelectSM->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4));
135   fGSelectSM->Select(fIdxSM);
136
137   fGSelectChamber = new TGComboBox(fGPanel);
138   for(int i=0; i<fgknChamber; i++) fGSelectChamber->AddEntry(Form("Chamber %d", i), i);
139   fGSelectChamber->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4));
140   fGSelectChamber->Select(fIdxChamber);
141
142   // vew
143   fGSelectView = new TGComboBox(fGPanel);
144   fGSelectView->AddEntry("pedestals",0);
145   fGSelectView->AddEntry("entiries", 1);
146   fGSelectView->Resize(150, (Int_t)(fGPrevSM->GetHeight()*1.4));
147   fGSelectView->Select(0);
148
149
150   //fGPlay = new TGTextButton(fGPanel, "PLAY");
151
152   TGLayoutHints *hint = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5);
153   
154   // fGPanel->AddFrame(fGLabel, hint);
155   fGPanel->AddFrame(fGPrevSM, hint);
156   fGPanel->AddFrame(fGPrevChamber, hint);
157
158   fGPanel->AddFrame(fGSelectSM, hint);
159   fGPanel->AddFrame(fGSelectChamber, hint);
160
161   fGPanel->AddFrame(fGNextChamber, hint);
162   fGPanel->AddFrame(fGNextSM, hint);
163
164   fGPanel->AddFrame(fGSelectView, hint);
165   //fGPanel->AddFrame(fGPlay, hint);
166
167   AddFrame(fGPanel);
168
169   // panel logic
170   fGPrevChamber->Connect("Clicked()", "AliTRDqaGuiBlackChamber", this, "PreviusChamber()");
171   fGNextChamber->Connect("Clicked()", "AliTRDqaGuiBlackChamber", this, "NextChamber()");
172   fGPrevSM->Connect("Clicked()", "AliTRDqaGuiBlackChamber", this, "PreviusSM()");
173   fGNextSM->Connect("Clicked()", "AliTRDqaGuiBlackChamber", this, "NextSM()");
174
175   fGSelectSM->Connect("Selected(Int_t)", "AliTRDqaGuiBlackChamber", this, "SelectSM(Int_t)");
176   fGSelectChamber->Connect("Selected(Int_t)", "AliTRDqaGuiBlackChamber", this, "SelectChamber(Int_t)");
177   
178   fGSelectView->Connect("Selected(Int_t)", "AliTRDqaGuiBlackChamber", this, "SelectView(Int_t)");
179
180   //fGPlay->Connect("Clicked()", "AliTRDqaGuiBlackChamber", this, "Play()");
181
182   // histograms
183   
184   // fGCanvas = new TGCompositeFrame(this);
185   // fGCanvas->SetLayoutManager(new TGMatrixLayout(fGCanvas,2,2,0,0));
186   
187   //for(Int_t i=0; i<4; i++) {
188   //  fCanvasList[i] = new TRootEmbeddedCanvas(Form("L%d",i), fGCanvas, 480, 300);
189   //  fGCanvas->AddFrame(fCanvasList[i]);
190   // }
191
192
193   fGCanvasUp = new TGCompositeFrame(this);
194   fGCanvasUp->SetLayoutManager(new TGMatrixLayout(fGCanvasUp,1,2,1,1));
195
196   for(Int_t i=0; i<2; i++) {
197     fCanvasList[i] = new TRootEmbeddedCanvas(Form("L%d",i), fGCanvasUp, 480, 400);
198     fGCanvasUp->AddFrame(fCanvasList[i]);    
199     fCanvasList[i]->GetCanvas()->SetTopMargin(0.05);
200     fCanvasList[i]->GetCanvas()->SetRightMargin(0.15);
201     fCanvasList[i]->GetCanvas()->SetBottomMargin(0.05);
202   }
203   
204   
205   fGCanvasDown = new TGCompositeFrame(this);
206   fGCanvasDown->SetLayoutManager(new TGMatrixLayout(fGCanvasDown, 1,3,1,1));
207     
208   for(Int_t i=2; i<5; i++) {
209     fCanvasList[i] = new TRootEmbeddedCanvas(Form("L%d",i), fGCanvasDown, 320, 300);
210     fGCanvasDown->AddFrame(fCanvasList[i]);   
211     fCanvasList[i]->GetCanvas()->SetTopMargin(0.05);
212     fCanvasList[i]->GetCanvas()->SetRightMargin(0.05);
213   }
214   
215   for(Int_t i=0; i<5; i++) {
216     fHistList[i] = 0;
217   }
218
219   AddFrame(fGCanvasUp);
220   AddFrame(fGCanvasDown);
221
222 }
223
224 //////////////////////////////////////////////////////////////////////////////////
225
226 void AliTRDqaGuiBlackChamber::SetQAFile(const char *filename) {
227   //
228   // sets a file with histograms
229   //
230
231   //const char *names[5] = {"ped", "noise", "pedDist", "noiseDist", "signal"};
232   const char *names[10] = {
233     "ped", "noise", "pedDist", "noiseDist", "signal",
234     "entries", "entriesRM", "entriesDist", "", ""
235   };
236   const char *opt[10] = {"colz", "colz", "", "", "", "colz", "colz", "", "", ""};
237   const Int_t kLogy[10] = {0, 0, 1, 1, 1, 0, 0, 1, 1,1};
238   
239   //strncpy(fFileName,filename,256);
240   fFileName = filename;
241  
242   for(int i=0; i<5; i++) {
243     if (fHistList[i]) delete fHistList[i];
244   }
245   
246   TFile *file = new TFile(filename);
247
248   // printf("%d %lf %lf\n", fSetRangePed, fRangePed[0], fRangePed[1]);
249   //printf("%d %lf %lf\n", fSetRangeNoise, fRangeNoise[0], fRangeNoise[1]);
250
251   for(Int_t i=0; i<5; i++) {
252
253     Int_t index = fIdxSM * 30 + fIdxChamber;
254     const char *nn = Form("%s_%d", names[i+5*fView], index);
255     //printf("%s\n", nn);
256     fHistList[i] = (TH1*)file->Get(nn); //Form("%s_$d", names[fIdxType], index));
257     if (!fHistList[i]) continue;
258
259     if ( (fView == 1) && (i == 0)) {
260       fHistList[i]->SetMinimum(0);
261       fHistList[i]->SetMaximum(2);
262     }
263
264     if ( (fView == 0) && (i == 0)  && fSetRangePed) {
265       fHistList[i]->SetMinimum(fRangePed[0]);
266       fHistList[i]->SetMaximum(fRangePed[1]);
267     }
268     
269     if ( (fView == 0) && (i == 1) && fSetRangeNoise) {
270       fHistList[i]->SetMinimum(fRangeNoise[0]);
271       fHistList[i]->SetMaximum(fRangeNoise[1]);
272     }
273
274     fCanvasList[i]->GetCanvas()->cd();
275     fCanvasList[i]->GetCanvas()->SetLogy(kLogy[i+5*fView]);
276     if (fHistList[i]) fHistList[i]->Draw(opt[i+5*fView]);
277     //fCanvasList[i]->GetCanvas()->Update();
278   }
279   
280   // mcm lines
281   TLine *line;
282   for(Int_t i=1; i<8; i++) {
283
284     fCanvasList[0]->GetCanvas()->cd();
285     line = new TLine(0, i*18-0.5, 15, i*18-0.5);
286     line->SetLineStyle(2);
287     if (i!=4) line->SetLineStyle(3);
288     line->Draw();
289
290     fCanvasList[1]->GetCanvas()->cd();
291     line = new TLine(0, i*18-0.5, 15, i*18-0.5);
292     line->SetLineStyle(2);
293     if (i!=4) line->SetLineStyle(3);
294     line->Draw();    
295   }
296   
297   for(Int_t i=1; i<4; i++) {
298     
299     fCanvasList[0]->GetCanvas()->cd();
300     line = new TLine(i*4-0.5, 0, i*4-0.5, 143);
301     line->SetLineStyle(2);
302     line->Draw();
303
304     fCanvasList[1]->GetCanvas()->cd();
305     line = new TLine(i*4-0.5, 0, i*4-0.5, 143);
306     line->SetLineStyle(2);
307     line->Draw();  
308   }
309
310   
311
312
313   
314   for(Int_t i=0; i<5; i++)
315     fCanvasList[i]->GetCanvas()->Update();
316 }
317
318 //////////////////////////////////////////////////////////////////////////////////
319
320 void AliTRDqaGuiBlackChamber::SetChamber(Int_t idxChamber) {
321   //
322   // sets active chamber 
323   //
324
325   fIdxChamber = idxChamber; 
326   fGSelectSM->Select(fIdxSM, 0); 
327   fGSelectChamber->Select(fIdxChamber, 0);
328   SetQAFile(fFileName);
329 }
330
331 //////////////////////////////////////////////////////////////////////////////////
332
333 void AliTRDqaGuiBlackChamber::SetSM(Int_t idxSM) {
334   //
335   // sets active supermodule
336   //
337
338   fIdxSM = idxSM; 
339   fGSelectSM->Select(fIdxSM, 0); 
340   fGSelectChamber->Select(fIdxChamber, 0); 
341   SetQAFile(fFileName);
342 }
343
344 //////////////////////////////////////////////////////////////////////////////////
345
346 void AliTRDqaGuiBlackChamber::SetView(Int_t idxView) {
347   //
348   // sets active view
349   //
350   
351   fView = idxView;
352   fGSelectView->Select(idxView);
353   SetQAFile(fFileName);
354 }
355 //////////////////////////////////////////////////////////////////////////////////