New class for the analysis of black events
[u/mrichter/AliRoot.git] / TRD / AliTRDqaBlackEvents.cxx
CommitLineData
0f772b9f 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\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
15\r
16/* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */\r
17\r
18////////////////////////////////////////////////////////////////////////////\r
19// //\r
20// QA of black events //\r
21// //\r
22// Author: //\r
23// Sylwester Radomski (radomski@physi.uni-heidelberg.de) //\r
24// //\r
25////////////////////////////////////////////////////////////////////////////\r
26\r
27#include "TH1D.h"\r
28#include "TH2D.h"\r
29#include "TH3D.h"\r
30#include "TF1.h"\r
31#include "TFile.h"\r
32#include "TCanvas.h"\r
33#include "TPad.h"\r
34#include "TLatex.h"\r
35#include "TStyle.h"\r
36\r
37#include "AliTRDgeometry.h"\r
38#include "AliTRDrawStreamTB.h"\r
39#include "AliTRDqaBlackEvents.h"\r
40\r
41ClassImp(AliTRDqaBlackEvents)\r
42\r
43\r
44///////////////////////////////////////////////////////////////////////////////////////////////////\r
45\r
46AliTRDqaBlackEvents::AliTRDqaBlackEvents() \r
47 :TObject() \r
48 ,fMinNoise(0.5)\r
49 ,fMaxNoise(2) \r
50{\r
51 //\r
52 // Constructor \r
53 // to create the histograms call Init()\r
54 //\r
55}\r
56\r
57///////////////////////////////////////////////////////////////////////////////////////////////////\r
58\r
59AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa) \r
60 :TObject(qa) \r
61 ,fMinNoise(0.5)\r
62 ,fMaxNoise(2) \r
63{\r
64 //\r
65 // Copy constructor \r
66 // to create the histograms call Init()\r
67 //\r
68}\r
69\r
70///////////////////////////////////////////////////////////////////////////////////////////////////\r
71\r
72void AliTRDqaBlackEvents::Init() \r
73{\r
74 //\r
75 // creates histograms \r
76 // \r
77\r
78 //TFile *file = new \r
79 //Info("Init", "Statring");\r
80\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
88 }\r
89\r
90 //Info("Init", "Done");\r
91}\r
92\r
93\r
94///////////////////////////////////////////////////////////////////////////////////////////////////\r
95\r
96void AliTRDqaBlackEvents::Reset() \r
97{\r
98 //\r
99 // Resets the histograms\r
100 //\r
101\r
102 for(Int_t i=0; i<540; i++) {\r
103 fData[i]->Reset();\r
104 fChPed[i]->Reset();\r
105 fChNoise[i]->Reset();\r
106 }\r
107}\r
108\r
109///////////////////////////////////////////////////////////////////////////////////////////////////\r
110\r
111Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) \r
112{\r
113 //\r
114 // Add an event\r
115 //\r
116\r
117 Int_t nb = 0;\r
118 while (data->Next()) {\r
119\r
120 Int_t det = data->GetDet();\r
121 Int_t *sig = data->GetSignals();\r
122 nb++;\r
123\r
124 if (det<0 || det>=540) continue;\r
125 \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
130 }\r
131 }\r
132\r
133 return nb;\r
134}\r
135\r
136///////////////////////////////////////////////////////////////////////////////////////////////////\r
137\r
138void AliTRDqaBlackEvents::Process(const char *filename) \r
139{\r
140 //\r
141 // Process something\r
142 //\r
143\r
144 Int_t map[540];\r
145 \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
149 \r
150 for(Int_t i=0; i<540; i++) {\r
151 \r
152 map[i] = 0;\r
153 if (fData[i]->GetSum() < 100) continue;\r
154 map[i] = 1;\r
155\r
156 Info("process", "processing chamber %d", i);\r
157\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
160 \r
161 // project the histogramm\r
162 hist->Reset();\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
167 }\r
168\r
169 //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);\r
170 \r
171 Int_t bin = fChPed[i]->FindBin(j, k);\r
172\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
178\r
179 fChPed[i]->SetBinContent(bin, ped);\r
180 fChNoise[i]->SetBinContent(bin, noise);\r
181 \r
182 fPed[i]->Fill(ped);\r
183 fNoise[i]->Fill(noise);\r
184\r
185 } else {\r
186 fChPed[i]->SetBinContent(bin, 10);\r
187 fChNoise[i]->SetBinContent(bin, 1);\r
188 }\r
189 \r
190 //delete hist;\r
191 }\r
192 }\r
193 }\r
194\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
200 fPed[i]->Write();\r
201 fNoise[i]->Write();\r
202 fSignal[i]->Write();\r
203 }\r
204 file->Close();\r
205 delete file;\r
206}\r
207\r
208///////////////////////////////////////////////////////////////////////////////////////////////////\r
209\r
210void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h) \r
211{\r
212 //\r
213 // Draw raport for one chamber: \r
214 // pedestal map, noise map, distribution of pedestal and noise\r
215 // \r
216 // input:\r
217 // name of the file with histograms (created with Process())\r
218 // detector Id (0 - 539)\r
219 // \r
220\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
226\r
227 TFile *file = new TFile(filename, "READ");\r
228\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
232 c->cd(3);\r
233 \r
234 TPad *mPad = (TPad*) gPad;\r
235 mPad->Divide(1,2,0.01,0.01);\r
236 \r
237 c->cd(1);\r
238 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));\r
239 h2->SetMinimum(5);\r
240 h2->SetMaximum(15);\r
241 h2->SetTitle(";Z direction;#phi direction");\r
242 h2->Draw("colz");\r
243 \r
244 c->cd(2);\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
249 h2->Draw("colz");\r
250 \r
251 mPad->cd(1);\r
252 //gPad->SetLogy();\r
253 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));\r
254 h1->Draw();\r
255 \r
256 mPad->cd(2);\r
257 gPad->SetLogy();\r
258 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));\r
259 h1->Draw(); \r
260 \r
261 h1->Fit("gaus");\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
266 ll->Draw();\r
267}\r
268\r
269///////////////////////////////////////////////////////////////////////////////////////////////////\r
270\r
271void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h) \r
272{\r
273 //\r
274 // ????????????\r
275 //\r
276 \r
277 gStyle->SetPalette(1);\r
278 gStyle->SetOptStat(0);\r
279 \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
284\r
285 TFile *file = new TFile(filename, "READ");\r
286\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
290 \r
291 for(Int_t i=0; i<30; i++) {\r
292 \r
293 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));\r
294 if (!h2) continue;\r
295 h2->SetMinimum(fMinNoise);\r
296 h2->SetMaximum(fMaxNoise);\r
297\r
298 // to be replaced by the official calculation\r
299 Int_t stack = i/6;\r
300 Int_t layer = i%6;\r
301 Int_t index = (5-layer)*5 + stack + 1;\r
302 //printf("%d %d %d %d\n", i, stack, layer, index);\r
303 c->cd(index);\r
304 gPad->SetBottomMargin(0.02);\r
305 gPad->SetTopMargin(0.02);\r
306\r
307 h2->Draw("col");\r
308 }\r
309}\r
310\r
311///////////////////////////////////////////////////////////////////////////////////////////////////\r