1 /**************************************************************************
\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
\r
4 * Author: The ALICE Off-line Project. *
\r
5 * Contributors are mentioned in the code where appropriate. *
\r
7 * Permission to use, copy, modify and distribute this software and its *
\r
8 * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * withount fee, provided that the abovĂ…
\9be copyright notice appears in all *
\r
10 * copies and that both the copyright notice and this permission notice *
\r
11 * appear in the supporting documentation. The authors make no claims *
\r
12 * about the suitability of this software for any purpose. It is *
\r
13 * provided "as is" without express or implied warranty. *
\r
14 **************************************************************************/
\r
16 /* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */
\r
18 ////////////////////////////////////////////////////////////////////////////
\r
20 // QA of black events //
\r
23 // Sylwester Radomski (radomski@physi.uni-heidelberg.de) //
\r
25 ////////////////////////////////////////////////////////////////////////////
\r
32 #include "TCanvas.h"
\r
37 #include "AliTRDgeometry.h"
\r
38 #include "AliTRDrawStreamTB.h"
\r
39 #include "AliTRDqaBlackEvents.h"
\r
41 ClassImp(AliTRDqaBlackEvents)
\r
44 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
46 AliTRDqaBlackEvents::AliTRDqaBlackEvents()
\r
55 // to create the histograms call Init()
\r
59 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
61 AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
\r
69 // Copy constructor
\r
70 // to create the histograms call Init()
\r
74 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
76 void AliTRDqaBlackEvents::Init()
\r
79 // creates histograms
\r
82 //TFile *file = new
\r
83 //Info("Init", "Statring");
\r
87 for(Int_t i=0; i<540; i++) {
\r
88 fNPoint[i] = new TH2D(Form("entries_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
89 fData[i] = new TH3D(Form("data_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);
\r
90 fChPed[i] = new TH2D(Form("ped_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
91 fChNoise[i] = new TH2D(Form("noise_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
92 fPed[i] = new TH1D(Form("pedDist_%d", i), ";pedestals (ADC counts)", 100, 5, 15);
\r
93 fNoise[i] = new TH1D(Form("noiseDist_%d", i), ";noise (ADC counts)", 100, 0, 5);
\r
94 fSignal[i] = new TH1D(Form("signal_%d", i), "signal (ADC counts)", 100, -0.5, 99.5);
\r
97 fOccupancy = new TH1D("occupancy", "", 20, -0.5, 19.5);
\r
99 //Info("Init", "Done");
\r
103 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
105 void AliTRDqaBlackEvents::Reset()
\r
108 // Resets the histograms
\r
111 for(Int_t i=0; i<540; i++) {
\r
113 fChPed[i]->Reset();
\r
114 fChNoise[i]->Reset();
\r
118 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
120 Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
\r
127 Char_t isUsed[540][16][144];
\r
128 for(Int_t i=0; i<540; i++)
\r
129 for(Int_t j=0; j<16; j++)
\r
130 for(Int_t k=0; k<144; k++)
\r
131 isUsed[i][j][k] = 0;
\r
134 while (data->Next()) {
\r
136 Int_t det = data->GetDet();
\r
137 Int_t row = data->GetRow();
\r
138 Int_t col = data->GetCol();
\r
139 Int_t *sig = data->GetSignals();
\r
142 //printf("det = %d\n", det);
\r
144 if (det<0 || det>=540) continue;
\r
145 isUsed[det][row][col]++;
\r
147 // if (!isUsed[det][data->GetRow()][data->GetCol()]) {
\r
148 // isUsed[det][data->GetRow()][data->GetCol()] = 1;
\r
152 fNPoint[det]->Fill(row, col);
\r
154 for(Int_t k=0; k<30; k++) { /// to be corrected
\r
155 fSignal[det]->Fill(sig[k]);
\r
156 fData[det]->Fill(row, col, sig[k]);
\r
160 for(Int_t i=0; i<540; i++) {
\r
161 if (i != 0 && i != 8) continue;
\r
162 for(Int_t j=0; j<16; j++)
\r
163 for(Int_t k=0; k<144; k++)
\r
164 fOccupancy->Fill(isUsed[i][j][k]);
\r
172 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
174 void AliTRDqaBlackEvents::Process(const char *filename)
\r
177 // Process something
\r
182 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);
\r
183 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);
\r
184 fit->SetParameters(1e3, 10, 1);
\r
186 for(Int_t i=0; i<540; i++) {
\r
189 if (fData[i]->GetSum() < 10) continue;
\r
192 Info("process", "processing chamber %d", i);
\r
194 for(Int_t j=0; j<fData[i]->GetXaxis()->GetNbins(); j++) {
\r
195 for(Int_t k=0; k<fData[i]->GetYaxis()->GetNbins(); k++) {
\r
197 // project the histogramm
\r
199 for(Int_t bb=0; bb<50; bb++) {
\r
200 Int_t dataBin = fData[i]->FindBin(j, k, bb);
\r
201 Double_t v = fData[i]->GetBinContent(dataBin);
\r
202 hist->SetBinContent(bb+1, v);
\r
205 //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);
\r
207 Int_t bin = fChPed[i]->FindBin(j, k);
\r
209 if (hist->GetSum() > 1) {
\r
211 Double_t ped = 0, noise = 0;
\r
213 if (fFitType == 0) {
\r
214 fit->SetParameters(1e3, 10, 1);
\r
215 hist->Fit(fit, "q0", "goff", 0, 20);
\r
216 TF1 *f = hist->GetFunction("fit");
\r
217 ped = TMath::Abs(f->GetParameter(1));
\r
218 noise = TMath::Abs(f->GetParameter(2));
\r
220 ped = hist->GetMean();
\r
221 noise = hist->GetRMS();
\r
224 fChPed[i]->SetBinContent(bin, ped);
\r
225 fChNoise[i]->SetBinContent(bin, noise);
\r
227 fPed[i]->Fill(ped);
\r
228 fNoise[i]->Fill(noise);
\r
231 fChPed[i]->SetBinContent(bin, 0);
\r
232 fChNoise[i]->SetBinContent(bin, 0);
\r
240 // normalize number of entries histos
\r
244 for(Int_t i=0; i<540; i++) {
\r
245 if (!map[i]) continue;
\r
246 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
\r
247 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
\r
248 Int_t dataBin = fNPoint[i]->FindBin(j, k);
\r
249 Double_t v = fNPoint[i]->GetBinContent(dataBin);
\r
250 if (v > max) max = (Int_t)v;
\r
255 for(Int_t i=0; i<540; i++) {
\r
257 if (!map[i]) continue;
\r
259 fNPointDist[i] = new TH1D(Form("entriesDist_%d", i), ";number of events", max+2, -0.5, max+1.5);
\r
261 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
\r
262 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
\r
263 Int_t dataBin = fNPoint[i]->FindBin(j, k);
\r
264 Double_t v = fNPoint[i]->GetBinContent(dataBin);
\r
265 //if (v > fnEvents) printf("N = %d V = %lf\n", fnEvents, v);
\r
266 fNPointDist[i]->Fill(v);
\r
270 fNPoint[i]->Scale(1./fnEvents);
\r
274 TFile *file = new TFile(filename, "UPDATE");
\r
275 for(Int_t i=0; i<540; i++) {
\r
276 if (!map[i]) continue;
\r
277 fChPed[i]->Write();
\r
278 fChNoise[i]->Write();
\r
279 fNPoint[i]->Write();
\r
280 fNPointDist[i]->Write();
\r
282 fNoise[i]->Write();
\r
283 fSignal[i]->Write();
\r
285 fOccupancy->Write();
\r
290 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
292 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h)
\r
295 // Draw raport for one chamber:
\r
296 // pedestal map, noise map, distribution of pedestal and noise
\r
299 // name of the file with histograms (created with Process())
\r
300 // detector Id (0 - 539)
\r
303 // setup global style
\r
304 gStyle->SetPalette(1);
\r
305 gStyle->SetOptStat(0);
\r
306 gStyle->SetPadTopMargin(0.02);
\r
307 gStyle->SetPadBottomMargin(0.05);
\r
309 TFile *file = new TFile(filename, "READ");
\r
311 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);
\r
312 c->SetVertical(kFALSE);
\r
313 c->Divide(3,1, 0.01, 0.01);
\r
316 TPad *mPad = (TPad*) gPad;
\r
317 mPad->Divide(1,2,0.01,0.01);
\r
320 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));
\r
322 h2->SetMaximum(15);
\r
323 h2->SetTitle(";Z direction;#phi direction");
\r
327 h2 = (TH2D*)file->Get(Form("noise_%d",det));
\r
328 h2->SetMinimum(fMinNoise);
\r
329 h2->SetMaximum(fMaxNoise);
\r
330 h2->SetTitle(";Z direction;#phi direction");
\r
335 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));
\r
340 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));
\r
344 TF1 *f = h1->GetFunction("gaus");
\r
345 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));
\r
346 TLatex *ll = new TLatex(2, 100, tt);
\r
347 ll->SetTextSize(0.06);
\r
351 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
353 void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h)
\r
359 gStyle->SetPalette(1);
\r
360 gStyle->SetOptStat(0);
\r
362 gStyle->SetPadTopMargin(0.02);
\r
363 //gStyle->SetPadBottomMargin(0.05);
\r
364 //gStyle->SetPadLeftMargin(0.02);
\r
365 //gStyle->SetPadRightMargin(0.02);
\r
367 TFile *file = new TFile(filename, "READ");
\r
369 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);
\r
370 c->SetVertical(kFALSE);
\r
371 c->Divide(5, 6, 0.001, 0.01);
\r
373 for(Int_t i=0; i<30; i++) {
\r
375 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));
\r
377 h2->SetMinimum(fMinNoise);
\r
378 h2->SetMaximum(fMaxNoise);
\r
380 // to be replaced by the official calculation
\r
383 Int_t index = (5-layer)*5 + stack + 1;
\r
384 //printf("%d %d %d %d\n", i, stack, layer, index);
\r
386 gPad->SetBottomMargin(0.02);
\r
387 gPad->SetTopMargin(0.02);
\r
393 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r