]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCCalibVdrift.cxx
Remove () around exceptions thrown from interpreted code as CINT flops on those.
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibVdrift.cxx
CommitLineData
1209231c 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 the Vdrift dependencies on E,T,P and GasComposition //
20// Authors: Stefan Rossegger, Haavard Helstrup //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24#include "TSystem.h"
25#include "TObject.h"
26#include "TMath.h"
27#include "AliTPCTempMap.h"
28#include "AliTPCSensorTempArray.h"
29
30#include "AliTPCCalibVdrift.h"
31
32ClassImp(AliTPCCalibVdrift)
33
da6c0bc9 34namespace paramDefinitions {
1209231c 35
36 // Standard Conditions used as origin in the Magbolz simulations
37 // Dimesions E [kV/cm], T [K], P [TORR], Cco2 [%], Cn2 [%]
38 const Double_t kstdE = 400;
39 const Double_t kstdT = 293;
40 const Double_t kstdP = 744;
41 const Double_t kstdCco2 = 9.52;
42 const Double_t kstdCn2 = 4.76;
43 // Driftvelocity at Standardcontitions [cm/microSec]
44 const Double_t kstdVdrift = 2.57563;
45
46 // Vdrift dependencies simulated with Magbolz [%(Vdrift)/[unit]]
47 const Double_t kdvdE = 0.24;
48 const Double_t kdvdT = 0.30;
49 const Double_t kdvdP = -0.13;
50 const Double_t kdvdCco2 = -6.60;
51 const Double_t kdvdCn2 = -1.74;
52
53 Double_t krho = 0.934246; // density of TPC-Gas [kg/m^3]
54 // method of calculation: weighted average
55 Double_t kg = 9.81;
56}
57
58using namespace paramDefinitions;
59
da6c0bc9 60AliTPCCalibVdrift::AliTPCCalibVdrift(AliTPCSensorTempArray *SensTemp, AliDCSSensor *SensPres, TObject *SensGasComp):
1209231c 61 TNamed(),
62 fSensTemp(0),
63 fSensPres(0),
da6c0bc9 64 fTempMap(0),
1209231c 65 fSensGasComp(0)
66{
67 //
68 // Standard constructor
69 //
70
71 fSensTemp = SensTemp;
72 fSensPres = SensPres;
da6c0bc9 73 fTempMap = new AliTPCTempMap(fSensTemp);
1209231c 74 fSensGasComp = SensGasComp;
75}
76
77AliTPCCalibVdrift::AliTPCCalibVdrift(const AliTPCCalibVdrift& source) :
78 TNamed(source),
79 fSensTemp(source.fSensTemp),
80 fSensPres(source.fSensPres),
da6c0bc9 81 fTempMap(source.fTempMap),
1209231c 82 fSensGasComp(source.fSensGasComp)
83{
84 //
85 // Copy constructor
86 //
87}
88
89//_____________________________________________________________________________
90
91AliTPCCalibVdrift& AliTPCCalibVdrift::operator=(const AliTPCCalibVdrift& source){
92 //
93 // assignment operator
94 //
95 if (&source == this) return *this;
96 new (this) AliTPCCalibVdrift(source);
97
98 return *this;
99}
100
101//_____________________________________________________________________________
102AliTPCCalibVdrift::~AliTPCCalibVdrift()
103{
104 //
105 // AliTPCCalibVdrift destructor
da6c0bc9 106 //
107
108}
109
110Double_t AliTPCCalibVdrift::GetPTRelative(UInt_t timeSec, Int_t side){
1209231c 111 //
da6c0bc9 112 // Get Relative difference of p/T for given time stamp
113 // timeSec - absolute time
114 // side - 0 - A side 1 -C side
115 //
116 TTimeStamp tstamp(timeSec);
117 if (!fSensPres) return 0;
118 Double_t pressure = fSensPres->GetValue(tstamp);
119 TLinearFitter * fitter = fTempMap->GetLinearFitter(3,side,tstamp);
120 if (!fitter) return 0;
121 TVectorD vec;
122 fitter->GetParameters(vec);
123 delete fitter;
124 if (vec[0]<10) return 0;
125 Double_t temperature = vec[0]+273.15;
126 Double_t povertMeas = pressure/temperature;
127 const Double_t torrTokPascal = 0.75006;
128 Double_t povertNom = kstdP/(torrTokPascal*kstdT);
129 return povertMeas/povertNom;
1209231c 130}
131
da6c0bc9 132
1209231c 133//_____________________________________________________________________________
134Double_t AliTPCCalibVdrift::VdriftLinearHyperplaneApprox(Double_t dE, Double_t dT, Double_t dP, Double_t dCco2, Double_t dCn2)
135{
136 //
137 // Returns approximated value for the driftvelocity based on
138 // linear Hyperplane approximation (~ Taylorapproximation of 1st order)
139 //
140
2aaa30ef 141 Double_t vdrift = (dE*kdvdE+dT*kdvdT+dP*kdvdP+dCco2*kdvdCco2+dCn2*kdvdCn2);
1209231c 142
2aaa30ef 143 return vdrift;
1209231c 144
145}
146//_____________________________________________________________________________
147
148Double_t AliTPCCalibVdrift::GetVdriftNominal()
149{
150 // returns nominal Driftvelocity at StandardConditions
151 return kstdVdrift;
152}
153
154//_____________________________________________________________________________
155
156Double_t AliTPCCalibVdrift::GetVdriftChange(Double_t x, Double_t y, Double_t z, UInt_t timeSec)
157{
158 //
159 // Calculates Vdrift change in percent of Vdrift_nominal
160 // (under nominal conditions) at x,y,z,timeSec
161 //
162
163 // Get E-field Value --------------------------
164 Double_t dE = 0; //FIXME: eventually include Field-Inhomogenities
165
166 // Get Temperature Value ----------------------
da6c0bc9 167 AliTPCTempMap *tempMap = fTempMap;
1209231c 168 Double_t tempValue = tempMap->GetTemperature(x, y, z, timeSec);
169 Double_t dT = tempValue+273.15 - kstdT;
170
171 // Get Main Pressure Value ---------------------
172 // FIXME: READ REAL PRESSURE SENSOR
173 // through TObject *fSensPres;
174 // e.g. Double_t PO = fSensPres->GetValue(timeSec);
2aaa30ef 175 Double_t p0 = 744;
1209231c 176 // recalculate Pressure according to height in TPC and transform to
177 // TORR (with simplified hydrostatic formula)
2aaa30ef 178 Double_t dP = p0 - krho*kg*y/10000 /1000*760 - kstdP;
1209231c 179
180 // Get GasComposition
181 // FIXME: include Goofy values for CO2 and N2 conzentration out of DCS?
182 // through TObject *fSensGasComp and calculate difference to stdCondit.
183 Double_t dCco2 = 0;
184 Double_t dCn2 = 0;
185
186 // Calculate change in drift velocity in terms of Vdrift_nominal
187 Double_t vdrift = VdriftLinearHyperplaneApprox(dE, dT, dP, dCco2, dCn2);
188
da6c0bc9 189 return vdrift;
1209231c 190}
191
192//_____________________________________________________________________________
193
194Double_t AliTPCCalibVdrift::GetMeanZVdriftChange(Double_t x, Double_t y, UInt_t timeSec)
195{
196 //
197 // Calculates Meanvalue in z direction of Vdrift change in percent
198 // of Vdrift_nominal (under standard conditions) at position x,y,timeSec
199 // with help of 'nPopints' base points
200 //
201
202 Int_t nPoints = 5;
203
2aaa30ef 204 Double_t vdriftSum = 0;
1209231c 205
206 for (Int_t i = 0; i<nPoints; i++) {
207 Double_t z = (Double_t)i/(nPoints-1)*500-250;
2aaa30ef 208 vdriftSum = vdriftSum + GetVdriftChange(x, y, z, timeSec);
1209231c 209 }
210
2aaa30ef 211 Double_t meanZVdrift = vdriftSum/nPoints;
1209231c 212
2aaa30ef 213 return meanZVdrift;
1209231c 214
215}
216
217//_____________________________________________________________________________
218
219TGraph *AliTPCCalibVdrift::MakeGraphMeanZVdriftChange(Double_t x, Double_t y, Int_t nPoints)
220{
221 //
222 // Make graph from start time to end time of Mean Drift Velocity in
223 // Z direction at given x and y position
224 //
225
2aaa30ef 226 UInt_t startTime = fSensTemp->GetStartTime();
227 UInt_t endTime = fSensTemp->GetEndTime();
1209231c 228
2aaa30ef 229 UInt_t stepTime = (endTime - startTime)/nPoints;
1209231c 230
231
232 Double_t *xvec = new Double_t[nPoints];
233 Double_t *yvec = new Double_t[nPoints];
234
235 for (Int_t ip=0; ip<nPoints; ip++) {
2aaa30ef 236 xvec[ip] = startTime+ip*stepTime;
1209231c 237 yvec[ip] = GetMeanZVdriftChange(x, y, ip*stepTime);
238 }
239
240 TGraph *graph = new TGraph(nPoints,xvec,yvec);
241
242 delete [] xvec;
243 delete [] yvec;
244
245 graph->GetXaxis()->SetTimeDisplay(1);
246 graph->GetXaxis()->SetLabelOffset(0.02);
247 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
248
249 return graph;
250}