]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliDCSSensor.cxx
Possibility to fix some of the parameters. New method to get the number of free param...
[u/mrichter/AliRoot.git] / STEER / AliDCSSensor.cxx
CommitLineData
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"
e27404da 26ClassImp(AliDCSSensor)
8cb8848e 27
8cb8848e 28const Double_t kSecInHour = 3600.; // seconds in one hour
29
7264822f 30
31
32AliDCSSensor::AliDCSSensor():
33 fId(),
34 fIdDCS(0),
24cd438b 35 fStringID(),
7264822f 36 fStartTime(0),
8cb8848e 37 fEndTime(0),
7264822f 38 fGraph(0),
39 fFit(0),
40 fX(0),
41 fY(0),
42 fZ(0)
43{
44 //
45 // Standard constructor
46 //
47}
48
49AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
50 TNamed(source),
51 fId(source.fId),
52 fIdDCS(source.fIdDCS),
24cd438b 53 fStringID(source.fStringID),
7264822f 54 fStartTime(source.fStartTime),
8cb8848e 55 fEndTime(source.fEndTime),
7264822f 56 fGraph(source.fGraph),
57 fFit(source.fFit),
58 fX(source.fX),
59 fY(source.fY),
60 fZ(source.fZ)
61//
62// Copy constructor
63//
64{ }
65
66AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
67//
68// assignment operator
69//
70 if (&source == this) return *this;
71 new (this) AliDCSSensor(source);
dc0184e7 72
73 return *this;
7264822f 74}
75
76//_____________________________________________________________________________
dc0184e7 77Double_t AliDCSSensor::GetValue(UInt_t timeSec)
7264822f 78{
79 //
80 // Get temperature value for actual sensor
81 // timeSec given as offset from start-of-run measured in seconds
82 //
2972d4eb 83 Bool_t inside=kTRUE;
008ef66a 84 return Eval(TTimeStamp((time_t)(fStartTime+timeSec),0),inside);
7264822f 85}
86//_____________________________________________________________________________
87Double_t AliDCSSensor::GetValue(TTimeStamp time)
88{
89 // Get temperature value for actual sensor
90 // time given as absolute TTimeStamp
91 //
2972d4eb 92 Bool_t inside=kTRUE;
67a165ed 93 return Eval(time, inside);
8cb8848e 94}
95
96//_____________________________________________________________________________
97
67a165ed 98Double_t AliDCSSensor::Eval(const TTimeStamp& time, Bool_t inside) const
8cb8848e 99{
100 //
101 // Return temperature at given time
67a165ed 102 // If time < start of map return value at start of map, inside = false
103 // If time > end of map return value at end of map, inside = false
8cb8848e 104
105 UInt_t timeSec = time.GetSec();
106 UInt_t diff = timeSec-fStartTime;
67a165ed 107 inside = true;
8cb8848e 108
67a165ed 109 if ( timeSec < fStartTime ) {
110 inside=false;
111 diff=0;
112 }
113 if ( timeSec > fEndTime ) {
114 inside=false;
115 diff = fEndTime-fStartTime;
116 }
8cb8848e 117
118 Double_t timeHour = diff/kSecInHour;
119 if ( fFit ) {
120 return fFit->Eval(timeHour);
121 } else {
e7097603 122 if ( fGraph ) {
123 return EvalGraph(timeHour);
124 } else {
125 return -99;
126 }
8cb8848e 127 }
128}
e7097603 129//_____________________________________________________________________________
130Double_t AliDCSSensor::EvalGraph(const Double_t& timeHour) const
131{
132 //
133 // Extract last value in graph observed before time given by timeHour
134 //
135
136 // return -99 if point specified is before beginning of graph
137 Double_t x=0; Double_t y=0;
138 fGraph->GetPoint(0,x,y);
139 if ( timeHour < x ) return -99;
140
141 // return previous point when first time > timeHour is observed
142
143 Int_t npoints = fGraph->GetN();
144 for (Int_t i=1; i<npoints; i++) {
145 fGraph->GetPoint(i,x,y);
146 if ( timeHour < x ) {
147 fGraph->GetPoint(i-1,x,y);
148 return y;
149 }
150 }
151
152 // return last point if all times are < timeHour
153 return y;
154}
155
8cb8848e 156
e7097603 157//_____________________________________________________________________________
8cb8848e 158TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
159{
160 //
161 // Make graph from start time to end time of DCS values
162 //
163
164 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
165
166 if ( !fFit ) return 0;
167
168 Double_t *x = new Double_t[nPoints+1];
169 Double_t *y = new Double_t[nPoints+1];
170 for (Int_t ip=0; ip<nPoints; ip++) {
171 x[ip] = fStartTime+ip*stepTime;
172 y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
173 }
174
175 TGraph *graph = new TGraph(nPoints,x,y);
176 delete [] x;
177 delete [] y;
178
179 graph->GetXaxis()->SetTimeDisplay(1);
180 graph->GetXaxis()->SetLabelOffset(0.02);
181 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
82dfb6c8 182
8cb8848e 183 return graph;
7264822f 184}
185
24cd438b 186//_____________________________________________________________________________
187
188TClonesArray * AliDCSSensor::ReadTree(TTree* tree) {
189 //
190 // read values from ascii file
191 //
82dfb6c8 192
24cd438b 193 Int_t nentries = tree->GetEntries();
82dfb6c8 194
24cd438b 195 char stringId[100];
196 Int_t num=0;
197 Int_t idDCS=0;
198 Double_t x=0;
199 Double_t y=0;
200 Double_t z=0;
201
202 tree->SetBranchAddress("StringID",&stringId);
203 tree->SetBranchAddress("IdDCS",&idDCS);
204 tree->SetBranchAddress("Num",&num);
205 tree->SetBranchAddress("X",&x);
206 tree->SetBranchAddress("Y",&y);
207 tree->SetBranchAddress("Z",&z);
208
209 // firstSensor = (Int_t)tree->GetMinimum("ECha");
210 // lastSensor = (Int_t)tree->GetMaximum("ECha");
211
212 TClonesArray * array = new TClonesArray("AliDCSSensor",nentries);
213 printf ("nentries = %d\n",nentries);
214
215 for (Int_t isensor=0; isensor<nentries; isensor++){
216 AliDCSSensor * sens = new ((*array)[isensor])AliDCSSensor;
217 tree->GetEntry(isensor);
218 sens->SetId(isensor);
219 sens->SetIdDCS(idDCS);
220 sens->SetStringID(TString(stringId));
221 sens->SetX(x);
222 sens->SetY(y);
223 sens->SetZ(z);
224
225 }
226 return array;
227}
7264822f 228