]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibDB.cxx
Make copy of the TPC parameters (Marian)
[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"
38
39ClassImp(AliTPCcalibDB)
40
41AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
42Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
43
44
45//_ singleton implementation __________________________________________________
46AliTPCcalibDB* AliTPCcalibDB::Instance()
47{
48 //
49 // Singleton implementation
50 // Returns an instance of this class, it is created if neccessary
51 //
52
53 if (fgTerminated != kFALSE)
54 return 0;
55
56 if (fgInstance == 0)
57 fgInstance = new AliTPCcalibDB();
58
59 return fgInstance;
60}
61
62void AliTPCcalibDB::Terminate()
63{
64 //
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.
68 //
69
70 fgTerminated = kTRUE;
71
72 if (fgInstance != 0)
73 {
74 delete fgInstance;
75 fgInstance = 0;
76 }
77}
78
79//_____________________________________________________________________________
80AliTPCcalibDB::AliTPCcalibDB()
81{
82 //
83 // constructor
84 //
68751c2c 85 fRun = -1;
c5bbaa2c 86
c5bbaa2c 87 //
88 //
89 //
90 fPadGainFactor = 0;
91 fPadTime0 = 0;
92 fPadPRFWidth = 0;
93 fPadNoise = 0;
8477f500 94 fPedestals = 0;
95 fParam =0;
c5bbaa2c 96 Update(); // temporary
97}
98
99//_____________________________________________________________________________
100AliTPCcalibDB::~AliTPCcalibDB()
101{
102 //
103 // destructor
104 //
68751c2c 105
106 // don't delete anything, CDB cache is active!
107 //if (fPadGainFactor) delete fPadGainFactor;
108 //if (fPadTime0) delete fPadTime0;
109 //if (fPadPRFWidth) delete fPadPRFWidth;
110 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 111}
112
113
114//_____________________________________________________________________________
115AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
116{
117 //
118 // Retrieves an entry with path <cdbPath> from the CDB.
119 //
120 char chinfo[1000];
121
68751c2c 122 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
c5bbaa2c 123 if (!entry)
124 {
125 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
126 AliError(chinfo);
127 return 0;
128 }
129 return entry;
130}
131
132
133//_____________________________________________________________________________
134void AliTPCcalibDB::SetRun(Long64_t run)
135{
136 //
137 // Sets current run number. Calibration data is read from the corresponding file.
138 //
139 if (fRun == run)
140 return;
141 fRun = run;
142 Update();
143}
144
145
146
147void AliTPCcalibDB::Update(){
148 //
149 AliCDBEntry * entry=0;
68751c2c 150
151 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
152 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
153
c5bbaa2c 154 //
155 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
156 if (entry){
68751c2c 157 //if (fPadGainFactor) delete fPadGainFactor;
c5bbaa2c 158 entry->SetOwner(kTRUE);
159 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
160 }
161 //
162 entry = GetCDBEntry("TPC/Calib/PadTime0");
163 if (entry){
68751c2c 164 //if (fPadTime0) delete fPadTime0;
c5bbaa2c 165 entry->SetOwner(kTRUE);
166 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
167 }
168 //
169 entry = GetCDBEntry("TPC/Calib/PadPRF");
170 if (entry){
68751c2c 171 //if (fPadPRFWidth) delete fPadPRFWidth;
c5bbaa2c 172 entry->SetOwner(kTRUE);
173 fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
174 }
175 //
176 entry = GetCDBEntry("TPC/Calib/PadNoise");
177 if (entry){
68751c2c 178 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 179 entry->SetOwner(kTRUE);
180 fPadNoise = (AliTPCCalPad*)entry->GetObject();
181 }
8477f500 182
183 entry = GetCDBEntry("TPC/Calib/Pedestals");
184 if (entry){
185 //if (fPedestals) delete fPedestals;
186 entry->SetOwner(kTRUE);
187 fPedestals = (AliTPCCalPad*)entry->GetObject();
188 }
189
190 entry = GetCDBEntry("TPC/Calib/Parameters");
191 if (entry){
192 //if (fPadNoise) delete fPadNoise;
193 entry->SetOwner(kTRUE);
1734532c 194 fParam = (AliTPCParam*)(entry->GetObject()->Clone());
8477f500 195 }
196
197
c5bbaa2c 198 //
68751c2c 199 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
200
c5bbaa2c 201}