1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
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 **************************************************************************/
22 * \brief Macro for running the dHLT chain in a standalone mode.
24 * This macro is used to run the dHLT component chain within the AliHLTSystem
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.
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.
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:
37 * > aliroot -b -q -l $ALICE_ROOT/HLT/MUON/macros/RunChain.C+
40 * \author Artur Szostak <artursz@iafrica.com>
43 #if !defined(__CINT__) || defined(__MAKECINT__)
44 #include "HLT/BASE/AliHLTSystem.h"
45 #include "HLT/BASE/AliHLTConfiguration.h"
54 * Used to run the dimuon HLT (dHLT) chain in various configuration in a standalone
55 * configuration. This is normally used for debugging, testing and can also be used
56 * as an example of how to build chains for dHLT by hand.
58 * @param chainType Specifies the type of chain to run. This can be one of the
60 * "full" - Run the full dHLT chain. (default)
61 * "ddlreco" - Run only the reconstruction of the DDL raw data up to hits
62 * and trigger records.
63 * "tracker" - Run the tracker only using hits and trigger records from
64 * AliRoot simulation or offline reconstruction.
65 * @param firstEvent The event number of the first event to process. (default = 0)
66 * @param lastEvent The event number of the last event to process. If this is
67 * less than firstEvent then it is set to firstEvent automatically. (default = -1)
68 * @param output Specifies the kind of output to generate. The options can be one
70 * "bin" - Generates all possible output and dumps it to binary files
71 * using the FileWriter component.
72 * "root" - Generates all possible output and writes it to a ROOT file
73 * using the ROOTFileWriter component.
74 * "tracks_bin" - Generates only track data and dumps it to binary files
75 * using the FileWriter component. This option is equivalent to
76 * 'bin' if the chain type is 'ddlreco'.
77 * "tracks_root" - Generates only track data and writes it to a ROOT file
78 * using the ROOTFileWriter component. This option is equivalent
79 * to 'bin' if the chain type is 'ddlreco'.
80 * @param dataSource This is the data source from which to use hits and trigger
81 * records when we are running the tracker only chain. Note this parameter
82 * only makes sense if chainType = "tracker". The possible options are:
83 * "sim" - Take data from GEANT hits. (default)
84 * "rec" - Take data from offline reconstructed hits and local trigger
86 * @param logLevel Specifies the amount of logging messages produced by the HLT
87 * system. The possible options are:
88 * "normal" - Shows warnings, errors and information.
89 * "max" - Shows everything including debug messages if they were compiled in.
90 * "min" - Shows only error messages.
91 * @param lutDir This is the directory in which the LUTs can be found.
92 * If it is set to "CDB" (case sensitive) then the LUTs will be loaded from
93 * CDB instead. The default behaviour is to read from the local CDB store.
96 const char* chainType = "full",
99 const char* output = "bin",
100 const char* dataSource = "sim",
101 const char* logLevel = "normal",
102 const char* lutDir = "CDB"
105 // Make sure that the lastEvent is greater than firstEvent.
106 if (lastEvent < firstEvent)
107 lastEvent = firstEvent;
108 int eventCount = lastEvent - firstEvent + 1;
110 bool buildDDLFilePubs = false;
111 bool buildDDLRecoComps = false;
112 bool buildSimDataPubs = false;
113 bool buildRecDataPubs = false;
114 bool buildTrackerComp = false;
115 bool defaultLogging = true;
116 bool maxLogging = false;
117 bool minLogging = false;
118 bool useRootWriter = false;
119 bool makeTracksOnly = false;
121 // Parse the chainType, output, dataSource and logLevel option strings:
122 TString outOpt = output;
123 if (outOpt.CompareTo("bin", TString::kIgnoreCase) == 0)
125 useRootWriter = false;
127 else if (outOpt.CompareTo("root", TString::kIgnoreCase) == 0)
129 useRootWriter = true;
131 else if (outOpt.CompareTo("tracks_bin", TString::kIgnoreCase) == 0)
133 useRootWriter = false;
134 makeTracksOnly = true;
136 else if (outOpt.CompareTo("tracks_root", TString::kIgnoreCase) == 0)
138 useRootWriter = true;
139 makeTracksOnly = true;
143 cerr << "ERROR: Unknown option for output: " << output << endl;
147 TString chainOpt = chainType;
148 if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
150 buildDDLFilePubs = true;
151 buildDDLRecoComps = true;
152 buildTrackerComp = true;
154 else if (chainOpt.CompareTo("ddlreco", TString::kIgnoreCase) == 0)
156 buildDDLFilePubs = true;
157 buildDDLRecoComps = true;
159 else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
161 buildTrackerComp = true;
163 TString dataOpt = dataSource;
164 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
166 buildSimDataPubs = true;
168 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
170 buildRecDataPubs = true;
174 cerr << "ERROR: Unknown option for dataSource: " << dataSource << endl;
180 cerr << "ERROR: Unknown option for chainType: " << chainType << endl;
184 TString logOpt = logLevel;
185 if (logOpt.CompareTo("normal", TString::kIgnoreCase) == 0)
189 else if (logOpt.CompareTo("max", TString::kIgnoreCase) == 0)
193 else if (logOpt.CompareTo("min", TString::kIgnoreCase) == 0)
199 cerr << "ERROR: Unknown option for logLevel: " << logLevel << endl;
203 // If we are supposed to make tracks only but are in a ddlreco chain
204 // then we clearly can only generate the DDL reconstructed data, so do that.
205 if (makeTracksOnly && ! buildTrackerComp)
207 makeTracksOnly = false;
210 // Now we can initialise the AliHLTSystem...
213 // Start by setting up the logging.
216 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
217 sys.SetGlobalLoggingLevel(kHLTLogAll);
221 sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(
222 kHLTLogFatal | kHLTLogError
226 sys.LoadComponentLibraries("libAliHLTUtil.so");
227 sys.LoadComponentLibraries("libAliHLTMUON.so");
229 // The DDL file publishers are only needed if we create the ddlreco or
230 // full chains. The filename lists are built assuming the aliroot rawXX/
231 // directory structure.
232 if (buildDDLFilePubs)
234 string cmd13 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
235 string cmd14 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
236 string cmd15 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
237 string cmd16 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
238 string cmd17 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
239 string cmd18 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
240 string cmd19 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
241 string cmd20 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
242 string cmd21 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
243 string cmd22 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
244 for (int i = firstEvent; i < lastEvent+1; i++)
248 cmd13 += " -nextevent";
249 cmd14 += " -nextevent";
250 cmd15 += " -nextevent";
251 cmd16 += " -nextevent";
252 cmd17 += " -nextevent";
253 cmd18 += " -nextevent";
254 cmd19 += " -nextevent";
255 cmd20 += " -nextevent";
256 cmd21 += " -nextevent";
257 cmd22 += " -nextevent";
260 sprintf(buf, "%d", i);
261 cmd13 += " -datafile raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
262 cmd14 += " -datafile raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
263 cmd15 += " -datafile raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
264 cmd16 += " -datafile raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
265 cmd17 += " -datafile raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
266 cmd18 += " -datafile raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
267 cmd19 += " -datafile raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
268 cmd20 += " -datafile raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
269 cmd21 += " -datafile raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
270 cmd22 += " -datafile raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
273 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
274 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
275 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
276 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
277 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
278 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
279 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
280 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
281 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
282 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
285 // Build the DDL reconstructor components for all the DDLs 13 to 22, that
286 // is for chambers 7 to 10 and trigger stations. We only need to build
287 // these components if we are are building the ddlreco or full chains.
288 if (buildDDLRecoComps)
290 if (TString(lutDir) == "CDB")
292 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", TString("-ddl 13 -cdbpath local://$ALICE_ROOT -run 0"));
293 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", TString("-ddl 14 -cdbpath local://$ALICE_ROOT -run 0"));
294 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", TString("-ddl 15 -cdbpath local://$ALICE_ROOT -run 0"));
295 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", TString("-ddl 16 -cdbpath local://$ALICE_ROOT -run 0"));
296 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", TString("-ddl 17 -cdbpath local://$ALICE_ROOT -run 0"));
297 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", TString("-ddl 18 -cdbpath local://$ALICE_ROOT -run 0"));
298 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", TString("-ddl 19 -cdbpath local://$ALICE_ROOT -run 0"));
299 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", TString("-ddl 20 -cdbpath local://$ALICE_ROOT -run 0"));
300 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", TString("-ddl 21 -cdbpath local://$ALICE_ROOT -run 0 -suppress_partial_triggers"));
301 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", TString("-ddl 22 -cdbpath local://$ALICE_ROOT -run 0 -suppress_partial_triggers"));
305 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", TString("-ddl 13 -lut ") + lutDir + TString("/Lut13.dat"));
306 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", TString("-ddl 14 -lut ") + lutDir + TString("/Lut14.dat"));
307 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", TString("-ddl 15 -lut ") + lutDir + TString("/Lut15.dat"));
308 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", TString("-ddl 16 -lut ") + lutDir + TString("/Lut16.dat"));
309 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", TString("-ddl 17 -lut ") + lutDir + TString("/Lut17.dat"));
310 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", TString("-ddl 18 -lut ") + lutDir + TString("/Lut18.dat"));
311 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", TString("-ddl 19 -lut ") + lutDir + TString("/Lut19.dat"));
312 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", TString("-ddl 20 -lut ") + lutDir + TString("/Lut20.dat"));
313 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", TString("-ddl 21 -lut ") + lutDir + TString("/Lut21.dat -suppress_partial_triggers"));
314 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", TString("-ddl 22 -lut ") + lutDir + TString("/Lut22.dat -suppress_partial_triggers"));
318 TString startEventStr = "-firstevent ";
319 startEventStr += firstEvent;
321 // Build the data source components to take data from simulated hits if
322 // we are building the tracker only chain with the 'sim' data source.
323 if (buildSimDataPubs)
325 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 7");
326 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 7");
327 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 8");
328 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 8");
329 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 9");
330 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 9");
331 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 10");
332 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 10");
333 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane left");
334 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane right");
337 // Build the data source components to take data from offline reconstructed
338 // objects if we are building the tracker only chain with the 'rec' data source.
339 if (buildRecDataPubs)
341 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 7");
342 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 7");
343 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 8");
344 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 8");
345 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 9");
346 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 9");
347 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 10");
348 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 10");
349 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane left");
350 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane right");
353 // Build the tracker component if we are building the tracker only or
355 if (buildTrackerComp)
357 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
360 // Build the data sink to subscribe only to what has been created and
361 // to the data source we actaully want.
362 TString sources = "";
365 sources += "tracker ";
369 if (buildTrackerComp)
370 sources += "tracker ";
371 sources += "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
375 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
376 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-datafile output.root -specfmt");
380 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
383 // Build and run the chain's tasks.
384 sys.BuildTaskList("sink");