]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCcalibDB.cxx
The object has to be cloned, reverting the previous change
[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 {
83   //
84   // constructor
85   //  
86   fRun = -1;
87       
88   //
89   //
90   //
91   fPadGainFactor = 0;
92   fPadTime0      = 0;
93   fPadPRFWidth   = 0;
94   fPadNoise      = 0;
95   fPedestals     = 0;
96   fTemperature   = 0;
97   fParam         = 0;
98   Update();    // temporary
99 }
100
101 //_____________________________________________________________________________
102 AliTPCcalibDB::~AliTPCcalibDB() 
103 {
104   //
105   // destructor
106   //
107   
108   // don't delete anything, CDB cache is active!
109   //if (fPadGainFactor) delete fPadGainFactor;
110   //if (fPadTime0) delete fPadTime0;
111   //if (fPadPRFWidth) delete fPadPRFWidth;
112   //if (fPadNoise) delete fPadNoise;
113 }
114
115
116 //_____________________________________________________________________________
117 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
118 {
119   // 
120   // Retrieves an entry with path <cdbPath> from the CDB.
121   //
122   char chinfo[1000];
123     
124   AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun); 
125   if (!entry) 
126   { 
127     sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
128     AliError(chinfo); 
129     return 0; 
130   }
131   return entry;
132 }
133
134
135 //_____________________________________________________________________________
136 void AliTPCcalibDB::SetRun(Long64_t run)
137 {
138   //
139   // Sets current run number. Calibration data is read from the corresponding file. 
140   //  
141   if (fRun == run)
142     return;  
143   fRun = run;
144   Update();
145 }
146   
147
148
149 void AliTPCcalibDB::Update(){
150   //
151   AliCDBEntry * entry=0;
152   
153   Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
154   AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
155   
156   //
157   entry          = GetCDBEntry("TPC/Calib/PadGainFactor");
158   if (entry){
159     //if (fPadGainFactor) delete fPadGainFactor;
160     entry->SetOwner(kTRUE);
161     fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
162   }
163   //
164   entry          = GetCDBEntry("TPC/Calib/PadTime0");
165   if (entry){
166     //if (fPadTime0) delete fPadTime0;
167     entry->SetOwner(kTRUE);
168     fPadTime0 = (AliTPCCalPad*)entry->GetObject();
169   }
170   //
171   entry          = GetCDBEntry("TPC/Calib/PadPRF");
172   if (entry){
173     //if (fPadPRFWidth) delete fPadPRFWidth;
174     entry->SetOwner(kTRUE);
175     fPadPRFWidth = (AliTPCCalPad*)entry->GetObject();
176   }
177   //
178   entry          = GetCDBEntry("TPC/Calib/PadNoise");
179   if (entry){
180     //if (fPadNoise) delete fPadNoise;
181     entry->SetOwner(kTRUE);
182     fPadNoise = (AliTPCCalPad*)entry->GetObject();
183   }
184
185   entry          = GetCDBEntry("TPC/Calib/Pedestals");
186   if (entry){
187     //if (fPedestals) delete fPedestals;
188     entry->SetOwner(kTRUE);
189     fPedestals = (AliTPCCalPad*)entry->GetObject();
190   }
191
192   entry          = GetCDBEntry("TPC/Calib/Temperature");
193   if (entry){
194     //if (fTemperature) delete fTemperature;
195     entry->SetOwner(kTRUE);
196     fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
197   }
198
199   entry          = GetCDBEntry("TPC/Calib/Parameters");
200   if (entry){
201     //if (fPadNoise) delete fPadNoise;
202     entry->SetOwner(kTRUE);
203     fParam = (AliTPCParam*)(entry->GetObject()->Clone());
204   }
205
206
207   //
208   AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
209   
210 }