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"
49 #include "TProfile2D.h"
50 #include "AliTRDCalDet.h"
51 #include "AliTRDCalPad.h"
52 #include "AliCDBMetaData.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 #include "AliTRDCalChamberStatus.h"
63 ClassImp(AliTRDPreprocessorOffline)
65 AliTRDPreprocessorOffline::AliTRDPreprocessorOffline():
66 TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"),
68 fNameList("TRDCalib"),
70 fCalDetVdriftUsed(0x0),
74 fAliTRDCalibraVdriftLinearFit(0x0),
77 fPlots(new TObjArray(8)),
78 fCalibObjects(new TObjArray(8)),
80 fSubVersionGainUsed(0),
81 fVersionVdriftUsed(0),
82 fSubVersionVdriftUsed(0),
83 fSwitchOnValidation(kTRUE),
84 fVdriftValidated(kFALSE),
86 fMinStatsVdriftT0PH(800*20),
87 fMinStatsVdriftLinear(800),
92 // default constructor
95 //_________________________________________________________________________________________________________________
96 AliTRDPreprocessorOffline::~AliTRDPreprocessorOffline() {
101 if(fCalDetGainUsed) delete fCalDetGainUsed;
102 if(fCalDetVdriftUsed) delete fCalDetVdriftUsed;
103 if(fCH2d) delete fCH2d;
104 if(fPH2d) delete fPH2d;
105 if(fPRF2d) delete fPRF2d;
106 if(fAliTRDCalibraVdriftLinearFit) delete fAliTRDCalibraVdriftLinearFit;
107 if(fNEvents) delete fNEvents;
108 if(fAbsoluteGain) delete fAbsoluteGain;
109 if(fPlots) delete fPlots;
110 if(fCalibObjects) delete fCalibObjects;
113 //___________________________________________________________________________________________________________________
115 void AliTRDPreprocessorOffline::CalibVdriftT0(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
117 // make calibration of the drift velocity
119 // file - the location of input file
120 // startRunNumber, endRunNumber - run validity period
121 // ocdbStorage - path to the OCDB storage
122 // - if empty - local storage 'pwd' uesed
123 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
127 fVdriftValidated = kTRUE;
128 fT0Validated = kTRUE;
130 // 2. extraction of the information
132 if(ReadVdriftT0Global(file)) AnalyzeVdriftT0();
133 if(ReadVdriftLinearFitGlobal(file)) AnalyzeVdriftLinearFit();
135 // 3. Append QA plots
137 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
140 // 4. validate OCDB entries
142 if(fSwitchOnValidation==kTRUE && ValidateVdrift()==kFALSE) {
143 AliError("TRD vdrift OCDB parameters out of range!");
144 fVdriftValidated = kFALSE;
146 if(fSwitchOnValidation==kTRUE && ValidateT0()==kFALSE) {
147 AliError("TRD t0 OCDB parameters out of range!");
148 fT0Validated = kFALSE;
154 if(fVdriftValidated) UpdateOCDBVdrift(startRunNumber,endRunNumber,ocdbStorage);
155 if(fT0Validated) UpdateOCDBT0(startRunNumber,endRunNumber,ocdbStorage);
158 //_________________________________________________________________________________________________________________
160 void AliTRDPreprocessorOffline::CalibGain(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
162 // make calibration of the drift velocity
164 // file - the location of input file
165 // startRunNumber, endRunNumber - run validity period
166 // ocdbStorage - path to the OCDB storage
167 // - if empty - local storage 'pwd' uesed
168 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
171 if(!ReadGainGlobal(file)) return;
174 // 2. extraction of the information
177 if(fCalDetGainUsed) CorrectFromDetGainUsed();
178 if(fCalDetVdriftUsed) CorrectFromDetVdriftUsed();
180 // 3. Append QA plots
182 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
185 // 4. validate OCDB entries
187 if(fSwitchOnValidation==kTRUE && ValidateGain()==kFALSE) {
188 AliError("TRD gain OCDB parameters out of range!");
195 if((!fCalDetVdriftUsed) || (fCalDetVdriftUsed && fVdriftValidated)) UpdateOCDBGain(startRunNumber,endRunNumber,ocdbStorage);
199 //________________________________________________________________________________________________________________
201 void AliTRDPreprocessorOffline::CalibPRF(const Char_t* file, Int_t startRunNumber, Int_t endRunNumber, TString ocdbStorage){
203 // make calibration of the drift velocity
205 // file - the location of input file
206 // startRunNumber, endRunNumber - run validity period
207 // ocdbStorage - path to the OCDB storage
208 // - if empty - local storage 'pwd' uesed
209 if (ocdbStorage.Length()<=0) ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
212 if(!ReadPRFGlobal(file)) return;
215 // 2. extraction of the information
219 // 3. Append QA plots
221 //MakeDefaultPlots(fVdriftArray,fVdriftArray);
225 // 4. validate OCDB entries
227 if(fSwitchOnValidation==kTRUE && ValidatePRF()==kFALSE) {
228 AliError("TRD prf OCDB parameters out of range!");
235 UpdateOCDBPRF(startRunNumber,endRunNumber,ocdbStorage);
238 //______________________________________________________________________________________________________
239 Bool_t AliTRDPreprocessorOffline::Init(const Char_t* fileName){
241 // read the calibration used during the reconstruction
244 if(ReadVdriftT0Global(fileName)) {
246 TString nameph = fPH2d->GetTitle();
247 fVersionVdriftUsed = GetVersion(nameph);
248 fSubVersionVdriftUsed = GetSubVersion(nameph);
250 //printf("Found Version %d, Subversion %d for vdrift\n",fVersionVdriftUsed,fSubVersionVdriftUsed);
254 if(ReadGainGlobal(fileName)) {
256 TString namech = fCH2d->GetTitle();
257 fVersionGainUsed = GetVersion(namech);
258 fSubVersionGainUsed = GetSubVersion(namech);
260 //printf("Found Version %d, Subversion %d for gain\n",fVersionGainUsed,fSubVersionGainUsed);
267 //___________________________________________________________________________________________________________________
269 Bool_t AliTRDPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){
271 // read calibration entries from file
273 if(fCH2d) return kTRUE;
274 TFile fcalib(fileName);
275 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
277 TH2I *ch2d = (TH2I *) array->FindObject("CH2d");
278 if(!ch2d) return kFALSE;
279 fCH2d = (TH2I*)ch2d->Clone();
280 //fNEvents = (TH1I *) array->FindObject("NEvents");
281 //fAbsoluteGain = (TH2F *) array->FindObject("AbsoluteGain");
283 TH2I *ch2d = (TH2I *) fcalib.Get("CH2d");
284 if(!ch2d) return kFALSE;
285 fCH2d = (TH2I*)ch2d->Clone();
286 //fNEvents = (TH1I *) fcalib.Get("NEvents");
287 //fAbsoluteGain = (TH2F *) fcalib.Get("AbsoluteGain");
289 fCH2d->SetDirectory(0);
290 //printf("title of CH2d %s\n",fCH2d->GetTitle());
295 //_________________________________________________________________________________________________________________
297 Bool_t AliTRDPreprocessorOffline::ReadVdriftT0Global(const Char_t* fileName){
299 // read calibration entries from file
301 if(fPH2d) return kTRUE;
302 TFile fcalib(fileName);
303 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
305 TProfile2D *ph2d = (TProfile2D *) array->FindObject("PH2d");
306 if(!ph2d) return kFALSE;
307 fPH2d = (TProfile2D*)ph2d->Clone();
308 //fNEvents = (TH1I *) array->FindObject("NEvents");
310 TProfile2D *ph2d = (TProfile2D *) fcalib.Get("PH2d");
311 if(!ph2d) return kFALSE;
312 fPH2d = (TProfile2D*)ph2d->Clone();
313 //fNEvents = (TH1I *) fcalib.Get("NEvents");
315 fPH2d->SetDirectory(0);
316 //printf("title of PH2d %s\n",fPH2d->GetTitle());
321 //___________________________________________________________________________________________________________________
323 Bool_t AliTRDPreprocessorOffline::ReadVdriftLinearFitGlobal(const Char_t* fileName){
325 // read calibration entries from file
327 if(fAliTRDCalibraVdriftLinearFit) return kTRUE;
328 TFile fcalib(fileName);
329 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
331 fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) array->FindObject("AliTRDCalibraVdriftLinearFit");
332 //fNEvents = (TH1I *) array->FindObject("NEvents");
334 fAliTRDCalibraVdriftLinearFit = (AliTRDCalibraVdriftLinearFit *) fcalib.Get("AliTRDCalibraVdriftLinearFit");
335 //fNEvents = (TH1I *) fcalib.Get("NEvents");
337 if(!fAliTRDCalibraVdriftLinearFit) {
338 //printf("No AliTRDCalibraVdriftLinearFit\n");
344 //_____________________________________________________________________________________________________________
346 Bool_t AliTRDPreprocessorOffline::ReadPRFGlobal(const Char_t* fileName){
348 // read calibration entries from file
350 if(fPRF2d) return kTRUE;
351 TFile fcalib(fileName);
352 TObjArray * array = (TObjArray*)fcalib.Get(fNameList);
354 TProfile2D *prf2d = (TProfile2D *) array->FindObject("PRF2d");
355 if(!prf2d) return kFALSE;
356 fPRF2d = (TProfile2D*)prf2d->Clone();
357 //fNEvents = (TH1I *) array->FindObject("NEvents");
359 TProfile2D *prf2d = (TProfile2D *) fcalib.Get("PRF2d");
360 if(!prf2d) return kFALSE;
361 fPRF2d = (TProfile2D*)prf2d->Clone();
362 //fNEvents = (TH1I *) fcalib.Get("NEvents");
364 fPRF2d->SetDirectory(0);
365 //printf("title of PRF2d %s\n",fPRF2d->GetTitle());
370 //__________________________________________________________________________________________________________
372 Bool_t AliTRDPreprocessorOffline::AnalyzeGain(){
374 // Analyze gain - produce the calibration objects
377 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
378 calibra->SetMinEntries(fMinStatsGain); // If there is less than 1000 entries in the histo: no fit
379 calibra->AnalyseCH(fCH2d);
381 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
382 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
383 Int_t nbfit = calibra->GetNumberFit();
384 Int_t nbE = calibra->GetNumberEnt();
388 Bool_t meanother = kFALSE;
391 (nbfit >= 0.5*nbE) && (nbE > 30)) {
392 // create the cal objects
393 if(!fCalDetGainUsed) {
394 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
397 TObjArray object = calibra->GetVectorFit();
398 AliTRDCalDet *calDetGain = calibra->CreateDetObjectGain(&object,meanother);
399 TH1F *coefGain = calDetGain->MakeHisto1DAsFunctionOfDet();
400 // Put them in the array
401 fCalibObjects->AddAt(calDetGain,kGain);
402 fPlots->AddAt(coefGain,kGain);
407 calibra->ResetVectorFit();
412 //_____________________________________________________________________________________________________
413 Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftT0(){
415 // Analyze VdriftT0 - produce the calibration objects
418 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
419 calibra->SetMinEntries(fMinStatsVdriftT0PH); // If there is less than 1000 entries in the histo: no fit
420 calibra->AnalysePH(fPH2d);
422 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
423 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
424 Int_t nbfit = calibra->GetNumberFit();
425 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
426 Int_t nbE = calibra->GetNumberEnt();
428 //printf("nbtg %d, nbfit %d, nbE %d, nbfitSuccess %d\n",nbtg,nbfit,nbE,nbfitSuccess);
432 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
433 //printf("Pass the cut for VdriftT0\n");
434 // create the cal objects
435 calibra->RemoveOutliers(1,kFALSE);
436 calibra->PutMeanValueOtherVectorFit(1,kFALSE);
437 calibra->RemoveOutliers2(kFALSE);
438 calibra->PutMeanValueOtherVectorFit2(1,kFALSE);
440 TObjArray object = calibra->GetVectorFit();
441 AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object);
442 TH1F *coefVdriftPH = calDetVdrift->MakeHisto1DAsFunctionOfDet();
443 AliTRDCalPad *calPadVdrift = (AliTRDCalPad *)calibra->CreatePadObjectVdrift(&object,calDetVdrift);
444 TH1F *coefPadVdrift = calPadVdrift->MakeHisto1D();
445 object = calibra->GetVectorFit2();
446 AliTRDCalDet *calDetT0 = calibra->CreateDetObjectT0(&object);
447 TH1F *coefT0 = calDetT0->MakeHisto1DAsFunctionOfDet();
448 AliTRDCalPad *calPadT0 = (AliTRDCalPad *)calibra->CreatePadObjectT0(&object,calDetT0);
449 TH1F *coefPadT0 = calPadT0->MakeHisto1D();
450 // Put them in the array
451 fCalibObjects->AddAt(calDetT0,kT0PHDet);
452 fCalibObjects->AddAt(calDetVdrift,kVdriftPHDet);
453 fCalibObjects->AddAt(calPadT0,kT0PHPad);
454 fCalibObjects->AddAt(calPadVdrift,kVdriftPHPad);
455 fPlots->AddAt(coefVdriftPH,kVdriftPHDet);
456 fPlots->AddAt(coefT0,kT0PHDet);
457 fPlots->AddAt(coefPadVdrift,kVdriftPHPad);
458 fPlots->AddAt(coefPadT0,kT0PHPad);
462 calibra->ResetVectorFit();
467 //____________________________________________________________________________________________________________________
468 Bool_t AliTRDPreprocessorOffline::AnalyzeVdriftLinearFit(){
470 // Analyze vdrift linear fit - produce the calibration objects
473 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
474 calibra->SetMinEntries(fMinStatsVdriftLinear); // If there is less than 1000 entries in the histo: no fit
475 fAliTRDCalibraVdriftLinearFit->FillPEArray();
476 calibra->AnalyseLinearFitters(fAliTRDCalibraVdriftLinearFit);
479 Int_t nbfit = calibra->GetNumberFit();
480 Int_t nbE = calibra->GetNumberEnt();
485 if ((nbfit >= 0.5*nbE) && (nbE > 30)) {
486 // create the cal objects
487 //calibra->RemoveOutliers(1,kTRUE);
488 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
489 //calibra->RemoveOutliers2(kTRUE);
490 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
492 TObjArray object = calibra->GetVectorFit();
493 AliTRDCalDet *calDetVdrift = calibra->CreateDetObjectVdrift(&object,kTRUE);
494 TH1F *coefDriftLinear = calDetVdrift->MakeHisto1DAsFunctionOfDet();
495 object = calibra->GetVectorFit2();
496 AliTRDCalDet *calDetLorentz = calibra->CreateDetObjectLorentzAngle(&object);
497 TH1F *coefLorentzAngle = calDetLorentz->MakeHisto1DAsFunctionOfDet();
498 // Put them in the array
499 fCalibObjects->AddAt(calDetVdrift,kVdriftLinear);
500 fCalibObjects->AddAt(calDetLorentz,kLorentzLinear);
501 fPlots->AddAt(coefDriftLinear,kVdriftLinear);
502 fPlots->AddAt(coefLorentzAngle,kLorentzLinear);
507 calibra->ResetVectorFit();
512 //________________________________________________________________________________________________________________
514 Bool_t AliTRDPreprocessorOffline::AnalyzePRF(){
516 // Analyze PRF - produce the calibration objects
519 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
520 calibra->SetMinEntries(fMinStatsPRF); // If there is less than 1000 entries in the histo: no fit
521 calibra->AnalysePRFMarianFit(fPRF2d);
523 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
524 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
525 Int_t nbfit = calibra->GetNumberFit();
526 Int_t nbE = calibra->GetNumberEnt();
532 (nbfit >= 0.95*nbE) && (nbE > 30)) {
533 // create the cal objects
534 TObjArray object = calibra->GetVectorFit();
535 AliTRDCalPad *calPadPRF = (AliTRDCalPad*) calibra->CreatePadObjectPRF(&object);
536 TH1F *coefPRF = calPadPRF->MakeHisto1D();
537 // Put them in the array
538 fCalibObjects->AddAt(calPadPRF,kPRF);
539 fPlots->AddAt(coefPRF,kPRF);
544 calibra->ResetVectorFit();
549 //________________________________________________________________________________________________
550 void AliTRDPreprocessorOffline::CorrectFromDetGainUsed() {
552 // Correct from the gas gain used afterwards
554 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
555 if(!calDetGain) return;
561 for(Int_t det = 0; det < 540; det++) {
563 Float_t gaininit = fCalDetGainUsed->GetValue(det);
564 Float_t gainout = calDetGain->GetValue(det);
567 if(TMath::Abs(gainout-1.0) > 0.000001) {
568 mean += (gaininit*gainout);
572 if(nbdet > 0) mean = mean/nbdet;
574 for(Int_t det = 0; det < 540; det++) {
576 Float_t gaininit = fCalDetGainUsed->GetValue(det);
577 Float_t gainout = calDetGain->GetValue(det);
579 if(TMath::Abs(gainout-1.0) > 0.000001) calDetGain->SetValue(det,gaininit*gainout);
580 else calDetGain->SetValue(det,mean);
585 //________________________________________________________________________________________________
586 void AliTRDPreprocessorOffline::CorrectFromDetVdriftUsed() {
588 // Correct from the drift velocity
591 //printf("Correct for vdrift\n");
593 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
594 if(!calDetGain) return;
596 Int_t detVdrift = kVdriftPHDet;
597 if(fMethodSecond) detVdrift = kVdriftLinear;
598 AliTRDCalDet *calDetVdrift = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
599 if(!calDetVdrift) return;
603 for(Int_t det = 0; det < 540; det++) {
605 Float_t vdriftinit = fCalDetVdriftUsed->GetValue(det);
606 Float_t vdriftout = calDetVdrift->GetValue(det);
608 Float_t gain = calDetGain->GetValue(det);
609 if(vdriftout > 0.0) gain = gain*vdriftinit/vdriftout;
610 calDetGain->SetValue(det,gain);
616 //_________________________________________________________________________________________________________________
617 void AliTRDPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
622 AliCDBMetaData *metaData= new AliCDBMetaData();
623 metaData->SetObjectClassName("AliTRDCalDet");
624 metaData->SetResponsible("Raphaelle Bailhache");
625 metaData->SetBeamPeriod(1);
627 AliCDBId id1("TRD/Calib/ChamberGainFactor", startRunNumber, endRunNumber);
628 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
629 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain);
630 if(calDet) gStorage->Put(calDet, id1, metaData);
634 //___________________________________________________________________________________________________________________
635 void AliTRDPreprocessorOffline::UpdateOCDBVdrift(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
640 Int_t detVdrift = kVdriftPHDet;
642 if(fMethodSecond) detVdrift = kVdriftLinear;
644 AliCDBMetaData *metaData= new AliCDBMetaData();
645 metaData->SetObjectClassName("AliTRDCalDet");
646 metaData->SetResponsible("Raphaelle Bailhache");
647 metaData->SetBeamPeriod(1);
649 AliCDBId id1("TRD/Calib/ChamberVdrift", startRunNumber, endRunNumber);
650 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
651 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
652 if(calDet) gStorage->Put(calDet, id1, metaData);
658 AliCDBMetaData *metaDataPad= new AliCDBMetaData();
659 metaDataPad->SetObjectClassName("AliTRDCalPad");
660 metaDataPad->SetResponsible("Raphaelle Bailhache");
661 metaDataPad->SetBeamPeriod(1);
663 AliCDBId id1Pad("TRD/Calib/LocalVdrift", startRunNumber, endRunNumber);
664 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad);
665 if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad);
670 //________________________________________________________________________________________________________________________
671 void AliTRDPreprocessorOffline::UpdateOCDBT0(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
676 AliCDBMetaData *metaData= new AliCDBMetaData();
677 metaData->SetObjectClassName("AliTRDCalDet");
678 metaData->SetResponsible("Raphaelle Bailhache");
679 metaData->SetBeamPeriod(1);
681 AliCDBId id1("TRD/Calib/ChamberT0", startRunNumber, endRunNumber);
682 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
683 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet);
684 if(calDet) gStorage->Put(calDet, id1, metaData);
688 AliCDBMetaData *metaDataPad= new AliCDBMetaData();
689 metaDataPad->SetObjectClassName("AliTRDCalPad");
690 metaDataPad->SetResponsible("Raphaelle Bailhache");
691 metaDataPad->SetBeamPeriod(1);
693 AliCDBId id1Pad("TRD/Calib/LocalT0", startRunNumber, endRunNumber);
694 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad);
695 if(calPad) gStorage->Put(calPad, id1Pad, metaDataPad);
700 //_________________________________________________________________________________________________________________
701 void AliTRDPreprocessorOffline::UpdateOCDBPRF(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
706 AliCDBMetaData *metaData= new AliCDBMetaData();
707 metaData->SetObjectClassName("AliTRDCalPad");
708 metaData->SetResponsible("Raphaelle Bailhache");
709 metaData->SetBeamPeriod(1);
711 AliCDBId id1("TRD/Calib/PRFWidth", startRunNumber, endRunNumber);
712 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
713 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF);
714 if(calPad) gStorage->Put(calPad, id1, metaData);
718 //__________________________________________________________________________________________________________________________
719 Bool_t AliTRDPreprocessorOffline::ValidateGain() const {
721 // Validate OCDB entry
724 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kGain);
726 Double_t mean = calDet->GetMean();
727 Double_t rms = calDet->GetRMS();
728 if((mean > 0.2) && (mean < 1.4) && (rms < 0.5)) return kTRUE;
735 //__________________________________________________________________________________________________________________________
736 Bool_t AliTRDPreprocessorOffline::ValidateVdrift(){
741 Int_t detVdrift = kVdriftPHDet;
744 if(fMethodSecond) detVdrift = kVdriftLinear;
746 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(detVdrift);
748 Double_t mean = calDet->GetMean();
749 Double_t rms = calDet->GetRMS();
750 //printf("Vdrift::mean %f, rms %f\n",mean,rms);
751 if(!((mean > 1.0) && (mean < 2.0) && (rms < 0.5))) ok = kFALSE;
756 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kVdriftPHPad);
758 Double_t mean = calPad->GetMean();
759 Double_t rms = calPad->GetRMS();
760 //printf("Vdrift::meanpad %f, rmspad %f\n",mean,rms);
761 if(!((mean > 0.9) && (mean < 1.1) && (rms < 0.6))) ok = kFALSE;
769 //__________________________________________________________________________________________________________________________
770 Bool_t AliTRDPreprocessorOffline::ValidateT0(){
775 AliTRDCalDet *calDet = (AliTRDCalDet *) fCalibObjects->At(kT0PHDet);
776 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kT0PHPad);
777 if(calDet && calPad) {
778 Double_t meandet = calDet->GetMean();
779 Double_t rmsdet = calDet->GetRMS();
780 Double_t meanpad = calPad->GetMean();
781 //Double_t rmspad = calPad->GetRMS();
782 //printf("T0::minimum %f, rmsdet %f,meanpad %f, rmspad %f\n",meandet,rmsdet,meanpad,rmspad);
783 if((meandet > -1.5) && (meandet < 5.0) && (rmsdet < 4.0) && (meanpad < 5.0) && (meanpad > -0.5)) return kTRUE;
789 //__________________________________________________________________________________________________________________________
790 Bool_t AliTRDPreprocessorOffline::ValidatePRF() const{
795 AliTRDCalPad *calPad = (AliTRDCalPad *) fCalibObjects->At(kPRF);
797 Double_t meanpad = calPad->GetMean();
798 Double_t rmspad = calPad->GetRMS();
799 //printf("PRF::meanpad %f, rmspad %f\n",meanpad,rmspad);
800 if((meanpad < 1.0) && (rmspad < 0.8)) return kTRUE;
807 //_____________________________________________________________________________
808 Int_t AliTRDPreprocessorOffline::GetVersion(TString name) const
811 // Get version from the title
815 const Char_t *version = "Ver";
816 if(!strstr(name.Data(),version)) return -1;
818 for(Int_t ver = 0; ver < 999999999; ver++) {
820 TString vertry(version);
824 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
826 if(strstr(name.Data(),vertry.Data())) return ver;
834 //_____________________________________________________________________________
835 Int_t AliTRDPreprocessorOffline::GetSubVersion(TString name) const
838 // Get subversion from the title
842 const Char_t *subversion = "Subver";
843 if(!strstr(name.Data(),subversion)) return -1;
845 for(Int_t ver = 0; ver < 999999999; ver++) {
847 TString vertry(subversion);
851 //printf("vertry %s and name %s\n",vertry.Data(),name.Data());
853 if(strstr(name.Data(),vertry.Data())) return ver;
861 //_____________________________________________________________________________
862 AliTRDCalChamberStatus *AliTRDPreprocessorOffline::ProduceChamberStatus()
865 // Produce AliTRDCalChamberStatus out of calibration results
868 // set up AliTRDCalChamberStatus
869 AliTRDCalChamberStatus *CalChamberStatus = new AliTRDCalChamberStatus();
871 // get calibration objects
872 AliTRDCalDet *calDetGain = (AliTRDCalDet *) fCalibObjects->At(kGain);
873 AliTRDCalDet *calDetVDrift = (AliTRDCalDet *) fCalibObjects->At(kVdriftLinear);
875 // mask chambers with empty gain entries
877 for (Int_t idet = 0; idet < 540; idet++) {
880 TH1I *projch = (TH1I *) fCH2d->ProjectionX("projch",idet+1,idet+1,(Option_t *)"e");
881 if (!projch) continue;
883 Int_t entries = static_cast<Int_t>(projch->GetEntries());
886 Double_t defaultgain = calDetGain->GetMean();
887 Double_t gain = calDetGain->GetValue(idet);
890 Double_t defaultvdrift = calDetVDrift->GetMean();
891 Double_t vdrift = calDetVDrift->GetValue(idet);
894 TMath::Abs(defaultgain-gain) < 0.5 ||
895 TMath::Abs(defaultvdrift-vdrift) < 0.1) {
897 printf(" chamber det %03d masked \n",idet);
898 CalChamberStatus->SetStatus(idet,2);
902 // installed supermodules+1 -> abort
903 if(counter > (7+1)*30) {
904 printf("ERROR: more than one SM to be masked!! \n Abort...\n");
912 return CalChamberStatus;