1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 // TPC calibration class for temperature maps and tendencies //
20 // (based on TPC Temperature Sensors and FiniteElement Simulation) //
22 // Authors: Stefan Rossegger, Haavard Helstrup //
24 ///////////////////////////////////////////////////////////////////////////////
26 #include "AliTPCSensorTempArray.h"
27 #include "TLinearFitter.h"
30 #include "TTimeStamp.h"
32 #include "AliTPCTempMap.h"
35 ClassImp(AliTPCTempMap)
37 const char kStringFEsimulation[] = "FEsimulation.txt";
39 //_____________________________________________________________________________
40 AliTPCTempMap::AliTPCTempMap(AliTPCSensorTempArray *sensorDCS):
43 fStringFEsimulation(kStringFEsimulation)
46 // AliTPCTempMap default constructor
49 fTempArray = sensorDCS;
53 //_____________________________________________________________________________
54 AliTPCTempMap::AliTPCTempMap(const AliTPCTempMap &c):
56 fTempArray(c.fTempArray),
57 fStringFEsimulation(c.fStringFEsimulation)
60 // AliTPCTempMap copy constructor
65 //_____________________________________________________________________________
66 AliTPCTempMap::~AliTPCTempMap()
69 // AliTPCTempMap destructor
74 //_____________________________________________________________________________
75 AliTPCTempMap &AliTPCTempMap::operator=(const AliTPCTempMap &c)
78 // Assignment operator
81 if (this != &c) ((AliTPCTempMap &) c).Copy(*this);
86 //_____________________________________________________________________________
87 void AliTPCTempMap::Copy(TObject &c) const
97 //_____________________________________________________________________________
99 Double_t AliTPCTempMap::GetTempGradientY(UInt_t timeSec, Int_t side){
101 // Extract Linear Vertical Temperature Gradient [K/cm] within the TPC on
104 // Values based on TemperatureSensors within the TPC ( type: 3 (TPC) )
106 // FIXME: Also return residual-distribution, covariance Matrix
107 // or simply chi2 for validity check?
108 // -> better use GetLinearFitter - function in this case!
110 TLinearFitter *fitter = new TLinearFitter(3,"x0++x1++x2");
114 Int_t nsensors = fTempArray->NumSensors();
115 for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
116 AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
118 if (entry->GetType()==3 && entry->GetSide()==side) { // take SensorType:TPC
123 Double_t y = fTempArray->GetValue(timeSec,isensor); // get temperature value
124 if (IsOK(y)) fitter->AddPoint(x,y,1); // add values to LinearFitter
130 fitter->GetParameters(param);
132 fitter->~TLinearFitter();
134 return param[2]; // return vertical (Y) tempGradient in [K/cm]
138 //_____________________________________________________________________________
139 TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, TTimeStamp &stamp)
142 // absolute time stamp used
143 // see AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec) for details
145 Int_t timeSec = stamp.GetSec()-fTempArray->GetStartTime().GetSec();
146 return GetLinearFitter(type,side,timeSec);
149 //_____________________________________________________________________________
150 TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec)
153 // Creates a TlinearFitter object for the desired region of the TPC
154 // (via choosen type and side of TPC temperature sensors) at a given
155 // timeSec (in secounds) after start time
156 // type: 0 ... ReadOutChambers (ROC)
157 // 1 ... OuterContainmentVessel (OFC)
158 // 2 ... InnerContainmentVessel (IFC) + ThermalScreener (TS)
159 // 3 ... Within the TPC (DriftVolume) (TPC)
160 // 4 ... Only InnerContainmentVessel (IFC)
161 // side: Can be choosen for type 0 and 3 (otherwise it will be ignored in
162 // in order to get all temperature sensors of interest)
163 // 0 ... Shaft Side (A)
164 // 1 ... Muon Side (C)
167 TLinearFitter *fitter = new TLinearFitter(3);
168 Double_t *x = new Double_t[3];
170 const Float_t kMaxDelta=0.5;
172 if (type == 1 || type == 2 || type == 4) {
173 fitter->SetFormula("x0++x1++TMath::Sin(x2)"); // returns Z,Y gradient
175 fitter->SetFormula("x0++x1++x2"); // returns X,Y gradient
179 Int_t nsensors = fTempArray->NumSensors();
182 for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
183 AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
184 if (entry->GetType()==type && entry->GetSide()==side){
185 Float_t temperature= fTempArray->GetValue(timeSec,isensor); // get temperature value
186 if (IsOK(temperature)) {temps[i]=temperature; i++;}
189 Float_t medianTemp = TMath::Median(i, temps);
191 Float_t rmsTemp = TMath::RMS(i, temps);
195 for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
196 AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
198 if (type==0 || type==3) { // 'side' information used
199 if (entry->GetType()==type && entry->GetSide()==side) {
203 y = fTempArray->GetValue(timeSec,isensor); // get temperature value
204 if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
205 if (IsOK(y)) fitter->AddPoint(x,y,1); // add values to LinearFitter
208 } else if (type==2) { // in case of IFC also usage of TS values
209 if ((entry->GetType()==2) || (entry->GetType()==5)) {
212 x[2]=entry->GetPhi();
213 y = fTempArray->GetValue(timeSec,isensor);
214 if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
215 if (IsOK(y)) fitter->AddPoint(x,y,1);
219 if (entry->GetType()==type) {
222 x[2]=entry->GetPhi();
223 y = fTempArray->GetValue(timeSec,isensor);
224 if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
225 if (IsOK(y)) fitter->AddPoint(x,y,1);
228 } else if (type==4) { // ONLY IFC
229 if (entry->GetType()==2) {
232 x[2]=entry->GetPhi();
233 y = fTempArray->GetValue(timeSec,isensor);
234 if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
235 if (IsOK(y)) fitter->AddPoint(x,y,1);
241 //fitter->EvalRobust(0.9); // Evaluates fitter
247 // returns TLinearFitter object where Chi2, Fitparameters and residuals can
248 // be extracted via usual memberfunctions
249 // example: fitter->GetParameters(param)
250 // In case of type IFC or OFC, the parameters are the gradients in
251 // Z and Y direction (see fitformula)
252 // Caution: Parameters are [K/cm] except Y at IFC,OFC ([K/radius])
255 //_____________________________________________________________________________
257 TGraph2D *AliTPCTempMap::GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t timeSec)
260 // Creates a TGraph2D object for the desired region of the TPC
261 // (via choosen type and side of TPC temperature sensors) at a given
262 // timeSec (in secounds) after start time
263 // type: 0 ... ReadOutChambers (ROC)
264 // 1 ... OuterContainmentVessel (OFC)
265 // 2 ... InnerContainmentVessel (IFC) + ThermalScreener (TS)
266 // 3 ... Within the TPC (DriftVolume) (TPC)
267 // side: Can be choosen for type 0 and 3 (otherwise it will be ignored in
268 // in order to get all temperature sensors of interest)
273 TGraph2D *graph2D = new TGraph2D();
277 Int_t nsensors = fTempArray->NumSensors();
278 for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
279 AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
281 Double_t x, y, z, r, phi, tempValue;
286 phi = entry->GetPhi();
287 tempValue = fTempArray->GetValue(timeSec,isensor);
288 // printf("%d type %d: x=%lf y=%lf temp=%lf\n",isensor,entry->GetType(),x,y, tempValue);
289 if (type==0 || type==3) { // 'side' information used
290 if (entry->GetType()==type && entry->GetSide()==side) {
291 graph2D->SetPoint(i,x,y,tempValue);
294 } else if (type==2) { // in case of IFC also usage of TS values
295 if (entry->GetType()==2 || entry->GetType()==5) {
296 graph2D->SetPoint(i,z,phi,tempValue);
300 if (entry->GetType()==type) {
301 graph2D->SetPoint(i,z,phi,tempValue);
307 if (type==0 || type==3) {
308 graph2D->GetXaxis()->SetTitle("X[cm]");
309 graph2D->GetYaxis()->SetTitle("Y[cm]");
310 if (type==0 && side==0) {
311 graph2D->SetTitle("ROC A side");
312 } else if (type==0 && side==1) {
313 graph2D->SetTitle("ROC C side");
314 } else if (type==3 && side==0) {
315 graph2D->SetTitle("TPC A side (Inside the TPC)");
316 } else if (type==3 && side==1) {
317 graph2D->SetTitle("TPC C side (Inside the TPC)");
319 } else if (type==1 || type==2) {
320 graph2D->GetXaxis()->SetTitle("Z[cm]");
321 graph2D->GetYaxis()->SetTitle("Phi[RAD]");
323 graph2D->SetTitle("Outer Containment Vessel");
324 } else if (type==2) {
325 graph2D->SetTitle("Inner Containment Vessel");
329 if (!graph2D->GetN()) {
330 printf("Returned TGraph2D is empty: check type and side values\n");
333 graph2D->GetXaxis()->SetLabelOffset(0.0);
334 graph2D->GetYaxis()->SetLabelOffset(0.005);
335 graph2D->GetZaxis()->SetLabelOffset(-0.04);
338 return graph2D; // returns TGgraph2D object
343 //_____________________________________________________________________________
345 TGraph *AliTPCTempMap::MakeGraphGradient(Int_t axis, Int_t side, Int_t nPoints)
348 // Make graph from start time to end time of TempGradient in axis direction
349 // axis: 0 ... horizontal Temperature Gradient (X)
350 // 1 ... vertical Temperature Gradient (Y)
351 // 2 ... longitudenal Temperature Gradient (Z) (side is ignored)
352 // z gradient value based on OFC temperature sensors
353 // Caution!: better z gradient values through difference between
354 // param[0] A- and param[0] C-side !
355 // side for X and Y gradient:
356 // 0 ... Shaft Side (A)
357 // 1 ... Muon Side (C)
361 TLinearFitter *fitter = new TLinearFitter(3);
363 UInt_t fStartTime = fTempArray->AliTPCSensorTempArray::GetStartTime();
364 UInt_t fEndTime = fTempArray->AliTPCSensorTempArray::GetEndTime();
366 UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
368 Double_t *x = new Double_t[nPoints];
369 Double_t *y = new Double_t[nPoints];
370 for (Int_t ip=0; ip<nPoints; ip++) {
371 x[ip] = fStartTime+ip*stepTime;
372 if (axis==2) {// Gradient in Z direction (based on OFC tempSensors)
373 fitter = GetLinearFitter(1, side, ip*stepTime);
374 } else {// Gradient in X or Y direction (based on TPC tempSensors)
375 fitter = GetLinearFitter(3, side, ip*stepTime);
377 fitter->GetParameters(param);
378 // multiplied by 500 since TempGradient is in [K/cm]
379 // (TPC diameter and length ~500cm)
380 if (axis==1) { // Y axis
381 y[ip] = param[2]*500;
383 y[ip] = param[1]*500;
387 TGraph *graph = new TGraph(nPoints,x,y);
389 fitter->~TLinearFitter();
393 graph->GetXaxis()->SetTimeDisplay(1);
394 graph->GetXaxis()->SetLabelOffset(0.02);
395 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
401 //_____________________________________________________________________________
402 Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, TTimeStamp &stamp)
405 // absolute time stamp used
406 // see also Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_t timeSec) for details
409 Int_t timeSec = stamp.GetSec()-fTempArray->GetStartTime().GetSec();
410 return GetTemperature(x, y, z, timeSec);
413 //_____________________________________________________________________________
415 Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_t timeSec)
418 // Returns estimated Temperature at given position (x,y,z[cm]) at given time
419 // (timeSec) after starttime
420 // Method: so far just a linear interpolation between Linar fits of
421 // the TPC temperature sensors
422 // FIXME: 'Educated Fit' through FiniteElement Simulation results!
423 // FIXXME: Return 0? if x,y,z out of range
426 TVectorD paramA(3), paramC(3);
427 TLinearFitter *fitterA = new TLinearFitter(3);
428 TLinearFitter *fitterC = new TLinearFitter(3);
430 fitterA = GetLinearFitter(3, 0, timeSec);
431 fitterA->GetParameters(paramA);
432 fitterC = GetLinearFitter(3, 1, timeSec);
433 fitterC->GetParameters(paramC);
435 Double_t fvalA = paramA[0]+paramA[1]*x+paramA[2]*y;
436 Double_t fvalC = paramC[0]+paramC[1]*x+paramC[2]*y;
438 Double_t k = (fvalA-fvalC)/(2*247);
439 Double_t tempValue = fvalC+(fvalA-fvalC)/2+k*z;
441 fitterA->~TLinearFitter();
442 fitterC->~TLinearFitter();
449 Bool_t AliTPCTempMap::IsOK(Float_t value){
453 const Float_t kMinT=15;
454 const Float_t kMaxT=25;
455 return (value>kMinT && value<kMaxT);