- macro for creating OCDB configuration objects of the GlobalHisto component
[u/mrichter/AliRoot.git] / HLT / global / macros / makeGlobalHistoConfigObject.C
CommitLineData
efdf9202 1// $Id$
2/**
3 * @file makeGlobalHistoConfigObject.C
4 * @brief Creation of Global Histo component configuration objects in OCDB
5 *
6 * <pre>
7 * Usage:
8 * aliroot -b -q makeGlobalHistoConfigObject.C'("path", "key", "uri", runmin, runmax)'
9 * </pre>
10 *
11 * Create an OCDB entry with a TObjString containing param.
12 * Many HLT components understand configuration strings containing
13 * arguments and parameters just like the command line arguments.
14 * This macro facilitates the creation of an appropriate object
15 * from a parameter string.
16 * As another approach the TObjString parameters are stored in a TMap
17 * associated to a key. A TMap object is generated if 'key' is specified.
18 *
19 * Parameters: <br>
20 * - path path of the entry within the OCDB (e.g. HLT/ConfigHLT/GlobalHisto)
21 * - uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB
22 * - runmin (opt) default 0
23 * - runmax (opt) default 999999999
24 * The parameters of the component configuration should be defined inside function makeString().
25 *
26 * Note: The configuration procedure of an HLT component is not
27 * restricted to that scheme. The implementation is up to the
28 * developer and more complex objects are possible.
29 *
30 * @author Kalliopi.Kanaki@ift.uib.no
31 * @ingroup alihlt_tutorial
32 */
33void makeGlobalHistoConfigObject(const char* path,
34 const char* key,
35 //const char* param,
36 const char* cdbUri,
37 int runmin=0,
38 int runmax=999999999,
39 int runNo=0)
40{
41 AliCDBManager* man = AliCDBManager::Instance();
42 if (!man) {
43 cerr << "Cannot get AliCDBManager." << end;
44 exit;
45 }
46 TString storage;
47 if (!man->IsDefaultStorageSet()) {
48 if (cdbUri) {
49 storage=cdbUri;
50 if (storage.Contains("://")==0) {
51 storage="local://"; storage+=cdbUri;
52 }
53 } else {
54 storage="local://$ALICE_ROOT/OCDB";
55 }
56 man->SetDefaultStorage(storage);
57 } else {
58 storage = man->GetDefaultStorage()->GetURI();
59 }
60
61 TMap* pMap=NULL;
62
63 // load existing object and init TMap
64 AliCDBEntry* pExisting=NULL;
65 AliCDBStorage* pStorage=AliCDBManager::Instance()->GetDefaultStorage();
66 if (key && pStorage->GetLatestVersion(path, runNo)>=0) {
67 pExisting=pStorage->Get(path, runNo);
68 if (pExisting->GetObject()->IsA() == TMap::Class()) {
69 pMap=(TMap*)pExisting->GetObject()->Clone();
70 }
71 }
72
73 if (key && !pMap) pMap=new TMap;
74
75 // here is the actual content of the configuration object
76 TObject* obj=new TObjString(makeString()); //KK
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
86 AliCDBPath cdbPath(path);
87 AliCDBId cdbId(cdbPath, runmin, runmax);
88 AliCDBMetaData* cdbMetaData=NULL;
89 if (pExisting) cdbMetaData=pExisting->GetMetaData();
90 else cdbMetaData=new AliCDBMetaData;
91 man->Put(obj, cdbId, cdbMetaData);
92}
93
94// void makeGlobalHistoConfigObject(const char* path
95// ,//const char* param="",
96// ,const char* cdbUri=NULL
97// ,int runmin=0
98// ,int runmax=999999999)
99// {
100// //makeGlobalHistoConfigObject(path, NULL, param, cdbUri, runmin, runmax);
101// makeGlobalHistoConfigObject(path, NULL, makeString(), cdbUri, runmin, runmax); //KK
102// }
103//
104// void makeComponentConfigurationObject(const char* path,
105// int runNo,
106// const char* key,
107// const char* param)
108// {
109// makeComponentConfigurationObject(path, key, param, NULL, 0, 999999999, runNo);
110// }
111
112void makeGlobalHistoConfigObject()
113{
114 cout << "===============================================================" << endl;
115 cout << "usage: aliroot -b -q -l makeGlobalHistoConfigObject.C'(\"path\", NULL, \"uri\", rangemin, rangemax)'" << endl << endl;
116 cout << " path path of the entry within the OCDB, e.g. HLT/ConfigHLT/GlobalHisto" << endl;
117 cout << " uri (opt) the OCDB URI, default $ALICE_ROOT/OCDB " << endl;
118 cout << " rangemin (opt) default 0" << endl;
119 cout << " rangemax (opt) default 999999999" << endl;
120 cout << " The parameters of the component configuration should be defined inside function makeString()." << endl;
121 cout << "===============================================================" << endl;
122}
123
124TString makeString(){
125
126 TString s = "";
127
128 s+="-histogram TrackPt -size 1000 -expression Track_pt -cut Track_Nclusters>0 ";
129 s+="-histogram TrackPhi(180,0,360) -size 1000 -expression Track_phi -cut Track_Nclusters>0 ";
130 s+="-histogram TrackMultiplicity -size 1000 -expression trackcount -cut Track_Nclusters>0 ";
131 s+="-histogram TrackEta -size 1000 -expression Track_eta -cut Track_Nclusters>0 ";
132 s+="-histogram TrackNclusters(200,0,200) -size 1000 -expression Track_Nclusters -cut Track_Nclusters>0 ";
133 s+="-histogram TrackTheta(90,0,180) -size 1000 -expression Track_theta -cut Track_Nclusters>0 ";
134 s+="-histogram TrackDCAr -size 1000 -expression Track_DCAr -cut Track_Nclusters>0 ";
135 s+="-histogram TrackCharge -size 1000 -expression Track_charge -cut Track_Nclusters>0 ";
136
137 s+="-histogram VertexXY -size 1000 -expression vertexY:vertexX -cut nContributors>3 -opt colz ";
138 s+="-histogram VertexX -size 1000 -expression vertexX -cut nContributors>3 ";
139 s+="-histogram VertexY -size 1000 -expression vertexY -cut nContributors>3 ";
140 s+="-histogram VertexZ -size 1000 -expression vertexZ -cut nContributors>3 ";
141 s+="-histogram VertexTrendX -size 1000 -expression vertexX:event -cut nContributors>3 ";
142 s+="-histogram VertexTrendY -size 1000 -expression vertexY:event -cut nContributors>3 ";
143
144 //s+= "-histogram UPC -size 1500 -expression (px_1+px_2)*(px_1+px_2)+(py_1+py_2)*(py_1+py_2) -cut nClusters_1>50&&nClusters_2>50 ";
145 //s+= "-histogram pt1square -size 1500 -expression px_1*px_1+py_1*py_1 -cut nClusters_1>50 ";
146 //s+= "-histogram pt2 -size 1500 -expression TMath::Sqrt(px_2*px_2+py_2*py_2) -cut nClusters_2>50 ";
147
148 return s;
149}
150/*
151-histogram TrackPt -size 1000 -expression Track_pt -cut Track_Nclusters>0
152-histogram TrackPhi(180,0,360) -size 1000 -expression Track_phi -cut Track_Nclusters>0
153-histogram TrackMultiplicity -size 1000 -expression trackcount -cut Track_Nclusters>0
154-histogram TrackEta -size 1000 -expression Track_eta -cut Track_Nclusters>0
155-histogram TrackNclusters(200,0,200) -size 1000 -expression Track_Nclusters -cut Track_Nclusters>0
156-histogram TrackTheta(90,0,180) -size 1000 -expression Track_theta -cut Track_Nclusters>0
157-histogram TrackDCAr -size 1000 -expression Track_DCAr -cut Track_Nclusters>0
158-histogram TrackCharge -size 1000 -expression Track_charge -cut Track_Nclusters>0
159
160-histogram VertexXY -size 1000 -expression vertexY:vertexX -cut nContributors>3 -opt colz
161-histogram VertexX -size 1000 -expression vertexX -cut nContributors>3
162-histogram VertexY -size 1000 -expression vertexY -cut nContributors>3
163-histogram VertexZ -size 1000 -expression vertexZ -cut nContributors>3
164-histogram VertexTrendX -size 1000 -expression vertexX:event -cut nContributors>3
165-histogram VertexTrendY -size 1000 -expression vertexY:event -cut nContributors>3
166
167-histogram UPC -size 1000 -expression TMath::Sqrt((px_1+px_2)*(px_1+px_2)+(py_1+py_2)*(py_1+py_2)) -cut nClusters_1>50&&nClusters_2>50
168*/