3 * @file makeComponentConfigurationObject.C
4 * @brief Creation of HLT component configuration objects in OCDB
8 * aliroot -b -q makeComponentConfigurationObject.C'("path", "param", "uri", runmin, runmax)'
9 * aliroot -b -q makeComponentConfigurationObject.C'("path", "key", "param", "uri", runmin, runmax)'
12 * Create an OCDB entry with a TObjString containing param.
13 * Many HLT components understand configuration strings containing
14 * arguments and parameters just like the command line arguments.
15 * This macro facilitates the creation of an appropriate object
16 * from a parameter string.
17 * As another approach the TObjString parameters are stored in a TMap
18 * associated to a key. A TMap object is generated if 'key' is specified.
21 * - path path of the entry within the OCDB
22 * - param (opt) string to be stored in the TObjSting, default empty
23 * - uri (opt) the OCDB URI, default $ALICE_ROOT
24 * - runmin (opt) default 0
25 * - runmax (opt) default 999999999
27 * Note: The configuration procedure of an HLT component is not
28 * restricted to that scheme. The implementation is up to the
29 * developer and more complex objects are possible.
31 * @author Matthias.Richter@ift.uib.no
32 * @ingroup alihlt_tutorial
34 void makeComponentConfigurationObject(const char* path,
42 AliCDBManager* man = AliCDBManager::Instance();
44 cerr << "can not get AliCDBManager" << end;
48 if (!man->IsDefaultStorageSet()) {
51 if (storage.Contains("://")==0) {
52 storage="local://"; storage+=cdbUri;
55 storage="local://$ALICE_ROOT/OCDB";
57 man->SetDefaultStorage(storage);
59 storage = man->GetDefaultStorage()->GetURI();
64 // load existing object and init TMap
65 AliCDBEntry* pExisting=NULL;
66 AliCDBStorage* pStorage=AliCDBManager::Instance()->GetDefaultStorage();
67 if (key && pStorage->GetLatestVersion(path, runNo)>=0) {
68 pExisting=pStorage->Get(path, runNo);
69 if (pExisting->GetObject()->IsA() == TMap::Class()) {
70 pMap=(TMap*)pExisting->GetObject()->Clone();
74 if (key && !pMap) pMap=new TMap;
76 // here is the actual content of the configuration object
77 TObject* obj=new TObjString(param);
79 if (pMap->FindObject(key)) {
80 pMap->Remove(new TObjString(key));
82 pMap->Add(new TObjString(key), obj);
86 AliCDBPath cdbPath(path);
87 AliCDBId cdbId(cdbPath, runmin, runmax);
88 AliCDBMetaData* cdbMetaData=pExisting?pExisting->GetMetaData():(new AliCDBMetaData);
89 man->Put(obj, cdbId, cdbMetaData);
92 void makeComponentConfigurationObject(const char* path, const char* param="",
93 const char* cdbUri=NULL,
97 makeComponentConfigurationObject(path, param, NULL, cdbUri, runmin, runmax);
100 void makeComponentConfigurationObject(const char* path,
105 makeComponentConfigurationObject(path, key, param, NULL, 0, 999999999, runNo);
108 void makeComponentConfigurationObject()
110 cout << "===============================================================" << endl;
111 cout << "usage: aliroot -b -q -l makeComponentConfigurationObject.C'(\"path\", \"param\", \"uri\", rangemin, rangemax)'" << endl << endl;
112 cout << " path path of the entry within the OCDB" << endl;
113 cout << " param (opt) string to be stored in the TObjSting, default empty" << endl;
114 cout << " uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
115 cout << " rangemin (opt) default 0" << endl;
116 cout << " rangemax (opt) default 999999999" << endl;
117 cout << "===============================================================" << endl;
118 cout << "usage: aliroot -b -q -l makeComponentConfigurationObject.C'(\"path\", \"key\", \"param\", \"uri\", rangemin, rangemax)'" << endl << endl;
119 cout << " path path of the entry within the OCDB" << endl;
120 cout << " param (opt) string to be stored in the TObjSting, default empty" << endl;
121 cout << " uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
122 cout << " rangemin (opt) default 0" << endl;
123 cout << " rangemax (opt) default 999999999" << endl;
124 cout << "===============================================================" << endl;