]>
Commit | Line | Data |
---|---|---|
a42992b7 | 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 | /* $Id: AliEMCALCalibTimeDep.cxx $ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | ///*-- Author: | |
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // class for EMCAL time-dep calibration // | |
23 | // // | |
24 | /////////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | #include <iostream> | |
27 | #include <TGraphSmooth.h> | |
28 | #include "AliLog.h" | |
29 | #include "AliCDBEntry.h" | |
30 | #include "AliCDBManager.h" | |
31 | #include "AliEMCALSensorTempArray.h" | |
32 | #include "AliEMCALCalibTimeDep.h" | |
33 | ||
34 | /* first a bunch of constants.. */ | |
35 | const double fkSecToHour = 1.0/3600.0; // conversion factor from seconds to hours | |
36 | ||
37 | // some global variables for APD handling; assume the same for all, at least to start with | |
38 | const double fkTempSlope = 0.017; // 1.7% per deg. C, seems about right for all APDs, from studies at Catania, and by Rachid | |
39 | const double fkNormTemp = 20; // let's say that 20 degrees C is normal as default | |
40 | ||
621ff010 | 41 | const double fkErrorCode = -999; // to indicate that something went wrong |
42 | ||
a42992b7 | 43 | using namespace std; |
44 | ||
45 | ClassImp(AliEMCALCalibTimeDep) | |
46 | ||
47 | //________________________________________________________________ | |
48 | AliEMCALCalibTimeDep::AliEMCALCalibTimeDep() : | |
49 | fRun(0), | |
50 | fStartTime(0), | |
51 | fEndTime(0), | |
52 | fMinTemp(0), | |
53 | fMaxTemp(0), | |
54 | fMinTime(0), | |
55 | fMaxTime(0), | |
56 | fRefTemp(fkNormTemp), | |
57 | fTempArray(NULL) | |
58 | { | |
59 | // Constructor | |
60 | } | |
61 | ||
62 | //________________________________________________________________ | |
63 | AliEMCALCalibTimeDep::AliEMCALCalibTimeDep(const AliEMCALCalibTimeDep& calibt) : | |
621ff010 | 64 | TObject(calibt), |
a42992b7 | 65 | fRun(calibt.GetRunNumber()), |
66 | fStartTime(calibt.GetStartTime()), | |
67 | fEndTime(calibt.GetEndTime()), | |
68 | fMinTemp(calibt.GetMinTemp()), | |
69 | fMaxTemp(calibt.GetMaxTemp()), | |
70 | fMinTime(calibt.GetMinTime()), | |
71 | fMaxTime(calibt.GetMaxTime()), | |
72 | fRefTemp(calibt.GetRefTemp()), | |
73 | fTempArray(calibt.GetTempArray()) | |
74 | { | |
75 | // copy constructor | |
76 | } | |
77 | ||
78 | ||
79 | //________________________________________________________________ | |
80 | AliEMCALCalibTimeDep &AliEMCALCalibTimeDep::operator =(const AliEMCALCalibTimeDep& calibt) | |
81 | { | |
82 | // assignment operator; use copy ctor | |
83 | if (&calibt == this) return *this; | |
84 | ||
85 | new (this) AliEMCALCalibTimeDep(calibt); | |
86 | return *this; | |
87 | } | |
88 | ||
89 | //________________________________________________________________ | |
90 | AliEMCALCalibTimeDep::~AliEMCALCalibTimeDep() | |
91 | { | |
92 | // Destructor | |
93 | } | |
94 | ||
95 | //________________________________________________________________ | |
96 | void AliEMCALCalibTimeDep::Reset() | |
97 | { | |
98 | // clear variables to default | |
99 | fRun = 0; | |
100 | fStartTime = 0; | |
101 | fEndTime = 0; | |
102 | fMinTemp = 0; | |
103 | fMaxTemp = 0; | |
104 | fMinTime = 0; | |
105 | fMaxTime = 0; | |
106 | fRefTemp = fkNormTemp; | |
107 | fTempArray = NULL; | |
108 | return; | |
109 | } | |
110 | ||
111 | //________________________________________________________________ | |
621ff010 | 112 | void AliEMCALCalibTimeDep::PrintInfo() const |
a42992b7 | 113 | { |
114 | // print some info | |
115 | cout << endl << " AliEMCALCalibTimeDep::Print() " << endl; | |
116 | // basic variables, all 'publicly available' also | |
117 | cout << " VARIABLE DUMP: " << endl | |
118 | << " GetStartTime() " << GetStartTime() << endl | |
119 | << " GetEndTime() " << GetEndTime() << endl | |
120 | << " GetMinTemp() " << GetMinTemp() << endl | |
121 | << " GetMaxTemp() " << GetMaxTemp() << endl | |
122 | << " GetRefTemp() " << GetRefTemp() << endl; | |
123 | // run ranges | |
124 | cout << " RUN INFO: " << endl | |
125 | << " length (in hours) " << GetLengthOfRunInHours() << endl | |
126 | << " range of temperature measurements (in hours) " << GetRangeOfTempMeasureInHours() | |
127 | << " (in deg. C) " << GetRangeOfTempMeasureInDegrees() | |
128 | << endl; | |
129 | // range in correction values | |
130 | double corrAtMinTemp = GetCorrection( fMinTemp ); | |
131 | double corrAtMaxTemp = GetCorrection( fMaxTemp ); | |
132 | double corrMaxMinDiff = 100*(corrAtMinTemp - corrAtMaxTemp); | |
133 | cout << " CORRECTION INFO : " << endl | |
134 | << " corrAtMinTemp " << corrAtMinTemp << endl | |
135 | << " corrAtMaxTemp " << corrAtMaxTemp << endl | |
136 | << " corrMaxMinDiff (~%) [=(corrAtMin - corrAtMax)*100] " | |
137 | << corrMaxMinDiff << endl; | |
138 | ||
139 | return; | |
140 | } | |
141 | //________________________________________________________________ | |
142 | double AliEMCALCalibTimeDep::GetLengthOfRunInHours() const | |
143 | { | |
144 | return (fEndTime - fStartTime)*fkSecToHour; | |
145 | } | |
146 | //________________________________________________________________ | |
147 | double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInHours() const | |
148 | { | |
149 | return (fMaxTime - fMinTime)*fkSecToHour; | |
150 | } | |
151 | //________________________________________________________________ | |
152 | double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInDegrees() const | |
153 | { | |
154 | return (fMaxTemp - fMinTemp); | |
155 | } | |
156 | ||
157 | //________________________________________________________________ | |
158 | void AliEMCALCalibTimeDep::Initialize(Int_t run, | |
159 | UInt_t startTime, UInt_t endTime) | |
160 | { | |
161 | Reset(); // start fresh | |
162 | ||
163 | fRun = run; | |
164 | fStartTime = startTime; | |
165 | fEndTime = endTime; | |
166 | ||
167 | // collect the needed information | |
168 | GetTemperatureInfo(); // temperature readings during the run | |
169 | ||
170 | return; | |
171 | } | |
172 | ||
173 | //________________________________________________________________ | |
621ff010 | 174 | double AliEMCALCalibTimeDep::GetTemperature(UInt_t timeStamp) const |
a42992b7 | 175 | {// return estimate for all SuperModules and sensors, that had data |
176 | ||
177 | // first convert from seconds to hours.. | |
621ff010 | 178 | double timeHour = (timeStamp - fStartTime) * fkSecToHour; |
179 | ||
180 | double average = 0; | |
181 | int n = 0; | |
182 | ||
183 | for (int i=0; i<fTempArray->NumSensors(); i++) { | |
184 | ||
185 | AliEMCALSensorTemp *st = fTempArray->GetSensor(i); | |
186 | ||
187 | // check if we had valid data for the time that is being asked for | |
188 | if ( timeStamp>=st->GetStartTime() && timeStamp<=st->GetEndTime() ) { | |
189 | AliSplineFit *f = st->GetFit(); | |
190 | if (f) { // ok, looks like we have valid data/info | |
191 | // let's check what the expected value at the time appears to be | |
192 | double val = f->Eval(timeHour); | |
193 | average += val; | |
194 | n++; | |
195 | } | |
196 | } // time | |
197 | } // loop over fTempArray | |
198 | ||
199 | if (n>0) { // some valid data was found | |
200 | average /= n; | |
201 | return average; | |
202 | } | |
203 | else { // no good data | |
204 | return fkErrorCode; | |
205 | } | |
a42992b7 | 206 | |
a42992b7 | 207 | } |
208 | ||
209 | //________________________________________________________________ | |
621ff010 | 210 | double AliEMCALCalibTimeDep::GetTemperatureSM(int imod, UInt_t timeStamp) const |
a42992b7 | 211 | {// return estimate for this one SuperModule, if it had data |
212 | ||
213 | // first convert from seconds to hours.. | |
621ff010 | 214 | double timeHour = (timeStamp - fStartTime) * fkSecToHour; |
215 | ||
216 | double average = 0; | |
217 | int n = 0; | |
218 | ||
219 | for (int i=0; i<fTempArray->NumSensors(); i++) { | |
220 | ||
221 | AliEMCALSensorTemp *st = fTempArray->GetSensor(i); | |
222 | int module = st->GetSector()*2 + st->GetSide(); | |
223 | if ( module == imod ) { // right module | |
224 | // check if we had valid data for the time that is being asked for | |
225 | if ( timeStamp>=st->GetStartTime() && timeStamp<=st->GetEndTime() ) { | |
226 | AliSplineFit *f = st->GetFit(); | |
227 | if (f) { // ok, looks like we have valid data/info | |
228 | // let's check what the expected value at the time appears to be | |
229 | double val = f->Eval(timeHour); | |
230 | cout << " i " << i << " val " << val << endl; | |
231 | average += val; | |
232 | n++; | |
233 | } | |
234 | } // time | |
235 | } | |
236 | ||
237 | } // loop over fTempArray | |
238 | ||
239 | if (n>0) { // some valid data was found | |
240 | average /= n; | |
241 | return average; | |
242 | } | |
243 | else { // no good data | |
244 | return fkErrorCode; | |
245 | } | |
a42992b7 | 246 | |
a42992b7 | 247 | } |
248 | ||
249 | //________________________________________________________________ | |
621ff010 | 250 | double AliEMCALCalibTimeDep::GetTemperatureSMSensor(int imod, int isens, UInt_t timeStamp) const |
a42992b7 | 251 | {// return estimate for this one SuperModule and sensor, if it had data |
621ff010 | 252 | |
a42992b7 | 253 | // first convert from seconds to hours.. |
621ff010 | 254 | double timeHour = (timeStamp - fStartTime) * fkSecToHour; |
255 | ||
256 | for (int i=0; i<fTempArray->NumSensors(); i++) { | |
257 | ||
258 | AliEMCALSensorTemp *st = fTempArray->GetSensor(i); | |
259 | int module = st->GetSector()*2 + st->GetSide(); | |
260 | if ( module == imod && st->GetNum()==isens ) { // right module, and sensor | |
261 | // check if we had valid data for the time that is being asked for | |
262 | if ( timeStamp>=st->GetStartTime() && timeStamp<=st->GetEndTime() ) { | |
263 | AliSplineFit *f = st->GetFit(); | |
264 | if (f) { // ok, looks like we have valid data/info | |
265 | // let's check what the expected value at the time appears to be | |
266 | double val = f->Eval(timeHour); | |
267 | ||
268 | return val; // no point to move further in for loop, we have found the sensor we were looking for | |
269 | } | |
270 | } // time | |
271 | } | |
272 | ||
273 | } // loop over fTempArray | |
a42992b7 | 274 | |
621ff010 | 275 | // if we made it all here, it means that we didn't find the sensor we were looking for |
276 | // i.e. no good data | |
277 | return fkErrorCode; | |
278 | ||
a42992b7 | 279 | } |
280 | ||
281 | //________________________________________________________________ | |
282 | double AliEMCALCalibTimeDep::GetCorrection(double temperature) const | |
283 | { // gain decreases with increasing temperature | |
284 | double gain = (1.0 - (temperature-fRefTemp)*fkTempSlope); | |
285 | // i.e. multiplicative correction to ADC increases with increasing temperature | |
286 | return 1.0/gain; | |
287 | } | |
288 | ||
289 | /* Next comes the method that does the work in picking up all the needed info..*/ | |
290 | //________________________________________________________________ | |
291 | void AliEMCALCalibTimeDep::GetTemperatureInfo() | |
292 | { | |
293 | // pick up Preprocessor output, based on fRun (most recent version) | |
294 | AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/Temperature", fRun); | |
295 | if (entry) { | |
296 | fTempArray = (AliEMCALSensorTempArray *) entry->GetObject(); | |
297 | } | |
298 | ||
621ff010 | 299 | if (fTempArray) { |
a42992b7 | 300 | AliInfo( Form("NumSensors %d - IdDCS: first %d last %d", |
301 | fTempArray->NumSensors(), | |
302 | fTempArray->GetFirstIdDCS(), fTempArray->GetLastIdDCS() ) ); | |
621ff010 | 303 | } |
304 | else { | |
305 | AliWarning( Form("AliEMCALSensorTempArray not found!") ); | |
a42992b7 | 306 | } |
307 | ||
308 | return; | |
309 | } |