- OCDB-related code for TRAPconfig
authorjklein <jklein@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 31 Mar 2012 10:06:15 +0000 (10:06 +0000)
committerjklein <jklein@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 31 Mar 2012 10:06:15 +0000 (10:06 +0000)
OCDB/TRD/Calib/TrapConfig/Run0_999999999_v0_s0.root [new file with mode: 0644]
TRD/AliTRDcalibDB.cxx
TRD/AliTRDcalibDB.h
TRD/CMakelibTRDbase.pkg
TRD/Cal/AliTRDCalTrapConfig.cxx [new file with mode: 0644]
TRD/Cal/AliTRDCalTrapConfig.h [new file with mode: 0644]
TRD/Macros/AliTRDcreateTrapConfigCDB.C [new file with mode: 0644]
TRD/TRDbaseLinkDef.h

diff --git a/OCDB/TRD/Calib/TrapConfig/Run0_999999999_v0_s0.root b/OCDB/TRD/Calib/TrapConfig/Run0_999999999_v0_s0.root
new file mode 100644 (file)
index 0000000..bbe58fa
Binary files /dev/null and b/OCDB/TRD/Calib/TrapConfig/Run0_999999999_v0_s0.root differ
index 1b229df..b8133ac 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "AliTRDPIDReference.h"
 #include "AliTRDcalibDB.h"
+#include "AliTRDtrapConfig.h"
+#include "AliTRDtrapConfigHandler.h"
 #include "AliTRDCommonParam.h"
 
 #include "Cal/AliTRDCalROC.h"
@@ -109,6 +111,7 @@ AliTRDcalibDB::AliTRDcalibDB()
   ,fPRFpad(0)
   ,fPIDResponse(NULL)
   ,fOnlineGainTableID(0)
+  ,fTrapConfig(0x0)
 {
   //
   // Default constructor
@@ -140,6 +143,7 @@ AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
   ,fPRFpad(0)
   ,fPIDResponse(NULL)
   ,fOnlineGainTableID(0)
+  ,fTrapConfig(0x0)
 {
   //
   // Copy constructor (not that it make any sense for a singleton...)
@@ -303,6 +307,9 @@ const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
     case kIDFEE : 
       return CacheCDBEntry(kIDFEE               ,"TRD/Calib/FEE"); 
       break;
+    case kIDTrapConfig :
+      return CacheCDBEntry(kIDFEE               ,"TRD/Calib/TrapConfig"); 
+      break;
     case kIDDCS :
       return CacheCDBEntry(kIDDCS               ,"TRD/Calib/DCS");
       break;
@@ -1743,3 +1750,57 @@ Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
 }
 
 
+AliTRDtrapConfig* AliTRDcalibDB::GetTrapConfig()
+{
+  // return an existing TRAPconfig or load it from the OCDB
+  // in case of failure, a default TRAPconfig is created
+
+  if (fTrapConfig)
+    return fTrapConfig;
+  else {
+    // query the configuration to be used
+    TString configName;
+    this->GetGlobalConfiguration(configName);
+    TString configVersion;
+    this->GetGlobalConfigurationVersion(configVersion);
+
+    this->LoadTrapConfig(configName, configVersion);
+
+    // if we still don't have a valid TRAPconfig, create a default one
+    if (!fTrapConfig) {
+      AliWarning("Falling back to default configuration");
+      fTrapConfig = new AliTRDtrapConfig("default", "default TRAP configuration");
+      AliTRDtrapConfigHandler cfgHandler(fTrapConfig);
+      cfgHandler.Init();
+      cfgHandler.LoadConfig();
+    }
+
+    AliInfo(Form("using TRAPconfig \"%s\"", fTrapConfig->GetTitle()));
+
+    return fTrapConfig;
+  }
+}
+
+
+AliTRDtrapConfig* AliTRDcalibDB::LoadTrapConfig(const TString &name, const TString &version)
+{
+  // try to load the specified configuration from the OCDB
+  // if it fails, or it does not exist, return null
+
+  AliInfo(Form("looking for TRAPconfig \"%s.%s\"", name.Data(), version.Data()));
+
+  const AliTRDCalTrapConfig *caltrap = dynamic_cast<const AliTRDCalTrapConfig*> (GetCachedCDBObject(kIDTrapConfig));
+
+  if (caltrap) {
+    TString configName(name);
+    configName.Append(".");
+    configName.Append(version);
+    fTrapConfig = caltrap->Get(configName);
+  }
+  else {
+    fTrapConfig = 0x0;
+    AliError("No TRAPconfig entry found!");
+  }
+
+  return fTrapConfig;
+}
index debe520..5a9db47 100644 (file)
@@ -23,6 +23,9 @@
 #include "AliTRDPIDResponse.h"
 #endif
 
+#include "AliTRDCalTrapConfig.h"
+#include "AliTRDtrapConfig.h"
+
 class TString;
 
 class AliCDBEntry;
@@ -119,6 +122,10 @@ class AliTRDcalibDB : public TObject {
   Int_t                               PadResponse(Double_t signal, Double_t dist
                                                 , Int_t layer, Double_t *pad) const;
 
+  AliTRDtrapConfig*                   GetTrapConfig();
+  void                                SetTrapConfig(AliTRDtrapConfig *trapcfg) { fTrapConfig = trapcfg; }
+  AliTRDtrapConfig*                   LoadTrapConfig(const TString &name = "", const TString &version = "");
+
  protected:
 
   // For caching see also implentation of GetCachedCDBObject in the .cxx file
@@ -134,6 +141,7 @@ class AliTRDcalibDB : public TObject {
        , kIDNoisePad
        , kIDPRFWidth
        , kIDFEE
+       , kIDTrapConfig
        , kIDChamberPos
        , kIDStackPos
        , kIDSuperModulePos
@@ -175,6 +183,8 @@ class AliTRDcalibDB : public TObject {
   AliTRDPIDResponse    *fPIDResponse;               //  TRD PID Response function
 
   Int_t                 fOnlineGainTableID;         //  ID for online gain table 
+
+  AliTRDtrapConfig*     fTrapConfig;                //  TRAP configuration
   
  private:
 
index 0d2aaaf..f50fb97 100644 (file)
@@ -69,6 +69,7 @@ set ( SRCS
     Cal/AliTRDCalOnlineGainTableROC.cxx
     Cal/AliTRDCalOnlineGainTableMCM.cxx
     Cal/AliTRDCalOnlineGainTableROC.h
+    Cal/AliTRDCalTrapConfig.cxx
     AliTRDCalibraFit.cxx
     AliTRDCalibraMode.cxx
     AliTRDCalibraVector.cxx
diff --git a/TRD/Cal/AliTRDCalTrapConfig.cxx b/TRD/Cal/AliTRDCalTrapConfig.cxx
new file mode 100644 (file)
index 0000000..32c4ef1
--- /dev/null
@@ -0,0 +1,34 @@
+#include "TString.h"
+
+#include "AliLog.h"
+#include "AliTRDCalTrapConfig.h"
+
+ClassImp(AliTRDCalTrapConfig)
+
+AliTRDCalTrapConfig::AliTRDCalTrapConfig() :
+  TObject(),
+  fConfigList()
+{
+  // ctor
+
+}
+
+AliTRDCalTrapConfig::~AliTRDCalTrapConfig()
+{
+  // dtor
+
+}
+
+AliTRDtrapConfig* AliTRDCalTrapConfig::Get(const TString &name) const
+{
+  return (AliTRDtrapConfig*) fConfigList.FindObject(name.Data());
+}
+
+void AliTRDCalTrapConfig::Print(Option_t * /* option */) const
+{
+  TIter config(&fConfigList);
+
+  while (AliTRDtrapConfig *cfg = (AliTRDtrapConfig*) config()) {
+    AliInfo(Form("found TRAPconfig: %s - %s", cfg->GetName(), cfg->GetTitle()));
+  }
+}
diff --git a/TRD/Cal/AliTRDCalTrapConfig.h b/TRD/Cal/AliTRDCalTrapConfig.h
new file mode 100644 (file)
index 0000000..f1a4d5e
--- /dev/null
@@ -0,0 +1,30 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#ifndef ALITRDCALTRAPCONFIG
+#define ALITRDCALTRAPCONFIG
+
+#include "TObject.h"
+#include "TList.h"
+
+#include "AliTRDtrapConfig.h"
+
+class AliTRDCalTrapConfig : public TObject
+{
+public:
+  AliTRDCalTrapConfig();
+  ~AliTRDCalTrapConfig();
+
+  void Add(AliTRDtrapConfig *cfg) { fConfigList.Add(cfg); }
+
+  virtual void Print(Option_t *option = "") const;
+
+  AliTRDtrapConfig* Get(const TString &name) const;
+
+protected:
+  TList fConfigList;
+
+  ClassDef(AliTRDCalTrapConfig, 1);
+};
+
+#endif
diff --git a/TRD/Macros/AliTRDcreateTrapConfigCDB.C b/TRD/Macros/AliTRDcreateTrapConfigCDB.C
new file mode 100644 (file)
index 0000000..95472eb
--- /dev/null
@@ -0,0 +1,45 @@
+void AliTRDcreateTrapConfigCDB(const TString &dirname = ".") {
+
+  TString initName("initialize.r3610");
+  TRegexp initCheck("initialize.r[0-9]*$");
+  TRegexp cfgCheck("cf_.*.r[0-9]*$");
+
+  AliTRDCalTrapConfig *caltrap = new AliTRDCalTrapConfig();
+
+  TList cfgList;
+
+  void *dirhandle = gSystem->OpenDirectory(dirname);
+
+  const char* filename;
+  while (filename = gSystem->GetDirEntry(dirhandle)) {
+    TString file(filename);
+    if (file.Contains(initCheck)) {
+      initName = file;
+      continue;
+    }
+
+    if (file.Contains(cfgCheck)) {
+      cfgList.Add(new TObjString(file));
+    }
+  }
+
+  TIter cfgIter(&cfgList);
+
+  TObjString *cfgName = 0x0;
+  while (cfgName = (TObjString*) cfgIter()) {
+    ::Info("createTrapConfigCDB", Form("adding config: %s", cfgName->GetString().Data()));
+    AliTRDtrapConfig *cfg = new AliTRDtrapConfig(cfgName->GetString(), cfgName->GetString());
+    AliTRDtrapConfigHandler cfgHandler(cfg);
+    cfgHandler.ResetMCMs();
+    cfgHandler.Init();
+    cfgHandler.LoadConfig(dirname + "/" + initName);
+    cfgHandler.LoadConfig(dirname + "/" + cfgName->GetString());
+    caltrap->Add(cfg);
+  }
+
+  AliCDBMetaData *cdbMeta = new AliCDBMetaData("Jochen Klein <jochen.klein@cern.ch>");
+  AliCDBId cdbId("TRD/Calib/TrapConfig", 0, 999999999);;
+
+  AliCDBStorage *storage = AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
+  storage->Put(caltrap, cdbId, cdbMeta);
+}
index a167919..604d9fc 100644 (file)
@@ -54,6 +54,7 @@
 #pragma link C++ class  AliTRDCalOnlineGainTable+;
 #pragma link C++ class  AliTRDCalOnlineGainTableROC+;
 #pragma link C++ class  AliTRDCalOnlineGainTableMCM+;
+#pragma link C++ class  AliTRDCalTrapConfig+;
 
 #pragma link C++ class  AliTRDCalChamberStatus+;
 #pragma link C++ class  AliTRDCalPadStatus+;