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 //////////////////////////////////////////////////////////////////////////////////
73 AliTRDqaGuiClustersStack::AliTRDqaGuiClustersStack(TGWindow *parent)
74 : TGCompositeFrame(parent, 720, 500),
98 SetLayoutManager(new TGVerticalLayout(this));
100 fGPanel = new TGHorizontalFrame(this);
102 // fGLabel = new TGLabel(fGPanel, "Current Stack: ");
103 fGPrevSM = new TGTextButton(fGPanel, "Prev SM");
104 fGPrevStack = new TGTextButton(fGPanel, "Prev Stack");
106 fGNextSM = new TGTextButton(fGPanel, "Next SM");
107 fGNextStack = new TGTextButton(fGPanel, "Next Stack");
109 fGSelectSM = new TGComboBox(fGPanel);
110 for(int i=0; i<fgknSM; i++) fGSelectSM->AddEntry(Form("SM %d", i), i);
111 fGSelectSM->Resize(100, fGPrevSM->GetHeight());
112 fGSelectSM->Select(fIdxSM);
114 fGSelectStack = new TGComboBox(fGPanel);
115 for(int i=0; i<fgknStack; i++) fGSelectStack->AddEntry(Form("Stack %d", i), i);
116 fGSelectStack->Resize(100, fGPrevSM->GetHeight());
117 fGSelectStack->Select(fIdxStack);
119 fGPlay = new TGTextButton(fGPanel, "PLAY");
121 fGSelectView = new TGComboBox(fGPanel);
122 fGSelectView->AddEntry("amplitude",0);
123 fGSelectView->AddEntry("time -- signal MPV", 1);
124 fGSelectView->AddEntry("time -- total charge", 2);
125 fGSelectView->AddEntry("time -- nClusters", 3);
126 fGSelectView->Resize(150, fGPrevSM->GetHeight());
127 fGSelectView->Select(0);
129 TGLayoutHints *hint = new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5);
131 // fGPanel->AddFrame(fGLabel, hint);
132 fGPanel->AddFrame(fGPrevSM, hint);
133 fGPanel->AddFrame(fGPrevStack, hint);
135 fGPanel->AddFrame(fGSelectSM, hint);
136 fGPanel->AddFrame(fGSelectStack, hint);
138 fGPanel->AddFrame(fGNextStack, hint);
139 fGPanel->AddFrame(fGNextSM, hint);
141 fGPanel->AddFrame(fGPlay, hint);
143 fGPanel->AddFrame(fGSelectView, hint);
149 fGPrevStack->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "PreviusStack()");
150 fGNextStack->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "NextStack()");
151 fGPrevSM->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "PreviusSM()");
152 fGNextSM->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "NextSM()");
154 fGSelectSM->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectSM(Int_t)");
155 fGSelectStack->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectStack(Int_t)");
156 fGSelectView->Connect("Selected(Int_t)", "AliTRDqaGuiClustersStack", this, "SelectView(Int_t)");
158 //fGPlay->Connect("Clicked()", "AliTRDqaGuiClustersStack", this, "Play()");
162 fGCanvas = new TGCompositeFrame(this);
163 fGCanvas->SetLayoutManager(new TGMatrixLayout(fGCanvas,2,3,1,1));
165 for(Int_t i=0; i<fgknCh; i++) {
166 fCanvasList[i] = new TRootEmbeddedCanvas(Form("L%d",i), fGCanvas, 320, 300);
167 fGCanvas->AddFrame(fCanvasList[i]);
168 fCanvasList[i]->GetCanvas()->SetRightMargin(0.05);
171 for(Int_t i=0; i<4; i++) {
179 //////////////////////////////////////////////////////////////////////////////////
181 void AliTRDqaGuiClustersStack::SetQAFile(const char *filename) {
183 // Sets a file with histograms
186 strcpy(fFileName, filename);
188 for(Int_t i=0; i<fgknCh; i++) {
189 if (fHistList[i]) delete fHistList[i];
193 TFile *file = new TFile(filename);
194 file->cd("TRD/RecPoints");
196 // const char *opt[2] = {"colz", ""};
197 if (fView == 0) CreateHistAmplitude();
198 if (fView == 1) CreateHistTimeMPV();
199 if (fView == 2 || fView == 3) CreateHistTimeCharge();
201 for(Int_t i=0; i<fgknCh; i++) {
202 fCanvasList[i]->GetCanvas()->cd();
203 if (fHistList[i]) fHistList[i]->Draw(); //opt[i]);
204 fCanvasList[i]->GetCanvas()->Update();
208 // for(Int_t i=0; i<fgknCh; i++) {
209 // TPaveText *title = (TPaveText*)fCanvasList[i]->GetCanvas()->FindObject("title");
210 // title->SetX1NDC(0.7);
211 // title->SetX2NDC(0.95);
215 //////////////////////////////////////////////////////////////////////////////////
217 void AliTRDqaGuiClustersStack::SetStack(Int_t idxStack) {
222 fIdxStack = idxStack;
223 fGSelectSM->Select(fIdxSM, 0);
224 fGSelectStack->Select(fIdxStack, 0);
225 SetQAFile(fFileName);
228 //////////////////////////////////////////////////////////////////////////////////
230 void AliTRDqaGuiClustersStack::SetSM(Int_t idxSM) {
232 // sets active super module
236 fGSelectSM->Select(fIdxSM, 0);
237 fGSelectStack->Select(fIdxStack, 0);
238 SetQAFile(fFileName);
241 //////////////////////////////////////////////////////////////////////////////////
243 void AliTRDqaGuiClustersStack::SetView(Int_t idxView) {
245 // sets active data type
249 fGSelectView->Select(idxView);
250 SetQAFile(fFileName);
253 //////////////////////////////////////////////////////////////////////////////////
255 void AliTRDqaGuiClustersStack::CreateHistTimeMPV() {
257 // builds histograms of the Most Probable Value distribution
258 // chamber-by-chamber from a 2D distribution
262 TH2D *fData = (TH2D*)gDirectory->Get(Form("qaTRD_recPoints_sigTime_sm%d", fIdxSM));
265 Int_t nBins = fData->GetYaxis()->GetNbins();
266 Double_t min = fData->GetYaxis()->GetXmin();
267 Double_t max = fData->GetYaxis()->GetXmax();
269 for(Int_t i=0; i<fgknCh; i++) {
271 //printf("I = %d\n", i);
273 Int_t det = fgknCh * fIdxStack + i;
274 fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;time bin; MPV",det), nBins, min, max);
276 // fill the histograms;
277 for(Int_t j=1; j<nBins+2; j++) {
279 Double_t c = fHistList[i]->GetBinCenter(j);
280 Int_t bin = fData->FindBin(det, c);
281 Double_t value = fData->GetBinContent(bin);
282 fHistList[i]->SetBinContent(j, value);
283 // printf("..j=%d c=%lf bin=%d value=%lf\n", j, c, bin, value);
288 //////////////////////////////////////////////////////////////////////////////////
290 void AliTRDqaGuiClustersStack::CreateHistAmplitude() {
292 // builds histograms with amplitude
295 //Info("createHist", "start");
297 TH2D *fData = (TH2D*)gDirectory->Get("qaTRD_recPoints_amp");
300 Int_t nBins = fData->GetYaxis()->GetNbins();
301 Double_t min = fData->GetYaxis()->GetXmin();
302 Double_t max = fData->GetYaxis()->GetXmax();
304 for(Int_t i=0; i<fgknCh; i++) {
306 //printf("I = %d\n", i);
307 //if (fHistList[i]) delete fHistList[i];
309 Int_t det = fgknCh * fgknStack * fIdxSM + fgknCh * fIdxStack + i;
310 fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;amplidtude",det), nBins, min, max);
312 // fill the histograms;
313 for(Int_t j=1; j<nBins+2; j++) {
314 //printf("..j=%d\n", j);
315 Double_t c = fHistList[i]->GetBinCenter(j);
316 Int_t bin = fData->FindBin(det, c);
317 Double_t value = fData->GetBinContent(bin);
318 fHistList[i]->SetBinContent(j, value);
323 //////////////////////////////////////////////////////////////////////////////////
325 void AliTRDqaGuiClustersStack::CreateHistTimeCharge() {
327 // builds histograms with time-charge distribution
330 TH3D *fData = (TH3D*)gDirectory->Get("qaTRD_recPoints_sigTime");
333 Int_t nBins = fData->GetYaxis()->GetNbins();
334 //Int_t nBinsCharge = fData->GetZaxis()->GetNbins();
335 Double_t min = fData->GetYaxis()->GetXmin();
336 Double_t max = fData->GetYaxis()->GetXmax();
338 for(Int_t i=0; i<fgknCh; i++) {
340 //printf("I = %d\n", i);
341 //if (fHistList[i]) delete fHistList[i];
343 Int_t det = fgknCh * fgknStack * fIdxSM + fgknCh * fIdxStack + i;
344 const char *yaxis[2] = {"total charge", "number of clusters"};
345 fHistList[i] = new TH1D(Form("det%d",det), Form("Det = %d;time bin;%s",det,yaxis[fView-2]), nBins, min, max);
347 // fill the histograms;
348 for(Int_t j=1; j<nBins+1; j++) {
352 for(Int_t k=0; k<201; k++) { // needs more robust loop
353 Int_t bin = fData->FindBin(det, fHistList[i]->GetBinCenter(j), k);
354 Double_t v = fData->GetBinContent(bin);
360 fHistList[i]->SetBinContent(j, charge);
363 fHistList[i]->SetBinContent(j, ncls);
368 //////////////////////////////////////////////////////////////////////////////////