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