]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TPC/AliTPCcalibDB.cxx
First calibration classes (M.Ivanov)
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibDB.cxx
... / ...
CommitLineData
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 //
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.
87 fRun = 0;
88
89 AliCDBManager* manager = AliCDBManager::Instance();
90 if (!manager)
91 {
92 AliFatal("AliTRDcalibDB: CRITICAL: Failed to get instance of AliCDBManager.");
93 fLocator = 0;
94 }
95 else
96 fLocator = manager->GetStorage("local://$ALICE_ROOT");
97
98 //
99 //
100 //
101 fPadGainFactor = 0;
102 fPadTime0 = 0;
103 fPadPRFWidth = 0;
104 fPadNoise = 0;
105 Update(); // temporary
106}
107
108//_____________________________________________________________________________
109AliTPCcalibDB::~AliTPCcalibDB()
110{
111 //
112 // destructor
113 //
114 if (fPadGainFactor) delete fPadGainFactor;
115 if (fPadTime0) delete fPadTime0;
116 if (fPadPRFWidth) delete fPadPRFWidth;
117 if (fPadNoise) delete fPadNoise;
118}
119
120
121//_____________________________________________________________________________
122AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
123{
124 //
125 // Retrieves an entry with path <cdbPath> from the CDB.
126 //
127 char chinfo[1000];
128
129 if (fRun < 0)
130 {
131 AliFatal("AliTPCcalibDB: Run number not set! Use AliTPCcalibDB::SetRun.");
132 return 0;
133 }
134 if (!fLocator)
135 {
136 AliError("AliTPCcalibDB: Storage Locator not available.");
137 return 0;
138 }
139 AliCDBEntry* entry = fLocator->Get(cdbPath, fRun);
140 if (!entry)
141 {
142 sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
143 AliError(chinfo);
144 return 0;
145 }
146 return entry;
147}
148
149
150//_____________________________________________________________________________
151void AliTPCcalibDB::SetRun(Long64_t run)
152{
153 //
154 // Sets current run number. Calibration data is read from the corresponding file.
155 //
156 if (fRun == run)
157 return;
158 fRun = run;
159 Update();
160}
161
162
163
164void AliTPCcalibDB::Update(){
165 //
166 AliCDBEntry * entry=0;
167 //
168 entry = GetCDBEntry("TPC/Calib/PadGainFactor");
169 if (entry){
170 if (fPadGainFactor) delete fPadGainFactor;
171 entry->SetOwner(kTRUE);
172 fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
173 }
174 //
175 entry = GetCDBEntry("TPC/Calib/PadTime0");
176 if (entry){
177 if (fPadTime0) delete fPadTime0;
178 entry->SetOwner(kTRUE);
179 fPadTime0 = (AliTPCCalPad*)entry->GetObject();
180 }
181 //
182 entry = GetCDBEntry("TPC/Calib/PadPRF");
183 if (entry){
184 if (fPadPRFWidth) delete fPadPRFWidth;
185 entry->SetOwner(kTRUE);
186 fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
187 }
188 //
189 entry = GetCDBEntry("TPC/Calib/PadNoise");
190 if (entry){
191 if (fPadNoise) delete fPadNoise;
192 entry->SetOwner(kTRUE);
193 fPadNoise = (AliTPCCalPad*)entry->GetObject();
194 }
195 //
196
197}