1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 Responsible: Raphaelle Bailhache (rbailhache@ikf.uni-frankfurt.de)
20 Code to analyze the TRD calibration and to produce OCDB entries
24 gSystem->Load("libANALYSIS");
25 gSystem->Load("libTRDcalib");
27 AliTRDPreprocessorOffline proces;
28 TString ocdbPath="local:////"
29 ocdbPath+=gSystem->GetFromPipe("pwd");
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
40 #include "Riostream.h"
50 #include "THnSparse.h"
51 #include "TProfile2D.h"
52 #include "AliTRDCalDet.h"
53 #include "AliTRDCalPad.h"
54 #include "AliCDBMetaData.h"
56 #include "AliCDBManager.h"
57 #include "AliCDBStorage.h"
58 #include "AliTRDCalibraMode.h"
59 #include "AliTRDCalibraFit.h"
60 #include "AliTRDCalibraVdriftLinearFit.h"
61 #include "AliTRDCalibraExbAltFit.h"
62 #include "AliTRDPreprocessorOffline.h"
63 #include "AliTRDCalChamberStatus.h"
64 #include "AliTRDCalibChamberStatus.h"
65 #include "AliTRDCommonParam.h"
66 #include "AliCDBManager.h"
67 #include "AliCDBEntry.h"
70 ClassImp(AliTRDPreprocessorOffline)
72 AliTRDPreprocessorOffline::AliTRDPreprocessorOffline():
73 TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"),
75 fNameList("TRDCalib"),
77 fCalDetVdriftUsed(0x0),
83 fAliTRDCalibraVdriftLinearFit(0x0),
84 fAliTRDCalibraExbAltFit(0x0),
87 fPlots(new TObjArray(kNumCalibObjs)),
88 fCalibObjects(new TObjArray(kNumCalibObjs)),
91 fSubVersionGainUsed(0),
92 fFirstRunVdriftUsed(0),
93 fVersionVdriftUsed(0),
94 fSubVersionVdriftUsed(0),
97 fSubVersionExBUsed(0),
98 fNoExBUsedInReco(kFALSE),
99 fSwitchOnValidation(kTRUE),
100 fVdriftValidated(kFALSE),
101 fExBValidated(kFALSE),
102 fT0Validated(kFALSE),
103 fMinStatsVdriftT0PH(800*20),
104 fMinStatsVdriftLinear(800),
107 fMinStatsChamberStatus(20),
108 fBackCorrectGain(kFALSE),
109 fBackCorrectVdrift(kTRUE),
110 fNotEnoughStatisticsForTheGain(kFALSE),
111 fNotEnoughStatisticsForTheVdriftLinear(kFALSE),
114 fBadCalibValidate(20),
116 fRMSBadCalibratedGain(20.0),
117 fRMSBadCalibratedVdrift(20.0),
118 fRMSBadCalibratedExB(50.0)
121 // default constructor
124 memset(fBadCalib, 0, sizeof(Int_t) * 18);
125 memset(fNoData, 0, sizeof(Int_t) * 18);
127 //_________________________________________________________________________________________________________________
128 AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() {
133 if(fCalDetGainUsed) delete fCalDetGainUsed;
134 if(fCalDetVdriftUsed) delete fCalDetVdriftUsed;
135 if(fCalDetExBUsed) delete fCalDetExBUsed;
136 if(fCH2d) delete fCH2d;
137 if(fPH2d) delete fPH2d;
138 if(fPRF2d) delete fPRF2d;
139 if(fSparse) delete fSparse;
140 if(fAliTRDCalibraVdriftLinearFit) delete fAliTRDCalibraVdriftLinearFit;
141 if(fAliTRDCalibraExbAltFit) delete fAliTRDCalibraExbAltFit;
142 if(fNEvents) delete fNEvents;
143 if(fAbsoluteGain) delete fAbsoluteGain;
144 if(fPlots) delete fPlots;
145 if(fCalibObjects) delete fCalibObjects;
148 //___________________________________________________________________________________
149 void AliTRDPreprocessorOffline::Process(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage)
152 // Process to the gain, vdrift, timeoffset, exb and chamber status calibration
155 if(SetCalDetGain(startRunNumber,fVersionGainUsed,fSubVersionGainUsed) && SetCalDetVdriftExB(startRunNumber,fVersionVdriftUsed,fSubVersionVdriftUsed,fVersionExBUsed,fSubVersionExBUsed)) {
157 CalibVdriftT0(file,startRunNumber,endRunNumber,ocdbStorage);
158 CalibGain(file,startRunNumber,endRunNumber,ocdbStorage);
159 CalibChamberStatus(file,startRunNumber,endRunNumber,ocdbStorage);
166 //___________________________________________________________________________________________________________________
168 void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
170 // make calibration of the drift velocity
172 // file - the location of input file
173 // startRunNumber, endRunNumber - run validity period
174 // ocdbStorage - path to the OCDB storage
175 // - if empty - local storage 'pwd' uesed
176 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
180 fVdriftValidated = kTRUE;
181 fT0Validated = kTRUE;
182 fExBValidated = kTRUE;
183 fNotEnoughStatisticsForTheVdriftLinear = kFALSE;
185 // 2. extraction of the information
187 if(ReadVdriftLinearFitGlobal(file) && fCalDetVdriftUsed && fCalDetExBUsed) AnalyzeVdriftLinearFit();
188 if(ReadVdriftT0Global(file)) AnalyzeVdriftT0();
190 // 3. Append QA plots
192 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
195 // 4. validate OCDB entries
197 if(fSwitchOnValidation==kTRUE && ValidateVdrift()==kFALSE) {
198 //AliError("TRD vdrift OCDB parameters out of range!");
199 fVdriftValidated = kFALSE;
201 if(fSwitchOnValidation==kTRUE && ValidateT0()==kFALSE) {
202 //AliError("TRD t0 OCDB parameters out of range!");
203 fT0Validated = kFALSE;
205 if(fSwitchOnValidation==kTRUE && ValidateExB()==kFALSE) {
206 //AliError("TRD t0 OCDB parameters out of range!");
207 fExBValidated = kFALSE;
213 if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage);
214 if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage);
215 if(fExBValidated) UpdateOCDBExB(startRunNumber,endRunNumber,ocdbStorage);
218 //___________________________________________________________________________________________________________________
220 void AliTRDPreprocessorOffline::CalibExbAlt(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
222 // make calibration of the drift velocity
224 // file - the location of input file
225 // startRunNumber, endRunNumber - run validity period
226 // ocdbStorage - path to the OCDB storage
227 // - if empty - local storage 'pwd' uesed
228 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
234 // 2. extraction of the information
236 if(ReadExbAltFitGlobal(file)) AnalyzeExbAltFit();
238 // 3. Append QA plots
240 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
243 // 4. validate OCDB entries
249 UpdateOCDBExBAlt(startRunNumber,endRunNumber,ocdbStorage);
253 //_________________________________________________________________________________________________________________
255 void AliTRDPreprocessorOffline::CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
257 // make calibration of the drift velocity
259 // file - the location of input file
260 // startRunNumber, endRunNumber - run validity period
261 // ocdbStorage - path to the OCDB storage
262 // - if empty - local storage 'pwd' uesed
263 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
265 fNotEnoughStatisticsForTheGain = kFALSE;
268 if(!ReadGainGlobal(file)) return;
271 // 2. extraction of the information
274 if(fBackCorrectGain) CorrectFromDetGainUsed();
275 //if(fBackCorrectVdrift) CorrectFromDetVdriftUsed();
277 // 3. Append QA plots
279 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
282 // 4. validate OCDB entries
284 if(fSwitchOnValidation==kTRUE && ValidateGain()==kFALSE) {
285 //AliError("TRD gain OCDB parameters out of range!");
292 if((!fCalDetVdriftUsed) || (fCalDetVdriftUsed && fVdriftValidated)) UpdateOCDBGain(startRunNumber,endRunNumber,ocdbStorage);
296 //________________________________________________________________________________________________________________
298 void AliTRDPreprocessorOffline::CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
300 // make calibration of the drift velocity
302 // file - the location of input file
303 // startRunNumber, endRunNumber - run validity period
304 // ocdbStorage - path to the OCDB storage
305 // - if empty - local storage 'pwd' uesed
306 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
309 if(!ReadPRFGlobal(file)) return;
312 // 2. extraction of the information
316 // 3. Append QA plots
318 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
322 // 4. validate OCDB entries
324 if(fSwitchOnValidation==kTRUE && ValidatePRF()==kFALSE) {
325 //AliError("TRD prf OCDB parameters out of range!");
332 UpdateOCDBPRF(startRunNumber,endRunNumber,ocdbStorage);
335 //________________________________________________________________________________________________________________
337 void AliTRDPreprocessorOffline::CalibChamberStatus(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
339 // make calibration of the chamber status
341 // startRunNumber, endRunNumber - run validity period
342 // ocdbStorage - path to the OCDB storage
343 // - if empty - local storage 'pwd' uesed
344 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
348 if(!ReadStatusGlobal(file)) return;
352 // 2. extraction of the information
354 if(!AnalyzeChamberStatus()) return;
356 // 3. Append QA plots
358 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
362 // 4. validate OCDB entries
364 if(fSwitchOnValidation==kTRUE && ValidateChamberStatus()==kFALSE) {
365 //AliError("TRD Chamber status OCDB parameters not ok!");
372 if((!fNotEnoughStatisticsForTheVdriftLinear) && (!fNotEnoughStatisticsForTheGain)) UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage);
373 //UpdateOCDBChamberStatus(startRunNumber,endRunNumber,ocdbStorage);
376 //______________________________________________________________________________________________________
377 Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){
379 // read the calibration used during the reconstruction
382 if(ReadVdriftT0Global(fileName)) {
384 TString nameph = fPH2d->GetTitle();
385 fFirstRunVdriftUsed = GetFirstRun(nameph);
386 fVersionVdriftUsed = GetVersion(nameph);
387 fSubVersionVdriftUsed = GetSubVersion(nameph);
389 //printf("Found Version %d, Subversion %d for vdrift\n",fVersionVdriftUsed,fSubVersionVdriftUsed);
393 if(ReadGainGlobal(fileName)) {
395 TString namech = fCH2d->GetTitle();
396 fFirstRunGainUsed = GetFirstRun(namech);
397 fVersionGainUsed = GetVersion(namech);
398 fSubVersionGainUsed = GetSubVersion(namech);
400 //printf("Found Version %d, Subversion %d for gain\n",fVersionGainUsed,fSubVersionGainUsed);
404 if(ReadVdriftLinearFitGlobal(fileName)) {
406 TString namelinear = fAliTRDCalibraVdriftLinearFit->GetNameCalibUsed();
407 fFirstRunExBUsed = GetFirstRun(namelinear);
408 fVersionExBUsed = GetVersion(namelinear);
409 fSubVersionExBUsed = GetSubVersion(namelinear);
411 //printf("Found Version %d, Subversion %d, run %d for ExB\n",fVersionExBUsed,fSubVersionExBUsed,fFirstRunExBUsed);
415 if(fVersionVdriftUsed == 0) fStatusPos = fStatusPos |kVdriftErrorOld;
416 if(fVersionGainUsed == 0) fStatusPos = fStatusPos | kGainErrorOld;
421 //___________________________________________________________________________________________________________________
423 Bool_t AliTRDPreprocessorOffline::ReadStatusGlobal(const Char_t* fileName){
425 // read calibration entries from file
427 if(fSparse) return kTRUE;
428 TFile fcalib(fileName);
429 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
431 fSparse = (THnSparseI *) array->FindObject("NumberOfEntries");
432 if(!fSparse) return kFALSE;
440 //___________________________________________________________________________________________________________________
442 Bool_t AliTRDPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){
444 // read calibration entries from file
446 if(fCH2d) return kTRUE;
447 TFile fcalib(fileName);
448 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
450 TH2I *ch2d = (TH2I *) array->FindObject("CH2d");
451 if(!ch2d) return kFALSE;
452 fCH2d = (TH2I*)ch2d->Clone();
453 //fNEvents = (TH1I *) array->FindObject("NEvents");
454 //fAbsoluteGain = (TH2F *) array->FindObject("AbsoluteGain");
456 TH2I *ch2d = (TH2I *) fcalib.Get("CH2d");
457 if(!ch2d) return kFALSE;
458 fCH2d = (TH2I*)ch2d->Clone();
459 //fNEvents = (TH1I *) fcalib.Get("NEvents");
460 //fAbsoluteGain = (TH2F *) fcalib.Get("AbsoluteGain");
462 fCH2d->SetDirectory(0);
463 //printf("title of CH2d %s\n",fCH2d->GetTitle());
468 //_________________________________________________________________________________________________________________
470 Bool_t AliTRDPreprocessorOffline::ReadVdriftT0Global(const Char_t* fileName){
472 // read calibration entries from file
474 if(fPH2d) return kTRUE;
475 TFile fcalib(fileName);
476 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
478 TProfile2D *ph2d = (TProfile2D *) array->FindObject("PH2d");
479 if(!ph2d) return kFALSE;
480 fPH2d = (TProfile2D*)ph2d->Clone();
481 //fNEvents = (TH1I *) array->FindObject("NEvents");
483 TProfile2D *ph2d = (TProfile2D *) fcalib.Get("PH2d");
484 if(!ph2d) return kFALSE;
485 fPH2d = (TProfile2D*)ph2d->Clone();
486 //fNEvents = (TH1I *) fcalib.Get("NEvents");
488 fPH2d->SetDirectory(0);
489 //printf("title of PH2d %s\n",fPH2d->GetTitle());
494 //___________________________________________________________________________________________________________________
496 Bool_t AliTRDPreprocessorOffline::ReadVdriftLinearFitGlobal(const Char_t* fileName){
498 // read calibration entries from file
500 if(fAliTRDCalibraVdriftLinearFit) return kTRUE;
501 TFile fcalib(fileName);
502 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
504 fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) array->FindObject("AliTRDCalibraVdriftLinearFit");
505 //fNEvents = (TH1I *) array->FindObject("NEvents");
507 fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) fcalib.Get("AliTRDCalibraVdriftLinearFit");
508 //fNEvents = (TH1I *) fcalib.Get("NEvents");
510 if(!fAliTRDCalibraVdriftLinearFit) {
511 //printf("No AliTRDCalibraVdriftLinearFit\n");
517 //_____________________________________________________________________________________________________________
518 Bool_t AliTRDPreprocessorOffline::ReadExbAltFitGlobal(const Char_t* fileName){
520 // read calibration entries from file
522 if(fAliTRDCalibraExbAltFit) return kTRUE;
523 TFile fcalib(fileName);
524 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
526 fAliTRDCalibraExbAltFit = (AliTRDCalibraExbAltFit *) array->FindObject("AliTRDCalibraExbAltFit");
527 //fNEvents = (TH1I *) array->FindObject("NEvents");
529 fAliTRDCalibraExbAltFit = (AliTRDCalibraExbAltFit *) fcalib.Get("AliTRDCalibraExbAltFit");
530 //fNEvents = (TH1I *) fcalib.Get("NEvents");
532 if(!fAliTRDCalibraExbAltFit) {
533 //printf("No AliTRDCalibraExbAltFit\n");
539 //_____________________________________________________________________________________________________________
541 Bool_t AliTRDPreprocessorOffline::ReadPRFGlobal(const Char_t* fileName){
543 // read calibration entries from file
545 if(fPRF2d) return kTRUE;
546 TFile fcalib(fileName);
547 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
549 TProfile2D *prf2d = (TProfile2D *) array->FindObject("PRF2d");
550 if(!prf2d) return kFALSE;
551 fPRF2d = (TProfile2D*)prf2d->Clone();
552 //fNEvents = (TH1I *) array->FindObject("NEvents");
554 TProfile2D *prf2d = (TProfile2D *) fcalib.Get("PRF2d");
555 if(!prf2d) return kFALSE;
556 fPRF2d = (TProfile2D*)prf2d->Clone();
557 //fNEvents = (TH1I *) fcalib.Get("NEvents");
559 fPRF2d->SetDirectory(0);
560 //printf("title of PRF2d %s\n",fPRF2d->GetTitle());
565 //__________________________________________________________________________________________________________
567 Bool_t AliTRDPreprocessorOffline::AnalyzeGain(){
569 // Analyze gain - produce the calibration objects
572 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
573 calibra->SetMinEntries(fMinStatsGain); // If there is less than 1000 entries in the histo: no fit
574 calibra->AnalyseCH(fCH2d);
576 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
577 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
578 Int_t nbfit = calibra->GetNumberFit();
579 Int_t nbE = calibra->GetNumberEnt();
583 Bool_t meanother = kFALSE;
586 (nbfit >= 0.5*nbE) && (nbE > 30)) {
587 // create the cal objects
588 if(!fBackCorrectGain) {
589 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
592 TObjArray object = calibra->GetVectorFit();
593 AliTRDCalDet *calDetGain = calibra->CreateDetObjectGain(&object,meanother);
594 TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet();
595 // Put them in the array
596 fCalibObjects->AddAt(calDetGain,kGain);
597 fPlots->AddAt(coefGain,kGain);
602 fNotEnoughStatisticsForTheGain = kTRUE;
603 Int_t minStatsGain = fMinStatsGain*30;
604 calibra->SetMinEntries(minStatsGain); // Because we do it for all, we increase this
605 Double_t gainoverallnotnormalized = calibra->AnalyseCHAllTogether(fCH2d);
606 if(fCalDetGainUsed && (gainoverallnotnormalized > 0.0)) {
607 AliTRDCalDet *calDetGain = new AliTRDCalDet(*fCalDetGainUsed);
608 Double_t oldmean = fCalDetGainUsed->CalcMean(kFALSE);
609 //printf("oldmean %f\n",oldmean);
611 Double_t scalefactor = calibra->GetScaleFactorGain();
612 //printf("Correction factor %f\n",gainoverallnotnormalized*scalefactor);
613 calDetGain->Multiply(gainoverallnotnormalized*scalefactor/oldmean);
614 //printf("newmean %f\n",calDetGain->CalcMean(kFALSE));
615 TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet();
616 fCalibObjects->AddAt(calDetGain,kGain);
617 fPlots->AddAt(coefGain,kGain);
620 fStatusNeg = fStatusNeg | kGainNotEnoughStatsButFill;
623 fStatusPos = fStatusPos | kGainErrorOld;
627 if(gainoverallnotnormalized <= 0.0) fStatusNeg = fStatusNeg | kGainNotEnoughStatsNotFill;
628 if(!fCalDetGainUsed) fStatusPos = fStatusPos | kGainErrorOld;
632 calibra->ResetVectorFit();
637 //_____________________________________________________________________________________________________
638 Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){
640 // Analyze VdriftT0 - produce the calibration objects
643 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
644 calibra->SetMinEntries(fMinStatsVdriftT0PH); // If there is less than 1000 entries in the histo: no fit
645 calibra->AnalysePH(fPH2d);
647 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
648 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
649 Int_t nbfit = calibra->GetNumberFit();
650 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
651 Int_t nbE = calibra->GetNumberEnt();
653 //printf("nbtg %d, nbfit %d, nbE %d, nbfitSuccess %d\n",nbtg,nbfit,nbE,nbfitSuccess);
657 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
658 //printf("Pass the cut for VdriftT0\n");
659 // create the cal objects
660 calibra->RemoveOutliers(1,kFALSE);
661 calibra->PutMeanValueOtherVectorFit(1,kFALSE);
662 calibra->RemoveOutliers2(kFALSE);
663 calibra->PutMeanValueOtherVectorFit2(1,kFALSE);
665 TObjArray object = calibra->GetVectorFit();
666 AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object);
667 TH1F *coefVdriftPH = calDetVdrift->MakeHisto1DAsFunctionOfDet();
668 AliTRDCalPad *calPadVdrift = (AliTRDCalPad *)calibra->CreatePadObjectVdrift(&object,calDetVdrift);
669 TH1F *coefPadVdrift = calPadVdrift->MakeHisto1D();
670 object = calibra->GetVectorFit2();
671 AliTRDCalDet *calDetT0 = calibra->CreateDetObjectT0(&object);
672 TH1F *coefT0 = calDetT0->MakeHisto1DAsFunctionOfDet();
673 AliTRDCalPad *calPadT0 = (AliTRDCalPad *)calibra->CreatePadObjectT0(&object,calDetT0);
674 TH1F *coefPadT0 = calPadT0->MakeHisto1D();
675 // Put them in the array
676 fCalibObjects->AddAt(calDetT0,kT0PHDet);
677 fCalibObjects->AddAt(calDetVdrift,kVdriftPHDet);
678 fCalibObjects->AddAt(calPadT0,kT0PHPad);
679 fCalibObjects->AddAt(calPadVdrift,kVdriftPHPad);
680 fPlots->AddAt(coefVdriftPH,kVdriftPHDet);
681 fPlots->AddAt(coefT0,kT0PHDet);
682 fPlots->AddAt(coefPadVdrift,kVdriftPHPad);
683 fPlots->AddAt(coefPadT0,kT0PHPad);
688 //printf("Not enough stats timeoffset\n");
689 fStatusNeg = fStatusNeg | kTimeOffsetNotEnoughStatsNotFill;
691 calibra->ResetVectorFit();
696 //____________________________________________________________________________________________________________________
697 Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){
699 // Analyze vdrift linear fit - produce the calibration objects
702 //printf("Analyse linear fit\n");
705 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
706 calibra->SetCalDetVdriftExB(fCalDetVdriftUsed,fCalDetExBUsed);
707 calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit
708 //printf("Fill PE Array\n");
709 fAliTRDCalibraVdriftLinearFit->FillPEArray();
710 //printf("AliTRDCalibraFit\n");
711 calibra->AnalyseLinearFitters(fAliTRDCalibraVdriftLinearFit);
715 Int_t nbfit = calibra->GetNumberFit();
716 Int_t nbE = calibra->GetNumberEnt();
721 if ((nbfit >= 0.5*nbE) && (nbE > 30)) {
722 // create the cal objects
723 //calibra->RemoveOutliers(1,kTRUE);
724 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
725 //calibra->RemoveOutliers2(kTRUE);
726 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
728 TObjArray object = calibra->GetVectorFit();
729 AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object,kTRUE);
730 TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet();
731 object = calibra->GetVectorFit2();
732 AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectLorentzAngle(&object);
733 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
734 //if(!calDetLorentz) printf("No lorentz created\n");
735 // Put them in the array
736 fCalibObjects->AddAt(calDetVdrift,kVdriftLinear);
737 fCalibObjects->AddAt(calDetLorentz,kLorentzLinear);
738 fPlots->AddAt(coefDriftLinear,kVdriftLinear);
739 fPlots->AddAt(coefLorentzAngle,kLorentzLinear);
744 fNotEnoughStatisticsForTheVdriftLinear = kTRUE;
745 Int_t minNumberOfEntriesForAll = fMinStatsVdriftLinear*30;
746 calibra->SetMinEntries(minNumberOfEntriesForAll); // Because we do it for all, we increase this
747 Double_t vdriftoverall = -100.0;
748 Double_t exboverall = 100.0;
749 calibra->AnalyseLinearFittersAllTogether(fAliTRDCalibraVdriftLinearFit,vdriftoverall,exboverall);
750 //printf("Found mean vdrift %f and exb %f\n",vdriftoverall,exboverall);
751 if(fCalDetVdriftUsed && (vdriftoverall > 0.0) && (exboverall < 70.0)) {
752 AliTRDCalDet *calDetVdrift = new AliTRDCalDet(*fCalDetVdriftUsed);
753 AliTRDCalDet *calDetLorentz = new AliTRDCalDet(*fCalDetExBUsed);
754 Double_t oldmeanvdrift = fCalDetVdriftUsed->CalcMean(kFALSE);
755 Double_t oldmeanexb = fCalDetExBUsed->CalcMean(kFALSE);
756 //printf("oldmean %f\n",oldmean);
757 if((oldmeanvdrift > 0.0) && (oldmeanexb < 70.0)) {
758 //printf("Correction factor %f\n",vdriftoverall);
759 calDetVdrift->Multiply(vdriftoverall/oldmeanvdrift);
760 calDetLorentz->Multiply(exboverall/oldmeanexb);
761 //printf("newmean %f\n",calDetVdrift->CalcMean(kFALSE));
762 TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet();
763 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
764 // Put them in the array
765 fCalibObjects->AddAt(calDetVdrift,kVdriftLinear);
766 fCalibObjects->AddAt(calDetLorentz,kLorentzLinear);
767 fPlots->AddAt(coefDriftLinear,kVdriftLinear);
768 fPlots->AddAt(coefLorentzAngle,kLorentzLinear);
771 fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsButFill;
774 if(oldmeanvdrift) fStatusPos = fStatusPos | kVdriftErrorOld;
775 if(oldmeanexb) fStatusPos = fStatusPos | kExBErrorOld;
779 if((vdriftoverall <= 0.0) && (exboverall > 70.0)) fStatusNeg = fStatusNeg | kVdriftNotEnoughStatsNotFill;
780 if(!fCalDetVdriftUsed) fStatusPos = fStatusPos | kVdriftErrorOld;
781 if(!fCalDetExBUsed) fStatusPos = fStatusPos | kExBErrorOld;
785 calibra->ResetVectorFit();
790 //________________________________________________________________________________________________________________
792 Bool_t AliTRDPreprocessorOffline::AnalyzeExbAltFit(){
794 // Analyze vdrift linear fit - produce the calibration objects
797 //printf("Analyse linear fit\n");
800 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
801 calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit
802 //printf("Fill PE Array\n");
803 fAliTRDCalibraExbAltFit->FillPEArray();
804 //printf("AliTRDCalibraFit\n");
805 calibra->AnalyseExbAltFit(fAliTRDCalibraExbAltFit);
809 Int_t nbfit = calibra->GetNumberFit();
810 Int_t nbE = calibra->GetNumberEnt();
815 if ((nbfit >= 0.5*nbE) && (nbE > 30)) {
816 // create the cal objects
817 //calibra->RemoveOutliers(1,kTRUE);
818 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
820 TObjArray object = calibra->GetVectorFit2();
821 AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectExbAlt(&object);
822 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
823 //if(!calDetLorentz) printf("No lorentz created\n");
824 // Put them in the array
825 fCalibObjects->AddAt(calDetLorentz,kExbAlt);
826 fPlots->AddAt(coefLorentzAngle,kExbAlt);
831 calibra->ResetVectorFit();
836 //________________________________________________________________________________________________________________
838 Bool_t AliTRDPreprocessorOffline::AnalyzePRF(){
840 // Analyze PRF - produce the calibration objects
843 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
844 calibra->SetMinEntries(fMinStatsPRF); // If there is less than 1000 entries in the histo: no fit
845 calibra->AnalysePRFMarianFit(fPRF2d);
847 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
848 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
849 Int_t nbfit = calibra->GetNumberFit();
850 Int_t nbE = calibra->GetNumberEnt();
856 (nbfit >= 0.95*nbE) && (nbE > 30)) {
857 // create the cal objects
858 TObjArray object = calibra->GetVectorFit();
859 AliTRDCalPad *calPadPRF = (AliTRDCalPad*) calibra->CreatePadObjectPRF(&object);
860 TH1F *coefPRF = calPadPRF->MakeHisto1D();
861 // Put them in the array
862 fCalibObjects->AddAt(calPadPRF,kPRF);
863 fPlots->AddAt(coefPRF,kPRF);
868 calibra->ResetVectorFit();
874 //_____________________________________________________________________________
875 Bool_t AliTRDPreprocessorOffline::AnalyzeChamberStatus()
878 // Produce AliTRDCalChamberStatus out of calibration results
881 // set up AliTRDCalibChamberStatus
882 AliTRDCalibChamberStatus *ChamberStatus = new AliTRDCalibChamberStatus();
883 ChamberStatus->SetSparseI(fSparse);
884 ChamberStatus->AnalyseHisto(fMinStatsChamberStatus);
885 // get AliTRDCalChamberStatus
886 AliTRDCalChamberStatus *CalChamberStatus = ChamberStatus->GetCalChamberStatus();
888 // get calibration objects
889 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
890 AliTRDCalDet *calDetVDrift = (AliTRDCalDet *) fCalibObjects->At(kVdriftLinear);
891 AliTRDCalDet *calDetExB = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear);
894 if((!calDetGain) || (!calDetVDrift) || (!fCH2d) || (!calDetExB) || (!CalChamberStatus)) return kFALSE;
897 Double_t gainmean = calDetGain->GetMean();
898 Double_t vdriftmean = calDetVDrift->GetMean();
899 Double_t exbmean = calDetExB->GetMean();
901 Double_t gainrms = calDetGain->GetRMSRobust();
902 Double_t vdriftrms = calDetVDrift->GetRMSRobust();
903 Double_t exbrms = calDetExB->GetRMSRobust();
905 //printf("Gain mean: %f, rms: %f\n",gainmean,gainrms);
906 //printf("Vdrift mean: %f, rms: %f\n",vdriftmean,vdriftrms);
907 //printf("ExB mean: %f, rms: %f\n",exbmean,exbrms);
910 if((TMath::Abs(gainrms) < 0.001) || (TMath::Abs(vdriftrms) < 0.001) || (TMath::Abs(exbrms) < 0.0000001)) return kFALSE;
912 // mask chambers with empty gain entries
914 for (Int_t idet = 0; idet < 540; idet++) {
917 TH1I *projch = (TH1I *) fCH2d->ProjectionX("projch",idet+1,idet+1,(Option_t *)"e");
918 Double_t entries = projch->GetEntries();
919 //printf("Number of entries %f for det %d\n",entries,idet);
922 Double_t gain = calDetGain->GetValue(idet);
925 Double_t vdrift = calDetVDrift->GetValue(idet);
928 Double_t exb = calDetExB->GetValue(idet);
931 if( (entries<50 && !CalChamberStatus->IsNoData(idet)) ||
932 TMath::Abs(gainmean-gain) > (fRMSBadCalibratedGain*gainrms) ||
933 TMath::Abs(vdriftmean-vdrift) > (fRMSBadCalibratedVdrift*vdriftrms) ||
934 TMath::Abs(exbmean-exb) > (fRMSBadCalibratedExB*exbrms) ) {
936 //printf(" chamber det %03d masked \n",idet);
937 //printf(" gainmean %f and gain %f, gainrms %f \n",gainmean,gain,gainrms);
938 //printf(" vdriftmean %f and vdrift %f, vdriftrms %f \n",vdriftmean,vdrift,vdriftrms);
939 //printf(" exbmean %f and exb %f, exbrms %f \n",exbmean,exb,exbrms);
941 CalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kBadCalibrated);
950 for(Int_t sm=0; sm < 18; sm++) {
952 Int_t smbadcalib = 0;
953 for(Int_t det = 0; det < 30; det++){
954 Int_t detector = sm*30+det;
955 if(CalChamberStatus->IsNoData(detector)) smnodata++;
957 if(CalChamberStatus->IsBadCalibrated(detector)) smbadcalib++;
960 fNoData[sm] = smnodata;
961 fBadCalib[sm]= smbadcalib;
962 //printf("No Data %d, bad calibrated %d for %d\n",fNoData[sm],fBadCalib[sm],sm);
966 // for(Int_t sm=0; sm < 18; sm++) {
967 // Int_t counter = 0;
968 // for(Int_t det = 0; det < 30; det++){
969 // Int_t detector = sm*30+det;
970 // if(CalChamberStatus->IsBadCalibrated(detector)) counter++;
972 // if(counter >= 20) {
973 // for(Int_t det = 0; det < 30; det++){
974 // Int_t detector = sm*30+det;
975 // CalChamberStatus->SetStatus(detector,AliTRDCalChamberStatus::kGood);
980 fCalibObjects->AddAt(CalChamberStatus,kChamberStatus);
986 //________________________________________________________________________________________________
987 void AliTRDPreprocessorOffline::CorrectFromDetGainUsed() {
989 // Correct from the gas gain used afterwards
991 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
992 if(!calDetGain) return;
998 for(Int_t det = 0; det < 540; det++) {
1000 Float_t gaininit = fCalDetGainUsed->GetValue(det);
1001 Float_t gainout = calDetGain->GetValue(det);
1004 if(TMath::Abs(gainout-1.0) > 0.000001) {
1005 mean += (gaininit*gainout);
1009 if(nbdet > 0) mean = mean/nbdet;
1011 for(Int_t det = 0; det < 540; det++) {
1013 Float_t gaininit = fCalDetGainUsed->GetValue(det);
1014 Float_t gainout = calDetGain->GetValue(det);
1016 if(TMath::Abs(gainout-1.0) > 0.000001) {
1017 Double_t newgain = gaininit*gainout;
1018 if(newgain < 0.1) newgain = 0.1;
1019 if(newgain > 1.9) newgain = 1.9;
1020 calDetGain->SetValue(det,newgain);
1023 Double_t newgain = mean;
1024 if(newgain < 0.1) newgain = 0.1;
1025 if(newgain > 1.9) newgain = 1.9;
1026 calDetGain->SetValue(det,newgain);
1032 //________________________________________________________________________________________________
1033 void AliTRDPreprocessorOffline::CorrectFromDetVdriftUsed() {
1035 // Correct from the drift velocity
1038 //printf("Correct for vdrift\n");
1040 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
1041 if(!calDetGain) return;
1043 Int_t detVdrift = kVdriftPHDet;
1044 if(fMethodSecond) detVdrift = kVdriftLinear;
1045 AliTRDCalDet *calDetVdrift = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
1046 if(!calDetVdrift) return;
1049 if(!fNotEnoughStatisticsForTheVdriftLinear) {
1050 for(Int_t det = 0; det < 540; det++) {
1052 Float_t vdriftinit = fCalDetVdriftUsed->GetValue(det);
1053 Float_t vdriftout = calDetVdrift->GetValue(det);
1055 Float_t gain = calDetGain->GetValue(det);
1056 if(vdriftout > 0.0) gain = gain*vdriftinit/vdriftout;
1057 if(gain < 0.1) gain = 0.1;
1058 if(gain > 1.9) gain = 1.9;
1059 calDetGain->SetValue(det,gain);
1064 Float_t vdriftinit = fCalDetVdriftUsed->CalcMean(kFALSE);
1065 Float_t vdriftout = calDetVdrift->CalcMean(kFALSE);
1066 Float_t factorcorrectif = 1.0;
1067 if(vdriftout > 0.0) factorcorrectif = vdriftinit/vdriftout;
1068 for(Int_t det = 0; det < 540; det++) {
1069 Float_t gain = calDetGain->GetValue(det);
1070 gain = gain*factorcorrectif;
1071 if(gain < 0.1) gain = 0.1;
1072 if(gain > 1.9) gain = 1.9;
1073 calDetGain->SetValue(det,gain);
1079 //_________________________________________________________________________________________________________________
1080 void AliTRDPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1082 // Update OCDB entry
1085 AliCDBMetaData *metaData= new AliCDBMetaData();
1086 metaData->SetObjectClassName("AliTRDCalDet");
1087 metaData->SetResponsible("Raphaelle Bailhache");
1088 metaData->SetBeamPeriod(1);
1090 AliCDBId id1("TRD/Calib/ChamberGainFactor", startRunNumber, endRunNumber);
1091 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1092 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain);
1093 if(calDet) gStorage->Put(calDet, id1, metaData);
1097 //___________________________________________________________________________________________________________________
1098 void AliTRDPreprocessorOffline::UpdateOCDBExB(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1100 // Update OCDB entry
1103 Int_t detExB = kLorentzLinear;
1104 if(!fMethodSecond) return;
1108 AliCDBMetaData *metaData= new AliCDBMetaData();
1109 metaData->SetObjectClassName("AliTRDCalDet");
1110 metaData->SetResponsible("Raphaelle Bailhache");
1111 metaData->SetBeamPeriod(1);
1113 AliCDBId id1("TRD/Calib/ChamberExB", startRunNumber, endRunNumber);
1114 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1115 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detExB);
1116 if(calDet) gStorage->Put(calDet, id1, metaData);
1117 //if(!calDet) printf("No caldet\n");
1120 //___________________________________________________________________________________________________________________
1121 void AliTRDPreprocessorOffline::UpdateOCDBExBAlt(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1123 // Update OCDB entry
1126 Int_t detExB = kExbAlt;
1127 if(!fMethodSecond) return;
1131 AliCDBMetaData *metaData= new AliCDBMetaData();
1132 metaData->SetObjectClassName("AliTRDCalDet");
1133 metaData->SetResponsible("Raphaelle Bailhache");
1134 metaData->SetBeamPeriod(1);
1136 AliCDBId id1("TRD/Calib/ChamberExBAlt", startRunNumber, endRunNumber);
1137 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1138 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detExB);
1139 if(calDet) gStorage->Put(calDet, id1, metaData);
1140 //if(!calDet) printf("No caldet\n");
1143 //___________________________________________________________________________________________________________________
1144 void AliTRDPreprocessorOffline::UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1146 // Update OCDB entry
1149 Int_t detVdrift = kVdriftPHDet;
1151 if(fMethodSecond) detVdrift = kVdriftLinear;
1153 AliCDBMetaData *metaData= new AliCDBMetaData();
1154 metaData->SetObjectClassName("AliTRDCalDet");
1155 metaData->SetResponsible("Raphaelle Bailhache");
1156 metaData->SetBeamPeriod(1);
1158 AliCDBId id1("TRD/Calib/ChamberVdrift", startRunNumber, endRunNumber);
1159 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1160 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
1161 if(calDet) gStorage->Put(calDet, id1, metaData);
1165 if(!fMethodSecond) {
1167 AliCDBMetaData *metaDataPad= new AliCDBMetaData();
1168 metaDataPad->SetObjectClassName("AliTRDCalPad");
1169 metaDataPad->SetResponsible("Raphaelle Bailhache");
1170 metaDataPad->SetBeamPeriod(1);
1172 AliCDBId id1Pad("TRD/Calib/LocalVdrift", startRunNumber, endRunNumber);
1173 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad);
1174 if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad);
1179 //________________________________________________________________________________________________________________________
1180 void AliTRDPreprocessorOffline::UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1182 // Update OCDB entry
1185 AliCDBMetaData *metaData= new AliCDBMetaData();
1186 metaData->SetObjectClassName("AliTRDCalDet");
1187 metaData->SetResponsible("Raphaelle Bailhache");
1188 metaData->SetBeamPeriod(1);
1190 AliCDBId id1("TRD/Calib/ChamberT0", startRunNumber, endRunNumber);
1191 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1192 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet);
1193 if(calDet) gStorage->Put(calDet, id1, metaData);
1197 AliCDBMetaData *metaDataPad= new AliCDBMetaData();
1198 metaDataPad->SetObjectClassName("AliTRDCalPad");
1199 metaDataPad->SetResponsible("Raphaelle Bailhache");
1200 metaDataPad->SetBeamPeriod(1);
1202 AliCDBId id1Pad("TRD/Calib/LocalT0", startRunNumber, endRunNumber);
1203 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad);
1204 if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad);
1209 //_________________________________________________________________________________________________________________
1210 void AliTRDPreprocessorOffline::UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1212 // Update OCDB entry
1215 AliCDBMetaData *metaData= new AliCDBMetaData();
1216 metaData->SetObjectClassName("AliTRDCalPad");
1217 metaData->SetResponsible("Raphaelle Bailhache");
1218 metaData->SetBeamPeriod(1);
1220 AliCDBId id1("TRD/Calib/PRFWidth", startRunNumber, endRunNumber);
1221 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1222 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF);
1223 if(calPad) gStorage->Put(calPad, id1, metaData);
1227 //_________________________________________________________________________________________________________________
1228 void AliTRDPreprocessorOffline::UpdateOCDBChamberStatus(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
1230 // Update OCDB entry
1233 AliCDBMetaData *metaData= new AliCDBMetaData();
1234 metaData->SetObjectClassName("AliTRDCalChamberStatus");
1235 metaData->SetResponsible("Raphaelle Bailhache");
1236 metaData->SetBeamPeriod(1);
1238 AliCDBId id1("TRD/Calib/ChamberStatus", startRunNumber, endRunNumber);
1239 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
1240 AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus);
1241 if(calChamberStatus) gStorage->Put(calChamberStatus, id1, metaData);
1245 //__________________________________________________________________________________________________________________________
1246 Bool_t AliTRDPreprocessorOffline::ValidateGain() {
1248 // Validate OCDB entry
1251 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain);
1253 Double_t mean = calDet->GetMean();
1254 Double_t rms = calDet->GetRMSRobust();
1255 if((mean > 0.2) && (mean < 1.4) && (rms < 0.5)) return kTRUE;
1256 //if((mean > 0.2) && (mean < 1.4)) return kTRUE;
1258 fStatusPos = fStatusPos | kGainErrorRange;
1267 //__________________________________________________________________________________________________________________________
1268 Bool_t AliTRDPreprocessorOffline::ValidateVdrift(){
1270 // Update OCDB entry
1273 Int_t detVdrift = kVdriftPHDet;
1276 if(fMethodSecond) detVdrift = kVdriftLinear;
1278 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
1280 Double_t mean = calDet->GetMean();
1281 Double_t rms = calDet->GetRMSRobust();
1282 //printf("Vdrift::mean %f, rms %f\n",mean,rms);
1283 if(!((mean > 1.0) && (mean < 2.0) && (rms < 0.5))) {
1284 fStatusPos = fStatusPos | kVdriftErrorRange;
1290 if(!fMethodSecond) {
1291 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad);
1293 Double_t mean = calPad->GetMean();
1294 Double_t rms = calPad->GetRMS();
1295 //printf("Vdrift::meanpad %f, rmspad %f\n",mean,rms);
1296 if(!((mean > 0.9) && (mean < 1.1) && (rms < 0.6))) {
1297 fStatusPos = fStatusPos | kVdriftErrorRange;
1307 //__________________________________________________________________________________________________________________________
1308 Bool_t AliTRDPreprocessorOffline::ValidateExB(){
1310 // Update OCDB entry
1313 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kLorentzLinear);
1315 Double_t mean = calDet->GetMean();
1316 Double_t rms = calDet->GetRMSRobust();
1317 //printf("Vdrift::mean %f, rms %f\n",mean,rms);
1318 if(!((mean > -1.0) && (mean < 1.0) && (rms < 0.5))) {
1319 fStatusNeg = fStatusNeg | kExBErrorRange;
1327 //__________________________________________________________________________________________________________________________
1328 Bool_t AliTRDPreprocessorOffline::ValidateT0(){
1330 // Update OCDB entry
1333 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet);
1334 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad);
1335 if(calDet && calPad) {
1336 Double_t meandet = calDet->GetMean();
1337 Double_t rmsdet = calDet->GetRMSRobust();
1338 Double_t meanpad = calPad->GetMean();
1339 //Double_t rmspad = calPad->GetRMS();
1340 //printf("T0::minimum %f, rmsdet %f,meanpad %f, rmspad %f\n",meandet,rmsdet,meanpad,rmspad);
1341 if((meandet > -1.5) && (meandet < 5.0) && (rmsdet < 4.0) && (meanpad < 5.0) && (meanpad > -0.5)) return kTRUE;
1343 fStatusPos = fStatusPos | kTimeOffsetErrorRange;
1350 //__________________________________________________________________________________________________________________________
1351 Bool_t AliTRDPreprocessorOffline::ValidatePRF() const{
1353 // Update OCDB entry
1356 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF);
1358 Double_t meanpad = calPad->GetMean();
1359 Double_t rmspad = calPad->GetRMS();
1360 //printf("PRF::meanpad %f, rmspad %f\n",meanpad,rmspad);
1361 if((meanpad < 1.0) && (rmspad < 0.8)) return kTRUE;
1368 //__________________________________________________________________________________________________________________________
1369 Bool_t AliTRDPreprocessorOffline::ValidateChamberStatus(){
1371 // Update OCDB entry
1374 AliTRDCalChamberStatus *calChamberStatus = (AliTRDCalChamberStatus *) fCalibObjects->At(kChamberStatus);
1375 if(calChamberStatus) {
1377 Int_t detectornodata = 0;
1378 Int_t detectorbadcalib = 0;
1380 for(Int_t sm=0; sm < 18; sm++) {
1381 //printf("%d chambers w/o data in sm %d\n",fNoData[sm],sm);
1382 //printf("%d bad calibrated chambers in sm %d\n",fBadCalib[sm],sm);
1383 if(fNoData[sm] != 30) detectornodata += fNoData[sm];
1384 detectorbadcalib+=fBadCalib[sm];
1386 //printf("Number of chambers w/o data %d\n",detectornodata);
1387 //printf("Number of chambers bad calibrated %d\n",detectorbadcalib);
1389 if((detectornodata > fNoDataValidate) ||
1390 (detectorbadcalib > fBadCalibValidate)){
1391 fStatusPos = fStatusPos | kChamberStatusErrorRange;
1399 //_____________________________________________________________________________
1400 Int_t AliTRDPreprocessorOffline::GetVersion(TString name) const
1403 // Get version from the title
1407 const Char_t *version = "Ver";
1408 if(!strstr(name.Data(),version)) return -1;
1409 const Char_t *after = "Subver";
1410 if(!strstr(name.Data(),after)) return -1;
1412 for(Int_t ver = 0; ver < 999999999; ver++) {
1414 TString vertry(version);
1418 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
1420 if(strstr(name.Data(),vertry.Data())) return ver;
1428 //_____________________________________________________________________________
1429 Int_t AliTRDPreprocessorOffline::GetSubVersion(TString name) const
1432 // Get subversion from the title
1436 const Char_t *subversion = "Subver";
1437 if(!strstr(name.Data(),subversion)) return -1;
1438 const Char_t *after = "FirstRun";
1439 if(!strstr(name.Data(),after)) {
1442 if(!strstr(name.Data(),after)) return -1;
1445 for(Int_t ver = 0; ver < 999999999; ver++) {
1447 TString vertry(subversion);
1451 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
1453 if(strstr(name.Data(),vertry.Data())) return ver;
1461 //_____________________________________________________________________________
1462 Int_t AliTRDPreprocessorOffline::GetFirstRun(TString name) const
1465 // Get first run from the title
1469 const Char_t *firstrun = "FirstRun";
1470 if(!strstr(name.Data(),firstrun)) return -1;
1471 const Char_t *after = "Nz";
1472 if(!strstr(name.Data(),after)) return -1;
1475 for(Int_t ver = 0; ver < 999999999; ver++) {
1477 TString vertry(firstrun);
1481 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
1483 if(strstr(name.Data(),vertry.Data())) return ver;
1490 //_____________________________________________________________________________
1491 Bool_t AliTRDPreprocessorOffline::CheckStatus(Int_t status, Int_t bitMask) const
1494 // Checks the status
1497 return (status & bitMask) ? kTRUE : kFALSE;
1500 //_____________________________________________________________________________
1501 Int_t AliTRDPreprocessorOffline::GetStatus() const
1504 // Checks the status
1505 // fStatusPos: errors
1506 // fStatusNeg: only info
1509 if(fStatusPos > 0) return fStatusPos;
1510 else return (-TMath::Abs(fStatusNeg));
1513 //_____________________________________________________________________________
1514 void AliTRDPreprocessorOffline::PrintStatus() const
1520 AliInfo(Form("The error status is %d",fStatusPos));
1521 AliInfo(Form("IsGainErrorOld? %d",(Int_t)IsGainErrorOld()));
1522 AliInfo(Form("IsVdriftErrorOld? %d",(Int_t)IsVdriftErrorOld()));
1523 AliInfo(Form("IsGainErrorRange? %d",(Int_t)IsGainErrorRange()));
1524 AliInfo(Form("IsVdriftErrorRange? %d",(Int_t)IsVdriftErrorRange()));
1525 AliInfo(Form("IsTimeOffsetErrorRange? %d",(Int_t)IsTimeOffsetErrorRange()));
1526 AliInfo(Form("IsChamberStatusErrorRange? %d",(Int_t)IsChamberStatusErrorRange()));
1529 AliInfo(Form("The info status is %d",fStatusNeg));
1530 AliInfo(Form("IsGainNotEnoughStatsButFill? %d",(Int_t)IsGainNotEnoughStatsButFill()));
1531 AliInfo(Form("IsVdriftNotEnoughStatsButFill? %d",(Int_t)IsVdriftNotEnoughStatsButFill()));
1532 AliInfo(Form("IsGainNotEnoughStatsNotFill? %d",(Int_t)IsGainNotEnoughStatsNotFill()));
1533 AliInfo(Form("IsVdriftNotEnoughStatsNotFill? %d",(Int_t)IsVdriftNotEnoughStatsNotFill()));
1534 AliInfo(Form("IsTimeOffsetNotEnoughStatsNotFill? %d",(Int_t)IsTimeOffsetNotEnoughStatsNotFill()));
1536 AliInfo(Form("IsExBErrorRange? %d",(Int_t)IsExBErrorRange()));
1537 AliInfo(Form("IsExBErrorOld? %d",(Int_t)IsExBErrorOld()));
1540 //___________________________________________________________________________________
1541 void AliTRDPreprocessorOffline::SetCalDetVdrift(AliTRDCalDet *calDetVdriftUsed)
1544 fCalDetVdriftUsed = calDetVdriftUsed;
1546 fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
1547 for(Int_t k = 0; k < 540; k++){
1548 fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
1549 //printf("Set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
1553 //___________________________________________________________________________________
1554 Bool_t AliTRDPreprocessorOffline::SetCalDetGain(Int_t runNumber, Int_t version, Int_t subversion)
1557 // Set the fCalDetGainUsed
1560 if((version == 0) && (subversion == 0)) return kFALSE;
1562 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",runNumber, version, subversion);
1564 AliError("Found no entry\n");
1565 fStatusPos = fStatusPos | kGainErrorOld;
1568 //const AliCDBId id = entry->GetId();
1569 //version = id.GetVersion();
1570 //subversion = id.GetSubVersion();
1571 //printf("Found version %d and subversion %d for vdrift\n",version,subversion);
1572 AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject();
1573 if(calDet) fCalDetGainUsed = calDet;
1575 fStatusPos = fStatusPos | kGainErrorOld;
1582 //___________________________________________________________________________________
1583 Bool_t AliTRDPreprocessorOffline::SetCalDetVdriftExB(Int_t runNumber, Int_t versionv, Int_t subversionv, Int_t versionexb, Int_t subversionexb)
1586 // Set the fCalDetVdriftUsed and fCalDetExBUsed
1589 if((versionv == 0) && (subversionv == 0)) return kFALSE;
1591 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberVdrift",runNumber, versionv, subversionv);
1593 AliError("Found no entry\n");
1594 fStatusPos = fStatusPos | kVdriftErrorOld;
1597 AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject();
1598 if(calDet) fCalDetVdriftUsed = calDet;
1600 fStatusPos = fStatusPos | kVdriftErrorOld;
1606 if((versionexb == 0) && (subversionexb == 0)) {
1608 fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
1609 for(Int_t k = 0; k < 540; k++){
1610 fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
1611 //printf("Nothing found: set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
1617 entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberExB",runNumber, versionexb, subversionexb);
1619 //printf("Found no entry\n");
1620 fStatusPos = fStatusPos | kExBErrorOld;
1623 AliTRDCalDet* calDetexb = (AliTRDCalDet *)entry->GetObject();
1625 fStatusPos = fStatusPos | kExBErrorOld;
1629 Double_t meanexb = calDetexb->GetMean();
1630 //printf("Mean value %f\n",meanexb);
1631 if((meanexb > 70) || (fNoExBUsedInReco)) {
1632 fCalDetExBUsed = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
1633 for(Int_t k = 0; k < 540; k++){
1634 fCalDetExBUsed->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDetVdriftUsed->GetValue(k)));
1635 //printf("Found but: set the exb object for detector %d, vdrift %f and exb %f\n",k,fCalDetVdriftUsed->GetValue(k),fCalDetExBUsed->GetValue(k));
1639 fCalDetExBUsed = calDetexb;