]>
Commit | Line | Data |
---|---|---|
36f55715 | 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: AliTRDqaGuiClustersStack.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 clusters on the stack by stack basis. | |
22 | // It lets display and browse throu histograms created by | |
23 | // the AliTRDQADataMakerRec run during the reconstruction | |
24 | // | |
25 | // S. Radomski | |
26 | // Uni-Heidelberg | |
27 | // Feb. 2008 | |
28 | // | |
29 | ////////////////////////////////////////////////////////////////////////////////// | |
30 | ||
31 | #include "AliTRDqaGuiClustersStack.h" | |
32 | ||
33 | #include "TH1D.h" | |
34 | #include "TH2D.h" | |
35 | #include "TH3D.h" | |
36 | #include "TFile.h" | |
37 | #include "TCanvas.h" | |
38 | #include "TString.h" | |
39 | #include "TSystem.h" | |
40 | ||
41 | #include "TPaveText.h" | |
42 | #include "TGLabel.h" | |
43 | #include "TGComboBox.h" | |
44 | #include "TGButton.h" | |
45 | #include "TRootEmbeddedCanvas.h" | |
46 | ||
47 | ClassImp(AliTRDqaGuiClustersStack) | |
48 | ||
49 | const Int_t AliTRDqaGuiClustersStack::fgknSM = 18; | |
50 | const Int_t AliTRDqaGuiClustersStack::fgknStack = 5; | |
51 | const Int_t AliTRDqaGuiClustersStack::fgknCh = 6; | |
52 | ||
53 | ||
54 | AliTRDqaGuiClustersStack::AliTRDqaGuiClustersStack() | |
55 | : fIdxSM (0), | |
56 | fIdxStack (0), | |
57 | fView (0), | |
58 | fGPanel (0), | |
59 | fGCanvas (0), | |
60 | fGSelectSM (0), | |
61 | fGSelectStack (0), | |
62 | fGSelectView (0), | |
63 | fGPrevSM (0), | |
64 | fGPrevStack (0), | |
65 | fGNextSM (0), | |
66 | fGNextStack (0), | |
67 | fGPlay (0) | |
68 | { | |
02f3bfcc | 69 | // |
70 | // Default constructor | |
71 | // | |
72 | ||
73 | for (Int_t i = 0; i < 6; i++) { | |
74 | fCanvasList[i] = 0x0; | |
75 | fHistList[i] = 0x0; | |
76 | } | |
77 | ||
78 | strncpy(fFileName,"",256); | |
36f55715 | 79 | |
80 | } | |
36f55715 | 81 | |
02f3bfcc | 82 | ////////////////////////////////////////////////////////////////////////////////// |
36f55715 | 83 | AliTRDqaGuiClustersStack::AliTRDqaGuiClustersStack(TGWindow *parent) |
84 | : TGCompositeFrame(parent, 720, 500), | |
85 | fIdxSM (0), | |
86 | fIdxStack (0), | |
87 | fView (0), | |
88 | fGPanel (0), | |
89 | fGCanvas (0), | |
90 | fGSelectSM (0), | |
91 | fGSelectStack (0), | |
92 | fGSelectView (0), | |
93 | fGPrevSM (0), | |
94 | fGPrevStack (0), | |
95 | fGNextSM (0), | |
96 | fGNextStack (0), | |
97 | fGPlay (0) | |
98 | { | |
99 | // | |
100 | // Main constructor | |
101 | // | |
102 | ||
103 | fIdxSM = 0; | |
104 | fIdxStack = 0; | |
105 | ||
106 | // steering panel | |
107 | ||
108 | SetLayoutManager(new TGVerticalLayout(this)); | |
109 | ||
110 | fGPanel = new TGHorizontalFrame(this); | |
111 | ||
112 | // fGLabel = new TGLabel(fGPanel, "Current Stack: "); | |
113 | fGPrevSM = new TGTextButton(fGPanel, "Prev SM"); | |
114 | fGPrevStack = new TGTextButton(fGPanel, "Prev Stack"); | |
115 | ||
116 | fGNextSM = new TGTextButton(fGPanel, "Next SM"); | |
117 | fGNextStack = new TGTextButton(fGPanel, "Next Stack"); | |
118 | ||
119 | fGSelectSM = new TGComboBox(fGPanel); | |
120 | for(int i=0; i<fgknSM; i++) fGSelectSM->AddEntry(Form("SM %d", i), i); | |
a73a87be | 121 | fGSelectSM->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4)); |
36f55715 | 122 | fGSelectSM->Select(fIdxSM); |
123 | ||
124 | fGSelectStack = new TGComboBox(fGPanel); | |
125 | for(int i=0; i<fgknStack; i++) fGSelectStack->AddEntry(Form("Stack %d", i), i); | |
a73a87be | 126 | fGSelectStack->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4)); |
36f55715 | 127 | fGSelectStack->Select(fIdxStack); |
128 | ||
129 | fGPlay = new TGTextButton(fGPanel, "PLAY"); | |
130 | ||
131 | fGSelectView = new TGComboBox(fGPanel); | |
132 | fGSelectView->AddEntry("amplitude",0); | |
133 | fGSelectView->AddEntry("time -- signal MPV", 1); | |
134 | fGSelectView->AddEntry("time -- total charge", 2); | |
135 | fGSelectView->AddEntry("time -- nClusters", 3); | |
a73a87be | 136 | fGSelectView->Resize(150, (Int_t)(fGPrevSM->GetHeight()*1.4)); |
36f55715 | 137 | fGSelectView->Select(0); |
138 | ||
139 | TGLayoutHints *hint = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5); | |
140 | ||
141 | // fGPanel->AddFrame(fGLabel, hint); | |
142 | fGPanel->AddFrame(fGPrevSM, hint); | |
143 | fGPanel->AddFrame(fGPrevStack, hint); | |
144 | ||
145 | fGPanel->AddFrame(fGSelectSM, hint); | |
146 | fGPanel->AddFrame(fGSelectStack, hint); | |
147 | ||
148 | fGPanel->AddFrame(fGNextStack, hint); | |
149 | fGPanel->AddFrame(fGNextSM, hint); | |
150 | ||
151 | fGPanel->AddFrame(fGPlay, hint); | |
152 | ||
153 | fGPanel->AddFrame(fGSelectView, hint); | |
154 | ||
155 | ||
156 | AddFrame(fGPanel); | |
157 | ||
158 | // panel logic | |
159 | fGPrevStack->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "PreviusStack()"); | |
160 | fGNextStack->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "NextStack()"); | |
161 | fGPrevSM->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "PreviusSM()"); | |
162 | fGNextSM->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "NextSM()"); | |
163 | ||
164 | fGSelectSM->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectSM(Int_t)"); | |
165 | fGSelectStack->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectStack(Int_t)"); | |
166 | fGSelectView->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectView(Int_t)"); | |
167 | ||
168 | //fGPlay->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "Play()"); | |
169 | ||
170 | // histograms | |
171 | /**/ | |
172 | fGCanvas = new TGCompositeFrame(this); | |
173 | fGCanvas->SetLayoutManager(new TGMatrixLayout(fGCanvas,2,3,1,1)); | |
174 | ||
175 | for(Int_t i=0; i<fgknCh; i++) { | |
176 | fCanvasList[i] = new TRootEmbeddedCanvas(Form("L%d",i), fGCanvas, 320, 300); | |
177 | fGCanvas->AddFrame(fCanvasList[i]); | |
178 | fCanvasList[i]->GetCanvas()->SetRightMargin(0.05); | |
179 | } | |
180 | ||
181 | for(Int_t i=0; i<4; i++) { | |
182 | fHistList[i] = 0; | |
183 | } | |
184 | ||
185 | AddFrame(fGCanvas); | |
186 | /**/ | |
187 | } | |
188 | ||
189 | ////////////////////////////////////////////////////////////////////////////////// | |
190 | ||
191 | void AliTRDqaGuiClustersStack::SetQAFile(const char *filename) { | |
192 | // | |
193 | // Sets a file with histograms | |
194 | // | |
195 | ||
02f3bfcc | 196 | strncpy(fFileName,filename,256); |
36f55715 | 197 | |
198 | for(Int_t i=0; i<fgknCh; i++) { | |
199 | if (fHistList[i]) delete fHistList[i]; | |
200 | fHistList[i] = 0; | |
201 | } | |
202 | ||
203 | TFile *file = new TFile(filename); | |
204 | file->cd("TRD/RecPoints"); | |
205 | ||
206 | // const char *opt[2] = {"colz", ""}; | |
207 | if (fView == 0) CreateHistAmplitude(); | |
208 | if (fView == 1) CreateHistTimeMPV(); | |
209 | if (fView == 2 || fView == 3) CreateHistTimeCharge(); | |
210 | ||
211 | for(Int_t i=0; i<fgknCh; i++) { | |
212 | fCanvasList[i]->GetCanvas()->cd(); | |
213 | if (fHistList[i]) fHistList[i]->Draw(); //opt[i]); | |
214 | fCanvasList[i]->GetCanvas()->Update(); | |
215 | } | |
216 | ||
217 | // style | |
218 | // for(Int_t i=0; i<fgknCh; i++) { | |
219 | // TPaveText *title = (TPaveText*)fCanvasList[i]->GetCanvas()->FindObject("title"); | |
220 | // title->SetX1NDC(0.7); | |
221 | // title->SetX2NDC(0.95); | |
222 | // } | |
223 | } | |
224 | ||
225 | ////////////////////////////////////////////////////////////////////////////////// | |
226 | ||
227 | void AliTRDqaGuiClustersStack::SetStack(Int_t idxStack) { | |
228 | // | |
229 | // sets active stack | |
230 | // | |
231 | ||
232 | fIdxStack = idxStack; | |
233 | fGSelectSM->Select(fIdxSM, 0); | |
234 | fGSelectStack->Select(fIdxStack, 0); | |
235 | SetQAFile(fFileName); | |
236 | } | |
237 | ||
238 | ////////////////////////////////////////////////////////////////////////////////// | |
239 | ||
240 | void AliTRDqaGuiClustersStack::SetSM(Int_t idxSM) { | |
241 | // | |
242 | // sets active super module | |
243 | // | |
244 | ||
245 | fIdxSM = idxSM; | |
246 | fGSelectSM->Select(fIdxSM, 0); | |
247 | fGSelectStack->Select(fIdxStack, 0); | |
248 | SetQAFile(fFileName); | |
249 | } | |
250 | ||
251 | ////////////////////////////////////////////////////////////////////////////////// | |
252 | ||
253 | void AliTRDqaGuiClustersStack::SetView(Int_t idxView) { | |
254 | // | |
255 | // sets active data type | |
256 | // | |
257 | ||
258 | fView = idxView; | |
259 | fGSelectView->Select(idxView); | |
260 | SetQAFile(fFileName); | |
261 | } | |
262 | ||
263 | ////////////////////////////////////////////////////////////////////////////////// | |
264 | ||
265 | void AliTRDqaGuiClustersStack::CreateHistTimeMPV() { | |
266 | // | |
267 | // builds histograms of the Most Probable Value distribution | |
268 | // chamber-by-chamber from a 2D distribution | |
269 | // | |
270 | ||
271 | ||
272 | TH2D *fData = (TH2D*)gDirectory->Get(Form("qaTRD_recPoints_sigTime_sm%d", fIdxSM)); | |
273 | if (!fData) return; | |
274 | ||
275 | Int_t nBins = fData->GetYaxis()->GetNbins(); | |
276 | Double_t min = fData->GetYaxis()->GetXmin(); | |
277 | Double_t max = fData->GetYaxis()->GetXmax(); | |
278 | ||
279 | for(Int_t i=0; i<fgknCh; i++) { | |
280 | ||
281 | //printf("I = %d\n", i); | |
282 | ||
283 | Int_t det = fgknCh * fIdxStack + i; | |
284 | fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;time bin; MPV",det), nBins, min, max); | |
285 | ||
286 | // fill the histograms; | |
287 | for(Int_t j=1; j<nBins+2; j++) { | |
288 | ||
289 | Double_t c = fHistList[i]->GetBinCenter(j); | |
290 | Int_t bin = fData->FindBin(det, c); | |
291 | Double_t value = fData->GetBinContent(bin); | |
292 | fHistList[i]->SetBinContent(j, value); | |
293 | // printf("..j=%d c=%lf bin=%d value=%lf\n", j, c, bin, value); | |
294 | } | |
295 | } | |
296 | } | |
297 | ||
298 | ////////////////////////////////////////////////////////////////////////////////// | |
299 | ||
300 | void AliTRDqaGuiClustersStack::CreateHistAmplitude() { | |
301 | // | |
302 | // builds histograms with amplitude | |
303 | // | |
304 | ||
305 | //Info("createHist", "start"); | |
306 | ||
307 | TH2D *fData = (TH2D*)gDirectory->Get("qaTRD_recPoints_amp"); | |
308 | if (!fData) return; | |
309 | ||
310 | Int_t nBins = fData->GetYaxis()->GetNbins(); | |
311 | Double_t min = fData->GetYaxis()->GetXmin(); | |
312 | Double_t max = fData->GetYaxis()->GetXmax(); | |
313 | ||
314 | for(Int_t i=0; i<fgknCh; i++) { | |
315 | ||
316 | //printf("I = %d\n", i); | |
317 | //if (fHistList[i]) delete fHistList[i]; | |
318 | ||
319 | Int_t det = fgknCh * fgknStack * fIdxSM + fgknCh * fIdxStack + i; | |
320 | fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;amplidtude",det), nBins, min, max); | |
321 | ||
322 | // fill the histograms; | |
323 | for(Int_t j=1; j<nBins+2; j++) { | |
324 | //printf("..j=%d\n", j); | |
325 | Double_t c = fHistList[i]->GetBinCenter(j); | |
326 | Int_t bin = fData->FindBin(det, c); | |
327 | Double_t value = fData->GetBinContent(bin); | |
328 | fHistList[i]->SetBinContent(j, value); | |
329 | } | |
330 | } | |
331 | } | |
332 | ||
333 | ////////////////////////////////////////////////////////////////////////////////// | |
334 | ||
335 | void AliTRDqaGuiClustersStack::CreateHistTimeCharge() { | |
336 | // | |
337 | // builds histograms with time-charge distribution | |
338 | // | |
339 | ||
340 | TH3D *fData = (TH3D*)gDirectory->Get("qaTRD_recPoints_sigTime"); | |
341 | if (!fData) return; | |
342 | ||
343 | Int_t nBins = fData->GetYaxis()->GetNbins(); | |
344 | //Int_t nBinsCharge = fData->GetZaxis()->GetNbins(); | |
345 | Double_t min = fData->GetYaxis()->GetXmin(); | |
346 | Double_t max = fData->GetYaxis()->GetXmax(); | |
347 | ||
348 | for(Int_t i=0; i<fgknCh; i++) { | |
349 | ||
350 | //printf("I = %d\n", i); | |
351 | //if (fHistList[i]) delete fHistList[i]; | |
352 | ||
353 | Int_t det = fgknCh * fgknStack * fIdxSM + fgknCh * fIdxStack + i; | |
354 | const char *yaxis[2] = {"total charge", "number of clusters"}; | |
355 | fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;time bin;%s",det,yaxis[fView-2]), nBins, min, max); | |
356 | ||
357 | // fill the histograms; | |
358 | for(Int_t j=1; j<nBins+1; j++) { | |
359 | ||
360 | Double_t charge = 0; | |
361 | Double_t ncls = 0; | |
362 | for(Int_t k=0; k<201; k++) { // needs more robust loop | |
363 | Int_t bin = fData->FindBin(det, fHistList[i]->GetBinCenter(j), k); | |
364 | Double_t v = fData->GetBinContent(bin); | |
365 | charge += k * v; | |
366 | ncls += v; | |
367 | } | |
368 | // if (ncls > 1) | |
369 | if (fView == 2) | |
370 | fHistList[i]->SetBinContent(j, charge); | |
371 | ||
372 | if (fView == 3) | |
373 | fHistList[i]->SetBinContent(j, ncls); | |
374 | } | |
375 | } | |
376 | } | |
377 | ||
378 | ////////////////////////////////////////////////////////////////////////////////// |