]>
Commit | Line | Data |
---|---|---|
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 | ||
7264822f | 25 | #include "AliDCSSensor.h" |
e27404da | 26 | ClassImp(AliDCSSensor) |
8cb8848e | 27 | |
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 | |
31 | ||
7264822f | 32 | |
33 | ||
34 | AliDCSSensor::AliDCSSensor(): | |
35 | fId(), | |
36 | fIdDCS(0), | |
24cd438b | 37 | fStringID(), |
7264822f | 38 | fStartTime(0), |
8cb8848e | 39 | fEndTime(0), |
7264822f | 40 | fGraph(0), |
41 | fFit(0), | |
42 | fX(0), | |
43 | fY(0), | |
44 | fZ(0) | |
45 | { | |
46 | // | |
47 | // Standard constructor | |
48 | // | |
49 | } | |
50 | ||
51 | AliDCSSensor::AliDCSSensor(const AliDCSSensor& source) : | |
52 | TNamed(source), | |
53 | fId(source.fId), | |
54 | fIdDCS(source.fIdDCS), | |
24cd438b | 55 | fStringID(source.fStringID), |
7264822f | 56 | fStartTime(source.fStartTime), |
8cb8848e | 57 | fEndTime(source.fEndTime), |
7264822f | 58 | fGraph(source.fGraph), |
59 | fFit(source.fFit), | |
60 | fX(source.fX), | |
61 | fY(source.fY), | |
62 | fZ(source.fZ) | |
63 | // | |
64 | // Copy constructor | |
65 | // | |
66 | { } | |
67 | ||
68 | AliDCSSensor& AliDCSSensor::operator=(const AliDCSSensor& source){ | |
69 | // | |
70 | // assignment operator | |
71 | // | |
72 | if (&source == this) return *this; | |
73 | new (this) AliDCSSensor(source); | |
dc0184e7 | 74 | |
75 | return *this; | |
7264822f | 76 | } |
77 | ||
78 | //_____________________________________________________________________________ | |
dc0184e7 | 79 | Double_t AliDCSSensor::GetValue(UInt_t timeSec) |
7264822f | 80 | { |
81 | // | |
82 | // Get temperature value for actual sensor | |
83 | // timeSec given as offset from start-of-run measured in seconds | |
84 | // | |
dc0184e7 | 85 | return Eval(TTimeStamp(fStartTime+timeSec)); |
7264822f | 86 | } |
87 | //_____________________________________________________________________________ | |
88 | Double_t AliDCSSensor::GetValue(TTimeStamp time) | |
89 | { | |
90 | // Get temperature value for actual sensor | |
91 | // time given as absolute TTimeStamp | |
92 | // | |
e5250086 | 93 | return Eval(time); |
8cb8848e | 94 | } |
95 | ||
96 | //_____________________________________________________________________________ | |
97 | ||
98 | Double_t AliDCSSensor::Eval(const TTimeStamp& time) const | |
99 | { | |
100 | // | |
101 | // Return temperature at given time | |
102 | // If time < start of map return kSmall | |
103 | // If time > end of map return kLarge | |
104 | ||
105 | UInt_t timeSec = time.GetSec(); | |
106 | UInt_t diff = timeSec-fStartTime; | |
107 | ||
108 | if ( timeSec < fStartTime ) return kSmall; | |
109 | if ( timeSec > fEndTime ) return kLarge; | |
110 | ||
111 | Double_t timeHour = diff/kSecInHour; | |
112 | if ( fFit ) { | |
113 | return fFit->Eval(timeHour); | |
114 | } else { | |
115 | return kSmall; | |
116 | } | |
117 | } | |
118 | ||
119 | TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const | |
120 | { | |
121 | // | |
122 | // Make graph from start time to end time of DCS values | |
123 | // | |
124 | ||
125 | UInt_t stepTime = (fEndTime-fStartTime)/nPoints; | |
126 | ||
127 | if ( !fFit ) return 0; | |
128 | ||
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); | |
134 | } | |
135 | ||
136 | TGraph *graph = new TGraph(nPoints,x,y); | |
137 | delete [] x; | |
138 | delete [] y; | |
139 | ||
140 | graph->GetXaxis()->SetTimeDisplay(1); | |
141 | graph->GetXaxis()->SetLabelOffset(0.02); | |
142 | graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}"); | |
82dfb6c8 | 143 | |
8cb8848e | 144 | return graph; |
7264822f | 145 | } |
146 | ||
24cd438b | 147 | //_____________________________________________________________________________ |
148 | ||
149 | TClonesArray * AliDCSSensor::ReadTree(TTree* tree) { | |
150 | // | |
151 | // read values from ascii file | |
152 | // | |
82dfb6c8 | 153 | |
24cd438b | 154 | Int_t nentries = tree->GetEntries(); |
82dfb6c8 | 155 | |
24cd438b | 156 | char stringId[100]; |
157 | Int_t num=0; | |
158 | Int_t idDCS=0; | |
159 | Double_t x=0; | |
160 | Double_t y=0; | |
161 | Double_t z=0; | |
162 | ||
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); | |
169 | ||
170 | // firstSensor = (Int_t)tree->GetMinimum("ECha"); | |
171 | // lastSensor = (Int_t)tree->GetMaximum("ECha"); | |
172 | ||
173 | TClonesArray * array = new TClonesArray("AliDCSSensor",nentries); | |
174 | printf ("nentries = %d\n",nentries); | |
175 | ||
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)); | |
182 | sens->SetX(x); | |
183 | sens->SetY(y); | |
184 | sens->SetZ(z); | |
185 | ||
186 | } | |
187 | return array; | |
188 | } | |
7264822f | 189 |