1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTRDqaGuiClustersStack.cxx 23871 2008-02-12 11:48:20Z hristov $ */
18 //////////////////////////////////////////////////////////////////////////////////
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
29 //////////////////////////////////////////////////////////////////////////////////
31 #include "AliTRDqaGuiClustersStack.h"
41 #include "TPaveText.h"
43 #include "TGComboBox.h"
45 #include "TRootEmbeddedCanvas.h"
47 ClassImp(AliTRDqaGuiClustersStack)
49 const Int_t AliTRDqaGuiClustersStack::fgknSM = 18;
50 const Int_t AliTRDqaGuiClustersStack::fgknStack = 5;
51 const Int_t AliTRDqaGuiClustersStack::fgknCh = 6;
54 AliTRDqaGuiClustersStack::AliTRDqaGuiClustersStack()
71 // Default constructor
74 for (Int_t i = 0; i < 6; i++) {
79 //strncpy(fFileName,"",256);
83 //////////////////////////////////////////////////////////////////////////////////
84 AliTRDqaGuiClustersStack::AliTRDqaGuiClustersStack(TGWindow *parent)
85 : TGCompositeFrame(parent, 720, 500),
110 SetLayoutManager(new TGVerticalLayout(this));
112 fGPanel = new TGHorizontalFrame(this);
114 // fGLabel = new TGLabel(fGPanel, "Current Stack: ");
115 fGPrevSM = new TGTextButton(fGPanel, "Prev SM");
116 fGPrevStack = new TGTextButton(fGPanel, "Prev Stack");
118 fGNextSM = new TGTextButton(fGPanel, "Next SM");
119 fGNextStack = new TGTextButton(fGPanel, "Next Stack");
121 fGSelectSM = new TGComboBox(fGPanel);
122 for(int i=0; i<fgknSM; i++) fGSelectSM->AddEntry(Form("SM %d", i), i);
123 fGSelectSM->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4));
124 fGSelectSM->Select(fIdxSM);
126 fGSelectStack = new TGComboBox(fGPanel);
127 for(int i=0; i<fgknStack; i++) fGSelectStack->AddEntry(Form("Stack %d", i), i);
128 fGSelectStack->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4));
129 fGSelectStack->Select(fIdxStack);
131 fGPlay = new TGTextButton(fGPanel, "PLAY");
133 fGSelectView = new TGComboBox(fGPanel);
134 fGSelectView->AddEntry("amplitude",0);
135 fGSelectView->AddEntry("time -- signal MPV", 1);
136 fGSelectView->AddEntry("time -- total charge", 2);
137 fGSelectView->AddEntry("time -- nClusters", 3);
138 fGSelectView->Resize(150, (Int_t)(fGPrevSM->GetHeight()*1.4));
139 fGSelectView->Select(0);
141 TGLayoutHints *hint = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5);
143 // fGPanel->AddFrame(fGLabel, hint);
144 fGPanel->AddFrame(fGPrevSM, hint);
145 fGPanel->AddFrame(fGPrevStack, hint);
147 fGPanel->AddFrame(fGSelectSM, hint);
148 fGPanel->AddFrame(fGSelectStack, hint);
150 fGPanel->AddFrame(fGNextStack, hint);
151 fGPanel->AddFrame(fGNextSM, hint);
153 fGPanel->AddFrame(fGPlay, hint);
155 fGPanel->AddFrame(fGSelectView, hint);
161 fGPrevStack->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "PreviusStack()");
162 fGNextStack->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "NextStack()");
163 fGPrevSM->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "PreviusSM()");
164 fGNextSM->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "NextSM()");
166 fGSelectSM->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectSM(Int_t)");
167 fGSelectStack->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectStack(Int_t)");
168 fGSelectView->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectView(Int_t)");
170 //fGPlay->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "Play()");
174 fGCanvas = new TGCompositeFrame(this);
175 fGCanvas->SetLayoutManager(new TGMatrixLayout(fGCanvas,2,3,1,1));
177 for(Int_t i=0; i<fgknCh; i++) {
178 fCanvasList[i] = new TRootEmbeddedCanvas(Form("L%d",i), fGCanvas, 320, 300);
179 fGCanvas->AddFrame(fCanvasList[i]);
180 fCanvasList[i]->GetCanvas()->SetRightMargin(0.05);
183 for(Int_t i=0; i<4; i++) {
191 //////////////////////////////////////////////////////////////////////////////////
193 void AliTRDqaGuiClustersStack::SetQAFile(const char *filename) {
195 // Sets a file with histograms
198 //strncpy(fFileName,filename,256);
199 fFileName = filename;
201 for(Int_t i=0; i<fgknCh; i++) {
202 if (fHistList[i]) delete fHistList[i];
206 TFile *file = new TFile(filename);
207 file->cd("TRD/RecPoints");
209 // const char *opt[2] = {"colz", ""};
210 if (fView == 0) CreateHistAmplitude();
211 if (fView == 1) CreateHistTimeMPV();
212 if (fView == 2 || fView == 3) CreateHistTimeCharge();
214 for(Int_t i=0; i<fgknCh; i++) {
215 fCanvasList[i]->GetCanvas()->cd();
216 if (fHistList[i]) fHistList[i]->Draw(); //opt[i]);
217 fCanvasList[i]->GetCanvas()->Update();
221 // for(Int_t i=0; i<fgknCh; i++) {
222 // TPaveText *title = (TPaveText*)fCanvasList[i]->GetCanvas()->FindObject("title");
223 // title->SetX1NDC(0.7);
224 // title->SetX2NDC(0.95);
228 //////////////////////////////////////////////////////////////////////////////////
230 void AliTRDqaGuiClustersStack::SetStack(Int_t idxStack) {
235 fIdxStack = idxStack;
236 fGSelectSM->Select(fIdxSM, 0);
237 fGSelectStack->Select(fIdxStack, 0);
238 SetQAFile(fFileName);
241 //////////////////////////////////////////////////////////////////////////////////
243 void AliTRDqaGuiClustersStack::SetSM(Int_t idxSM) {
245 // sets active super module
249 fGSelectSM->Select(fIdxSM, 0);
250 fGSelectStack->Select(fIdxStack, 0);
251 SetQAFile(fFileName);
254 //////////////////////////////////////////////////////////////////////////////////
256 void AliTRDqaGuiClustersStack::SetView(Int_t idxView) {
258 // sets active data type
262 fGSelectView->Select(idxView);
263 SetQAFile(fFileName);
266 //////////////////////////////////////////////////////////////////////////////////
268 void AliTRDqaGuiClustersStack::CreateHistTimeMPV() {
270 // builds histograms of the Most Probable Value distribution
271 // chamber-by-chamber from a 2D distribution
275 TH2D *fData = (TH2D*)gDirectory->Get(Form("qaTRD_recPoints_sigTime_sm%d", fIdxSM));
278 Int_t nBins = fData->GetYaxis()->GetNbins();
279 Double_t min = fData->GetYaxis()->GetXmin();
280 Double_t max = fData->GetYaxis()->GetXmax();
282 for(Int_t i=0; i<fgknCh; i++) {
284 //printf("I = %d\n", i);
286 Int_t det = fgknCh * fIdxStack + i;
287 fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;time bin; MPV",det), nBins, min, max);
289 // fill the histograms;
290 for(Int_t j=1; j<nBins+2; j++) {
292 Double_t c = fHistList[i]->GetBinCenter(j);
293 Int_t bin = fData->FindBin(det, c);
294 Double_t value = fData->GetBinContent(bin);
295 fHistList[i]->SetBinContent(j, value);
296 // printf("..j=%d c=%lf bin=%d value=%lf\n", j, c, bin, value);
301 //////////////////////////////////////////////////////////////////////////////////
303 void AliTRDqaGuiClustersStack::CreateHistAmplitude() {
305 // builds histograms with amplitude
308 //Info("createHist", "start");
310 TH2D *fData = (TH2D*)gDirectory->Get("qaTRD_recPoints_amp");
313 Int_t nBins = fData->GetYaxis()->GetNbins();
314 Double_t min = fData->GetYaxis()->GetXmin();
315 Double_t max = fData->GetYaxis()->GetXmax();
317 for(Int_t i=0; i<fgknCh; i++) {
319 //printf("I = %d\n", i);
320 //if (fHistList[i]) delete fHistList[i];
322 Int_t det = fgknCh * fgknStack * fIdxSM + fgknCh * fIdxStack + i;
323 fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;amplidtude",det), nBins, min, max);
325 // fill the histograms;
326 for(Int_t j=1; j<nBins+2; j++) {
327 //printf("..j=%d\n", j);
328 Double_t c = fHistList[i]->GetBinCenter(j);
329 Int_t bin = fData->FindBin(det, c);
330 Double_t value = fData->GetBinContent(bin);
331 fHistList[i]->SetBinContent(j, value);
336 //////////////////////////////////////////////////////////////////////////////////
338 void AliTRDqaGuiClustersStack::CreateHistTimeCharge() {
340 // builds histograms with time-charge distribution
343 TH3D *fData = (TH3D*)gDirectory->Get("qaTRD_recPoints_sigTime");
346 Int_t nBins = fData->GetYaxis()->GetNbins();
347 //Int_t nBinsCharge = fData->GetZaxis()->GetNbins();
348 Double_t min = fData->GetYaxis()->GetXmin();
349 Double_t max = fData->GetYaxis()->GetXmax();
351 for(Int_t i=0; i<fgknCh; i++) {
353 //printf("I = %d\n", i);
354 //if (fHistList[i]) delete fHistList[i];
356 Int_t det = fgknCh * fgknStack * fIdxSM + fgknCh * fIdxStack + i;
357 const char *yaxis[2] = {"total charge", "number of clusters"};
358 fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;time bin;%s",det,yaxis[fView-2]), nBins, min, max);
360 // fill the histograms;
361 for(Int_t j=1; j<nBins+1; j++) {
365 for(Int_t k=0; k<201; k++) { // needs more robust loop
366 Int_t bin = fData->FindBin(det, fHistList[i]->GetBinCenter(j), k);
367 Double_t v = fData->GetBinContent(bin);
373 fHistList[i]->SetBinContent(j, charge);
376 fHistList[i]->SetBinContent(j, ncls);
381 //////////////////////////////////////////////////////////////////////////////////