]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDCSSensor.cxx
f4d05acc8bcf36f27dcc78e1fc4f0a70531c0d9e
[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 // Running instructions:
26 /*
27   TClonesArray * arr = AliDCSSensor::ReadList("TempSensor.txt");
28   TFile f("TempSensors.root","RECREATE");
29   TTree * tree = new TTree("TempSensor", "TempSensor");
30   tree->Branch("Temp",&arr);
31   tree->Fill();
32   tree->Write();
33   
34  */
35 //
36
37
38 #include "AliDCSSensor.h"
39 ClassImp(AliDCSSensor)
40
41 const Double_t kSmall = -9e99;     // invalid small value
42 const Double_t kLarge = 9e99;      // invalid large value
43 const Double_t kSecInHour = 3600.; // seconds in one hour
44
45
46
47 AliDCSSensor::AliDCSSensor():
48   fId(),
49   fIdDCS(0),
50   fStartTime(0),
51   fEndTime(0),
52   fGraph(0),
53   fFit(0),
54   fX(0),
55   fY(0),
56   fZ(0)
57 {
58   //
59   //  Standard constructor
60   //
61 }
62
63 AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
64    TNamed(source),
65    fId(source.fId),
66    fIdDCS(source.fIdDCS),
67    fStartTime(source.fStartTime),
68    fEndTime(source.fEndTime),
69    fGraph(source.fGraph),
70    fFit(source.fFit),
71    fX(source.fX),
72    fY(source.fY),
73    fZ(source.fZ)
74 //
75 //  Copy constructor
76 //
77 { }
78
79 AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
80 //
81 // assignment operator
82 //
83   if (&source == this) return *this;
84   new (this) AliDCSSensor(source);
85   
86   return *this;  
87 }
88
89 //_____________________________________________________________________________
90 Double_t AliDCSSensor::GetValue(UInt_t timeSec) 
91 {
92  //
93  // Get temperature value for actual sensor
94  //  timeSec given as offset from start-of-run measured in seconds
95  //
96  Double_t timeHrs = timeSec/kSecInHour;
97  if (fFit) {
98   return  fFit->Eval(timeHrs,0);
99  } else { 
100   return kSmall;
101  }
102 }
103 //_____________________________________________________________________________
104 Double_t AliDCSSensor::GetValue(TTimeStamp time) 
105 {
106  // Get temperature value for actual sensor
107  //  time given as absolute TTimeStamp
108  //
109  Double_t timeHrs = (time.GetSec() - fStartTime)/kSecInHour;
110  if (fFit) {
111   return  fFit->Eval(timeHrs,0);
112  } else { 
113   return kSmall;
114  }
115 }
116
117 //_____________________________________________________________________________
118
119 Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
120 {
121   // 
122   // Return temperature at given time
123   //  If time < start of map  return kSmall
124   //  If time > end of map    return kLarge
125   
126   UInt_t timeSec = time.GetSec();
127   UInt_t diff = timeSec-fStartTime;
128   
129   if ( timeSec < fStartTime ) return kSmall;
130   if ( timeSec > fEndTime ) return kLarge;
131  
132   Double_t timeHour = diff/kSecInHour;
133   if ( fFit ) {
134      return fFit->Eval(timeHour); 
135   } else {
136      return kSmall;
137   }
138 }
139
140 TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
141 {
142   //
143   // Make graph from start time to end time of DCS values 
144   //
145
146   UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
147   
148   if ( !fFit ) return 0;
149
150   Double_t *x = new Double_t[nPoints+1];
151   Double_t *y = new Double_t[nPoints+1];
152   for (Int_t ip=0; ip<nPoints; ip++) {
153     x[ip] = fStartTime+ip*stepTime;
154     y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
155   }
156   
157   TGraph *graph = new TGraph(nPoints,x,y);
158   delete [] x;
159   delete [] y;
160   
161   graph->GetXaxis()->SetTimeDisplay(1);
162   graph->GetXaxis()->SetLabelOffset(0.02);
163   graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
164   
165   return graph;
166 }
167
168