Removing obsolete classes (Haavard)
[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
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"
e27404da 39ClassImp(AliDCSSensor)
8cb8848e 40
41const Double_t kSmall = -9e99; // invalid small value
42const Double_t kLarge = 9e99; // invalid large value
43const Double_t kSecInHour = 3600.; // seconds in one hour
44
7264822f 45
46
47AliDCSSensor::AliDCSSensor():
48 fId(),
49 fIdDCS(0),
50 fStartTime(0),
8cb8848e 51 fEndTime(0),
7264822f 52 fGraph(0),
53 fFit(0),
54 fX(0),
55 fY(0),
56 fZ(0)
57{
58 //
59 // Standard constructor
60 //
61}
62
63AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
64 TNamed(source),
65 fId(source.fId),
66 fIdDCS(source.fIdDCS),
67 fStartTime(source.fStartTime),
8cb8848e 68 fEndTime(source.fEndTime),
7264822f 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
79AliDCSSensor& 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//_____________________________________________________________________________
90Double_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 //
e5250086 96 return Eval(TTimeStamp(timeSec));
7264822f 97}
98//_____________________________________________________________________________
99Double_t AliDCSSensor::GetValue(TTimeStamp time)
100{
101 // Get temperature value for actual sensor
102 // time given as absolute TTimeStamp
103 //
e5250086 104 return Eval(time);
8cb8848e 105}
106
107//_____________________________________________________________________________
108
109Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
110{
111 //
112 // Return temperature at given time
113 // If time < start of map return kSmall
114 // If time > end of map return kLarge
115
116 UInt_t timeSec = time.GetSec();
117 UInt_t diff = timeSec-fStartTime;
118
119 if ( timeSec < fStartTime ) return kSmall;
120 if ( timeSec > fEndTime ) return kLarge;
121
122 Double_t timeHour = diff/kSecInHour;
123 if ( fFit ) {
124 return fFit->Eval(timeHour);
125 } else {
126 return kSmall;
127 }
128}
129
130TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
131{
132 //
133 // Make graph from start time to end time of DCS values
134 //
135
136 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
137
138 if ( !fFit ) return 0;
139
140 Double_t *x = new Double_t[nPoints+1];
141 Double_t *y = new Double_t[nPoints+1];
142 for (Int_t ip=0; ip<nPoints; ip++) {
143 x[ip] = fStartTime+ip*stepTime;
144 y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
145 }
146
147 TGraph *graph = new TGraph(nPoints,x,y);
148 delete [] x;
149 delete [] y;
150
151 graph->GetXaxis()->SetTimeDisplay(1);
152 graph->GetXaxis()->SetLabelOffset(0.02);
153 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
154
155 return graph;
7264822f 156}
157
158