]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/macros/RunChain.C
- Fix error message when opening merged aod file on client in PROOF mode
[u/mrichter/AliRoot.git] / HLT / MUON / macros / RunChain.C
CommitLineData
cc76079a 1/**************************************************************************
1b3806c8 2 * This file is property of and copyright by the ALICE HLT Project *
cc76079a 3 * All rights reserved. *
4 * *
5 * Primary Authors: *
6 * Artur Szostak <artursz@iafrica.com> *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
1b3806c8 17/* $Id$ */
18
19/**
20 * \ingroup macros
21 * \file RunChain.C
22 * \brief Macro for running the dHLT chain in a standalone mode.
23 *
24 * This macro is used to run the dHLT component chain within the AliHLTSystem
cc76079a 25 * framework, which is a simulation of the dHLT online system's output.
26 * To run this macro you must be in the same directory as the galice.root
27 * files or in the directory containing the rawXX/ directories produced from
28 * AliRoot simulations.
1b3806c8 29 * Also make sure you specify CDB as for the lutDir (lookup table directory)
30 * or that the appropriate LUTs are in the same directory as your working
31 * directory, or you can specify the directory with the lutDir parameter option.
32 *
33 * The simplest way to run this macro with defaults is to copy "rootlogon.C" from
34 * $ALICE_ROOT/HLT/MUON/macros into your current working directory, then from
35 * the shell command prompt run the following command:
36 * \code
37 * > aliroot -b -q -l $ALICE_ROOT/HLT/MUON/macros/RunChain.C+
38 * \endcode
39 *
40 * \author Artur Szostak <artursz@iafrica.com>
cc76079a 41 */
42
43#if !defined(__CINT__) || defined(__MAKECINT__)
846e6f41 44#include "AliCDBManager.h"
45#include "AliHLTSystem.h"
46#include "AliHLTConfiguration.h"
cc76079a 47#include "AliLog.h"
48#include "TString.h"
846e6f41 49#include "TClassTable.h"
cc76079a 50#include <iostream>
51using std::cerr;
52using std::endl;
53#endif
54
1b3806c8 55/**
56 * Used to run the dimuon HLT (dHLT) chain in various configuration in a standalone
57 * configuration. This is normally used for debugging, testing and can also be used
58 * as an example of how to build chains for dHLT by hand.
59 *
60 * @param chainType Specifies the type of chain to run. This can be one of the
cc76079a 61 * following:
62 * "full" - Run the full dHLT chain. (default)
63 * "ddlreco" - Run only the reconstruction of the DDL raw data up to hits
64 * and trigger records.
65 * "tracker" - Run the tracker only using hits and trigger records from
66 * AliRoot simulation or offline reconstruction.
67 * @param firstEvent The event number of the first event to process. (default = 0)
68 * @param lastEvent The event number of the last event to process. If this is
69 * less than firstEvent then it is set to firstEvent automatically. (default = -1)
1f50d9b1 70 * @param output Specifies the kind of output to generate. The options can be one
71 * of the following:
72 * "bin" - Generates all possible output and dumps it to binary files
73 * using the FileWriter component.
74 * "root" - Generates all possible output and writes it to a ROOT file
75 * using the ROOTFileWriter component.
76 * "tracks_bin" - Generates only track data and dumps it to binary files
77 * using the FileWriter component. This option is equivalent to
78 * 'bin' if the chain type is 'ddlreco'.
79 * "tracks_root" - Generates only track data and writes it to a ROOT file
80 * using the ROOTFileWriter component. This option is equivalent
81 * to 'bin' if the chain type is 'ddlreco'.
cc76079a 82 * @param dataSource This is the data source from which to use hits and trigger
83 * records when we are running the tracker only chain. Note this parameter
84 * only makes sense if chainType = "tracker". The possible options are:
85 * "sim" - Take data from GEANT hits. (default)
86 * "rec" - Take data from offline reconstructed hits and local trigger
87 * objects.
88 * @param logLevel Specifies the amount of logging messages produced by the HLT
89 * system. The possible options are:
90 * "normal" - Shows warnings, errors and information.
91 * "max" - Shows everything including debug messages if they were compiled in.
92 * "min" - Shows only error messages.
1f50d9b1 93 * @param lutDir This is the directory in which the LUTs can be found.
1b3806c8 94 * If it is set to "CDB" (case sensitive) then the LUTs will be loaded from
95 * CDB instead. The default behaviour is to read from the local CDB store.
cc76079a 96 */
97void RunChain(
98 const char* chainType = "full",
99 Int_t firstEvent = 0,
100 Int_t lastEvent = -1,
1f50d9b1 101 const char* output = "bin",
cc76079a 102 const char* dataSource = "sim",
1f50d9b1 103 const char* logLevel = "normal",
1b3806c8 104 const char* lutDir = "CDB"
cc76079a 105 )
106{
846e6f41 107 // Setup the CDB default storage and run number if nothing was set.
108 AliCDBManager* cdbManager = AliCDBManager::Instance();
109 if (cdbManager == NULL)
110 {
111 cerr << "ERROR: Global CDB manager object does not exist." << endl;
112 return;
113 }
114 if (cdbManager->GetDefaultStorage() == NULL)
115 {
116 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
117 }
118 if (cdbManager->GetRun() == -1)
119 {
120 cdbManager->SetRun(0);
121 }
122
cc76079a 123 // Make sure that the lastEvent is greater than firstEvent.
124 if (lastEvent < firstEvent)
125 lastEvent = firstEvent;
126 int eventCount = lastEvent - firstEvent + 1;
127
128 bool buildDDLFilePubs = false;
129 bool buildDDLRecoComps = false;
130 bool buildSimDataPubs = false;
131 bool buildRecDataPubs = false;
cc76079a 132 bool buildTrackerComp = false;
cc76079a 133 bool maxLogging = false;
134 bool minLogging = false;
1f50d9b1 135 bool useRootWriter = false;
136 bool makeTracksOnly = false;
c9537879 137 bool buildDecisionComp = true;
1f50d9b1 138
139 // Parse the chainType, output, dataSource and logLevel option strings:
140 TString outOpt = output;
141 if (outOpt.CompareTo("bin", TString::kIgnoreCase) == 0)
142 {
143 useRootWriter = false;
144 }
145 else if (outOpt.CompareTo("root", TString::kIgnoreCase) == 0)
146 {
147 useRootWriter = true;
148 }
149 else if (outOpt.CompareTo("tracks_bin", TString::kIgnoreCase) == 0)
150 {
151 useRootWriter = false;
152 makeTracksOnly = true;
153 }
154 else if (outOpt.CompareTo("tracks_root", TString::kIgnoreCase) == 0)
155 {
156 useRootWriter = true;
157 makeTracksOnly = true;
158 }
159 else
160 {
161 cerr << "ERROR: Unknown option for output: " << output << endl;
162 return;
163 }
cc76079a 164
cc76079a 165 TString chainOpt = chainType;
166 if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
167 {
168 buildDDLFilePubs = true;
169 buildDDLRecoComps = true;
170 buildTrackerComp = true;
cc76079a 171 }
1f50d9b1 172 else if (chainOpt.CompareTo("ddlreco", TString::kIgnoreCase) == 0)
cc76079a 173 {
174 buildDDLFilePubs = true;
175 buildDDLRecoComps = true;
c9537879 176 buildDecisionComp = false;
cc76079a 177 }
178 else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
179 {
cc76079a 180 buildTrackerComp = true;
1f50d9b1 181
cc76079a 182 TString dataOpt = dataSource;
183 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
184 {
185 buildSimDataPubs = true;
186 }
187 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
188 {
189 buildRecDataPubs = true;
190 }
191 else
192 {
193 cerr << "ERROR: Unknown option for dataSource: " << dataSource << endl;
194 return;
195 }
196 }
1f50d9b1 197 else
198 {
199 cerr << "ERROR: Unknown option for chainType: " << chainType << endl;
200 return;
201 }
cc76079a 202
203 TString logOpt = logLevel;
a563b588 204 if (logOpt.CompareTo("normal", TString::kIgnoreCase) == 0)
cc76079a 205 {
206 // nothing to do.
207 }
a563b588 208 else if (logOpt.CompareTo("max", TString::kIgnoreCase) == 0)
cc76079a 209 {
210 maxLogging = true;
211 }
a563b588 212 else if (logOpt.CompareTo("min", TString::kIgnoreCase) == 0)
cc76079a 213 {
214 minLogging = true;
215 }
216 else
217 {
218 cerr << "ERROR: Unknown option for logLevel: " << logLevel << endl;
219 return;
220 }
221
1f50d9b1 222 // If we are supposed to make tracks only but are in a ddlreco chain
223 // then we clearly can only generate the DDL reconstructed data, so do that.
224 if (makeTracksOnly && ! buildTrackerComp)
225 {
226 makeTracksOnly = false;
227 }
228
cc76079a 229 // Now we can initialise the AliHLTSystem...
230 AliHLTSystem sys;
cc76079a 231
232 // Start by setting up the logging.
233 if (maxLogging)
234 {
235 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
236 sys.SetGlobalLoggingLevel(kHLTLogAll);
237 }
238 if (minLogging)
239 {
1b3806c8 240 sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(
241 kHLTLogFatal | kHLTLogError
242 ));
cc76079a 243 }
a563b588 244
846e6f41 245 if (gClassTable->GetID("AliHLTAgentUtil") < 0)
246 {
247 sys.LoadComponentLibraries("libAliHLTUtil.so");
248 }
249 if (gClassTable->GetID("AliHLTMUONAgent") < 0)
250 {
251 sys.LoadComponentLibraries("libAliHLTMUON.so");
252 }
cc76079a 253
254 // The DDL file publishers are only needed if we create the ddlreco or
255 // full chains. The filename lists are built assuming the aliroot rawXX/
256 // directory structure.
257 if (buildDDLFilePubs)
258 {
668eee9f 259 string cmd13 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
260 string cmd14 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
261 string cmd15 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
262 string cmd16 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
263 string cmd17 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
264 string cmd18 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
265 string cmd19 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
266 string cmd20 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
267 string cmd21 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
268 string cmd22 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
cc76079a 269 for (int i = firstEvent; i < lastEvent+1; i++)
270 {
271 if (i != 0)
272 {
273 cmd13 += " -nextevent";
274 cmd14 += " -nextevent";
275 cmd15 += " -nextevent";
276 cmd16 += " -nextevent";
277 cmd17 += " -nextevent";
278 cmd18 += " -nextevent";
279 cmd19 += " -nextevent";
280 cmd20 += " -nextevent";
281 cmd21 += " -nextevent";
282 cmd22 += " -nextevent";
283 }
284 char buf[16];
285 sprintf(buf, "%d", i);
286 cmd13 += " -datafile raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
287 cmd14 += " -datafile raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
288 cmd15 += " -datafile raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
289 cmd16 += " -datafile raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
290 cmd17 += " -datafile raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
291 cmd18 += " -datafile raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
292 cmd19 += " -datafile raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
293 cmd20 += " -datafile raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
294 cmd21 += " -datafile raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
295 cmd22 += " -datafile raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
296 }
297
298 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
299 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
300 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
301 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
302 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
303 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
304 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
305 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
306 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
307 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
308 }
309
310 // Build the DDL reconstructor components for all the DDLs 13 to 22, that
311 // is for chambers 7 to 10 and trigger stations. We only need to build
312 // these components if we are are building the ddlreco or full chains.
313 if (buildDDLRecoComps)
314 {
1b3806c8 315 if (TString(lutDir) == "CDB")
316 {
317 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", TString("-ddl 13 -cdbpath local://$ALICE_ROOT -run 0"));
318 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", TString("-ddl 14 -cdbpath local://$ALICE_ROOT -run 0"));
319 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", TString("-ddl 15 -cdbpath local://$ALICE_ROOT -run 0"));
320 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", TString("-ddl 16 -cdbpath local://$ALICE_ROOT -run 0"));
321 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", TString("-ddl 17 -cdbpath local://$ALICE_ROOT -run 0"));
322 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", TString("-ddl 18 -cdbpath local://$ALICE_ROOT -run 0"));
323 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", TString("-ddl 19 -cdbpath local://$ALICE_ROOT -run 0"));
324 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", TString("-ddl 20 -cdbpath local://$ALICE_ROOT -run 0"));
325 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", TString("-ddl 21 -cdbpath local://$ALICE_ROOT -run 0 -suppress_partial_triggers"));
326 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", TString("-ddl 22 -cdbpath local://$ALICE_ROOT -run 0 -suppress_partial_triggers"));
327 }
328 else
329 {
330 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", TString("-ddl 13 -lut ") + lutDir + TString("/Lut13.dat"));
331 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", TString("-ddl 14 -lut ") + lutDir + TString("/Lut14.dat"));
332 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", TString("-ddl 15 -lut ") + lutDir + TString("/Lut15.dat"));
333 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", TString("-ddl 16 -lut ") + lutDir + TString("/Lut16.dat"));
334 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", TString("-ddl 17 -lut ") + lutDir + TString("/Lut17.dat"));
335 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", TString("-ddl 18 -lut ") + lutDir + TString("/Lut18.dat"));
336 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", TString("-ddl 19 -lut ") + lutDir + TString("/Lut19.dat"));
337 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", TString("-ddl 20 -lut ") + lutDir + TString("/Lut20.dat"));
338 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", TString("-ddl 21 -lut ") + lutDir + TString("/Lut21.dat -suppress_partial_triggers"));
339 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", TString("-ddl 22 -lut ") + lutDir + TString("/Lut22.dat -suppress_partial_triggers"));
340 }
1f50d9b1 341 }
342
343 TString startEventStr = "-firstevent ";
344 startEventStr += firstEvent;
ee3678d3 345
1f50d9b1 346 // Build the data source components to take data from simulated hits if
347 // we are building the tracker only chain with the 'sim' data source.
cc76079a 348 if (buildSimDataPubs)
349 {
1f50d9b1 350 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 7");
351 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 7");
352 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 8");
353 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 8");
354 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 9");
355 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 9");
356 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 10");
357 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 10");
358 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane left");
359 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane right");
cc76079a 360 }
361
362 // Build the data source components to take data from offline reconstructed
363 // objects if we are building the tracker only chain with the 'rec' data source.
364 if (buildRecDataPubs)
365 {
1f50d9b1 366 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 7");
367 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 7");
368 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 8");
369 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 8");
370 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 9");
371 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 9");
372 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 10");
373 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 10");
374 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane left");
375 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane right");
cc76079a 376 }
377
378 // Build the tracker component if we are building the tracker only or
379 // full chains.
380 if (buildTrackerComp)
381 {
382 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
383 }
c9537879 384
385 // Build the dHLT trigger decision component if enabled.
386 if (buildDecisionComp)
387 {
388 AliHLTConfiguration decision("decision", "MUONDecisionComponent", "tracker", "");
389 }
cc76079a 390
1f50d9b1 391 // Build the data sink to subscribe only to what has been created and
392 // to the data source we actaully want.
393 TString sources = "";
394 if (makeTracksOnly)
cc76079a 395 {
1f50d9b1 396 sources += "tracker ";
cc76079a 397 }
1f50d9b1 398 else
399 {
400 if (buildTrackerComp)
401 sources += "tracker ";
402 sources += "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
403 }
c9537879 404 if (buildDecisionComp)
405 {
406 // Add the trigger decision component if it was enabled.
407 sources += " decision";
408 }
1f50d9b1 409 if (useRootWriter)
410 {
411 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
d8cf7391 412 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-concatenate-events -datafile output.root -specfmt");
1f50d9b1 413 }
414 else
cc76079a 415 {
1f50d9b1 416 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
cc76079a 417 }
418
1f50d9b1 419 // Build and run the chain's tasks.
420 sys.BuildTaskList("sink");
cc76079a 421 sys.Run(eventCount);
422}