]>
Commit | Line | Data |
---|---|---|
8bc7e885 | 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 | ||
7d855b04 | 16 | /// \class AliTPCCalibPedestal |
8bc7e885 | 17 | |
7d855b04 | 18 | // Root includes |
8bc7e885 | 19 | #include <TH1F.h> |
8bc7e885 | 20 | #include <TH2F.h> |
8bc7e885 | 21 | #include <TString.h> |
8bc7e885 | 22 | #include <TMath.h> |
23 | #include <TF1.h> | |
24 | #include <TRandom.h> | |
8bc7e885 | 25 | #include <TDirectory.h> |
8bc7e885 | 26 | #include <TFile.h> |
ac940b58 | 27 | #include <TMap.h> |
8bc7e885 | 28 | //AliRoot includes |
29 | #include "AliRawReader.h" | |
30 | #include "AliRawReaderRoot.h" | |
bc331d5b | 31 | #include "AliRawReaderDate.h" |
8bc7e885 | 32 | #include "AliTPCCalROC.h" |
8bc7e885 | 33 | #include "AliTPCROC.h" |
8bc7e885 | 34 | #include "AliMathBase.h" |
8bc7e885 | 35 | #include "TTreeStream.h" |
36 | ||
bc331d5b | 37 | //date |
38 | #include "event.h" | |
39 | ||
40 | //header file | |
41 | #include "AliTPCCalibPedestal.h" | |
8bc7e885 | 42 | |
43 | ||
aa983e4f | 44 | /////////////////////////////////////////////////////////////////////////////////////// |
45 | // Implementation of the TPC pedestal and noise calibration | |
46 | // | |
47 | // Origin: Jens Wiechula, Marian Ivanov J.Wiechula@gsi.de, Marian.Ivanov@cern.ch | |
48 | // | |
49 | // | |
50 | // ************************************************************************************* | |
51 | // * Class Description * | |
52 | // ************************************************************************************* | |
53 | // | |
54 | // Working principle: | |
55 | // ------------------ | |
56 | // Raw pedestal data is processed by calling one of the ProcessEvent(...) functions | |
57 | // (see below). These in the end call the Update(...) function, where the data is filled | |
58 | // into histograms. | |
59 | // | |
60 | // For each ROC one TH2F histo (ROC channel vs. ADC channel) is created when | |
61 | // it is filled for the first time (GetHistoPedestal(ROC,kTRUE)). All histos are stored in the | |
62 | // TObjArray fHistoPedestalArray. | |
63 | // | |
64 | // For a fast filling of the histogram the corresponding bin number of the channel and ADC channel | |
65 | // is computed by hand and the histogram array is accessed directly via its pointer. | |
66 | // ATTENTION: Doing so the the entry counter of the histogram is not increased | |
67 | // this means that e.g. the colz draw option gives an empty plot unless | |
68 | // calling 'histo->SetEntries(1)' before drawing. | |
69 | // | |
70 | // After accumulating the desired statistics the Analyse() function has to be called. | |
71 | // Whithin this function the pedestal and noise values are calculated for each pad, using | |
72 | // the fast gaus fit function AliMathBase::FitGaus(...), and the calibration | |
73 | // storage classes (AliTPCCalROC) are filled for each ROC. | |
74 | // The calibration information is stored in the TObjArrays fCalRocArrayPedestal and fCalRocArrayRMS; | |
75 | // | |
76 | // | |
77 | // | |
78 | // User interface for filling data: | |
79 | // -------------------------------- | |
80 | // | |
81 | // To Fill information one of the following functions can be used: | |
82 | // | |
83 | // Bool_t ProcessEvent(eventHeaderStruct *event); | |
84 | // - process Date event | |
85 | // - use AliTPCRawReaderDate and call ProcessEvent(AliRawReader *rawReader) | |
86 | // | |
87 | // Bool_t ProcessEvent(AliRawReader *rawReader); | |
88 | // - process AliRawReader event | |
829455ad | 89 | // - use AliTPCRawStreamV3 to loop over data and call ProcessEvent(AliTPCRawStreamV3 *rawStream) |
aa983e4f | 90 | // |
829455ad | 91 | // Bool_t ProcessEvent(AliTPCRawStreamV3 *rawStream); |
92 | // - process event from AliTPCRawStreamV3 | |
aa983e4f | 93 | // - call Update function for signal filling |
94 | // | |
95 | // Int_t Update(const Int_t isector, const Int_t iRow, const Int_t | |
96 | // iPad, const Int_t iTimeBin, const Float_t signal); | |
97 | // - directly fill signal information (sector, row, pad, time bin, pad) | |
98 | // to the reference histograms | |
99 | // | |
100 | // It is also possible to merge two independently taken calibrations using the function | |
101 | // | |
102 | // void Merge(AliTPCCalibPedestal *ped) | |
103 | // - copy histograms in 'ped' if the do not exist in this instance | |
104 | // - Add histograms in 'ped' to the histograms in this instance if the allready exist | |
105 | // - After merging call Analyse again! | |
106 | // | |
107 | // | |
108 | // | |
109 | // -- example: filling data using root raw data: | |
110 | // void fillPedestal(Char_t *filename) | |
111 | // { | |
112 | // rawReader = new AliRawReaderRoot(fileName); | |
113 | // if ( !rawReader ) return; | |
114 | // AliTPCCalibPedestal *calib = new AliTPCCalibPedestal; | |
115 | // while (rawReader->NextEvent()){ | |
116 | // calib->ProcessEvent(rawReader); | |
117 | // } | |
118 | // calib->Analyse(); | |
119 | // calib->DumpToFile("PedestalData.root"); | |
120 | // delete rawReader; | |
121 | // delete calib; | |
122 | // } | |
123 | // | |
124 | // | |
125 | // What kind of information is stored and how to retrieve them: | |
126 | // ------------------------------------------------------------ | |
127 | // | |
128 | // - Accessing the 'Reference Histograms' (pedestal distribution histograms): | |
129 | // | |
130 | // TH2F *GetHistoPedestal(Int_t sector); | |
131 | // | |
132 | // - Accessing the calibration storage objects: | |
133 | // | |
1542c62d | 134 | // AliTPCCalROC *GetCalRocPedestal(Int_t sector); - for the pedestal values, mean from gaus fit |
135 | // AliTPCCalROC *GetCalRocSigma(Int_t sector); - for the Noise values, sigma from guas fit | |
136 | // AliTPCCalROC *GetCalRocMean(Int_t sector); - for the pedestal values, truncated mean | |
137 | // AliTPCCalROC *GetCalRocRMS(Int_t sector); - for the Noise values, rms from truncated mean | |
aa983e4f | 138 | // |
139 | // example for visualisation: | |
140 | // if the file "PedestalData.root" was created using the above example one could do the following: | |
141 | // | |
142 | // TFile filePedestal("PedestalData.root") | |
143 | // AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)filePedestal->Get("AliTPCCalibPedestal"); | |
144 | // ped->GetCalRocPedestal(0)->Draw("colz"); | |
145 | // ped->GetCalRocRMS(0)->Draw("colz"); | |
146 | // | |
147 | // or use the AliTPCCalPad functionality: | |
148 | // AliTPCCalPad padPedestal(ped->GetCalPadPedestal()); | |
149 | // AliTPCCalPad padNoise(ped->GetCalPadRMS()); | |
150 | // padPedestal->MakeHisto2D()->Draw("colz"); //Draw A-Side Pedestal Information | |
151 | // padNoise->MakeHisto2D()->Draw("colz"); //Draw A-Side Noise Information | |
152 | // | |
153 | /* | |
154 | example: fill pedestal with gausschen noise | |
155 | AliTPCCalibPedestal ped; | |
156 | ped.TestEvent(); | |
157 | ped.Analyse(); | |
158 | //Draw output; | |
159 | TCanvas* c1 = new TCanvas; | |
160 | c1->Divide(1,2); | |
161 | c1->cd(1); | |
162 | ped.GetHistoPedestal(0)->SetEntries(1); //needed in order for colz to work, reason: fast filling does not increase the entries counter | |
163 | ped.GetHistoPedestal(0)->Draw("colz"); | |
164 | c1->cd(2); | |
165 | ped.GetHistoPedestal(36)->SetEntries(1); //needed in order for colz to work, reason: fast filling does not increase the entries counter | |
166 | ped.GetHistoPedestal(36)->Draw("colz"); | |
167 | TCanvas* c2 = new TCanvas; | |
168 | c2->Divide(2,2); | |
169 | c2->cd(1); | |
170 | ped.GetCalRocPedestal(0)->Draw("colz"); | |
171 | c2->cd(2); | |
172 | ped.GetCalRocRMS(0)->Draw("colz"); | |
173 | c2->cd(3); | |
174 | ped.GetCalRocPedestal(36)->Draw("colz"); | |
175 | c2->cd(4); | |
176 | ped.GetCalRocRMS(36)->Draw("colz"); | |
aa983e4f | 177 | */ |
bdf99a93 | 178 | // |
179 | // Time dependent pedestals: | |
180 | // | |
181 | // If wished there is the possibility to calculate for each channel and time bin | |
182 | // the mean pedestal [pedestals(t)]. This is done by | |
183 | // | |
184 | // 1) setting SetTimeAnalysis(kTRUE), | |
185 | // 2) processing the data by looping over the events using ProcessEvent(..) | |
186 | // 3) calling the Analyse() and AnalyseTime(nevents) functions (providing nevents) | |
187 | // 4) getting the pedestals(t) using TArrayF **timePed = calibPedestal.GetTimePedestals(); | |
188 | // 5) looking at values using timePed[row][pad].At(timebin) | |
189 | // | |
190 | // This functionality is intended to be used on an LDC bu the detector algorithm | |
191 | // (TPCPEDESTALda) to generate a data set used for configuration of the pattern | |
192 | // memory for baseline subtraction in the ALTROs. Later the information should also | |
193 | // be stored as reference data. | |
194 | // | |
8bc7e885 | 195 | |
196 | ||
7d855b04 | 197 | /// \cond CLASSIMP |
aa983e4f | 198 | ClassImp(AliTPCCalibPedestal) |
7d855b04 | 199 | /// \endcond |
8bc7e885 | 200 | |
1542c62d | 201 | AliTPCCalibPedestal::AliTPCCalibPedestal() : |
880c3382 | 202 | AliTPCCalibRawBase(), |
8bc7e885 | 203 | fAdcMin(1), |
204 | fAdcMax(100), | |
1542c62d | 205 | fAnaMeanDown(0.), |
206 | fAnaMeanUp(1.), | |
bdf99a93 | 207 | fTimeAnalysis(kFALSE), |
8bc7e885 | 208 | fCalRocArrayPedestal(72), |
1542c62d | 209 | fCalRocArraySigma(72), |
bdf99a93 | 210 | fHistoPedestalArray(72), |
1542c62d | 211 | fTimeSignal(NULL), |
212 | fCalRocArrayMean(72), | |
213 | fCalRocArrayRMS(72) | |
8bc7e885 | 214 | { |
bdf99a93 | 215 | // |
216 | // default constructor | |
217 | // | |
880c3382 | 218 | SetNameTitle("AliTPCCalibPedestal","AliTPCCalibPedestal"); |
219 | fFirstTimeBin=60; | |
220 | fLastTimeBin=1000; | |
8bc7e885 | 221 | } |
bdf99a93 | 222 | |
223 | ||
bc331d5b | 224 | //_____________________________________________________________________ |
1542c62d | 225 | AliTPCCalibPedestal::AliTPCCalibPedestal(const AliTPCCalibPedestal &ped) : |
880c3382 | 226 | AliTPCCalibRawBase(ped), |
bc331d5b | 227 | fAdcMin(ped.GetAdcMin()), |
228 | fAdcMax(ped.GetAdcMax()), | |
1542c62d | 229 | fAnaMeanDown(ped.fAnaMeanDown), |
230 | fAnaMeanUp(ped.fAnaMeanUp), | |
bdf99a93 | 231 | fTimeAnalysis(ped.fTimeAnalysis), |
bc331d5b | 232 | fCalRocArrayPedestal(72), |
1542c62d | 233 | fCalRocArraySigma(72), |
bdf99a93 | 234 | fHistoPedestalArray(72), |
1542c62d | 235 | fTimeSignal(ped.fTimeSignal), |
236 | fCalRocArrayMean(72), | |
237 | fCalRocArrayRMS(72) | |
bc331d5b | 238 | { |
7d855b04 | 239 | /// copy constructor |
240 | ||
bdf99a93 | 241 | for (Int_t iSec = 0; iSec < 72; ++iSec){ |
242 | const AliTPCCalROC *calPed = (AliTPCCalROC*)ped.fCalRocArrayPedestal.UncheckedAt(iSec); | |
243 | const AliTPCCalROC *calRMS = (AliTPCCalROC*)ped.fCalRocArrayRMS.UncheckedAt(iSec); | |
244 | const TH2F *hPed = (TH2F*)ped.fHistoPedestalArray.UncheckedAt(iSec); | |
245 | ||
246 | if ( calPed != 0x0 ) fCalRocArrayPedestal.AddAt(new AliTPCCalROC(*calPed), iSec); | |
247 | if ( calRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTPCCalROC(*calRMS), iSec); | |
248 | ||
249 | if ( hPed != 0x0 ){ | |
250 | TH2F *hNew = new TH2F(*hPed); | |
251 | hNew->SetDirectory(0); | |
252 | fHistoPedestalArray.AddAt(hNew,iSec); | |
bc331d5b | 253 | } |
bdf99a93 | 254 | } |
bc331d5b | 255 | } |
ac940b58 | 256 | AliTPCCalibPedestal::AliTPCCalibPedestal(const TMap *config): |
880c3382 | 257 | AliTPCCalibRawBase(), |
ac940b58 | 258 | fAdcMin(1), |
259 | fAdcMax(100), | |
260 | fAnaMeanDown(0.), | |
261 | fAnaMeanUp(1.), | |
262 | fTimeAnalysis(kFALSE), | |
ac940b58 | 263 | fCalRocArrayPedestal(72), |
264 | fCalRocArraySigma(72), | |
265 | fHistoPedestalArray(72), | |
266 | fTimeSignal(NULL), | |
267 | fCalRocArrayMean(72), | |
268 | fCalRocArrayRMS(72) | |
269 | { | |
7d855b04 | 270 | /// This constructor uses a TMap for setting some parametes |
271 | ||
880c3382 | 272 | SetNameTitle("AliTPCCalibPedestal","AliTPCCalibPedestal"); |
273 | fFirstTimeBin=60; | |
274 | fLastTimeBin=1000; | |
ac940b58 | 275 | if (config->GetValue("FirstTimeBin")) fFirstTimeBin = ((TObjString*)config->GetValue("FirstTimeBin"))->GetString().Atoi(); |
276 | if (config->GetValue("LastTimeBin")) fLastTimeBin = ((TObjString*)config->GetValue("LastTimeBin"))->GetString().Atoi(); | |
277 | if (config->GetValue("AdcMin")) fAdcMin = ((TObjString*)config->GetValue("AdcMin"))->GetString().Atoi(); | |
278 | if (config->GetValue("AdcMax")) fAdcMax = ((TObjString*)config->GetValue("AdcMax"))->GetString().Atoi(); | |
279 | if (config->GetValue("TimeAnalysis")) SetTimeAnalysis(((TObjString*)config->GetValue("TimeAnalysis"))->GetString().Atoi()); | |
ac940b58 | 280 | } |
bdf99a93 | 281 | |
282 | ||
bc331d5b | 283 | //_____________________________________________________________________ |
284 | AliTPCCalibPedestal& AliTPCCalibPedestal::operator = (const AliTPCCalibPedestal &source) | |
285 | { | |
7d855b04 | 286 | /// assignment operator |
287 | ||
bc331d5b | 288 | if (&source == this) return *this; |
289 | new (this) AliTPCCalibPedestal(source); | |
8bc7e885 | 290 | |
bc331d5b | 291 | return *this; |
292 | } | |
bdf99a93 | 293 | |
294 | ||
8bc7e885 | 295 | //_____________________________________________________________________ |
1542c62d | 296 | AliTPCCalibPedestal::~AliTPCCalibPedestal() |
8bc7e885 | 297 | { |
7d855b04 | 298 | /// destructor |
8bc7e885 | 299 | |
bdf99a93 | 300 | fCalRocArrayPedestal.Delete(); |
301 | fCalRocArrayRMS.Delete(); | |
a480de15 | 302 | fCalRocArraySigma.Delete(); |
bdf99a93 | 303 | fHistoPedestalArray.Delete(); |
304 | ||
305 | if ( fTimeSignal ) { | |
306 | for (Int_t i = 0; i < 159; i++) { | |
307 | delete [] fTimeSignal[i]; | |
308 | fTimeSignal[i] = 0; | |
309 | } | |
310 | delete [] fTimeSignal; | |
311 | fTimeSignal = 0; | |
312 | } | |
4958b652 | 313 | |
314 | // do not delete fMapping, because we do not own it. | |
315 | ||
bdf99a93 | 316 | } |
317 | ||
318 | ||
319 | //_____________________________________________________________________ | |
320 | void AliTPCCalibPedestal::SetTimeAnalysis(Bool_t time) | |
321 | { | |
7d855b04 | 322 | /// Use time dependent analysis: Pedestals are analysed as a function |
323 | /// of the drift time. There is one mean value generated for each time | |
324 | /// bin and each channel. It can be used as reference data and for | |
325 | /// configuration of the ALTRO pattern memory for baseline subtraction. | |
326 | /// | |
327 | /// ATTENTION: Use only on LDC in TPCPEDESTALda! On a LDC we get data | |
328 | /// only from one sector. For the full TPC we would need a lot of | |
329 | /// memory (36*159*140*1024*4bytes = 3.3GB)! | |
bdf99a93 | 330 | |
331 | fTimeAnalysis = time; | |
332 | ||
333 | if ( !fTimeAnalysis ) return; | |
334 | ||
335 | // prepare array for one sector (159*140*1024*4bytes = 92MB): | |
336 | fTimeSignal = new TArrayF*[159]; | |
337 | for (Int_t i = 0; i < 159; i++) { // padrows | |
338 | fTimeSignal[i] = new TArrayF[140]; | |
339 | for (Int_t j = 0; j < 140; j++) { // pads per row | |
340 | fTimeSignal[i][j].Set(1024); | |
341 | for (Int_t k = 0; k < 1024; k++) { // time bins per pad | |
342 | fTimeSignal[i][j].AddAt(0., k); | |
343 | } | |
344 | } | |
345 | } | |
aa983e4f | 346 | } |
bdf99a93 | 347 | |
348 | ||
8bc7e885 | 349 | //_____________________________________________________________________ |
1542c62d | 350 | Int_t AliTPCCalibPedestal::Update(const Int_t icsector, |
bdf99a93 | 351 | const Int_t icRow, |
352 | const Int_t icPad, | |
353 | const Int_t icTimeBin, | |
354 | const Float_t csignal) | |
8bc7e885 | 355 | { |
7d855b04 | 356 | /// Signal filling method |
357 | ||
b401648b | 358 | if (icRow<0) return 0; |
359 | if (icPad<0) return 0; | |
360 | if (icTimeBin<0) return 0; | |
361 | ||
bdf99a93 | 362 | // Time dependent pedestals |
363 | if ( fTimeAnalysis ) { | |
364 | if ( icsector < 36 ) // IROC | |
365 | fTimeSignal[icRow][icPad].AddAt(fTimeSignal[icRow][icPad].At(icTimeBin)+csignal, icTimeBin); | |
366 | else | |
367 | fTimeSignal[icRow+63][icPad].AddAt(fTimeSignal[icRow+63][icPad].At(icTimeBin)+csignal, icTimeBin); | |
368 | } | |
369 | //return if we are out of the specified time bin or adc range | |
370 | if ( (icTimeBin>fLastTimeBin) || (icTimeBin<fFirstTimeBin) ) return 0; | |
371 | if ( ((Int_t)csignal>fAdcMax) || ((Int_t)csignal<fAdcMin) ) return 0; | |
8bc7e885 | 372 | |
bdf99a93 | 373 | Int_t iChannel = fROC->GetRowIndexes(icsector)[icRow]+icPad; // global pad position in sector |
8bc7e885 | 374 | |
4958b652 | 375 | // fast filling method |
bdf99a93 | 376 | // Attention: the entry counter of the histogram is not increased |
377 | // this means that e.g. the colz draw option gives an empty plot | |
378 | Int_t bin = (iChannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1); | |
8bc7e885 | 379 | |
bdf99a93 | 380 | GetHistoPedestal(icsector,kTRUE)->GetArray()[bin]++; |
8bc7e885 | 381 | |
bdf99a93 | 382 | return 0; |
8bc7e885 | 383 | } |
4958b652 | 384 | |
385 | ||
bc331d5b | 386 | //_____________________________________________________________________ |
1542c62d | 387 | Bool_t AliTPCCalibPedestal::TestEvent() |
8bc7e885 | 388 | { |
7d855b04 | 389 | /// Test event loop |
390 | /// fill one oroc and one iroc with random gaus | |
8bc7e885 | 391 | |
880c3382 | 392 | gRandom->SetSeed(0); |
393 | ||
394 | for (UInt_t iSec=0; iSec<72; ++iSec){ | |
395 | if (iSec%36>0) continue; | |
396 | for (UInt_t iRow=0; iRow < fROC->GetNRows(iSec); ++iRow){ | |
397 | for (UInt_t iPad=0; iPad < fROC->GetNPads(iSec,iRow); ++iPad){ | |
398 | for (UInt_t iTimeBin=0; iTimeBin<1024; ++iTimeBin){ | |
399 | Float_t signal=(Int_t)(iRow+3+gRandom->Gaus(0,.7)); | |
400 | if ( signal>0 )Update(iSec,iRow,iPad,iTimeBin,signal); | |
401 | } | |
402 | } | |
8bc7e885 | 403 | } |
880c3382 | 404 | } |
405 | return kTRUE; | |
8bc7e885 | 406 | } |
bdf99a93 | 407 | |
408 | ||
8bc7e885 | 409 | //_____________________________________________________________________ |
1542c62d | 410 | TH2F* AliTPCCalibPedestal::GetHisto(Int_t sector, TObjArray *arr, |
4958b652 | 411 | Int_t nbinsY, Float_t ymin, Float_t ymax, |
a6e0ebfe | 412 | const Char_t *type, Bool_t force) |
8bc7e885 | 413 | { |
7d855b04 | 414 | /// return pointer to Q histogram |
415 | /// if force is true create a new histogram if it doesn't exist allready | |
416 | ||
8bc7e885 | 417 | if ( !force || arr->UncheckedAt(sector) ) |
a3b590cf | 418 | return (TH2F*)arr->UncheckedAt(sector); |
8bc7e885 | 419 | |
420 | // if we are forced and histogram doesn't yes exist create it | |
8bc7e885 | 421 | // new histogram with Q calib information. One value for each pad! |
a3b590cf | 422 | TH2F* hist = new TH2F(Form("hCalib%s%.2d",type,sector), |
423 | Form("%s calibration histogram sector %.2d;ADC channel;Channel (pad)",type,sector), | |
424 | nbinsY, ymin, ymax, | |
425 | fROC->GetNChannels(sector),0,fROC->GetNChannels(sector) | |
426 | ); | |
8bc7e885 | 427 | hist->SetDirectory(0); |
428 | arr->AddAt(hist,sector); | |
429 | return hist; | |
430 | } | |
bdf99a93 | 431 | |
432 | ||
8bc7e885 | 433 | //_____________________________________________________________________ |
1542c62d | 434 | TH2F* AliTPCCalibPedestal::GetHistoPedestal(Int_t sector, Bool_t force) |
8bc7e885 | 435 | { |
7d855b04 | 436 | /// return pointer to T0 histogram |
437 | /// if force is true create a new histogram if it doesn't exist allready | |
438 | ||
8bc7e885 | 439 | TObjArray *arr = &fHistoPedestalArray; |
440 | return GetHisto(sector, arr, fAdcMax-fAdcMin, fAdcMin, fAdcMax, "Pedestal", force); | |
441 | } | |
bdf99a93 | 442 | |
443 | ||
8bc7e885 | 444 | //_____________________________________________________________________ |
1542c62d | 445 | AliTPCCalROC* AliTPCCalibPedestal::GetCalRoc(Int_t sector, TObjArray* arr, Bool_t force) |
8bc7e885 | 446 | { |
7d855b04 | 447 | /// return pointer to ROC Calibration |
448 | /// if force is true create a new histogram if it doesn't exist allready | |
449 | ||
8bc7e885 | 450 | if ( !force || arr->UncheckedAt(sector) ) |
451 | return (AliTPCCalROC*)arr->UncheckedAt(sector); | |
452 | ||
aa983e4f | 453 | // if we are forced and the histogram doesn't yet exist create it |
8bc7e885 | 454 | |
455 | // new AliTPCCalROC for T0 information. One value for each pad! | |
456 | AliTPCCalROC *croc = new AliTPCCalROC(sector); | |
8bc7e885 | 457 | arr->AddAt(croc,sector); |
458 | return croc; | |
459 | } | |
bdf99a93 | 460 | |
461 | ||
8bc7e885 | 462 | //_____________________________________________________________________ |
1542c62d | 463 | AliTPCCalROC* AliTPCCalibPedestal::GetCalRocPedestal(Int_t sector, Bool_t force) |
8bc7e885 | 464 | { |
7d855b04 | 465 | /// return pointer to ROC with Pedestal data |
466 | /// if force is true create a new histogram if it doesn't exist allready | |
467 | ||
8bc7e885 | 468 | TObjArray *arr = &fCalRocArrayPedestal; |
469 | return GetCalRoc(sector, arr, force); | |
470 | } | |
bdf99a93 | 471 | |
472 | ||
8bc7e885 | 473 | //_____________________________________________________________________ |
1542c62d | 474 | AliTPCCalROC* AliTPCCalibPedestal::GetCalRocSigma(Int_t sector, Bool_t force) |
8bc7e885 | 475 | { |
7d855b04 | 476 | /// return pointer to ROC with signal witdth in sigma |
477 | /// if force is true create a new histogram if it doesn't exist allready | |
478 | ||
1542c62d | 479 | TObjArray *arr = &fCalRocArraySigma; |
8bc7e885 | 480 | return GetCalRoc(sector, arr, force); |
481 | } | |
1542c62d | 482 | //_____________________________________________________________________ |
483 | AliTPCCalROC* AliTPCCalibPedestal::GetCalRocMean(Int_t sector, Bool_t force) | |
484 | { | |
7d855b04 | 485 | /// return pointer to ROC with signal mean information |
486 | /// if force is true create a new histogram if it doesn't exist allready | |
487 | ||
1542c62d | 488 | TObjArray *arr = &fCalRocArrayMean; |
489 | return GetCalRoc(sector, arr, force); | |
490 | } | |
491 | ||
492 | //_____________________________________________________________________ | |
493 | AliTPCCalROC* AliTPCCalibPedestal::GetCalRocRMS(Int_t sector, Bool_t force) | |
494 | { | |
7d855b04 | 495 | /// return pointer to signal width ROC Calibration |
496 | /// if force is true create a new histogram if it doesn't exist allready | |
497 | ||
1542c62d | 498 | TObjArray *arr = &fCalRocArrayRMS; |
499 | return GetCalRoc(sector, arr, force); | |
500 | } | |
bdf99a93 | 501 | |
502 | ||
8bc7e885 | 503 | //_____________________________________________________________________ |
7442bceb | 504 | void AliTPCCalibPedestal::Merge(AliTPCCalibPedestal * const ped) |
aa983e4f | 505 | { |
7d855b04 | 506 | /// Merge reference histograms of sig to the current AliTPCCalibPedestal |
507 | ||
78f17711 | 508 | MergeBase(ped); |
bdf99a93 | 509 | // merge histograms |
510 | for (Int_t iSec=0; iSec<72; ++iSec){ | |
511 | TH2F *hRefPedMerge = ped->GetHistoPedestal(iSec); | |
7442bceb | 512 | |
bdf99a93 | 513 | if ( hRefPedMerge ){ |
514 | TDirectory *dir = hRefPedMerge->GetDirectory(); hRefPedMerge->SetDirectory(0); | |
515 | TH2F *hRefPed = GetHistoPedestal(iSec); | |
516 | if ( hRefPed ) hRefPed->Add(hRefPedMerge); | |
517 | else { | |
7442bceb | 518 | TH2F *hist = new TH2F(*hRefPedMerge); |
519 | hist->SetDirectory(0); | |
520 | fHistoPedestalArray.AddAt(hist, iSec); | |
bdf99a93 | 521 | } |
522 | hRefPedMerge->SetDirectory(dir); | |
523 | } | |
524 | } | |
7442bceb | 525 | |
bdf99a93 | 526 | // merge array |
527 | // ... | |
7442bceb | 528 | |
aa983e4f | 529 | } |
bdf99a93 | 530 | |
7442bceb | 531 | //_____________________________________________________________________ |
532 | Long64_t AliTPCCalibPedestal::Merge(TCollection * const list) | |
533 | { | |
7d855b04 | 534 | /// Merge all objects of this type in list |
535 | ||
7442bceb | 536 | Long64_t nmerged=1; |
537 | ||
538 | TIter next(list); | |
539 | AliTPCCalibPedestal *ce=0; | |
540 | TObject *o=0; | |
541 | ||
542 | while ( (o=next()) ){ | |
543 | ce=dynamic_cast<AliTPCCalibPedestal*>(o); | |
544 | if (ce){ | |
545 | Merge(ce); | |
546 | ++nmerged; | |
547 | } | |
548 | } | |
549 | ||
550 | return nmerged; | |
551 | } | |
bdf99a93 | 552 | |
aa983e4f | 553 | //_____________________________________________________________________ |
1542c62d | 554 | void AliTPCCalibPedestal::Analyse() |
8bc7e885 | 555 | { |
7d855b04 | 556 | /// Calculate calibration constants |
8bc7e885 | 557 | |
bdf99a93 | 558 | Int_t nbinsAdc = fAdcMax-fAdcMin; |
8bc7e885 | 559 | |
1542c62d | 560 | TVectorD param(4); |
bdf99a93 | 561 | TMatrixD dummy(3,3); |
8bc7e885 | 562 | |
1542c62d | 563 | TH1F *hChannel=new TH1F("hChannel","hChannel",nbinsAdc,fAdcMin,fAdcMax); |
564 | ||
7442bceb | 565 | Float_t *arrayhP=0; |
8bc7e885 | 566 | |
bdf99a93 | 567 | for (Int_t iSec=0; iSec<72; ++iSec){ |
568 | TH2F *hP = GetHistoPedestal(iSec); | |
569 | if ( !hP ) continue; | |
8bc7e885 | 570 | |
bdf99a93 | 571 | AliTPCCalROC *rocPedestal = GetCalRocPedestal(iSec,kTRUE); |
1542c62d | 572 | AliTPCCalROC *rocSigma = GetCalRocSigma(iSec,kTRUE); |
573 | AliTPCCalROC *rocMean = GetCalRocMean(iSec,kTRUE); | |
bdf99a93 | 574 | AliTPCCalROC *rocRMS = GetCalRocRMS(iSec,kTRUE); |
8bc7e885 | 575 | |
7442bceb | 576 | arrayhP = hP->GetArray(); |
bdf99a93 | 577 | UInt_t nChannels = fROC->GetNChannels(iSec); |
8bc7e885 | 578 | |
bdf99a93 | 579 | for (UInt_t iChannel=0; iChannel<nChannels; ++iChannel){ |
580 | Int_t offset = (nbinsAdc+2)*(iChannel+1)+1; | |
1542c62d | 581 | //calculate mean and sigma using a gaus fit |
9e359afd | 582 | //Double_t ret = |
7442bceb | 583 | AliMathBase::FitGaus(arrayhP+offset,nbinsAdc,fAdcMin,fAdcMax,¶m,&dummy); |
bdf99a93 | 584 | // if the fitting failed set noise and pedestal to 0 |
1542c62d | 585 | // is now done in AliMathBase::FitGaus ! |
586 | // if ( ret == -4 ) { | |
587 | // param[1]=0; | |
588 | // param[2]=0; | |
589 | // } | |
ac940b58 | 590 | if ( param[1]<fAdcMin || param[1]>fAdcMax ){ |
591 | param[1]=0; | |
592 | param[2]=0; | |
593 | } | |
bdf99a93 | 594 | rocPedestal->SetValue(iChannel,param[1]); |
1542c62d | 595 | rocSigma->SetValue(iChannel,param[2]); |
596 | //calculate mean and RMS using a truncated means | |
7442bceb | 597 | hChannel->Set(nbinsAdc+2,arrayhP+offset-1); |
1542c62d | 598 | hChannel->SetEntries(param[3]); |
599 | param[1]=0; | |
600 | param[2]=0; | |
601 | if ( param[3]>0 ) AliMathBase::TruncatedMean(hChannel,¶m,fAnaMeanDown,fAnaMeanUp); | |
602 | rocMean->SetValue(iChannel,param[1]); | |
bdf99a93 | 603 | rocRMS->SetValue(iChannel,param[2]); |
604 | } | |
605 | } | |
1542c62d | 606 | delete hChannel; |
bdf99a93 | 607 | } |
8bc7e885 | 608 | |
bdf99a93 | 609 | |
610 | //_____________________________________________________________________ | |
611 | void AliTPCCalibPedestal::AnalyseTime(Int_t nevents) | |
612 | { | |
7d855b04 | 613 | /// Calculate for each channel and time bin the mean pedestal. This |
614 | /// is used on LDC by TPCPEDESTALda to generate data used for configuration | |
615 | /// of the pattern memory for baseline subtraction in the ALTROs. | |
bdf99a93 | 616 | |
617 | if ( nevents <= 0 ) return; | |
618 | if ( fTimeAnalysis ) { | |
619 | for (Int_t i = 0; i < 159; i++) { // padrows | |
620 | for (Int_t j = 0; j < 140; j++) { // pads per row | |
621 | for (Int_t k = 0; k < 1024; k++) { // time bins per pad | |
622 | fTimeSignal[i][j].AddAt(fTimeSignal[i][j].At(k)/(Float_t)nevents, k); | |
8bc7e885 | 623 | } |
bdf99a93 | 624 | } |
8bc7e885 | 625 | } |
bdf99a93 | 626 | } |
8bc7e885 | 627 | } |