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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Class providing the calibration parameters by accessing the CDB //
21 // Request an instance with AliTPCcalibDB::Instance() //
22 // If a new event is processed set the event number with SetRun //
23 // Then request the calibration data ////
28 // Simulation - not yet
29 // Reconstruction - AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
31 // 1.) pad by pad calibration - AliTPCCalPad
34 // Simulation: AliTPCDigitizer::ExecFast - Multiply by gain
35 // Reconstruction : AliTPCclustererMI::Digits2Clusters - Divide by gain
38 // Simulation: AliTPCDigitizer::ExecFast
39 // Reconstruction: AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
40 // Noise depending cut on clusters charge (n sigma)
42 // Simulation: Not used yet - To be impleneted - Rounding to the nearest integer
43 // Reconstruction: Used in AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
44 // if data taken without zero suppression
45 // Currently switch in fRecoParam->GetCalcPedestal();
48 // Simulation: applied in the AliTPC::MakeSector - adding offset
49 // Reconstruction: AliTPCTransform::Transform() - remove offset
50 // AliTPCTransform::Transform() - to be called
51 // in AliTPCtracker::Transform()
54 // 2.) Space points transformation:
56 // a.) General coordinate tranformation - AliTPCtransform (see $ALICE_ROOT/TPC/AliTPCtransform.cxx)
57 // Created on fly - use the other calibration components
58 // Unisochronity - (substract time0 - pad by pad)
59 // Drift velocity - Currently common drift velocity - functionality of AliTPCParam
61 // Simulation - Not used directly (the effects are applied one by one (see AliTPC::MakeSector)
63 // AliTPCclustererMI::AddCluster
64 // AliTPCtrackerMI::Transform
65 // b.) ExB effect calibration -
66 // classes (base class AliTPCExB, implementation- AliTPCExBExact.h AliTPCExBFirst.h)
67 // a.a) Simulation: applied in the AliTPC::MakeSector -
68 // calib->GetExB()->CorrectInverse(dxyz0,dxyz1);
69 // a.b) Reconstruction -
71 // in AliTPCtransform::Correct() - called calib->GetExB()->Correct(dxyz0,dxyz1)
73 // 3.) cluster error, shape and Q parameterization
77 ///////////////////////////////////////////////////////////////////////////////
83 #include <AliCDBManager.h>
84 #include <AliCDBEntry.h>
87 #include <AliSplineFit.h>
89 #include "AliTPCcalibDB.h"
90 #include "AliTPCAltroMapping.h"
91 #include "AliTPCExB.h"
93 #include "AliTPCCalROC.h"
94 #include "AliTPCCalPad.h"
95 #include "AliTPCSensorTempArray.h"
96 #include "AliGRPObject.h"
97 #include "AliTPCTransform.h"
107 #include "TObjArray.h"
108 #include "TObjString.h"
110 #include "AliTPCCalPad.h"
111 #include "AliTPCCalibPulser.h"
112 #include "AliTPCCalibPedestal.h"
113 #include "AliTPCCalibCE.h"
114 #include "AliTPCExBFirst.h"
115 #include "AliTPCTempMap.h"
116 #include "AliTPCCalibVdrift.h"
118 #include "AliTPCPreprocessorOnline.h"
121 ClassImp(AliTPCcalibDB)
123 AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
124 Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
125 TObjArray AliTPCcalibDB::fgExBArray; // array of ExB corrections
128 //_ singleton implementation __________________________________________________
129 AliTPCcalibDB* AliTPCcalibDB::Instance()
132 // Singleton implementation
133 // Returns an instance of this class, it is created if neccessary
136 if (fgTerminated != kFALSE)
140 fgInstance = new AliTPCcalibDB();
145 void AliTPCcalibDB::Terminate()
148 // Singleton implementation
149 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
150 // This function can be called several times.
153 fgTerminated = kTRUE;
162 //_____________________________________________________________________________
163 AliTPCcalibDB::AliTPCcalibDB():
181 fTimeGainSplinesArray(100000),
182 fGRPArray(100000), //! array of GRPs - per run - JUST for calibration studies
183 fGRPMaps(100000), //! array of GRPs - per run - JUST for calibration studies
184 fGoofieArray(100000), //! array of GOOFIE values -per run - Just for calibration studies
185 fVoltageArray(100000),
186 fTemperatureArray(100000), //! array of temperature sensors - per run - Just for calibration studies
187 fVdriftArray(100000), //! array of v drift interfaces
188 fDriftCorrectionArray(100000), //! array of drift correction
189 fRunList(100000) //! run list - indicates try to get the run param
196 Update(); // temporary
199 AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
217 fTimeGainSplinesArray(100000),
218 fGRPArray(0), //! array of GRPs - per run - JUST for calibration studies
219 fGRPMaps(0), //! array of GRPs - per run - JUST for calibration studies
220 fGoofieArray(0), //! array of GOOFIE values -per run - Just for calibration studies
222 fTemperatureArray(0), //! array of temperature sensors - per run - Just for calibration studies
223 fVdriftArray(0), //! array of v drift interfaces
224 fDriftCorrectionArray(0), //! array of v drift interfaces
225 fRunList(0) //! run list - indicates try to get the run param
228 // Copy constructor invalid -- singleton implementation
230 Error("copy constructor","invalid -- singleton implementation");
233 AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& )
236 // Singleton implementation - no assignment operator
238 Error("operator =", "assignment operator not implemented");
244 //_____________________________________________________________________________
245 AliTPCcalibDB::~AliTPCcalibDB()
251 // don't delete anything, CDB cache is active!
252 //if (fPadGainFactor) delete fPadGainFactor;
253 //if (fPadTime0) delete fPadTime0;
254 //if (fPadNoise) delete fPadNoise;
258 //_____________________________________________________________________________
259 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
262 // Retrieves an entry with path <cdbPath> from the CDB.
266 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
269 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
277 //_____________________________________________________________________________
278 void AliTPCcalibDB::SetRun(Long64_t run)
281 // Sets current run number. Calibration data is read from the corresponding file.
291 void AliTPCcalibDB::Update(){
293 AliCDBEntry * entry=0;
295 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
296 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
299 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
301 //if (fPadGainFactor) delete fPadGainFactor;
302 entry->SetOwner(kTRUE);
303 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
306 entry = GetCDBEntry("TPC/Calib/TimeGain");
308 //if (fTimeGainSplines) delete fTimeGainSplines;
309 entry->SetOwner(kTRUE);
310 fTimeGainSplines = (TObjArray*)entry->GetObject();
313 entry = GetCDBEntry("TPC/Calib/GainFactorDedx");
315 entry->SetOwner(kTRUE);
316 fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
319 entry = GetCDBEntry("TPC/Calib/PadTime0");
321 //if (fPadTime0) delete fPadTime0;
322 entry->SetOwner(kTRUE);
323 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
327 entry = GetCDBEntry("TPC/Calib/PadNoise");
329 //if (fPadNoise) delete fPadNoise;
330 entry->SetOwner(kTRUE);
331 fPadNoise = (AliTPCCalPad*)entry->GetObject();
334 entry = GetCDBEntry("TPC/Calib/Pedestals");
336 //if (fPedestals) delete fPedestals;
337 entry->SetOwner(kTRUE);
338 fPedestals = (AliTPCCalPad*)entry->GetObject();
341 entry = GetCDBEntry("TPC/Calib/Temperature");
343 //if (fTemperature) delete fTemperature;
344 entry->SetOwner(kTRUE);
345 fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
348 entry = GetCDBEntry("TPC/Calib/Parameters");
350 //if (fPadNoise) delete fPadNoise;
351 entry->SetOwner(kTRUE);
352 fParam = (AliTPCParam*)(entry->GetObject()->Clone());
355 entry = GetCDBEntry("TPC/Calib/ClusterParam");
357 entry->SetOwner(kTRUE);
358 fClusterParam = (AliTPCClusterParam*)(entry->GetObject()->Clone());
361 //ALTRO configuration data
362 entry = GetCDBEntry("TPC/Calib/AltroConfig");
364 entry->SetOwner(kTRUE);
365 fALTROConfigData=(TObjArray*)(entry->GetObject());
368 //Calibration Pulser data
369 entry = GetCDBEntry("TPC/Calib/Pulser");
371 entry->SetOwner(kTRUE);
372 fPulserData=(TObjArray*)(entry->GetObject());
376 entry = GetCDBEntry("TPC/Calib/CE");
378 entry->SetOwner(kTRUE);
379 fCEData=(TObjArray*)(entry->GetObject());
382 entry = GetCDBEntry("TPC/Calib/Mapping");
384 //if (fPadNoise) delete fPadNoise;
385 entry->SetOwner(kTRUE);
386 TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
387 if (array && array->GetEntriesFast()==6){
388 fMapping = new AliTPCAltroMapping*[6];
389 for (Int_t i=0; i<6; i++){
390 fMapping[i] = dynamic_cast<AliTPCAltroMapping*>(array->At(i));
397 //entry = GetCDBEntry("TPC/Calib/ExB");
399 // entry->SetOwner(kTRUE);
400 // fExB=dynamic_cast<AliTPCExB*>(entry->GetObject()->Clone());
403 // ExB - calculate during initialization
405 fExB = GetExB(-5,kTRUE);
408 fTransform=new AliTPCTransform();
409 fTransform->SetCurrentRun(AliCDBManager::Instance()->GetRun());
413 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
419 void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
422 // Create calibration objects and read contents from OCDB
424 if ( calibObjects == 0x0 ) return;
427 if ( !in.is_open() ){
428 fprintf(stderr,"Error: cannot open list file '%s'", filename);
432 AliTPCCalPad *calPad=0x0;
438 TObjArray *arrFileLine = sFile.Tokenize("\n");
440 TIter nextLine(arrFileLine);
442 TObjString *sObjLine=0x0;
443 while ( (sObjLine = (TObjString*)nextLine()) ){
444 TString sLine(sObjLine->GetString());
446 TObjArray *arrNextCol = sLine.Tokenize("\t");
448 TObjString *sObjType = (TObjString*)(arrNextCol->At(0));
449 TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
451 if ( !sObjType || ! sObjFileName ) continue;
452 TString sType(sObjType->GetString());
453 TString sFileName(sObjFileName->GetString());
454 printf("%s\t%s\n",sType.Data(),sFileName.Data());
456 TFile *fIn = TFile::Open(sFileName);
458 fprintf(stderr,"File not found: '%s'", sFileName.Data());
462 if ( sType == "CE" ){
463 AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
465 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
466 calPad->SetNameTitle("CETmean","CETmean");
467 calibObjects->Add(calPad);
469 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
470 calPad->SetNameTitle("CEQmean","CEQmean");
471 calibObjects->Add(calPad);
473 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
474 calPad->SetNameTitle("CETrms","CETrms");
475 calibObjects->Add(calPad);
477 } else if ( sType == "Pulser") {
478 AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
480 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());
481 calPad->SetNameTitle("PulserTmean","PulserTmean");
482 calibObjects->Add(calPad);
484 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());
485 calPad->SetNameTitle("PulserQmean","PulserQmean");
486 calibObjects->Add(calPad);
488 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
489 calPad->SetNameTitle("PulserTrms","PulserTrms");
490 calibObjects->Add(calPad);
492 } else if ( sType == "Pedestals") {
493 AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
495 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());
496 calPad->SetNameTitle("Pedestals","Pedestals");
497 calibObjects->Add(calPad);
499 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());
500 calPad->SetNameTitle("Noise","Noise");
501 calibObjects->Add(calPad);
504 fprintf(stderr,"Undefined Type: '%s'",sType.Data());
513 void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
515 // Write a tree with all available information
516 // if mapFileName is specified, the Map information are also written to the tree
517 // pads specified in outlierPad are not used for calculating statistics
518 // - the same function as AliTPCCalPad::MakeTree -
520 AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
522 TObjArray* mapIROCs = 0;
523 TObjArray* mapOROCs = 0;
524 TVectorF *mapIROCArray = 0;
525 TVectorF *mapOROCArray = 0;
526 Int_t mapEntries = 0;
527 TString* mapNames = 0;
530 TFile mapFile(mapFileName, "read");
532 TList* listOfROCs = mapFile.GetListOfKeys();
533 mapEntries = listOfROCs->GetEntries()/2;
534 mapIROCs = new TObjArray(mapEntries*2);
535 mapOROCs = new TObjArray(mapEntries*2);
536 mapIROCArray = new TVectorF[mapEntries];
537 mapOROCArray = new TVectorF[mapEntries];
539 mapNames = new TString[mapEntries];
540 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
541 TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
542 nameROC.Remove(nameROC.Length()-4, 4);
543 mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
544 mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
545 mapNames[ivalue].Append(nameROC);
548 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
549 mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
550 mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
552 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
553 (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
554 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
555 (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
558 } // if (mapFileName)
560 TTreeSRedirector cstream(fileName);
561 Int_t arrayEntries = array->GetEntries();
563 TString* names = new TString[arrayEntries];
564 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
565 names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
567 for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
569 // get statistic for given sector
571 TVectorF median(arrayEntries);
572 TVectorF mean(arrayEntries);
573 TVectorF rms(arrayEntries);
574 TVectorF ltm(arrayEntries);
575 TVectorF ltmrms(arrayEntries);
576 TVectorF medianWithOut(arrayEntries);
577 TVectorF meanWithOut(arrayEntries);
578 TVectorF rmsWithOut(arrayEntries);
579 TVectorF ltmWithOut(arrayEntries);
580 TVectorF ltmrmsWithOut(arrayEntries);
582 TVectorF *vectorArray = new TVectorF[arrayEntries];
583 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
584 vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
586 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
587 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
588 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
589 AliTPCCalROC* outlierROC = 0;
590 if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
592 median[ivalue] = calROC->GetMedian();
593 mean[ivalue] = calROC->GetMean();
594 rms[ivalue] = calROC->GetRMS();
595 Double_t ltmrmsValue = 0;
596 ltm[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction);
597 ltmrms[ivalue] = ltmrmsValue;
599 medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
600 meanWithOut[ivalue] = calROC->GetMean(outlierROC);
601 rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
603 ltmWithOut[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction, outlierROC);
604 ltmrmsWithOut[ivalue] = ltmrmsValue;
613 medianWithOut[ivalue] = 0.;
614 meanWithOut[ivalue] = 0.;
615 rmsWithOut[ivalue] = 0.;
616 ltmWithOut[ivalue] = 0.;
617 ltmrmsWithOut[ivalue] = 0.;
622 // fill vectors of variable per pad
624 TVectorF *posArray = new TVectorF[8];
625 for (Int_t ivalue = 0; ivalue < 8; ivalue++)
626 posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
628 Float_t posG[3] = {0};
629 Float_t posL[3] = {0};
631 for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
632 for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
633 tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
634 tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
635 posArray[0][ichannel] = irow;
636 posArray[1][ichannel] = ipad;
637 posArray[2][ichannel] = posL[0];
638 posArray[3][ichannel] = posL[1];
639 posArray[4][ichannel] = posG[0];
640 posArray[5][ichannel] = posG[1];
641 posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
642 posArray[7][ichannel] = ichannel;
644 // loop over array containing AliTPCCalPads
645 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
646 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
647 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
649 (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
651 (vectorArray[ivalue])[ichannel] = 0;
657 cstream << "calPads" <<
658 "sector=" << isector;
660 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
661 cstream << "calPads" <<
662 (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
663 (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
664 (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
665 (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
666 (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
668 cstream << "calPads" <<
669 (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
670 (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
671 (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
672 (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
673 (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
677 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
678 cstream << "calPads" <<
679 (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
683 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
685 cstream << "calPads" <<
686 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
688 cstream << "calPads" <<
689 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
693 cstream << "calPads" <<
694 "row.=" << &posArray[0] <<
695 "pad.=" << &posArray[1] <<
696 "lx.=" << &posArray[2] <<
697 "ly.=" << &posArray[3] <<
698 "gx.=" << &posArray[4] <<
699 "gy.=" << &posArray[5] <<
700 "rpad.=" << &posArray[6] <<
701 "channel.=" << &posArray[7];
703 cstream << "calPads" <<
707 delete[] vectorArray;
715 delete[] mapIROCArray;
716 delete[] mapOROCArray;
723 void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
725 // Register static ExB correction map
726 // index - registration index - used for visualization
727 // bz - bz field in kGaus
729 Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
731 AliMagF* bmap = new AliMagF("MapsExB","MapsExB", 2,factor,1., 10.,AliMagF::k5kG,"$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
733 AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
734 AliTPCExB::SetInstance(exb);
739 AliTPCExB::RegisterField(index,bmap);
741 if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
742 fgExBArray.AddAt(exb,index);
746 AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
748 // bz filed in KGaus not in tesla
749 // Get ExB correction map
750 // if doesn't exist - create it
752 Int_t index = TMath::Nint(5+bz);
753 if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
754 if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
755 return (AliTPCExB*)fgExBArray.At(index);
759 void AliTPCcalibDB::SetExBField(Float_t bz){
761 // Set magnetic filed for ExB correction
763 fExB = GetExB(bz,kFALSE);
770 void AliTPCcalibDB::UpdateRunInformations( Int_t run, Bool_t force){
772 // - > Don't use it for reconstruction - Only for Calibration studies
774 AliCDBEntry * entry = 0;
775 if (run>= fRunList.GetSize()){
776 fRunList.Set(run*2+1);
777 fGRPArray.Expand(run*2+1);
778 fGRPMaps.Expand(run*2+1);
779 fGoofieArray.Expand(run*2+1);
780 fVoltageArray.Expand(run*2+1);
781 fTemperatureArray.Expand(run*2+1);
782 fVdriftArray.Expand(run*2+1);
783 fDriftCorrectionArray.Expand(run*2+1);
784 fTimeGainSplinesArray.Expand(run*2+1);
786 if (fRunList[run]>0 &&force==kFALSE) return;
788 entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
790 AliGRPObject * grpRun = dynamic_cast<AliGRPObject*>(entry->GetObject());
792 TMap* map = dynamic_cast<TMap*>(entry->GetObject());
794 //grpRun = new AliGRPObject;
795 //grpRun->ReadValuesFromMap(map);
796 grpRun = MakeGRPObjectFromMap(map);
798 fGRPMaps.AddAt(map,run);
801 fGRPArray.AddAt(grpRun,run);
803 entry = AliCDBManager::Instance()->Get("TPC/Calib/Goofie",run);
805 fGoofieArray.AddAt(entry->GetObject(),run);
808 entry = AliCDBManager::Instance()->Get("TPC/Calib/HighVoltage",run);
810 fVoltageArray.AddAt(entry->GetObject(),run);
813 entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeGain",run);
815 fTimeGainSplinesArray.AddAt(entry->GetObject(),run);
818 entry = AliCDBManager::Instance()->Get("TPC/Calib/TimeDrift",run);
820 fDriftCorrectionArray.AddAt(entry->GetObject(),run);
823 entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run);
825 fTemperatureArray.AddAt(entry->GetObject(),run);
827 fRunList[run]=1; // sign as used
829 AliDCSSensor * press = GetPressureSensor(run,0);
830 AliTPCSensorTempArray * temp = GetTemperatureSensor(run);
832 AliTPCCalibVdrift * vdrift = new AliTPCCalibVdrift(temp, press,0);
833 fVdriftArray.AddAt(vdrift,run);
838 Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
841 AliTPCCalPad *calPad = Instance()->fDedxGainFactor;;
842 if (!calPad) return 0;
843 return calPad->GetCalROC(sector)->GetValue(row,pad);
847 AliGRPObject *AliTPCcalibDB::GetGRP(Int_t run){
849 // Get GRP object for given run
851 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>((Instance()->fGRPArray).At(run));
853 Instance()->UpdateRunInformations(run);
854 grpRun = dynamic_cast<AliGRPObject *>(Instance()->fGRPArray.At(run));
855 if (!grpRun) return 0;
860 TMap * AliTPCcalibDB::GetGRPMap(Int_t run){
864 TMap * grpRun = dynamic_cast<TMap *>((Instance()->fGRPMaps).At(run));
866 Instance()->UpdateRunInformations(run);
867 grpRun = dynamic_cast<TMap *>(Instance()->fGRPMaps.At(run));
868 if (!grpRun) return 0;
874 AliDCSSensor * AliTPCcalibDB::GetPressureSensor(Int_t run, Int_t type){
876 // Get Pressure sensor
878 // type = 0 - Cavern pressure
879 // 1 - Suface pressure
880 // First try to get if trom map - if existing (Old format of data storing)
884 TMap *map = GetGRPMap(run);
886 AliDCSSensor * sensor = 0;
888 if (type==0) osensor = ((*map)("fCavernPressure"));
889 if (type==1) osensor = ((*map)("fP2Pressure"));
890 sensor =dynamic_cast<AliDCSSensor *>(osensor);
891 if (sensor) return sensor;
894 // If not map try to get it from the GRPObject
896 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.At(run));
898 UpdateRunInformations(run);
899 grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.At(run));
900 if (!grpRun) return 0;
902 AliDCSSensor * sensor = grpRun->GetCavernAtmosPressure();
903 if (type==1) sensor = grpRun->GetSurfaceAtmosPressure();
907 AliTPCSensorTempArray * AliTPCcalibDB::GetTemperatureSensor(Int_t run){
909 // Get temperature sensor array
911 AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)fTemperatureArray.At(run);
913 UpdateRunInformations(run);
914 tempArray = (AliTPCSensorTempArray *)fTemperatureArray.At(run);
920 TObjArray * AliTPCcalibDB::GetTimeGainSplinesRun(Int_t run){
922 // Get temperature sensor array
924 TObjArray * gainSplines = (TObjArray *)fTimeGainSplinesArray.At(run);
926 UpdateRunInformations(run);
927 gainSplines = (TObjArray *)fTimeGainSplinesArray.At(run);
932 AliDCSSensorArray * AliTPCcalibDB::GetVoltageSensors(Int_t run){
934 // Get temperature sensor array
936 AliDCSSensorArray * voltageArray = (AliDCSSensorArray *)fVoltageArray.At(run);
938 UpdateRunInformations(run);
939 voltageArray = (AliDCSSensorArray *)fVoltageArray.At(run);
944 AliDCSSensorArray * AliTPCcalibDB::GetGoofieSensors(Int_t run){
946 // Get temperature sensor array
948 AliDCSSensorArray * goofieArray = (AliDCSSensorArray *)fGoofieArray.At(run);
950 UpdateRunInformations(run);
951 goofieArray = (AliDCSSensorArray *)fGoofieArray.At(run);
958 AliTPCCalibVdrift * AliTPCcalibDB::GetVdrift(Int_t run){
960 // Get the interface to the the vdrift
962 AliTPCCalibVdrift * vdrift = (AliTPCCalibVdrift*)fVdriftArray.At(run);
964 UpdateRunInformations(run);
965 vdrift= (AliTPCCalibVdrift*)fVdriftArray.At(run);
970 Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char * sensorName, Int_t sigDigits)
973 // Get Value for a DCS sensor 'sensorName', run 'run' at time 'timeStamp'
976 const TString sensorNameString(sensorName);
977 AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
978 if (!sensor) return val;
979 val=sensor->GetValue(timeStamp);
981 val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
986 Float_t AliTPCcalibDB::GetDCSSensorMeanValue(AliDCSSensorArray *arr, const char * sensorName, Int_t sigDigits)
989 // Get mean Value for a DCS sensor 'sensorName' during run 'run'
992 const TString sensorNameString(sensorName);
993 AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
994 if (!sensor) return val;
996 //current hack until the spline fit problem is solved
997 if (!sensor->GetFit()) return val;
998 Int_t nKnots=sensor->GetFit()->GetKnots();
999 Double_t tMid=(sensor->GetEndTime()-sensor->GetStartTime())/2.;
1000 for (Int_t iKnot=0;iKnot<nKnots;++iKnot){
1001 if (sensor->GetFit()->GetX()[iKnot]>tMid/3600.) break;
1002 val=(Float_t)sensor->GetFit()->GetY0()[iKnot];
1005 TGraph *gr=sensor->MakeGraph();
1006 if (gr) val=(Float_t)gr->GetMean(2);
1011 val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
1017 Float_t AliTPCcalibDB::GetChamberHighVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits) {
1019 // return the chamber HV for given run and time: 0-35 IROC, 36-72 OROC
1020 // if timeStamp==-1 return mean value
1023 TString sensorName="";
1024 TTimeStamp stamp(timeStamp);
1025 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1026 if (!voltageArray || (sector<0) || (sector>71)) return val;
1027 Char_t sideName='A';
1028 if ((sector/18)%2==1) sideName='C';
1031 sensorName=Form("TPC_ANODE_I_%c%02d_VMEAS",sideName,sector%18);
1034 sensorName=Form("TPC_ANODE_O_%c%02d_0_VMEAS",sideName,sector%18);
1037 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1039 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1043 Float_t AliTPCcalibDB::GetSkirtVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1046 // Get the skirt voltage for 'run' at 'timeStamp' and 'sector': 0-35 IROC, 36-72 OROC
1047 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1048 // if timeStamp==-1 return the mean value for the run
1051 TString sensorName="";
1052 TTimeStamp stamp(timeStamp);
1053 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1054 if (!voltageArray || (sector<0) || (sector>71)) return val;
1055 Char_t sideName='A';
1056 if ((sector/18)%2==1) sideName='C';
1057 sensorName=Form("TPC_SKIRT_%c_VMEAS",sideName);
1059 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1061 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1066 Float_t AliTPCcalibDB::GetCoverVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1069 // Get the cover voltage for run 'run' at time 'timeStamp'
1070 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1071 // if timeStamp==-1 return the mean value for the run
1074 TString sensorName="";
1075 TTimeStamp stamp(timeStamp);
1076 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1077 if (!voltageArray || (sector<0) || (sector>71)) return val;
1078 Char_t sideName='A';
1079 if ((sector/18)%2==1) sideName='C';
1082 sensorName=Form("TPC_COVER_I_%c_VMEAS",sideName);
1085 sensorName=Form("TPC_COVER_O_%c_VMEAS",sideName);
1088 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1090 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1095 Float_t AliTPCcalibDB::GetGGoffsetVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1098 // Get the GG offset voltage for run 'run' at time 'timeStamp'
1099 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1100 // if timeStamp==-1 return the mean value for the run
1103 TString sensorName="";
1104 TTimeStamp stamp(timeStamp);
1105 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1106 if (!voltageArray || (sector<0) || (sector>71)) return val;
1107 Char_t sideName='A';
1108 if ((sector/18)%2==1) sideName='C';
1111 sensorName=Form("TPC_GATE_I_%c_OFF_VMEAS",sideName);
1114 sensorName=Form("TPC_GATE_O_%c_OFF_VMEAS",sideName);
1117 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1119 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1124 Float_t AliTPCcalibDB::GetGGnegVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1127 // Get the GG offset voltage for run 'run' at time 'timeStamp'
1128 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1129 // if timeStamp==-1 return the mean value for the run
1132 TString sensorName="";
1133 TTimeStamp stamp(timeStamp);
1134 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1135 if (!voltageArray || (sector<0) || (sector>71)) return val;
1136 Char_t sideName='A';
1137 if ((sector/18)%2==1) sideName='C';
1140 sensorName=Form("TPC_GATE_I_%c_NEG_VMEAS",sideName);
1143 sensorName=Form("TPC_GATE_O_%c_NEG_VMEAS",sideName);
1146 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1148 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1153 Float_t AliTPCcalibDB::GetGGposVoltage(Int_t run, Int_t sector, Int_t timeStamp, Int_t sigDigits)
1156 // Get the GG offset voltage for run 'run' at time 'timeStamp'
1157 // type corresponds to the following: 0 - IROC A-Side; 1 - IROC C-Side; 2 - OROC A-Side; 3 - OROC C-Side
1158 // if timeStamp==-1 return the mean value for the run
1161 TString sensorName="";
1162 TTimeStamp stamp(timeStamp);
1163 AliDCSSensorArray* voltageArray = AliTPCcalibDB::Instance()->GetVoltageSensors(run);
1164 if (!voltageArray || (sector<0) || (sector>71)) return val;
1165 Char_t sideName='A';
1166 if ((sector/18)%2==1) sideName='C';
1169 sensorName=Form("TPC_GATE_I_%c_POS_VMEAS",sideName);
1172 sensorName=Form("TPC_GATE_O_%c_POS_VMEAS",sideName);
1175 val=AliTPCcalibDB::GetDCSSensorMeanValue(voltageArray, sensorName.Data(),sigDigits);
1177 val=AliTPCcalibDB::GetDCSSensorValue(voltageArray, timeStamp, sensorName.Data(),sigDigits);
1182 Float_t AliTPCcalibDB::GetPressure(Int_t timeStamp, Int_t run, Int_t type){
1184 // GetPressure for given time stamp and runt
1186 TTimeStamp stamp(timeStamp);
1187 AliDCSSensor * sensor = Instance()->GetPressureSensor(run,type);
1188 if (!sensor) return 0;
1189 return sensor->GetValue(stamp);
1192 Float_t AliTPCcalibDB::GetL3Current(Int_t run, Int_t statType){
1194 // return L3 current
1195 // stat type is: AliGRPObject::Stats: kMean = 0, kTruncMean = 1, kMedian = 2, kSDMean = 3, kSDMedian = 4
1198 AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
1199 if (grp) current=grp->GetL3Current((AliGRPObject::Stats)statType);
1203 Float_t AliTPCcalibDB::GetBz(Int_t run){
1205 // calculate BZ in T from L3 current
1208 Float_t current=AliTPCcalibDB::GetL3Current(run);
1209 if (current>-1) bz=5*current/30000.*.1;
1213 Char_t AliTPCcalibDB::GetL3Polarity(Int_t run) {
1215 // get l3 polarity from GRP
1217 return AliTPCcalibDB::GetGRP(run)->GetL3Polarity();
1220 TString AliTPCcalibDB::GetRunType(Int_t run){
1222 // return run type from grp
1224 return AliTPCcalibDB::GetGRP(run)->GetRunType();
1227 Float_t AliTPCcalibDB::GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type){
1229 // GetPressure for given time stamp and runt
1231 TTimeStamp stamp(timeStamp);
1232 AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(run);
1233 if (!goofieArray) return 0;
1234 AliDCSSensor *sensor = goofieArray->GetSensor(type);
1235 return sensor->GetValue(stamp);
1243 Bool_t AliTPCcalibDB::GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit){
1247 TTimeStamp tstamp(timeStamp);
1248 AliTPCSensorTempArray* tempArray = Instance()->GetTemperatureSensor(run);
1249 if (! tempArray) return kFALSE;
1250 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
1251 TLinearFitter * fitter = tempMap->GetLinearFitter(3,side,tstamp);
1254 fitter->GetParameters(fit);
1258 if (!fitter) return kFALSE;
1262 Float_t AliTPCcalibDB::GetTemperature(Int_t timeStamp, Int_t run, Int_t side){
1268 GetTemperatureFit(timeStamp,run,0,vec);
1272 GetTemperatureFit(timeStamp,run,0,vec);
1279 Double_t AliTPCcalibDB::GetPTRelative(UInt_t timeSec, Int_t run, Int_t side){
1282 // time - absolute time
1284 // side - 0 - A side 1-C side
1285 AliTPCCalibVdrift * vdrift = Instance()->GetVdrift(run);
1286 if (!vdrift) return 0;
1287 return vdrift->GetPTRelative(timeSec,side);
1291 void AliTPCcalibDB::ProcessEnv(const char * runList){
1293 // Example test function - how to use the environment variables
1294 // runList - ascii file with run numbers
1295 // output - dcsTime.root file with tree
1300 TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root");
1303 if (irun==0) continue;
1304 printf("Processing run %d\n",irun);
1305 AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
1306 if (!sensorPressure) continue;
1307 AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun);
1308 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
1309 AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(irun);
1311 Int_t startTime = sensorPressure->GetStartTime();
1312 Int_t endTime = sensorPressure->GetEndTime();
1313 Int_t dtime = TMath::Max((endTime-startTime)/20,10*60);
1314 for (Int_t itime=startTime; itime<endTime; itime+=dtime){
1316 TTimeStamp tstamp(itime);
1317 Float_t valuePressure = sensorPressure->GetValue(tstamp);
1319 TLinearFitter * fitter = 0;
1320 TVectorD vecTemp[10];
1321 if (itime<tempArray->GetStartTime().GetSec() || itime>tempArray->GetEndTime().GetSec()){
1323 for (Int_t itype=0; itype<5; itype++)
1324 for (Int_t iside=0; iside<2; iside++){
1325 fitter= tempMap->GetLinearFitter(itype,iside,tstamp);
1326 if (!fitter) continue;
1327 fitter->Eval(); fitter->GetParameters(vecTemp[itype+iside*5]);
1332 TVectorD vecGoofie, vecEntries, vecMean, vecMedian,vecRMS;
1334 vecGoofie.ResizeTo(goofieArray->NumSensors());
1335 ProcessGoofie(goofieArray, vecEntries ,vecMedian, vecMean, vecRMS);
1337 for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
1338 AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
1340 vecGoofie[isensor] = gsensor->GetValue(tstamp);
1346 //tempMap->GetLinearFitter(0,0,itime);
1347 (*pcstream)<<"dcs"<<
1350 "goofie.="<<&vecGoofie<<
1351 "goofieE.="<<&vecEntries<<
1352 "goofieMean.="<<&vecMean<<
1353 "goofieMedian.="<<&vecMedian<<
1354 "goofieRMS.="<<&vecRMS<<
1355 "press="<<valuePressure<<
1356 "temp00.="<<&vecTemp[0]<<
1357 "temp10.="<<&vecTemp[1]<<
1358 "temp20.="<<&vecTemp[2]<<
1359 "temp30.="<<&vecTemp[3]<<
1360 "temp40.="<<&vecTemp[4]<<
1361 "temp01.="<<&vecTemp[5]<<
1362 "temp11.="<<&vecTemp[6]<<
1363 "temp21.="<<&vecTemp[7]<<
1364 "temp31.="<<&vecTemp[8]<<
1365 "temp41.="<<&vecTemp[9]<<
1373 void AliTPCcalibDB::ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS){
1376 1 TPC_ANODE_I_A00_STAT
1378 3 TPC_DVM_DriftVelocity
1383 8 TPC_DVM_NumberOfSparks
1384 9 TPC_DVM_PeakAreaFar
1385 10 TPC_DVM_PeakAreaNear
1386 11 TPC_DVM_PeakPosFar
1387 12 TPC_DVM_PeakPosNear
1390 15 TPC_DVM_T1_Over_P
1391 16 TPC_DVM_T2_Over_P
1393 18 TPC_DVM_TemperatureS1
1397 // TVectorD vecMedian; TVectorD vecEntries; TVectorD vecMean; TVectorD vecRMS;
1398 Double_t kEpsilon=0.0000000001;
1399 Double_t kBig=100000000000.;
1400 Int_t nsensors = goofieArray->NumSensors();
1401 vecEntries.ResizeTo(nsensors);
1402 vecMedian.ResizeTo(nsensors);
1403 vecMean.ResizeTo(nsensors);
1404 vecRMS.ResizeTo(nsensors);
1406 for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
1407 AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
1408 if (gsensor && gsensor->GetGraph()){
1409 Int_t npoints = gsensor->GetGraph()->GetN();
1411 values.ResizeTo(npoints);
1413 for (Int_t ipoint=0; ipoint<npoints; ipoint++){
1414 if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon &&
1415 TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){
1416 values[nused]=gsensor->GetGraph()->GetY()[ipoint];
1421 vecEntries[isensor]= nused;
1423 vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray());
1424 vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray());
1425 vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray());
1433 AliGRPObject * AliTPCcalibDB::MakeGRPObjectFromMap(TMap *map){
1435 // Function to covert old GRP run information from TMap to GRPObject
1437 // TMap * map = AliTPCcalibDB::GetGRPMap(52406);
1439 AliDCSSensor * sensor = 0;
1441 osensor = ((*map)("fP2Pressure"));
1442 sensor =dynamic_cast<AliDCSSensor *>(osensor);
1444 if (!sensor) return 0;
1446 AliDCSSensor * sensor2 = new AliDCSSensor(*sensor);
1447 osensor = ((*map)("fCavernPressure"));
1448 TGraph * gr = new TGraph(2);
1449 gr->GetX()[0]= -100000.;
1450 gr->GetX()[1]= 1000000.;
1451 gr->GetY()[0]= atof(osensor->GetName());
1452 gr->GetY()[1]= atof(osensor->GetName());
1453 sensor2->SetGraph(gr);
1457 AliGRPObject *grpRun = new AliGRPObject;
1458 grpRun->ReadValuesFromMap(map);
1459 grpRun->SetCavernAtmosPressure(sensor2);
1460 grpRun->SetSurfaceAtmosPressure(sensor);
1464 Bool_t AliTPCcalibDB::CreateGUITree(Int_t run, const char* filename)
1467 // Create a gui tree for run number 'run'
1470 if (!AliCDBManager::Instance()->GetDefaultStorage()){
1471 AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
1472 MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
1476 AliTPCcalibDB *db=AliTPCcalibDB::Instance();
1477 // retrieve cal pad objects
1479 AliTPCPreprocessorOnline prep;
1480 //noise and pedestals
1481 prep.AddComponent(db->GetPedestals());
1482 prep.AddComponent(db->GetPadNoise());
1484 prep.AddComponent(db->GetPulserTmean());
1485 prep.AddComponent(db->GetPulserTrms());
1486 prep.AddComponent(db->GetPulserQmean());
1488 prep.AddComponent(db->GetCETmean());
1489 prep.AddComponent(db->GetCETrms());
1490 prep.AddComponent(db->GetCEQmean());
1492 prep.AddComponent(db->GetALTROAcqStart() );
1493 prep.AddComponent(db->GetALTROZsThr() );
1494 prep.AddComponent(db->GetALTROFPED() );
1495 prep.AddComponent(db->GetALTROAcqStop() );
1496 prep.AddComponent(db->GetALTROMasked() );
1498 TString file(filename);
1499 if (file.IsNull()) file=Form("guiTreeRun_%d.root",run);
1500 prep.DumpToFile(file.Data());