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()
70 // Default constructor
73 for (Int_t i = 0; i < 6; i++) {
78 strncpy(fFileName,"",256);
82 //////////////////////////////////////////////////////////////////////////////////
83 AliTRDqaGuiClustersStack::AliTRDqaGuiClustersStack(TGWindow *parent)
84 : TGCompositeFrame(parent, 720, 500),
108 SetLayoutManager(new TGVerticalLayout(this));
110 fGPanel = new TGHorizontalFrame(this);
112 // fGLabel = new TGLabel(fGPanel, "Current Stack: ");
113 fGPrevSM = new TGTextButton(fGPanel, "Prev SM");
114 fGPrevStack = new TGTextButton(fGPanel, "Prev Stack");
116 fGNextSM = new TGTextButton(fGPanel, "Next SM");
117 fGNextStack = new TGTextButton(fGPanel, "Next Stack");
119 fGSelectSM = new TGComboBox(fGPanel);
120 for(int i=0; i<fgknSM; i++) fGSelectSM->AddEntry(Form("SM %d", i), i);
121 fGSelectSM->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4));
122 fGSelectSM->Select(fIdxSM);
124 fGSelectStack = new TGComboBox(fGPanel);
125 for(int i=0; i<fgknStack; i++) fGSelectStack->AddEntry(Form("Stack %d", i), i);
126 fGSelectStack->Resize(100, (Int_t)(fGPrevSM->GetHeight()*1.4));
127 fGSelectStack->Select(fIdxStack);
129 fGPlay = new TGTextButton(fGPanel, "PLAY");
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);
136 fGSelectView->Resize(150, (Int_t)(fGPrevSM->GetHeight()*1.4));
137 fGSelectView->Select(0);
139 TGLayoutHints *hint = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5);
141 // fGPanel->AddFrame(fGLabel, hint);
142 fGPanel->AddFrame(fGPrevSM, hint);
143 fGPanel->AddFrame(fGPrevStack, hint);
145 fGPanel->AddFrame(fGSelectSM, hint);
146 fGPanel->AddFrame(fGSelectStack, hint);
148 fGPanel->AddFrame(fGNextStack, hint);
149 fGPanel->AddFrame(fGNextSM, hint);
151 fGPanel->AddFrame(fGPlay, hint);
153 fGPanel->AddFrame(fGSelectView, hint);
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()");
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)");
168 //fGPlay->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "Play()");
172 fGCanvas = new TGCompositeFrame(this);
173 fGCanvas->SetLayoutManager(new TGMatrixLayout(fGCanvas,2,3,1,1));
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);
181 for(Int_t i=0; i<4; i++) {
189 //////////////////////////////////////////////////////////////////////////////////
191 void AliTRDqaGuiClustersStack::SetQAFile(const char *filename) {
193 // Sets a file with histograms
196 strncpy(fFileName,filename,256);
198 for(Int_t i=0; i<fgknCh; i++) {
199 if (fHistList[i]) delete fHistList[i];
203 TFile *file = new TFile(filename);
204 file->cd("TRD/RecPoints");
206 // const char *opt[2] = {"colz", ""};
207 if (fView == 0) CreateHistAmplitude();
208 if (fView == 1) CreateHistTimeMPV();
209 if (fView == 2 || fView == 3) CreateHistTimeCharge();
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();
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);
225 //////////////////////////////////////////////////////////////////////////////////
227 void AliTRDqaGuiClustersStack::SetStack(Int_t idxStack) {
232 fIdxStack = idxStack;
233 fGSelectSM->Select(fIdxSM, 0);
234 fGSelectStack->Select(fIdxStack, 0);
235 SetQAFile(fFileName);
238 //////////////////////////////////////////////////////////////////////////////////
240 void AliTRDqaGuiClustersStack::SetSM(Int_t idxSM) {
242 // sets active super module
246 fGSelectSM->Select(fIdxSM, 0);
247 fGSelectStack->Select(fIdxStack, 0);
248 SetQAFile(fFileName);
251 //////////////////////////////////////////////////////////////////////////////////
253 void AliTRDqaGuiClustersStack::SetView(Int_t idxView) {
255 // sets active data type
259 fGSelectView->Select(idxView);
260 SetQAFile(fFileName);
263 //////////////////////////////////////////////////////////////////////////////////
265 void AliTRDqaGuiClustersStack::CreateHistTimeMPV() {
267 // builds histograms of the Most Probable Value distribution
268 // chamber-by-chamber from a 2D distribution
272 TH2D *fData = (TH2D*)gDirectory->Get(Form("qaTRD_recPoints_sigTime_sm%d", fIdxSM));
275 Int_t nBins = fData->GetYaxis()->GetNbins();
276 Double_t min = fData->GetYaxis()->GetXmin();
277 Double_t max = fData->GetYaxis()->GetXmax();
279 for(Int_t i=0; i<fgknCh; i++) {
281 //printf("I = %d\n", i);
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);
286 // fill the histograms;
287 for(Int_t j=1; j<nBins+2; j++) {
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);
298 //////////////////////////////////////////////////////////////////////////////////
300 void AliTRDqaGuiClustersStack::CreateHistAmplitude() {
302 // builds histograms with amplitude
305 //Info("createHist", "start");
307 TH2D *fData = (TH2D*)gDirectory->Get("qaTRD_recPoints_amp");
310 Int_t nBins = fData->GetYaxis()->GetNbins();
311 Double_t min = fData->GetYaxis()->GetXmin();
312 Double_t max = fData->GetYaxis()->GetXmax();
314 for(Int_t i=0; i<fgknCh; i++) {
316 //printf("I = %d\n", i);
317 //if (fHistList[i]) delete fHistList[i];
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);
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);
333 //////////////////////////////////////////////////////////////////////////////////
335 void AliTRDqaGuiClustersStack::CreateHistTimeCharge() {
337 // builds histograms with time-charge distribution
340 TH3D *fData = (TH3D*)gDirectory->Get("qaTRD_recPoints_sigTime");
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();
348 for(Int_t i=0; i<fgknCh; i++) {
350 //printf("I = %d\n", i);
351 //if (fHistList[i]) delete fHistList[i];
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);
357 // fill the histograms;
358 for(Int_t j=1; j<nBins+1; j++) {
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);
370 fHistList[i]->SetBinContent(j, charge);
373 fHistList[i]->SetBinContent(j, ncls);
378 //////////////////////////////////////////////////////////////////////////////////