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 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
56 // to create the histograms call Init()
\r
60 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
62 AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
\r
71 // Copy constructor
\r
72 // to create the histograms call Init()
\r
76 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
78 void AliTRDqaBlackEvents::Init()
\r
81 // creates histograms
\r
84 //TFile *file = new
\r
85 //Info("Init", "Statring");
\r
89 for(Int_t i=0; i<540; i++) {
\r
90 fNPoint[i] = new TH2D(Form("entries_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
91 fData[i] = new TH3D(Form("data_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);
\r
92 fChPed[i] = new TH2D(Form("ped_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
93 fChNoise[i] = new TH2D(Form("noise_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
94 fPed[i] = new TH1D(Form("pedDist_%d", i), ";pedestals (ADC counts)", 100, 5, 15);
\r
96 fNoise[i] = new TH1D(Form("noiseDist_%d", i), ";noise (ADC counts)", 100, 0, 5);
\r
97 fSignal[i] = new TH1D(Form("signal_%d", i), ";signal (ADC counts)", 100, -0.5, 99.5);
\r
99 fnEntriesRM[i] = new TH2D(Form("entriesRM_%d", i), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);
\r
102 fOccupancy = new TH1D("occupancy", "", 20, -0.5, 19.5);
\r
104 //Info("Init", "Done");
\r
108 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
110 void AliTRDqaBlackEvents::Reset()
\r
113 // Resets the histograms
\r
116 for(Int_t i=0; i<540; i++) {
\r
118 fChPed[i]->Reset();
\r
119 fChNoise[i]->Reset();
\r
123 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
125 Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
\r
132 Char_t isUsed[540][16][144];
\r
133 for(Int_t i=0; i<540; i++)
\r
134 for(Int_t j=0; j<16; j++)
\r
135 for(Int_t k=0; k<144; k++)
\r
136 isUsed[i][j][k] = 0;
\r
139 Int_t rob_last = -1;
\r
140 Int_t mcm_last = -1;
\r
142 while (data->Next()) {
\r
144 Int_t det = data->GetDet();
\r
146 Int_t row = data->GetRow();
\r
147 Int_t col = data->GetCol();
\r
149 Int_t rob = data->GetROB();
\r
150 Int_t mcm = data->GetMCM();
\r
152 Int_t *sig = data->GetSignals();
\r
155 //printf("det = %d\n", det);
\r
157 if (det<0 || det>=540) continue;
\r
159 isUsed[det][row][col]++;
\r
161 if ((rob_last != rob) || (mcm_last != mcm)) {
\r
164 fnEntriesRM[det]->Fill(rob,mcm);
\r
167 // if (!isUsed[det][data->GetRow()][data->GetCol()]) {
\r
168 // isUsed[det][data->GetRow()][data->GetCol()] = 1;
\r
172 fNPoint[det]->Fill(row, col);
\r
174 for(Int_t k=0; k<30; k++) { /// to be corrected
\r
175 fSignal[det]->Fill(sig[k]);
\r
176 fData[det]->Fill(row, col, sig[k]);
\r
180 for(Int_t i=0; i<540; i++) {
\r
181 if (i != 0 && i != 8) continue;
\r
182 for(Int_t j=0; j<16; j++)
\r
183 for(Int_t k=0; k<144; k++)
\r
184 fOccupancy->Fill(isUsed[i][j][k]);
\r
192 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
194 void AliTRDqaBlackEvents::Process(const char *filename)
\r
197 // Process something
\r
202 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);
\r
203 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);
\r
204 fit->SetParameters(1e3, 10, 1);
\r
206 for(Int_t i=0; i<540; i++) {
\r
209 if (fData[i]->GetSum() < 10) continue;
\r
212 Info("process", "processing chamber %d", i);
\r
214 for(Int_t j=0; j<fData[i]->GetXaxis()->GetNbins(); j++) {
\r
215 for(Int_t k=0; k<fData[i]->GetYaxis()->GetNbins(); k++) {
\r
217 // project the histogramm
\r
219 for(Int_t bb=0; bb<50; bb++) {
\r
220 Int_t dataBin = fData[i]->FindBin(j, k, bb);
\r
221 Double_t v = fData[i]->GetBinContent(dataBin);
\r
222 hist->SetBinContent(bb+1, v);
\r
225 //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);
\r
227 Int_t bin = fChPed[i]->FindBin(j, k);
\r
229 if (hist->GetSum() > 1) {
\r
231 Double_t ped = 0, noise = 0;
\r
233 if (fFitType == 0) {
\r
234 fit->SetParameters(1e3, 10, 1);
\r
235 hist->Fit(fit, "q0", "goff", 0, 20);
\r
236 TF1 *f = hist->GetFunction("fit");
\r
237 ped = TMath::Abs(f->GetParameter(1));
\r
238 noise = TMath::Abs(f->GetParameter(2));
\r
240 ped = hist->GetMean();
\r
241 noise = hist->GetRMS();
\r
244 fChPed[i]->SetBinContent(bin, ped);
\r
245 fChNoise[i]->SetBinContent(bin, noise);
\r
247 fPed[i]->Fill(ped);
\r
248 fNoise[i]->Fill(noise);
\r
251 fChPed[i]->SetBinContent(bin, 0);
\r
252 fChNoise[i]->SetBinContent(bin, 0);
\r
260 Info("Process", "Number of events = %d", fnEvents);
\r
262 // normalize number of entries histos
\r
264 for(Int_t i=0; i<540; i++) {
\r
265 if (!map[i]) continue;
\r
266 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
\r
267 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
\r
268 Int_t dataBin = fNPoint[i]->FindBin(j, k);
\r
269 Double_t v = fNPoint[i]->GetBinContent(dataBin);
\r
270 if (v > max) max = (Int_t)v;
\r
275 for(Int_t i=0; i<540; i++) {
\r
277 if (!map[i]) continue;
\r
279 fNPointDist[i] = new TH1D(Form("entriesDist_%d", i), ";number of events", max+2, -0.5, max+1.5);
\r
281 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
\r
282 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
\r
283 Int_t dataBin = fNPoint[i]->FindBin(j, k);
\r
284 Double_t v = fNPoint[i]->GetBinContent(dataBin);
\r
285 //if (v > fnEvents) printf("N = %d V = %lf\n", fnEvents, v);
\r
286 fNPointDist[i]->Fill(v);
\r
290 fNPoint[i]->Scale(1./fnEvents);
\r
294 for(Int_t i=0; i<540; i++) {
\r
295 fnEntriesRM[i]->SetMaximum(fnEvents * 1.5);
\r
298 TFile *file = new TFile(filename, "UPDATE");
\r
299 for(Int_t i=0; i<540; i++) {
\r
300 if (!map[i]) continue;
\r
301 fChPed[i]->Write();
\r
302 fChNoise[i]->Write();
\r
303 fNPoint[i]->Write();
\r
304 fNPointDist[i]->Write();
\r
306 fNoise[i]->Write();
\r
307 fSignal[i]->Write();
\r
308 fnEntriesRM[i]->Write();
\r
310 fOccupancy->Write();
\r
315 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
317 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h)
\r
320 // Draw raport for one chamber:
\r
321 // pedestal map, noise map, distribution of pedestal and noise
\r
324 // name of the file with histograms (created with Process())
\r
325 // detector Id (0 - 539)
\r
328 // setup global style
\r
329 gStyle->SetPalette(1);
\r
330 gStyle->SetOptStat(0);
\r
331 gStyle->SetPadTopMargin(0.02);
\r
332 gStyle->SetPadBottomMargin(0.05);
\r
334 TFile *file = new TFile(filename, "READ");
\r
336 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);
\r
337 c->SetVertical(kFALSE);
\r
338 c->Divide(3,1, 0.01, 0.01);
\r
341 TPad *mPad = (TPad*) gPad;
\r
342 mPad->Divide(1,2,0.01,0.01);
\r
345 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));
\r
347 h2->SetMaximum(15);
\r
348 h2->SetTitle(";Z direction;#phi direction");
\r
352 h2 = (TH2D*)file->Get(Form("noise_%d",det));
\r
353 h2->SetMinimum(fMinNoise);
\r
354 h2->SetMaximum(fMaxNoise);
\r
355 h2->SetTitle(";Z direction;#phi direction");
\r
360 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));
\r
365 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));
\r
369 TF1 *f = h1->GetFunction("gaus");
\r
370 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));
\r
371 TLatex *ll = new TLatex(2, 100, tt);
\r
372 ll->SetTextSize(0.06);
\r
376 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
378 void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h)
\r
384 gStyle->SetPalette(1);
\r
385 gStyle->SetOptStat(0);
\r
387 gStyle->SetPadTopMargin(0.02);
\r
388 //gStyle->SetPadBottomMargin(0.05);
\r
389 //gStyle->SetPadLeftMargin(0.02);
\r
390 //gStyle->SetPadRightMargin(0.02);
\r
392 TFile *file = new TFile(filename, "READ");
\r
394 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);
\r
395 c->SetVertical(kFALSE);
\r
396 c->Divide(5, 6, 0.001, 0.01);
\r
398 for(Int_t i=0; i<30; i++) {
\r
400 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));
\r
402 h2->SetMinimum(fMinNoise);
\r
403 h2->SetMaximum(fMaxNoise);
\r
405 // to be replaced by the official calculation
\r
408 Int_t index = (5-layer)*5 + stack + 1;
\r
409 //printf("%d %d %d %d\n", i, stack, layer, index);
\r
411 gPad->SetBottomMargin(0.02);
\r
412 gPad->SetTopMargin(0.02);
\r
418 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r