3 * @file rec-hlt-offline-vertexer.C
4 * @brief Example macro to run the AliHLTGlobalOfflineVertexerComponent in
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"
14 * 1) Usage: aliroot -b -q -l \
15 * rec-hlt-offline-vertexer.C'("file", "cdb", minEvent, maxEvent)'
16 * 2) Usage: aliroot -b -q -l \
17 * rec-hlt-offline-vertexer.C'("esdfile", "tree", "cdb", nofEvents)'
20 * rec-hlt-offline-vertexer.C'("alien:///alice/data/2009/.../....root")'
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")'
25 * cdb="raw://" -> take OCDB from GRID
26 * minEvent=-1 -> no lower event selection
27 * maxEvent=-1 -> no upper event selection
28 * nofEvents=-1 -> all events
32 * The input file can be a file on the grid, indicated by the tag
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
35 * connects to the Grid in the beginning.
37 * It is always a good idea to use the OCDB from the
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"
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.
47 * @author Matthias.Richter@ift.uib.no
48 * @ingroup alihlt_global
50 void rec_hlt_offline_vertexer(const char *filename,
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");
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/..");
77 //////////////////////////////////////////////////////////////////////////////////////
79 // Reconstruction settings
80 AliReconstruction rec;
82 if (minEvent>=0 || maxEvent>minEvent) {
83 if (minEvent<0) minEvent=0;
84 if (maxEvent<minEvent) maxEvent=minEvent;
85 rec.SetEventRange(minEvent,maxEvent);
87 rec.SetRunReconstruction("HLT ITS TPC");
88 rec.SetWriteESDfriend(kFALSE);
89 rec.SetInput(filename);
93 //rec.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
95 //////////////////////////////////////////////////////////////////////////////////////
97 // setup the HLT system
98 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
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
105 // The same chain is set up for the GlobalVertexer component, output
106 // saved in glblvertex.root.
108 // arguments of a configuration:
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", "");
114 AliHLTConfiguration offlhistogram("Offline-Histogram", "GlobalVertexerHisto", "Offline-Vertexer", "");
115 AliHLTConfiguration offlwriter("Offline-Writer", "ROOTFileWriter", "Offline-Histogram", "-datafile offlvertex.root -overwrite -concatenate-events");
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");
121 // set option for the HLT module in AliReconstruction
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
129 "libAliHLTUtil.so libAliHLTTPC.so "
130 "libAliHLTITS.so libAliHLTGlobal.so "
132 "chains=Offline-Writer,Global-Writer "
135 rec.SetRunPlaneEff(kFALSE);
137 // switch off cleanESD
138 rec.SetCleanESD(kFALSE);
145 // run default chain and connect vertexer components to global ESD
146 // using the raw OCDB
147 void rec_hlt_offline_vertexer(const char *filename,
151 rec_hlt_offline_vertexer(filename, "raw://", minEvent, maxEvent);
155 void rec_hlt_offline_vertexer(const char *esdfilename,
156 const char *treename,
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";
165 cerr << "invalid treename '" << treename << "', supported 'esdTree' and 'HLTesdTree'" << endl;
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");
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;
186 // get number of events
188 esdfile->GetObject(treename, pTree);
190 cerr << "can not find " << treename << " in file " << strfile << endl;
193 if (pTree->GetEntries()<=0) {
194 cerr << "empty tree " << treename << " in file " << strfile << endl;
198 AliESDEvent* esd=new AliESDEvent;
199 esd->ReadFromTree(pTree);
202 if (nofEvents<0 || nofEvents>pTree->GetEntries())
203 nofEvents=pTree->GetEntries();
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/..");
220 //////////////////////////////////////////////////////////////////////////////////////
222 // setup the HLT system
223 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
225 TString arguments, vertexerinput;
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());
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");
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");
241 // set option for the HLT system
243 // - libraries to be used as plugins
244 // - loglevel=0x79 : Important, Warning, Error, Fatal
245 pHLT->ScanOptions("libAliHLTUtil.so libAliHLTGlobal.so "
249 pHLT->BuildTaskList("Offline-Writer");
250 pHLT->BuildTaskList("Global-Writer");
251 pHLT->Run(nofEvents);
255 void rec_hlt_offline_vertexer()
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;
261 cout << " rec-hlt-offline-vertexer.C'(\"file\", \"cdb\", minEvent, maxEvent)'" << endl;
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;
268 cout << " Examples:" << endl;
269 cout << " rec-hlt-offline-vertexer.C'(\"alien:///alice/data/2009/.../....root\")' " << endl;
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;
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;
277 cout << " nofEvents=-1 -> all events" << endl;