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 **************************************************************************/
19 // * this class defines the TOF object to be stored
20 // * in OCDB on a run-by-run basis in order to have the measurement
21 // * of the time evolution of T0 and of TOF resolution including
22 // * average T0 uncertainty
27 #include "AliTOFRunParams.h"
29 ClassImp(AliTOFRunParams)
31 //_________________________________________________________
33 AliTOFRunParams::AliTOFRunParams() :
46 //_________________________________________________________
48 AliTOFRunParams::AliTOFRunParams(Int_t nPoints) :
51 fTimestamp(new UInt_t[nPoints]),
52 fT0(new Float_t[nPoints]),
53 fTOFResolution(new Float_t[nPoints]),
54 fT0Spread(new Float_t[nPoints])
57 * standard constructor
61 //_________________________________________________________
63 AliTOFRunParams::~AliTOFRunParams()
69 if (fTimestamp) delete [] fTimestamp;
70 if (fT0) delete [] fT0;
71 if (fTOFResolution) delete [] fTOFResolution;
72 if (fT0Spread) delete [] fT0Spread;
75 //_________________________________________________________
77 AliTOFRunParams::AliTOFRunParams(const AliTOFRunParams &source) :
79 fNPoints(source.fNPoints),
80 fTimestamp(new UInt_t[source.fNPoints]),
81 fT0(new Float_t[source.fNPoints]),
82 fTOFResolution(new Float_t[source.fNPoints]),
83 fT0Spread(new Float_t[source.fNPoints])
89 for (Int_t i = 0; i < fNPoints; i++) {
90 fTimestamp[i] = source.fTimestamp[i];
91 fT0[i] = source.fT0[i];
92 fTOFResolution[i] = source.fTOFResolution[i];
93 fT0Spread[i] = source.fT0Spread[i];
98 //_________________________________________________________
101 AliTOFRunParams::operator=(const AliTOFRunParams &source)
107 if (this == &source) return *this;
108 TObject::operator=(source);
110 if (fNPoints != source.fNPoints) {
111 if (fTimestamp) delete [] fTimestamp;
112 if (fT0) delete [] fT0;
113 if (fTOFResolution) delete [] fTOFResolution;
114 if (fT0Spread) delete [] fT0Spread;
115 fNPoints = source.fNPoints;
116 fTimestamp = new UInt_t[source.fNPoints];
117 fT0 = new Float_t[source.fNPoints];
118 fTOFResolution = new Float_t[source.fNPoints];
119 fT0Spread = new Float_t[source.fNPoints];
122 for (Int_t i = 0; i < fNPoints; i++) {
123 fTimestamp[i] = source.fTimestamp[i];
124 fT0[i] = source.fT0[i];
125 fTOFResolution[i] = source.fTOFResolution[i];
126 fT0Spread[i] = source.fT0Spread[i];
132 //_________________________________________________________
135 AliTOFRunParams::EvalT0(UInt_t timestamp)
142 1. no measurement -> 0.
143 2. single measurement -> single value
144 3. timestamp before first measurement -> first value
145 4. timestamp after last measurement -> last value
147 if (fNPoints <= 0 || !fT0 || !fTimestamp) return 0.;
148 if (fNPoints == 1) return fT0[0];
149 if (timestamp <= fTimestamp[0]) return fT0[0];
150 if (timestamp >= fTimestamp[fNPoints - 1]) return fT0[fNPoints - 1];
152 /* interpolate value */
154 for (ipoint = 0; ipoint < fNPoints - 1; ipoint++)
155 if (timestamp >= fTimestamp[ipoint] && timestamp < fTimestamp[ipoint + 1])
157 Float_t coeff = (fT0[ipoint + 1] - fT0[ipoint]) / (Float_t)(fTimestamp[ipoint + 1] - fTimestamp[ipoint]);
158 Float_t t0 = fT0[ipoint] + coeff * (timestamp - fTimestamp[ipoint]);
163 //_________________________________________________________
166 AliTOFRunParams::EvalTOFResolution(UInt_t timestamp)
169 * eval TOF resolution
173 1. no measurement -> 0.
174 2. single measurement -> single value
175 3. timestamp before first measurement -> first value
176 4. timestamp after last measurement -> last value
178 if (fNPoints <= 0 || !fTOFResolution || !fTimestamp) return 0.;
179 if (fNPoints == 1) return fTOFResolution[0];
180 if (timestamp <= fTimestamp[0]) return fTOFResolution[0];
181 if (timestamp >= fTimestamp[fNPoints - 1]) return fTOFResolution[fNPoints - 1];
183 /* interpolate value */
185 for (ipoint = 0; ipoint < fNPoints - 1; ipoint++)
186 if (timestamp >= fTimestamp[ipoint] && timestamp < fTimestamp[ipoint + 1])
188 Float_t coeff = (fTOFResolution[ipoint + 1] - fTOFResolution[ipoint]) / (Float_t)(fTimestamp[ipoint + 1] - fTimestamp[ipoint]);
189 Float_t reso = fTOFResolution[ipoint] + coeff * (timestamp - fTimestamp[ipoint]);
194 //_________________________________________________________
197 AliTOFRunParams::EvalT0Spread(UInt_t timestamp)
204 1. no measurement -> 0.
205 2. single measurement -> single value
206 3. timestamp before first measurement -> first value
207 4. timestamp after last measurement -> last value
209 if (fNPoints <= 0 || !fT0Spread || !fTimestamp) return 0.;
210 if (fNPoints == 1) return fT0Spread[0];
211 if (timestamp <= fTimestamp[0]) return fT0Spread[0];
212 if (timestamp >= fTimestamp[fNPoints - 1]) return fT0Spread[fNPoints - 1];
214 /* interpolate value */
216 for (ipoint = 0; ipoint < fNPoints - 1; ipoint++)
217 if (timestamp >= fTimestamp[ipoint] && timestamp < fTimestamp[ipoint + 1])
219 Float_t coeff = (fT0Spread[ipoint + 1] - fT0Spread[ipoint]) / (Float_t)(fTimestamp[ipoint + 1] - fTimestamp[ipoint]);
220 Float_t spread = fT0Spread[ipoint] + coeff * (timestamp - fTimestamp[ipoint]);