]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New DCS code by Wilfried
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 31 May 2007 13:02:45 +0000 (13:02 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 31 May 2007 13:02:45 +0000 (13:02 +0000)
TRD/AliTRDDataDCS.cxx [new file with mode: 0644]
TRD/AliTRDDataDCS.h [new file with mode: 0644]
TRD/AliTRDPreprocessor.cxx
TRD/AliTRDPreprocessor.h
TRD/TRDbaseLinkDef.h
TRD/libTRDbase.pkg

diff --git a/TRD/AliTRDDataDCS.cxx b/TRD/AliTRDDataDCS.cxx
new file mode 100644 (file)
index 0000000..f64a46d
--- /dev/null
@@ -0,0 +1,478 @@
+
+
+#include <TGraph.h>
+#include <TObjArray.h>
+#include <AliCDBMetaData.h>
+#include <TMap.h>
+
+#include "AliDCSValue.h"
+#include "AliDCSValue.h"
+#include "AliLog.h"
+#include "AliTRDDataDCS.h"
+#include "AliSplineFit.h"
+
+ClassImp(AliTRDDataDCS)
+
+
+/*
+Typical use :
+
+AliTRDDataDCS dataDcs;
+dataDcs.ExtractDCS (dcs);
+->call a storeRef function
+dataDcs.PerformFit ();
+dataDcs.ClearGraphs ();
+->call a store function
+dataDcs.ClearFits ();
+
+*/
+
+//_____________________________________________________________________________
+AliTRDDataDCS::AliTRDDataDCS () 
+  :  chamberByteStatus         (0),
+     preTrigger                (1),
+     goofyHv           (2),
+     goofyPeakPos      (3),
+     goofyPeakArea     (4),
+     goofyTemp                 (5),
+     goofyPressure     (6),
+     goofyVelocity     (7),
+     goofyGain                 (8),
+     goofyCO2          (9),
+     goofyN2           (10),
+     gasO2             (11),
+     gasOverpressure   (12),
+     envTemp           (13),
+     hvAnodeImon       (14),
+     hvDriftImon       (15),
+     hvAnodeUmon       (16),
+     hvDriftUmon       (17),
+     adcClkPhase       (18),
+     atmPressure       (19),
+     luminosity        (20),
+     magneticField     (21),
+     fNAlias           (22),
+     graphsAreIni      (false),
+     fitsAreIni        (false)
+{
+  Init ();
+}
+
+//_____________________________________________________________________________
+AliTRDDataDCS::~AliTRDDataDCS ()
+{
+  ClearFits ();
+  ClearGraphs ();
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::Init ()
+{
+  SetConf (chamberByteStatus, "trd_chamberByteStatus%03d", 'c', 540, true, false, 10,10,0,2); 
+  SetConf (preTrigger,                 "trd_preTrigger",               'c', 1, true, true,     10,10,0,2);
+  SetConf (goofyHv,                    "trd_goofyHv",                  'f', 1, true, true,     10,10,0,2);
+  SetConf (goofyPeakPos,               "trd_goofyPeakPos%02d", 'f', 2, true, true,     10,10,0,2);
+  SetConf (goofyPeakArea,      "trd_goofyPeakArea%02d",'f', 2, true, true,     10,10,0,2);
+  SetConf (goofyTemp,          "trd_goofyTemp%02d",    'f', 2, true, true,     10,10,0,2);
+  SetConf (goofyPressure,      "trd_goofyPressure",    'f', 1, true, true,     10,10,0,2);
+  SetConf (goofyVelocity,      "trd_goofyVelocity",    'f', 1, true, true,     10,10,0,2);
+  SetConf (goofyGain,          "trd_goofyGain%02d",    'f', 2, true, true,     10,10,0,2);
+  SetConf (goofyCO2,                   "trd_goofyCO2",                 'f', 1, true, true,     10,10,0,2);
+  SetConf (goofyN2,                    "trd_goofyN2",                  'f', 1, true, true,     10,10,0,2);
+  SetConf (gasO2,                      "trd_gasO2",                    'f', 1, true, true,     10,10,0,2);
+  SetConf (gasOverpressure,    "trd_gasOverpressure",  'f', 1, true, true,     10,10,0,2);
+  SetConf (envTemp,                    "trd_envTemp%03d",              'f', 540, true, true,   10,10,0,2);
+  SetConf (hvAnodeImon,                "trd_hvAnodeImon%03d",  'f', 540, true, true,   10,10,0,2);
+  SetConf (hvDriftImon,                "trd_hvDriftImon%03d",  'f', 540, true, true,   10,10,0,2);
+  SetConf (hvAnodeUmon,                "trd_hvAnodeUmon%03d",  'f', 540, true, true,   10,10,0,2);
+  SetConf (hvDriftUmon,                "trd_hvDriftUmon%03d",  'f', 540, true, true,   10,10,0,2);
+  SetConf (adcClkPhase,                "trd_adcClkPhase",              'f', 1, true, true,     10,10,0,2);
+  SetConf (atmPressure,                "trd_atmPressure",              'f', 1, true, true,     10,10,0,2);
+  SetConf (luminosity,                 "trd_luminosity",               'f', 1, true, true,     10,10,0,2);
+  SetConf (magneticField,      "trd_magneticField",    'f', 1, true, true,     10,10,0,2);             
+  
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
+    fDatas[iAlias].graph.SetOwner (1);
+    fDatas[iAlias].fit.SetOwner (1);
+  }
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::SetConf (UInt_t iAlias, const char * amanda, 
+                            char dataType, UInt_t nChannel, 
+                            Bool_t enableGraph, Bool_t enableFit, Int_t kMinPoints, 
+                            Int_t kIter, Double_t kMaxDelta, Int_t kFitReq)
+{
+  if (iAlias >= fNAlias) {
+    AliWarning (Form("Alias %d is not correct", iAlias));
+    return;
+  }
+  
+  fConfs[iAlias].amanda = amanda;
+  fConfs[iAlias].dataType = dataType;
+  fConfs[iAlias].nChannel = nChannel;
+  fConfs[iAlias].enableGraph = enableGraph;
+  fConfs[iAlias].enableFit = enableFit;
+  fConfs[iAlias].kMinPoints = kMinPoints;
+  fConfs[iAlias].kIter = kIter;
+  fConfs[iAlias].kMaxDelta = kMaxDelta;
+  fConfs[iAlias].kFitReq = kFitReq;
+  
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::InitFits ()
+{
+  if (fitsAreIni)
+    return;
+  
+  UInt_t nChannel;
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
+    nChannel = fConfs[iAlias].enableFit ? fConfs[iAlias].nChannel : 0;
+    fDatas[iAlias].fit.Expand (nChannel);      
+  }
+  
+  fitsAreIni = true;
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::InitGraphs ()
+{
+  if (graphsAreIni)
+    return;
+  
+  UInt_t nChannel;     
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
+    nChannel = fConfs[iAlias].enableGraph ? fConfs[iAlias].nChannel : 0;        
+    fDatas[iAlias].graph.Expand (nChannel);
+  }
+  
+  graphsAreIni = true;
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::ClearFits ()
+{
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
+    fDatas[iAlias].fit.Clear ();
+    fDatas[iAlias].fit.Expand (0);
+  }
+  
+  fitsAreIni = false;
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::ClearGraphs ()
+{      
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
+    fDatas[iAlias].graph.Clear ();
+    fDatas[iAlias].graph.Expand (0);
+  }
+  
+  graphsAreIni = false;
+}
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::Streamer(TBuffer &R__b) {
+  
+  if (R__b.IsReading()) {
+    
+    R__b.ReadBool (graphsAreIni);
+    R__b.ReadBool (fitsAreIni);
+    
+    
+    for (UInt_t iAlias=0; iAlias<fNAlias; iAlias++) {
+      TString::ReadString (R__b, TString::Class());
+      R__b.ReadChar (fConfs[iAlias].dataType);
+      R__b.ReadUInt (fConfs[iAlias].nChannel);
+      R__b.ReadBool (fConfs[iAlias].enableGraph);
+      R__b.ReadBool (fConfs[iAlias].enableFit);
+      R__b.ReadInt  (fConfs[iAlias].kMinPoints);
+      R__b.ReadInt  (fConfs[iAlias].kIter);
+      R__b.ReadDouble  (fConfs[iAlias].kMaxDelta);
+      R__b.ReadInt  (fConfs[iAlias].kFitReq);
+    }
+    
+    
+    if (graphsAreIni) {
+      for (UInt_t iAlias=0; iAlias<fNAlias; iAlias++)
+       fDatas[iAlias].graph = *(TObjArray*)R__b.ReadObject (TObjArray::Class());
+    }
+    
+    if (fitsAreIni) {
+      for (UInt_t iAlias=0; iAlias<fNAlias; iAlias++)
+       fDatas[iAlias].fit = *(TObjArray*)R__b.ReadObject (TObjArray::Class());
+    }
+    
+    AliInfo (Form("Read %d octets to the stream (%d Ko)", R__b.Length(), R__b.Length()/1024));
+    
+  } else {
+    R__b.WriteBool (graphsAreIni);
+    R__b.WriteBool (fitsAreIni);
+    
+    for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
+      TString::WriteString (R__b, &fConfs[iAlias].amanda);
+      R__b.WriteChar (fConfs[iAlias].dataType);
+      R__b.WriteUInt (fConfs[iAlias].nChannel);
+      R__b.WriteBool (fConfs[iAlias].enableGraph);
+      R__b.WriteBool (fConfs[iAlias].enableFit);
+      R__b.WriteInt  (fConfs[iAlias].kMinPoints);
+      R__b.WriteInt  (fConfs[iAlias].kIter);
+      R__b.WriteDouble  (fConfs[iAlias].kMaxDelta);
+      R__b.WriteInt  (fConfs[iAlias].kFitReq);
+    }
+    
+    if (graphsAreIni) {
+      for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) 
+       R__b.WriteObject ((TObject*)&fDatas[iAlias].graph);
+    }
+    
+    if (fitsAreIni) {
+      for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) 
+       R__b.WriteObject ((TObject*)&fDatas[iAlias].fit);
+    }
+    
+    AliInfo (Form("Write %d octets to the stream (%d Ko)", R__b.Length(), R__b.Length()/1024));
+  }
+}
+
+//_____________________________________________________________________________
+Bool_t AliTRDDataDCS::ExtractDCS (TMap * dcsAlias)
+{
+  if (dcsAlias == 0x0) {
+    AliWarning ("No DCS Map");
+    return kFALSE;
+  }
+  
+  ClearGraphs ();
+  InitGraphs ();
+  
+  TGraph * graphTemp;
+  UInt_t nChannel;
+  
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++){
+    
+    // extract dcs only when it is needed
+    nChannel = fDatas[iAlias].graph.GetSize ();
+    
+    for (UInt_t iSensor=0; iSensor < nChannel; iSensor++) {
+      
+      graphTemp = FindAndMakeGraph (dcsAlias, 
+                                   Form (fConfs[iAlias].amanda.Data(), iSensor), 
+                                   fConfs[iAlias].dataType); 
+      
+      fDatas[iAlias].graph.AddAt (graphTemp, iSensor);
+    }
+  }
+  
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+TGraph * AliTRDDataDCS::FindAndMakeGraph (TMap * dcsMap, const char * amandaStr, 
+                                         char dataType)
+{
+  TGraph * graph;
+  
+  TPair * pair = (TPair*)dcsMap->FindObject(amandaStr);
+  if (pair == 0x0) {
+    AliWarning (Form("Can't find %s in dcsMap", amandaStr));
+    return 0x0;
+  }
+  
+  TObjArray * valueSet = (TObjArray*)pair->Value();
+  
+  //
+  // Make graph of values read from DCS map
+  //   (spline fit parameters will subsequently be obtained from this graph) 
+  //
+  
+  Int_t nEntries = valueSet->GetEntriesFast();
+  if (nEntries == 0) {
+    AliWarning (Form("Entry %s in dcsMap contain no datas", amandaStr));
+    return 0x0;
+  }
+  
+  Float_t * x = new Float_t [nEntries];
+  Float_t * y = new Float_t [nEntries];
+  
+  Bool_t ok = true;
+  Int_t time0 = 0;
+  Int_t iEntries;
+  for (iEntries = 0;  iEntries< nEntries; iEntries++) {
+    
+    AliDCSValue * val = (AliDCSValue *)valueSet->At(iEntries);
+    
+    if (val == 0x0) { 
+      ok = false;
+      AliError (Form("Entry %s at %d contain no datas", amandaStr, iEntries));
+      break;
+    }
+    
+    if (time0 == 0) 
+      time0 = val->GetTimeStamp();
+    
+    
+    x[iEntries] = (val->GetTimeStamp() - time0)/3600.0; // give times in fractions of hours 
+    
+    switch (dataType) {
+    case 'f' :
+      y[iEntries] = val->GetFloat();
+      break;
+      
+    case 'c' :
+      y[iEntries] = (Float_t) val->GetChar();
+      break;
+      
+    default :
+      ok = false;
+      AliError (Form("Bad type for entry %s", amandaStr));
+      break;
+    }
+  }
+  
+  if (ok)
+    graph = new TGraph (iEntries, x, y);
+  else
+    graph = 0x0;
+  
+  delete [] x;
+  delete [] y;
+  
+  return graph;
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliTRDDataDCS::PerformFit ()
+{
+  AliSplineFit * fitTemp;
+  
+  ClearFits ();
+  InitFits ();
+  
+  UInt_t nChannel;
+  
+  for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++){
+    
+    // perform fit only when it is needed
+    nChannel = fDatas[iAlias].fit.GetSize ();
+    
+    for (UInt_t iSensor=0; iSensor < nChannel; iSensor++) {
+      
+      fitTemp = Fit ((TGraph*)fDatas[iAlias].graph[iSensor],
+                    fConfs[iAlias].kMinPoints,
+                    fConfs[iAlias].kIter,
+                    fConfs[iAlias].kMaxDelta,
+                    fConfs[iAlias].kFitReq); 
+      
+      if (fitTemp == 0x0)
+       AliInfo (Form ("Can't fit %s", Form (fConfs[iAlias].amanda.Data(), iSensor)));
+      
+      fDatas[iAlias].fit.AddAt (fitTemp, iSensor);
+    }
+  }
+  
+  return kTRUE;
+  
+}
+
+//_____________________________________________________________________________
+AliSplineFit * AliTRDDataDCS::Fit (TGraph * graph, 
+                                  Int_t  kMinPoints, Int_t  kIter, 
+                                  Double_t  kMaxDelta, Int_t  kFitReq)
+{
+  if (graph == 0x0) {
+    AliError ("No graph for fit");
+    return 0x0;
+  }
+  
+  AliSplineFit * spline = new AliSplineFit ();
+  spline->InitKnots (new TGraph (*graph), kMinPoints, kIter, kMaxDelta);
+  spline->SplineFit (kFitReq);
+  spline->Cleanup();   // delete also new TGraph (*graph)
+  
+  return spline;
+}
+
+
+//_____________________________________________________________________________
+void AliTRDDataDCS::Print (Option_t* option) const
+{
+  if (option[0]=='g' || option[0]=='\0'){
+    
+    if (graphsAreIni){
+      
+      for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++){
+       
+       for (Int_t iSensor = 0; iSensor < fDatas[iAlias].graph.GetSize(); iSensor++) {
+         
+         if (fDatas[iAlias].graph[iSensor] != 0x0)
+           AliInfo (Form("Graph %s contain %d point(s)", 
+                         Form(fConfs[iAlias].amanda, iSensor), 
+                         ((TGraph*)(fDatas[iAlias].graph[iSensor]))->GetN ()));
+       }
+      }
+    }else{
+      AliInfo ("Graphs don't exist");
+    }
+  }
+  
+  
+  if (option[0] == 'f' || option[0]=='\0'){
+    
+    AliInfo ("no print for fit");
+    
+  }
+  
+}
+
+//_____________________________________________________________________________
+TGraph * AliTRDDataDCS::GetGraph (UInt_t iAlias, UInt_t iChannel) const
+{
+  if (iAlias >= fNAlias) {
+    AliWarning (Form("Alias %d is not correct", iAlias));
+    return 0x0;
+  }
+  
+  if (iChannel >= (UInt_t)fDatas[iAlias].graph.GetSize()) {
+    AliWarning (Form("Alias %s is not correct", 
+                    Form(fConfs[iAlias].amanda.Data(), iChannel)));
+    return 0x0;
+  }
+  
+  return (TGraph *)fDatas[iAlias].graph[iChannel];
+}
+
+//_____________________________________________________________________________
+AliSplineFit * AliTRDDataDCS::GetFit (UInt_t iAlias, UInt_t iChannel) const
+{
+  if (iAlias >= fNAlias) {
+    AliWarning (Form("Alias %d is not correct", iAlias));
+    return 0x0;
+  }
+  
+  if (iChannel >= (UInt_t)fDatas[iAlias].fit.GetSize()) {
+    AliWarning (Form("Alias %s is not correct", 
+                    Form(fConfs[iAlias].amanda.Data(), iChannel)));
+    return 0x0;
+  }
+  
+  return (AliSplineFit *)fDatas[iAlias].fit[iChannel];
+}
+
+//_____________________________________________________________________________
+TString AliTRDDataDCS::GetAmandaStr (UInt_t iAlias) const 
+{
+  if (iAlias < fNAlias)
+    return fConfs[iAlias].amanda;
+  else return TString ();
+}
+
+//_____________________________________________________________________________
+UInt_t AliTRDDataDCS::GetNChannel (UInt_t iAlias) const 
+{
+  if (iAlias < fNAlias)
+    return fConfs[iAlias].nChannel;
+  else return 0;
+}
diff --git a/TRD/AliTRDDataDCS.h b/TRD/AliTRDDataDCS.h
new file mode 100644 (file)
index 0000000..5b94bad
--- /dev/null
@@ -0,0 +1,158 @@
+#ifndef AliTRDDataDCS_H
+#define AliTRDDAtaDCS_H
+
+#include <TNamed.h>
+#include <TObjArray.h>
+#include <TString.h>
+
+class TGraph;
+class AliSplineFit;
+class TMap;
+
+
+class AliTRDDataDCS : public TNamed
+{
+  
+  public :
+    
+    AliTRDDataDCS ();
+  ~AliTRDDataDCS ();
+  
+  Bool_t ExtractDCS (TMap * aliDCS);
+  Bool_t PerformFit ();
+  void   ClearFits ();
+  void   ClearGraphs ();
+  
+  UInt_t       GetNAlias () const {return fNAlias;}
+  TString       GetAmandaStr (UInt_t iAlias) const;
+  UInt_t       GetNChannel (UInt_t iAlias) const; 
+  
+  TGraph *             GetGraph (UInt_t iAlias, UInt_t iChannel = 0) const;
+  AliSplineFit *       GetFit (UInt_t iAlias, UInt_t iChannel = 0) const;
+  
+  // Get TGraph
+  TGraph * GetGraphChamberByteStatus (UInt_t iSensor) const            {return GetGraph (chamberByteStatus, iSensor);}
+  TGraph * GetGraphPreTrigger () const                                         {return GetGraph (preTrigger);}
+  TGraph * GetGraphGoofyHv () const                                    {return GetGraph (goofyHv);}
+  TGraph * GetGraphGoofyPeakPos (UInt_t iSensor) const                 {return GetGraph (goofyPeakPos, iSensor);}
+  TGraph * GetGraphGoofyPeakArea (UInt_t iSensor) const                {return GetGraph (goofyPeakArea, iSensor);}
+  TGraph * GetGraphGoofyTemp (UInt_t iSensor) const                    {return GetGraph (goofyTemp, iSensor);}
+  TGraph * GetGraphGoofyPressure () const                              {return GetGraph (goofyPressure);}
+  TGraph * GetGraphGoofyVelocity () const                              {return GetGraph (goofyVelocity);}
+  TGraph * GetGraphGoofyGain (UInt_t iSensor) const                    {return GetGraph (goofyGain, iSensor);}
+  TGraph * GetGraphGoofyCO2 ()  const                                  {return GetGraph (goofyCO2);}
+  TGraph * GetGraphGoofyN2 () const                                    {return GetGraph (goofyN2);}
+  TGraph * GetGraphGasO2 () const                                      {return GetGraph (gasO2);}
+  TGraph * GetGraphGasOverpressure () const                            {return GetGraph (gasOverpressure);}
+  TGraph * GetGraphEnvTemp (UInt_t iSensor) const                      {return GetGraph (envTemp, iSensor);}
+  TGraph * GetGraphHvAnodeImon (UInt_t iSensor) const                  {return GetGraph (hvAnodeImon, iSensor);}
+  TGraph * GetGraphHvDriftImon (UInt_t iSensor) const                  {return GetGraph (hvDriftImon, iSensor);}
+  TGraph * GetGraphHvAnodeUmon (UInt_t iSensor) const                  {return GetGraph (hvAnodeUmon, iSensor);}
+  TGraph * GetGraphHvDriftUmon (UInt_t iSensor) const                  {return GetGraph (hvDriftUmon, iSensor);}
+  TGraph * GetGraphAdcClkPhase () const                                {return GetGraph (adcClkPhase);}
+  TGraph * GetGraphAtmPressure () const                                {return GetGraph (atmPressure);}
+  TGraph * GetGraphLuminosity () const                                         {return GetGraph (luminosity);}
+  TGraph * GetGraphMagneticField () const                              {return GetGraph (magneticField);}
+  
+  AliSplineFit * GetFitChamberByteStatus (UInt_t iSensor) const                {return GetFit (chamberByteStatus, iSensor);}
+  AliSplineFit * GetFitPreTrigger () const                             {return GetFit (preTrigger);}
+  AliSplineFit * GetFitGoofyHv () const                                        {return GetFit (goofyHv);}
+  AliSplineFit * GetFitGoofyPeakPos (UInt_t iSensor) const             {return GetFit (goofyPeakPos, iSensor);}
+  AliSplineFit * GetFitGoofyPeakArea (UInt_t iSensor) const            {return GetFit (goofyPeakArea, iSensor);}
+  AliSplineFit * GetFitGoofyTemp (UInt_t iSensor) const                        {return GetFit (goofyTemp, iSensor);}
+  AliSplineFit * GetFitGoofyPressure () const                          {return GetFit (goofyPressure);}
+  AliSplineFit * GetFitGoofyVelocity () const                          {return GetFit (goofyVelocity);}
+  AliSplineFit * GetFitGoofyGain (UInt_t iSensor) const                        {return GetFit (goofyGain, iSensor);}
+  AliSplineFit * GetFitGoofyCO2 ()  const                              {return GetFit (goofyCO2);}
+  AliSplineFit * GetFitGoofyN2 () const                                {return GetFit (goofyN2);}
+  AliSplineFit * GetFitGasO2 () const                                  {return GetFit (gasO2);}
+  AliSplineFit * GetFitGasOverpressure () const                        {return GetFit (gasOverpressure);}
+  AliSplineFit * GetFitEnvTemp (UInt_t iSensor) const                  {return GetFit (envTemp, iSensor);}
+  AliSplineFit * GetFitHvAnodeImon (UInt_t iSensor) const              {return GetFit (hvAnodeImon, iSensor);}
+  AliSplineFit * GetFitHvDriftImon (UInt_t iSensor) const              {return GetFit (hvDriftImon, iSensor);}
+  AliSplineFit * GetFitHvAnodeUmon (UInt_t iSensor) const              {return GetFit (hvAnodeUmon, iSensor);}
+  AliSplineFit * GetFitHvDriftUmon (UInt_t iSensor) const              {return GetFit (hvDriftUmon, iSensor);}
+  AliSplineFit * GetFitAdcClkPhase () const                            {return GetFit (adcClkPhase);}
+  AliSplineFit * GetFitAtmPressure () const                            {return GetFit (atmPressure);}
+  AliSplineFit * GetFitLuminosity () const                             {return GetFit (luminosity);}
+  AliSplineFit * GetFitMagneticField () const                          {return GetFit (magneticField);}
+  
+  void Print (Option_t* option = "") const;
+  
+  
+  public :
+    
+    const UInt_t  chamberByteStatus;
+    const UInt_t  preTrigger;
+    const UInt_t  goofyHv;
+    const UInt_t  goofyPeakPos;
+    const UInt_t  goofyPeakArea;
+    const UInt_t  goofyTemp;
+    const UInt_t  goofyPressure;
+    const UInt_t  goofyVelocity;
+    const UInt_t  goofyGain;
+    const UInt_t  goofyCO2;
+    const UInt_t  goofyN2;
+    const UInt_t  gasO2;
+    const UInt_t  gasOverpressure;
+    const UInt_t  envTemp ;
+    const UInt_t  hvAnodeImon;
+    const UInt_t  hvDriftImon;
+    const UInt_t  hvAnodeUmon;
+    const UInt_t  hvDriftUmon;
+    const UInt_t  adcClkPhase;
+    const UInt_t  atmPressure;
+    const UInt_t  luminosity;
+    const UInt_t  magneticField;
+    const UInt_t  fNAlias;
+    
+    
+    
+    protected :
+      
+      private :
+      
+      TGraph * FindAndMakeGraph (TMap * dcsMap, const char * amandaStr,
+                                char dataType);
+    AliSplineFit * Fit (TGraph * graph,
+                       Int_t  kMinPoints, Int_t  kIter, 
+                       Double_t  kMaxDelta, Int_t  kFitReq);
+    
+    void Init ();
+    void InitFits ();
+    void InitGraphs ();
+    
+    void SetConf (UInt_t iAlias, const char * amanda, char dataType, UInt_t nChannel, 
+                 Bool_t enableGraph, Bool_t enableFit, Int_t kMinPoints, 
+                 Int_t kIter, Double_t kMaxDelta, Int_t kFitReq);
+    
+    private :
+      
+      Bool_t graphsAreIni;
+      Bool_t fitsAreIni;
+      
+      struct data {
+       TObjArray fit;                  // array of AliSplineFit
+       TObjArray graph;                // array of TGraph
+      };
+      
+      struct conf {
+       TString amanda;                 // amanda string
+       char dataType;                  // 'c' for char, 'f' for float
+       UInt_t nChannel;                // number of channel
+       Bool_t enableGraph;             // will be converted in TGraph
+       Bool_t enableFit;               // will be converted in AliSplineFit
+       Int_t  kMinPoints;              // minimum number of points per knot in fit
+       Int_t  kIter;                   // number of iterations for spline fit
+       Double_t  kMaxDelta;            // precision parameter for spline fit
+       Int_t  kFitReq;                 // fit requirement, 2 = continuous 2nd derivative
+      };
+      
+      data fDatas [22];                
+      conf fConfs [22];                        
+      
+      ClassDef(AliTRDDataDCS,1)         //  TRD calibration class
+       
+       };
+
+#endif
index 4f11c4a15862957da407efbb96d936c5f25757df..af89c5ab74a5726caadf074c020bb2958e4e935c 100644 (file)
 // It takes data from HLT and computes the parameters                     //
 // and stores both reference data and online calibration                  //
 // parameters in the CDB                                                  //
+// It alsotakes DCS data, does spline fits                                //
+// and stores both reference data and spline fits results                 //
+// in the CDB                                                             //
 //                                                                        //
 // Author:                                                                //
 //   R. Bailhache (R.Bailhache@gsi.de)                                    //
+//   W. Monange   (wilfried.monange@free.fr)                              //
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
@@ -45,6 +49,7 @@
 
 #include "AliTRDCalibraFit.h"
 #include "AliTRDCalibraMode.h"
+#include "AliTRDDataDCS.h"
 #include "Cal/AliTRDCalDet.h"
 
 ClassImp(AliTRDPreprocessor)
@@ -80,8 +85,50 @@ void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
 }
 
 //______________________________________________________________________________________________
-UInt_t AliTRDPreprocessor::Process(TMap* /*dcsAliasMap*/)
+UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
 {
+  //
+  // Process DCS and calibration part for HLT
+  //
+
+  UInt_t result = 0;
+
+  //
+  // DCS
+  //
+  AliTRDDataDCS dataRef;
+
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
+  metaData.SetComment("TRD calib test");
+
+  if (dataRef.ExtractDCS (dcsAliasMap)) {
+
+    if (!StoreReferenceData("Calib", "DataRef", &dataRef, &metaData)) {
+      AliError("Problem during StoreRef DCS");
+      result |= EStoreRefDCS;
+    }
+
+    if (dataRef.PerformFit()) {
+      if(!Store("Calib", "Data", &dataRef, &metaData, 0, 0)) {
+        AliError("Problem during Store DCS");
+        result |=EStoreDCS;
+      }
+    }else {
+      AliError("Problem during PerformFit DCS");
+      result |= EFitDCS;
+    }
+
+    dataRef.ClearFits();
+
+  }else {
+    AliError ("Problem during ExtractDCS");
+    result |= EExtractDCS;
+  }
+
+  dataRef.ClearGraphs();
+
   //
   // Process the calibration data for the HLT part
   //
@@ -107,13 +154,6 @@ UInt_t AliTRDPreprocessor::Process(TMap* /*dcsAliasMap*/)
     Log(Form("Number of events not put in logbook!"));
   }
 
-
-  // Metadata for the reference data
-  AliCDBMetaData metaData;
-  metaData.SetBeamPeriod(1);
-  metaData.SetResponsible("Raphaelle Bailhache");
-  metaData.SetComment("This preprocessor fills reference data.");
-
   // Take the file from the HLT file exchange server
   TList *filesources = GetFileSources(kHLT,"GAINDRIFTPRF");
   if (!filesources) {
index 37fa2516ded50cffc219bebb30ebad69e3ee7e20..441e8a222db861872162435c91b105a854be14d9 100644 (file)
@@ -22,14 +22,27 @@ class AliTRDPreprocessor : public AliPreprocessor
     AliTRDPreprocessor(AliShuttleInterface *shuttle);
     virtual ~AliTRDPreprocessor();
 
+    enum {
+       EExtractDCS    =   1  // error in case of failure by extracting DCS variables
+      ,EStoreRefDCS   =   2  // error in case of failure by storing DCS variables references
+      ,EFitDCS        =   4  // error in case of failure by fitting DCS variables
+      ,EStoreDCS      =   8  // error in case of failure by storing DCS variables fit results
+      ,EListFileHLT   =  16  // error in case of failure by taking the listof HLT files
+      ,EOpenFileHLT   =  32  // error in case of failure by opening the HLTfile
+      ,ETakeHistoHLT  =  64  // error in case of failure by taking the histos HLT
+      ,EStoreHistoHLT = 128  // error in case of failure by storing the reference data HLT
+      ,EFitHistoHLT   = 256  // error in case of failure by fitting the histos HLT
+      ,EStoreCalHLT   = 512  // error in case of failure by storing the HLTcal objects
+    };
+
   protected:
 
     virtual void   Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
-    virtual UInt_t Process(TMap* /*dcsAliasMap*/);
-  
+    virtual UInt_t Process(TMap* dcsAliasMap);
+
   private:
     
-    ClassDef(AliTRDPreprocessor,0) // The SHUTTLE preprocessor for TRD
+    ClassDef(AliTRDPreprocessor,1) // The SHUTTLE preprocessor for TRD
 
 };
 
index a95802c54024b8670fdf52997b08f6b203f927b7..46daf7d44854531f99d13e768102f16ae447b8ec 100644 (file)
@@ -49,6 +49,7 @@
 #pragma link C++ class  AliTRDCalibraMode+;
 #pragma link C++ class  AliTRDCalibraVector+;
 #pragma link C++ class  AliTRDCalibPadStatus+;
+#pragma link C++ class  AliTRDDataDCS+;
 #pragma link C++ class  AliTRDPreprocessor+;
 
 #pragma link C++ class  AliTRDTriggerL1+;
index ebe0209298ce0077a97470be406e6e30e90de982..f61f2ef19b1ddd54bc4c3bac99c39531452b4b63 100644 (file)
@@ -29,6 +29,7 @@ SRCS= AliTRDarrayI.cxx \
       AliTRDCalibraMode.cxx \
       AliTRDCalibraVector.cxx \
       AliTRDCalibPadStatus.cxx \
+      AliTRDDataDCS.cxx \
       AliTRDPreprocessor.cxx \
       AliTRDalignment.cxx \
       AliTRDTriggerL1.cxx \