]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliDCSSensor.cxx
Replacing obsolete classes
[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),
24cd438b 50 fStringID(),
7264822f 51 fStartTime(0),
8cb8848e 52 fEndTime(0),
7264822f 53 fGraph(0),
54 fFit(0),
55 fX(0),
56 fY(0),
57 fZ(0)
58{
59 //
60 // Standard constructor
61 //
62}
63
64AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
65 TNamed(source),
66 fId(source.fId),
67 fIdDCS(source.fIdDCS),
24cd438b 68 fStringID(source.fStringID),
7264822f 69 fStartTime(source.fStartTime),
8cb8848e 70 fEndTime(source.fEndTime),
7264822f 71 fGraph(source.fGraph),
72 fFit(source.fFit),
73 fX(source.fX),
74 fY(source.fY),
75 fZ(source.fZ)
76//
77// Copy constructor
78//
79{ }
80
81AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
82//
83// assignment operator
84//
85 if (&source == this) return *this;
86 new (this) AliDCSSensor(source);
dc0184e7 87
88 return *this;
7264822f 89}
90
91//_____________________________________________________________________________
dc0184e7 92Double_t AliDCSSensor::GetValue(UInt_t timeSec)
7264822f 93{
94 //
95 // Get temperature value for actual sensor
96 // timeSec given as offset from start-of-run measured in seconds
97 //
dc0184e7 98 return Eval(TTimeStamp(fStartTime+timeSec));
7264822f 99}
100//_____________________________________________________________________________
101Double_t AliDCSSensor::GetValue(TTimeStamp time)
102{
103 // Get temperature value for actual sensor
104 // time given as absolute TTimeStamp
105 //
e5250086 106 return Eval(time);
8cb8848e 107}
108
109//_____________________________________________________________________________
110
111Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
112{
113 //
114 // Return temperature at given time
115 // If time < start of map return kSmall
116 // If time > end of map return kLarge
117
118 UInt_t timeSec = time.GetSec();
119 UInt_t diff = timeSec-fStartTime;
120
121 if ( timeSec < fStartTime ) return kSmall;
122 if ( timeSec > fEndTime ) return kLarge;
123
124 Double_t timeHour = diff/kSecInHour;
125 if ( fFit ) {
126 return fFit->Eval(timeHour);
127 } else {
128 return kSmall;
129 }
130}
131
132TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
133{
134 //
135 // Make graph from start time to end time of DCS values
136 //
137
138 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
139
140 if ( !fFit ) return 0;
141
142 Double_t *x = new Double_t[nPoints+1];
143 Double_t *y = new Double_t[nPoints+1];
144 for (Int_t ip=0; ip<nPoints; ip++) {
145 x[ip] = fStartTime+ip*stepTime;
146 y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
147 }
148
149 TGraph *graph = new TGraph(nPoints,x,y);
150 delete [] x;
151 delete [] y;
152
153 graph->GetXaxis()->SetTimeDisplay(1);
154 graph->GetXaxis()->SetLabelOffset(0.02);
155 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
156
157 return graph;
7264822f 158}
159
24cd438b 160//_____________________________________________________________________________
161
162TClonesArray * AliDCSSensor::ReadTree(TTree* tree) {
163 //
164 // read values from ascii file
165 //
166
167 Int_t nentries = tree->GetEntries();
168
169 char stringId[100];
170 Int_t num=0;
171 Int_t idDCS=0;
172 Double_t x=0;
173 Double_t y=0;
174 Double_t z=0;
175
176 tree->SetBranchAddress("StringID",&stringId);
177 tree->SetBranchAddress("IdDCS",&idDCS);
178 tree->SetBranchAddress("Num",&num);
179 tree->SetBranchAddress("X",&x);
180 tree->SetBranchAddress("Y",&y);
181 tree->SetBranchAddress("Z",&z);
182
183 // firstSensor = (Int_t)tree->GetMinimum("ECha");
184 // lastSensor = (Int_t)tree->GetMaximum("ECha");
185
186 TClonesArray * array = new TClonesArray("AliDCSSensor",nentries);
187 printf ("nentries = %d\n",nentries);
188
189 for (Int_t isensor=0; isensor<nentries; isensor++){
190 AliDCSSensor * sens = new ((*array)[isensor])AliDCSSensor;
191 tree->GetEntry(isensor);
192 sens->SetId(isensor);
193 sens->SetIdDCS(idDCS);
194 sens->SetStringID(TString(stringId));
195 sens->SetX(x);
196 sens->SetY(y);
197 sens->SetZ(z);
198
199 }
200 return array;
201}
7264822f 202