]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCTempMap.cxx
Removing obsolete class
[u/mrichter/AliRoot.git] / TPC / AliTPCTempMap.cxx
index 29028e8585921870136210dea9814e046b52f6dd..e3e32b5cbb78f0c9aa61d37fe0d6effc12d0c95d 100644 (file)
 //                                                                           //
 //  Authors: Stefan Rossegger, Haavard Helstrup                              //
 //                                                                           //
+//  Note: Obvioulsy some changes by Marian, but when ???                     //
+//                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliTPCSensorTempArray.h"
 #include "TLinearFitter.h"
 #include "TString.h"
 #include "TGraph2D.h"
+#include "TTimeStamp.h"
 
 #include "AliTPCTempMap.h"
 
@@ -38,21 +41,21 @@ ClassImp(AliTPCTempMap)
 //_____________________________________________________________________________
 AliTPCTempMap::AliTPCTempMap(AliTPCSensorTempArray *sensorDCS):
   TNamed(),
-  ft(0),
+  fTempArray(0),
   fStringFEsimulation(kStringFEsimulation)
 {
   //
   // AliTPCTempMap default constructor
   //
 
-  ft = sensorDCS;
+  fTempArray = sensorDCS;
 
 }
 
 //_____________________________________________________________________________
 AliTPCTempMap::AliTPCTempMap(const AliTPCTempMap &c):
   TNamed(c),
-  ft(c.ft),
+  fTempArray(c.fTempArray),
   fStringFEsimulation(c.fStringFEsimulation)
 {
   //
@@ -106,35 +109,46 @@ Double_t AliTPCTempMap::GetTempGradientY(UInt_t timeSec, Int_t side){
  //        or simply chi2 for validity check? 
  //        -> better use GetLinearFitter - function in this case!
   
- TLinearFitter fitter(3,"x0++x1++x2");
+ TLinearFitter *fitter = new TLinearFitter(3,"x0++x1++x2");
  TVectorD param(3);
  Int_t i = 0;
 
- Int_t nsensors = ft->NumSensors();
+ Int_t nsensors = fTempArray->NumSensors();
  for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
-   AliTPCSensorTemp *entry = (AliTPCSensorTemp*)ft->GetSensorNum(isensor);
+   AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
    
    if (entry->GetType()==3 && entry->GetSide()==side) { // take SensorType:TPC 
      Double_t x[3];
      x[0]=1;
      x[1]=entry->GetX();
      x[2]=entry->GetY();    
-     Double_t y = entry->GetValue(timeSec); // get temperature value
-     fitter.AddPoint(x,y,1); // add values to LinearFitter
+     Double_t y = fTempArray->GetValue(timeSec,isensor); // get temperature value
+     if (IsOK(y)) fitter->AddPoint(x,y,1); // add values to LinearFitter
      i++;
    }
 
  }  
- fitter.Eval();
- fitter.GetParameters(param);
- fitter.~TLinearFitter();
+ fitter->Eval();
+ fitter->GetParameters(param);
+
+ fitter->~TLinearFitter();
 
  return param[2]; // return vertical (Y) tempGradient in [K/cm]
   
 }
 
 //_____________________________________________________________________________
+TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, TTimeStamp &stamp)
+{
+  //
+  // absolute time stamp used
+  // see AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec) for details
+  //
+  Int_t timeSec = stamp.GetSec()-fTempArray->GetStartTime().GetSec();
+  return GetLinearFitter(type,side,timeSec);
+}
 
+//_____________________________________________________________________________
 TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t timeSec)
 {
   // 
@@ -145,6 +159,7 @@ TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t tim
   //       1 ... OuterContainmentVessel (OFC)
   //       2 ... InnerContainmentVessel (IFC) + ThermalScreener (TS)
   //       3 ... Within the TPC (DriftVolume) (TPC)
+  //       4 ... Only InnerContainmentVessel (IFC) 
   // side: Can be choosen for type 0 and 3 (otherwise it will be ignored in 
   //       in order to get all temperature sensors of interest)
   //       0 ... Shaft Side (A)
@@ -152,27 +167,44 @@ TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t tim
   // 
 
   TLinearFitter *fitter = new TLinearFitter(3);
-  Double_t *x = new Double_t[3];
+  Double_t x[3]={0};
   Double_t y = 0;
-
-  if (type == 1 || type == 2) {
+  const Float_t kMaxDelta=0.5;
+  
+  if (type == 1 || type == 2 || type == 4) {
     fitter->SetFormula("x0++x1++TMath::Sin(x2)"); // returns Z,Y gradient
   } else {
     fitter->SetFormula("x0++x1++x2"); // returns X,Y gradient
   }
 
   Int_t i = 0;
-  Int_t nsensors = ft->NumSensors();
+  Int_t nsensors = fTempArray->NumSensors();
+
+  Float_t temps[1000];
   for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
-    AliTPCSensorTemp *entry = (AliTPCSensorTemp*)ft->GetSensorNum(isensor);
+    AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
+    if (entry->GetType()==type && entry->GetSide()==side){
+      Float_t temperature= fTempArray->GetValue(timeSec,isensor); // get temperature value
+      if (IsOK(temperature)) {temps[i]=temperature; i++;}
+    }
+  }
+  Float_t medianTemp = TMath::Median(i, temps);
+  if (i<3) return 0;
+  Float_t rmsTemp = TMath::RMS(i, temps);
+  
+  i=0;
+  
+  for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
+    AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
     
     if (type==0 || type==3) { // 'side' information used
       if (entry->GetType()==type && entry->GetSide()==side) {
        x[0]=1;
        x[1]=entry->GetX();
        x[2]=entry->GetY();    
-       y = entry->GetValue(timeSec); // get temperature value
-       fitter->AddPoint(x,y,1); // add values to LinearFitter
+       y = fTempArray->GetValue(timeSec,isensor); // get temperature value
+       if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
+       if (IsOK(y)) fitter->AddPoint(x,y,1); // add values to LinearFitter
        i++;
       }
     } else if (type==2) { // in case of IFC also usage of TS values
@@ -180,8 +212,9 @@ TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t tim
        x[0]=1;
        x[1]=entry->GetZ();
        x[2]=entry->GetPhi();    
-       y = entry->GetValue(timeSec);
-       fitter->AddPoint(x,y,1); 
+       y = fTempArray->GetValue(timeSec,isensor);
+       if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
+       if (IsOK(y)) fitter->AddPoint(x,y,1); 
        i++;
       }
     } else if (type==1){
@@ -189,21 +222,32 @@ TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t tim
        x[0]=1;
        x[1]=entry->GetZ();
        x[2]=entry->GetPhi();    
-       y = entry->GetValue(timeSec);
-       fitter->AddPoint(x,y,1);
+       y = fTempArray->GetValue(timeSec,isensor);
+       if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
+       if (IsOK(y)) fitter->AddPoint(x,y,1);
        i++;    
       }
+    } else if (type==4) { // ONLY IFC
+      if (entry->GetType()==2) {
+       x[0]=1;
+       x[1]=entry->GetZ();
+       x[2]=entry->GetPhi();    
+       y = fTempArray->GetValue(timeSec,isensor);
+       if (TMath::Abs(y-medianTemp)>kMaxDelta+4.*rmsTemp) continue;
+       if (IsOK(y)) fitter->AddPoint(x,y,1); 
+       i++;
+      }
     }
   }  
-  fitter->Eval(); // Evaluates fitter
+  fitter->Eval();
+  //fitter->EvalRobust(0.9); // Evaluates fitter
   
-  delete [] x;
 
   return fitter; 
 
   // returns TLinearFitter object where Chi2, Fitparameters and residuals can 
   // be extracted via usual memberfunctions
-  // example: fitter.GetParameters(param)
+  // example: fitter->GetParameters(param)
   // In case of type IFC or OFC, the parameters are the gradients in 
   // Z and Y direction (see fitformula)
   // Caution: Parameters are [K/cm] except Y at IFC,OFC ([K/radius]) 
@@ -223,20 +267,17 @@ TGraph2D *AliTPCTempMap::GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t ti
   //       3 ... Within the TPC (DriftVolume) (TPC)
   // side: Can be choosen for type 0 and 3 (otherwise it will be ignored in 
   //       in order to get all temperature sensors of interest)
-  //       0 ... Shaft Side (A)
-  //       1 ... Muon Side (C)
+  //       0 ... A - side
+  //       1 ... C - side
   // 
 
   TGraph2D *graph2D = new TGraph2D();
 
   Int_t i = 0;
   
-
-  Int_t nsensors = ft->NumSensors();
-
+  Int_t nsensors = fTempArray->NumSensors();
   for (Int_t isensor=0; isensor<nsensors; isensor++) { // loop over all sensors
-    AliTPCSensorTemp *entry = (AliTPCSensorTemp*)ft->GetSensorNum(isensor);
+    AliTPCSensorTemp *entry = (AliTPCSensorTemp*)fTempArray->GetSensorNum(isensor);
 
     Double_t x, y, z, r, phi, tempValue;
     x = entry->GetX();
@@ -244,8 +285,8 @@ TGraph2D *AliTPCTempMap::GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t ti
     z = entry->GetZ();
     r = entry->GetR();
     phi = entry->GetPhi();
-    tempValue = entry->GetValue(timeSec);
-
+    tempValue = fTempArray->GetValue(timeSec,isensor);
+    //    printf("%d type %d: x=%lf y=%lf temp=%lf\n",isensor,entry->GetType(),x,y, tempValue);
     if (type==0 || type==3) { // 'side' information used
       if (entry->GetType()==type && entry->GetSide()==side) {
        graph2D->SetPoint(i,x,y,tempValue);
@@ -268,13 +309,13 @@ TGraph2D *AliTPCTempMap::GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t ti
     graph2D->GetXaxis()->SetTitle("X[cm]");
     graph2D->GetYaxis()->SetTitle("Y[cm]");
     if (type==0 && side==0) {
-      graph2D->SetTitle("ROC A - Endplate Shaft Side");
+      graph2D->SetTitle("ROC A side");
     } else if (type==0 && side==1) {
-      graph2D->SetTitle("ROC C - Endplate Muon Side");
+      graph2D->SetTitle("ROC C side");
     } else if (type==3 && side==0) {
-      graph2D->SetTitle("TPC A - Inside the TPC Shaft Side");
+      graph2D->SetTitle("TPC A side (Inside the TPC)");
     } else if (type==3 && side==1) {
-      graph2D->SetTitle("TPC C - Inside the TPC Muon Side");
+      graph2D->SetTitle("TPC C side (Inside the TPC)");
     }
   } else if (type==1 || type==2) {
     graph2D->GetXaxis()->SetTitle("Z[cm]");
@@ -282,7 +323,7 @@ TGraph2D *AliTPCTempMap::GetTempMapsViaSensors(Int_t type, Int_t side, UInt_t ti
     if (type==1) {
       graph2D->SetTitle("Outer Containment Vessel");
     } else if (type==2) {
-      graph2D->SetTitle("InnerContainmentVessel + ThermalScreeners");
+      graph2D->SetTitle("Inner Containment Vessel");
     }
   }
 
@@ -320,8 +361,8 @@ TGraph *AliTPCTempMap::MakeGraphGradient(Int_t axis, Int_t side, Int_t nPoints)
   TVectorD param(3);
   TLinearFitter *fitter = new TLinearFitter(3);
 
-  UInt_t fStartTime = ft->AliTPCSensorTempArray::GetStartTime();
-  UInt_t fEndTime = ft->AliTPCSensorTempArray::GetEndTime();
+  UInt_t fStartTime = fTempArray->AliTPCSensorTempArray::GetStartTime();
+  UInt_t fEndTime = fTempArray->AliTPCSensorTempArray::GetEndTime();
   
   UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
 
@@ -357,12 +398,25 @@ TGraph *AliTPCTempMap::MakeGraphGradient(Int_t axis, Int_t side, Int_t nPoints)
   return graph;
 }
 
+
+//_____________________________________________________________________________
+Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, TTimeStamp &stamp)
+{
+  //
+  // absolute time stamp used
+  // see also Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_t timeSec) for details
+  //
+
+  Int_t timeSec = stamp.GetSec()-fTempArray->GetStartTime().GetSec();
+  return GetTemperature(x, y, z, timeSec);
+}
+
 //_____________________________________________________________________________
 
 Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_t timeSec)
 {  
   //
-  // Returns estimated Temperature at given position (x,y,z) at given time 
+  // Returns estimated Temperature at given position (x,y,z[cm]) at given time 
   // (timeSec) after starttime
   // Method: so far just a linear interpolation between Linar fits of 
   //         the TPC temperature sensors
@@ -371,8 +425,8 @@ Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_
   //
   
   TVectorD paramA(3), paramC(3);
-  TLinearFitter *fitterA = new TLinearFitter(3);
-  TLinearFitter *fitterC = new TLinearFitter(3);
+  TLinearFitter *fitterA = 0;
+  TLinearFitter *fitterC = 0;
 
   fitterA = GetLinearFitter(3, 0, timeSec);
   fitterA->GetParameters(paramA);
@@ -385,9 +439,19 @@ Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_
   Double_t k = (fvalA-fvalC)/(2*247);
   Double_t tempValue = fvalC+(fvalA-fvalC)/2+k*z;
 
-  fitterA->~TLinearFitter();
-  fitterC->~TLinearFitter();
+  delete fitterA;
+  delete fitterC;
 
   return tempValue;
+
 }
 
+
+Bool_t  AliTPCTempMap::IsOK(Float_t value){
+  //
+  // checks if value is within a certain range
+  //
+  const Float_t kMinT=15;
+  const Float_t kMaxT=25;
+  return (value>kMinT && value<kMaxT);
+}