]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCCalibVdrift.cxx
calibration updates (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibVdrift.cxx
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
32 ClassImp(AliTPCCalibVdrift)
33
34 namespace paramDefinitions {
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
58 using namespace paramDefinitions;
59
60 AliTPCCalibVdrift::AliTPCCalibVdrift(AliTPCSensorTempArray *SensTemp, AliDCSSensor *SensPres, TObject *SensGasComp):
61   TNamed(),
62   fSensTemp(0),
63   fSensPres(0),
64   fTempMap(0),
65   fSensGasComp(0)
66 {
67   //
68   //  Standard constructor
69   //
70
71   fSensTemp = SensTemp;
72   fSensPres = SensPres;
73   fTempMap  = new AliTPCTempMap(fSensTemp);
74   fSensGasComp = SensGasComp;
75 }
76
77 AliTPCCalibVdrift::AliTPCCalibVdrift(const AliTPCCalibVdrift& source) :
78   TNamed(source),
79   fSensTemp(source.fSensTemp),
80   fSensPres(source.fSensPres),
81   fTempMap(source.fTempMap),
82   fSensGasComp(source.fSensGasComp)
83 {
84   //
85   //  Copy constructor
86   //
87 }
88
89 //_____________________________________________________________________________
90
91 AliTPCCalibVdrift& 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 //_____________________________________________________________________________
102 AliTPCCalibVdrift::~AliTPCCalibVdrift()
103 {
104   //
105   // AliTPCCalibVdrift destructor
106   // 
107
108 }
109
110 Double_t AliTPCCalibVdrift::GetPTRelative(UInt_t timeSec, Int_t side){
111   //
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;
130 }
131
132
133 //_____________________________________________________________________________
134 Double_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
141   Double_t vdrift = (dE*kdvdE+dT*kdvdT+dP*kdvdP+dCco2*kdvdCco2+dCn2*kdvdCn2);
142   
143   return vdrift; 
144
145 }
146 //_____________________________________________________________________________
147
148 Double_t AliTPCCalibVdrift::GetVdriftNominal() 
149 {
150   // returns nominal Driftvelocity at StandardConditions
151   return kstdVdrift;
152 }
153
154 //_____________________________________________________________________________
155
156 Double_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 ----------------------  
167   AliTPCTempMap *tempMap = fTempMap;
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);  
175   Double_t p0 = 744;
176   // recalculate Pressure according to height in TPC and transform to
177   // TORR (with simplified hydrostatic formula)   
178   Double_t dP = p0 - krho*kg*y/10000 /1000*760 - kstdP;
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   
189   return vdrift;    
190 }
191
192 //_____________________________________________________________________________
193
194 Double_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  
204   Double_t vdriftSum = 0;
205
206   for (Int_t i = 0; i<nPoints; i++) {
207     Double_t z = (Double_t)i/(nPoints-1)*500-250;
208     vdriftSum = vdriftSum + GetVdriftChange(x, y, z, timeSec);
209   }
210   
211   Double_t meanZVdrift = vdriftSum/nPoints;
212
213   return meanZVdrift;
214
215 }
216
217 //_____________________________________________________________________________
218
219 TGraph *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
226   UInt_t startTime = fSensTemp->GetStartTime();
227   UInt_t endTime = fSensTemp->GetEndTime();
228   
229   UInt_t stepTime = (endTime - startTime)/nPoints;
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++) {
236     xvec[ip] = startTime+ip*stepTime;
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 }