]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCcalibDB.cxx
Changed some Double_t to Double32_t
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibDB.cxx
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 #include "AliTPCSensorTempArray.h"
39
40 ClassImp(AliTPCcalibDB)
41
42 AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
43 Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
44
45
46 //_ singleton implementation __________________________________________________
47 AliTPCcalibDB* 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
63 void 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 //_____________________________________________________________________________
81 AliTPCcalibDB::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
92 {
93   //
94   // constructor
95   //  
96   //
97   Update();    // temporary
98 }
99
100 //_____________________________________________________________________________
101 AliTPCcalibDB::~AliTPCcalibDB() 
102 {
103   //
104   // destructor
105   //
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;
112 }
113
114
115 //_____________________________________________________________________________
116 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
117 {
118   // 
119   // Retrieves an entry with path <cdbPath> from the CDB.
120   //
121   char chinfo[1000];
122     
123   AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun); 
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 //_____________________________________________________________________________
135 void 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
148 void AliTPCcalibDB::Update(){
149   //
150   AliCDBEntry * entry=0;
151   
152   Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
153   AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
154   
155   //
156   entry          = GetCDBEntry("TPC/Calib/PadGainFactor");
157   if (entry){
158     //if (fPadGainFactor) delete fPadGainFactor;
159     entry->SetOwner(kTRUE);
160     fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
161   }
162   //
163   entry          = GetCDBEntry("TPC/Calib/PadTime0");
164   if (entry){
165     //if (fPadTime0) delete fPadTime0;
166     entry->SetOwner(kTRUE);
167     fPadTime0 = (AliTPCCalPad*)entry->GetObject();
168   }
169   //
170   entry          = GetCDBEntry("TPC/Calib/PadPRF");
171   if (entry){
172     //if (fPadPRFWidth) delete fPadPRFWidth;
173     entry->SetOwner(kTRUE);
174     fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
175   }
176   //
177   entry          = GetCDBEntry("TPC/Calib/PadNoise");
178   if (entry){
179     //if (fPadNoise) delete fPadNoise;
180     entry->SetOwner(kTRUE);
181     fPadNoise = (AliTPCCalPad*)entry->GetObject();
182   }
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
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
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
206   entry          = GetCDBEntry("TPC/Calib/Parameters");
207   if (entry){
208     //if (fPadNoise) delete fPadNoise;
209     entry->SetOwner(kTRUE);
210     fParam = (AliTPCParam*)(entry->GetObject()->Clone());
211   }
212
213
214   //
215   AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
216   
217 }
218 AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& org)
219 {
220   //
221   // Copy constructor invalid -- singleton implementation
222   //
223    Error("copy constructor","invalid -- singleton implementation");
224 }
225
226 AliTPCcalibDB& 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