1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliEMCALCalibTimeDep.cxx $ */
18 //_________________________________________________________________________
20 ///////////////////////////////////////////////////////////////////////////////
22 // class for EMCAL time-dep calibration //
24 ///////////////////////////////////////////////////////////////////////////////
27 #include <TGraphSmooth.h>
29 #include "AliCDBEntry.h"
30 #include "AliCDBManager.h"
31 #include "AliEMCALSensorTempArray.h"
32 #include "AliEMCALCalibTimeDep.h"
34 /* first a bunch of constants.. */
35 const double fkSecToHour = 1.0/3600.0; // conversion factor from seconds to hours
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 // Note that this is only valid at gain M~30; i.e. voltages at V30.
40 // At V50, it's more like 2.25%/C, and at V20 about 1.35%/C (also info from Catania)
41 const double fkNormTemp = 20; // let's say that 20 degrees C is normal as default
43 const double fkErrorCode = -999; // to indicate that something went wrong
47 ClassImp(AliEMCALCalibTimeDep)
49 //________________________________________________________________
50 AliEMCALCalibTimeDep::AliEMCALCalibTimeDep() :
64 //________________________________________________________________
65 AliEMCALCalibTimeDep::AliEMCALCalibTimeDep(const AliEMCALCalibTimeDep& calibt) :
67 fRun(calibt.GetRunNumber()),
68 fStartTime(calibt.GetStartTime()),
69 fEndTime(calibt.GetEndTime()),
70 fMinTemp(calibt.GetMinTemp()),
71 fMaxTemp(calibt.GetMaxTemp()),
72 fMinTime(calibt.GetMinTime()),
73 fMaxTime(calibt.GetMaxTime()),
74 fRefTemp(calibt.GetRefTemp()),
75 fTempArray(calibt.GetTempArray())
81 //________________________________________________________________
82 AliEMCALCalibTimeDep &AliEMCALCalibTimeDep::operator =(const AliEMCALCalibTimeDep& calibt)
84 // assignment operator; use copy ctor
85 if (&calibt == this) return *this;
87 new (this) AliEMCALCalibTimeDep(calibt);
91 //________________________________________________________________
92 AliEMCALCalibTimeDep::~AliEMCALCalibTimeDep()
97 //________________________________________________________________
98 void AliEMCALCalibTimeDep::Reset()
100 // clear variables to default
108 fRefTemp = fkNormTemp;
113 //________________________________________________________________
114 void AliEMCALCalibTimeDep::PrintInfo() const
117 cout << endl << " AliEMCALCalibTimeDep::Print() " << endl;
118 // basic variables, all 'publicly available' also
119 cout << " VARIABLE DUMP: " << endl
120 << " GetStartTime() " << GetStartTime() << endl
121 << " GetEndTime() " << GetEndTime() << endl
122 << " GetMinTemp() " << GetMinTemp() << endl
123 << " GetMaxTemp() " << GetMaxTemp() << endl
124 << " GetRefTemp() " << GetRefTemp() << endl;
126 cout << " RUN INFO: " << endl
127 << " length (in hours) " << GetLengthOfRunInHours() << endl
128 << " range of temperature measurements (in hours) " << GetRangeOfTempMeasureInHours()
129 << " (in deg. C) " << GetRangeOfTempMeasureInDegrees()
131 // range in correction values
132 double corrAtMinTemp = GetCorrection( fMinTemp );
133 double corrAtMaxTemp = GetCorrection( fMaxTemp );
134 double corrMaxMinDiff = 100*(corrAtMinTemp - corrAtMaxTemp);
135 cout << " CORRECTION INFO : " << endl
136 << " corrAtMinTemp " << corrAtMinTemp << endl
137 << " corrAtMaxTemp " << corrAtMaxTemp << endl
138 << " corrMaxMinDiff (~%) [=(corrAtMin - corrAtMax)*100] "
139 << corrMaxMinDiff << endl;
143 //________________________________________________________________
144 double AliEMCALCalibTimeDep::GetLengthOfRunInHours() const
146 return (fEndTime - fStartTime)*fkSecToHour;
148 //________________________________________________________________
149 double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInHours() const
151 return (fMaxTime - fMinTime)*fkSecToHour;
153 //________________________________________________________________
154 double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInDegrees() const
156 return (fMaxTemp - fMinTemp);
159 //________________________________________________________________
160 void AliEMCALCalibTimeDep::Initialize(Int_t run,
161 UInt_t startTime, UInt_t endTime)
163 Reset(); // start fresh
166 fStartTime = startTime;
169 // collect the needed information
170 GetTemperatureInfo(); // temperature readings during the run
175 //________________________________________________________________
176 double AliEMCALCalibTimeDep::GetTemperature(UInt_t timeStamp) const
177 {// return estimate for all SuperModules and sensors, that had data
179 // first convert from seconds to hours..
180 double timeHour = (timeStamp - fStartTime) * fkSecToHour;
185 for (int i=0; i<fTempArray->NumSensors(); i++) {
187 AliEMCALSensorTemp *st = fTempArray->GetSensor(i);
189 // check if we had valid data for the time that is being asked for
190 if ( timeStamp>=st->GetStartTime() && timeStamp<=st->GetEndTime() ) {
191 AliSplineFit *f = st->GetFit();
192 if (f) { // ok, looks like we have valid data/info
193 // let's check what the expected value at the time appears to be
194 double val = f->Eval(timeHour);
199 } // loop over fTempArray
201 if (n>0) { // some valid data was found
205 else { // no good data
211 //________________________________________________________________
212 double AliEMCALCalibTimeDep::GetTemperatureSM(int imod, UInt_t timeStamp) const
213 {// return estimate for this one SuperModule, if it had data
215 // first convert from seconds to hours..
216 double timeHour = (timeStamp - fStartTime) * fkSecToHour;
221 for (int i=0; i<fTempArray->NumSensors(); i++) {
223 AliEMCALSensorTemp *st = fTempArray->GetSensor(i);
224 int module = st->GetSector()*2 + st->GetSide();
225 if ( module == imod ) { // right module
226 // check if we had valid data for the time that is being asked for
227 if ( timeStamp>=st->GetStartTime() && timeStamp<=st->GetEndTime() ) {
228 AliSplineFit *f = st->GetFit();
229 if (f) { // ok, looks like we have valid data/info
230 // let's check what the expected value at the time appears to be
231 double val = f->Eval(timeHour);
232 cout << " i " << i << " val " << val << endl;
239 } // loop over fTempArray
241 if (n>0) { // some valid data was found
245 else { // no good data
251 //________________________________________________________________
252 double AliEMCALCalibTimeDep::GetTemperatureSMSensor(int imod, int isens, UInt_t timeStamp) const
253 {// return estimate for this one SuperModule and sensor, if it had data
255 // first convert from seconds to hours..
256 double timeHour = (timeStamp - fStartTime) * fkSecToHour;
258 for (int i=0; i<fTempArray->NumSensors(); i++) {
260 AliEMCALSensorTemp *st = fTempArray->GetSensor(i);
261 int module = st->GetSector()*2 + st->GetSide();
262 if ( module == imod && st->GetNum()==isens ) { // right module, and sensor
263 // check if we had valid data for the time that is being asked for
264 if ( timeStamp>=st->GetStartTime() && timeStamp<=st->GetEndTime() ) {
265 AliSplineFit *f = st->GetFit();
266 if (f) { // ok, looks like we have valid data/info
267 // let's check what the expected value at the time appears to be
268 double val = f->Eval(timeHour);
270 return val; // no point to move further in for loop, we have found the sensor we were looking for
275 } // loop over fTempArray
277 // if we made it all here, it means that we didn't find the sensor we were looking for
283 //________________________________________________________________
284 double AliEMCALCalibTimeDep::GetCorrection(double temperature) const
285 { // gain decreases with increasing temperature
286 double gain = (1.0 - (temperature-fRefTemp)*fkTempSlope);
287 // i.e. multiplicative correction to ADC increases with increasing temperature
291 /* Next comes the method that does the work in picking up all the needed info..*/
292 //________________________________________________________________
293 void AliEMCALCalibTimeDep::GetTemperatureInfo()
295 // pick up Preprocessor output, based on fRun (most recent version)
296 AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/Temperature", fRun);
298 fTempArray = (AliEMCALSensorTempArray *) entry->GetObject();
302 AliInfo( Form("NumSensors %d - IdDCS: first %d last %d",
303 fTempArray->NumSensors(),
304 fTempArray->GetFirstIdDCS(), fTempArray->GetLastIdDCS() ) );
307 AliWarning( Form("AliEMCALSensorTempArray not found!") );