]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibDB.cxx
reduced to 6 standard plots
[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
8e245d15 35#include "AliTPCParam.h"
c5bbaa2c 36#include "AliTPCCalROC.h"
37#include "AliTPCCalPad.h"
38#include "AliTPCCalDet.h"
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//_____________________________________________________________________________
81AliTPCcalibDB::AliTPCcalibDB()
e046d791 82 :TObject(),
83 fRun(-1),
84 fPadGainFactor(0),
85 fPadTime0(0),
86 fPadPRFWidth(0),
87 fPadNoise(0),
88 fPedestals(0),
89 fParam(0)
c5bbaa2c 90{
91 //
92 // constructor
93 //
e046d791 94
c5bbaa2c 95 Update(); // temporary
96}
97
98//_____________________________________________________________________________
99AliTPCcalibDB::~AliTPCcalibDB()
100{
101 //
102 // destructor
103 //
68751c2c 104
105 // don't delete anything, CDB cache is active!
106 //if (fPadGainFactor) delete fPadGainFactor;
107 //if (fPadTime0) delete fPadTime0;
108 //if (fPadPRFWidth) delete fPadPRFWidth;
109 //if (fPadNoise) delete fPadNoise;
8e245d15 110 if (fParam) {delete fParam; fParam = 0;}
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){
8e245d15 192 if (fParam) {delete fParam; fParam = 0;}
8477f500 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}