]>
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" | |
49 | #include "TProfile2D.h" | |
50 | #include "AliTRDCalDet.h" | |
51 | #include "AliTRDCalPad.h" | |
52 | #include "AliCDBMetaData.h" | |
53 | #include "AliCDBId.h" | |
54 | #include "AliCDBManager.h" | |
55 | #include "AliCDBStorage.h" | |
56 | #include "AliTRDCalibraMode.h" | |
57 | #include "AliTRDCalibraFit.h" | |
58 | #include "AliTRDCalibraVdriftLinearFit.h" | |
59 | #include "AliTRDPreprocessorOffline.h" | |
60 | ||
61 | ||
62 | ClassImp(AliTRDPreprocessorOffline) | |
63 | ||
64 | AliTRDPreprocessorOffline::AliTRDPreprocessorOffline(): | |
01239968 | 65 | TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"), |
b3fcfd96 | 66 | fMethodSecond(kTRUE), |
01239968 | 67 | fNameList("TRDCalib"), |
68 | fCalDetGainUsed(0x0), | |
4c865c34 | 69 | fCalDetVdriftUsed(0x0), |
b3fcfd96 | 70 | fCH2d(0x0), |
71 | fPH2d(0x0), | |
72 | fPRF2d(0x0), | |
73 | fAliTRDCalibraVdriftLinearFit(0x0), | |
74 | fNEvents(0x0), | |
75 | fAbsoluteGain(0x0), | |
76 | fPlots(new TObjArray(8)), | |
4c865c34 | 77 | fCalibObjects(new TObjArray(8)), |
78 | fVersionGainUsed(0), | |
79 | fSubVersionGainUsed(0), | |
80 | fVersionVdriftUsed(0), | |
00d203b6 | 81 | fSubVersionVdriftUsed(0), |
82 | fSwitchOnValidation(kTRUE), | |
83 | fVdriftValidated(kFALSE), | |
84 | fT0Validated(kFALSE) | |
b3fcfd96 | 85 | { |
86 | // | |
87 | // default constructor | |
88 | // | |
89 | } | |
00d203b6 | 90 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 91 | AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() { |
92 | // | |
93 | // Destructor | |
94 | // | |
95 | ||
01239968 | 96 | if(fCalDetGainUsed) delete fCalDetGainUsed; |
4c865c34 | 97 | if(fCalDetVdriftUsed) delete fCalDetVdriftUsed; |
b3fcfd96 | 98 | if(fCH2d) delete fCH2d; |
99 | if(fPH2d) delete fPH2d; | |
100 | if(fPRF2d) delete fPRF2d; | |
101 | if(fAliTRDCalibraVdriftLinearFit) delete fAliTRDCalibraVdriftLinearFit; | |
102 | if(fNEvents) delete fNEvents; | |
103 | if(fAbsoluteGain) delete fAbsoluteGain; | |
104 | if(fPlots) delete fPlots; | |
105 | if(fCalibObjects) delete fCalibObjects; | |
106 | ||
107 | } | |
00d203b6 | 108 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 109 | |
110 | void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
111 | // | |
112 | // make calibration of the drift velocity | |
113 | // Input parameters: | |
114 | // file - the location of input file | |
115 | // startRunNumber, endRunNumber - run validity period | |
116 | // ocdbStorage - path to the OCDB storage | |
117 | // - if empty - local storage 'pwd' uesed | |
118 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
119 | // | |
120 | // 1. Initialization | |
121 | // | |
008817a3 | 122 | fVdriftValidated = kTRUE; |
123 | fT0Validated = kTRUE; | |
b3fcfd96 | 124 | // |
125 | // 2. extraction of the information | |
126 | // | |
127 | if(ReadVdriftT0Global(file)) AnalyzeVdriftT0(); | |
128 | if(ReadVdriftLinearFitGlobal(file)) AnalyzeVdriftLinearFit(); | |
129 | // | |
130 | // 3. Append QA plots | |
131 | // | |
132 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
133 | // | |
134 | // | |
00d203b6 | 135 | // 4. validate OCDB entries |
b3fcfd96 | 136 | // |
00d203b6 | 137 | if(fSwitchOnValidation==kTRUE && ValidateVdrift()==kFALSE) { |
138 | AliError("TRD vdrift OCDB parameters out of range!"); | |
139 | fVdriftValidated = kFALSE; | |
140 | } | |
141 | if(fSwitchOnValidation==kTRUE && ValidateT0()==kFALSE) { | |
142 | AliError("TRD t0 OCDB parameters out of range!"); | |
143 | fT0Validated = kFALSE; | |
144 | } | |
b3fcfd96 | 145 | // |
00d203b6 | 146 | // 5. update of OCDB |
147 | // | |
148 | // | |
149 | if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage); | |
150 | if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage); | |
151 | ||
b3fcfd96 | 152 | } |
00d203b6 | 153 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 154 | |
155 | void AliTRDPreprocessorOffline::CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
156 | // | |
157 | // make calibration of the drift velocity | |
158 | // Input parameters: | |
159 | // file - the location of input file | |
160 | // startRunNumber, endRunNumber - run validity period | |
161 | // ocdbStorage - path to the OCDB storage | |
162 | // - if empty - local storage 'pwd' uesed | |
163 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
164 | // | |
165 | // 1. Initialization | |
166 | if(!ReadGainGlobal(file)) return; | |
167 | // | |
168 | // | |
169 | // 2. extraction of the information | |
170 | // | |
171 | AnalyzeGain(); | |
01239968 | 172 | if(fCalDetGainUsed) CorrectFromDetGainUsed(); |
4c865c34 | 173 | if(fCalDetVdriftUsed) CorrectFromDetVdriftUsed(); |
b3fcfd96 | 174 | // |
175 | // 3. Append QA plots | |
176 | // | |
177 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
178 | // | |
179 | // | |
00d203b6 | 180 | // 4. validate OCDB entries |
181 | // | |
182 | if(fSwitchOnValidation==kTRUE && ValidateGain()==kFALSE) { | |
183 | AliError("TRD gain OCDB parameters out of range!"); | |
184 | return; | |
185 | } | |
b3fcfd96 | 186 | // |
00d203b6 | 187 | // 5. update of OCDB |
b3fcfd96 | 188 | // |
00d203b6 | 189 | // |
190 | if((!fCalDetVdriftUsed) || (fCalDetVdriftUsed && fVdriftValidated)) UpdateOCDBGain(startRunNumber,endRunNumber,ocdbStorage); | |
191 | ||
b3fcfd96 | 192 | |
193 | } | |
00d203b6 | 194 | //________________________________________________________________________________________________________________ |
b3fcfd96 | 195 | |
196 | void AliTRDPreprocessorOffline::CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
197 | // | |
198 | // make calibration of the drift velocity | |
199 | // Input parameters: | |
200 | // file - the location of input file | |
201 | // startRunNumber, endRunNumber - run validity period | |
202 | // ocdbStorage - path to the OCDB storage | |
203 | // - if empty - local storage 'pwd' uesed | |
204 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
205 | // | |
206 | // 1. Initialization | |
207 | if(!ReadPRFGlobal(file)) return; | |
208 | // | |
209 | // | |
210 | // 2. extraction of the information | |
211 | // | |
212 | AnalyzePRF(); | |
213 | // | |
214 | // 3. Append QA plots | |
215 | // | |
216 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
217 | // | |
218 | // | |
00d203b6 | 219 | // |
220 | // 4. validate OCDB entries | |
221 | // | |
222 | if(fSwitchOnValidation==kTRUE && ValidatePRF()==kFALSE) { | |
223 | AliError("TRD prf OCDB parameters out of range!"); | |
224 | return; | |
225 | } | |
226 | // | |
227 | // 5. update of OCDB | |
b3fcfd96 | 228 | // |
229 | // | |
230 | UpdateOCDBPRF(startRunNumber,endRunNumber,ocdbStorage); | |
231 | ||
232 | } | |
00d203b6 | 233 | //______________________________________________________________________________________________________ |
4c865c34 | 234 | Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){ |
235 | // | |
236 | // read the calibration used during the reconstruction | |
237 | // | |
238 | ||
239 | if(ReadVdriftT0Global(fileName)) { | |
240 | ||
241 | TString nameph = fPH2d->GetTitle(); | |
242 | fVersionVdriftUsed = GetVersion(nameph); | |
243 | fSubVersionVdriftUsed = GetSubVersion(nameph); | |
244 | ||
245 | //printf("Found Version %d, Subversion %d for vdrift\n",fVersionVdriftUsed,fSubVersionVdriftUsed); | |
246 | ||
247 | } | |
248 | ||
249 | if(ReadGainGlobal(fileName)) { | |
250 | ||
251 | TString namech = fCH2d->GetTitle(); | |
252 | fVersionGainUsed = GetVersion(namech); | |
253 | fSubVersionGainUsed = GetSubVersion(namech); | |
254 | ||
255 | //printf("Found Version %d, Subversion %d for gain\n",fVersionGainUsed,fSubVersionGainUsed); | |
256 | ||
257 | } | |
258 | ||
259 | return kTRUE; | |
260 | ||
261 | } | |
00d203b6 | 262 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 263 | |
264 | Bool_t AliTRDPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){ | |
265 | // | |
266 | // read calibration entries from file | |
267 | // | |
4c865c34 | 268 | if(fCH2d) return kTRUE; |
b3fcfd96 | 269 | TFile fcalib(fileName); |
01239968 | 270 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 271 | if (array){ |
272 | TH2I *ch2d = (TH2I *) array->FindObject("CH2d"); | |
273 | if(!ch2d) return kFALSE; | |
274 | fCH2d = (TH2I*)ch2d->Clone(); | |
275 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
276 | //fAbsoluteGain = (TH2F *) array->FindObject("AbsoluteGain"); | |
277 | }else{ | |
278 | TH2I *ch2d = (TH2I *) fcalib.Get("CH2d"); | |
279 | if(!ch2d) return kFALSE; | |
280 | fCH2d = (TH2I*)ch2d->Clone(); | |
281 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
282 | //fAbsoluteGain = (TH2F *) fcalib.Get("AbsoluteGain"); | |
283 | } | |
284 | fCH2d->SetDirectory(0); | |
285 | //printf("title of CH2d %s\n",fCH2d->GetTitle()); | |
286 | ||
287 | return kTRUE; | |
288 | ||
289 | } | |
00d203b6 | 290 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 291 | |
292 | Bool_t AliTRDPreprocessorOffline::ReadVdriftT0Global(const Char_t* fileName){ | |
293 | // | |
294 | // read calibration entries from file | |
295 | // | |
4c865c34 | 296 | if(fPH2d) return kTRUE; |
b3fcfd96 | 297 | TFile fcalib(fileName); |
01239968 | 298 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 299 | if (array){ |
300 | TProfile2D *ph2d = (TProfile2D *) array->FindObject("PH2d"); | |
301 | if(!ph2d) return kFALSE; | |
302 | fPH2d = (TProfile2D*)ph2d->Clone(); | |
303 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
304 | }else{ | |
305 | TProfile2D *ph2d = (TProfile2D *) fcalib.Get("PH2d"); | |
306 | if(!ph2d) return kFALSE; | |
307 | fPH2d = (TProfile2D*)ph2d->Clone(); | |
308 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
309 | } | |
310 | fPH2d->SetDirectory(0); | |
311 | //printf("title of PH2d %s\n",fPH2d->GetTitle()); | |
312 | ||
313 | return kTRUE; | |
314 | ||
315 | } | |
00d203b6 | 316 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 317 | |
318 | Bool_t AliTRDPreprocessorOffline::ReadVdriftLinearFitGlobal(const Char_t* fileName){ | |
319 | // | |
320 | // read calibration entries from file | |
321 | // | |
4c865c34 | 322 | if(fAliTRDCalibraVdriftLinearFit) return kTRUE; |
b3fcfd96 | 323 | TFile fcalib(fileName); |
01239968 | 324 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 325 | if (array){ |
326 | fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) array->FindObject("AliTRDCalibraVdriftLinearFit"); | |
327 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
328 | }else{ | |
329 | fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) fcalib.Get("AliTRDCalibraVdriftLinearFit"); | |
330 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
331 | } | |
332 | if(!fAliTRDCalibraVdriftLinearFit) { | |
333 | //printf("No AliTRDCalibraVdriftLinearFit\n"); | |
334 | return kFALSE; | |
335 | } | |
336 | return kTRUE; | |
337 | ||
338 | } | |
00d203b6 | 339 | //_____________________________________________________________________________________________________________ |
b3fcfd96 | 340 | |
341 | Bool_t AliTRDPreprocessorOffline::ReadPRFGlobal(const Char_t* fileName){ | |
342 | // | |
343 | // read calibration entries from file | |
344 | // | |
4c865c34 | 345 | if(fPRF2d) return kTRUE; |
b3fcfd96 | 346 | TFile fcalib(fileName); |
01239968 | 347 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 348 | if (array){ |
349 | TProfile2D *prf2d = (TProfile2D *) array->FindObject("PRF2d"); | |
350 | if(!prf2d) return kFALSE; | |
351 | fPRF2d = (TProfile2D*)prf2d->Clone(); | |
352 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
353 | }else{ | |
354 | TProfile2D *prf2d = (TProfile2D *) fcalib.Get("PRF2d"); | |
355 | if(!prf2d) return kFALSE; | |
356 | fPRF2d = (TProfile2D*)prf2d->Clone(); | |
357 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
358 | } | |
359 | fPRF2d->SetDirectory(0); | |
360 | //printf("title of PRF2d %s\n",fPRF2d->GetTitle()); | |
361 | ||
362 | return kTRUE; | |
363 | ||
364 | } | |
00d203b6 | 365 | //__________________________________________________________________________________________________________ |
b3fcfd96 | 366 | |
367 | Bool_t AliTRDPreprocessorOffline::AnalyzeGain(){ | |
368 | // | |
369 | // Analyze gain - produce the calibration objects | |
370 | // | |
371 | ||
372 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
373 | calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit | |
374 | calibra->AnalyseCH(fCH2d); | |
375 | ||
376 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
377 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
378 | Int_t nbfit = calibra->GetNumberFit(); | |
379 | Int_t nbE = calibra->GetNumberEnt(); | |
380 | ||
381 | ||
382 | Bool_t ok = kFALSE; | |
4c865c34 | 383 | Bool_t meanother = kFALSE; |
b3fcfd96 | 384 | // enough statistics |
385 | if ((nbtg > 0) && | |
386 | (nbfit >= 0.5*nbE) && (nbE > 30)) { | |
387 | // create the cal objects | |
4c865c34 | 388 | if(!fCalDetGainUsed) { |
389 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); | |
390 | meanother = kTRUE; | |
391 | } | |
b3fcfd96 | 392 | TObjArray object = calibra->GetVectorFit(); |
4c865c34 | 393 | AliTRDCalDet *calDetGain = calibra->CreateDetObjectGain(&object,meanother); |
b3fcfd96 | 394 | TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet(); |
395 | // Put them in the array | |
396 | fCalibObjects->AddAt(calDetGain,kGain); | |
397 | fPlots->AddAt(coefGain,kGain); | |
398 | // | |
399 | ok = kTRUE; | |
400 | } | |
401 | ||
402 | calibra->ResetVectorFit(); | |
403 | ||
404 | return ok; | |
405 | ||
406 | } | |
00d203b6 | 407 | //_____________________________________________________________________________________________________ |
b3fcfd96 | 408 | Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){ |
409 | // | |
410 | // Analyze VdriftT0 - produce the calibration objects | |
411 | // | |
412 | ||
413 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
414 | calibra->SetMinEntries(800*20); // If there is less than 1000 entries in the histo: no fit | |
415 | calibra->AnalysePH(fPH2d); | |
416 | ||
417 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
418 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
419 | Int_t nbfit = calibra->GetNumberFit(); | |
420 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); | |
421 | Int_t nbE = calibra->GetNumberEnt(); | |
422 | ||
423 | //printf("nbtg %d, nbfit %d, nbE %d, nbfitSuccess %d\n",nbtg,nbfit,nbE,nbfitSuccess); | |
424 | ||
425 | Bool_t ok = kFALSE; | |
426 | if ((nbtg > 0) && | |
427 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { | |
428 | //printf("Pass the cut for VdriftT0\n"); | |
429 | // create the cal objects | |
01239968 | 430 | calibra->RemoveOutliers(1,kFALSE); |
431 | calibra->PutMeanValueOtherVectorFit(1,kFALSE); | |
432 | calibra->RemoveOutliers2(kFALSE); | |
433 | calibra->PutMeanValueOtherVectorFit2(1,kFALSE); | |
434 | // | |
b3fcfd96 | 435 | TObjArray object = calibra->GetVectorFit(); |
436 | AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object); | |
437 | TH1F *coefVdriftPH = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
438 | AliTRDCalPad *calPadVdrift = (AliTRDCalPad *)calibra->CreatePadObjectVdrift(&object,calDetVdrift); | |
439 | TH1F *coefPadVdrift = calPadVdrift->MakeHisto1D(); | |
440 | object = calibra->GetVectorFit2(); | |
441 | AliTRDCalDet *calDetT0 = calibra->CreateDetObjectT0(&object); | |
442 | TH1F *coefT0 = calDetT0->MakeHisto1DAsFunctionOfDet(); | |
443 | AliTRDCalPad *calPadT0 = (AliTRDCalPad *)calibra->CreatePadObjectT0(&object,calDetT0); | |
444 | TH1F *coefPadT0 = calPadT0->MakeHisto1D(); | |
445 | // Put them in the array | |
446 | fCalibObjects->AddAt(calDetT0,kT0PHDet); | |
447 | fCalibObjects->AddAt(calDetVdrift,kVdriftPHDet); | |
448 | fCalibObjects->AddAt(calPadT0,kT0PHPad); | |
449 | fCalibObjects->AddAt(calPadVdrift,kVdriftPHPad); | |
450 | fPlots->AddAt(coefVdriftPH,kVdriftPHDet); | |
451 | fPlots->AddAt(coefT0,kT0PHDet); | |
452 | fPlots->AddAt(coefPadVdrift,kVdriftPHPad); | |
453 | fPlots->AddAt(coefPadT0,kT0PHPad); | |
454 | // | |
455 | ok = kTRUE; | |
456 | } | |
457 | calibra->ResetVectorFit(); | |
458 | ||
459 | return ok; | |
460 | ||
461 | } | |
00d203b6 | 462 | //____________________________________________________________________________________________________________________ |
b3fcfd96 | 463 | Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){ |
464 | // | |
465 | // Analyze vdrift linear fit - produce the calibration objects | |
466 | // | |
467 | ||
468 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
469 | calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit | |
01239968 | 470 | fAliTRDCalibraVdriftLinearFit->FillPEArray(); |
b3fcfd96 | 471 | calibra->AnalyseLinearFitters(fAliTRDCalibraVdriftLinearFit); |
472 | ||
473 | //Int_t nbtg = 540; | |
474 | Int_t nbfit = calibra->GetNumberFit(); | |
475 | Int_t nbE = calibra->GetNumberEnt(); | |
476 | ||
477 | ||
478 | Bool_t ok = kFALSE; | |
479 | // enough statistics | |
480 | if ((nbfit >= 0.5*nbE) && (nbE > 30)) { | |
481 | // create the cal objects | |
01239968 | 482 | //calibra->RemoveOutliers(1,kTRUE); |
483 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); | |
484 | //calibra->RemoveOutliers2(kTRUE); | |
485 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
486 | // | |
b3fcfd96 | 487 | TObjArray object = calibra->GetVectorFit(); |
488 | AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
489 | TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
490 | object = calibra->GetVectorFit2(); | |
491 | AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectLorentzAngle(&object); | |
492 | TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet(); | |
493 | // Put them in the array | |
494 | fCalibObjects->AddAt(calDetVdrift,kVdriftLinear); | |
495 | fCalibObjects->AddAt(calDetLorentz,kLorentzLinear); | |
496 | fPlots->AddAt(coefDriftLinear,kVdriftLinear); | |
497 | fPlots->AddAt(coefLorentzAngle,kLorentzLinear); | |
498 | // | |
499 | ok = kTRUE; | |
500 | } | |
501 | ||
502 | calibra->ResetVectorFit(); | |
503 | ||
504 | return ok; | |
505 | ||
506 | } | |
00d203b6 | 507 | //________________________________________________________________________________________________________________ |
b3fcfd96 | 508 | |
509 | Bool_t AliTRDPreprocessorOffline::AnalyzePRF(){ | |
510 | // | |
511 | // Analyze PRF - produce the calibration objects | |
512 | // | |
513 | ||
514 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
515 | calibra->SetMinEntries(600); // If there is less than 1000 entries in the histo: no fit | |
516 | calibra->AnalysePRFMarianFit(fPRF2d); | |
517 | ||
518 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
519 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
520 | Int_t nbfit = calibra->GetNumberFit(); | |
521 | Int_t nbE = calibra->GetNumberEnt(); | |
522 | ||
523 | ||
524 | Bool_t ok = kFALSE; | |
525 | // enough statistics | |
526 | if ((nbtg > 0) && | |
527 | (nbfit >= 0.95*nbE) && (nbE > 30)) { | |
528 | // create the cal objects | |
529 | TObjArray object = calibra->GetVectorFit(); | |
530 | AliTRDCalPad *calPadPRF = (AliTRDCalPad*) calibra->CreatePadObjectPRF(&object); | |
531 | TH1F *coefPRF = calPadPRF->MakeHisto1D(); | |
532 | // Put them in the array | |
533 | fCalibObjects->AddAt(calPadPRF,kPRF); | |
534 | fPlots->AddAt(coefPRF,kPRF); | |
535 | // | |
536 | ok = kTRUE; | |
537 | } | |
538 | ||
539 | calibra->ResetVectorFit(); | |
540 | ||
541 | return ok; | |
542 | ||
543 | } | |
00d203b6 | 544 | //________________________________________________________________________________________________ |
01239968 | 545 | void AliTRDPreprocessorOffline::CorrectFromDetGainUsed() { |
4c865c34 | 546 | // |
547 | // Correct from the gas gain used afterwards | |
548 | // | |
01239968 | 549 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); |
550 | if(!calDetGain) return; | |
551 | ||
4c865c34 | 552 | // Calculate mean |
553 | Double_t mean = 0.0; | |
554 | Int_t nbdet = 0; | |
555 | ||
01239968 | 556 | for(Int_t det = 0; det < 540; det++) { |
557 | ||
558 | Float_t gaininit = fCalDetGainUsed->GetValue(det); | |
559 | Float_t gainout = calDetGain->GetValue(det); | |
01239968 | 560 | |
4c865c34 | 561 | |
562 | if(TMath::Abs(gainout-1.0) > 0.000001) { | |
563 | mean += (gaininit*gainout); | |
564 | nbdet++; | |
565 | } | |
566 | } | |
567 | if(nbdet > 0) mean = mean/nbdet; | |
568 | ||
569 | for(Int_t det = 0; det < 540; det++) { | |
570 | ||
571 | Float_t gaininit = fCalDetGainUsed->GetValue(det); | |
572 | Float_t gainout = calDetGain->GetValue(det); | |
573 | ||
574 | if(TMath::Abs(gainout-1.0) > 0.000001) calDetGain->SetValue(det,gaininit*gainout); | |
575 | else calDetGain->SetValue(det,mean); | |
01239968 | 576 | } |
577 | ||
578 | ||
579 | } | |
00d203b6 | 580 | //________________________________________________________________________________________________ |
4c865c34 | 581 | void AliTRDPreprocessorOffline::CorrectFromDetVdriftUsed() { |
582 | // | |
583 | // Correct from the drift velocity | |
584 | // | |
585 | ||
586 | //printf("Correct for vdrift\n"); | |
587 | ||
588 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
589 | if(!calDetGain) return; | |
590 | ||
591 | Int_t detVdrift = kVdriftPHDet; | |
592 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
593 | AliTRDCalDet *calDetVdrift = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
594 | if(!calDetVdrift) return; | |
595 | ||
596 | // Calculate mean | |
597 | ||
598 | for(Int_t det = 0; det < 540; det++) { | |
599 | ||
600 | Float_t vdriftinit = fCalDetVdriftUsed->GetValue(det); | |
601 | Float_t vdriftout = calDetVdrift->GetValue(det); | |
602 | ||
603 | Float_t gain = calDetGain->GetValue(det); | |
604 | if(vdriftout > 0.0) gain = gain*vdriftinit/vdriftout; | |
605 | calDetGain->SetValue(det,gain); | |
606 | ||
607 | ||
608 | } | |
609 | ||
610 | } | |
00d203b6 | 611 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 612 | void AliTRDPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ |
613 | // | |
614 | // Update OCDB entry | |
615 | // | |
616 | ||
617 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
618 | metaData->SetObjectClassName("AliTRDCalDet"); | |
619 | metaData->SetResponsible("Raphaelle Bailhache"); | |
620 | metaData->SetBeamPeriod(1); | |
621 | ||
622 | AliCDBId id1("TRD/Calib/ChamberGainFactor", startRunNumber, endRunNumber); | |
623 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
624 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
625 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
b3fcfd96 | 626 | |
627 | ||
628 | } | |
00d203b6 | 629 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 630 | void AliTRDPreprocessorOffline::UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ |
631 | // | |
632 | // Update OCDB entry | |
633 | // | |
634 | ||
635 | Int_t detVdrift = kVdriftPHDet; | |
636 | ||
637 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
638 | ||
639 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
640 | metaData->SetObjectClassName("AliTRDCalDet"); | |
641 | metaData->SetResponsible("Raphaelle Bailhache"); | |
642 | metaData->SetBeamPeriod(1); | |
643 | ||
644 | AliCDBId id1("TRD/Calib/ChamberVdrift", startRunNumber, endRunNumber); | |
645 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
646 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
647 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
4c865c34 | 648 | |
b3fcfd96 | 649 | // |
650 | ||
651 | if(!fMethodSecond) { | |
652 | ||
653 | AliCDBMetaData *metaDataPad= new AliCDBMetaData(); | |
654 | metaDataPad->SetObjectClassName("AliTRDCalPad"); | |
655 | metaDataPad->SetResponsible("Raphaelle Bailhache"); | |
656 | metaDataPad->SetBeamPeriod(1); | |
657 | ||
658 | AliCDBId id1Pad("TRD/Calib/LocalVdrift", startRunNumber, endRunNumber); | |
659 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad); | |
660 | if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad); | |
4c865c34 | 661 | |
b3fcfd96 | 662 | } |
663 | ||
664 | } | |
00d203b6 | 665 | //________________________________________________________________________________________________________________________ |
b3fcfd96 | 666 | void AliTRDPreprocessorOffline::UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ |
667 | // | |
668 | // Update OCDB entry | |
669 | // | |
670 | ||
671 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
672 | metaData->SetObjectClassName("AliTRDCalDet"); | |
673 | metaData->SetResponsible("Raphaelle Bailhache"); | |
674 | metaData->SetBeamPeriod(1); | |
675 | ||
676 | AliCDBId id1("TRD/Calib/ChamberT0", startRunNumber, endRunNumber); | |
677 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
678 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet); | |
679 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
b3fcfd96 | 680 | |
b3fcfd96 | 681 | // |
682 | ||
683 | AliCDBMetaData *metaDataPad= new AliCDBMetaData(); | |
684 | metaDataPad->SetObjectClassName("AliTRDCalPad"); | |
685 | metaDataPad->SetResponsible("Raphaelle Bailhache"); | |
686 | metaDataPad->SetBeamPeriod(1); | |
687 | ||
688 | AliCDBId id1Pad("TRD/Calib/LocalT0", startRunNumber, endRunNumber); | |
689 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad); | |
690 | if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad); | |
4c865c34 | 691 | |
b3fcfd96 | 692 | |
693 | ||
694 | } | |
00d203b6 | 695 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 696 | void AliTRDPreprocessorOffline::UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ |
697 | // | |
698 | // Update OCDB entry | |
699 | // | |
700 | ||
701 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
702 | metaData->SetObjectClassName("AliTRDCalPad"); | |
703 | metaData->SetResponsible("Raphaelle Bailhache"); | |
704 | metaData->SetBeamPeriod(1); | |
705 | ||
706 | AliCDBId id1("TRD/Calib/PRFWidth", startRunNumber, endRunNumber); | |
707 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
708 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF); | |
709 | if(calPad) gStorage->Put(calPad, id1, metaData); | |
b3fcfd96 | 710 | |
711 | ||
00d203b6 | 712 | } |
713 | //__________________________________________________________________________________________________________________________ | |
714 | Bool_t AliTRDPreprocessorOffline::ValidateGain() const { | |
715 | // | |
716 | // Validate OCDB entry | |
717 | // | |
718 | ||
719 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
720 | if(calDet) { | |
721 | Double_t mean = calDet->GetMean(); | |
722 | Double_t rms = calDet->GetRMS(); | |
723 | if((mean > 0.2) && (mean < 1.4) && (rms < 0.5)) return kTRUE; | |
724 | else return kFALSE; | |
725 | } | |
726 | else return kFALSE; | |
727 | ||
728 | ||
729 | } | |
730 | //__________________________________________________________________________________________________________________________ | |
731 | Bool_t AliTRDPreprocessorOffline::ValidateVdrift(){ | |
732 | // | |
733 | // Update OCDB entry | |
734 | // | |
735 | ||
736 | Int_t detVdrift = kVdriftPHDet; | |
737 | Bool_t ok = kTRUE; | |
738 | ||
739 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
740 | ||
741 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
742 | if(calDet) { | |
743 | Double_t mean = calDet->GetMean(); | |
744 | Double_t rms = calDet->GetRMS(); | |
745 | //printf("Vdrift::mean %f, rms %f\n",mean,rms); | |
746 | if(!((mean > 1.0) && (mean < 2.0) && (rms < 0.5))) ok = kFALSE; | |
747 | } | |
748 | else return kFALSE; | |
749 | ||
750 | if(!fMethodSecond) { | |
751 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad); | |
752 | if(calPad) { | |
753 | Double_t mean = calPad->GetMean(); | |
754 | Double_t rms = calPad->GetRMS(); | |
755 | //printf("Vdrift::meanpad %f, rmspad %f\n",mean,rms); | |
756 | if(!((mean > 0.9) && (mean < 1.1) && (rms < 0.6))) ok = kFALSE; | |
757 | } | |
758 | else return kFALSE; | |
759 | } | |
760 | ||
761 | return ok; | |
762 | ||
763 | } | |
764 | //__________________________________________________________________________________________________________________________ | |
765 | Bool_t AliTRDPreprocessorOffline::ValidateT0(){ | |
766 | // | |
767 | // Update OCDB entry | |
768 | // | |
769 | ||
770 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet); | |
771 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad); | |
772 | if(calDet && calPad) { | |
773 | Double_t meandet = calDet->GetMean(); | |
774 | Double_t rmsdet = calDet->GetRMS(); | |
775 | Double_t meanpad = calPad->GetMean(); | |
776 | //Double_t rmspad = calPad->GetRMS(); | |
777 | //printf("T0::minimum %f, rmsdet %f,meanpad %f, rmspad %f\n",meandet,rmsdet,meanpad,rmspad); | |
778 | if((meandet > -1.5) && (meandet < 5.0) && (rmsdet < 4.0) && (meanpad < 5.0) && (meanpad > -0.5)) return kTRUE; | |
779 | else return kFALSE; | |
780 | } | |
781 | else return kFALSE; | |
782 | ||
783 | } | |
784 | //__________________________________________________________________________________________________________________________ | |
785 | Bool_t AliTRDPreprocessorOffline::ValidatePRF() const{ | |
786 | // | |
787 | // Update OCDB entry | |
788 | // | |
789 | ||
790 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF); | |
791 | if(calPad) { | |
792 | Double_t meanpad = calPad->GetMean(); | |
793 | Double_t rmspad = calPad->GetRMS(); | |
794 | //printf("PRF::meanpad %f, rmspad %f\n",meanpad,rmspad); | |
795 | if((meanpad < 1.0) && (rmspad < 0.8)) return kTRUE; | |
796 | else return kFALSE; | |
797 | } | |
798 | else return kFALSE; | |
799 | ||
800 | ||
b3fcfd96 | 801 | } |
4c865c34 | 802 | //_____________________________________________________________________________ |
803 | Int_t AliTRDPreprocessorOffline::GetVersion(TString name) const | |
804 | { | |
805 | // | |
806 | // Get version from the title | |
807 | // | |
808 | ||
809 | // Some patterns | |
810 | const Char_t *version = "Ver"; | |
811 | if(!strstr(name.Data(),version)) return -1; | |
812 | ||
813 | for(Int_t ver = 0; ver < 999999999; ver++) { | |
814 | ||
815 | TString vertry(version); | |
816 | vertry += ver; | |
817 | vertry += "Subver"; | |
818 | ||
819 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
820 | ||
821 | if(strstr(name.Data(),vertry.Data())) return ver; | |
822 | ||
823 | } | |
824 | ||
825 | return -1; | |
826 | ||
827 | } | |
828 | ||
829 | //_____________________________________________________________________________ | |
830 | Int_t AliTRDPreprocessorOffline::GetSubVersion(TString name) const | |
831 | { | |
832 | // | |
833 | // Get subversion from the title | |
834 | // | |
835 | ||
836 | // Some patterns | |
837 | const Char_t *subversion = "Subver"; | |
838 | if(!strstr(name.Data(),subversion)) return -1; | |
839 | ||
840 | for(Int_t ver = 0; ver < 999999999; ver++) { | |
841 | ||
842 | TString vertry(subversion); | |
843 | vertry += ver; | |
844 | vertry += "Nz"; | |
845 | ||
846 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
847 | ||
848 | if(strstr(name.Data(),vertry.Data())) return ver; | |
849 | ||
850 | } | |
851 | ||
852 | return -1; | |
853 | ||
854 | } | |
01239968 | 855 | |
008817a3 | 856 |