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 * without 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
53 // to create the histograms call Init()
\r
57 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
59 AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa)
\r
65 // Copy constructor
\r
66 // to create the histograms call Init()
\r
70 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
72 void AliTRDqaBlackEvents::Init()
\r
75 // creates histograms
\r
78 //TFile *file = new
\r
79 //Info("Init", "Statring");
\r
81 for(Int_t i=0; i<540; i++) {
\r
82 fData[i] = new TH3D(Form("data_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);
\r
83 fChPed[i] = new TH2D(Form("ped_%d", i), "", 16, -0.5, 15.5, 150, -0.5, 149.5);
\r
84 fChNoise[i] = new TH2D(Form("noise_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);
\r
85 fPed[i] = new TH1D(Form("pedDist_%d", i), ";pedestals", 100, 0, 20);
\r
86 fNoise[i] = new TH1D(Form("noiseDist_%d", i), ";noise", 100, 0, 5);
\r
87 fSignal[i] = new TH1D(Form("signal_%d", i), "", 100, -0.5, 99.5);
\r
90 //Info("Init", "Done");
\r
94 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
96 void AliTRDqaBlackEvents::Reset()
\r
99 // Resets the histograms
\r
102 for(Int_t i=0; i<540; i++) {
\r
104 fChPed[i]->Reset();
\r
105 fChNoise[i]->Reset();
\r
109 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
111 Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data)
\r
118 while (data->Next()) {
\r
120 Int_t det = data->GetDet();
\r
121 Int_t *sig = data->GetSignals();
\r
124 if (det<0 || det>=540) continue;
\r
126 for(Int_t k=0; k<30; k++) {
\r
127 fSignal[det]->Fill(sig[k]);
\r
128 //if(sig[k]>13) printf("timebin: %d signal: %d\n",k,sig[k]);
\r
129 fData[det]->Fill(data->GetRow(), data->GetCol(), sig[k]);
\r
136 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
138 void AliTRDqaBlackEvents::Process(const char *filename)
\r
141 // Process something
\r
146 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);
\r
147 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);
\r
148 fit->SetParameters(1e3, 10, 1);
\r
150 for(Int_t i=0; i<540; i++) {
\r
153 if (fData[i]->GetSum() < 100) continue;
\r
156 Info("process", "processing chamber %d", i);
\r
158 for(Int_t j=0; j<fData[i]->GetXaxis()->GetNbins(); j++) {
\r
159 for(Int_t k=0; k<fData[i]->GetYaxis()->GetNbins(); k++) {
\r
161 // project the histogramm
\r
163 for(Int_t bb=0; bb<50; bb++) {
\r
164 Int_t dataBin = fData[i]->FindBin(j, k, bb);
\r
165 Double_t v = fData[i]->GetBinContent(dataBin);
\r
166 hist->SetBinContent(bb+1, v);
\r
169 //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);
\r
171 Int_t bin = fChPed[i]->FindBin(j, k);
\r
173 if (hist->GetSum() > 10) {
\r
174 hist->Fit(fit, "q0", "goff", 0, 20);
\r
175 TF1 *f = hist->GetFunction("fit");
\r
176 Double_t ped = TMath::Abs(f->GetParameter(1));
\r
177 Double_t noise = TMath::Abs(f->GetParameter(2));
\r
179 fChPed[i]->SetBinContent(bin, ped);
\r
180 fChNoise[i]->SetBinContent(bin, noise);
\r
182 fPed[i]->Fill(ped);
\r
183 fNoise[i]->Fill(noise);
\r
186 fChPed[i]->SetBinContent(bin, 10);
\r
187 fChNoise[i]->SetBinContent(bin, 1);
\r
195 TFile *file = new TFile(filename, "UPDATE");
\r
196 for(Int_t i=0; i<540; i++) {
\r
197 if (!map[i]) continue;
\r
198 fChPed[i]->Write();
\r
199 fChNoise[i]->Write();
\r
201 fNoise[i]->Write();
\r
202 fSignal[i]->Write();
\r
208 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
210 void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h)
\r
213 // Draw raport for one chamber:
\r
214 // pedestal map, noise map, distribution of pedestal and noise
\r
217 // name of the file with histograms (created with Process())
\r
218 // detector Id (0 - 539)
\r
221 // setup global style
\r
222 gStyle->SetPalette(1);
\r
223 gStyle->SetOptStat(0);
\r
224 gStyle->SetPadTopMargin(0.02);
\r
225 gStyle->SetPadBottomMargin(0.05);
\r
227 TFile *file = new TFile(filename, "READ");
\r
229 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);
\r
230 c->SetVertical(kFALSE);
\r
231 c->Divide(3,1, 0.01, 0.01);
\r
234 TPad *mPad = (TPad*) gPad;
\r
235 mPad->Divide(1,2,0.01,0.01);
\r
238 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));
\r
240 h2->SetMaximum(15);
\r
241 h2->SetTitle(";Z direction;#phi direction");
\r
245 h2 = (TH2D*)file->Get(Form("noise_%d",det));
\r
246 h2->SetMinimum(fMinNoise);
\r
247 h2->SetMaximum(fMaxNoise);
\r
248 h2->SetTitle(";Z direction;#phi direction");
\r
253 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));
\r
258 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));
\r
262 TF1 *f = h1->GetFunction("gaus");
\r
263 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));
\r
264 TLatex *ll = new TLatex(2, 100, tt);
\r
265 ll->SetTextSize(0.06);
\r
269 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r
271 void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h)
\r
277 gStyle->SetPalette(1);
\r
278 gStyle->SetOptStat(0);
\r
280 gStyle->SetPadTopMargin(0.02);
\r
281 //gStyle->SetPadBottomMargin(0.05);
\r
282 //gStyle->SetPadLeftMargin(0.02);
\r
283 //gStyle->SetPadRightMargin(0.02);
\r
285 TFile *file = new TFile(filename, "READ");
\r
287 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);
\r
288 c->SetVertical(kFALSE);
\r
289 c->Divide(5, 6, 0.001, 0.01);
\r
291 for(Int_t i=0; i<30; i++) {
\r
293 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));
\r
295 h2->SetMinimum(fMinNoise);
\r
296 h2->SetMaximum(fMaxNoise);
\r
298 // to be replaced by the official calculation
\r
301 Int_t index = (5-layer)*5 + stack + 1;
\r
302 //printf("%d %d %d %d\n", i, stack, layer, index);
\r
304 gPad->SetBottomMargin(0.02);
\r
305 gPad->SetTopMargin(0.02);
\r
311 ///////////////////////////////////////////////////////////////////////////////////////////////////
\r