/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /////////////////////////////////////////////////////////////////////////////// // // // Class providing the calibration parameters by accessing the CDB // // // // Request an instance with AliTPCcalibDB::Instance() // // If a new event is processed set the event number with SetRun // // Then request the calibration data // // // /////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include "AliTPCcalibDB.h" #include "AliTPCCalROC.h" #include "AliTPCCalPad.h" #include "AliTPCCalDet.h" ClassImp(AliTPCcalibDB) AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0; Bool_t AliTPCcalibDB::fgTerminated = kFALSE; //_ singleton implementation __________________________________________________ AliTPCcalibDB* AliTPCcalibDB::Instance() { // // Singleton implementation // Returns an instance of this class, it is created if neccessary // if (fgTerminated != kFALSE) return 0; if (fgInstance == 0) fgInstance = new AliTPCcalibDB(); return fgInstance; } void AliTPCcalibDB::Terminate() { // // Singleton implementation // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore // This function can be called several times. // fgTerminated = kTRUE; if (fgInstance != 0) { delete fgInstance; fgInstance = 0; } } //_____________________________________________________________________________ AliTPCcalibDB::AliTPCcalibDB() :TObject(), fRun(-1), fPadGainFactor(0), fPadTime0(0), fPadPRFWidth(0), fPadNoise(0), fPedestals(0), fParam(0) { // // constructor // Update(); // temporary } //_____________________________________________________________________________ AliTPCcalibDB::~AliTPCcalibDB() { // // destructor // // don't delete anything, CDB cache is active! //if (fPadGainFactor) delete fPadGainFactor; //if (fPadTime0) delete fPadTime0; //if (fPadPRFWidth) delete fPadPRFWidth; //if (fPadNoise) delete fPadNoise; } //_____________________________________________________________________________ AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath) { // // Retrieves an entry with path from the CDB. // char chinfo[1000]; AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun); if (!entry) { sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath); AliError(chinfo); return 0; } return entry; } //_____________________________________________________________________________ void AliTPCcalibDB::SetRun(Long64_t run) { // // Sets current run number. Calibration data is read from the corresponding file. // if (fRun == run) return; fRun = run; Update(); } void AliTPCcalibDB::Update(){ // AliCDBEntry * entry=0; Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache // entry = GetCDBEntry("TPC/Calib/PadGainFactor"); if (entry){ //if (fPadGainFactor) delete fPadGainFactor; entry->SetOwner(kTRUE); fPadGainFactor = (AliTPCCalPad*)entry->GetObject(); } // entry = GetCDBEntry("TPC/Calib/PadTime0"); if (entry){ //if (fPadTime0) delete fPadTime0; entry->SetOwner(kTRUE); fPadTime0 = (AliTPCCalPad*)entry->GetObject(); } // entry = GetCDBEntry("TPC/Calib/PadPRF"); if (entry){ //if (fPadPRFWidth) delete fPadPRFWidth; entry->SetOwner(kTRUE); fPadPRFWidth = (AliTPCCalPad*)entry->GetObject(); } // entry = GetCDBEntry("TPC/Calib/PadNoise"); if (entry){ //if (fPadNoise) delete fPadNoise; entry->SetOwner(kTRUE); fPadNoise = (AliTPCCalPad*)entry->GetObject(); } entry = GetCDBEntry("TPC/Calib/Pedestals"); if (entry){ //if (fPedestals) delete fPedestals; entry->SetOwner(kTRUE); fPedestals = (AliTPCCalPad*)entry->GetObject(); } entry = GetCDBEntry("TPC/Calib/Parameters"); if (entry){ //if (fPadNoise) delete fPadNoise; entry->SetOwner(kTRUE); fParam = (AliTPCParam*)(entry->GetObject()->Clone()); } // AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache }