AliRoot Core  3dc7879 (3dc7879)
AliTPCTempMap.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 
25 
26 #include "AliTPCSensorTempArray.h"
27 #include "TLinearFitter.h"
28 #include "TString.h"
29 #include "TGraph2D.h"
30 #include "TTimeStamp.h"
31 
32 #include "AliTPCTempMap.h"
33 
34 
36 ClassImp(AliTPCTempMap)
38 
39  const char kStringFEsimulation[] = "FEsimulation.txt";
40 
41 //_____________________________________________________________________________
43  TNamed(),
44  fTempArray(0),
45  fStringFEsimulation(kStringFEsimulation)
46 {
48 
49  fTempArray = sensorDCS;
50 
51 }
52 
53 //_____________________________________________________________________________
55  TNamed(c),
56  fTempArray(c.fTempArray),
57  fStringFEsimulation(c.fStringFEsimulation)
58 {
60 
61 }
62 
63 //_____________________________________________________________________________
65 {
67 
68 }
69 
70 //_____________________________________________________________________________
72 {
74 
75  if (this != &c) ((AliTPCTempMap &) c).Copy(*this);
76  return *this;
77 
78 }
79 
80 //_____________________________________________________________________________
81 void AliTPCTempMap::Copy(TObject &c) const
82 {
84 
85  TObject::Copy(c);
86 
87 }
88 
89 //_____________________________________________________________________________
90 
91 Double_t AliTPCTempMap::GetTempGradientY(UInt_t timeSec, Int_t side){
100 
101  TLinearFitter *fitter = new TLinearFitter(3,"x0++x1++x2");
102  TVectorD param(3);
103  Int_t i = 0;
104 
105  Int_t nsensors = fTempArray->NumSensors();
106  for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
108 
109  if (entry->GetType()==3 && entry->GetSide()==side) { // take SensorType:TPC
110  Double_t x[3];
111  x[0]=1;
112  x[1]=entry->GetX();
113  x[2]=entry->GetY();
114  Double_t y = fTempArray->GetValue(timeSec,isensor); // get temperature value
115  if (IsOK(y)) fitter->AddPoint(x,y,1); // add values to LinearFitter
116  i++;
117  }
118 
119  }
120  fitter->Eval();
121  fitter->GetParameters(param);
122 
123  fitter->~TLinearFitter();
124 
125  return param[2]; // return vertical (Y) tempGradient in [K/cm]
126 
127 }
128 
129 //_____________________________________________________________________________
130 TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, TTimeStamp &stamp)
131 {
134 
135  Int_t timeSec = stamp.GetSec()-fTempArray->GetStartTime().GetSec();
136  return GetLinearFitter(type,side,timeSec);
137 }
138 
139 //_____________________________________________________________________________
140 TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec)
141 {
154 
155  TLinearFitter *fitter = new TLinearFitter(3);
156  Double_t x[3]={0};
157  Double_t y = 0;
158  const Float_t kMaxDelta=0.5;
159 
160  if (type == 1 || type == 2 || type == 4) {
161  fitter->SetFormula("x0++x1++TMath::Sin(x2)"); // returns Z,Y gradient
162  } else {
163  fitter->SetFormula("x0++x1++x2"); // returns X,Y gradient
164  }
165 
166  Int_t i = 0;
167  Int_t nsensors = fTempArray->NumSensors();
168 
169  Float_t temps[1000];
170  for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
172  if (entry->GetType()==type && entry->GetSide()==side){
173  Float_t temperature= fTempArray->GetValue(timeSec,isensor); // get temperature value
174  if (IsOK(temperature)) {temps[i]=temperature; i++;}
175  }
176  }
177  Float_t medianTemp = TMath::Median(i, temps);
178  if (i<3) return 0;
179  Float_t rmsTemp = TMath::RMS(i, temps);
180 
181  i=0;
182 
183  for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
185 
186  if (type==0 || type==3) { // 'side' information used
187  if (entry->GetType()==type && entry->GetSide()==side) {
188  x[0]=1;
189  x[1]=entry->GetX();
190  x[2]=entry->GetY();
191  y = fTempArray->GetValue(timeSec,isensor); // get temperature value
192  if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
193  if (IsOK(y)) fitter->AddPoint(x,y,1); // add values to LinearFitter
194  i++;
195  }
196  } else if (type==2) { // in case of IFC also usage of TS values
197  if ((entry->GetType()==2) || (entry->GetType()==5)) {
198  x[0]=1;
199  x[1]=entry->GetZ();
200  x[2]=entry->GetPhi();
201  y = fTempArray->GetValue(timeSec,isensor);
202  if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
203  if (IsOK(y)) fitter->AddPoint(x,y,1);
204  i++;
205  }
206  } else if (type==1){
207  if (entry->GetType()==type) {
208  x[0]=1;
209  x[1]=entry->GetZ();
210  x[2]=entry->GetPhi();
211  y = fTempArray->GetValue(timeSec,isensor);
212  if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
213  if (IsOK(y)) fitter->AddPoint(x,y,1);
214  i++;
215  }
216  } else if (type==4) { // ONLY IFC
217  if (entry->GetType()==2) {
218  x[0]=1;
219  x[1]=entry->GetZ();
220  x[2]=entry->GetPhi();
221  y = fTempArray->GetValue(timeSec,isensor);
222  if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
223  if (IsOK(y)) fitter->AddPoint(x,y,1);
224  i++;
225  }
226  }
227  }
228  fitter->Eval();
229  //fitter->EvalRobust(0.9); // Evaluates fitter
230 
231 
232  return fitter;
233 
234  // returns TLinearFitter object where Chi2, Fitparameters and residuals can
235  // be extracted via usual memberfunctions
236  // example: fitter->GetParameters(param)
237  // In case of type IFC or OFC, the parameters are the gradients in
238  // Z and Y direction (see fitformula)
239  // Caution: Parameters are [K/cm] except Y at IFC,OFC ([K/radius])
240 }
241 
242 //_____________________________________________________________________________
243 
244 TGraph2D *AliTPCTempMap::GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t timeSec)
245 {
257 
258  TGraph2D *graph2D = new TGraph2D();
259 
260  Int_t i = 0;
261 
262  Int_t nsensors = fTempArray->NumSensors();
263  for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
265 
266  Double_t x, y, z, r, phi, tempValue;
267  x = entry->GetX();
268  y = entry->GetY();
269  z = entry->GetZ();
270  r = entry->GetR();
271  phi = entry->GetPhi();
272  tempValue = fTempArray->GetValue(timeSec,isensor);
273  // printf("%d type %d: x=%lf y=%lf temp=%lf\n",isensor,entry->GetType(),x,y, tempValue);
274  if (type==0 || type==3) { // 'side' information used
275  if (entry->GetType()==type && entry->GetSide()==side) {
276  graph2D->SetPoint(i,x,y,tempValue);
277  i++;
278  }
279  } else if (type==2) { // in case of IFC also usage of TS values
280  if (entry->GetType()==2 || entry->GetType()==5) {
281  graph2D->SetPoint(i,z,phi,tempValue);
282  i++;
283  }
284  } else if (type==1){
285  if (entry->GetType()==type) {
286  graph2D->SetPoint(i,z,phi,tempValue);
287  i++;
288  }
289  }
290  }
291 
292  if (type==0 || type==3) {
293  graph2D->GetXaxis()->SetTitle("X[cm]");
294  graph2D->GetYaxis()->SetTitle("Y[cm]");
295  if (type==0 && side==0) {
296  graph2D->SetTitle("ROC A side");
297  } else if (type==0 && side==1) {
298  graph2D->SetTitle("ROC C side");
299  } else if (type==3 && side==0) {
300  graph2D->SetTitle("TPC A side (Inside the TPC)");
301  } else if (type==3 && side==1) {
302  graph2D->SetTitle("TPC C side (Inside the TPC)");
303  }
304  } else if (type==1 || type==2) {
305  graph2D->GetXaxis()->SetTitle("Z[cm]");
306  graph2D->GetYaxis()->SetTitle("Phi[RAD]");
307  if (type==1) {
308  graph2D->SetTitle("Outer Containment Vessel");
309  } else if (type==2) {
310  graph2D->SetTitle("Inner Containment Vessel");
311  }
312  }
313 
314  if (!graph2D->GetN()) {
315  printf("Returned TGraph2D is empty: check type and side values\n");
316  }
317 
318  graph2D->GetXaxis()->SetLabelOffset(0.0);
319  graph2D->GetYaxis()->SetLabelOffset(0.005);
320  graph2D->GetZaxis()->SetLabelOffset(-0.04);
321 
322 
323  return graph2D; // returns TGgraph2D object
324 
325 }
326 
327 
328 //_____________________________________________________________________________
329 
330 TGraph *AliTPCTempMap::MakeGraphGradient(Int_t axis, Int_t side, Int_t nPoints)
331 {
342 
343  TVectorD param(3);
344  TLinearFitter *fitter = new TLinearFitter(3);
345 
346  UInt_t fStartTime = fTempArray->AliTPCSensorTempArray::GetStartTime();
347  UInt_t fEndTime = fTempArray->AliTPCSensorTempArray::GetEndTime();
348 
349  UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
350 
351  Double_t *x = new Double_t[nPoints];
352  Double_t *y = new Double_t[nPoints];
353  for (Int_t ip=0; ip<nPoints; ip++) {
354  x[ip] = fStartTime+ip*stepTime;
355  if (axis==2) {// Gradient in Z direction (based on OFC tempSensors)
356  fitter = GetLinearFitter(1, side, ip*stepTime);
357  } else {// Gradient in X or Y direction (based on TPC tempSensors)
358  fitter = GetLinearFitter(3, side, ip*stepTime);
359  }
360  fitter->GetParameters(param);
361  // multiplied by 500 since TempGradient is in [K/cm]
362  // (TPC diameter and length ~500cm)
363  if (axis==1) { // Y axis
364  y[ip] = param[2]*500;
365  } else { // X axis
366  y[ip] = param[1]*500;
367  }
368  }
369 
370  TGraph *graph = new TGraph(nPoints,x,y);
371 
372  fitter->~TLinearFitter();
373  delete [] x;
374  delete [] y;
375 
376  graph->GetXaxis()->SetTimeDisplay(1);
377  graph->GetXaxis()->SetLabelOffset(0.02);
378  graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
379 
380  return graph;
381 }
382 
383 
384 //_____________________________________________________________________________
385 Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, TTimeStamp &stamp)
386 {
389 
390  Int_t timeSec = stamp.GetSec()-fTempArray->GetStartTime().GetSec();
391  return GetTemperature(x, y, z, timeSec);
392 }
393 
394 //_____________________________________________________________________________
395 
396 Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_t timeSec)
397 {
404 
405  TVectorD paramA(3), paramC(3);
406  TLinearFitter *fitterA = 0;
407  TLinearFitter *fitterC = 0;
408 
409  fitterA = GetLinearFitter(3, 0, timeSec);
410  fitterA->GetParameters(paramA);
411  fitterC = GetLinearFitter(3, 1, timeSec);
412  fitterC->GetParameters(paramC);
413 
414  Double_t fvalA = paramA[0]+paramA[1]*x+paramA[2]*y;
415  Double_t fvalC = paramC[0]+paramC[1]*x+paramC[2]*y;
416 
417  Double_t k = (fvalA-fvalC)/(2*247);
418  Double_t tempValue = fvalC+(fvalA-fvalC)/2+k*z;
419 
420  delete fitterA;
421  delete fitterC;
422 
423  return tempValue;
424 
425 }
426 
427 
428 Bool_t AliTPCTempMap::IsOK(Float_t value){
430 
431  const Float_t kMinT=15;
432  const Float_t kMaxT=25;
433  return (value>kMinT && value<kMaxT);
434 }
TGraph2D * GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t timeSec)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Double_t GetZ() const
Definition: AliDCSSensor.h:47
virtual ~AliTPCTempMap()
AliTPCSensorTempArray * fTempArray
Array of Sensors (initialized in Constructor)
Definition: AliTPCTempMap.h:38
Double_t GetX() const
Definition: AliDCSSensor.h:45
Int_t NumSensors() const
AliTPCTempMap & operator=(const AliTPCTempMap &c)
virtual void Copy(TObject &c) const
Class describing TPC temperature sensors (including pointers to graphs/fits.
TPC calibration class for temperature maps and tendencies.
Definition: AliTPCTempMap.h:19
Double_t GetTemperature(Double_t x, Double_t y, Double_t z, UInt_t timeSec)
TGraph * MakeGraphGradient(Int_t axis, Int_t side, Int_t nPoints)
TLinearFitter * GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec)
Double_t GetR() const
Definition: AliDCSSensor.h:48
Double_t GetValue(UInt_t timeSec, Int_t sensor)
Double_t GetPhi() const
Definition: AliDCSSensor.h:49
Int_t GetType() const
TPC calibration class for parameters which saved per pad.
Bool_t IsOK(Float_t value)
TTimeStamp GetStartTime() const
AliTPCTempMap(AliTPCSensorTempArray *SensorsDCS)
AliDCSSensor * GetSensorNum(Int_t ind)
const char kStringFEsimulation[]
Int_t GetSide() const
Double_t GetTempGradientY(UInt_t timeSec, Int_t side)
Double_t GetY() const
Definition: AliDCSSensor.h:46