]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/macros/rec-hlt-offline-vertexer.C
bugfix: adding libAliHLTTPC.so and libAliHLTITS.so which have not been loaded automat...
[u/mrichter/AliRoot.git] / HLT / global / macros / rec-hlt-offline-vertexer.C
CommitLineData
e09e5bba 1// $Id$
2/**
3 * @file rec-hlt-offline-vertexer.C
593cd4f6 4 * @brief Example macro to run the AliHLTGlobalOfflineVertexerComponent in
e09e5bba 5 * AliReconstruction.
6 *
2471b7fc 7 * The macro supports two running modes for tests of the
8 * 'GlobalOfflineVertexer' HLT component:
9 * 1) subscribes to the output of the default HLT reconstruction chain,
10 * extracts the ESD from the input, and runs the AliVertexerTracks.
11 * 2) run on already reconstructed ESD, either "esdTree" or "HLTesdTree"
e09e5bba 12 *
13 * <pre>
2471b7fc 14 * 1) Usage: aliroot -b -q -l \
e09e5bba 15 * rec-hlt-offline-vertexer.C'("file", "cdb", minEvent, maxEvent)'
2471b7fc 16 * 2) Usage: aliroot -b -q -l \
17 * rec-hlt-offline-vertexer.C'("esdfile", "tree", "cdb", nofEvents)'
e09e5bba 18 *
19 * Examples:
20 * rec-hlt-offline-vertexer.C'("alien:///alice/data/2009/.../....root")'
2471b7fc 21 * rec-hlt-offline-vertexer.C'("raw.root", "local://$ALICE_ROOT/OCDB", minEvent, MaxEvent)'
22 * rec-hlt-offline-vertexer.C'("raw.root", "esdTree", "local://$ALICE_ROOT/OCDB")'
e09e5bba 23 *
24 * Defaults
25 * cdb="raw://" -> take OCDB from GRID
26 * minEvent=-1 -> no lower event selection
27 * maxEvent=-1 -> no upper event selection
2471b7fc 28 * nofEvents=-1 -> all events
e09e5bba 29 *
30 * </pre>
31 *
32 * The input file can be a file on the grid, indicated by the tag
2471b7fc 33 * 'alien://'. By default also the OCDB is set to the GRID.
34 * If either the file or the OCDB is taken from the GRID, the macro
e09e5bba 35 * connects to the Grid in the beginning.
36 *
2471b7fc 37 * It is always a good idea to use the OCDB from the
e09e5bba 38 * Grid as this will contain all the necessary objects and the latest
39 * calibration. The special URI 'raw://' is most advisable as it selects
40 * the storage automatically from the run number. Other options are e.g.
41 * - "alien://folder=/alice/data/2010/OCDB"
42 * - "local://$ALICE_ROOT/OCDB"
43 *
44 * Note: You need a valid GRID token, if you want to access files directly
45 * from the Grid, use 'alien-token-init' of your alien installation.
46 *
47 * @author Matthias.Richter@ift.uib.no
48 * @ingroup alihlt_global
49 */
50void rec_hlt_offline_vertexer(const char *filename,
2471b7fc 51 const char *cdbURI,
52 int minEvent=-1,
53 int maxEvent=-1)
e09e5bba 54{
55 // connect to the GRID if we use a file or OCDB from the GRID
56 TString struri=cdbURI;
57 TString strfile=filename;
58 if (struri.BeginsWith("raw://") ||
59 strfile.Contains("://") && !strfile.Contains("local://")) {
60 TGrid::Connect("alien");
61 }
62
63 // Set the CDB storage location
64 AliCDBManager * man = AliCDBManager::Instance();
65 man->SetDefaultStorage(cdbURI);
66 if (struri.BeginsWith("local://")) {
67 // set specific storage for GRP entry
68 // search in the working directory and one level above, the latter
69 // follows the standard simulation setup like e.g. in test/ppbench
70 if (!gSystem->AccessPathName("GRP/GRP/Data")) {
71 man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD");
72 } else if (!gSystem->AccessPathName("../GRP/GRP/Data")) {
73 man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD/..");
74 }
75 }
76
77 //////////////////////////////////////////////////////////////////////////////////////
78 //
79 // Reconstruction settings
80 AliReconstruction rec;
81
82 if (minEvent>=0 || maxEvent>minEvent) {
83 if (minEvent<0) minEvent=0;
84 if (maxEvent<minEvent) maxEvent=minEvent;
85 rec.SetEventRange(minEvent,maxEvent);
86 }
87 rec.SetRunReconstruction("HLT ITS TPC");
88 rec.SetWriteESDfriend(kFALSE);
89 rec.SetInput(filename);
90
91 // QA options
92 rec.SetRunQA(":") ;
93 //rec.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
94
95 //////////////////////////////////////////////////////////////////////////////////////
96 //
97 // setup the HLT system
98 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
99
2471b7fc 100 // define a configuration for the GlobalOfflineVertexer component
101 // a histgram component (GlobalVertexerHisto) creates histograms from
102 // the output of the vertexer component. Histograms are saved in file
103 // offlvertex.root
104 //
105 // The same chain is set up for the GlobalVertexer component, output
106 // saved in glblvertex.root.
107 //
108 // arguments of a configuration:
e09e5bba 109 // 1) id of the configuartion, later used to refer to this configuration
110 // 2) id of the component to run
111 // 3) parents, here the configuration 'GLOBAL-esd-converter' of the libAliHLTGlobal
112 // 4) optional component arguments
113 AliHLTConfiguration offlvertexer("Offline-Vertexer", "GlobalOfflineVertexer", "GLOBAL-esd-converter", "");
2471b7fc 114 AliHLTConfiguration offlhistogram("Offline-Histogram", "GlobalVertexerHisto", "Offline-Vertexer", "");
115 AliHLTConfiguration offlwriter("Offline-Writer", "ROOTFileWriter", "Offline-Histogram", "-datafile offlvertex.root -overwrite -concatenate-events");
116
117 AliHLTConfiguration glblvertexer("Global-Vertexer", "GlobalVertexer", "GLOBAL-esd-converter", "");
118 AliHLTConfiguration glblhistogram("Global-Histogram", "GlobalVertexerHisto", "Global-Vertexer", "");
119 AliHLTConfiguration glblwriter("Global-Writer", "ROOTFileWriter", "Global-Histogram", "-datafile glblvertex.root -overwrite -concatenate-events");
e09e5bba 120
121 // set option for the HLT module in AliReconstruction
122 // arguments
123 // - ignore-hltout : ignore the HLTOUT payload from the HLT DDLs
124 // - libraries to be used as plugins
125 // - loglevel=0x79 : Important, Warning, Error, Fatal
126 // - chains=Offline-Vertexer : chains to be run
127 rec.SetOption("HLT",
128 "ignore-hltout "
e06810a5 129 "libAliHLTUtil.so libAliHLTTPC.so "
130 "libAliHLTITS.so libAliHLTGlobal.so "
e09e5bba 131 "loglevel=0x79 "
2471b7fc 132 "chains=Offline-Writer,Global-Writer "
e09e5bba 133 );
134
135 rec.SetRunPlaneEff(kFALSE);
136
137 // switch off cleanESD
138 rec.SetCleanESD(kFALSE);
139
140 AliLog::Flush();
141 rec.Run();
142
143}
144
2471b7fc 145// run default chain and connect vertexer components to global ESD
146// using the raw OCDB
e09e5bba 147void rec_hlt_offline_vertexer(const char *filename,
148 int minEvent=-1,
149 int maxEvent=-1)
150{
593cd4f6 151 rec_hlt_offline_vertexer(filename, "raw://", minEvent, maxEvent);
e09e5bba 152}
153
2471b7fc 154// run on ESD
155void rec_hlt_offline_vertexer(const char *esdfilename,
156 const char *treename,
157 const char *cdbURI,
158 int nofEvents=-1)
159{
160 // check the name of the tree
161 TString strtree=treename;
162 if (strtree.CompareTo("esdTree")==0) strtree="ESD";
163 else if (strtree.CompareTo("HLTesdTree")==0) strtree="HLTESD";
164 else {
165 cerr << "invalid treename '" << treename << "', supported 'esdTree' and 'HLTesdTree'" << endl;
166 return;
167 }
168
169 // connect to the GRID if we use a file or OCDB from the GRID
170 TString struri=cdbURI;
171 TString strfile=esdfilename;
172 if (struri.BeginsWith("raw://") ||
173 strfile.Contains("://") && !strfile.Contains("local://")) {
174 TGrid::Connect("alien");
175 }
176
177 // open the ESD file and get the event count
178 if (!strfile.EndsWith("/")) strfile+="/";
179 strfile+="AliESDs.root";
180 TFile* esdfile=TFile::Open(strfile);
181 if (!esdfile || esdfile->IsZombie()) {
182 cerr << "can not open file " << strfile << endl;
183 return;
184 }
185
186 // get number of events
187 TTree* pTree=NULL;
188 esdfile->GetObject(treename, pTree);
189 if (!pTree) {
190 cerr << "can not find " << treename << " in file " << strfile << endl;
191 return;
192 }
193 if (pTree->GetEntries()<=0) {
194 cerr << "empty tree " << treename << " in file " << strfile << endl;
195 return;
196 }
197
198 AliESDEvent* esd=new AliESDEvent;
199 esd->ReadFromTree(pTree);
200 pTree->GetEntry(0);
201
202 if (nofEvents<0 || nofEvents>pTree->GetEntries())
203 nofEvents=pTree->GetEntries();
204
205 // Set the CDB storage location
206 AliCDBManager * man = AliCDBManager::Instance();
207 man->SetDefaultStorage(cdbURI);
208 man->SetRun(esd->GetRunNumber());
209 if (struri.BeginsWith("local://")) {
210 // set specific storage for GRP entry
211 // search in the working directory and one level above, the latter
212 // follows the standard simulation setup like e.g. in test/ppbench
213 if (!gSystem->AccessPathName("GRP/GRP/Data")) {
214 man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD");
215 } else if (!gSystem->AccessPathName("../GRP/GRP/Data")) {
216 man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD/..");
217 }
218 }
219
220 //////////////////////////////////////////////////////////////////////////////////////
221 //
222 // setup the HLT system
223 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
224
225 TString arguments, vertexerinput;
226
227 // ESD publisher component
228 arguments=" -datapath "; arguments+=esdfilename;
229 arguments+=" -entrytype "; arguments+=strtree;
230 vertexerinput="ESD-publisher";
231 AliHLTConfiguration esdpublisher(vertexerinput.Data(), "ESDMCEventPublisher", "", arguments.Data());
232
233 AliHLTConfiguration offlvertexer("Offline-Vertexer", "GlobalOfflineVertexer", vertexerinput.Data(), "");
234 AliHLTConfiguration offlhistogram("Offline-Histogram", "GlobalVertexerHisto", "Offline-Vertexer", "");
235 AliHLTConfiguration offlwriter("Offline-Writer", "ROOTFileWriter", "Offline-Histogram", "-datafile offlvertex.root -overwrite -concatenate-events");
236
237 AliHLTConfiguration glblvertexer("Global-Vertexer", "GlobalVertexer", vertexerinput.Data(), "");
238 AliHLTConfiguration glblhistogram("Global-Histogram", "GlobalVertexerHisto", "Global-Vertexer", "");
239 AliHLTConfiguration glblwriter("Global-Writer", "ROOTFileWriter", "Global-Histogram", "-datafile glblvertex.root -overwrite -concatenate-events");
240
241 // set option for the HLT system
242 // arguments
243 // - libraries to be used as plugins
244 // - loglevel=0x79 : Important, Warning, Error, Fatal
245 pHLT->ScanOptions("libAliHLTUtil.so libAliHLTGlobal.so "
246 "loglevel=0x79 "
247 );
248
249 pHLT->BuildTaskList("Offline-Writer");
250 pHLT->BuildTaskList("Global-Writer");
251 pHLT->Run(nofEvents);
252}
253
254// help
e09e5bba 255void rec_hlt_offline_vertexer()
256{
2471b7fc 257 cout << "rec_hlt_offline_vertexer.C: The macro supports two running modes of the " << endl;
258 cout << " 'GlobalOfflineVertexer' HLT component" << endl;
259 cout << " Run in AliReconstruction" << endl;
260 cout << " Usage: aliroot -b -q -l \\" << endl;
e09e5bba 261 cout << " rec-hlt-offline-vertexer.C'(\"file\", \"cdb\", minEvent, maxEvent)'" << endl;
262 cout << "" << endl;
2471b7fc 263 cout << " Run on already reconstructed ESD, either \"esdTree\" or \"HLTesdTree\"" << endl;
264 cout << " Usage: aliroot -b -q -l \\" << endl;
265 cout << " rec-hlt-offline-vertexer.C'(\"esdfile\", \"tree\", \"cdb\", nofEvents)'" << endl;
266 cout << " three first arguments mandatory" << endl;
267 cout << "" << endl;
e09e5bba 268 cout << " Examples:" << endl;
269 cout << " rec-hlt-offline-vertexer.C'(\"alien:///alice/data/2009/.../....root\")' " << endl;
2471b7fc 270 cout << " rec-hlt-offline-vertexer.C'(\"raw.root\", \"local://$ALICE_ROOT/OCDB\", minEvent, MaxEvent)'" << endl;
271 cout << " rec-hlt-offline-vertexer.C'(\"raw.root\", \"esdTree\", \"local://$ALICE_ROOT/OCDB\")'" << endl;
e09e5bba 272 cout << "" << endl;
273 cout << " Defaults" << endl;
274 cout << " cdb=\"raw://\" -> take OCDB from GRID" << endl;
275 cout << " minEvent=-1 -> no lower event selection" << endl;
276 cout << " maxEvent=-1 -> no upper event selection" << endl;
2471b7fc 277 cout << " nofEvents=-1 -> all events" << endl;
e09e5bba 278}