]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/exa/makeComponentConfigurationObject.C
- switching MultFinder depending on 'ITS' in reconstruction recraw-local.C
[u/mrichter/AliRoot.git] / HLT / exa / makeComponentConfigurationObject.C
CommitLineData
9bdcc572 1// $Id$
2/**
3 * @file makeComponentConfigurationObject.C
4 * @brief Creation of HLT component configuration objects in OCDB
5 *
6 * <pre>
12fe5aa8 7 * Usage:
8 * aliroot -b -q makeComponentConfigurationObject.C'("path", "param", "uri", runmin, runmax)'
9 * aliroot -b -q makeComponentConfigurationObject.C'("path", "key", "param", "uri", runmin, runmax)'
9bdcc572 10 * </pre>
11 *
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.
12fe5aa8 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.
9bdcc572 19 *
20 * Parameters: <br>
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
26 *
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.
30 *
31 * @author Matthias.Richter@ift.uib.no
32 * @ingroup alihlt_tutorial
33 */
12fe5aa8 34void makeComponentConfigurationObject(const char* path,
35 const char* key,
36 const char* param,
37 const char* cdbUri,
9bdcc572 38 int runmin=0,
12fe5aa8 39 int runmax=999999999,
40 int runNo=0)
9bdcc572 41{
42 AliCDBManager* man = AliCDBManager::Instance();
43 if (!man) {
44 cerr << "can not get AliCDBManager" << end;
45 exit;
46 }
47 TString storage;
48 if (!man->IsDefaultStorageSet()) {
49 if (cdbUri) {
50 storage=cdbUri;
84683b66 51 if (storage.Contains("://")==0) {
9bdcc572 52 storage="local://"; storage+=cdbUri;
53 }
54 } else {
55 storage="local://$ALICE_ROOT/OCDB";
56 }
57 man->SetDefaultStorage(storage);
58 } else {
59 storage = man->GetDefaultStorage()->GetURI();
60 }
61
12fe5aa8 62 TMap* pMap=NULL;
63
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();
71 }
72 }
73
74 if (key && !pMap) pMap=new TMap;
75
9bdcc572 76 // here is the actual content of the configuration object
12fe5aa8 77 TObject* obj=new TObjString(param);
78 if (pMap) {
79 if (pMap->FindObject(key)) {
80 pMap->Remove(new TObjString(key));
81 }
82 pMap->Add(new TObjString(key), obj);
83 obj=pMap;
84 }
85
9bdcc572 86 AliCDBPath cdbPath(path);
87 AliCDBId cdbId(cdbPath, runmin, runmax);
12fe5aa8 88 AliCDBMetaData* cdbMetaData=pExisting?pExisting->GetMetaData():(new AliCDBMetaData);
89 man->Put(obj, cdbId, cdbMetaData);
90}
91
92void makeComponentConfigurationObject(const char* path, const char* param="",
93 const char* cdbUri=NULL,
94 int runmin=0,
95 int runmax=999999999)
96{
97 makeComponentConfigurationObject(path, param, NULL, cdbUri, runmin, runmax);
98}
99
100void makeComponentConfigurationObject(const char* path,
101 int runNo,
102 const char* key,
103 const char* param)
104{
105 makeComponentConfigurationObject(path, key, param, NULL, 0, 999999999, runNo);
9bdcc572 106}
107
108void makeComponentConfigurationObject()
109{
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;
a51a0599 114 cout << " uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
9bdcc572 115 cout << " rangemin (opt) default 0" << endl;
116 cout << " rangemax (opt) default 999999999" << endl;
117 cout << "===============================================================" << endl;
12fe5aa8 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;
9bdcc572 125}