]>
Commit | Line | Data |
---|---|---|
07627591 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // TPC calibration class for parameters which saved per pad // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliTPCCalPad.h" | |
25 | #include "AliTPCCalROC.h" | |
184bcc16 | 26 | #include <TObjArray.h> |
27 | #include <TAxis.h> | |
28 | #include <TGraph.h> | |
200be8a6 | 29 | #include <TGraph2D.h> |
30 | #include <TH2F.h> | |
07627591 | 31 | ClassImp(AliTPCCalPad) |
32 | ||
33 | //_____________________________________________________________________________ | |
34 | AliTPCCalPad::AliTPCCalPad():TNamed() | |
35 | { | |
36 | // | |
37 | // AliTPCCalPad default constructor | |
38 | // | |
39 | ||
40 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
41 | fROC[isec] = 0; | |
42 | } | |
43 | ||
44 | } | |
45 | ||
46 | //_____________________________________________________________________________ | |
47 | AliTPCCalPad::AliTPCCalPad(const Text_t *name, const Text_t *title) | |
48 | :TNamed(name,title) | |
49 | { | |
50 | // | |
51 | // AliTPCCalPad constructor | |
52 | // | |
53 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
54 | fROC[isec] = new AliTPCCalROC(isec); | |
55 | } | |
56 | } | |
57 | ||
58 | ||
59 | //_____________________________________________________________________________ | |
60 | AliTPCCalPad::AliTPCCalPad(const AliTPCCalPad &c):TNamed(c) | |
61 | { | |
62 | // | |
63 | // AliTPCCalPad copy constructor | |
64 | // | |
65 | ||
66 | ((AliTPCCalPad &) c).Copy(*this); | |
67 | ||
68 | } | |
69 | ||
184bcc16 | 70 | //_____________________________________________________________________________ |
71 | AliTPCCalPad::AliTPCCalPad(TObjArray * array):TNamed() | |
72 | { | |
73 | // | |
74 | // AliTPCCalPad default constructor | |
75 | // | |
76 | ||
77 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
78 | fROC[isec] = (AliTPCCalROC *)array->At(isec); | |
79 | } | |
80 | ||
81 | } | |
82 | ||
83 | ||
07627591 | 84 | ///_____________________________________________________________________________ |
85 | AliTPCCalPad::~AliTPCCalPad() | |
86 | { | |
87 | // | |
88 | // AliTPCCalPad destructor | |
89 | // | |
90 | ||
91 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
92 | if (fROC[isec]) { | |
93 | delete fROC[isec]; | |
94 | fROC[isec] = 0; | |
95 | } | |
96 | } | |
97 | ||
98 | } | |
99 | ||
100 | //_____________________________________________________________________________ | |
101 | AliTPCCalPad &AliTPCCalPad::operator=(const AliTPCCalPad &c) | |
102 | { | |
103 | // | |
104 | // Assignment operator | |
105 | // | |
106 | ||
107 | if (this != &c) ((AliTPCCalPad &) c).Copy(*this); | |
108 | return *this; | |
109 | ||
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | void AliTPCCalPad::Copy(TObject &c) const | |
114 | { | |
115 | // | |
116 | // Copy function | |
117 | // | |
118 | ||
119 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
120 | if (fROC[isec]) { | |
121 | fROC[isec]->Copy(*((AliTPCCalPad &) c).fROC[isec]); | |
122 | } | |
123 | } | |
124 | TObject::Copy(c); | |
125 | } | |
184bcc16 | 126 | |
90127643 | 127 | //_____________________________________________________________________________ |
128 | void AliTPCCalPad::Add(Float_t c1) | |
129 | { | |
130 | // | |
131 | // add constant for all channels of all ROCs | |
132 | // | |
133 | ||
134 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
135 | if (fROC[isec]){ | |
136 | fROC[isec]->Add(c1); | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
141 | //_____________________________________________________________________________ | |
142 | void AliTPCCalPad::Multiply(Float_t c1) | |
143 | { | |
144 | // | |
145 | // multiply constant for all channels of all ROCs | |
146 | // | |
147 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
148 | if (fROC[isec]){ | |
149 | fROC[isec]->Multiply(c1); | |
150 | } | |
151 | } | |
152 | } | |
153 | ||
154 | //_____________________________________________________________________________ | |
155 | void AliTPCCalPad::Add(const AliTPCCalPad * pad, Double_t c1) | |
156 | { | |
157 | // | |
158 | // add calpad channel by channel multiplied by c1 - all ROCs | |
159 | // | |
160 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
161 | if (fROC[isec]){ | |
162 | fROC[isec]->Add(pad->GetCalROC(isec),c1); | |
163 | } | |
164 | } | |
165 | } | |
166 | ||
167 | //_____________________________________________________________________________ | |
168 | void AliTPCCalPad::Multiply(const AliTPCCalPad * pad) | |
169 | { | |
170 | // | |
171 | // multiply calpad channel by channel - all ROCs | |
172 | // | |
173 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
174 | if (fROC[isec]){ | |
175 | fROC[isec]->Multiply(pad->GetCalROC(isec)); | |
176 | } | |
177 | } | |
178 | } | |
179 | ||
180 | //_____________________________________________________________________________ | |
181 | void AliTPCCalPad::Divide(const AliTPCCalPad * pad) | |
182 | { | |
183 | // | |
184 | // divide calpad channel by channel - all ROCs | |
185 | // | |
186 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
187 | if (fROC[isec]){ | |
188 | fROC[isec]->Divide(pad->GetCalROC(isec)); | |
189 | } | |
190 | } | |
191 | } | |
192 | ||
193 | //_____________________________________________________________________________ | |
184bcc16 | 194 | TGraph * AliTPCCalPad::MakeGraph(Int_t type, Float_t ratio){ |
195 | // | |
196 | // type=1 - mean | |
197 | // 2 - median | |
198 | // 3 - LTM | |
199 | Int_t npoints = 0; | |
200 | for (Int_t i=0;i<72;i++) if (fROC[i]) npoints++; | |
201 | TGraph * graph = new TGraph(npoints); | |
202 | npoints=0; | |
203 | for (Int_t isec=0;isec<72;isec++){ | |
204 | if (!fROC[isec]) continue; | |
205 | if (type==0) graph->SetPoint(npoints,isec,fROC[isec]->GetMean()); | |
206 | if (type==1) graph->SetPoint(npoints,isec,fROC[isec]->GetMedian()); | |
207 | if (type==2) graph->SetPoint(npoints,isec,fROC[isec]->GetLTM(0,ratio)); | |
208 | npoints++; | |
209 | } | |
210 | ||
211 | graph->GetXaxis()->SetTitle("Sector"); | |
212 | if (type==0) { | |
213 | graph->GetYaxis()->SetTitle("Mean"); | |
214 | graph->SetMarkerStyle(22); | |
215 | } | |
216 | if (type==1) { | |
217 | graph->GetYaxis()->SetTitle("Median"); | |
218 | graph->SetMarkerStyle(22); | |
219 | } | |
220 | if (type==2) { | |
221 | graph->GetYaxis()->SetTitle(Form("Mean%f",ratio)); | |
222 | graph->SetMarkerStyle(24); | |
223 | } | |
224 | ||
225 | return graph; | |
226 | } | |
200be8a6 | 227 | |
90127643 | 228 | //_____________________________________________________________________________ |
229 | Double_t AliTPCCalPad::GetMeanRMS(Double_t &rms) | |
230 | { | |
231 | // | |
232 | // Calculate mean an RMS of all rocs | |
233 | // | |
234 | Double_t sum = 0, sum2 = 0, n=0, val=0; | |
235 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
236 | AliTPCCalROC *calRoc = fROC[isec]; | |
237 | if ( calRoc ){ | |
238 | for (UInt_t irow=0; irow<calRoc->GetNrows(); irow++){ | |
239 | for (UInt_t ipad=0; ipad<calRoc->GetNPads(irow); ipad++){ | |
240 | val = calRoc->GetValue(irow,ipad); | |
241 | sum+=val; | |
242 | sum2+=val*val; | |
243 | n++; | |
244 | } | |
245 | } | |
246 | ||
247 | } | |
248 | } | |
249 | Double_t n1 = 1./n; | |
250 | Double_t mean = sum*n1; | |
251 | rms = TMath::Sqrt(TMath::Abs(sum2*n1-mean*mean)); | |
252 | return mean; | |
253 | } | |
254 | ||
255 | ||
256 | //_____________________________________________________________________________ | |
257 | Double_t AliTPCCalPad::GetMean() | |
258 | { | |
259 | // | |
260 | // return mean of the mean of all ROCs | |
261 | // | |
262 | Double_t arr[kNsec]; | |
263 | Int_t n=0; | |
264 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
265 | AliTPCCalROC *calRoc = fROC[isec]; | |
266 | if ( calRoc ){ | |
267 | arr[n] = calRoc->GetMean(); | |
268 | n++; | |
269 | } | |
270 | } | |
271 | return TMath::Mean(n,arr); | |
272 | } | |
273 | ||
274 | //_____________________________________________________________________________ | |
275 | Double_t AliTPCCalPad::GetRMS() | |
276 | { | |
277 | // | |
278 | // return mean of the RMS of all ROCs | |
279 | // | |
280 | Double_t arr[kNsec]; | |
281 | Int_t n=0; | |
282 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
283 | AliTPCCalROC *calRoc = fROC[isec]; | |
284 | if ( calRoc ){ | |
285 | arr[n] = calRoc->GetRMS(); | |
286 | n++; | |
287 | } | |
288 | } | |
289 | return TMath::Mean(n,arr); | |
290 | } | |
291 | ||
292 | //_____________________________________________________________________________ | |
293 | Double_t AliTPCCalPad::GetMedian() | |
294 | { | |
295 | // | |
296 | // return mean of the median of all ROCs | |
297 | // | |
298 | Double_t arr[kNsec]; | |
299 | Int_t n=0; | |
300 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
301 | AliTPCCalROC *calRoc = fROC[isec]; | |
302 | if ( calRoc ){ | |
303 | arr[n] = calRoc->GetMedian(); | |
304 | n++; | |
305 | } | |
306 | } | |
307 | return TMath::Mean(n,arr); | |
308 | } | |
309 | ||
310 | //_____________________________________________________________________________ | |
311 | Double_t AliTPCCalPad::GetLTM(Double_t *sigma, Double_t fraction) | |
312 | { | |
313 | // | |
314 | // return mean of the LTM and sigma of all ROCs | |
315 | // | |
316 | Double_t arrm[kNsec]; | |
317 | Double_t arrs[kNsec]; | |
318 | Double_t *sTemp=0x0; | |
319 | Int_t n=0; | |
320 | ||
321 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
322 | AliTPCCalROC *calRoc = fROC[isec]; | |
323 | if ( calRoc ){ | |
324 | if ( sigma ) sTemp=arrs+n; | |
325 | arrm[n] = calRoc->GetLTM(sTemp,fraction); | |
326 | n++; | |
327 | } | |
328 | } | |
329 | if ( sigma ) *sigma = TMath::Mean(n,arrs); | |
330 | return TMath::Mean(n,arrm); | |
331 | } | |
332 | ||
333 | //_____________________________________________________________________________ | |
334 | TH1F * AliTPCCalPad::MakeHisto1D(Float_t min, Float_t max,Int_t type){ | |
335 | // | |
336 | // make 1D histo | |
337 | // type -1 = user defined range | |
338 | // 0 = nsigma cut nsigma=min | |
339 | if (type>=0){ | |
340 | if (type==0){ | |
341 | // nsigma range | |
342 | Float_t mean = GetMean(); | |
343 | Float_t sigma = GetRMS(); | |
344 | Float_t nsigma = TMath::Abs(min); | |
345 | min = mean-nsigma*sigma; | |
346 | max = mean+nsigma*sigma; | |
347 | } | |
348 | if (type==1){ | |
349 | // fixed range | |
350 | Float_t mean = GetMedian(); | |
351 | Float_t delta = min; | |
352 | min = mean-delta; | |
353 | max = mean+delta; | |
354 | } | |
355 | if (type==2){ | |
356 | // | |
357 | // LTM mean +- nsigma | |
358 | // | |
359 | Double_t sigma; | |
360 | Float_t mean = GetLTM(&sigma,max); | |
361 | sigma*=min; | |
362 | min = mean-sigma; | |
363 | max = mean+sigma; | |
364 | } | |
365 | } | |
366 | char name[1000]; | |
367 | sprintf(name,"%s Pad 1D",GetTitle()); | |
368 | TH1F * his = new TH1F(name,name,100, min,max); | |
369 | for (Int_t isec = 0; isec < kNsec; isec++) { | |
370 | if (fROC[isec]){ | |
371 | for (UInt_t irow=0; irow<fROC[isec]->GetNrows(); irow++){ | |
372 | UInt_t npads = (Int_t)fROC[isec]->GetNPads(irow); | |
373 | for (UInt_t ipad=0; ipad<npads; ipad++){ | |
374 | his->Fill(fROC[isec]->GetValue(irow,ipad)); | |
375 | } | |
376 | } | |
377 | } | |
378 | } | |
379 | return his; | |
380 | } | |
381 | ||
382 | //_____________________________________________________________________________ | |
200be8a6 | 383 | TH2F *AliTPCCalPad::MakeHisto2D(Int_t side){ |
384 | // | |
385 | // Make 2D graph | |
386 | // side - specify the side A = 0 C = 1 | |
387 | // type - used types of determination of boundaries in z | |
388 | Float_t kEpsilon = 0.000000000001; | |
389 | TH2F * his = new TH2F(GetName(), GetName(), 250,-250,250,250,-250,250); | |
390 | AliTPCROC * roc = AliTPCROC::Instance(); | |
391 | for (Int_t isec=0; isec<72; isec++){ | |
392 | if (side==0 && isec%36>=18) continue; | |
393 | if (side>0 && isec%36<18) continue; | |
394 | if (fROC[isec]){ | |
395 | AliTPCCalROC * calRoc = fROC[isec]; | |
396 | for (UInt_t irow=0; irow<calRoc->GetNrows(); irow++) | |
397 | for (UInt_t ipad=0; ipad<calRoc->GetNPads(irow); ipad++) | |
398 | if (TMath::Abs(calRoc->GetValue(irow,ipad))>kEpsilon){ | |
399 | Float_t xyz[3]; | |
400 | roc->GetPositionGlobal(isec,irow,ipad,xyz); | |
401 | Int_t binx = 1+TMath::Nint((xyz[0]+250.)*0.5); | |
402 | Int_t biny = 1+TMath::Nint((xyz[1]+250.)*0.5); | |
403 | Float_t value = calRoc->GetValue(irow,ipad); | |
404 | his->SetBinContent(binx,biny,value); | |
405 | } | |
406 | } | |
407 | } | |
408 | his->SetXTitle("x (cm)"); | |
409 | his->SetYTitle("y (cm)"); | |
410 | return his; | |
411 | } | |
412 | ||
413 | ||
414 |