]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibDB.cxx
Added preprocessor conditionals to support ROOT > 5.11.2.
[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;
94 Update(); // temporary
95}
96
97//_____________________________________________________________________________
98AliTPCcalibDB::~AliTPCcalibDB()
99{
100 //
101 // destructor
102 //
68751c2c 103
104 // don't delete anything, CDB cache is active!
105 //if (fPadGainFactor) delete fPadGainFactor;
106 //if (fPadTime0) delete fPadTime0;
107 //if (fPadPRFWidth) delete fPadPRFWidth;
108 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 109}
110
111
112//_____________________________________________________________________________
113AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
114{
115 //
116 // Retrieves an entry with path <cdbPath> from the CDB.
117 //
118 char chinfo[1000];
119
68751c2c 120 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
c5bbaa2c 121 if (!entry)
122 {
123 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
124 AliError(chinfo);
125 return 0;
126 }
127 return entry;
128}
129
130
131//_____________________________________________________________________________
132void AliTPCcalibDB::SetRun(Long64_t run)
133{
134 //
135 // Sets current run number. Calibration data is read from the corresponding file.
136 //
137 if (fRun == run)
138 return;
139 fRun = run;
140 Update();
141}
142
143
144
145void AliTPCcalibDB::Update(){
146 //
147 AliCDBEntry * entry=0;
68751c2c 148
149 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
150 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
151
c5bbaa2c 152 //
153 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
154 if (entry){
68751c2c 155 //if (fPadGainFactor) delete fPadGainFactor;
c5bbaa2c 156 entry->SetOwner(kTRUE);
157 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
158 }
159 //
160 entry = GetCDBEntry("TPC/Calib/PadTime0");
161 if (entry){
68751c2c 162 //if (fPadTime0) delete fPadTime0;
c5bbaa2c 163 entry->SetOwner(kTRUE);
164 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
165 }
166 //
167 entry = GetCDBEntry("TPC/Calib/PadPRF");
168 if (entry){
68751c2c 169 //if (fPadPRFWidth) delete fPadPRFWidth;
c5bbaa2c 170 entry->SetOwner(kTRUE);
171 fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
172 }
173 //
174 entry = GetCDBEntry("TPC/Calib/PadNoise");
175 if (entry){
68751c2c 176 //if (fPadNoise) delete fPadNoise;
c5bbaa2c 177 entry->SetOwner(kTRUE);
178 fPadNoise = (AliTPCCalPad*)entry->GetObject();
179 }
180 //
68751c2c 181 AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
182
c5bbaa2c 183}