]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliDCSSensor.cxx
Fixing part of the Coding violation
[u/mrichter/AliRoot.git] / STEER / AliDCSSensor.cxx
index b856049f07d7b48cfa2bc24379a8e8e8b282bdb6..69af0d9e2849bbb8859c955ec082cd59af5fefdf 100644 (file)
@@ -80,7 +80,7 @@ Double_t AliDCSSensor::GetValue(UInt_t timeSec)
  // Get temperature value for actual sensor
  //  timeSec given as offset from start-of-run measured in seconds
  //
- Bool_t inside;
+ Bool_t inside=kTRUE;
  return Eval(TTimeStamp((time_t)(fStartTime+timeSec),0),inside);
 }
 //_____________________________________________________________________________
@@ -89,7 +89,7 @@ Double_t AliDCSSensor::GetValue(TTimeStamp time)
  // Get temperature value for actual sensor
  //  time given as absolute TTimeStamp
  //
- Bool_t inside;
+ Bool_t inside=kTRUE;
  return Eval(time, inside);
 }
 
@@ -119,10 +119,42 @@ Double_t AliDCSSensor::Eval(const TTimeStamp& time, Bool_t inside) const
   if ( fFit ) {
      return fFit->Eval(timeHour); 
   } else {
-     return -99;
+     if ( fGraph ) {
+       return EvalGraph(timeHour);
+     } else {  
+       return -99;
+     }
   }
 }
+//_____________________________________________________________________________
+Double_t AliDCSSensor::EvalGraph(const Double_t& timeHour) const 
+{
+  //
+  // Extract last value in graph observed before time given by timeHour
+  //
+
+  // return -99 if point specified is before beginning of graph
+  Double_t x=0; Double_t y=0;
+  fGraph->GetPoint(0,x,y);
+  if ( timeHour < x ) return -99;
+  
+  // return previous point when first time > timeHour is observed
+  
+  Int_t npoints = fGraph->GetN();
+  for (Int_t i=1; i<npoints; i++) {
+     fGraph->GetPoint(i,x,y);
+     if ( timeHour < x ) {
+       fGraph->GetPoint(i-1,x,y);
+       return y;
+     }
+  }
+  
+  // return last point if all times are < timeHour
+  return y;
+} 
+       
 
+//_____________________________________________________________________________
 TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
 {
   //