]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - GRP/UpdateCDBCTPConfig.C
Macro to generate the CTP configuiration and put it in CDB
[u/mrichter/AliRoot.git] / GRP / UpdateCDBCTPConfig.C
diff --git a/GRP/UpdateCDBCTPConfig.C b/GRP/UpdateCDBCTPConfig.C
new file mode 100644 (file)
index 0000000..1bb6d3c
--- /dev/null
@@ -0,0 +1,43 @@
+void UpdateCDBCTPConfig(const char *CTPcfg, const char* cdbUri, const char* cfgFile){
+  // Produces a trigger configuration starting from a 'cfg' file in the
+  // GRP/CTP folder (CTPcfg argument). Stores the configuration in the specified CDB.
+  // The third argument allows to specify the config file against which
+  // the trigger confiuration is checked.
+
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  // we set the default storage to the repository because some dets require
+  // already at the time of geometry creation to find calibration objects in the cdb
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+  AliCDBStorage* storage = cdb->GetStorage(cdbUri);
+  cdb->SetRun(0);
+  AliCDBId id("GRP/CTP/Config",0,AliCDBRunRange::Infinity());
+  AliCDBMetaData *md= new AliCDBMetaData();
+
+  // Get root and AliRoot versions
+  const char* rootv = gROOT->GetVersion();
+  gROOT->ProcessLine(".L $ALICE_ROOT/macros/GetARversion.C");
+  TString av(GetARversion());
+
+  md->SetAliRootVersion(av.Data());
+  md->SetComment(Form("Default CTP configuration for p-p mode produced with root version %s and AliRoot version %s",rootv,av.Data()));
+  
+  // construct the CTP configuration starting from GRP/CTP/<CTPcfg>.cfg file
+  AliTriggerConfiguration *trconfig = AliTriggerConfiguration::LoadConfiguration(CTPcfg);
+  if (!trconfig) {
+    Printf("Invalid cfg file! Exiting...");
+    return;
+  }
+  if (!trconfig->CheckConfiguration(cfgFile)) {
+    Printf("CTP configuration is incompatible with the specified Config.C and AliRoot version! Exiting...");
+    return;
+  }
+  
+  Printf("Storing in CDB geometry produced with root version %s and AliRoot version %s",rootv,av.Data());
+  storage->Put(trconfig,id,md);
+  // This is to allow macros lauched after this one in the same session to find the
+  // newly produced geometry.
+  storage->QueryCDB(cdb->GetRun());
+
+}
+
+