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 <AliMagWrapCheb.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"
120 ClassImp(AliTPCcalibDB)
122 AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
123 Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
124 TObjArray AliTPCcalibDB::fgExBArray; // array of ExB corrections
127 //_ singleton implementation __________________________________________________
128 AliTPCcalibDB* AliTPCcalibDB::Instance()
131 // Singleton implementation
132 // Returns an instance of this class, it is created if neccessary
135 if (fgTerminated != kFALSE)
139 fgInstance = new AliTPCcalibDB();
144 void AliTPCcalibDB::Terminate()
147 // Singleton implementation
148 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
149 // This function can be called several times.
152 fgTerminated = kTRUE;
161 //_____________________________________________________________________________
162 AliTPCcalibDB::AliTPCcalibDB():
176 fGRPArray(100000), //! array of GRPs - per run - JUST for calibration studies
177 fGoofieArray(100000), //! array of GOOFIE values -per run - Just for calibration studies
178 fTemperatureArray(100000), //! array of temperature sensors - per run - Just for calibration studies
179 fRunList(100000) //! run list - indicates try to get the run param
186 Update(); // temporary
189 AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
203 fGRPArray(0), //! array of GRPs - per run - JUST for calibration studies
204 fGoofieArray(0), //! array of GOOFIE values -per run - Just for calibration studies
205 fTemperatureArray(0), //! array of temperature sensors - per run - Just for calibration studies
206 fRunList(0) //! run list - indicates try to get the run param
209 // Copy constructor invalid -- singleton implementation
211 Error("copy constructor","invalid -- singleton implementation");
214 AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& )
217 // Singleton implementation - no assignment operator
219 Error("operator =", "assignment operator not implemented");
225 //_____________________________________________________________________________
226 AliTPCcalibDB::~AliTPCcalibDB()
232 // don't delete anything, CDB cache is active!
233 //if (fPadGainFactor) delete fPadGainFactor;
234 //if (fPadTime0) delete fPadTime0;
235 //if (fPadNoise) delete fPadNoise;
239 //_____________________________________________________________________________
240 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
243 // Retrieves an entry with path <cdbPath> from the CDB.
247 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
250 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
258 //_____________________________________________________________________________
259 void AliTPCcalibDB::SetRun(Long64_t run)
262 // Sets current run number. Calibration data is read from the corresponding file.
272 void AliTPCcalibDB::Update(){
274 AliCDBEntry * entry=0;
276 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
277 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
280 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
282 //if (fPadGainFactor) delete fPadGainFactor;
283 entry->SetOwner(kTRUE);
284 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
287 entry = GetCDBEntry("TPC/Calib/GainFactorDedx");
289 entry->SetOwner(kTRUE);
290 fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
293 entry = GetCDBEntry("TPC/Calib/PadTime0");
295 //if (fPadTime0) delete fPadTime0;
296 entry->SetOwner(kTRUE);
297 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
301 entry = GetCDBEntry("TPC/Calib/PadNoise");
303 //if (fPadNoise) delete fPadNoise;
304 entry->SetOwner(kTRUE);
305 fPadNoise = (AliTPCCalPad*)entry->GetObject();
308 entry = GetCDBEntry("TPC/Calib/Pedestals");
310 //if (fPedestals) delete fPedestals;
311 entry->SetOwner(kTRUE);
312 fPedestals = (AliTPCCalPad*)entry->GetObject();
315 entry = GetCDBEntry("TPC/Calib/Temperature");
317 //if (fTemperature) delete fTemperature;
318 entry->SetOwner(kTRUE);
319 fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
322 entry = GetCDBEntry("TPC/Calib/Parameters");
324 //if (fPadNoise) delete fPadNoise;
325 entry->SetOwner(kTRUE);
326 fParam = (AliTPCParam*)(entry->GetObject()->Clone());
329 entry = GetCDBEntry("TPC/Calib/ClusterParam");
331 //if (fPadNoise) delete fPadNoise;
332 entry->SetOwner(kTRUE);
333 fClusterParam = (AliTPCClusterParam*)(entry->GetObject()->Clone());
336 entry = GetCDBEntry("TPC/Calib/Mapping");
338 //if (fPadNoise) delete fPadNoise;
339 entry->SetOwner(kTRUE);
340 TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
341 if (array && array->GetEntriesFast()==6){
342 fMapping = new AliTPCAltroMapping*[6];
343 for (Int_t i=0; i<6; i++){
344 fMapping[i] = dynamic_cast<AliTPCAltroMapping*>(array->At(i));
351 //entry = GetCDBEntry("TPC/Calib/ExB");
353 // entry->SetOwner(kTRUE);
354 // fExB=dynamic_cast<AliTPCExB*>(entry->GetObject()->Clone());
357 // ExB - calculate during initialization
359 fExB = GetExB(-5,kTRUE);
362 fTransform=new AliTPCTransform();
366 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
372 void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
375 // Create calibration objects and read contents from OCDB
377 if ( calibObjects == 0x0 ) return;
380 if ( !in.is_open() ){
381 fprintf(stderr,"Error: cannot open list file '%s'", filename);
385 AliTPCCalPad *calPad=0x0;
391 TObjArray *arrFileLine = sFile.Tokenize("\n");
393 TIter nextLine(arrFileLine);
395 TObjString *sObjLine=0x0;
396 while ( (sObjLine = (TObjString*)nextLine()) ){
397 TString sLine(sObjLine->GetString());
399 TObjArray *arrNextCol = sLine.Tokenize("\t");
401 TObjString *sObjType = (TObjString*)(arrNextCol->At(0));
402 TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
404 if ( !sObjType || ! sObjFileName ) continue;
405 TString sType(sObjType->GetString());
406 TString sFileName(sObjFileName->GetString());
407 printf("%s\t%s\n",sType.Data(),sFileName.Data());
409 TFile *fIn = TFile::Open(sFileName);
411 fprintf(stderr,"File not found: '%s'", sFileName.Data());
415 if ( sType == "CE" ){
416 AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
418 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());
419 calPad->SetNameTitle("CETmean","CETmean");
420 calibObjects->Add(calPad);
422 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());
423 calPad->SetNameTitle("CEQmean","CEQmean");
424 calibObjects->Add(calPad);
426 calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
427 calPad->SetNameTitle("CETrms","CETrms");
428 calibObjects->Add(calPad);
430 } else if ( sType == "Pulser") {
431 AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
433 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());
434 calPad->SetNameTitle("PulserTmean","PulserTmean");
435 calibObjects->Add(calPad);
437 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());
438 calPad->SetNameTitle("PulserQmean","PulserQmean");
439 calibObjects->Add(calPad);
441 calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
442 calPad->SetNameTitle("PulserTrms","PulserTrms");
443 calibObjects->Add(calPad);
445 } else if ( sType == "Pedestals") {
446 AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
448 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());
449 calPad->SetNameTitle("Pedestals","Pedestals");
450 calibObjects->Add(calPad);
452 calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());
453 calPad->SetNameTitle("Noise","Noise");
454 calibObjects->Add(calPad);
457 fprintf(stderr,"Undefined Type: '%s'",sType.Data());
466 void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
468 // Write a tree with all available information
469 // if mapFileName is specified, the Map information are also written to the tree
470 // pads specified in outlierPad are not used for calculating statistics
471 // - the same function as AliTPCCalPad::MakeTree -
473 AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
475 TObjArray* mapIROCs = 0;
476 TObjArray* mapOROCs = 0;
477 TVectorF *mapIROCArray = 0;
478 TVectorF *mapOROCArray = 0;
479 Int_t mapEntries = 0;
480 TString* mapNames = 0;
483 TFile mapFile(mapFileName, "read");
485 TList* listOfROCs = mapFile.GetListOfKeys();
486 mapEntries = listOfROCs->GetEntries()/2;
487 mapIROCs = new TObjArray(mapEntries*2);
488 mapOROCs = new TObjArray(mapEntries*2);
489 mapIROCArray = new TVectorF[mapEntries];
490 mapOROCArray = new TVectorF[mapEntries];
492 mapNames = new TString[mapEntries];
493 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
494 TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
495 nameROC.Remove(nameROC.Length()-4, 4);
496 mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
497 mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
498 mapNames[ivalue].Append(nameROC);
501 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
502 mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
503 mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
505 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
506 (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
507 for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
508 (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
511 } // if (mapFileName)
513 TTreeSRedirector cstream(fileName);
514 Int_t arrayEntries = array->GetEntries();
516 TString* names = new TString[arrayEntries];
517 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
518 names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
520 for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
522 // get statistic for given sector
524 TVectorF median(arrayEntries);
525 TVectorF mean(arrayEntries);
526 TVectorF rms(arrayEntries);
527 TVectorF ltm(arrayEntries);
528 TVectorF ltmrms(arrayEntries);
529 TVectorF medianWithOut(arrayEntries);
530 TVectorF meanWithOut(arrayEntries);
531 TVectorF rmsWithOut(arrayEntries);
532 TVectorF ltmWithOut(arrayEntries);
533 TVectorF ltmrmsWithOut(arrayEntries);
535 TVectorF *vectorArray = new TVectorF[arrayEntries];
536 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
537 vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
539 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
540 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
541 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
542 AliTPCCalROC* outlierROC = 0;
543 if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
545 median[ivalue] = calROC->GetMedian();
546 mean[ivalue] = calROC->GetMean();
547 rms[ivalue] = calROC->GetRMS();
548 Double_t ltmrmsValue = 0;
549 ltm[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction);
550 ltmrms[ivalue] = ltmrmsValue;
552 medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
553 meanWithOut[ivalue] = calROC->GetMean(outlierROC);
554 rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
556 ltmWithOut[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction, outlierROC);
557 ltmrmsWithOut[ivalue] = ltmrmsValue;
566 medianWithOut[ivalue] = 0.;
567 meanWithOut[ivalue] = 0.;
568 rmsWithOut[ivalue] = 0.;
569 ltmWithOut[ivalue] = 0.;
570 ltmrmsWithOut[ivalue] = 0.;
575 // fill vectors of variable per pad
577 TVectorF *posArray = new TVectorF[8];
578 for (Int_t ivalue = 0; ivalue < 8; ivalue++)
579 posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
581 Float_t posG[3] = {0};
582 Float_t posL[3] = {0};
584 for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
585 for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
586 tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
587 tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
588 posArray[0][ichannel] = irow;
589 posArray[1][ichannel] = ipad;
590 posArray[2][ichannel] = posL[0];
591 posArray[3][ichannel] = posL[1];
592 posArray[4][ichannel] = posG[0];
593 posArray[5][ichannel] = posG[1];
594 posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
595 posArray[7][ichannel] = ichannel;
597 // loop over array containing AliTPCCalPads
598 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
599 AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
600 AliTPCCalROC* calROC = calPad->GetCalROC(isector);
602 (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
604 (vectorArray[ivalue])[ichannel] = 0;
610 cstream << "calPads" <<
611 "sector=" << isector;
613 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
614 cstream << "calPads" <<
615 (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
616 (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
617 (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
618 (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
619 (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
621 cstream << "calPads" <<
622 (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
623 (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
624 (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
625 (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
626 (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
630 for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
631 cstream << "calPads" <<
632 (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
636 for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
638 cstream << "calPads" <<
639 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
641 cstream << "calPads" <<
642 (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
646 cstream << "calPads" <<
647 "row.=" << &posArray[0] <<
648 "pad.=" << &posArray[1] <<
649 "lx.=" << &posArray[2] <<
650 "ly.=" << &posArray[3] <<
651 "gx.=" << &posArray[4] <<
652 "gy.=" << &posArray[5] <<
653 "rpad.=" << &posArray[6] <<
654 "channel.=" << &posArray[7];
656 cstream << "calPads" <<
660 delete[] vectorArray;
668 delete[] mapIROCArray;
669 delete[] mapOROCArray;
676 void AliTPCcalibDB::RegisterExB(Int_t index, Float_t bz, Bool_t bdelete){
678 // Register static ExB correction map
679 // index - registration index - used for visualization
680 // bz - bz field in kGaus
682 Float_t factor = bz/(-5.); // default b filed in Cheb with minus sign
684 AliMagF* bmap = new AliMagWrapCheb("Maps","Maps", 2, factor, 10., AliMagWrapCheb::k5kG,kTRUE,"$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root");
686 AliTPCExBFirst *exb = new AliTPCExBFirst(bmap,0.88*2.6400e+04,50,50,50);
687 AliTPCExB::SetInstance(exb);
692 AliTPCExB::RegisterField(index,bmap);
694 if (index>=fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
695 fgExBArray.AddAt(exb,index);
699 AliTPCExB* AliTPCcalibDB::GetExB(Float_t bz, Bool_t deleteB) {
701 // bz filed in KGaus not in tesla
702 // Get ExB correction map
703 // if doesn't exist - create it
705 Int_t index = TMath::Nint(5+bz);
706 if (index>fgExBArray.GetEntries()) fgExBArray.Expand((index+1)*2+11);
707 if (!fgExBArray.At(index)) AliTPCcalibDB::RegisterExB(index,bz,deleteB);
708 return (AliTPCExB*)fgExBArray.At(index);
712 void AliTPCcalibDB::SetExBField(Float_t bz){
714 // Set magnetic filed for ExB correction
716 printf("Set magnetic field for ExB correction = %f\n",bz);
717 fExB = GetExB(bz,kFALSE);
722 void AliTPCcalibDB::GetRunInformations( Int_t run){
724 // - > Don't use it for reconstruction - Only for Calibration studies
726 AliCDBEntry * entry = 0;
727 if (run>= fRunList.GetSize()){
728 fRunList.Set(run*2+1);
729 fGRPArray.Expand(run*2+1);fGoofieArray.Expand(run*2+1); fTemperatureArray.Expand(run*2+1);
731 if (fRunList[run]>0) return;
732 entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
733 if (entry) fGRPArray.AddAt(entry->GetObject(),run);
734 entry = AliCDBManager::Instance()->Get("TPC/Calib/Goofie",run);
735 if (entry) fGoofieArray.AddAt(entry->GetObject(),run);
736 entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run);
737 if (entry) fTemperatureArray.AddAt(entry->GetObject(),run);
738 fRunList[run]=1; // sign as used
742 Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
745 AliTPCCalPad *calPad = Instance()->fDedxGainFactor;;
746 if (!calPad) return 0;
747 return calPad->GetCalROC(sector)->GetValue(row,pad);
750 AliDCSSensor * AliTPCcalibDB::GetPressureSensor(Int_t run){
753 AliGRPObject * grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.At(run));
755 GetRunInformations(run);
756 grpRun = dynamic_cast<AliGRPObject *>(fGRPArray.At(run));
757 if (!grpRun) return 0;
759 AliDCSSensor * sensor = grpRun->GetCavernAtmosPressure();
764 AliTPCSensorTempArray * AliTPCcalibDB::GetTemperatureSensor(Int_t run){
766 // Get temperature sensor array
768 AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)fTemperatureArray.At(run);
770 GetRunInformations(run);
771 tempArray = (AliTPCSensorTempArray *)fTemperatureArray.At(run);
776 AliDCSSensorArray * AliTPCcalibDB::GetGoofieSensors(Int_t run){
778 // Get temperature sensor array
780 AliDCSSensorArray * goofieArray = (AliDCSSensorArray *)fGoofieArray.At(run);
782 GetRunInformations(run);
783 goofieArray = (AliDCSSensorArray *)fGoofieArray.At(run);
791 Float_t AliTPCcalibDB::GetPressure(Int_t timeStamp, Int_t run){
793 // GetPressure for given time stamp and runt
795 TTimeStamp stamp(timeStamp);
796 AliDCSSensor * sensor = Instance()->GetPressureSensor(run);
797 if (!sensor) return 0;
798 if (!sensor->GetFit()) return 0;
799 return sensor->GetValue(stamp);
802 Bool_t AliTPCcalibDB::GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit){
806 TTimeStamp tstamp(timeStamp);
807 AliTPCSensorTempArray* tempArray = Instance()->GetTemperatureSensor(run);
808 if (! tempArray) return kFALSE;
809 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
810 TLinearFitter * fitter = tempMap->GetLinearFitter(3,side,tstamp);
813 fitter->GetParameters(fit);
817 if (!fitter) return kFALSE;
821 Float_t AliTPCcalibDB::GetTemperature(Int_t timeStamp, Int_t run, Int_t side){
827 GetTemperatureFit(timeStamp,run,0,vec);
831 GetTemperatureFit(timeStamp,run,0,vec);
838 void AliTPCcalibDB::ProcessEnv(const char * runList){
840 // Example test function - how to use the environment variables
841 // runList - ascii file with run numbers
842 // output - dcsTime.root file with tree
847 TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root");
850 if (irun==0) continue;
851 printf("Processing run %d\n",irun);
852 AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
853 if (!sensorPressure) continue;
854 AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun);
855 AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
856 AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(irun);
858 Int_t startTime = sensorPressure->GetStartTime();
859 Int_t endTime = sensorPressure->GetEndTime();
860 Int_t dtime = TMath::Max((endTime-startTime)/20,10*60);
861 for (Int_t itime=startTime; itime<endTime; itime+=dtime){
863 TTimeStamp tstamp(itime);
864 Float_t valuePressure = sensorPressure->GetValue(tstamp);
866 TLinearFitter * fitter = 0;
867 TVectorD vecTemp[10];
868 if (itime<tempArray->GetStartTime().GetSec() || itime>tempArray->GetEndTime().GetSec()){
870 for (Int_t itype=0; itype<5; itype++)
871 for (Int_t iside=0; iside<2; iside++){
872 fitter= tempMap->GetLinearFitter(itype,iside,tstamp);
873 if (!fitter) continue;
874 fitter->Eval(); fitter->GetParameters(vecTemp[itype+iside*5]);
879 TVectorD vecGoofie, vecEntries, vecMean, vecMedian,vecRMS;
881 vecGoofie.ResizeTo(goofieArray->NumSensors());
882 ProcessGoofie(goofieArray, vecEntries ,vecMedian, vecMean, vecRMS);
884 for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
885 AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
887 vecGoofie[isensor] = gsensor->GetValue(tstamp);
893 //tempMap->GetLinearFitter(0,0,itime);
897 "goofie.="<<&vecGoofie<<
898 "goofieE.="<<&vecEntries<<
899 "goofieMean.="<<&vecMean<<
900 "goofieMedian.="<<&vecMedian<<
901 "goofieRMS.="<<&vecRMS<<
902 "press="<<valuePressure<<
903 "temp00.="<<&vecTemp[0]<<
904 "temp10.="<<&vecTemp[1]<<
905 "temp20.="<<&vecTemp[2]<<
906 "temp30.="<<&vecTemp[3]<<
907 "temp40.="<<&vecTemp[4]<<
908 "temp01.="<<&vecTemp[5]<<
909 "temp11.="<<&vecTemp[6]<<
910 "temp21.="<<&vecTemp[7]<<
911 "temp31.="<<&vecTemp[8]<<
912 "temp41.="<<&vecTemp[9]<<
920 void AliTPCcalibDB::ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS){
923 1 TPC_ANODE_I_A00_STAT
925 3 TPC_DVM_DriftVelocity
930 8 TPC_DVM_NumberOfSparks
931 9 TPC_DVM_PeakAreaFar
932 10 TPC_DVM_PeakAreaNear
933 11 TPC_DVM_PeakPosFar
934 12 TPC_DVM_PeakPosNear
940 18 TPC_DVM_TemperatureS1
944 // TVectorD vecMedian; TVectorD vecEntries; TVectorD vecMean; TVectorD vecRMS;
945 Double_t kEpsilon=0.0000000001;
946 Double_t kBig=100000000000.;
947 Int_t nsensors = goofieArray->NumSensors();
948 vecEntries.ResizeTo(nsensors);
949 vecMedian.ResizeTo(nsensors);
950 vecMean.ResizeTo(nsensors);
951 vecRMS.ResizeTo(nsensors);
953 for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
954 AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
955 if (gsensor && gsensor->GetGraph()){
956 Int_t npoints = gsensor->GetGraph()->GetN();
958 values.ResizeTo(npoints);
960 for (Int_t ipoint=0; ipoint<npoints; ipoint++){
961 if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon &&
962 TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){
963 values[nused]=gsensor->GetGraph()->GetY()[ipoint];
968 vecEntries[isensor]= nused;
970 vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray());
971 vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray());
972 vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray());