]>
Commit | Line | Data |
---|---|---|
b3fcfd96 | 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 | ||
17 | ||
18 | /* | |
4c865c34 | 19 | Responsible: Raphaelle Bailhache (rbailhache@ikf.uni-frankfurt.de) |
20 | Code to analyze the TRD calibration and to produce OCDB entries | |
b3fcfd96 | 21 | |
22 | ||
23 | .x ~/rootlogon.C | |
24 | gSystem->Load("libANALYSIS"); | |
4c865c34 | 25 | gSystem->Load("libTRDcalib"); |
b3fcfd96 | 26 | |
27 | AliTRDPreprocessorOffline proces; | |
28 | TString ocdbPath="local:////" | |
29 | ocdbPath+=gSystem->GetFromPipe("pwd"); | |
30 | ||
31 | proces.CalibTimeGain("CalibObjects.root",run0,run1,ocdbPath); | |
32 | proces.CalibTimeVdrift("CalibObjects.root",run0,run1,ocdbPath); | |
33 | // take the raw calibration data from the file CalibObjects.root | |
34 | // and make a OCDB entry with run validity run0-run1 | |
35 | // results are stored at the ocdbPath - local or alien ... | |
36 | // default storage ""- data stored at current working directory | |
37 | ||
38 | */ | |
00d203b6 | 39 | #include "AliLog.h" |
b3fcfd96 | 40 | #include "Riostream.h" |
41 | #include <fstream> | |
42 | #include "TFile.h" | |
43 | #include "TCanvas.h" | |
44 | #include "TLegend.h" | |
45 | #include "TH2I.h" | |
46 | #include "TH1I.h" | |
47 | #include "TH2F.h" | |
48 | #include "TH1F.h" | |
82b413fd | 49 | #include "TMath.h" |
83d0cc79 | 50 | #include "THnSparse.h" |
b3fcfd96 | 51 | #include "TProfile2D.h" |
52 | #include "AliTRDCalDet.h" | |
53 | #include "AliTRDCalPad.h" | |
54 | #include "AliCDBMetaData.h" | |
55 | #include "AliCDBId.h" | |
56 | #include "AliCDBManager.h" | |
57 | #include "AliCDBStorage.h" | |
58 | #include "AliTRDCalibraMode.h" | |
59 | #include "AliTRDCalibraFit.h" | |
60 | #include "AliTRDCalibraVdriftLinearFit.h" | |
a0bb5615 | 61 | #include "AliTRDCalibraExbAltFit.h" |
b3fcfd96 | 62 | #include "AliTRDPreprocessorOffline.h" |
81a5aeca | 63 | #include "AliTRDCalChamberStatus.h" |
83d0cc79 | 64 | #include "AliTRDCalibChamberStatus.h" |
840ec79d | 65 | #include "AliTRDCommonParam.h" |
83d0cc79 | 66 | #include "AliCDBManager.h" |
67 | #include "AliCDBEntry.h" | |
b3fcfd96 | 68 | |
69 | ||
70 | ClassImp(AliTRDPreprocessorOffline) | |
71 | ||
54f2ff1c | 72 | AliTRDPreprocessorOffline::AliTRDPreprocessorOffline(): |
01239968 | 73 | TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"), |
b3fcfd96 | 74 | fMethodSecond(kTRUE), |
01239968 | 75 | fNameList("TRDCalib"), |
76 | fCalDetGainUsed(0x0), | |
4c865c34 | 77 | fCalDetVdriftUsed(0x0), |
840ec79d | 78 | fCalDetExBUsed(0x0), |
b3fcfd96 | 79 | fCH2d(0x0), |
80 | fPH2d(0x0), | |
81 | fPRF2d(0x0), | |
83d0cc79 | 82 | fSparse(0x0), |
b3fcfd96 | 83 | fAliTRDCalibraVdriftLinearFit(0x0), |
a0bb5615 | 84 | fAliTRDCalibraExbAltFit(0x0), |
b3fcfd96 | 85 | fNEvents(0x0), |
86 | fAbsoluteGain(0x0), | |
a0bb5615 | 87 | fPlots(new TObjArray(kNumCalibObjs)), |
88 | fCalibObjects(new TObjArray(kNumCalibObjs)), | |
83d0cc79 | 89 | fFirstRunGainUsed(0), |
4c865c34 | 90 | fVersionGainUsed(0), |
91 | fSubVersionGainUsed(0), | |
ca7e6e64 | 92 | fFirstRunVdriftUsed(0), |
4c865c34 | 93 | fVersionVdriftUsed(0), |
00d203b6 | 94 | fSubVersionVdriftUsed(0), |
83d0cc79 | 95 | fFirstRunExBUsed(0), |
96 | fVersionExBUsed(0), | |
97 | fSubVersionExBUsed(0), | |
98 | fNoExBUsedInReco(kFALSE), | |
00d203b6 | 99 | fSwitchOnValidation(kTRUE), |
100 | fVdriftValidated(kFALSE), | |
840ec79d | 101 | fExBValidated(kFALSE), |
a2a4ec8e | 102 | fT0Validated(kFALSE), |
103 | fMinStatsVdriftT0PH(800*20), | |
104 | fMinStatsVdriftLinear(800), | |
105 | fMinStatsGain(800), | |
54f2ff1c | 106 | fMinStatsPRF(600), |
83d0cc79 | 107 | fMinStatsChamberStatus(20), |
54f2ff1c | 108 | fBackCorrectGain(kFALSE), |
109 | fBackCorrectVdrift(kTRUE), | |
110 | fNotEnoughStatisticsForTheGain(kFALSE), | |
111 | fNotEnoughStatisticsForTheVdriftLinear(kFALSE), | |
82b413fd | 112 | fStatusNeg(0), |
83d0cc79 | 113 | fStatusPos(0), |
661c7be6 | 114 | fBadCalibValidate(40), |
115 | fNoDataValidate(40), | |
83d0cc79 | 116 | fRMSBadCalibratedGain(20.0), |
117 | fRMSBadCalibratedVdrift(20.0), | |
661c7be6 | 118 | fRMSBadCalibratedExB(20.0), |
2a1a7b36 | 119 | fRobustFitDriftVelocity(kTRUE), |
661c7be6 | 120 | fRobustFitExbAlt(kFALSE), |
121 | fAlternativeVdrfitFit(kFALSE), | |
122 | fAlternativeExbAltFit(kFALSE) | |
b3fcfd96 | 123 | { |
124 | // | |
125 | // default constructor | |
126 | // | |
83d0cc79 | 127 | |
128 | memset(fBadCalib, 0, sizeof(Int_t) * 18); | |
129 | memset(fNoData, 0, sizeof(Int_t) * 18); | |
b3fcfd96 | 130 | } |
00d203b6 | 131 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 132 | AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() { |
133 | // | |
134 | // Destructor | |
135 | // | |
136 | ||
01239968 | 137 | if(fCalDetGainUsed) delete fCalDetGainUsed; |
4c865c34 | 138 | if(fCalDetVdriftUsed) delete fCalDetVdriftUsed; |
840ec79d | 139 | if(fCalDetExBUsed) delete fCalDetExBUsed; |
b3fcfd96 | 140 | if(fCH2d) delete fCH2d; |
141 | if(fPH2d) delete fPH2d; | |
142 | if(fPRF2d) delete fPRF2d; | |
83d0cc79 | 143 | if(fSparse) delete fSparse; |
b3fcfd96 | 144 | if(fAliTRDCalibraVdriftLinearFit) delete fAliTRDCalibraVdriftLinearFit; |
a0bb5615 | 145 | if(fAliTRDCalibraExbAltFit) delete fAliTRDCalibraExbAltFit; |
b3fcfd96 | 146 | if(fNEvents) delete fNEvents; |
147 | if(fAbsoluteGain) delete fAbsoluteGain; | |
148 | if(fPlots) delete fPlots; | |
149 | if(fCalibObjects) delete fCalibObjects; | |
150 | ||
83d0cc79 | 151 | } |
152 | //___________________________________________________________________________________ | |
153 | void AliTRDPreprocessorOffline::Process(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage) | |
154 | { | |
155 | // | |
156 | // Process to the gain, vdrift, timeoffset, exb and chamber status calibration | |
157 | // | |
158 | ||
159 | if(SetCalDetGain(startRunNumber,fVersionGainUsed,fSubVersionGainUsed) && SetCalDetVdriftExB(startRunNumber,fVersionVdriftUsed,fSubVersionVdriftUsed,fVersionExBUsed,fSubVersionExBUsed)) { | |
160 | ||
161 | CalibVdriftT0(file,startRunNumber,endRunNumber,ocdbStorage); | |
162 | CalibGain(file,startRunNumber,endRunNumber,ocdbStorage); | |
163 | CalibChamberStatus(file,startRunNumber,endRunNumber,ocdbStorage); | |
f29cf84c | 164 | CalibExbAlt(file,startRunNumber,endRunNumber,ocdbStorage); |
83d0cc79 | 165 | |
166 | } | |
167 | ||
168 | PrintStatus(); | |
169 | ||
b3fcfd96 | 170 | } |
00d203b6 | 171 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 172 | |
173 | void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
174 | // | |
175 | // make calibration of the drift velocity | |
176 | // Input parameters: | |
177 | // file - the location of input file | |
178 | // startRunNumber, endRunNumber - run validity period | |
179 | // ocdbStorage - path to the OCDB storage | |
180 | // - if empty - local storage 'pwd' uesed | |
181 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
182 | // | |
183 | // 1. Initialization | |
184 | // | |
008817a3 | 185 | fVdriftValidated = kTRUE; |
186 | fT0Validated = kTRUE; | |
840ec79d | 187 | fExBValidated = kTRUE; |
54f2ff1c | 188 | fNotEnoughStatisticsForTheVdriftLinear = kFALSE; |
b3fcfd96 | 189 | // |
190 | // 2. extraction of the information | |
191 | // | |
840ec79d | 192 | if(ReadVdriftLinearFitGlobal(file) && fCalDetVdriftUsed && fCalDetExBUsed) AnalyzeVdriftLinearFit(); |
54f2ff1c | 193 | if(ReadVdriftT0Global(file)) AnalyzeVdriftT0(); |
b3fcfd96 | 194 | // |
195 | // 3. Append QA plots | |
196 | // | |
197 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
198 | // | |
199 | // | |
00d203b6 | 200 | // 4. validate OCDB entries |
b3fcfd96 | 201 | // |
00d203b6 | 202 | if(fSwitchOnValidation==kTRUE && ValidateVdrift()==kFALSE) { |
82b413fd | 203 | //AliError("TRD vdrift OCDB parameters out of range!"); |
00d203b6 | 204 | fVdriftValidated = kFALSE; |
205 | } | |
206 | if(fSwitchOnValidation==kTRUE && ValidateT0()==kFALSE) { | |
82b413fd | 207 | //AliError("TRD t0 OCDB parameters out of range!"); |
00d203b6 | 208 | fT0Validated = kFALSE; |
209 | } | |
840ec79d | 210 | if(fSwitchOnValidation==kTRUE && ValidateExB()==kFALSE) { |
211 | //AliError("TRD t0 OCDB parameters out of range!"); | |
212 | fExBValidated = kFALSE; | |
213 | } | |
b3fcfd96 | 214 | // |
00d203b6 | 215 | // 5. update of OCDB |
216 | // | |
217 | // | |
218 | if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage); | |
219 | if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage); | |
840ec79d | 220 | if(fExBValidated) UpdateOCDBExB(startRunNumber,endRunNumber,ocdbStorage); |
00d203b6 | 221 | |
b3fcfd96 | 222 | } |
a0bb5615 | 223 | //___________________________________________________________________________________________________________________ |
224 | ||
225 | void AliTRDPreprocessorOffline::CalibExbAlt(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
226 | // | |
227 | // make calibration of the drift velocity | |
228 | // Input parameters: | |
229 | // file - the location of input file | |
230 | // startRunNumber, endRunNumber - run validity period | |
231 | // ocdbStorage - path to the OCDB storage | |
232 | // - if empty - local storage 'pwd' uesed | |
233 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
234 | // | |
235 | // 1. Initialization | |
236 | // | |
237 | ||
238 | // | |
239 | // 2. extraction of the information | |
240 | // | |
241 | if(ReadExbAltFitGlobal(file)) AnalyzeExbAltFit(); | |
242 | // | |
243 | // 3. Append QA plots | |
244 | // | |
245 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
246 | // | |
247 | // | |
248 | // 4. validate OCDB entries | |
249 | // | |
250 | // | |
251 | // 5. update of OCDB | |
252 | // | |
253 | // | |
254 | UpdateOCDBExBAlt(startRunNumber,endRunNumber,ocdbStorage); | |
255 | ||
256 | } | |
257 | ||
00d203b6 | 258 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 259 | |
260 | void AliTRDPreprocessorOffline::CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
261 | // | |
262 | // make calibration of the drift velocity | |
263 | // Input parameters: | |
264 | // file - the location of input file | |
265 | // startRunNumber, endRunNumber - run validity period | |
266 | // ocdbStorage - path to the OCDB storage | |
267 | // - if empty - local storage 'pwd' uesed | |
268 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
269 | // | |
54f2ff1c | 270 | fNotEnoughStatisticsForTheGain = kFALSE; |
271 | // | |
b3fcfd96 | 272 | // 1. Initialization |
273 | if(!ReadGainGlobal(file)) return; | |
274 | // | |
275 | // | |
276 | // 2. extraction of the information | |
277 | // | |
278 | AnalyzeGain(); | |
54f2ff1c | 279 | if(fBackCorrectGain) CorrectFromDetGainUsed(); |
a0bb5615 | 280 | //if(fBackCorrectVdrift) CorrectFromDetVdriftUsed(); |
b3fcfd96 | 281 | // |
282 | // 3. Append QA plots | |
283 | // | |
284 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
285 | // | |
286 | // | |
00d203b6 | 287 | // 4. validate OCDB entries |
288 | // | |
289 | if(fSwitchOnValidation==kTRUE && ValidateGain()==kFALSE) { | |
82b413fd | 290 | //AliError("TRD gain OCDB parameters out of range!"); |
00d203b6 | 291 | return; |
292 | } | |
b3fcfd96 | 293 | // |
00d203b6 | 294 | // 5. update of OCDB |
b3fcfd96 | 295 | // |
00d203b6 | 296 | // |
297 | if((!fCalDetVdriftUsed) || (fCalDetVdriftUsed && fVdriftValidated)) UpdateOCDBGain(startRunNumber,endRunNumber,ocdbStorage); | |
298 | ||
b3fcfd96 | 299 | |
300 | } | |
00d203b6 | 301 | //________________________________________________________________________________________________________________ |
b3fcfd96 | 302 | |
303 | void AliTRDPreprocessorOffline::CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
304 | // | |
305 | // make calibration of the drift velocity | |
306 | // Input parameters: | |
307 | // file - the location of input file | |
308 | // startRunNumber, endRunNumber - run validity period | |
309 | // ocdbStorage - path to the OCDB storage | |
310 | // - if empty - local storage 'pwd' uesed | |
311 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
312 | // | |
313 | // 1. Initialization | |
314 | if(!ReadPRFGlobal(file)) return; | |
315 | // | |
316 | // | |
317 | // 2. extraction of the information | |
318 | // | |
319 | AnalyzePRF(); | |
320 | // | |
321 | // 3. Append QA plots | |
322 | // | |
323 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
324 | // | |
325 | // | |
00d203b6 | 326 | // |
327 | // 4. validate OCDB entries | |
328 | // | |
329 | if(fSwitchOnValidation==kTRUE && ValidatePRF()==kFALSE) { | |
82b413fd | 330 | //AliError("TRD prf OCDB parameters out of range!"); |
00d203b6 | 331 | return; |
332 | } | |
333 | // | |
334 | // 5. update of OCDB | |
b3fcfd96 | 335 | // |
336 | // | |
337 | UpdateOCDBPRF(startRunNumber,endRunNumber,ocdbStorage); | |
338 | ||
a5dcf618 | 339 | } |
340 | //________________________________________________________________________________________________________________ | |
341 | ||
83d0cc79 | 342 | void AliTRDPreprocessorOffline::CalibChamberStatus(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ |
a5dcf618 | 343 | // |
344 | // make calibration of the chamber status | |
345 | // Input parameters: | |
346 | // startRunNumber, endRunNumber - run validity period | |
347 | // ocdbStorage - path to the OCDB storage | |
348 | // - if empty - local storage 'pwd' uesed | |
349 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
350 | // | |
351 | // | |
83d0cc79 | 352 | // 1. Initialization |
353 | if(!ReadStatusGlobal(file)) return; | |
354 | // | |
355 | // | |
356 | // | |
a5dcf618 | 357 | // 2. extraction of the information |
358 | // | |
359 | if(!AnalyzeChamberStatus()) return; | |
360 | // | |
361 | // 3. Append QA plots | |
362 | // | |
363 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
364 | // | |
365 | // | |
366 | // | |
367 | // 4. validate OCDB entries | |
368 | // | |
369 | if(fSwitchOnValidation==kTRUE && ValidateChamberStatus()==kFALSE) { | |
82b413fd | 370 | //AliError("TRD Chamber status OCDB parameters not ok!"); |
a5dcf618 | 371 | return; |
372 | } | |
373 | // | |
374 | // 5. update of OCDB | |
375 | // | |
376 | // | |
83d0cc79 | 377 | if((!fNotEnoughStatisticsForTheVdriftLinear) && (!fNotEnoughStatisticsForTheGain)) UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage); |
378 | //UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage); | |
a5dcf618 | 379 | |
b3fcfd96 | 380 | } |
00d203b6 | 381 | //______________________________________________________________________________________________________ |
4c865c34 | 382 | Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){ |
383 | // | |
384 | // read the calibration used during the reconstruction | |
385 | // | |
386 | ||
387 | if(ReadVdriftT0Global(fileName)) { | |
388 | ||
389 | TString nameph = fPH2d->GetTitle(); | |
ca7e6e64 | 390 | fFirstRunVdriftUsed = GetFirstRun(nameph); |
4c865c34 | 391 | fVersionVdriftUsed = GetVersion(nameph); |
392 | fSubVersionVdriftUsed = GetSubVersion(nameph); | |
393 | ||
394 | //printf("Found Version %d, Subversion %d for vdrift\n",fVersionVdriftUsed,fSubVersionVdriftUsed); | |
395 | ||
396 | } | |
397 | ||
398 | if(ReadGainGlobal(fileName)) { | |
399 | ||
400 | TString namech = fCH2d->GetTitle(); | |
83d0cc79 | 401 | fFirstRunGainUsed = GetFirstRun(namech); |
4c865c34 | 402 | fVersionGainUsed = GetVersion(namech); |
403 | fSubVersionGainUsed = GetSubVersion(namech); | |
404 | ||
405 | //printf("Found Version %d, Subversion %d for gain\n",fVersionGainUsed,fSubVersionGainUsed); | |
406 | ||
407 | } | |
83d0cc79 | 408 | |
409 | if(ReadVdriftLinearFitGlobal(fileName)) { | |
410 | ||
411 | TString namelinear = fAliTRDCalibraVdriftLinearFit->GetNameCalibUsed(); | |
412 | fFirstRunExBUsed = GetFirstRun(namelinear); | |
413 | fVersionExBUsed = GetVersion(namelinear); | |
414 | fSubVersionExBUsed = GetSubVersion(namelinear); | |
415 | ||
416 | //printf("Found Version %d, Subversion %d, run %d for ExB\n",fVersionExBUsed,fSubVersionExBUsed,fFirstRunExBUsed); | |
417 | ||
418 | } | |
4c865c34 | 419 | |
82b413fd | 420 | if(fVersionVdriftUsed == 0) fStatusPos = fStatusPos |kVdriftErrorOld; |
421 | if(fVersionGainUsed == 0) fStatusPos = fStatusPos | kGainErrorOld; | |
840ec79d | 422 | |
4c865c34 | 423 | return kTRUE; |
424 | ||
425 | } | |
00d203b6 | 426 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 427 | |
83d0cc79 | 428 | Bool_t AliTRDPreprocessorOffline::ReadStatusGlobal(const Char_t* fileName){ |
429 | // | |
430 | // read calibration entries from file | |
431 | // | |
432 | if(fSparse) return kTRUE; | |
433 | TFile fcalib(fileName); | |
434 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); | |
435 | if (array){ | |
436 | fSparse = (THnSparseI *) array->FindObject("NumberOfEntries"); | |
437 | if(!fSparse) return kFALSE; | |
438 | } | |
439 | else | |
440 | return kFALSE; | |
441 | ||
442 | return kTRUE; | |
443 | ||
444 | } | |
445 | //___________________________________________________________________________________________________________________ | |
446 | ||
b3fcfd96 | 447 | Bool_t AliTRDPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){ |
448 | // | |
449 | // read calibration entries from file | |
450 | // | |
4c865c34 | 451 | if(fCH2d) return kTRUE; |
b3fcfd96 | 452 | TFile fcalib(fileName); |
01239968 | 453 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 454 | if (array){ |
455 | TH2I *ch2d = (TH2I *) array->FindObject("CH2d"); | |
456 | if(!ch2d) return kFALSE; | |
457 | fCH2d = (TH2I*)ch2d->Clone(); | |
458 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
459 | //fAbsoluteGain = (TH2F *) array->FindObject("AbsoluteGain"); | |
460 | }else{ | |
461 | TH2I *ch2d = (TH2I *) fcalib.Get("CH2d"); | |
462 | if(!ch2d) return kFALSE; | |
463 | fCH2d = (TH2I*)ch2d->Clone(); | |
464 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
465 | //fAbsoluteGain = (TH2F *) fcalib.Get("AbsoluteGain"); | |
466 | } | |
467 | fCH2d->SetDirectory(0); | |
468 | //printf("title of CH2d %s\n",fCH2d->GetTitle()); | |
469 | ||
470 | return kTRUE; | |
471 | ||
472 | } | |
00d203b6 | 473 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 474 | |
475 | Bool_t AliTRDPreprocessorOffline::ReadVdriftT0Global(const Char_t* fileName){ | |
476 | // | |
477 | // read calibration entries from file | |
478 | // | |
4c865c34 | 479 | if(fPH2d) return kTRUE; |
b3fcfd96 | 480 | TFile fcalib(fileName); |
01239968 | 481 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 482 | if (array){ |
483 | TProfile2D *ph2d = (TProfile2D *) array->FindObject("PH2d"); | |
484 | if(!ph2d) return kFALSE; | |
485 | fPH2d = (TProfile2D*)ph2d->Clone(); | |
486 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
487 | }else{ | |
488 | TProfile2D *ph2d = (TProfile2D *) fcalib.Get("PH2d"); | |
489 | if(!ph2d) return kFALSE; | |
490 | fPH2d = (TProfile2D*)ph2d->Clone(); | |
491 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
492 | } | |
493 | fPH2d->SetDirectory(0); | |
494 | //printf("title of PH2d %s\n",fPH2d->GetTitle()); | |
495 | ||
496 | return kTRUE; | |
497 | ||
498 | } | |
00d203b6 | 499 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 500 | |
501 | Bool_t AliTRDPreprocessorOffline::ReadVdriftLinearFitGlobal(const Char_t* fileName){ | |
502 | // | |
503 | // read calibration entries from file | |
504 | // | |
4c865c34 | 505 | if(fAliTRDCalibraVdriftLinearFit) return kTRUE; |
b3fcfd96 | 506 | TFile fcalib(fileName); |
01239968 | 507 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 508 | if (array){ |
509 | fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) array->FindObject("AliTRDCalibraVdriftLinearFit"); | |
510 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
511 | }else{ | |
512 | fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) fcalib.Get("AliTRDCalibraVdriftLinearFit"); | |
513 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
514 | } | |
515 | if(!fAliTRDCalibraVdriftLinearFit) { | |
516 | //printf("No AliTRDCalibraVdriftLinearFit\n"); | |
517 | return kFALSE; | |
518 | } | |
519 | return kTRUE; | |
520 | ||
a0bb5615 | 521 | } |
522 | //_____________________________________________________________________________________________________________ | |
523 | Bool_t AliTRDPreprocessorOffline::ReadExbAltFitGlobal(const Char_t* fileName){ | |
524 | // | |
525 | // read calibration entries from file | |
526 | // | |
527 | if(fAliTRDCalibraExbAltFit) return kTRUE; | |
528 | TFile fcalib(fileName); | |
529 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); | |
530 | if (array){ | |
531 | fAliTRDCalibraExbAltFit = (AliTRDCalibraExbAltFit *) array->FindObject("AliTRDCalibraExbAltFit"); | |
532 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
533 | }else{ | |
534 | fAliTRDCalibraExbAltFit = (AliTRDCalibraExbAltFit *) fcalib.Get("AliTRDCalibraExbAltFit"); | |
535 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
536 | } | |
537 | if(!fAliTRDCalibraExbAltFit) { | |
538 | //printf("No AliTRDCalibraExbAltFit\n"); | |
539 | return kFALSE; | |
540 | } | |
541 | return kTRUE; | |
542 | ||
b3fcfd96 | 543 | } |
00d203b6 | 544 | //_____________________________________________________________________________________________________________ |
b3fcfd96 | 545 | |
546 | Bool_t AliTRDPreprocessorOffline::ReadPRFGlobal(const Char_t* fileName){ | |
547 | // | |
548 | // read calibration entries from file | |
549 | // | |
4c865c34 | 550 | if(fPRF2d) return kTRUE; |
b3fcfd96 | 551 | TFile fcalib(fileName); |
01239968 | 552 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 553 | if (array){ |
554 | TProfile2D *prf2d = (TProfile2D *) array->FindObject("PRF2d"); | |
555 | if(!prf2d) return kFALSE; | |
556 | fPRF2d = (TProfile2D*)prf2d->Clone(); | |
557 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
558 | }else{ | |
559 | TProfile2D *prf2d = (TProfile2D *) fcalib.Get("PRF2d"); | |
560 | if(!prf2d) return kFALSE; | |
561 | fPRF2d = (TProfile2D*)prf2d->Clone(); | |
562 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
563 | } | |
564 | fPRF2d->SetDirectory(0); | |
565 | //printf("title of PRF2d %s\n",fPRF2d->GetTitle()); | |
566 | ||
567 | return kTRUE; | |
568 | ||
569 | } | |
00d203b6 | 570 | //__________________________________________________________________________________________________________ |
b3fcfd96 | 571 | |
572 | Bool_t AliTRDPreprocessorOffline::AnalyzeGain(){ | |
573 | // | |
574 | // Analyze gain - produce the calibration objects | |
575 | // | |
576 | ||
577 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
a2a4ec8e | 578 | calibra->SetMinEntries(fMinStatsGain); // If there is less than 1000 entries in the histo: no fit |
b3fcfd96 | 579 | calibra->AnalyseCH(fCH2d); |
580 | ||
581 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
582 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
583 | Int_t nbfit = calibra->GetNumberFit(); | |
584 | Int_t nbE = calibra->GetNumberEnt(); | |
585 | ||
586 | ||
587 | Bool_t ok = kFALSE; | |
4c865c34 | 588 | Bool_t meanother = kFALSE; |
b3fcfd96 | 589 | // enough statistics |
590 | if ((nbtg > 0) && | |
591 | (nbfit >= 0.5*nbE) && (nbE > 30)) { | |
592 | // create the cal objects | |
54f2ff1c | 593 | if(!fBackCorrectGain) { |
4c865c34 | 594 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
595 | meanother = kTRUE; | |
596 | } | |
b3fcfd96 | 597 | TObjArray object = calibra->GetVectorFit(); |
4c865c34 | 598 | AliTRDCalDet *calDetGain = calibra->CreateDetObjectGain(&object,meanother); |
b3fcfd96 | 599 | TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet(); |
600 | // Put them in the array | |
601 | fCalibObjects->AddAt(calDetGain,kGain); | |
602 | fPlots->AddAt(coefGain,kGain); | |
603 | // | |
604 | ok = kTRUE; | |
605 | } | |
54f2ff1c | 606 | else { |
607 | fNotEnoughStatisticsForTheGain = kTRUE; | |
dee5f636 | 608 | Int_t minStatsGain = fMinStatsGain*30; |
609 | calibra->SetMinEntries(minStatsGain); // Because we do it for all, we increase this | |
54f2ff1c | 610 | Double_t gainoverallnotnormalized = calibra->AnalyseCHAllTogether(fCH2d); |
611 | if(fCalDetGainUsed && (gainoverallnotnormalized > 0.0)) { | |
612 | AliTRDCalDet *calDetGain = new AliTRDCalDet(*fCalDetGainUsed); | |
613 | Double_t oldmean = fCalDetGainUsed->CalcMean(kFALSE); | |
614 | //printf("oldmean %f\n",oldmean); | |
615 | if(oldmean > 0.0) { | |
616 | Double_t scalefactor = calibra->GetScaleFactorGain(); | |
617 | //printf("Correction factor %f\n",gainoverallnotnormalized*scalefactor); | |
618 | calDetGain->Multiply(gainoverallnotnormalized*scalefactor/oldmean); | |
619 | //printf("newmean %f\n",calDetGain->CalcMean(kFALSE)); | |
620 | TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet(); | |
621 | fCalibObjects->AddAt(calDetGain,kGain); | |
622 | fPlots->AddAt(coefGain,kGain); | |
623 | // | |
624 | ok = kTRUE; | |
82b413fd | 625 | fStatusNeg = fStatusNeg | kGainNotEnoughStatsButFill; |
54f2ff1c | 626 | } |
627 | else { | |
82b413fd | 628 | fStatusPos = fStatusPos | kGainErrorOld; |
54f2ff1c | 629 | } |
630 | } | |
631 | else { | |
82b413fd | 632 | if(gainoverallnotnormalized <= 0.0) fStatusNeg = fStatusNeg | kGainNotEnoughStatsNotFill; |
633 | if(!fCalDetGainUsed) fStatusPos = fStatusPos | kGainErrorOld; | |
54f2ff1c | 634 | } |
635 | } | |
b3fcfd96 | 636 | |
637 | calibra->ResetVectorFit(); | |
638 | ||
639 | return ok; | |
640 | ||
641 | } | |
00d203b6 | 642 | //_____________________________________________________________________________________________________ |
b3fcfd96 | 643 | Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){ |
644 | // | |
645 | // Analyze VdriftT0 - produce the calibration objects | |
646 | // | |
647 | ||
648 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
a2a4ec8e | 649 | calibra->SetMinEntries(fMinStatsVdriftT0PH); // If there is less than 1000 entries in the histo: no fit |
b3fcfd96 | 650 | calibra->AnalysePH(fPH2d); |
651 | ||
652 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
653 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
654 | Int_t nbfit = calibra->GetNumberFit(); | |
655 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); | |
656 | Int_t nbE = calibra->GetNumberEnt(); | |
657 | ||
658 | //printf("nbtg %d, nbfit %d, nbE %d, nbfitSuccess %d\n",nbtg,nbfit,nbE,nbfitSuccess); | |
659 | ||
660 | Bool_t ok = kFALSE; | |
661 | if ((nbtg > 0) && | |
662 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { | |
663 | //printf("Pass the cut for VdriftT0\n"); | |
664 | // create the cal objects | |
01239968 | 665 | calibra->RemoveOutliers(1,kFALSE); |
666 | calibra->PutMeanValueOtherVectorFit(1,kFALSE); | |
667 | calibra->RemoveOutliers2(kFALSE); | |
668 | calibra->PutMeanValueOtherVectorFit2(1,kFALSE); | |
669 | // | |
b3fcfd96 | 670 | TObjArray object = calibra->GetVectorFit(); |
671 | AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object); | |
672 | TH1F *coefVdriftPH = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
673 | AliTRDCalPad *calPadVdrift = (AliTRDCalPad *)calibra->CreatePadObjectVdrift(&object,calDetVdrift); | |
674 | TH1F *coefPadVdrift = calPadVdrift->MakeHisto1D(); | |
675 | object = calibra->GetVectorFit2(); | |
676 | AliTRDCalDet *calDetT0 = calibra->CreateDetObjectT0(&object); | |
677 | TH1F *coefT0 = calDetT0->MakeHisto1DAsFunctionOfDet(); | |
678 | AliTRDCalPad *calPadT0 = (AliTRDCalPad *)calibra->CreatePadObjectT0(&object,calDetT0); | |
679 | TH1F *coefPadT0 = calPadT0->MakeHisto1D(); | |
680 | // Put them in the array | |
681 | fCalibObjects->AddAt(calDetT0,kT0PHDet); | |
682 | fCalibObjects->AddAt(calDetVdrift,kVdriftPHDet); | |
683 | fCalibObjects->AddAt(calPadT0,kT0PHPad); | |
684 | fCalibObjects->AddAt(calPadVdrift,kVdriftPHPad); | |
685 | fPlots->AddAt(coefVdriftPH,kVdriftPHDet); | |
686 | fPlots->AddAt(coefT0,kT0PHDet); | |
687 | fPlots->AddAt(coefPadVdrift,kVdriftPHPad); | |
688 | fPlots->AddAt(coefPadT0,kT0PHPad); | |
689 | // | |
690 | ok = kTRUE; | |
691 | } | |
54f2ff1c | 692 | else { |
840ec79d | 693 | //printf("Not enough stats timeoffset\n"); |
82b413fd | 694 | fStatusNeg = fStatusNeg | kTimeOffsetNotEnoughStatsNotFill; |
54f2ff1c | 695 | } |
b3fcfd96 | 696 | calibra->ResetVectorFit(); |
697 | ||
698 | return ok; | |
699 | ||
700 | } | |
00d203b6 | 701 | //____________________________________________________________________________________________________________________ |
b3fcfd96 | 702 | Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){ |
703 | // | |
704 | // Analyze vdrift linear fit - produce the calibration objects | |
705 | // | |
706 | ||
a5dcf618 | 707 | //printf("Analyse linear fit\n"); |
708 | ||
f558cb62 | 709 | |
b3fcfd96 | 710 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
840ec79d | 711 | calibra->SetCalDetVdriftExB(fCalDetVdriftUsed,fCalDetExBUsed); |
a2a4ec8e | 712 | calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit |
a5dcf618 | 713 | //printf("Fill PE Array\n"); |
2a1a7b36 | 714 | fAliTRDCalibraVdriftLinearFit->SetRobustFit(fRobustFitDriftVelocity); |
661c7be6 | 715 | if(!fAlternativeVdrfitFit) |
716 | fAliTRDCalibraVdriftLinearFit->FillPEArray(); | |
717 | else | |
718 | fAliTRDCalibraVdriftLinearFit->FillPEArray2(); | |
a5dcf618 | 719 | //printf("AliTRDCalibraFit\n"); |
b3fcfd96 | 720 | calibra->AnalyseLinearFitters(fAliTRDCalibraVdriftLinearFit); |
a5dcf618 | 721 | //printf("After\n"); |
b3fcfd96 | 722 | |
723 | //Int_t nbtg = 540; | |
724 | Int_t nbfit = calibra->GetNumberFit(); | |
725 | Int_t nbE = calibra->GetNumberEnt(); | |
726 | ||
727 | ||
728 | Bool_t ok = kFALSE; | |
729 | // enough statistics | |
730 | if ((nbfit >= 0.5*nbE) && (nbE > 30)) { | |
731 | // create the cal objects | |
01239968 | 732 | //calibra->RemoveOutliers(1,kTRUE); |
733 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); | |
734 | //calibra->RemoveOutliers2(kTRUE); | |
735 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
736 | // | |
b3fcfd96 | 737 | TObjArray object = calibra->GetVectorFit(); |
738 | AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
739 | TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
740 | object = calibra->GetVectorFit2(); | |
741 | AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectLorentzAngle(&object); | |
742 | TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet(); | |
eec29d56 | 743 | //if(!calDetLorentz) printf("No lorentz created\n"); |
b3fcfd96 | 744 | // Put them in the array |
745 | fCalibObjects->AddAt(calDetVdrift,kVdriftLinear); | |
746 | fCalibObjects->AddAt(calDetLorentz,kLorentzLinear); | |
747 | fPlots->AddAt(coefDriftLinear,kVdriftLinear); | |
748 | fPlots->AddAt(coefLorentzAngle,kLorentzLinear); | |
749 | // | |
750 | ok = kTRUE; | |
751 | } | |
54f2ff1c | 752 | else { |
753 | fNotEnoughStatisticsForTheVdriftLinear = kTRUE; | |
dee5f636 | 754 | Int_t minNumberOfEntriesForAll = fMinStatsVdriftLinear*30; |
755 | calibra->SetMinEntries(minNumberOfEntriesForAll); // Because we do it for all, we increase this | |
840ec79d | 756 | Double_t vdriftoverall = -100.0; |
757 | Double_t exboverall = 100.0; | |
758 | calibra->AnalyseLinearFittersAllTogether(fAliTRDCalibraVdriftLinearFit,vdriftoverall,exboverall); | |
759 | //printf("Found mean vdrift %f and exb %f\n",vdriftoverall,exboverall); | |
760 | if(fCalDetVdriftUsed && (vdriftoverall > 0.0) && (exboverall < 70.0)) { | |
54f2ff1c | 761 | AliTRDCalDet *calDetVdrift = new AliTRDCalDet(*fCalDetVdriftUsed); |
840ec79d | 762 | AliTRDCalDet *calDetLorentz = new AliTRDCalDet(*fCalDetExBUsed); |
763 | Double_t oldmeanvdrift = fCalDetVdriftUsed->CalcMean(kFALSE); | |
764 | Double_t oldmeanexb = fCalDetExBUsed->CalcMean(kFALSE); | |
54f2ff1c | 765 | //printf("oldmean %f\n",oldmean); |
840ec79d | 766 | if((oldmeanvdrift > 0.0) && (oldmeanexb < 70.0)) { |
54f2ff1c | 767 | //printf("Correction factor %f\n",vdriftoverall); |
840ec79d | 768 | calDetVdrift->Multiply(vdriftoverall/oldmeanvdrift); |
769 | calDetLorentz->Multiply(exboverall/oldmeanexb); | |
54f2ff1c | 770 | //printf("newmean %f\n",calDetVdrift->CalcMean(kFALSE)); |
771 | TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
840ec79d | 772 | TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet(); |
54f2ff1c | 773 | // Put them in the array |
774 | fCalibObjects->AddAt(calDetVdrift,kVdriftLinear); | |
840ec79d | 775 | fCalibObjects->AddAt(calDetLorentz,kLorentzLinear); |
54f2ff1c | 776 | fPlots->AddAt(coefDriftLinear,kVdriftLinear); |
840ec79d | 777 | fPlots->AddAt(coefLorentzAngle,kLorentzLinear); |
54f2ff1c | 778 | // |
779 | ok = kTRUE; | |
82b413fd | 780 | fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsButFill; |
54f2ff1c | 781 | } |
82b413fd | 782 | else { |
840ec79d | 783 | if(oldmeanvdrift) fStatusPos = fStatusPos | kVdriftErrorOld; |
784 | if(oldmeanexb) fStatusPos = fStatusPos | kExBErrorOld; | |
82b413fd | 785 | } |
786 | } | |
787 | else { | |
840ec79d | 788 | if((vdriftoverall <= 0.0) && (exboverall > 70.0)) fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsNotFill; |
82b413fd | 789 | if(!fCalDetVdriftUsed) fStatusPos = fStatusPos | kVdriftErrorOld; |
840ec79d | 790 | if(!fCalDetExBUsed) fStatusPos = fStatusPos | kExBErrorOld; |
54f2ff1c | 791 | } |
54f2ff1c | 792 | } |
b3fcfd96 | 793 | |
794 | calibra->ResetVectorFit(); | |
795 | ||
796 | return ok; | |
797 | ||
798 | } | |
00d203b6 | 799 | //________________________________________________________________________________________________________________ |
b3fcfd96 | 800 | |
a0bb5615 | 801 | Bool_t AliTRDPreprocessorOffline::AnalyzeExbAltFit(){ |
802 | // | |
803 | // Analyze vdrift linear fit - produce the calibration objects | |
804 | // | |
805 | ||
806 | //printf("Analyse linear fit\n"); | |
807 | ||
808 | ||
809 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
810 | calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit | |
811 | //printf("Fill PE Array\n"); | |
2a1a7b36 | 812 | fAliTRDCalibraExbAltFit->SetRobustFit(fRobustFitExbAlt); |
661c7be6 | 813 | if(!fAlternativeExbAltFit) |
814 | fAliTRDCalibraExbAltFit->FillPEArray(); | |
815 | else | |
816 | fAliTRDCalibraExbAltFit->FillPEArray2(); | |
a0bb5615 | 817 | //printf("AliTRDCalibraFit\n"); |
818 | calibra->AnalyseExbAltFit(fAliTRDCalibraExbAltFit); | |
819 | //printf("After\n"); | |
820 | ||
821 | //Int_t nbtg = 540; | |
822 | Int_t nbfit = calibra->GetNumberFit(); | |
823 | Int_t nbE = calibra->GetNumberEnt(); | |
824 | ||
825 | ||
826 | Bool_t ok = kFALSE; | |
827 | // enough statistics | |
828 | if ((nbfit >= 0.5*nbE) && (nbE > 30)) { | |
829 | // create the cal objects | |
830 | //calibra->RemoveOutliers(1,kTRUE); | |
831 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
832 | // | |
833 | TObjArray object = calibra->GetVectorFit2(); | |
834 | AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectExbAlt(&object); | |
835 | TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet(); | |
836 | //if(!calDetLorentz) printf("No lorentz created\n"); | |
837 | // Put them in the array | |
838 | fCalibObjects->AddAt(calDetLorentz,kExbAlt); | |
839 | fPlots->AddAt(coefLorentzAngle,kExbAlt); | |
840 | // | |
841 | ok = kTRUE; | |
842 | } | |
843 | ||
844 | calibra->ResetVectorFit(); | |
845 | ||
846 | return ok; | |
847 | ||
848 | } | |
849 | //________________________________________________________________________________________________________________ | |
850 | ||
b3fcfd96 | 851 | Bool_t AliTRDPreprocessorOffline::AnalyzePRF(){ |
852 | // | |
853 | // Analyze PRF - produce the calibration objects | |
854 | // | |
855 | ||
856 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
a2a4ec8e | 857 | calibra->SetMinEntries(fMinStatsPRF); // If there is less than 1000 entries in the histo: no fit |
b3fcfd96 | 858 | calibra->AnalysePRFMarianFit(fPRF2d); |
859 | ||
860 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
861 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
862 | Int_t nbfit = calibra->GetNumberFit(); | |
863 | Int_t nbE = calibra->GetNumberEnt(); | |
864 | ||
865 | ||
866 | Bool_t ok = kFALSE; | |
867 | // enough statistics | |
868 | if ((nbtg > 0) && | |
869 | (nbfit >= 0.95*nbE) && (nbE > 30)) { | |
870 | // create the cal objects | |
871 | TObjArray object = calibra->GetVectorFit(); | |
872 | AliTRDCalPad *calPadPRF = (AliTRDCalPad*) calibra->CreatePadObjectPRF(&object); | |
873 | TH1F *coefPRF = calPadPRF->MakeHisto1D(); | |
874 | // Put them in the array | |
875 | fCalibObjects->AddAt(calPadPRF,kPRF); | |
876 | fPlots->AddAt(coefPRF,kPRF); | |
877 | // | |
878 | ok = kTRUE; | |
879 | } | |
880 | ||
881 | calibra->ResetVectorFit(); | |
882 | ||
883 | return ok; | |
884 | ||
885 | } | |
a5dcf618 | 886 | |
887 | //_____________________________________________________________________________ | |
888 | Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus() | |
889 | { | |
4c865c34 | 890 | // |
a5dcf618 | 891 | // Produce AliTRDCalChamberStatus out of calibration results |
4c865c34 | 892 | // |
b61b92a0 | 893 | |
83d0cc79 | 894 | // set up AliTRDCalibChamberStatus |
895 | AliTRDCalibChamberStatus *ChamberStatus = new AliTRDCalibChamberStatus(); | |
896 | ChamberStatus->SetSparseI(fSparse); | |
897 | ChamberStatus->AnalyseHisto(fMinStatsChamberStatus); | |
898 | // get AliTRDCalChamberStatus | |
899 | AliTRDCalChamberStatus *CalChamberStatus = ChamberStatus->GetCalChamberStatus(); | |
01239968 | 900 | |
a5dcf618 | 901 | // get calibration objects |
902 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
903 | AliTRDCalDet *calDetVDrift = (AliTRDCalDet *) fCalibObjects->At(kVdriftLinear); | |
840ec79d | 904 | AliTRDCalDet *calDetExB = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear); |
a5dcf618 | 905 | |
906 | // Check | |
83d0cc79 | 907 | if((!calDetGain) || (!calDetVDrift) || (!fCH2d) || (!calDetExB) || (!CalChamberStatus)) return kFALSE; |
a5dcf618 | 908 | |
909 | // Gain | |
83d0cc79 | 910 | Double_t gainmean = calDetGain->GetMean(); |
a5dcf618 | 911 | Double_t vdriftmean = calDetVDrift->GetMean(); |
83d0cc79 | 912 | Double_t exbmean = calDetExB->GetMean(); |
a5dcf618 | 913 | |
83d0cc79 | 914 | Double_t gainrms = calDetGain->GetRMSRobust(); |
915 | Double_t vdriftrms = calDetVDrift->GetRMSRobust(); | |
916 | Double_t exbrms = calDetExB->GetRMSRobust(); | |
a5dcf618 | 917 | |
918 | //printf("Gain mean: %f, rms: %f\n",gainmean,gainrms); | |
919 | //printf("Vdrift mean: %f, rms: %f\n",vdriftmean,vdriftrms); | |
840ec79d | 920 | //printf("ExB mean: %f, rms: %f\n",exbmean,exbrms); |
921 | ||
a5dcf618 | 922 | // Check |
840ec79d | 923 | if((TMath::Abs(gainrms) < 0.001) || (TMath::Abs(vdriftrms) < 0.001) || (TMath::Abs(exbrms) < 0.0000001)) return kFALSE; |
01239968 | 924 | |
a5dcf618 | 925 | // mask chambers with empty gain entries |
926 | //Int_t counter = 0; | |
927 | for (Int_t idet = 0; idet < 540; idet++) { | |
01239968 | 928 | |
a5dcf618 | 929 | // ch2d |
930 | TH1I *projch = (TH1I *) fCH2d->ProjectionX("projch",idet+1,idet+1,(Option_t *)"e"); | |
931 | Double_t entries = projch->GetEntries(); | |
83d0cc79 | 932 | //printf("Number of entries %f for det %d\n",entries,idet); |
4c865c34 | 933 | |
a5dcf618 | 934 | // gain |
935 | Double_t gain = calDetGain->GetValue(idet); | |
4c865c34 | 936 | |
a5dcf618 | 937 | // vdrift |
938 | Double_t vdrift = calDetVDrift->GetValue(idet); | |
4c865c34 | 939 | |
840ec79d | 940 | // exb |
941 | Double_t exb = calDetExB->GetValue(idet); | |
942 | ||
4c865c34 | 943 | |
83d0cc79 | 944 | if( (entries<50 && !CalChamberStatus->IsNoData(idet)) || |
945 | TMath::Abs(gainmean-gain) > (fRMSBadCalibratedGain*gainrms) || | |
946 | TMath::Abs(vdriftmean-vdrift) > (fRMSBadCalibratedVdrift*vdriftrms) || | |
947 | TMath::Abs(exbmean-exb) > (fRMSBadCalibratedExB*exbrms) ) { | |
a5dcf618 | 948 | |
949 | //printf(" chamber det %03d masked \n",idet); | |
950 | //printf(" gainmean %f and gain %f, gainrms %f \n",gainmean,gain,gainrms); | |
951 | //printf(" vdriftmean %f and vdrift %f, vdriftrms %f \n",vdriftmean,vdrift,vdriftrms); | |
840ec79d | 952 | //printf(" exbmean %f and exb %f, exbrms %f \n",exbmean,exb,exbrms); |
953 | ||
83d0cc79 | 954 | CalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kBadCalibrated); |
a5dcf618 | 955 | //counter++; |
956 | } | |
4c865c34 | 957 | |
b61b92a0 | 958 | delete projch; |
959 | ||
a5dcf618 | 960 | } |
b3fcfd96 | 961 | |
83d0cc79 | 962 | // Security |
963 | for(Int_t sm=0; sm < 18; sm++) { | |
964 | Int_t smnodata = 0; | |
965 | Int_t smbadcalib = 0; | |
966 | for(Int_t det = 0; det < 30; det++){ | |
967 | Int_t detector = sm*30+det; | |
968 | if(CalChamberStatus->IsNoData(detector)) smnodata++; | |
969 | else { | |
970 | if(CalChamberStatus->IsBadCalibrated(detector)) smbadcalib++; | |
971 | } | |
972 | } | |
973 | fNoData[sm] = smnodata; | |
974 | fBadCalib[sm]= smbadcalib; | |
975 | //printf("No Data %d, bad calibrated %d for %d\n",fNoData[sm],fBadCalib[sm],sm); | |
976 | } | |
977 | ||
978 | // Security | |
979 | // for(Int_t sm=0; sm < 18; sm++) { | |
980 | // Int_t counter = 0; | |
981 | // for(Int_t det = 0; det < 30; det++){ | |
982 | // Int_t detector = sm*30+det; | |
983 | // if(CalChamberStatus->IsBadCalibrated(detector)) counter++; | |
984 | // } | |
985 | // if(counter >= 20) { | |
986 | // for(Int_t det = 0; det < 30; det++){ | |
987 | // Int_t detector = sm*30+det; | |
988 | // CalChamberStatus->SetStatus(detector,AliTRDCalChamberStatus::kGood); | |
989 | // } | |
990 | // } | |
991 | // } | |
b3fcfd96 | 992 | |
a5dcf618 | 993 | fCalibObjects->AddAt(CalChamberStatus,kChamberStatus); |
994 | return kTRUE; | |
b3fcfd96 | 995 | |
a5dcf618 | 996 | } |
b3fcfd96 | 997 | |
b3fcfd96 | 998 | |
a5dcf618 | 999 | //________________________________________________________________________________________________ |
1000 | void AliTRDPreprocessorOffline::CorrectFromDetGainUsed() { | |
1001 | // | |
1002 | // Correct from the gas gain used afterwards | |
1003 | // | |
1004 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
1005 | if(!calDetGain) return; | |
b3fcfd96 | 1006 | |
a5dcf618 | 1007 | // Calculate mean |
1008 | Double_t mean = 0.0; | |
1009 | Int_t nbdet = 0; | |
b3fcfd96 | 1010 | |
a5dcf618 | 1011 | for(Int_t det = 0; det < 540; det++) { |
00d203b6 | 1012 | |
a5dcf618 | 1013 | Float_t gaininit = fCalDetGainUsed->GetValue(det); |
1014 | Float_t gainout = calDetGain->GetValue(det); | |
00d203b6 | 1015 | |
00d203b6 | 1016 | |
a5dcf618 | 1017 | if(TMath::Abs(gainout-1.0) > 0.000001) { |
1018 | mean += (gaininit*gainout); | |
1019 | nbdet++; | |
1020 | } | |
1021 | } | |
1022 | if(nbdet > 0) mean = mean/nbdet; | |
00d203b6 | 1023 | |
a5dcf618 | 1024 | for(Int_t det = 0; det < 540; det++) { |
00d203b6 | 1025 | |
a5dcf618 | 1026 | Float_t gaininit = fCalDetGainUsed->GetValue(det); |
1027 | Float_t gainout = calDetGain->GetValue(det); | |
1028 | ||
ba1aa7a7 | 1029 | if(TMath::Abs(gainout-1.0) > 0.000001) { |
1030 | Double_t newgain = gaininit*gainout; | |
1031 | if(newgain < 0.1) newgain = 0.1; | |
58e2b572 | 1032 | if(newgain > 1.9) newgain = 1.9; |
ba1aa7a7 | 1033 | calDetGain->SetValue(det,newgain); |
1034 | } | |
1035 | else { | |
1036 | Double_t newgain = mean; | |
1037 | if(newgain < 0.1) newgain = 0.1; | |
58e2b572 | 1038 | if(newgain > 1.9) newgain = 1.9; |
ba1aa7a7 | 1039 | calDetGain->SetValue(det,newgain); |
1040 | } | |
a5dcf618 | 1041 | } |
1042 | ||
1043 | ||
1044 | } | |
1045 | //________________________________________________________________________________________________ | |
1046 | void AliTRDPreprocessorOffline::CorrectFromDetVdriftUsed() { | |
1047 | // | |
1048 | // Correct from the drift velocity | |
1049 | // | |
1050 | ||
1051 | //printf("Correct for vdrift\n"); | |
1052 | ||
1053 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
1054 | if(!calDetGain) return; | |
1055 | ||
1056 | Int_t detVdrift = kVdriftPHDet; | |
1057 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
1058 | AliTRDCalDet *calDetVdrift = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
1059 | if(!calDetVdrift) return; | |
1060 | ||
1061 | // Calculate mean | |
8dac2af1 | 1062 | if(!fNotEnoughStatisticsForTheVdriftLinear) { |
54f2ff1c | 1063 | for(Int_t det = 0; det < 540; det++) { |
1064 | ||
1065 | Float_t vdriftinit = fCalDetVdriftUsed->GetValue(det); | |
1066 | Float_t vdriftout = calDetVdrift->GetValue(det); | |
1067 | ||
1068 | Float_t gain = calDetGain->GetValue(det); | |
1069 | if(vdriftout > 0.0) gain = gain*vdriftinit/vdriftout; | |
1070 | if(gain < 0.1) gain = 0.1; | |
1071 | if(gain > 1.9) gain = 1.9; | |
1072 | calDetGain->SetValue(det,gain); | |
1073 | } | |
a5dcf618 | 1074 | } |
54f2ff1c | 1075 | else { |
1076 | ||
1077 | Float_t vdriftinit = fCalDetVdriftUsed->CalcMean(kFALSE); | |
1078 | Float_t vdriftout = calDetVdrift->CalcMean(kFALSE); | |
1079 | Float_t factorcorrectif = 1.0; | |
1080 | if(vdriftout > 0.0) factorcorrectif = vdriftinit/vdriftout; | |
1081 | for(Int_t det = 0; det < 540; det++) { | |
1082 | Float_t gain = calDetGain->GetValue(det); | |
1083 | gain = gain*factorcorrectif; | |
1084 | if(gain < 0.1) gain = 0.1; | |
1085 | if(gain > 1.9) gain = 1.9; | |
1086 | calDetGain->SetValue(det,gain); | |
1087 | } | |
1088 | ||
1089 | } | |
1090 | ||
a5dcf618 | 1091 | } |
54f2ff1c | 1092 | //_________________________________________________________________________________________________________________ |
a5dcf618 | 1093 | void AliTRDPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ |
1094 | // | |
1095 | // Update OCDB entry | |
1096 | // | |
1097 | ||
1098 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1099 | metaData->SetObjectClassName("AliTRDCalDet"); | |
1100 | metaData->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1101 | metaData->AddDateToComment(); |
a5dcf618 | 1102 | metaData->SetBeamPeriod(1); |
1103 | ||
1104 | AliCDBId id1("TRD/Calib/ChamberGainFactor", startRunNumber, endRunNumber); | |
1105 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1106 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
1107 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
1108 | ||
1109 | ||
eec29d56 | 1110 | } |
1111 | //___________________________________________________________________________________________________________________ | |
1112 | void AliTRDPreprocessorOffline::UpdateOCDBExB(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
1113 | // | |
1114 | // Update OCDB entry | |
1115 | // | |
1116 | ||
1117 | Int_t detExB = kLorentzLinear; | |
1118 | if(!fMethodSecond) return; | |
1119 | ||
1120 | //printf("Pass\n"); | |
1121 | ||
1122 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1123 | metaData->SetObjectClassName("AliTRDCalDet"); | |
1124 | metaData->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1125 | metaData->AddDateToComment(); |
eec29d56 | 1126 | metaData->SetBeamPeriod(1); |
1127 | ||
1128 | AliCDBId id1("TRD/Calib/ChamberExB", startRunNumber, endRunNumber); | |
1129 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1130 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detExB); | |
1131 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
1132 | //if(!calDet) printf("No caldet\n"); | |
1133 | ||
a5dcf618 | 1134 | } |
a0bb5615 | 1135 | //___________________________________________________________________________________________________________________ |
1136 | void AliTRDPreprocessorOffline::UpdateOCDBExBAlt(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
1137 | // | |
1138 | // Update OCDB entry | |
1139 | // | |
1140 | ||
1141 | Int_t detExB = kExbAlt; | |
1142 | if(!fMethodSecond) return; | |
1143 | ||
1144 | //printf("Pass\n"); | |
1145 | ||
1146 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1147 | metaData->SetObjectClassName("AliTRDCalDet"); | |
58006729 | 1148 | metaData->SetResponsible("Theo Rascanu"); |
1149 | metaData->AddDateToComment(); | |
a0bb5615 | 1150 | metaData->SetBeamPeriod(1); |
1151 | ||
1152 | AliCDBId id1("TRD/Calib/ChamberExBAlt", startRunNumber, endRunNumber); | |
1153 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1154 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detExB); | |
1155 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
1156 | //if(!calDet) printf("No caldet\n"); | |
1157 | ||
1158 | } | |
a5dcf618 | 1159 | //___________________________________________________________________________________________________________________ |
1160 | void AliTRDPreprocessorOffline::UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
1161 | // | |
1162 | // Update OCDB entry | |
1163 | // | |
1164 | ||
1165 | Int_t detVdrift = kVdriftPHDet; | |
1166 | ||
1167 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
1168 | ||
1169 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1170 | metaData->SetObjectClassName("AliTRDCalDet"); | |
1171 | metaData->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1172 | metaData->AddDateToComment(); |
a5dcf618 | 1173 | metaData->SetBeamPeriod(1); |
1174 | ||
1175 | AliCDBId id1("TRD/Calib/ChamberVdrift", startRunNumber, endRunNumber); | |
1176 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1177 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
1178 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
1179 | ||
1180 | // | |
1181 | ||
1182 | if(!fMethodSecond) { | |
1183 | ||
1184 | AliCDBMetaData *metaDataPad= new AliCDBMetaData(); | |
1185 | metaDataPad->SetObjectClassName("AliTRDCalPad"); | |
1186 | metaDataPad->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1187 | metaDataPad->AddDateToComment(); |
a5dcf618 | 1188 | metaDataPad->SetBeamPeriod(1); |
1189 | ||
1190 | AliCDBId id1Pad("TRD/Calib/LocalVdrift", startRunNumber, endRunNumber); | |
1191 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad); | |
1192 | if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad); | |
1193 | ||
1194 | } | |
1195 | ||
1196 | } | |
1197 | //________________________________________________________________________________________________________________________ | |
1198 | void AliTRDPreprocessorOffline::UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
1199 | // | |
1200 | // Update OCDB entry | |
1201 | // | |
1202 | ||
1203 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1204 | metaData->SetObjectClassName("AliTRDCalDet"); | |
1205 | metaData->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1206 | metaData->AddDateToComment(); |
a5dcf618 | 1207 | metaData->SetBeamPeriod(1); |
1208 | ||
1209 | AliCDBId id1("TRD/Calib/ChamberT0", startRunNumber, endRunNumber); | |
1210 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1211 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet); | |
1212 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
1213 | ||
1214 | // | |
1215 | ||
1216 | AliCDBMetaData *metaDataPad= new AliCDBMetaData(); | |
1217 | metaDataPad->SetObjectClassName("AliTRDCalPad"); | |
1218 | metaDataPad->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1219 | metaDataPad->AddDateToComment(); |
a5dcf618 | 1220 | metaDataPad->SetBeamPeriod(1); |
1221 | ||
1222 | AliCDBId id1Pad("TRD/Calib/LocalT0", startRunNumber, endRunNumber); | |
1223 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad); | |
1224 | if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad); | |
1225 | ||
1226 | ||
1227 | ||
1228 | } | |
1229 | //_________________________________________________________________________________________________________________ | |
1230 | void AliTRDPreprocessorOffline::UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
1231 | // | |
1232 | // Update OCDB entry | |
1233 | // | |
1234 | ||
1235 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1236 | metaData->SetObjectClassName("AliTRDCalPad"); | |
1237 | metaData->SetResponsible("Raphaelle Bailhache"); | |
58006729 | 1238 | metaData->AddDateToComment(); |
a5dcf618 | 1239 | metaData->SetBeamPeriod(1); |
1240 | ||
58006729 | 1241 | |
a5dcf618 | 1242 | AliCDBId id1("TRD/Calib/PRFWidth", startRunNumber, endRunNumber); |
1243 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1244 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF); | |
1245 | if(calPad) gStorage->Put(calPad, id1, metaData); | |
1246 | ||
1247 | ||
1248 | } | |
1249 | //_________________________________________________________________________________________________________________ | |
1250 | void AliTRDPreprocessorOffline::UpdateOCDBChamberStatus(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
1251 | // | |
1252 | // Update OCDB entry | |
1253 | // | |
1254 | ||
1255 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
1256 | metaData->SetObjectClassName("AliTRDCalChamberStatus"); | |
58006729 | 1257 | metaData->SetResponsible("Raphaelle Bailhache and Julian Book"); |
1258 | metaData->AddDateToComment(); | |
a5dcf618 | 1259 | metaData->SetBeamPeriod(1); |
1260 | ||
1261 | AliCDBId id1("TRD/Calib/ChamberStatus", startRunNumber, endRunNumber); | |
1262 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
1263 | AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus); | |
1264 | if(calChamberStatus) gStorage->Put(calChamberStatus, id1, metaData); | |
1265 | ||
1266 | ||
1267 | } | |
1268 | //__________________________________________________________________________________________________________________________ | |
54f2ff1c | 1269 | Bool_t AliTRDPreprocessorOffline::ValidateGain() { |
a5dcf618 | 1270 | // |
1271 | // Validate OCDB entry | |
1272 | // | |
1273 | ||
1274 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
1275 | if(calDet) { | |
1276 | Double_t mean = calDet->GetMean(); | |
1277 | Double_t rms = calDet->GetRMSRobust(); | |
1278 | if((mean > 0.2) && (mean < 1.4) && (rms < 0.5)) return kTRUE; | |
1279 | //if((mean > 0.2) && (mean < 1.4)) return kTRUE; | |
54f2ff1c | 1280 | else { |
82b413fd | 1281 | fStatusPos = fStatusPos | kGainErrorRange; |
54f2ff1c | 1282 | return kFALSE; |
1283 | } | |
a5dcf618 | 1284 | } |
1285 | else return kFALSE; | |
54f2ff1c | 1286 | |
a5dcf618 | 1287 | |
1288 | ||
1289 | } | |
1290 | //__________________________________________________________________________________________________________________________ | |
1291 | Bool_t AliTRDPreprocessorOffline::ValidateVdrift(){ | |
1292 | // | |
1293 | // Update OCDB entry | |
1294 | // | |
1295 | ||
1296 | Int_t detVdrift = kVdriftPHDet; | |
1297 | Bool_t ok = kTRUE; | |
1298 | ||
1299 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
1300 | ||
1301 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
1302 | if(calDet) { | |
1303 | Double_t mean = calDet->GetMean(); | |
1304 | Double_t rms = calDet->GetRMSRobust(); | |
1305 | //printf("Vdrift::mean %f, rms %f\n",mean,rms); | |
54f2ff1c | 1306 | if(!((mean > 1.0) && (mean < 2.0) && (rms < 0.5))) { |
82b413fd | 1307 | fStatusPos = fStatusPos | kVdriftErrorRange; |
54f2ff1c | 1308 | ok = kFALSE; |
1309 | } | |
a5dcf618 | 1310 | } |
1311 | else return kFALSE; | |
1312 | ||
1313 | if(!fMethodSecond) { | |
1314 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad); | |
1315 | if(calPad) { | |
1316 | Double_t mean = calPad->GetMean(); | |
1317 | Double_t rms = calPad->GetRMS(); | |
1318 | //printf("Vdrift::meanpad %f, rmspad %f\n",mean,rms); | |
54f2ff1c | 1319 | if(!((mean > 0.9) && (mean < 1.1) && (rms < 0.6))) { |
82b413fd | 1320 | fStatusPos = fStatusPos | kVdriftErrorRange; |
54f2ff1c | 1321 | ok = kFALSE; |
1322 | } | |
a5dcf618 | 1323 | } |
1324 | else return kFALSE; | |
1325 | } | |
1326 | ||
1327 | return ok; | |
1328 | ||
840ec79d | 1329 | } |
1330 | //__________________________________________________________________________________________________________________________ | |
1331 | Bool_t AliTRDPreprocessorOffline::ValidateExB(){ | |
1332 | // | |
1333 | // Update OCDB entry | |
1334 | // | |
1335 | ||
1336 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear); | |
1337 | if(calDet) { | |
1338 | Double_t mean = calDet->GetMean(); | |
1339 | Double_t rms = calDet->GetRMSRobust(); | |
1340 | //printf("Vdrift::mean %f, rms %f\n",mean,rms); | |
1341 | if(!((mean > -1.0) && (mean < 1.0) && (rms < 0.5))) { | |
1342 | fStatusNeg = fStatusNeg | kExBErrorRange; | |
1343 | return kFALSE; | |
1344 | } | |
1345 | else return kTRUE; | |
1346 | } | |
1347 | else return kFALSE; | |
1348 | ||
a5dcf618 | 1349 | } |
1350 | //__________________________________________________________________________________________________________________________ | |
1351 | Bool_t AliTRDPreprocessorOffline::ValidateT0(){ | |
1352 | // | |
1353 | // Update OCDB entry | |
1354 | // | |
1355 | ||
1356 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet); | |
1357 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad); | |
1358 | if(calDet && calPad) { | |
1359 | Double_t meandet = calDet->GetMean(); | |
1360 | Double_t rmsdet = calDet->GetRMSRobust(); | |
1361 | Double_t meanpad = calPad->GetMean(); | |
1362 | //Double_t rmspad = calPad->GetRMS(); | |
1363 | //printf("T0::minimum %f, rmsdet %f,meanpad %f, rmspad %f\n",meandet,rmsdet,meanpad,rmspad); | |
1364 | if((meandet > -1.5) && (meandet < 5.0) && (rmsdet < 4.0) && (meanpad < 5.0) && (meanpad > -0.5)) return kTRUE; | |
54f2ff1c | 1365 | else { |
82b413fd | 1366 | fStatusPos = fStatusPos | kTimeOffsetErrorRange; |
54f2ff1c | 1367 | return kFALSE; |
1368 | } | |
a5dcf618 | 1369 | } |
1370 | else return kFALSE; | |
1371 | ||
1372 | } | |
1373 | //__________________________________________________________________________________________________________________________ | |
1374 | Bool_t AliTRDPreprocessorOffline::ValidatePRF() const{ | |
1375 | // | |
1376 | // Update OCDB entry | |
1377 | // | |
1378 | ||
1379 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF); | |
1380 | if(calPad) { | |
1381 | Double_t meanpad = calPad->GetMean(); | |
1382 | Double_t rmspad = calPad->GetRMS(); | |
1383 | //printf("PRF::meanpad %f, rmspad %f\n",meanpad,rmspad); | |
1384 | if((meanpad < 1.0) && (rmspad < 0.8)) return kTRUE; | |
1385 | else return kFALSE; | |
1386 | } | |
1387 | else return kFALSE; | |
1388 | ||
1389 | ||
1390 | } | |
1391 | //__________________________________________________________________________________________________________________________ | |
82b413fd | 1392 | Bool_t AliTRDPreprocessorOffline::ValidateChamberStatus(){ |
00d203b6 | 1393 | // |
1394 | // Update OCDB entry | |
1395 | // | |
1396 | ||
a5dcf618 | 1397 | AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus); |
1398 | if(calChamberStatus) { | |
83d0cc79 | 1399 | |
1400 | Int_t detectornodata = 0; | |
1401 | Int_t detectorbadcalib = 0; | |
1402 | ||
1403 | for(Int_t sm=0; sm < 18; sm++) { | |
1404 | //printf("%d chambers w/o data in sm %d\n",fNoData[sm],sm); | |
1405 | //printf("%d bad calibrated chambers in sm %d\n",fBadCalib[sm],sm); | |
1406 | if(fNoData[sm] != 30) detectornodata += fNoData[sm]; | |
1407 | detectorbadcalib+=fBadCalib[sm]; | |
a5dcf618 | 1408 | } |
83d0cc79 | 1409 | //printf("Number of chambers w/o data %d\n",detectornodata); |
1410 | //printf("Number of chambers bad calibrated %d\n",detectorbadcalib); | |
1411 | ||
1412 | if((detectornodata > fNoDataValidate) || | |
1413 | (detectorbadcalib > fBadCalibValidate)){ | |
82b413fd | 1414 | fStatusPos = fStatusPos | kChamberStatusErrorRange; |
1415 | return kFALSE; | |
1416 | } | |
83d0cc79 | 1417 | return kTRUE; |
00d203b6 | 1418 | } |
1419 | else return kFALSE; | |
83d0cc79 | 1420 | |
b3fcfd96 | 1421 | } |
4c865c34 | 1422 | //_____________________________________________________________________________ |
1423 | Int_t AliTRDPreprocessorOffline::GetVersion(TString name) const | |
1424 | { | |
1425 | // | |
1426 | // Get version from the title | |
1427 | // | |
1428 | ||
1429 | // Some patterns | |
1430 | const Char_t *version = "Ver"; | |
1431 | if(!strstr(name.Data(),version)) return -1; | |
f558cb62 | 1432 | const Char_t *after = "Subver"; |
1433 | if(!strstr(name.Data(),after)) return -1; | |
1434 | ||
4c865c34 | 1435 | for(Int_t ver = 0; ver < 999999999; ver++) { |
1436 | ||
1437 | TString vertry(version); | |
1438 | vertry += ver; | |
f558cb62 | 1439 | vertry += after; |
4c865c34 | 1440 | |
1441 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
1442 | ||
1443 | if(strstr(name.Data(),vertry.Data())) return ver; | |
1444 | ||
1445 | } | |
1446 | ||
1447 | return -1; | |
1448 | ||
1449 | } | |
1450 | ||
1451 | //_____________________________________________________________________________ | |
1452 | Int_t AliTRDPreprocessorOffline::GetSubVersion(TString name) const | |
1453 | { | |
1454 | // | |
1455 | // Get subversion from the title | |
1456 | // | |
1457 | ||
1458 | // Some patterns | |
1459 | const Char_t *subversion = "Subver"; | |
1460 | if(!strstr(name.Data(),subversion)) return -1; | |
f558cb62 | 1461 | const Char_t *after = "FirstRun"; |
1462 | if(!strstr(name.Data(),after)) { | |
1463 | after = "Nz"; | |
1464 | } | |
1465 | if(!strstr(name.Data(),after)) return -1; | |
1466 | ||
4c865c34 | 1467 | |
1468 | for(Int_t ver = 0; ver < 999999999; ver++) { | |
1469 | ||
1470 | TString vertry(subversion); | |
1471 | vertry += ver; | |
f558cb62 | 1472 | vertry += after; |
ca7e6e64 | 1473 | |
1474 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
1475 | ||
1476 | if(strstr(name.Data(),vertry.Data())) return ver; | |
1477 | ||
1478 | } | |
1479 | ||
1480 | return -1; | |
1481 | ||
1482 | } | |
1483 | ||
1484 | //_____________________________________________________________________________ | |
1485 | Int_t AliTRDPreprocessorOffline::GetFirstRun(TString name) const | |
1486 | { | |
1487 | // | |
1488 | // Get first run from the title | |
1489 | // | |
1490 | ||
1491 | // Some patterns | |
1492 | const Char_t *firstrun = "FirstRun"; | |
1493 | if(!strstr(name.Data(),firstrun)) return -1; | |
f558cb62 | 1494 | const Char_t *after = "Nz"; |
1495 | if(!strstr(name.Data(),after)) return -1; | |
1496 | ||
ca7e6e64 | 1497 | |
1498 | for(Int_t ver = 0; ver < 999999999; ver++) { | |
1499 | ||
1500 | TString vertry(firstrun); | |
1501 | vertry += ver; | |
f558cb62 | 1502 | vertry += after; |
4c865c34 | 1503 | |
1504 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
1505 | ||
1506 | if(strstr(name.Data(),vertry.Data())) return ver; | |
1507 | ||
1508 | } | |
1509 | ||
1510 | return -1; | |
1511 | ||
1512 | } | |
82b413fd | 1513 | //_____________________________________________________________________________ |
1514 | Bool_t AliTRDPreprocessorOffline::CheckStatus(Int_t status, Int_t bitMask) const | |
1515 | { | |
1516 | // | |
1517 | // Checks the status | |
1518 | // | |
1519 | ||
1520 | return (status & bitMask) ? kTRUE : kFALSE; | |
1521 | ||
1522 | } | |
1523 | //_____________________________________________________________________________ | |
1524 | Int_t AliTRDPreprocessorOffline::GetStatus() const | |
1525 | { | |
1526 | // | |
1527 | // Checks the status | |
1528 | // fStatusPos: errors | |
1529 | // fStatusNeg: only info | |
1530 | // | |
1531 | ||
1532 | if(fStatusPos > 0) return fStatusPos; | |
1533 | else return (-TMath::Abs(fStatusNeg)); | |
1534 | ||
1535 | } | |
1536 | //_____________________________________________________________________________ | |
1537 | void AliTRDPreprocessorOffline::PrintStatus() const | |
1538 | { | |
1539 | // | |
1540 | // Do Summary | |
1541 | // | |
1542 | ||
1543 | AliInfo(Form("The error status is %d",fStatusPos)); | |
1544 | AliInfo(Form("IsGainErrorOld? %d",(Int_t)IsGainErrorOld())); | |
1545 | AliInfo(Form("IsVdriftErrorOld? %d",(Int_t)IsVdriftErrorOld())); | |
1546 | AliInfo(Form("IsGainErrorRange? %d",(Int_t)IsGainErrorRange())); | |
1547 | AliInfo(Form("IsVdriftErrorRange? %d",(Int_t)IsVdriftErrorRange())); | |
1548 | AliInfo(Form("IsTimeOffsetErrorRange? %d",(Int_t)IsTimeOffsetErrorRange())); | |
1549 | AliInfo(Form("IsChamberStatusErrorRange? %d",(Int_t)IsChamberStatusErrorRange())); | |
1550 | ||
1551 | ||
1552 | AliInfo(Form("The info status is %d",fStatusNeg)); | |
1553 | AliInfo(Form("IsGainNotEnoughStatsButFill? %d",(Int_t)IsGainNotEnoughStatsButFill())); | |
1554 | AliInfo(Form("IsVdriftNotEnoughStatsButFill? %d",(Int_t)IsVdriftNotEnoughStatsButFill())); | |
1555 | AliInfo(Form("IsGainNotEnoughStatsNotFill? %d",(Int_t)IsGainNotEnoughStatsNotFill())); | |
1556 | AliInfo(Form("IsVdriftNotEnoughStatsNotFill? %d",(Int_t)IsVdriftNotEnoughStatsNotFill())); | |
1557 | AliInfo(Form("IsTimeOffsetNotEnoughStatsNotFill? %d",(Int_t)IsTimeOffsetNotEnoughStatsNotFill())); | |
840ec79d | 1558 | |
1559 | AliInfo(Form("IsExBErrorRange? %d",(Int_t)IsExBErrorRange())); | |
1560 | AliInfo(Form("IsExBErrorOld? %d",(Int_t)IsExBErrorOld())); | |
82b413fd | 1561 | |
1562 | } | |
840ec79d | 1563 | //___________________________________________________________________________________ |
1564 | void AliTRDPreprocessorOffline::SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed) | |
1565 | { | |
1566 | ||
1567 | fCalDetVdriftUsed = calDetVdriftUsed; | |
1568 | ||
1569 | fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)"); | |
1570 | for(Int_t k = 0; k < 540; k++){ | |
1571 | fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k))); | |
1572 | //printf("Set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k)); | |
1573 | } | |
1574 | ||
1575 | }; | |
83d0cc79 | 1576 | //___________________________________________________________________________________ |
1577 | Bool_t AliTRDPreprocessorOffline::SetCalDetGain(Int_t runNumber, Int_t version, Int_t subversion) | |
1578 | { | |
1579 | // | |
1580 | // Set the fCalDetGainUsed | |
1581 | // | |
1582 | ||
1583 | if((version == 0) && (subversion == 0)) return kFALSE; | |
82b413fd | 1584 | |
83d0cc79 | 1585 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",runNumber, version, subversion); |
1586 | if(!entry) { | |
1587 | AliError("Found no entry\n"); | |
1588 | fStatusPos = fStatusPos | kGainErrorOld; | |
1589 | return kFALSE; | |
1590 | } | |
1591 | //const AliCDBId id = entry->GetId(); | |
1592 | //version = id.GetVersion(); | |
1593 | //subversion = id.GetSubVersion(); | |
1594 | //printf("Found version %d and subversion %d for vdrift\n",version,subversion); | |
1595 | AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject(); | |
1596 | if(calDet) fCalDetGainUsed = calDet; | |
1597 | else { | |
1598 | fStatusPos = fStatusPos | kGainErrorOld; | |
1599 | return kFALSE; | |
1600 | } | |
1601 | ||
1602 | return kTRUE; | |
1603 | ||
1604 | } | |
1605 | //___________________________________________________________________________________ | |
1606 | Bool_t AliTRDPreprocessorOffline::SetCalDetVdriftExB(Int_t runNumber, Int_t versionv, Int_t subversionv, Int_t versionexb, Int_t subversionexb) | |
1607 | { | |
1608 | // | |
1609 | // Set the fCalDetVdriftUsed and fCalDetExBUsed | |
1610 | // | |
1611 | ||
1612 | if((versionv == 0) && (subversionv == 0)) return kFALSE; | |
1613 | ||
1614 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberVdrift",runNumber, versionv, subversionv); | |
1615 | if(!entry) { | |
1616 | AliError("Found no entry\n"); | |
1617 | fStatusPos = fStatusPos | kVdriftErrorOld; | |
1618 | return kFALSE; | |
1619 | } | |
1620 | AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject(); | |
1621 | if(calDet) fCalDetVdriftUsed = calDet; | |
1622 | else { | |
1623 | fStatusPos = fStatusPos | kVdriftErrorOld; | |
1624 | return kFALSE; | |
1625 | } | |
1626 | ||
1627 | // ExB object | |
1628 | ||
1629 | if((versionexb == 0) && (subversionexb == 0)) { | |
1630 | ||
1631 | fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)"); | |
1632 | for(Int_t k = 0; k < 540; k++){ | |
1633 | fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k))); | |
1634 | //printf("Nothing found: set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k)); | |
1635 | } | |
1636 | } | |
1637 | else { | |
1638 | ||
1639 | entry = 0x0; | |
1640 | entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberExB",runNumber, versionexb, subversionexb); | |
1641 | if(!entry) { | |
1642 | //printf("Found no entry\n"); | |
1643 | fStatusPos = fStatusPos | kExBErrorOld; | |
1644 | return kFALSE; | |
1645 | } | |
1646 | AliTRDCalDet* calDetexb = (AliTRDCalDet *)entry->GetObject(); | |
1647 | if(!calDetexb) { | |
1648 | fStatusPos = fStatusPos | kExBErrorOld; | |
1649 | return kFALSE; | |
1650 | } | |
1651 | ||
1652 | Double_t meanexb = calDetexb->GetMean(); | |
1653 | //printf("Mean value %f\n",meanexb); | |
1654 | if((meanexb > 70) || (fNoExBUsedInReco)) { | |
1655 | fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)"); | |
1656 | for(Int_t k = 0; k < 540; k++){ | |
1657 | fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k))); | |
1658 | //printf("Found but: set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k)); | |
1659 | } | |
1660 | } | |
1661 | else { | |
1662 | fCalDetExBUsed = calDetexb; | |
1663 | } | |
1664 | ||
1665 | } | |
1666 | ||
1667 | ||
1668 | return kTRUE; | |
1669 | ||
1670 | } | |
01239968 | 1671 |