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