]>
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" | |
81a5aeca | 60 | #include "AliTRDCalChamberStatus.h" |
b3fcfd96 | 61 | |
62 | ||
63 | ClassImp(AliTRDPreprocessorOffline) | |
64 | ||
54f2ff1c | 65 | AliTRDPreprocessorOffline::AliTRDPreprocessorOffline(): |
01239968 | 66 | TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"), |
b3fcfd96 | 67 | fMethodSecond(kTRUE), |
01239968 | 68 | fNameList("TRDCalib"), |
69 | fCalDetGainUsed(0x0), | |
4c865c34 | 70 | fCalDetVdriftUsed(0x0), |
b3fcfd96 | 71 | fCH2d(0x0), |
72 | fPH2d(0x0), | |
73 | fPRF2d(0x0), | |
74 | fAliTRDCalibraVdriftLinearFit(0x0), | |
75 | fNEvents(0x0), | |
76 | fAbsoluteGain(0x0), | |
adab6236 | 77 | fPlots(new TObjArray(9)), |
78 | fCalibObjects(new TObjArray(9)), | |
4c865c34 | 79 | fVersionGainUsed(0), |
80 | fSubVersionGainUsed(0), | |
ca7e6e64 | 81 | fFirstRunVdriftUsed(0), |
4c865c34 | 82 | fVersionVdriftUsed(0), |
00d203b6 | 83 | fSubVersionVdriftUsed(0), |
84 | fSwitchOnValidation(kTRUE), | |
85 | fVdriftValidated(kFALSE), | |
a2a4ec8e | 86 | fT0Validated(kFALSE), |
87 | fMinStatsVdriftT0PH(800*20), | |
88 | fMinStatsVdriftLinear(800), | |
89 | fMinStatsGain(800), | |
54f2ff1c | 90 | fMinStatsPRF(600), |
91 | fBackCorrectGain(kFALSE), | |
92 | fBackCorrectVdrift(kTRUE), | |
93 | fNotEnoughStatisticsForTheGain(kFALSE), | |
94 | fNotEnoughStatisticsForTheVdriftLinear(kFALSE), | |
95 | fStatus(0) | |
b3fcfd96 | 96 | { |
97 | // | |
98 | // default constructor | |
99 | // | |
100 | } | |
00d203b6 | 101 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 102 | AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() { |
103 | // | |
104 | // Destructor | |
105 | // | |
106 | ||
01239968 | 107 | if(fCalDetGainUsed) delete fCalDetGainUsed; |
4c865c34 | 108 | if(fCalDetVdriftUsed) delete fCalDetVdriftUsed; |
b3fcfd96 | 109 | if(fCH2d) delete fCH2d; |
110 | if(fPH2d) delete fPH2d; | |
111 | if(fPRF2d) delete fPRF2d; | |
112 | if(fAliTRDCalibraVdriftLinearFit) delete fAliTRDCalibraVdriftLinearFit; | |
113 | if(fNEvents) delete fNEvents; | |
114 | if(fAbsoluteGain) delete fAbsoluteGain; | |
115 | if(fPlots) delete fPlots; | |
116 | if(fCalibObjects) delete fCalibObjects; | |
117 | ||
118 | } | |
00d203b6 | 119 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 120 | |
121 | void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
122 | // | |
123 | // make calibration of the drift velocity | |
124 | // Input parameters: | |
125 | // file - the location of input file | |
126 | // startRunNumber, endRunNumber - run validity period | |
127 | // ocdbStorage - path to the OCDB storage | |
128 | // - if empty - local storage 'pwd' uesed | |
129 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
130 | // | |
131 | // 1. Initialization | |
132 | // | |
008817a3 | 133 | fVdriftValidated = kTRUE; |
134 | fT0Validated = kTRUE; | |
54f2ff1c | 135 | fNotEnoughStatisticsForTheVdriftLinear = kFALSE; |
b3fcfd96 | 136 | // |
137 | // 2. extraction of the information | |
138 | // | |
b3fcfd96 | 139 | if(ReadVdriftLinearFitGlobal(file)) AnalyzeVdriftLinearFit(); |
54f2ff1c | 140 | if(ReadVdriftT0Global(file)) AnalyzeVdriftT0(); |
b3fcfd96 | 141 | // |
142 | // 3. Append QA plots | |
143 | // | |
144 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
145 | // | |
146 | // | |
00d203b6 | 147 | // 4. validate OCDB entries |
b3fcfd96 | 148 | // |
00d203b6 | 149 | if(fSwitchOnValidation==kTRUE && ValidateVdrift()==kFALSE) { |
150 | AliError("TRD vdrift OCDB parameters out of range!"); | |
151 | fVdriftValidated = kFALSE; | |
152 | } | |
153 | if(fSwitchOnValidation==kTRUE && ValidateT0()==kFALSE) { | |
154 | AliError("TRD t0 OCDB parameters out of range!"); | |
155 | fT0Validated = kFALSE; | |
156 | } | |
b3fcfd96 | 157 | // |
00d203b6 | 158 | // 5. update of OCDB |
159 | // | |
160 | // | |
161 | if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage); | |
162 | if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage); | |
163 | ||
b3fcfd96 | 164 | } |
00d203b6 | 165 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 166 | |
167 | void AliTRDPreprocessorOffline::CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
168 | // | |
169 | // make calibration of the drift velocity | |
170 | // Input parameters: | |
171 | // file - the location of input file | |
172 | // startRunNumber, endRunNumber - run validity period | |
173 | // ocdbStorage - path to the OCDB storage | |
174 | // - if empty - local storage 'pwd' uesed | |
175 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
176 | // | |
54f2ff1c | 177 | fNotEnoughStatisticsForTheGain = kFALSE; |
178 | // | |
b3fcfd96 | 179 | // 1. Initialization |
180 | if(!ReadGainGlobal(file)) return; | |
181 | // | |
182 | // | |
183 | // 2. extraction of the information | |
184 | // | |
185 | AnalyzeGain(); | |
54f2ff1c | 186 | if(fBackCorrectGain) CorrectFromDetGainUsed(); |
187 | if(fBackCorrectVdrift) CorrectFromDetVdriftUsed(); | |
b3fcfd96 | 188 | // |
189 | // 3. Append QA plots | |
190 | // | |
191 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
192 | // | |
193 | // | |
00d203b6 | 194 | // 4. validate OCDB entries |
195 | // | |
196 | if(fSwitchOnValidation==kTRUE && ValidateGain()==kFALSE) { | |
197 | AliError("TRD gain OCDB parameters out of range!"); | |
198 | return; | |
199 | } | |
b3fcfd96 | 200 | // |
00d203b6 | 201 | // 5. update of OCDB |
b3fcfd96 | 202 | // |
00d203b6 | 203 | // |
204 | if((!fCalDetVdriftUsed) || (fCalDetVdriftUsed && fVdriftValidated)) UpdateOCDBGain(startRunNumber,endRunNumber,ocdbStorage); | |
205 | ||
b3fcfd96 | 206 | |
207 | } | |
00d203b6 | 208 | //________________________________________________________________________________________________________________ |
b3fcfd96 | 209 | |
210 | void AliTRDPreprocessorOffline::CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
211 | // | |
212 | // make calibration of the drift velocity | |
213 | // Input parameters: | |
214 | // file - the location of input file | |
215 | // startRunNumber, endRunNumber - run validity period | |
216 | // ocdbStorage - path to the OCDB storage | |
217 | // - if empty - local storage 'pwd' uesed | |
218 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
219 | // | |
220 | // 1. Initialization | |
221 | if(!ReadPRFGlobal(file)) return; | |
222 | // | |
223 | // | |
224 | // 2. extraction of the information | |
225 | // | |
226 | AnalyzePRF(); | |
227 | // | |
228 | // 3. Append QA plots | |
229 | // | |
230 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
231 | // | |
232 | // | |
00d203b6 | 233 | // |
234 | // 4. validate OCDB entries | |
235 | // | |
236 | if(fSwitchOnValidation==kTRUE && ValidatePRF()==kFALSE) { | |
237 | AliError("TRD prf OCDB parameters out of range!"); | |
238 | return; | |
239 | } | |
240 | // | |
241 | // 5. update of OCDB | |
b3fcfd96 | 242 | // |
243 | // | |
244 | UpdateOCDBPRF(startRunNumber,endRunNumber,ocdbStorage); | |
245 | ||
a5dcf618 | 246 | } |
247 | //________________________________________________________________________________________________________________ | |
248 | ||
249 | void AliTRDPreprocessorOffline::CalibChamberStatus(Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){ | |
250 | // | |
251 | // make calibration of the chamber status | |
252 | // Input parameters: | |
253 | // startRunNumber, endRunNumber - run validity period | |
254 | // ocdbStorage - path to the OCDB storage | |
255 | // - if empty - local storage 'pwd' uesed | |
256 | if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
257 | // | |
258 | // | |
259 | // 2. extraction of the information | |
260 | // | |
261 | if(!AnalyzeChamberStatus()) return; | |
262 | // | |
263 | // 3. Append QA plots | |
264 | // | |
265 | //MakeDefaultPlots(fVdriftArray,fVdriftArray); | |
266 | // | |
267 | // | |
268 | // | |
269 | // 4. validate OCDB entries | |
270 | // | |
271 | if(fSwitchOnValidation==kTRUE && ValidateChamberStatus()==kFALSE) { | |
272 | AliError("TRD Chamber status OCDB parameters not ok!"); | |
273 | return; | |
274 | } | |
275 | // | |
276 | // 5. update of OCDB | |
277 | // | |
278 | // | |
54f2ff1c | 279 | if((!fNotEnoughStatisticsForTheGain) && (!fNotEnoughStatisticsForTheGain)) UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage); |
a5dcf618 | 280 | |
b3fcfd96 | 281 | } |
00d203b6 | 282 | //______________________________________________________________________________________________________ |
4c865c34 | 283 | Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){ |
284 | // | |
285 | // read the calibration used during the reconstruction | |
286 | // | |
287 | ||
288 | if(ReadVdriftT0Global(fileName)) { | |
289 | ||
290 | TString nameph = fPH2d->GetTitle(); | |
ca7e6e64 | 291 | fFirstRunVdriftUsed = GetFirstRun(nameph); |
4c865c34 | 292 | fVersionVdriftUsed = GetVersion(nameph); |
293 | fSubVersionVdriftUsed = GetSubVersion(nameph); | |
294 | ||
295 | //printf("Found Version %d, Subversion %d for vdrift\n",fVersionVdriftUsed,fSubVersionVdriftUsed); | |
296 | ||
297 | } | |
298 | ||
299 | if(ReadGainGlobal(fileName)) { | |
300 | ||
301 | TString namech = fCH2d->GetTitle(); | |
302 | fVersionGainUsed = GetVersion(namech); | |
303 | fSubVersionGainUsed = GetSubVersion(namech); | |
304 | ||
305 | //printf("Found Version %d, Subversion %d for gain\n",fVersionGainUsed,fSubVersionGainUsed); | |
306 | ||
307 | } | |
308 | ||
54f2ff1c | 309 | if((fVersionVdriftUsed == 0) && (fVersionGainUsed == 0)) fStatus = -1; |
310 | ||
4c865c34 | 311 | return kTRUE; |
312 | ||
313 | } | |
00d203b6 | 314 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 315 | |
316 | Bool_t AliTRDPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){ | |
317 | // | |
318 | // read calibration entries from file | |
319 | // | |
4c865c34 | 320 | if(fCH2d) return kTRUE; |
b3fcfd96 | 321 | TFile fcalib(fileName); |
01239968 | 322 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 323 | if (array){ |
324 | TH2I *ch2d = (TH2I *) array->FindObject("CH2d"); | |
325 | if(!ch2d) return kFALSE; | |
326 | fCH2d = (TH2I*)ch2d->Clone(); | |
327 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
328 | //fAbsoluteGain = (TH2F *) array->FindObject("AbsoluteGain"); | |
329 | }else{ | |
330 | TH2I *ch2d = (TH2I *) fcalib.Get("CH2d"); | |
331 | if(!ch2d) return kFALSE; | |
332 | fCH2d = (TH2I*)ch2d->Clone(); | |
333 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
334 | //fAbsoluteGain = (TH2F *) fcalib.Get("AbsoluteGain"); | |
335 | } | |
336 | fCH2d->SetDirectory(0); | |
337 | //printf("title of CH2d %s\n",fCH2d->GetTitle()); | |
338 | ||
339 | return kTRUE; | |
340 | ||
341 | } | |
00d203b6 | 342 | //_________________________________________________________________________________________________________________ |
b3fcfd96 | 343 | |
344 | Bool_t AliTRDPreprocessorOffline::ReadVdriftT0Global(const Char_t* fileName){ | |
345 | // | |
346 | // read calibration entries from file | |
347 | // | |
4c865c34 | 348 | if(fPH2d) return kTRUE; |
b3fcfd96 | 349 | TFile fcalib(fileName); |
01239968 | 350 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 351 | if (array){ |
352 | TProfile2D *ph2d = (TProfile2D *) array->FindObject("PH2d"); | |
353 | if(!ph2d) return kFALSE; | |
354 | fPH2d = (TProfile2D*)ph2d->Clone(); | |
355 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
356 | }else{ | |
357 | TProfile2D *ph2d = (TProfile2D *) fcalib.Get("PH2d"); | |
358 | if(!ph2d) return kFALSE; | |
359 | fPH2d = (TProfile2D*)ph2d->Clone(); | |
360 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
361 | } | |
362 | fPH2d->SetDirectory(0); | |
363 | //printf("title of PH2d %s\n",fPH2d->GetTitle()); | |
364 | ||
365 | return kTRUE; | |
366 | ||
367 | } | |
00d203b6 | 368 | //___________________________________________________________________________________________________________________ |
b3fcfd96 | 369 | |
370 | Bool_t AliTRDPreprocessorOffline::ReadVdriftLinearFitGlobal(const Char_t* fileName){ | |
371 | // | |
372 | // read calibration entries from file | |
373 | // | |
4c865c34 | 374 | if(fAliTRDCalibraVdriftLinearFit) return kTRUE; |
b3fcfd96 | 375 | TFile fcalib(fileName); |
01239968 | 376 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 377 | if (array){ |
378 | fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) array->FindObject("AliTRDCalibraVdriftLinearFit"); | |
379 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
380 | }else{ | |
381 | fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) fcalib.Get("AliTRDCalibraVdriftLinearFit"); | |
382 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
383 | } | |
384 | if(!fAliTRDCalibraVdriftLinearFit) { | |
385 | //printf("No AliTRDCalibraVdriftLinearFit\n"); | |
386 | return kFALSE; | |
387 | } | |
388 | return kTRUE; | |
389 | ||
390 | } | |
00d203b6 | 391 | //_____________________________________________________________________________________________________________ |
b3fcfd96 | 392 | |
393 | Bool_t AliTRDPreprocessorOffline::ReadPRFGlobal(const Char_t* fileName){ | |
394 | // | |
395 | // read calibration entries from file | |
396 | // | |
4c865c34 | 397 | if(fPRF2d) return kTRUE; |
b3fcfd96 | 398 | TFile fcalib(fileName); |
01239968 | 399 | TObjArray * array = (TObjArray*)fcalib.Get(fNameList); |
b3fcfd96 | 400 | if (array){ |
401 | TProfile2D *prf2d = (TProfile2D *) array->FindObject("PRF2d"); | |
402 | if(!prf2d) return kFALSE; | |
403 | fPRF2d = (TProfile2D*)prf2d->Clone(); | |
404 | //fNEvents = (TH1I *) array->FindObject("NEvents"); | |
405 | }else{ | |
406 | TProfile2D *prf2d = (TProfile2D *) fcalib.Get("PRF2d"); | |
407 | if(!prf2d) return kFALSE; | |
408 | fPRF2d = (TProfile2D*)prf2d->Clone(); | |
409 | //fNEvents = (TH1I *) fcalib.Get("NEvents"); | |
410 | } | |
411 | fPRF2d->SetDirectory(0); | |
412 | //printf("title of PRF2d %s\n",fPRF2d->GetTitle()); | |
413 | ||
414 | return kTRUE; | |
415 | ||
416 | } | |
00d203b6 | 417 | //__________________________________________________________________________________________________________ |
b3fcfd96 | 418 | |
419 | Bool_t AliTRDPreprocessorOffline::AnalyzeGain(){ | |
420 | // | |
421 | // Analyze gain - produce the calibration objects | |
422 | // | |
423 | ||
424 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
a2a4ec8e | 425 | calibra->SetMinEntries(fMinStatsGain); // If there is less than 1000 entries in the histo: no fit |
b3fcfd96 | 426 | calibra->AnalyseCH(fCH2d); |
427 | ||
428 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
429 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
430 | Int_t nbfit = calibra->GetNumberFit(); | |
431 | Int_t nbE = calibra->GetNumberEnt(); | |
432 | ||
433 | ||
434 | Bool_t ok = kFALSE; | |
4c865c34 | 435 | Bool_t meanother = kFALSE; |
b3fcfd96 | 436 | // enough statistics |
437 | if ((nbtg > 0) && | |
438 | (nbfit >= 0.5*nbE) && (nbE > 30)) { | |
439 | // create the cal objects | |
54f2ff1c | 440 | if(!fBackCorrectGain) { |
4c865c34 | 441 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
442 | meanother = kTRUE; | |
443 | } | |
b3fcfd96 | 444 | TObjArray object = calibra->GetVectorFit(); |
4c865c34 | 445 | AliTRDCalDet *calDetGain = calibra->CreateDetObjectGain(&object,meanother); |
b3fcfd96 | 446 | TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet(); |
447 | // Put them in the array | |
448 | fCalibObjects->AddAt(calDetGain,kGain); | |
449 | fPlots->AddAt(coefGain,kGain); | |
450 | // | |
451 | ok = kTRUE; | |
452 | } | |
54f2ff1c | 453 | else { |
454 | fNotEnoughStatisticsForTheGain = kTRUE; | |
455 | Double_t gainoverallnotnormalized = calibra->AnalyseCHAllTogether(fCH2d); | |
456 | if(fCalDetGainUsed && (gainoverallnotnormalized > 0.0)) { | |
457 | AliTRDCalDet *calDetGain = new AliTRDCalDet(*fCalDetGainUsed); | |
458 | Double_t oldmean = fCalDetGainUsed->CalcMean(kFALSE); | |
459 | //printf("oldmean %f\n",oldmean); | |
460 | if(oldmean > 0.0) { | |
461 | Double_t scalefactor = calibra->GetScaleFactorGain(); | |
462 | //printf("Correction factor %f\n",gainoverallnotnormalized*scalefactor); | |
463 | calDetGain->Multiply(gainoverallnotnormalized*scalefactor/oldmean); | |
464 | //printf("newmean %f\n",calDetGain->CalcMean(kFALSE)); | |
465 | TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet(); | |
466 | fCalibObjects->AddAt(calDetGain,kGain); | |
467 | fPlots->AddAt(coefGain,kGain); | |
468 | // | |
469 | ok = kTRUE; | |
3d046f80 | 470 | fStatus += 1000000; |
54f2ff1c | 471 | } |
472 | else { | |
3d046f80 | 473 | fStatus += 1000; |
54f2ff1c | 474 | } |
475 | } | |
476 | else { | |
3d046f80 | 477 | fStatus += 1000; |
54f2ff1c | 478 | } |
479 | } | |
b3fcfd96 | 480 | |
481 | calibra->ResetVectorFit(); | |
482 | ||
483 | return ok; | |
484 | ||
485 | } | |
00d203b6 | 486 | //_____________________________________________________________________________________________________ |
b3fcfd96 | 487 | Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){ |
488 | // | |
489 | // Analyze VdriftT0 - produce the calibration objects | |
490 | // | |
491 | ||
492 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
a2a4ec8e | 493 | calibra->SetMinEntries(fMinStatsVdriftT0PH); // If there is less than 1000 entries in the histo: no fit |
b3fcfd96 | 494 | calibra->AnalysePH(fPH2d); |
495 | ||
496 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
497 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
498 | Int_t nbfit = calibra->GetNumberFit(); | |
499 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); | |
500 | Int_t nbE = calibra->GetNumberEnt(); | |
501 | ||
502 | //printf("nbtg %d, nbfit %d, nbE %d, nbfitSuccess %d\n",nbtg,nbfit,nbE,nbfitSuccess); | |
503 | ||
504 | Bool_t ok = kFALSE; | |
505 | if ((nbtg > 0) && | |
506 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { | |
507 | //printf("Pass the cut for VdriftT0\n"); | |
508 | // create the cal objects | |
01239968 | 509 | calibra->RemoveOutliers(1,kFALSE); |
510 | calibra->PutMeanValueOtherVectorFit(1,kFALSE); | |
511 | calibra->RemoveOutliers2(kFALSE); | |
512 | calibra->PutMeanValueOtherVectorFit2(1,kFALSE); | |
513 | // | |
b3fcfd96 | 514 | TObjArray object = calibra->GetVectorFit(); |
515 | AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object); | |
516 | TH1F *coefVdriftPH = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
517 | AliTRDCalPad *calPadVdrift = (AliTRDCalPad *)calibra->CreatePadObjectVdrift(&object,calDetVdrift); | |
518 | TH1F *coefPadVdrift = calPadVdrift->MakeHisto1D(); | |
519 | object = calibra->GetVectorFit2(); | |
520 | AliTRDCalDet *calDetT0 = calibra->CreateDetObjectT0(&object); | |
521 | TH1F *coefT0 = calDetT0->MakeHisto1DAsFunctionOfDet(); | |
522 | AliTRDCalPad *calPadT0 = (AliTRDCalPad *)calibra->CreatePadObjectT0(&object,calDetT0); | |
523 | TH1F *coefPadT0 = calPadT0->MakeHisto1D(); | |
524 | // Put them in the array | |
525 | fCalibObjects->AddAt(calDetT0,kT0PHDet); | |
526 | fCalibObjects->AddAt(calDetVdrift,kVdriftPHDet); | |
527 | fCalibObjects->AddAt(calPadT0,kT0PHPad); | |
528 | fCalibObjects->AddAt(calPadVdrift,kVdriftPHPad); | |
529 | fPlots->AddAt(coefVdriftPH,kVdriftPHDet); | |
530 | fPlots->AddAt(coefT0,kT0PHDet); | |
531 | fPlots->AddAt(coefPadVdrift,kVdriftPHPad); | |
532 | fPlots->AddAt(coefPadT0,kT0PHPad); | |
533 | // | |
534 | ok = kTRUE; | |
535 | } | |
54f2ff1c | 536 | else { |
3d046f80 | 537 | fStatus += 100; |
54f2ff1c | 538 | } |
b3fcfd96 | 539 | calibra->ResetVectorFit(); |
540 | ||
541 | return ok; | |
542 | ||
543 | } | |
00d203b6 | 544 | //____________________________________________________________________________________________________________________ |
b3fcfd96 | 545 | Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){ |
546 | // | |
547 | // Analyze vdrift linear fit - produce the calibration objects | |
548 | // | |
549 | ||
a5dcf618 | 550 | //printf("Analyse linear fit\n"); |
551 | ||
f558cb62 | 552 | |
b3fcfd96 | 553 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
a2a4ec8e | 554 | calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit |
a5dcf618 | 555 | //printf("Fill PE Array\n"); |
01239968 | 556 | fAliTRDCalibraVdriftLinearFit->FillPEArray(); |
a5dcf618 | 557 | //printf("AliTRDCalibraFit\n"); |
b3fcfd96 | 558 | calibra->AnalyseLinearFitters(fAliTRDCalibraVdriftLinearFit); |
a5dcf618 | 559 | //printf("After\n"); |
b3fcfd96 | 560 | |
561 | //Int_t nbtg = 540; | |
562 | Int_t nbfit = calibra->GetNumberFit(); | |
563 | Int_t nbE = calibra->GetNumberEnt(); | |
564 | ||
565 | ||
566 | Bool_t ok = kFALSE; | |
567 | // enough statistics | |
568 | if ((nbfit >= 0.5*nbE) && (nbE > 30)) { | |
569 | // create the cal objects | |
01239968 | 570 | //calibra->RemoveOutliers(1,kTRUE); |
571 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); | |
572 | //calibra->RemoveOutliers2(kTRUE); | |
573 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
574 | // | |
b3fcfd96 | 575 | TObjArray object = calibra->GetVectorFit(); |
576 | AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
577 | TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
578 | object = calibra->GetVectorFit2(); | |
579 | AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectLorentzAngle(&object); | |
580 | TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet(); | |
581 | // Put them in the array | |
582 | fCalibObjects->AddAt(calDetVdrift,kVdriftLinear); | |
583 | fCalibObjects->AddAt(calDetLorentz,kLorentzLinear); | |
584 | fPlots->AddAt(coefDriftLinear,kVdriftLinear); | |
585 | fPlots->AddAt(coefLorentzAngle,kLorentzLinear); | |
586 | // | |
587 | ok = kTRUE; | |
588 | } | |
54f2ff1c | 589 | else { |
590 | fNotEnoughStatisticsForTheVdriftLinear = kTRUE; | |
591 | Double_t vdriftoverall = calibra->AnalyseLinearFittersAllTogether(fAliTRDCalibraVdriftLinearFit); | |
592 | if(fCalDetVdriftUsed && (vdriftoverall > 0.0)) { | |
593 | AliTRDCalDet *calDetVdrift = new AliTRDCalDet(*fCalDetVdriftUsed); | |
594 | Double_t oldmean = fCalDetVdriftUsed->CalcMean(kFALSE); | |
595 | //printf("oldmean %f\n",oldmean); | |
596 | if(oldmean > 0.0) { | |
597 | //printf("Correction factor %f\n",vdriftoverall); | |
598 | calDetVdrift->Multiply(vdriftoverall/oldmean); | |
599 | //printf("newmean %f\n",calDetVdrift->CalcMean(kFALSE)); | |
600 | TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet(); | |
601 | // Put them in the array | |
602 | fCalibObjects->AddAt(calDetVdrift,kVdriftLinear); | |
603 | fPlots->AddAt(coefDriftLinear,kVdriftLinear); | |
604 | // | |
605 | ok = kTRUE; | |
3d046f80 | 606 | fStatus += 10000; |
54f2ff1c | 607 | } |
3d046f80 | 608 | else fStatus += 1; |
54f2ff1c | 609 | } |
3d046f80 | 610 | else fStatus += 1; |
54f2ff1c | 611 | } |
b3fcfd96 | 612 | |
613 | calibra->ResetVectorFit(); | |
614 | ||
615 | return ok; | |
616 | ||
617 | } | |
00d203b6 | 618 | //________________________________________________________________________________________________________________ |
b3fcfd96 | 619 | |
620 | Bool_t AliTRDPreprocessorOffline::AnalyzePRF(){ | |
621 | // | |
622 | // Analyze PRF - produce the calibration objects | |
623 | // | |
624 | ||
625 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
a2a4ec8e | 626 | calibra->SetMinEntries(fMinStatsPRF); // If there is less than 1000 entries in the histo: no fit |
b3fcfd96 | 627 | calibra->AnalysePRFMarianFit(fPRF2d); |
628 | ||
629 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
630 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
631 | Int_t nbfit = calibra->GetNumberFit(); | |
632 | Int_t nbE = calibra->GetNumberEnt(); | |
633 | ||
634 | ||
635 | Bool_t ok = kFALSE; | |
636 | // enough statistics | |
637 | if ((nbtg > 0) && | |
638 | (nbfit >= 0.95*nbE) && (nbE > 30)) { | |
639 | // create the cal objects | |
640 | TObjArray object = calibra->GetVectorFit(); | |
641 | AliTRDCalPad *calPadPRF = (AliTRDCalPad*) calibra->CreatePadObjectPRF(&object); | |
642 | TH1F *coefPRF = calPadPRF->MakeHisto1D(); | |
643 | // Put them in the array | |
644 | fCalibObjects->AddAt(calPadPRF,kPRF); | |
645 | fPlots->AddAt(coefPRF,kPRF); | |
646 | // | |
647 | ok = kTRUE; | |
648 | } | |
649 | ||
650 | calibra->ResetVectorFit(); | |
651 | ||
652 | return ok; | |
653 | ||
654 | } | |
a5dcf618 | 655 | |
656 | //_____________________________________________________________________________ | |
657 | Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus() | |
658 | { | |
4c865c34 | 659 | // |
a5dcf618 | 660 | // Produce AliTRDCalChamberStatus out of calibration results |
4c865c34 | 661 | // |
b61b92a0 | 662 | |
a5dcf618 | 663 | // set up AliTRDCalChamberStatus |
664 | AliTRDCalChamberStatus *CalChamberStatus = new AliTRDCalChamberStatus(); | |
665 | for(Int_t det = 0; det < 540; det++) CalChamberStatus->SetStatus(det,1); | |
01239968 | 666 | |
a5dcf618 | 667 | // get calibration objects |
668 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
669 | AliTRDCalDet *calDetVDrift = (AliTRDCalDet *) fCalibObjects->At(kVdriftLinear); | |
670 | ||
671 | // Check | |
b61b92a0 | 672 | if((!calDetGain) || (!calDetVDrift) || (!fCH2d)) return kFALSE; |
a5dcf618 | 673 | |
674 | // Gain | |
675 | Double_t gainmean = calDetGain->GetMean(); | |
676 | Double_t vdriftmean = calDetVDrift->GetMean(); | |
677 | ||
678 | Double_t gainrms = calDetGain->GetRMSRobust(); | |
679 | Double_t vdriftrms = calDetVDrift->GetRMSRobust(); | |
680 | ||
681 | //printf("Gain mean: %f, rms: %f\n",gainmean,gainrms); | |
682 | //printf("Vdrift mean: %f, rms: %f\n",vdriftmean,vdriftrms); | |
4c865c34 | 683 | |
a5dcf618 | 684 | // Check |
685 | if((TMath::Abs(gainrms) < 0.001) || (TMath::Abs(vdriftrms) < 0.001)) return kFALSE; | |
01239968 | 686 | |
a5dcf618 | 687 | // mask chambers with empty gain entries |
688 | //Int_t counter = 0; | |
689 | for (Int_t idet = 0; idet < 540; idet++) { | |
01239968 | 690 | |
a5dcf618 | 691 | // ch2d |
692 | TH1I *projch = (TH1I *) fCH2d->ProjectionX("projch",idet+1,idet+1,(Option_t *)"e"); | |
693 | Double_t entries = projch->GetEntries(); | |
4c865c34 | 694 | |
a5dcf618 | 695 | // gain |
696 | Double_t gain = calDetGain->GetValue(idet); | |
4c865c34 | 697 | |
a5dcf618 | 698 | // vdrift |
699 | Double_t vdrift = calDetVDrift->GetValue(idet); | |
4c865c34 | 700 | |
4c865c34 | 701 | |
a5dcf618 | 702 | if(entries<=0.5 || |
703 | TMath::Abs(gainmean-gain) > (15.0*gainrms) || | |
704 | TMath::Abs(vdriftmean-vdrift) > (15.0*vdriftrms)) { | |
705 | ||
706 | //printf(" chamber det %03d masked \n",idet); | |
707 | //printf(" gainmean %f and gain %f, gainrms %f \n",gainmean,gain,gainrms); | |
708 | //printf(" vdriftmean %f and vdrift %f, vdriftrms %f \n",vdriftmean,vdrift,vdriftrms); | |
709 | CalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kMasked); | |
710 | //counter++; | |
711 | } | |
4c865c34 | 712 | |
a5dcf618 | 713 | /* |
714 | // installed supermodules+1 -> abort | |
715 | if(counter > (7+1)*30) { | |
716 | printf("ERROR: more than one SM to be masked!! \n Abort...\n"); | |
717 | if(projch) delete projch; | |
718 | return 0x0; | |
719 | } | |
720 | */ | |
4c865c34 | 721 | |
b61b92a0 | 722 | delete projch; |
723 | ||
a5dcf618 | 724 | } |
b3fcfd96 | 725 | |
a5dcf618 | 726 | // Security |
727 | for(Int_t sm=0; sm < 18; sm++) { | |
728 | Int_t counter = 0; | |
729 | for(Int_t det = 0; det < 30; det++){ | |
730 | Int_t detector = sm*30+det; | |
731 | if(CalChamberStatus->IsMasked(detector)) counter++; | |
732 | } | |
733 | if(counter >= 10) { | |
734 | for(Int_t det = 0; det < 30; det++){ | |
735 | Int_t detector = sm*30+det; | |
736 | CalChamberStatus->SetStatus(detector,AliTRDCalChamberStatus::kInstalled); | |
737 | } | |
738 | } | |
739 | } | |
b3fcfd96 | 740 | |
a5dcf618 | 741 | fCalibObjects->AddAt(CalChamberStatus,kChamberStatus); |
742 | return kTRUE; | |
b3fcfd96 | 743 | |
a5dcf618 | 744 | } |
b3fcfd96 | 745 | |
b3fcfd96 | 746 | |
a5dcf618 | 747 | //________________________________________________________________________________________________ |
748 | void AliTRDPreprocessorOffline::CorrectFromDetGainUsed() { | |
749 | // | |
750 | // Correct from the gas gain used afterwards | |
751 | // | |
752 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
753 | if(!calDetGain) return; | |
b3fcfd96 | 754 | |
a5dcf618 | 755 | // Calculate mean |
756 | Double_t mean = 0.0; | |
757 | Int_t nbdet = 0; | |
b3fcfd96 | 758 | |
a5dcf618 | 759 | for(Int_t det = 0; det < 540; det++) { |
00d203b6 | 760 | |
a5dcf618 | 761 | Float_t gaininit = fCalDetGainUsed->GetValue(det); |
762 | Float_t gainout = calDetGain->GetValue(det); | |
00d203b6 | 763 | |
00d203b6 | 764 | |
a5dcf618 | 765 | if(TMath::Abs(gainout-1.0) > 0.000001) { |
766 | mean += (gaininit*gainout); | |
767 | nbdet++; | |
768 | } | |
769 | } | |
770 | if(nbdet > 0) mean = mean/nbdet; | |
00d203b6 | 771 | |
a5dcf618 | 772 | for(Int_t det = 0; det < 540; det++) { |
00d203b6 | 773 | |
a5dcf618 | 774 | Float_t gaininit = fCalDetGainUsed->GetValue(det); |
775 | Float_t gainout = calDetGain->GetValue(det); | |
776 | ||
ba1aa7a7 | 777 | if(TMath::Abs(gainout-1.0) > 0.000001) { |
778 | Double_t newgain = gaininit*gainout; | |
779 | if(newgain < 0.1) newgain = 0.1; | |
58e2b572 | 780 | if(newgain > 1.9) newgain = 1.9; |
ba1aa7a7 | 781 | calDetGain->SetValue(det,newgain); |
782 | } | |
783 | else { | |
784 | Double_t newgain = mean; | |
785 | if(newgain < 0.1) newgain = 0.1; | |
58e2b572 | 786 | if(newgain > 1.9) newgain = 1.9; |
ba1aa7a7 | 787 | calDetGain->SetValue(det,newgain); |
788 | } | |
a5dcf618 | 789 | } |
790 | ||
791 | ||
792 | } | |
793 | //________________________________________________________________________________________________ | |
794 | void AliTRDPreprocessorOffline::CorrectFromDetVdriftUsed() { | |
795 | // | |
796 | // Correct from the drift velocity | |
797 | // | |
798 | ||
799 | //printf("Correct for vdrift\n"); | |
800 | ||
801 | AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
802 | if(!calDetGain) return; | |
803 | ||
804 | Int_t detVdrift = kVdriftPHDet; | |
805 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
806 | AliTRDCalDet *calDetVdrift = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
807 | if(!calDetVdrift) return; | |
808 | ||
809 | // Calculate mean | |
54f2ff1c | 810 | if(!fNotEnoughStatisticsForTheGain) { |
811 | for(Int_t det = 0; det < 540; det++) { | |
812 | ||
813 | Float_t vdriftinit = fCalDetVdriftUsed->GetValue(det); | |
814 | Float_t vdriftout = calDetVdrift->GetValue(det); | |
815 | ||
816 | Float_t gain = calDetGain->GetValue(det); | |
817 | if(vdriftout > 0.0) gain = gain*vdriftinit/vdriftout; | |
818 | if(gain < 0.1) gain = 0.1; | |
819 | if(gain > 1.9) gain = 1.9; | |
820 | calDetGain->SetValue(det,gain); | |
821 | } | |
a5dcf618 | 822 | } |
54f2ff1c | 823 | else { |
824 | ||
825 | Float_t vdriftinit = fCalDetVdriftUsed->CalcMean(kFALSE); | |
826 | Float_t vdriftout = calDetVdrift->CalcMean(kFALSE); | |
827 | Float_t factorcorrectif = 1.0; | |
828 | if(vdriftout > 0.0) factorcorrectif = vdriftinit/vdriftout; | |
829 | for(Int_t det = 0; det < 540; det++) { | |
830 | Float_t gain = calDetGain->GetValue(det); | |
831 | gain = gain*factorcorrectif; | |
832 | if(gain < 0.1) gain = 0.1; | |
833 | if(gain > 1.9) gain = 1.9; | |
834 | calDetGain->SetValue(det,gain); | |
835 | } | |
836 | ||
837 | } | |
838 | ||
a5dcf618 | 839 | } |
54f2ff1c | 840 | //_________________________________________________________________________________________________________________ |
a5dcf618 | 841 | void AliTRDPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ |
842 | // | |
843 | // Update OCDB entry | |
844 | // | |
845 | ||
846 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
847 | metaData->SetObjectClassName("AliTRDCalDet"); | |
848 | metaData->SetResponsible("Raphaelle Bailhache"); | |
849 | metaData->SetBeamPeriod(1); | |
850 | ||
851 | AliCDBId id1("TRD/Calib/ChamberGainFactor", startRunNumber, endRunNumber); | |
852 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
853 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
854 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
855 | ||
856 | ||
857 | } | |
858 | //___________________________________________________________________________________________________________________ | |
859 | void AliTRDPreprocessorOffline::UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
860 | // | |
861 | // Update OCDB entry | |
862 | // | |
863 | ||
864 | Int_t detVdrift = kVdriftPHDet; | |
865 | ||
866 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
867 | ||
868 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
869 | metaData->SetObjectClassName("AliTRDCalDet"); | |
870 | metaData->SetResponsible("Raphaelle Bailhache"); | |
871 | metaData->SetBeamPeriod(1); | |
872 | ||
873 | AliCDBId id1("TRD/Calib/ChamberVdrift", startRunNumber, endRunNumber); | |
874 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
875 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
876 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
877 | ||
878 | // | |
879 | ||
880 | if(!fMethodSecond) { | |
881 | ||
882 | AliCDBMetaData *metaDataPad= new AliCDBMetaData(); | |
883 | metaDataPad->SetObjectClassName("AliTRDCalPad"); | |
884 | metaDataPad->SetResponsible("Raphaelle Bailhache"); | |
885 | metaDataPad->SetBeamPeriod(1); | |
886 | ||
887 | AliCDBId id1Pad("TRD/Calib/LocalVdrift", startRunNumber, endRunNumber); | |
888 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad); | |
889 | if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad); | |
890 | ||
891 | } | |
892 | ||
893 | } | |
894 | //________________________________________________________________________________________________________________________ | |
895 | void AliTRDPreprocessorOffline::UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
896 | // | |
897 | // Update OCDB entry | |
898 | // | |
899 | ||
900 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
901 | metaData->SetObjectClassName("AliTRDCalDet"); | |
902 | metaData->SetResponsible("Raphaelle Bailhache"); | |
903 | metaData->SetBeamPeriod(1); | |
904 | ||
905 | AliCDBId id1("TRD/Calib/ChamberT0", startRunNumber, endRunNumber); | |
906 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
907 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet); | |
908 | if(calDet) gStorage->Put(calDet, id1, metaData); | |
909 | ||
910 | // | |
911 | ||
912 | AliCDBMetaData *metaDataPad= new AliCDBMetaData(); | |
913 | metaDataPad->SetObjectClassName("AliTRDCalPad"); | |
914 | metaDataPad->SetResponsible("Raphaelle Bailhache"); | |
915 | metaDataPad->SetBeamPeriod(1); | |
916 | ||
917 | AliCDBId id1Pad("TRD/Calib/LocalT0", startRunNumber, endRunNumber); | |
918 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad); | |
919 | if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad); | |
920 | ||
921 | ||
922 | ||
923 | } | |
924 | //_________________________________________________________________________________________________________________ | |
925 | void AliTRDPreprocessorOffline::UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
926 | // | |
927 | // Update OCDB entry | |
928 | // | |
929 | ||
930 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
931 | metaData->SetObjectClassName("AliTRDCalPad"); | |
932 | metaData->SetResponsible("Raphaelle Bailhache"); | |
933 | metaData->SetBeamPeriod(1); | |
934 | ||
935 | AliCDBId id1("TRD/Calib/PRFWidth", startRunNumber, endRunNumber); | |
936 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
937 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF); | |
938 | if(calPad) gStorage->Put(calPad, id1, metaData); | |
939 | ||
940 | ||
941 | } | |
942 | //_________________________________________________________________________________________________________________ | |
943 | void AliTRDPreprocessorOffline::UpdateOCDBChamberStatus(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){ | |
944 | // | |
945 | // Update OCDB entry | |
946 | // | |
947 | ||
948 | AliCDBMetaData *metaData= new AliCDBMetaData(); | |
949 | metaData->SetObjectClassName("AliTRDCalChamberStatus"); | |
950 | metaData->SetResponsible("Raphaelle Bailhache"); | |
951 | metaData->SetBeamPeriod(1); | |
952 | ||
953 | AliCDBId id1("TRD/Calib/ChamberStatus", startRunNumber, endRunNumber); | |
954 | AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath); | |
955 | AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus); | |
956 | if(calChamberStatus) gStorage->Put(calChamberStatus, id1, metaData); | |
957 | ||
958 | ||
959 | } | |
960 | //__________________________________________________________________________________________________________________________ | |
54f2ff1c | 961 | Bool_t AliTRDPreprocessorOffline::ValidateGain() { |
a5dcf618 | 962 | // |
963 | // Validate OCDB entry | |
964 | // | |
965 | ||
966 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain); | |
967 | if(calDet) { | |
968 | Double_t mean = calDet->GetMean(); | |
969 | Double_t rms = calDet->GetRMSRobust(); | |
970 | if((mean > 0.2) && (mean < 1.4) && (rms < 0.5)) return kTRUE; | |
971 | //if((mean > 0.2) && (mean < 1.4)) return kTRUE; | |
54f2ff1c | 972 | else { |
3d046f80 | 973 | fStatus += 1000000000; |
54f2ff1c | 974 | return kFALSE; |
975 | } | |
a5dcf618 | 976 | } |
977 | else return kFALSE; | |
54f2ff1c | 978 | |
a5dcf618 | 979 | |
980 | ||
981 | } | |
982 | //__________________________________________________________________________________________________________________________ | |
983 | Bool_t AliTRDPreprocessorOffline::ValidateVdrift(){ | |
984 | // | |
985 | // Update OCDB entry | |
986 | // | |
987 | ||
988 | Int_t detVdrift = kVdriftPHDet; | |
989 | Bool_t ok = kTRUE; | |
990 | ||
991 | if(fMethodSecond) detVdrift = kVdriftLinear; | |
992 | ||
993 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift); | |
994 | if(calDet) { | |
995 | Double_t mean = calDet->GetMean(); | |
996 | Double_t rms = calDet->GetRMSRobust(); | |
997 | //printf("Vdrift::mean %f, rms %f\n",mean,rms); | |
54f2ff1c | 998 | if(!((mean > 1.0) && (mean < 2.0) && (rms < 0.5))) { |
3d046f80 | 999 | fStatus += 10000000; |
54f2ff1c | 1000 | ok = kFALSE; |
1001 | } | |
a5dcf618 | 1002 | } |
1003 | else return kFALSE; | |
1004 | ||
1005 | if(!fMethodSecond) { | |
1006 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad); | |
1007 | if(calPad) { | |
1008 | Double_t mean = calPad->GetMean(); | |
1009 | Double_t rms = calPad->GetRMS(); | |
1010 | //printf("Vdrift::meanpad %f, rmspad %f\n",mean,rms); | |
54f2ff1c | 1011 | if(!((mean > 0.9) && (mean < 1.1) && (rms < 0.6))) { |
3d046f80 | 1012 | fStatus += 10000000; |
54f2ff1c | 1013 | ok = kFALSE; |
1014 | } | |
a5dcf618 | 1015 | } |
1016 | else return kFALSE; | |
1017 | } | |
1018 | ||
1019 | return ok; | |
1020 | ||
1021 | } | |
1022 | //__________________________________________________________________________________________________________________________ | |
1023 | Bool_t AliTRDPreprocessorOffline::ValidateT0(){ | |
1024 | // | |
1025 | // Update OCDB entry | |
1026 | // | |
1027 | ||
1028 | AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet); | |
1029 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad); | |
1030 | if(calDet && calPad) { | |
1031 | Double_t meandet = calDet->GetMean(); | |
1032 | Double_t rmsdet = calDet->GetRMSRobust(); | |
1033 | Double_t meanpad = calPad->GetMean(); | |
1034 | //Double_t rmspad = calPad->GetRMS(); | |
1035 | //printf("T0::minimum %f, rmsdet %f,meanpad %f, rmspad %f\n",meandet,rmsdet,meanpad,rmspad); | |
1036 | if((meandet > -1.5) && (meandet < 5.0) && (rmsdet < 4.0) && (meanpad < 5.0) && (meanpad > -0.5)) return kTRUE; | |
54f2ff1c | 1037 | else { |
3d046f80 | 1038 | fStatus += 100000000; |
54f2ff1c | 1039 | return kFALSE; |
1040 | } | |
a5dcf618 | 1041 | } |
1042 | else return kFALSE; | |
1043 | ||
1044 | } | |
1045 | //__________________________________________________________________________________________________________________________ | |
1046 | Bool_t AliTRDPreprocessorOffline::ValidatePRF() const{ | |
1047 | // | |
1048 | // Update OCDB entry | |
1049 | // | |
1050 | ||
1051 | AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF); | |
1052 | if(calPad) { | |
1053 | Double_t meanpad = calPad->GetMean(); | |
1054 | Double_t rmspad = calPad->GetRMS(); | |
1055 | //printf("PRF::meanpad %f, rmspad %f\n",meanpad,rmspad); | |
1056 | if((meanpad < 1.0) && (rmspad < 0.8)) return kTRUE; | |
1057 | else return kFALSE; | |
1058 | } | |
1059 | else return kFALSE; | |
1060 | ||
1061 | ||
1062 | } | |
1063 | //__________________________________________________________________________________________________________________________ | |
1064 | Bool_t AliTRDPreprocessorOffline::ValidateChamberStatus() const{ | |
00d203b6 | 1065 | // |
1066 | // Update OCDB entry | |
1067 | // | |
1068 | ||
a5dcf618 | 1069 | AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus); |
1070 | if(calChamberStatus) { | |
1071 | Int_t detectormasked = 0; | |
1072 | for(Int_t det = 0; det < 540; det++) { | |
1073 | if(calChamberStatus->IsMasked(det)) detectormasked++; | |
1074 | } | |
1075 | //printf("Number of chambers masked %d\n",detectormasked); | |
3d046f80 | 1076 | if(detectormasked > 40) return kFALSE; |
a5dcf618 | 1077 | else return kTRUE; |
00d203b6 | 1078 | } |
1079 | else return kFALSE; | |
1080 | ||
b3fcfd96 | 1081 | } |
4c865c34 | 1082 | //_____________________________________________________________________________ |
1083 | Int_t AliTRDPreprocessorOffline::GetVersion(TString name) const | |
1084 | { | |
1085 | // | |
1086 | // Get version from the title | |
1087 | // | |
1088 | ||
1089 | // Some patterns | |
1090 | const Char_t *version = "Ver"; | |
1091 | if(!strstr(name.Data(),version)) return -1; | |
f558cb62 | 1092 | const Char_t *after = "Subver"; |
1093 | if(!strstr(name.Data(),after)) return -1; | |
1094 | ||
4c865c34 | 1095 | for(Int_t ver = 0; ver < 999999999; ver++) { |
1096 | ||
1097 | TString vertry(version); | |
1098 | vertry += ver; | |
f558cb62 | 1099 | vertry += after; |
4c865c34 | 1100 | |
1101 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
1102 | ||
1103 | if(strstr(name.Data(),vertry.Data())) return ver; | |
1104 | ||
1105 | } | |
1106 | ||
1107 | return -1; | |
1108 | ||
1109 | } | |
1110 | ||
1111 | //_____________________________________________________________________________ | |
1112 | Int_t AliTRDPreprocessorOffline::GetSubVersion(TString name) const | |
1113 | { | |
1114 | // | |
1115 | // Get subversion from the title | |
1116 | // | |
1117 | ||
1118 | // Some patterns | |
1119 | const Char_t *subversion = "Subver"; | |
1120 | if(!strstr(name.Data(),subversion)) return -1; | |
f558cb62 | 1121 | const Char_t *after = "FirstRun"; |
1122 | if(!strstr(name.Data(),after)) { | |
1123 | after = "Nz"; | |
1124 | } | |
1125 | if(!strstr(name.Data(),after)) return -1; | |
1126 | ||
4c865c34 | 1127 | |
1128 | for(Int_t ver = 0; ver < 999999999; ver++) { | |
1129 | ||
1130 | TString vertry(subversion); | |
1131 | vertry += ver; | |
f558cb62 | 1132 | vertry += after; |
ca7e6e64 | 1133 | |
1134 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
1135 | ||
1136 | if(strstr(name.Data(),vertry.Data())) return ver; | |
1137 | ||
1138 | } | |
1139 | ||
1140 | return -1; | |
1141 | ||
1142 | } | |
1143 | ||
1144 | //_____________________________________________________________________________ | |
1145 | Int_t AliTRDPreprocessorOffline::GetFirstRun(TString name) const | |
1146 | { | |
1147 | // | |
1148 | // Get first run from the title | |
1149 | // | |
1150 | ||
1151 | // Some patterns | |
1152 | const Char_t *firstrun = "FirstRun"; | |
1153 | if(!strstr(name.Data(),firstrun)) return -1; | |
f558cb62 | 1154 | const Char_t *after = "Nz"; |
1155 | if(!strstr(name.Data(),after)) return -1; | |
1156 | ||
ca7e6e64 | 1157 | |
1158 | for(Int_t ver = 0; ver < 999999999; ver++) { | |
1159 | ||
1160 | TString vertry(firstrun); | |
1161 | vertry += ver; | |
f558cb62 | 1162 | vertry += after; |
4c865c34 | 1163 | |
1164 | //printf("vertry %s and name %s\n",vertry.Data(),name.Data()); | |
1165 | ||
1166 | if(strstr(name.Data(),vertry.Data())) return ver; | |
1167 | ||
1168 | } | |
1169 | ||
1170 | return -1; | |
1171 | ||
1172 | } | |
01239968 | 1173 |