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 #include "AliDCSSensor.h"
26 ClassImp(AliDCSSensor)
28 const Double_t kSmall = -9e99; // invalid small value
29 const Double_t kLarge = 9e99; // invalid large value
30 const Double_t kSecInHour = 3600.; // seconds in one hour
34 AliDCSSensor::AliDCSSensor():
47 // Standard constructor
51 AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
54 fIdDCS(source.fIdDCS),
55 fStringID(source.fStringID),
56 fStartTime(source.fStartTime),
57 fEndTime(source.fEndTime),
58 fGraph(source.fGraph),
68 AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
70 // assignment operator
72 if (&source == this) return *this;
73 new (this) AliDCSSensor(source);
78 //_____________________________________________________________________________
79 Double_t AliDCSSensor::GetValue(UInt_t timeSec)
82 // Get temperature value for actual sensor
83 // timeSec given as offset from start-of-run measured in seconds
85 return Eval(TTimeStamp(fStartTime+timeSec));
87 //_____________________________________________________________________________
88 Double_t AliDCSSensor::GetValue(TTimeStamp time)
90 // Get temperature value for actual sensor
91 // time given as absolute TTimeStamp
96 //_____________________________________________________________________________
98 Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
101 // Return temperature at given time
102 // If time < start of map return kSmall
103 // If time > end of map return kLarge
105 UInt_t timeSec = time.GetSec();
106 UInt_t diff = timeSec-fStartTime;
108 if ( timeSec < fStartTime ) return kSmall;
109 if ( timeSec > fEndTime ) return kLarge;
111 Double_t timeHour = diff/kSecInHour;
113 return fFit->Eval(timeHour);
119 TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
122 // Make graph from start time to end time of DCS values
125 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
127 if ( !fFit ) return 0;
129 Double_t *x = new Double_t[nPoints+1];
130 Double_t *y = new Double_t[nPoints+1];
131 for (Int_t ip=0; ip<nPoints; ip++) {
132 x[ip] = fStartTime+ip*stepTime;
133 y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
136 TGraph *graph = new TGraph(nPoints,x,y);
140 graph->GetXaxis()->SetTimeDisplay(1);
141 graph->GetXaxis()->SetLabelOffset(0.02);
142 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
147 //_____________________________________________________________________________
149 TClonesArray * AliDCSSensor::ReadTree(TTree* tree) {
151 // read values from ascii file
154 Int_t nentries = tree->GetEntries();
163 tree->SetBranchAddress("StringID",&stringId);
164 tree->SetBranchAddress("IdDCS",&idDCS);
165 tree->SetBranchAddress("Num",&num);
166 tree->SetBranchAddress("X",&x);
167 tree->SetBranchAddress("Y",&y);
168 tree->SetBranchAddress("Z",&z);
170 // firstSensor = (Int_t)tree->GetMinimum("ECha");
171 // lastSensor = (Int_t)tree->GetMaximum("ECha");
173 TClonesArray * array = new TClonesArray("AliDCSSensor",nentries);
174 printf ("nentries = %d\n",nentries);
176 for (Int_t isensor=0; isensor<nentries; isensor++){
177 AliDCSSensor * sens = new ((*array)[isensor])AliDCSSensor;
178 tree->GetEntry(isensor);
179 sens->SetId(isensor);
180 sens->SetIdDCS(idDCS);
181 sens->SetStringID(TString(stringId));