]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Updates to keep DCS graph for selected sensors
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Apr 2008 15:11:19 +0000 (15:11 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Apr 2008 15:11:19 +0000 (15:11 +0000)
Common interface to graphs and fits to obtain value for a given time

Haavard

STEER/AliDCSSensor.cxx
STEER/AliDCSSensor.h
STEER/AliDCSSensorArray.cxx
STEER/AliDCSSensorArray.h

index fccace729e1c62acaa1212bc4011ff4f903c931e..69af0d9e2849bbb8859c955ec082cd59af5fefdf 100644 (file)
@@ -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
 {
   //
index e7f3a91f6e329d54992918015cf532f02e8a385d..6de2f0d29034fd28a22ac28a997b0e1734fed8ca 100644 (file)
@@ -68,6 +68,7 @@ public:
   Double_t GetValue(UInt_t timeSec);
   Double_t GetValue(TTimeStamp time);
   Double_t Eval(const TTimeStamp& time, Bool_t inside=true) const;
+  Double_t EvalGraph(const Double_t& timeHour) const;
   TGraph *MakeGraph (Int_t nPoints=100) const;
   static TClonesArray *  ReadTree(TTree *tree);
   
index d171c570cef9f15e08d1050d2f74ced0170dff7e..c81b99d1486409528313bc93ff7c579dd99fee5d 100644 (file)
@@ -233,6 +233,27 @@ void AliDCSSensorArray::MakeSplineFit(TMap *map, Bool_t keepMap)
     if (keepMap) entry->SetGraph(gr);
   }
 }
+//_____________________________________________________________________________
+void AliDCSSensorArray::StoreGraph(TMap *map)
+{
+  //
+  // Store graphs extracted from DCS
+  //
+  Int_t nsensors = fSensors->GetEntries();
+  for ( Int_t isensor=0; isensor<nsensors; isensor++) {
+    AliDCSSensor *entry = (AliDCSSensor*)fSensors->At(isensor);
+    TString stringID = entry->GetStringID();
+    TGraph *gr = (TGraph*)map->GetValue(stringID.Data());
+    if (!gr ) {
+      entry->SetFit(0);
+      entry->SetGraph(0);
+      AliWarning(Form("sensor %s: no input graph",stringID.Data()));
+      continue;
+    }
+    entry->SetFit(0);
+    entry->SetGraph(gr);
+  }
+}
 
 //_____________________________________________________________________________
 Int_t AliDCSSensorArray::NumFits() const 
@@ -543,3 +564,19 @@ void AliDCSSensorArray::ClearFit()
      sensor->SetFit(0);
    }
 }
+//_____________________________________________________________________________
+void AliDCSSensorArray::AddSensors(AliDCSSensorArray *newSensors)
+{
+  //
+  // add sensors from two sensor arrays
+  //
+  
+  Int_t numNew = newSensors->NumSensors();
+  Int_t numOld = fSensors->GetEntries();
+  fSensors->Expand(numOld+numNew);
+  for (Int_t i=0;i<numNew;i++) {
+    AliDCSSensor *sens = newSensors->GetSensorNum(i);
+    new ((*fSensors)[numOld+i]) AliDCSSensor(*sens);
+  }
+}  
+  
index 91ab6cd4cecf103ae0ee75b5b334abf6c4703fb1..d4baa45b653a359c9c55eadc439b034b6543379d 100644 (file)
@@ -53,6 +53,7 @@ class AliDCSSensorArray : public TNamed {
 
   void SetGraph     (TMap *map);
   void MakeSplineFit(TMap *map, Bool_t keepMap=kFALSE);
+  void StoreGraph   (TMap *map);
   TMap* ExtractDCS  (TMap *dcsMap);
   TGraph* MakeGraph (TObjArray *valueSet);
   void ClearGraph();
@@ -64,6 +65,7 @@ class AliDCSSensorArray : public TNamed {
   AliDCSSensor* GetSensorNum (Int_t ind);
   void RemoveSensorNum(Int_t ind);
   void RemoveSensor(Int_t IdDCS);
+  void AddSensors(AliDCSSensorArray *sensors);
   TArrayI OutsideThreshold(Double_t threshold, UInt_t timeSec=0, Bool_t below=kTRUE) const;
   Int_t NumSensors() const { return fSensors->GetEntries(); }
   Int_t NumFits() const;