]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCTempMap.cxx
Due to a wrongly overloaded function need to call SetDistToBadChannel, rather than...
[u/mrichter/AliRoot.git] / TPC / AliTPCTempMap.cxx
index 2c415bd1f103d6aa8b0a0a879034740c870bb574..67108ab8a313ddffa1a6f1d1f4268fd0b0c73d35 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)
 {
   //
@@ -110,17 +113,17 @@ Double_t AliTPCTempMap::GetTempGradientY(UInt_t timeSec, Int_t side){
  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++;
    }
 
@@ -135,7 +138,17 @@ Double_t AliTPCTempMap::GetTempGradientY(UInt_t timeSec, Int_t side){
 }
 
 //_____________________________________________________________________________
+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)
 {
   // 
@@ -156,7 +169,8 @@ 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 y = 0;
-
+  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 {
@@ -164,17 +178,33 @@ TLinearFitter *AliTPCTempMap::GetLinearFitter(Int_t type, Int_t side, UInt_t tim
   }
 
   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*)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*)ft->GetSensorNum(isensor);
+    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
@@ -182,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){
@@ -191,8 +222,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==4) { // ONLY IFC
@@ -200,13 +232,15 @@ 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++;
       }
     }
   }  
-  fitter->Eval(); // Evaluates fitter
+  fitter->Eval();
+  //fitter->EvalRobust(0.9); // Evaluates fitter
   
   delete [] x;
 
@@ -234,20 +268,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();
@@ -255,8 +286,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);
@@ -279,13 +310,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]");
@@ -293,7 +324,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");
     }
   }
 
@@ -331,8 +362,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;
 
@@ -368,12 +399,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
@@ -400,5 +444,15 @@ Double_t AliTPCTempMap::GetTemperature(Double_t x, Double_t y, Double_t z, UInt_
   fitterC->~TLinearFitter();
 
   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);
+}