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():
60 // Standard constructor
64 AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) :
67 fIdDCS(source.fIdDCS),
68 fStringID(source.fStringID),
69 fStartTime(source.fStartTime),
70 fEndTime(source.fEndTime),
71 fGraph(source.fGraph),
81 AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){
83 // assignment operator
85 if (&source == this) return *this;
86 new (this) AliDCSSensor(source);
91 //_____________________________________________________________________________
92 Double_t AliDCSSensor::GetValue(UInt_t timeSec)
95 // Get temperature value for actual sensor
96 // timeSec given as offset from start-of-run measured in seconds
98 return Eval(TTimeStamp(fStartTime+timeSec));
100 //_____________________________________________________________________________
101 Double_t AliDCSSensor::GetValue(TTimeStamp time)
103 // Get temperature value for actual sensor
104 // time given as absolute TTimeStamp
109 //_____________________________________________________________________________
111 Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
114 // Return temperature at given time
115 // If time < start of map return kSmall
116 // If time > end of map return kLarge
118 UInt_t timeSec = time.GetSec();
119 UInt_t diff = timeSec-fStartTime;
121 if ( timeSec < fStartTime ) return kSmall;
122 if ( timeSec > fEndTime ) return kLarge;
124 Double_t timeHour = diff/kSecInHour;
126 return fFit->Eval(timeHour);
132 TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
135 // Make graph from start time to end time of DCS values
138 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
140 if ( !fFit ) return 0;
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);
149 TGraph *graph = new TGraph(nPoints,x,y);
153 graph->GetXaxis()->SetTimeDisplay(1);
154 graph->GetXaxis()->SetLabelOffset(0.02);
155 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
160 //_____________________________________________________________________________
162 TClonesArray * AliDCSSensor::ReadTree(TTree* tree) {
164 // read values from ascii file
167 Int_t nentries = tree->GetEntries();
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);
183 // firstSensor = (Int_t)tree->GetMinimum("ECha");
184 // lastSensor = (Int_t)tree->GetMaximum("ECha");
186 TClonesArray * array = new TClonesArray("AliDCSSensor",nentries);
187 printf ("nentries = %d\n",nentries);
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));