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
33 #include "TCanvas.h"
\r
38 #include "AliTRDgeometry.h"
\r
39 #include "AliTRDrawStreamTB.h"
\r
40 #include "AliTRDqaBlackEvents.h"
\r
42 ClassImp(AliTRDqaBlackEvents)
\r
44 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
46 AliTRDqaBlackEvents::AliTRDqaBlackEvents()
\r
61 // to create the histograms call Init()
\r
65 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
67 AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
\r
81 // Copy constructor
\r
82 // to create the histograms call Init()
\r
86 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
88 void AliTRDqaBlackEvents::Init()
\r
91 // creates histograms
\r
94 //TFile *file = new
\r
95 //Info("Init", "Statring");
\r
99 // histograms for chambers
\r
100 for(Int_t i=0; i<kDET; i++) {
\r
101 fNPoint[i] = new TH2D(Form("entries_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
102 fData[i] = new TH3F(Form("data_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);
\r
103 fChPed[i] = new TH2D(Form("ped_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
104 fChNoise[i] = new TH2D(Form("noise_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
105 fPed[i] = new TH1D(Form("pedDist_%d", i), ";pedestals (ADC counts)", 100, 5, 15);
\r
107 fNoise[i] = new TH1D(Form("noiseDist_%d", i), ";noise (ADC counts)", 100, 0, 5);
\r
108 fSignal[i] = new TH1D(Form("signal_%d", i), ";signal (ADC counts)", 100, -0.5, 99.5);
\r
110 fnEntriesRM[i] = new TH2D(Form("entriesRM_%d", i), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);
\r
113 // histogram for each MCM
\r
114 for(Int_t i=0; i < kDET * kROB * kMCM; i++)
\r
115 fFullCounter[i] = 0;
\r
117 // histograms from the whole detector
\r
118 fOccupancy = new TH1D("occupancy", "", 20, -0.5, 19.5);
\r
119 fDetRob = new TH2D("DetRob", ";detector;ROB", kDET, -0.5, 539.5, 8, -0.5, 7.5);
\r
120 fTBEvent = new TH2D("tbEvent", ";event ID;time bin", 100, -0.5, 99.5, 30, -0.5, 29.5);
\r
122 //Info("Init", "Done");
\r
126 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
128 void AliTRDqaBlackEvents::Reset()
\r
131 // Resets the histograms
\r
134 for(Int_t i=0; i<kDET; i++) {
\r
136 fChPed[i]->Reset();
\r
137 fChNoise[i]->Reset();
\r
141 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
143 Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
\r
149 // structure to keep track if particular chanel is used
\r
150 Char_t isUsed[kDET][kCOL][kPAD];
\r
151 for(Int_t i=0; i<kDET; i++)
\r
152 for(Int_t j=0; j<kCOL; j++)
\r
153 for(Int_t k=0; k<kPAD; k++)
\r
154 isUsed[i][j][k] = 0;
\r
157 Int_t rob_last = -1;
\r
158 Int_t mcm_last = -1;
\r
161 while (data->Next()) {
\r
163 Int_t det = data->GetDet();
\r
165 Int_t row = data->GetRow();
\r
166 Int_t col = data->GetCol();
\r
168 Int_t rob = data->GetROB();
\r
169 Int_t mcm = data->GetMCM();
\r
170 Int_t adc = data->GetADC();
\r
172 Int_t *sig = data->GetSignals();
\r
176 if (det == 0 && row == 0 && col == 0) {
\r
177 if (sm_01 > -1) printf("\t\t\t!!! !!! second data set !!! !!!\n");
\r
181 det += sm_01 * 30; /// ugly
\r
183 // memory coruption protection
\r
184 if (det<0 || det>=kDET) continue;
\r
187 fDetRob->Fill(det, rob, 1./(kMCM*18));
\r
189 isUsed[det][row][col]++;
\r
191 // check if mcm signal is continuus
\r
192 if ((rob_last != rob) || (mcm_last != mcm)) {
\r
195 fnEntriesRM[det]->Fill(rob,mcm);
\r
198 // number of entries for each channels
\r
199 fNPoint[det]->Fill(row, col);
\r
202 // create a structure for an MCM if needed
\r
203 Int_t mcmIndex = det * (kMCM * kROB) + rob * kMCM + mcm;
\r
204 if (fCreateFull && !fFullSignal[mcmIndex])
\r
205 fFullSignal[mcmIndex] = new TH2S(Form("mcm_%d_%d_%d", det, rob, mcm),
\r
206 Form("mcm-%d-%d-%d;ADC;time bin", det, rob,mcm),
\r
207 21, -0.5, 20.5, 30, -0.5, 29.5);
\r
210 // loop over Time Bins and fill histograms
\r
211 for(Int_t k=0; k<kTB; k++) { /// to be corrected
\r
214 //printf("det = %d rob = %d mcm = %d adc = %d k = %d S = %d\n", det, rob, mcm, adc, k, sig[k]);
\r
216 fSignal[det]->Fill(sig[k]);
\r
217 fData[det]->Fill(row, col, sig[k]);
\r
219 // check if data strange enought
\r
220 if (fCreateFull && fFullSignal[mcmIndex]) {
\r
221 if (sig[k] > fThresh || sig[k] < 1) fFullCounter[mcmIndex]++;
\r
222 fFullSignal[mcmIndex]->Fill(adc, k, sig[k]);
\r
227 fTBEvent->Fill(fnEvents, k, sig[k]);
\r
233 // is the dead-alive status changing during the run
\r
234 for(Int_t i=0; i<kDET; i++) {
\r
235 for(Int_t j=0; j<kCOL; j++)
\r
236 for(Int_t k=0; k<kPAD; k++)
\r
237 fOccupancy->Fill(isUsed[i][j][k]);
\r
244 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
246 void AliTRDqaBlackEvents::Process(const char *filename)
\r
249 // Process something
\r
254 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);
\r
255 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);
\r
256 fit->SetParameters(1e3, 10, 1);
\r
258 for(Int_t i=0; i<kDET; i++) {
\r
261 if (fData[i]->GetSum() < 10) continue;
\r
264 Info("process", "processing chamber %d", i);
\r
266 for(Int_t j=0; j<fData[i]->GetXaxis()->GetNbins(); j++) {
\r
267 for(Int_t k=0; k<fData[i]->GetYaxis()->GetNbins(); k++) {
\r
269 // project the histogramm
\r
271 for(Int_t bb=0; bb<50; bb++) {
\r
272 Int_t dataBin = fData[i]->FindBin(j, k, bb);
\r
273 Double_t v = fData[i]->GetBinContent(dataBin);
\r
274 hist->SetBinContent(bb+1, v);
\r
277 //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);
\r
279 Int_t bin = fChPed[i]->FindBin(j, k);
\r
281 if (hist->GetSum() > 1) {
\r
283 Double_t ped = 0, noise = 0;
\r
285 if (fFitType == 0) {
\r
286 fit->SetParameters(1e3, 10, 1);
\r
287 hist->Fit(fit, "q0", "goff", 0, 20);
\r
288 TF1 *f = hist->GetFunction("fit");
\r
289 ped = TMath::Abs(f->GetParameter(1));
\r
290 noise = TMath::Abs(f->GetParameter(2));
\r
292 ped = hist->GetMean();
\r
293 noise = hist->GetRMS();
\r
296 fChPed[i]->SetBinContent(bin, ped);
\r
297 fChNoise[i]->SetBinContent(bin, noise);
\r
299 fPed[i]->Fill(ped);
\r
300 fNoise[i]->Fill(noise);
\r
303 fChPed[i]->SetBinContent(bin, 0);
\r
304 fChNoise[i]->SetBinContent(bin, 0);
\r
312 Info("Process", "Number of events = %d", fnEvents);
\r
314 // normalize number of entries histos
\r
316 for(Int_t i=0; i<kDET; i++) {
\r
317 if (!map[i]) continue;
\r
318 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
\r
319 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
\r
320 Int_t dataBin = fNPoint[i]->FindBin(j, k);
\r
321 Double_t v = fNPoint[i]->GetBinContent(dataBin);
\r
322 if (v > max) max = (Int_t)v;
\r
327 char entriesDistName[100];
\r
329 for(Int_t i=0; i<kDET; i++) {
\r
331 if (!map[i]) continue;
\r
333 sprintf(entriesDistName, "entriesDist_%d", i);
\r
334 fNPointDist[i] = new TH1D(entriesDistName, ";number of events", max+2, -0.5, max+1.5);
\r
336 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {
\r
337 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {
\r
338 Int_t dataBin = fNPoint[i]->FindBin(j, k);
\r
339 Double_t v = fNPoint[i]->GetBinContent(dataBin);
\r
340 //if (v > fnEvents) printf("N = %d V = %lf\n", fnEvents, v);
\r
341 fNPointDist[i]->Fill(v);
\r
345 fNPoint[i]->Scale(1./fnEvents);
\r
349 for(Int_t i=0; i<kDET; i++) {
\r
350 fnEntriesRM[i]->SetMaximum(fnEvents * 1.5);
\r
355 TFile *file = new TFile(filename, "recreate");
\r
356 for(Int_t i=0; i<kDET; i++) {
\r
357 if (!map[i]) continue;
\r
358 fChPed[i]->Write();
\r
359 fChNoise[i]->Write();
\r
360 fNPoint[i]->Write();
\r
361 fNPointDist[i]->Write();
\r
363 fNoise[i]->Write();
\r
364 fSignal[i]->Write();
\r
365 fnEntriesRM[i]->Write();
\r
369 for(Int_t i=0; i < kDET * kROB * kMCM; i++) {
\r
370 if (fFullSignal[i] && fFullCounter[i] > fCount) {
\r
371 fFullSignal[i]->Write();
\r
376 printf("Number of saved MCMs = %d\n", nMcm);
\r
378 fOccupancy->Write();
\r
385 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
387 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h)
\r
390 // Draw raport for one chamber:
\r
391 // pedestal map, noise map, distribution of pedestal and noise
\r
394 // name of the file with histograms (created with Process())
\r
395 // detector Id (0 - 539)
\r
398 // setup global style
\r
399 gStyle->SetPalette(1);
\r
400 gStyle->SetOptStat(0);
\r
401 gStyle->SetPadTopMargin(0.02);
\r
402 gStyle->SetPadBottomMargin(0.05);
\r
404 TFile *file = new TFile(filename, "READ");
\r
406 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);
\r
407 c->SetVertical(kFALSE);
\r
408 c->Divide(3,1, 0.01, 0.01);
\r
411 TPad *mPad = (TPad*) gPad;
\r
412 mPad->Divide(1,2,0.01,0.01);
\r
415 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));
\r
417 h2->SetMaximum(15);
\r
418 h2->SetTitle(";Z direction;#phi direction");
\r
422 h2 = (TH2D*)file->Get(Form("noise_%d",det));
\r
423 h2->SetMinimum(fMinNoise);
\r
424 h2->SetMaximum(fMaxNoise);
\r
425 h2->SetTitle(";Z direction;#phi direction");
\r
430 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));
\r
435 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));
\r
439 TF1 *f = h1->GetFunction("gaus");
\r
440 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));
\r
441 TLatex *ll = new TLatex(2, 100, tt);
\r
442 ll->SetTextSize(0.06);
\r
446 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
448 void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h)
\r
454 gStyle->SetPalette(1);
\r
455 gStyle->SetOptStat(0);
\r
457 gStyle->SetPadTopMargin(0.02);
\r
458 //gStyle->SetPadBottomMargin(0.05);
\r
459 //gStyle->SetPadLeftMargin(0.02);
\r
460 //gStyle->SetPadRightMargin(0.02);
\r
462 TFile *file = new TFile(filename, "READ");
\r
464 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);
\r
465 c->SetVertical(kFALSE);
\r
466 c->Divide(5, 6, 0.001, 0.01);
\r
468 for(Int_t i=0; i<30; i++) {
\r
470 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));
\r
472 h2->SetMinimum(fMinNoise);
\r
473 h2->SetMaximum(fMaxNoise);
\r
475 // to be replaced by the official calculation
\r
478 Int_t index = (5-layer)*5 + stack + 1;
\r
479 //printf("%d %d %d %d\n", i, stack, layer, index);
\r
481 gPad->SetBottomMargin(0.02);
\r
482 gPad->SetTopMargin(0.02);
\r
488 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r