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 const double fkNormTemp = 20; // let's say that 20 degrees C is normal as default
43 ClassImp(AliEMCALCalibTimeDep)
45 //________________________________________________________________
46 AliEMCALCalibTimeDep::AliEMCALCalibTimeDep() :
60 //________________________________________________________________
61 AliEMCALCalibTimeDep::AliEMCALCalibTimeDep(const AliEMCALCalibTimeDep& calibt) :
62 fRun(calibt.GetRunNumber()),
63 fStartTime(calibt.GetStartTime()),
64 fEndTime(calibt.GetEndTime()),
65 fMinTemp(calibt.GetMinTemp()),
66 fMaxTemp(calibt.GetMaxTemp()),
67 fMinTime(calibt.GetMinTime()),
68 fMaxTime(calibt.GetMaxTime()),
69 fRefTemp(calibt.GetRefTemp()),
70 fTempArray(calibt.GetTempArray())
76 //________________________________________________________________
77 AliEMCALCalibTimeDep &AliEMCALCalibTimeDep::operator =(const AliEMCALCalibTimeDep& calibt)
79 // assignment operator; use copy ctor
80 if (&calibt == this) return *this;
82 new (this) AliEMCALCalibTimeDep(calibt);
86 //________________________________________________________________
87 AliEMCALCalibTimeDep::~AliEMCALCalibTimeDep()
92 //________________________________________________________________
93 void AliEMCALCalibTimeDep::Reset()
95 // clear variables to default
103 fRefTemp = fkNormTemp;
108 //________________________________________________________________
109 void AliEMCALCalibTimeDep::Print() const
112 cout << endl << " AliEMCALCalibTimeDep::Print() " << endl;
113 // basic variables, all 'publicly available' also
114 cout << " VARIABLE DUMP: " << endl
115 << " GetStartTime() " << GetStartTime() << endl
116 << " GetEndTime() " << GetEndTime() << endl
117 << " GetMinTemp() " << GetMinTemp() << endl
118 << " GetMaxTemp() " << GetMaxTemp() << endl
119 << " GetRefTemp() " << GetRefTemp() << endl;
121 cout << " RUN INFO: " << endl
122 << " length (in hours) " << GetLengthOfRunInHours() << endl
123 << " range of temperature measurements (in hours) " << GetRangeOfTempMeasureInHours()
124 << " (in deg. C) " << GetRangeOfTempMeasureInDegrees()
126 // range in correction values
127 double corrAtMinTemp = GetCorrection( fMinTemp );
128 double corrAtMaxTemp = GetCorrection( fMaxTemp );
129 double corrMaxMinDiff = 100*(corrAtMinTemp - corrAtMaxTemp);
130 cout << " CORRECTION INFO : " << endl
131 << " corrAtMinTemp " << corrAtMinTemp << endl
132 << " corrAtMaxTemp " << corrAtMaxTemp << endl
133 << " corrMaxMinDiff (~%) [=(corrAtMin - corrAtMax)*100] "
134 << corrMaxMinDiff << endl;
138 //________________________________________________________________
139 double AliEMCALCalibTimeDep::GetLengthOfRunInHours() const
141 return (fEndTime - fStartTime)*fkSecToHour;
143 //________________________________________________________________
144 double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInHours() const
146 return (fMaxTime - fMinTime)*fkSecToHour;
148 //________________________________________________________________
149 double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInDegrees() const
151 return (fMaxTemp - fMinTemp);
154 //________________________________________________________________
155 void AliEMCALCalibTimeDep::Initialize(Int_t run,
156 UInt_t startTime, UInt_t endTime)
158 Reset(); // start fresh
161 fStartTime = startTime;
164 // collect the needed information
165 GetTemperatureInfo(); // temperature readings during the run
170 //________________________________________________________________
171 double AliEMCALCalibTimeDep::GetTemperature(int secSinceRunStart) const
172 {// return estimate for all SuperModules and sensors, that had data
174 // first convert from seconds to hours..
175 double timeHour = secSinceRunStart * fkSecToHour;
177 // return fTempSpline->Eval(timeHour);
178 return timeHour; // DStmp - FIXME - just return time for now
181 //________________________________________________________________
182 double AliEMCALCalibTimeDep::GetTemperatureSM(int imod, int secSinceRunStart) const
183 {// return estimate for this one SuperModule, if it had data
185 // first convert from seconds to hours..
186 double timeHour = secSinceRunStart * fkSecToHour;
188 // return fTempSpline->Eval(timeHour);
189 return timeHour; // DStmp - FIXME - just return time for now
192 //________________________________________________________________
193 double AliEMCALCalibTimeDep::GetTemperatureSMSensor(int imod, int isens, int secSinceRunStart) const
194 {// return estimate for this one SuperModule and sensor, if it had data
195 // first convert from seconds to hours..
196 double timeHour = secSinceRunStart * fkSecToHour;
198 // return fTempSpline->Eval(timeHour);
199 return timeHour; // DStmp - FIXME - just return time for now
202 //________________________________________________________________
203 double AliEMCALCalibTimeDep::GetCorrection(double temperature) const
204 { // gain decreases with increasing temperature
205 double gain = (1.0 - (temperature-fRefTemp)*fkTempSlope);
206 // i.e. multiplicative correction to ADC increases with increasing temperature
210 /* Next comes the method that does the work in picking up all the needed info..*/
211 //________________________________________________________________
212 void AliEMCALCalibTimeDep::GetTemperatureInfo()
214 // pick up Preprocessor output, based on fRun (most recent version)
215 AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/Temperature", fRun);
217 fTempArray = (AliEMCALSensorTempArray *) entry->GetObject();
220 if (fTempArray) { // DStmp - FIXME - not implemented what should be done here yet
221 AliInfo( Form("NumSensors %d - IdDCS: first %d last %d",
222 fTempArray->NumSensors(),
223 fTempArray->GetFirstIdDCS(), fTempArray->GetLastIdDCS() ) );
225 /* // below is just examples on what could be done to access the data..
227 AliEMCALSensorTemp *o = arr->GetSensor(0);
229 cout << " side " << o->GetSide()
230 << " sector " << o->GetSector()
231 << " num " << o->GetNum()
232 << " startTime " << o->GetStartTime()
233 << " endTime " << o->GetEndTime()
236 AliSplineFit *f = o->GetFit();
243 cout << " np " << np << endl;
244 Double_t *x = f->GetX();
245 Double_t *y0 = f->GetY0();
246 Double_t *y1 = f->GetY1();
247 for (int i=0; i<np; i++) {
253 // g->SetPoint(i, x[i], y0[i]);
256 double stop = x[np-1];
258 TGraph *g = f->MakeGraph(start, stop, np);
259 f->MakeSmooth(g, ratio, "normal");
261 cout << " np " << np << endl;
262 TGraph *gSmooth = f->MakeGraph(start, stop, np);
264 // compare the raw and smoothed versions and select one..
265 // plot in 2 canvases/pads - CONTINUE HERE
268 gSmooth->Draw("ALP");