1 /**************************************************************************
2 * Copyright(c) 2006-07, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////////////
19 // Class describing TPC temperature sensors (including pointers to graphs/fits//
20 // Authors: Marian Ivanov, Haavard Helstrup and Martin Siska //
22 ////////////////////////////////////////////////////////////////////////////////
25 // Running instructions:
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);
38 #include "AliDCSSensor.h"
39 ClassImp(AliDCSSensor)
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
47 AliDCSSensor::AliDCSSensor():
59 // Standard constructor
63 AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
66 fIdDCS(source.fIdDCS),
67 fStartTime(source.fStartTime),
68 fEndTime(source.fEndTime),
69 fGraph(source.fGraph),
79 AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
81 // assignment operator
83 if (&source == this) return *this;
84 new (this) AliDCSSensor(source);
89 //_____________________________________________________________________________
90 Double_t AliDCSSensor::GetValue(UInt_t timeSec)
93 // Get temperature value for actual sensor
94 // timeSec given as offset from start-of-run measured in seconds
96 Double_t timeHrs = timeSec/kSecInHour;
98 return fFit->Eval(timeHrs,0);
103 //_____________________________________________________________________________
104 Double_t AliDCSSensor::GetValue(TTimeStamp time)
106 // Get temperature value for actual sensor
107 // time given as absolute TTimeStamp
109 Double_t timeHrs = (time.GetSec() - fStartTime)/kSecInHour;
111 return fFit->Eval(timeHrs,0);
117 //_____________________________________________________________________________
119 Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
122 // Return temperature at given time
123 // If time < start of map return kSmall
124 // If time > end of map return kLarge
126 UInt_t timeSec = time.GetSec();
127 UInt_t diff = timeSec-fStartTime;
129 if ( timeSec < fStartTime ) return kSmall;
130 if ( timeSec > fEndTime ) return kLarge;
132 Double_t timeHour = diff/kSecInHour;
134 return fFit->Eval(timeHour);
140 TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
143 // Make graph from start time to end time of DCS values
146 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
148 if ( !fFit ) return 0;
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);
157 TGraph *graph = new TGraph(nPoints,x,y);
161 graph->GetXaxis()->SetTimeDisplay(1);
162 graph->GetXaxis()->SetLabelOffset(0.02);
163 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");