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 //
25 ///////////////////////////////////////////////////////////////////////////////
28 #include <AliCDBManager.h>
29 #include <AliCDBStorage.h>
30 #include <AliCDBEntry.h>
33 #include "AliTPCcalibDB.h"
35 #include "AliTPCCalROC.h"
36 #include "AliTPCCalPad.h"
37 #include "AliTPCCalDet.h"
39 ClassImp(AliTPCcalibDB)
41 AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
42 Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
45 //_ singleton implementation __________________________________________________
46 AliTPCcalibDB* AliTPCcalibDB::Instance()
49 // Singleton implementation
50 // Returns an instance of this class, it is created if neccessary
53 if (fgTerminated != kFALSE)
57 fgInstance = new AliTPCcalibDB();
62 void AliTPCcalibDB::Terminate()
65 // Singleton implementation
66 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
67 // This function can be called several times.
79 //_____________________________________________________________________________
80 AliTPCcalibDB::AliTPCcalibDB()
85 // TODO Default runnumber is set to 0, this should be changed later to an invalid value (e.g. -1) to prevent
86 // TODO invalid calibration data to be used.
89 AliCDBManager* manager = AliCDBManager::Instance();
92 AliFatal("AliTRDcalibDB: CRITICAL: Failed to get instance of AliCDBManager.");
96 fLocator = manager->GetStorage("local://$ALICE_ROOT");
105 Update(); // temporary
108 //_____________________________________________________________________________
109 AliTPCcalibDB::~AliTPCcalibDB()
114 if (fPadGainFactor) delete fPadGainFactor;
115 if (fPadTime0) delete fPadTime0;
116 if (fPadPRFWidth) delete fPadPRFWidth;
117 if (fPadNoise) delete fPadNoise;
121 //_____________________________________________________________________________
122 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
125 // Retrieves an entry with path <cdbPath> from the CDB.
131 AliFatal("AliTPCcalibDB: Run number not set! Use AliTPCcalibDB::SetRun.");
136 AliError("AliTPCcalibDB: Storage Locator not available.");
139 AliCDBEntry* entry = fLocator->Get(cdbPath, fRun);
142 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
150 //_____________________________________________________________________________
151 void AliTPCcalibDB::SetRun(Long64_t run)
154 // Sets current run number. Calibration data is read from the corresponding file.
164 void AliTPCcalibDB::Update(){
166 AliCDBEntry * entry=0;
168 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
170 if (fPadGainFactor) delete fPadGainFactor;
171 entry->SetOwner(kTRUE);
172 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
175 entry = GetCDBEntry("TPC/Calib/PadTime0");
177 if (fPadTime0) delete fPadTime0;
178 entry->SetOwner(kTRUE);
179 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
182 entry = GetCDBEntry("TPC/Calib/PadPRF");
184 if (fPadPRFWidth) delete fPadPRFWidth;
185 entry->SetOwner(kTRUE);
186 fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
189 entry = GetCDBEntry("TPC/Calib/PadNoise");
191 if (fPadNoise) delete fPadNoise;
192 entry->SetOwner(kTRUE);
193 fPadNoise = (AliTPCCalPad*)entry->GetObject();