]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibDB.cxx
Add the possibiloity to save cut settings in the ROOT file
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibDB.cxx
CommitLineData
c5bbaa2c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16
17///////////////////////////////////////////////////////////////////////////////
18// //
19// Class providing the calibration parameters by accessing the CDB //
20// //
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 //
24// //
25///////////////////////////////////////////////////////////////////////////////
26
27
28#include <AliCDBManager.h>
29#include <AliCDBStorage.h>
30#include <AliCDBEntry.h>
31#include <AliLog.h>
32
33#include "AliTPCcalibDB.h"
34
35#include "AliTPCCalROC.h"
36#include "AliTPCCalPad.h"
37#include "AliTPCCalDet.h"
54472e4f 38#include "AliTPCSensorTempArray.h"
c5bbaa2c 39
40ClassImp(AliTPCcalibDB)
41
42AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
43Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
44
45
46//_ singleton implementation __________________________________________________
47AliTPCcalibDB* AliTPCcalibDB::Instance()
48{
49 //
50 // Singleton implementation
51 // Returns an instance of this class, it is created if neccessary
52 //
53
54 if (fgTerminated != kFALSE)
55 return 0;
56
57 if (fgInstance == 0)
58 fgInstance = new AliTPCcalibDB();
59
60 return fgInstance;
61}
62
63void AliTPCcalibDB::Terminate()
64{
65 //
66 // Singleton implementation
67 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
68 // This function can be called several times.
69 //
70
71 fgTerminated = kTRUE;
72
73 if (fgInstance != 0)
74 {
75 delete fgInstance;
76 fgInstance = 0;
77 }
78}
79
80//_____________________________________________________________________________
e4dce695 81AliTPCcalibDB::AliTPCcalibDB():
82 fRun(-1),
83 fPadGainFactor(0),
84 fPadTime0(0),
85 fPadPRFWidth(0),
86 fPadNoise(0),
87 fPedestals(0),
88 fTemperature(0),
89 fPressure(0),
90 fParam(0)
91
c5bbaa2c 92{
93 //
94 // constructor
95 //
54472e4f 96 //
c5bbaa2c 97 Update(); // temporary
98}
99
100//_____________________________________________________________________________
101AliTPCcalibDB::~AliTPCcalibDB()
102{
103 //
104 // destructor
105 //
68751c2c 106
107 // don't delete anything, CDB cache is active!
108 //if (fPadGainFactor) delete fPadGainFactor;
109 //if (fPadTime0) delete fPadTime0;
110 //if (fPadPRFWidth) delete fPadPRFWidth;
111 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 112}
113
114
115//_____________________________________________________________________________
116AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
117{
118 //
119 // Retrieves an entry with path <cdbPath> from the CDB.
120 //
121 char chinfo[1000];
122
68751c2c 123 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
c5bbaa2c 124 if (!entry)
125 {
126 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
127 AliError(chinfo);
128 return 0;
129 }
130 return entry;
131}
132
133
134//_____________________________________________________________________________
135void AliTPCcalibDB::SetRun(Long64_t run)
136{
137 //
138 // Sets current run number. Calibration data is read from the corresponding file.
139 //
140 if (fRun == run)
141 return;
142 fRun = run;
143 Update();
144}
145
146
147
148void AliTPCcalibDB::Update(){
149 //
150 AliCDBEntry * entry=0;
68751c2c 151
152 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
153 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
154
c5bbaa2c 155 //
156 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
157 if (entry){
68751c2c 158 //if (fPadGainFactor) delete fPadGainFactor;
c5bbaa2c 159 entry->SetOwner(kTRUE);
160 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
161 }
162 //
163 entry = GetCDBEntry("TPC/Calib/PadTime0");
164 if (entry){
68751c2c 165 //if (fPadTime0) delete fPadTime0;
c5bbaa2c 166 entry->SetOwner(kTRUE);
167 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
168 }
169 //
170 entry = GetCDBEntry("TPC/Calib/PadPRF");
171 if (entry){
68751c2c 172 //if (fPadPRFWidth) delete fPadPRFWidth;
c5bbaa2c 173 entry->SetOwner(kTRUE);
174 fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
175 }
176 //
177 entry = GetCDBEntry("TPC/Calib/PadNoise");
178 if (entry){
68751c2c 179 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 180 entry->SetOwner(kTRUE);
181 fPadNoise = (AliTPCCalPad*)entry->GetObject();
182 }
8477f500 183
184 entry = GetCDBEntry("TPC/Calib/Pedestals");
185 if (entry){
186 //if (fPedestals) delete fPedestals;
187 entry->SetOwner(kTRUE);
188 fPedestals = (AliTPCCalPad*)entry->GetObject();
189 }
190
54472e4f 191 entry = GetCDBEntry("TPC/Calib/Temperature");
192 if (entry){
193 //if (fTemperature) delete fTemperature;
194 entry->SetOwner(kTRUE);
195 fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
196 }
197
e4dce695 198 entry = GetCDBEntry("TPC/Calib/Pressure");
199 if (entry){
200 //if (fPressure) delete fPressure;
201 entry->SetOwner(kTRUE);
202 fPressure = (AliTPCSensorPressureArray*)entry->GetObject();
203 }
204
205
8477f500 206 entry = GetCDBEntry("TPC/Calib/Parameters");
207 if (entry){
54472e4f 208 //if (fPadNoise) delete fPadNoise;
8477f500 209 entry->SetOwner(kTRUE);
a778f7e3 210 fParam = (AliTPCParam*)(entry->GetObject()->Clone());
8477f500 211 }
212
213
c5bbaa2c 214 //
68751c2c 215 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
216
c5bbaa2c 217}
e4dce695 218AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& org)
219{
220 //
221 // Copy constructor invalid -- singleton implementation
222 //
223 Error("copy constructor","invalid -- singleton implementation");
224}
225
226AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& rhs)
227{
228//
229// Singleton implementation - no assignment operator
230//
231 Error("operator =", "assignment operator not implemented");
232 return *this;
233}
234