]>
Commit | Line | Data |
---|---|---|
7264822f | 1 | /************************************************************************** |
2 | * Copyright(c) 2006-07, 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 | ||
17 | //////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // Class describing TPC temperature sensors (including pointers to graphs/fits// | |
20 | // Authors: Marian Ivanov, Haavard Helstrup and Martin Siska // | |
21 | // // | |
22 | //////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | ||
7264822f | 25 | #include "AliDCSSensor.h" |
6ec4e3e3 | 26 | #include "TDatime.h" |
e27404da | 27 | ClassImp(AliDCSSensor) |
8cb8848e | 28 | |
8cb8848e | 29 | const Double_t kSecInHour = 3600.; // seconds in one hour |
30 | ||
7264822f | 31 | |
32 | ||
33 | AliDCSSensor::AliDCSSensor(): | |
34 | fId(), | |
35 | fIdDCS(0), | |
24cd438b | 36 | fStringID(), |
7264822f | 37 | fStartTime(0), |
8cb8848e | 38 | fEndTime(0), |
7264822f | 39 | fGraph(0), |
40 | fFit(0), | |
41 | fX(0), | |
42 | fY(0), | |
43 | fZ(0) | |
44 | { | |
45 | // | |
46 | // Standard constructor | |
47 | // | |
48 | } | |
49 | ||
50 | AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) : | |
51 | TNamed(source), | |
52 | fId(source.fId), | |
53 | fIdDCS(source.fIdDCS), | |
24cd438b | 54 | fStringID(source.fStringID), |
7264822f | 55 | fStartTime(source.fStartTime), |
8cb8848e | 56 | fEndTime(source.fEndTime), |
9663477d | 57 | fGraph(0), |
58 | fFit(0), | |
7264822f | 59 | fX(source.fX), |
60 | fY(source.fY), | |
61 | fZ(source.fZ) | |
62 | // | |
63 | // Copy constructor | |
64 | // | |
9663477d | 65 | { |
66 | if (source.fGraph) fGraph = (TGraph*)source.fGraph->Clone(); | |
67 | if (source.fFit) fFit = (AliSplineFit*)source.fFit->Clone(); | |
68 | } | |
7264822f | 69 | |
70 | AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){ | |
71 | // | |
72 | // assignment operator | |
73 | // | |
74 | if (&source == this) return *this; | |
75 | new (this) AliDCSSensor(source); | |
dc0184e7 | 76 | |
77 | return *this; | |
7264822f | 78 | } |
79 | ||
80 | //_____________________________________________________________________________ | |
dc0184e7 | 81 | Double_t AliDCSSensor::GetValue(UInt_t timeSec) |
7264822f | 82 | { |
83 | // | |
84 | // Get temperature value for actual sensor | |
6ec4e3e3 | 85 | // timeSec given as offset from start-of-map measured in seconds |
86 | // *NOTE* In the current TPC setup, start-of-map is defined as the | |
87 | // first measured point for each sensor. This will be different | |
88 | // for each sensor in the array. If you want to get a value at the | |
89 | // same absolute time, use AliDCSSensor::GetValue(TTimeStamp time) | |
90 | // or AliDCSSensorArray::GetValue (UInt_t timeSec, Int_t sensor) | |
91 | // which measure offsets with respect to the (global) start-of-run | |
7264822f | 92 | // |
2972d4eb | 93 | Bool_t inside=kTRUE; |
008ef66a | 94 | return Eval(TTimeStamp((time_t)(fStartTime+timeSec),0),inside); |
7264822f | 95 | } |
96 | //_____________________________________________________________________________ | |
97 | Double_t AliDCSSensor::GetValue(TTimeStamp time) | |
98 | { | |
99 | // Get temperature value for actual sensor | |
100 | // time given as absolute TTimeStamp | |
101 | // | |
2972d4eb | 102 | Bool_t inside=kTRUE; |
67a165ed | 103 | return Eval(time, inside); |
8cb8848e | 104 | } |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | ||
67a165ed | 108 | Double_t AliDCSSensor::Eval(const TTimeStamp& time, Bool_t inside) const |
8cb8848e | 109 | { |
110 | // | |
111 | // Return temperature at given time | |
67a165ed | 112 | // If time < start of map return value at start of map, inside = false |
113 | // If time > end of map return value at end of map, inside = false | |
8cb8848e | 114 | |
115 | UInt_t timeSec = time.GetSec(); | |
116 | UInt_t diff = timeSec-fStartTime; | |
67a165ed | 117 | inside = true; |
8cb8848e | 118 | |
67a165ed | 119 | if ( timeSec < fStartTime ) { |
120 | inside=false; | |
121 | diff=0; | |
122 | } | |
123 | if ( timeSec > fEndTime ) { | |
124 | inside=false; | |
125 | diff = fEndTime-fStartTime; | |
126 | } | |
8cb8848e | 127 | |
128 | Double_t timeHour = diff/kSecInHour; | |
129 | if ( fFit ) { | |
130 | return fFit->Eval(timeHour); | |
131 | } else { | |
e7097603 | 132 | if ( fGraph ) { |
133 | return EvalGraph(timeHour); | |
134 | } else { | |
135 | return -99; | |
136 | } | |
8cb8848e | 137 | } |
138 | } | |
e7097603 | 139 | //_____________________________________________________________________________ |
140 | Double_t AliDCSSensor::EvalGraph(const Double_t& timeHour) const | |
141 | { | |
142 | // | |
143 | // Extract last value in graph observed before time given by timeHour | |
144 | // | |
145 | ||
146 | // return -99 if point specified is before beginning of graph | |
147 | Double_t x=0; Double_t y=0; | |
148 | fGraph->GetPoint(0,x,y); | |
149 | if ( timeHour < x ) return -99; | |
150 | ||
151 | // return previous point when first time > timeHour is observed | |
152 | ||
153 | Int_t npoints = fGraph->GetN(); | |
154 | for (Int_t i=1; i<npoints; i++) { | |
155 | fGraph->GetPoint(i,x,y); | |
156 | if ( timeHour < x ) { | |
157 | fGraph->GetPoint(i-1,x,y); | |
158 | return y; | |
159 | } | |
160 | } | |
161 | ||
162 | // return last point if all times are < timeHour | |
163 | return y; | |
164 | } | |
165 | ||
8cb8848e | 166 | |
e7097603 | 167 | //_____________________________________________________________________________ |
6ec4e3e3 | 168 | TGraph* AliDCSSensor::MakeGraph(Int_t nPoints, Bool_t debug) const |
8cb8848e | 169 | { |
170 | // | |
171 | // Make graph from start time to end time of DCS values | |
172 | // | |
173 | ||
6ec4e3e3 | 174 | |
175 | ||
8cb8848e | 176 | UInt_t stepTime = (fEndTime-fStartTime)/nPoints; |
177 | ||
6ec4e3e3 | 178 | if (debug==kTRUE) { |
179 | printf ("Start time %d, End time %d, step time %d\n", | |
180 | fStartTime,fEndTime,stepTime); | |
181 | TTimeStamp t((time_t)fStartTime,0); t.Print(); | |
182 | TTimeStamp t2((time_t)fEndTime,0); t2.Print(); | |
183 | } | |
184 | ||
8cb8848e | 185 | if ( !fFit ) return 0; |
186 | ||
187 | Double_t *x = new Double_t[nPoints+1]; | |
188 | Double_t *y = new Double_t[nPoints+1]; | |
189 | for (Int_t ip=0; ip<nPoints; ip++) { | |
6ec4e3e3 | 190 | x[ip] = (time_t)(fStartTime+ip*stepTime); |
8cb8848e | 191 | y[ip] = fFit->Eval(ip*stepTime/kSecInHour); |
6ec4e3e3 | 192 | if (debug==kTRUE) { |
193 | TTimeStamp t3((time_t)x[ip],0); | |
194 | printf ("x=%f, y=%f ",x[ip],y[ip]); | |
195 | t3.Print(); | |
196 | } | |
8cb8848e | 197 | } |
198 | ||
199 | TGraph *graph = new TGraph(nPoints,x,y); | |
200 | delete [] x; | |
201 | delete [] y; | |
202 | ||
203 | graph->GetXaxis()->SetTimeDisplay(1); | |
204 | graph->GetXaxis()->SetLabelOffset(0.02); | |
205 | graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}"); | |
82dfb6c8 | 206 | |
8cb8848e | 207 | return graph; |
7264822f | 208 | } |
209 | ||
24cd438b | 210 | //_____________________________________________________________________________ |
211 | ||
212 | TClonesArray * AliDCSSensor::ReadTree(TTree* tree) { | |
213 | // | |
214 | // read values from ascii file | |
215 | // | |
82dfb6c8 | 216 | |
24cd438b | 217 | Int_t nentries = tree->GetEntries(); |
82dfb6c8 | 218 | |
24cd438b | 219 | char stringId[100]; |
220 | Int_t num=0; | |
221 | Int_t idDCS=0; | |
222 | Double_t x=0; | |
223 | Double_t y=0; | |
224 | Double_t z=0; | |
225 | ||
226 | tree->SetBranchAddress("StringID",&stringId); | |
227 | tree->SetBranchAddress("IdDCS",&idDCS); | |
228 | tree->SetBranchAddress("Num",&num); | |
229 | tree->SetBranchAddress("X",&x); | |
230 | tree->SetBranchAddress("Y",&y); | |
231 | tree->SetBranchAddress("Z",&z); | |
232 | ||
233 | // firstSensor = (Int_t)tree->GetMinimum("ECha"); | |
234 | // lastSensor = (Int_t)tree->GetMaximum("ECha"); | |
235 | ||
236 | TClonesArray * array = new TClonesArray("AliDCSSensor",nentries); | |
237 | printf ("nentries = %d\n",nentries); | |
238 | ||
239 | for (Int_t isensor=0; isensor<nentries; isensor++){ | |
240 | AliDCSSensor * sens = new ((*array)[isensor])AliDCSSensor; | |
241 | tree->GetEntry(isensor); | |
242 | sens->SetId(isensor); | |
243 | sens->SetIdDCS(idDCS); | |
244 | sens->SetStringID(TString(stringId)); | |
245 | sens->SetX(x); | |
246 | sens->SetY(y); | |
247 | sens->SetZ(z); | |
248 | ||
249 | } | |
250 | return array; | |
251 | } | |
7264822f | 252 |