]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDCSSensor.cxx
Possibility to convolute the original cov.matrix of the point with the matrix coming...
[u/mrichter/AliRoot.git] / STEER / AliDCSSensor.cxx
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
25 #include "AliDCSSensor.h"
26 ClassImp(AliDCSSensor)
27
28 const Double_t kSecInHour = 3600.; // seconds in one hour
29
30
31
32 AliDCSSensor::AliDCSSensor():
33   fId(),
34   fIdDCS(0),
35   fStringID(),
36   fStartTime(0),
37   fEndTime(0),
38   fGraph(0),
39   fFit(0),
40   fX(0),
41   fY(0),
42   fZ(0)
43 {
44   //
45   //  Standard constructor
46   //
47 }
48
49 AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
50    TNamed(source),
51    fId(source.fId),
52    fIdDCS(source.fIdDCS),
53    fStringID(source.fStringID),
54    fStartTime(source.fStartTime),
55    fEndTime(source.fEndTime),
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
66 AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
67 //
68 // assignment operator
69 //
70   if (&source == this) return *this;
71   new (this) AliDCSSensor(source);
72
73   return *this;
74 }
75
76 //_____________________________________________________________________________
77 Double_t AliDCSSensor::GetValue(UInt_t timeSec)
78 {
79  //
80  // Get temperature value for actual sensor
81  //  timeSec given as offset from start-of-run measured in seconds
82  //
83  Bool_t inside;
84  return Eval(TTimeStamp(fStartTime+timeSec),inside);
85 }
86 //_____________________________________________________________________________
87 Double_t AliDCSSensor::GetValue(TTimeStamp time) 
88 {
89  // Get temperature value for actual sensor
90  //  time given as absolute TTimeStamp
91  //
92  Bool_t inside;
93  return Eval(time, inside);
94 }
95
96 //_____________________________________________________________________________
97
98 Double_t AliDCSSensor::Eval(const TTimeStamp& time, Bool_t inside) const
99 {
100   // 
101   // Return temperature at given time
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
104   
105   UInt_t timeSec = time.GetSec();
106   UInt_t diff = timeSec-fStartTime;
107   inside = true;
108   
109   if ( timeSec < fStartTime ) { 
110      inside=false;
111      diff=0;
112   }
113   if ( timeSec > fEndTime ) {
114      inside=false;
115      diff = fEndTime-fStartTime;
116   }
117  
118   Double_t timeHour = diff/kSecInHour;
119   if ( fFit ) {
120      return fFit->Eval(timeHour); 
121   } else {
122      return -99;
123   }
124 }
125
126 TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
127 {
128   //
129   // Make graph from start time to end time of DCS values 
130   //
131
132   UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
133   
134   if ( !fFit ) return 0;
135
136   Double_t *x = new Double_t[nPoints+1];
137   Double_t *y = new Double_t[nPoints+1];
138   for (Int_t ip=0; ip<nPoints; ip++) {
139     x[ip] = fStartTime+ip*stepTime;
140     y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
141   }
142   
143   TGraph *graph = new TGraph(nPoints,x,y);
144   delete [] x;
145   delete [] y;
146   
147   graph->GetXaxis()->SetTimeDisplay(1);
148   graph->GetXaxis()->SetLabelOffset(0.02);
149   graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
150
151   return graph;
152 }
153
154 //_____________________________________________________________________________
155
156 TClonesArray * AliDCSSensor::ReadTree(TTree* tree) {
157   //
158   // read values from ascii file
159   //
160
161   Int_t nentries = tree->GetEntries();
162
163   char stringId[100];
164   Int_t num=0;
165   Int_t idDCS=0;
166   Double_t x=0;
167   Double_t y=0;
168   Double_t z=0;
169
170   tree->SetBranchAddress("StringID",&stringId);
171   tree->SetBranchAddress("IdDCS",&idDCS);
172   tree->SetBranchAddress("Num",&num);
173   tree->SetBranchAddress("X",&x);
174   tree->SetBranchAddress("Y",&y);
175   tree->SetBranchAddress("Z",&z);
176
177   // firstSensor = (Int_t)tree->GetMinimum("ECha");
178   // lastSensor = (Int_t)tree->GetMaximum("ECha");
179
180   TClonesArray * array = new TClonesArray("AliDCSSensor",nentries);
181    printf ("nentries = %d\n",nentries);
182
183   for (Int_t isensor=0; isensor<nentries; isensor++){
184     AliDCSSensor * sens = new ((*array)[isensor])AliDCSSensor;
185     tree->GetEntry(isensor);
186     sens->SetId(isensor);
187     sens->SetIdDCS(idDCS);
188     sens->SetStringID(TString(stringId));
189     sens->SetX(x);
190     sens->SetY(y);
191     sens->SetZ(z);
192
193   }
194   return array;
195 }
196