]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALCalibTimeDep.cxx
0th version of time-dependent basic calibration
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibTimeDep.cxx
CommitLineData
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.. */
35const 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
38const double fkTempSlope = 0.017; // 1.7% per deg. C, seems about right for all APDs, from studies at Catania, and by Rachid
39const double fkNormTemp = 20; // let's say that 20 degrees C is normal as default
40
41using namespace std;
42
43ClassImp(AliEMCALCalibTimeDep)
44
45//________________________________________________________________
46AliEMCALCalibTimeDep::AliEMCALCalibTimeDep() :
47 fRun(0),
48 fStartTime(0),
49 fEndTime(0),
50 fMinTemp(0),
51 fMaxTemp(0),
52 fMinTime(0),
53 fMaxTime(0),
54 fRefTemp(fkNormTemp),
55 fTempArray(NULL)
56{
57 // Constructor
58}
59
60//________________________________________________________________
61AliEMCALCalibTimeDep::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())
71{
72 // copy constructor
73}
74
75
76//________________________________________________________________
77AliEMCALCalibTimeDep &AliEMCALCalibTimeDep::operator =(const AliEMCALCalibTimeDep& calibt)
78{
79 // assignment operator; use copy ctor
80 if (&calibt == this) return *this;
81
82 new (this) AliEMCALCalibTimeDep(calibt);
83 return *this;
84}
85
86//________________________________________________________________
87AliEMCALCalibTimeDep::~AliEMCALCalibTimeDep()
88{
89 // Destructor
90}
91
92//________________________________________________________________
93void AliEMCALCalibTimeDep::Reset()
94{
95 // clear variables to default
96 fRun = 0;
97 fStartTime = 0;
98 fEndTime = 0;
99 fMinTemp = 0;
100 fMaxTemp = 0;
101 fMinTime = 0;
102 fMaxTime = 0;
103 fRefTemp = fkNormTemp;
104 fTempArray = NULL;
105 return;
106}
107
108//________________________________________________________________
109void AliEMCALCalibTimeDep::Print() const
110{
111 // print some info
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;
120 // run ranges
121 cout << " RUN INFO: " << endl
122 << " length (in hours) " << GetLengthOfRunInHours() << endl
123 << " range of temperature measurements (in hours) " << GetRangeOfTempMeasureInHours()
124 << " (in deg. C) " << GetRangeOfTempMeasureInDegrees()
125 << endl;
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;
135
136 return;
137}
138//________________________________________________________________
139double AliEMCALCalibTimeDep::GetLengthOfRunInHours() const
140{
141 return (fEndTime - fStartTime)*fkSecToHour;
142}
143//________________________________________________________________
144double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInHours() const
145{
146 return (fMaxTime - fMinTime)*fkSecToHour;
147}
148//________________________________________________________________
149double AliEMCALCalibTimeDep::GetRangeOfTempMeasureInDegrees() const
150{
151 return (fMaxTemp - fMinTemp);
152}
153
154//________________________________________________________________
155void AliEMCALCalibTimeDep::Initialize(Int_t run,
156 UInt_t startTime, UInt_t endTime)
157{
158 Reset(); // start fresh
159
160 fRun = run;
161 fStartTime = startTime;
162 fEndTime = endTime;
163
164 // collect the needed information
165 GetTemperatureInfo(); // temperature readings during the run
166
167 return;
168}
169
170//________________________________________________________________
171double AliEMCALCalibTimeDep::GetTemperature(int secSinceRunStart) const
172{// return estimate for all SuperModules and sensors, that had data
173
174 // first convert from seconds to hours..
175 double timeHour = secSinceRunStart * fkSecToHour;
176
177 // return fTempSpline->Eval(timeHour);
178 return timeHour; // DStmp - FIXME - just return time for now
179}
180
181//________________________________________________________________
182double AliEMCALCalibTimeDep::GetTemperatureSM(int imod, int secSinceRunStart) const
183{// return estimate for this one SuperModule, if it had data
184
185 // first convert from seconds to hours..
186 double timeHour = secSinceRunStart * fkSecToHour;
187
188 // return fTempSpline->Eval(timeHour);
189 return timeHour; // DStmp - FIXME - just return time for now
190}
191
192//________________________________________________________________
193double 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;
197
198 // return fTempSpline->Eval(timeHour);
199 return timeHour; // DStmp - FIXME - just return time for now
200}
201
202//________________________________________________________________
203double 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
207 return 1.0/gain;
208}
209
210/* Next comes the method that does the work in picking up all the needed info..*/
211//________________________________________________________________
212void AliEMCALCalibTimeDep::GetTemperatureInfo()
213{
214 // pick up Preprocessor output, based on fRun (most recent version)
215 AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/Temperature", fRun);
216 if (entry) {
217 fTempArray = (AliEMCALSensorTempArray *) entry->GetObject();
218 }
219
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() ) );
224
225 /* // below is just examples on what could be done to access the data..
226
227 AliEMCALSensorTemp *o = arr->GetSensor(0);
228 o->Print();
229 cout << " side " << o->GetSide()
230 << " sector " << o->GetSector()
231 << " num " << o->GetNum()
232 << " startTime " << o->GetStartTime()
233 << " endTime " << o->GetEndTime()
234 << endl;
235
236 AliSplineFit *f = o->GetFit();
237 int np = 0;
238
239 if (f) {
240 f->SplineFit(0);
241
242 np = f->GetKnots();
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++) {
248 cout << " i " << i
249 << " x " << x[i]
250 << " y0 " << y0[i]
251 << " y1 " << y1[i]
252 << endl;
253 // g->SetPoint(i, x[i], y0[i]);
254 }
255 double start = x[0];
256 double stop = x[np-1];
257
258 TGraph *g = f->MakeGraph(start, stop, np);
259 f->MakeSmooth(g, ratio, "normal");
260 np = f->GetKnots();
261 cout << " np " << np << endl;
262 TGraph *gSmooth = f->MakeGraph(start, stop, np);
263
264 // compare the raw and smoothed versions and select one..
265 // plot in 2 canvases/pads - CONTINUE HERE
266
267 g->Draw("ALP");
268 gSmooth->Draw("ALP");
269 f->Draw();
270 }
271
272 */
273
274 }
275
276 return;
277}