AliRoot Core  edcc906 (edcc906)
UpdateCDBCTPConfig.C
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
52 
53 #if !defined(__CINT__) || defined(__MAKECINT__)
54 #include "ARVersion.h"
55 #include "AliCDBManager.h"
56 #include "AliCDBStorage.h"
57 #include "AliCDBEntry.h"
58 #include "AliCDBId.h"
59 #include "AliCDBMetaData.h"
61 #include "AliTriggerUtils.h"
62 #include "AliSimulation.h"
63 #include <TROOT.h>
64 #include <TString.h>
65 #include <TSystem.h>
66 #endif
67 
68 void UpdateCDBCTPConfig(Bool_t check = false) {
69 
70  // AliSimulation object must exist, as it is used via AliMC
71  // which is used in AliTriggerUtils::CheckConfiguration()
73 
75  cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
76  cdb->SetRun(0);
77 
78  if (check) {
79  // current entry in GRP/CTP/Config trigger configuration
80  AliCDBEntry *entry;
81  entry = cdb->Get("GRP/CTP/Config");
82  AliCDBMetaData *md = entry->GetMetaData();
83  Printf("AliRoot version: %s",md->GetAliRootVersion());
84  Printf("Comment: %s ",md->GetComment());
85  Printf("Responsible: %s ",md->GetResponsible());
86  return;
87  }
88 
89  const Char_t* alice = gSystem->Getenv("ALICE_ROOT");
90 
91  // construct the CTP configuration starting from GRP/CTP/<CTPcfg>.cfg file
92 
93  // Config.C detector configuration
94  TString cfgFile(Form("%s/MUON/macros/Config.C",alice));
95 
96  // MUON.cfg trigger configuration
97  TString cfgCTP(Form("%s/GRP/CTP/MUON.cfg",alice));
98 
100  if (!trconfig) {
101  Printf("Invalid cfg file! Exiting...");
102  return;
103  }
104 
105  // check if Config.C is compatible with the trigger configuration requested
106  AliTriggerUtils tru;
107  if (!tru.CheckConfiguration(cfgFile,trconfig)) {
108  Printf("CTP configuration is incompatible with the specified Config.C and AliRoot version! Exiting...");
109  return;
110  }
111 
112  // put the new trigger configuration "trconfig" in the GRP/CTP/Config
113 
114  AliCDBId id("GRP/CTP/Config",0,AliCDBRunRange::Infinity());
115  AliCDBMetaData *md= new AliCDBMetaData();
116 
117  // ROOT and AliRoot versions
118  const char* rootv = gROOT->GetVersion();
119  TString av(ALIROOT_VERSION);
120  TString revnum(ALIROOT_REVISION);
121 
122  Printf("root version: %s. AliRoot %s, revision number %s",rootv,av.Data(),revnum.Data());
123 
124  md->SetAliRootVersion(av.Data());
125  md->SetComment(Form("Default CTP configuration for MUON mode produced with root version %s and AliRoot version %s revision %s ",rootv,av.Data(),revnum.Data()));
126 
127  AliCDBStorage* storage = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
128  storage->Put(trconfig,id,md);
129 
130 }
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
TROOT * gROOT
const char * GetComment() const
void SetComment(const char *comment)
static AliTriggerConfiguration * LoadConfiguration(TString &des)
void sim(char *configPath, char *tpcDbpath, Int_t nevents)
Definition: sim.C:3
Bool_t CheckConfiguration(TString &configfile, AliTriggerConfiguration *cfg)
AliCDBEntry * Get(const AliCDBId &query, Bool_t forceCaching=kFALSE)
AliCDBStorage * GetStorage(const char *dbString)
void UpdateCDBCTPConfig(Bool_t check=false)
void SetAliRootVersion(const char *version)
void SetRun(Int_t run)
Definition: AliCDBEntry.h:18
void SetDefaultStorage(const char *dbString)
const char * GetResponsible() const
AliCDBMetaData * GetMetaData()
Definition: AliCDBEntry.h:60
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
const char * GetAliRootVersion() const
static Int_t Infinity()