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