]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/macros/RunChain.C
Coverity Fix for the DptDpt Code
[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
1d8ae082 17// $Id$
1b3806c8 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__)
90af8855 44#include "AliRawReader.h"
45#include "AliHLTOfflineInterface.h"
bc5cb6d6 46#include "AliCDBStorage.h"
846e6f41 47#include "AliCDBManager.h"
48#include "AliHLTSystem.h"
49#include "AliHLTConfiguration.h"
cc76079a 50#include "AliLog.h"
51#include "TString.h"
52#include <iostream>
53using std::cerr;
54using std::endl;
55#endif
56
1b3806c8 57/**
58 * Used to run the dimuon HLT (dHLT) chain in various configuration in a standalone
59 * configuration. This is normally used for debugging, testing and can also be used
60 * as an example of how to build chains for dHLT by hand.
61 *
62 * @param chainType Specifies the type of chain to run. This can be one of the
cc76079a 63 * following:
52c6d8aa 64 * "full" - Run the full dHLT chain with manso tracker. (default)
65 * "full-tracker" - Run the full dHLT chain with the full tracker.
cc76079a 66 * "ddlreco" - Run only the reconstruction of the DDL raw data up to hits
67 * and trigger records.
52c6d8aa 68 * "tracker" - Run the Manso tracker only using hits and trigger records from
cc76079a 69 * AliRoot simulation or offline reconstruction.
70 * @param firstEvent The event number of the first event to process. (default = 0)
71 * @param lastEvent The event number of the last event to process. If this is
72 * less than firstEvent then it is set to firstEvent automatically. (default = -1)
1f50d9b1 73 * @param output Specifies the kind of output to generate. The options can be one
74 * of the following:
75 * "bin" - Generates all possible output and dumps it to binary files
76 * using the FileWriter component.
77 * "root" - Generates all possible output and writes it to a ROOT file
78 * using the ROOTFileWriter component.
79 * "tracks_bin" - Generates only track data and dumps it to binary files
80 * using the FileWriter component. This option is equivalent to
81 * 'bin' if the chain type is 'ddlreco'.
82 * "tracks_root" - Generates only track data and writes it to a ROOT file
83 * using the ROOTFileWriter component. This option is equivalent
84 * to 'bin' if the chain type is 'ddlreco'.
cc76079a 85 * @param dataSource This is the data source from which to use hits and trigger
90af8855 86 * records when we are running the tracker only chain and the DDL raw data
87 * reading method when running the 'full' or 'ddlreco' chain. If the
88 * chainType = "full" or "ddlreco", then the possible options are:
89 * "file" - Reads the raw data directly from the DDL files. (default)
90 * "rawreader" - Reads the raw data using the AliRawReader interface from
91 * the current working directory.
92 * If the chainType = "tracker", then the possible options are:
cc76079a 93 * "sim" - Take data from GEANT hits. (default)
94 * "rec" - Take data from offline reconstructed hits and local trigger
95 * objects.
96 * @param logLevel Specifies the amount of logging messages produced by the HLT
97 * system. The possible options are:
98 * "normal" - Shows warnings, errors and information.
24f12607 99 * "debug" - Shows all messages up to the debug level only for HLT and the
100 * same as normal for all other modules.
cc76079a 101 * "max" - Shows everything including debug messages if they were compiled in.
102 * "min" - Shows only error messages.
1f50d9b1 103 * @param lutDir This is the directory in which the LUTs can be found.
1b3806c8 104 * If it is set to "CDB" (case sensitive) then the LUTs will be loaded from
105 * CDB instead. The default behaviour is to read from the local CDB store.
dba14d7d 106 * @param checkData A flag for indicating if the event data should be checked
107 * for consistency with the AliHLTMUONDataCheckerComponent.
90af8855 108 * @param rawDataPath The path of the raw data (i.e. path to the rawXX directories)
109 * or can be the file name if using the "rawreader" option for dataSource.
1d8ae082 110 * @param runNumber Specifies the run number to use. If it is set to -1 then the
111 * run number is not set if the CDB manager already has a run number set,
112 * otherwise a default run number of 0 is used. The default value is -1.
113 * @param cdbPath This gives the CDB path to use. If it is set to NULL then
114 * the CDB path is not set if the CDB manager already has a default storage
115 * CDB path set, otherwise a default value of "local://$ALICE_ROOT/OCDB" is used.
116 * The default value is NULL.
117 * @param tryrecover If this is true then the "-tryrecover" flag is set in the
118 * raw data reconstruction components. This is useful if when running RunChain
119 * log messages appear indicating that there was a problem decoding the raw data.
120 * The "-tryrecover" flag will turn on recovery logic in the raw data decoders
121 * to try and overcome errors in the data.
cc76079a 122 */
123void RunChain(
124 const char* chainType = "full",
125 Int_t firstEvent = 0,
126 Int_t lastEvent = -1,
1f50d9b1 127 const char* output = "bin",
90af8855 128 const char* dataSource = "file",
1f50d9b1 129 const char* logLevel = "normal",
dba14d7d 130 const char* lutDir = "CDB",
90af8855 131 bool checkData = false,
1d8ae082 132 const char* rawDataPath = "./",
133 Int_t runNumber = -1,
134 const char* cdbPath = NULL,
135 bool tryrecover = false
cc76079a 136 )
137{
846e6f41 138 // Setup the CDB default storage and run number if nothing was set.
139 AliCDBManager* cdbManager = AliCDBManager::Instance();
140 if (cdbManager == NULL)
141 {
142 cerr << "ERROR: Global CDB manager object does not exist." << endl;
143 return;
144 }
1d8ae082 145 if (runNumber != -1)
846e6f41 146 {
1d8ae082 147 cdbManager->SetRun(runNumber);
846e6f41 148 }
1d8ae082 149 else if (cdbManager->GetRun() == -1)
846e6f41 150 {
151 cdbManager->SetRun(0);
152 }
1d8ae082 153 if (cdbPath != NULL)
154 {
155 cdbManager->SetDefaultStorage(cdbPath);
156 }
157 else if (cdbManager->GetDefaultStorage() == NULL)
158 {
159 cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
160 }
161
162 if (cdbManager->GetDefaultStorage() == NULL)
163 {
164 cerr << "ERROR: There is no value for the default CDB storage, cannot continue." << endl;
165 return;
166 }
846e6f41 167
cc76079a 168 // Make sure that the lastEvent is greater than firstEvent.
169 if (lastEvent < firstEvent)
170 lastEvent = firstEvent;
171 int eventCount = lastEvent - firstEvent + 1;
172
173 bool buildDDLFilePubs = false;
90af8855 174 bool buildRawReaderPubs = false;
cc76079a 175 bool buildDDLRecoComps = false;
176 bool buildSimDataPubs = false;
177 bool buildRecDataPubs = false;
cc76079a 178 bool buildTrackerComp = false;
52c6d8aa 179 bool buildFullTrackerComp = false;
cc76079a 180 bool maxLogging = false;
24f12607 181 bool debugLogging = false;
cc76079a 182 bool minLogging = false;
1f50d9b1 183 bool useRootWriter = false;
184 bool makeTracksOnly = false;
52c6d8aa 185 bool buildDecisionComp = false;
fa41da55 186 bool buildESDComp = false;
1f50d9b1 187
188 // Parse the chainType, output, dataSource and logLevel option strings:
189 TString outOpt = output;
190 if (outOpt.CompareTo("bin", TString::kIgnoreCase) == 0)
191 {
192 useRootWriter = false;
193 }
194 else if (outOpt.CompareTo("root", TString::kIgnoreCase) == 0)
195 {
196 useRootWriter = true;
197 }
198 else if (outOpt.CompareTo("tracks_bin", TString::kIgnoreCase) == 0)
199 {
200 useRootWriter = false;
201 makeTracksOnly = true;
202 }
203 else if (outOpt.CompareTo("tracks_root", TString::kIgnoreCase) == 0)
204 {
205 useRootWriter = true;
206 makeTracksOnly = true;
207 }
208 else
209 {
90af8855 210 cerr << "ERROR: Unknown option for output: '" << output << "'" << endl;
1f50d9b1 211 return;
212 }
cc76079a 213
cc76079a 214 TString chainOpt = chainType;
215 if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
216 {
cc76079a 217 buildDDLRecoComps = true;
218 buildTrackerComp = true;
52c6d8aa 219 buildDecisionComp = true;
fa41da55 220 buildESDComp = true;
52c6d8aa 221
222 TString dataOpt = dataSource;
223 if (dataOpt.CompareTo("file", TString::kIgnoreCase) == 0)
224 {
225 buildDDLFilePubs = true;
226 }
227 else if (dataOpt.CompareTo("rawreader", TString::kIgnoreCase) == 0)
228 {
229 buildRawReaderPubs = true;
230 }
231 else
232 {
233 cerr << "ERROR: Unknown option for dataSource: '" << dataSource
234 << "'. Valid options are: 'file' or 'rawreader'" << endl;
235 return;
236 }
237 }
238 else if (chainOpt.CompareTo("full-tracker", TString::kIgnoreCase) == 0)
239 {
240 buildDDLRecoComps = true;
241 buildFullTrackerComp = true;
242 buildDecisionComp = true;
fa41da55 243 buildESDComp = true;
90af8855 244
245 TString dataOpt = dataSource;
246 if (dataOpt.CompareTo("file", TString::kIgnoreCase) == 0)
247 {
248 buildDDLFilePubs = true;
249 }
250 else if (dataOpt.CompareTo("rawreader", TString::kIgnoreCase) == 0)
251 {
252 buildRawReaderPubs = true;
253 }
254 else
255 {
256 cerr << "ERROR: Unknown option for dataSource: '" << dataSource
257 << "'. Valid options are: 'file' or 'rawreader'" << endl;
258 return;
259 }
cc76079a 260 }
1f50d9b1 261 else if (chainOpt.CompareTo("ddlreco", TString::kIgnoreCase) == 0)
cc76079a 262 {
cc76079a 263 buildDDLRecoComps = true;
c9537879 264 buildDecisionComp = false;
fa41da55 265 buildESDComp = false;
90af8855 266
267 TString dataOpt = dataSource;
268 if (dataOpt.CompareTo("file", TString::kIgnoreCase) == 0)
269 {
270 buildDDLFilePubs = true;
271 }
272 else if (dataOpt.CompareTo("rawreader", TString::kIgnoreCase) == 0)
273 {
274 buildRawReaderPubs = true;
275 }
276 else
277 {
278 cerr << "ERROR: Unknown option for dataSource: '" << dataSource
279 << "'. Valid options are: 'file' or 'rawreader'" << endl;
280 return;
281 }
cc76079a 282 }
283 else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
284 {
cc76079a 285 buildTrackerComp = true;
52c6d8aa 286 buildDecisionComp = true;
fa41da55 287 buildESDComp = true;
1f50d9b1 288
cc76079a 289 TString dataOpt = dataSource;
290 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
291 {
292 buildSimDataPubs = true;
293 }
294 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
295 {
296 buildRecDataPubs = true;
297 }
298 else
299 {
90af8855 300 cerr << "ERROR: Unknown option for dataSource: '" << dataSource
301 << "'. Valid options are: 'sim' or 'rec'" << endl;
cc76079a 302 return;
303 }
304 }
1f50d9b1 305 else
306 {
90af8855 307 cerr << "ERROR: Unknown option for chainType: '" << chainType << "'" << endl;
1f50d9b1 308 return;
309 }
cc76079a 310
311 TString logOpt = logLevel;
a563b588 312 if (logOpt.CompareTo("normal", TString::kIgnoreCase) == 0)
cc76079a 313 {
314 // nothing to do.
315 }
24f12607 316 else if (logOpt.CompareTo("debug", TString::kIgnoreCase) == 0)
317 {
318 debugLogging = true;
319 }
a563b588 320 else if (logOpt.CompareTo("max", TString::kIgnoreCase) == 0)
cc76079a 321 {
322 maxLogging = true;
323 }
a563b588 324 else if (logOpt.CompareTo("min", TString::kIgnoreCase) == 0)
cc76079a 325 {
326 minLogging = true;
327 }
328 else
329 {
90af8855 330 cerr << "ERROR: Unknown option for logLevel: '" << logLevel << "'" << endl;
cc76079a 331 return;
332 }
333
1f50d9b1 334 // If we are supposed to make tracks only but are in a ddlreco chain
335 // then we clearly can only generate the DDL reconstructed data, so do that.
336 if (makeTracksOnly && ! buildTrackerComp)
337 {
338 makeTracksOnly = false;
339 }
340
cc76079a 341 // Now we can initialise the AliHLTSystem...
342 AliHLTSystem sys;
cc76079a 343
344 // Start by setting up the logging.
345 if (maxLogging)
346 {
347 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
348 sys.SetGlobalLoggingLevel(kHLTLogAll);
349 }
24f12607 350 if (debugLogging)
351 {
352 AliLog::SetModuleDebugLevel("HLT", AliLog::kMaxType);
353 sys.SetGlobalLoggingLevel(kHLTLogAll);
354 }
cc76079a 355 if (minLogging)
356 {
1b3806c8 357 sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(
358 kHLTLogFatal | kHLTLogError
359 ));
cc76079a 360 }
a563b588 361
1f614081 362 sys.LoadComponentLibraries("libAliHLTUtil.so");
363 sys.LoadComponentLibraries("libAliHLTMUON.so");
cc76079a 364
365 // The DDL file publishers are only needed if we create the ddlreco or
366 // full chains. The filename lists are built assuming the aliroot rawXX/
367 // directory structure.
368 if (buildDDLFilePubs)
369 {
52c6d8aa 370 string cmd1 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000001";
371 string cmd2 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000002";
372 string cmd3 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000004";
373 string cmd4 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000008";
374 string cmd5 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000010";
375 string cmd6 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000020";
376 string cmd7 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000040";
377 string cmd8 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000080";
378 string cmd9 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000100";
379 string cmd10 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000200";
380 string cmd11 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000400";
381 string cmd12 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x000800";
668eee9f 382 string cmd13 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
383 string cmd14 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
384 string cmd15 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
385 string cmd16 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
386 string cmd17 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
387 string cmd18 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
388 string cmd19 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
389 string cmd20 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
390 string cmd21 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
391 string cmd22 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
cc76079a 392 for (int i = firstEvent; i < lastEvent+1; i++)
393 {
394 if (i != 0)
395 {
396 cmd13 += " -nextevent";
397 cmd14 += " -nextevent";
398 cmd15 += " -nextevent";
399 cmd16 += " -nextevent";
400 cmd17 += " -nextevent";
401 cmd18 += " -nextevent";
402 cmd19 += " -nextevent";
403 cmd20 += " -nextevent";
404 cmd21 += " -nextevent";
405 cmd22 += " -nextevent";
406 }
407 char buf[16];
408 sprintf(buf, "%d", i);
52c6d8aa 409 cmd1 += " -datafile "; cmd1 += rawDataPath; cmd1 += "raw"; cmd1 += buf; cmd1 += "/MUONTRK_2560.ddl";
410 cmd2 += " -datafile "; cmd2 += rawDataPath; cmd2 += "raw"; cmd2 += buf; cmd2 += "/MUONTRK_2561.ddl";
411 cmd3 += " -datafile "; cmd3 += rawDataPath; cmd3 += "raw"; cmd3 += buf; cmd3 += "/MUONTRK_2562.ddl";
412 cmd4 += " -datafile "; cmd4 += rawDataPath; cmd4 += "raw"; cmd4 += buf; cmd4 += "/MUONTRK_2563.ddl";
413 cmd5 += " -datafile "; cmd5 += rawDataPath; cmd5 += "raw"; cmd5 += buf; cmd5 += "/MUONTRK_2564.ddl";
414 cmd6 += " -datafile "; cmd6 += rawDataPath; cmd6 += "raw"; cmd6 += buf; cmd6 += "/MUONTRK_2565.ddl";
415 cmd7 += " -datafile "; cmd7 += rawDataPath; cmd7 += "raw"; cmd7 += buf; cmd7 += "/MUONTRK_2566.ddl";
416 cmd8 += " -datafile "; cmd8 += rawDataPath; cmd8 += "raw"; cmd8 += buf; cmd8 += "/MUONTRK_2567.ddl";
417 cmd9 += " -datafile "; cmd9 += rawDataPath; cmd9 += "raw"; cmd9 += buf; cmd9 += "/MUONTRK_2568.ddl";
418 cmd10 += " -datafile "; cmd10 += rawDataPath; cmd10 += "raw"; cmd10 += buf; cmd10 += "/MUONTRK_2569.ddl";
419 cmd11 += " -datafile "; cmd11 += rawDataPath; cmd11 += "raw"; cmd11 += buf; cmd11 += "/MUONTRK_2570.ddl";
420 cmd12 += " -datafile "; cmd12 += rawDataPath; cmd12 += "raw"; cmd12 += buf; cmd12 += "/MUONTRK_2571.ddl";
90af8855 421 cmd13 += " -datafile "; cmd13 += rawDataPath; cmd13 += "raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
422 cmd14 += " -datafile "; cmd14 += rawDataPath; cmd14 += "raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
423 cmd15 += " -datafile "; cmd15 += rawDataPath; cmd15 += "raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
424 cmd16 += " -datafile "; cmd16 += rawDataPath; cmd16 += "raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
425 cmd17 += " -datafile "; cmd17 += rawDataPath; cmd17 += "raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
426 cmd18 += " -datafile "; cmd18 += rawDataPath; cmd18 += "raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
427 cmd19 += " -datafile "; cmd19 += rawDataPath; cmd19 += "raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
428 cmd20 += " -datafile "; cmd20 += rawDataPath; cmd20 += "raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
429 cmd21 += " -datafile "; cmd21 += rawDataPath; cmd21 += "raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
430 cmd22 += " -datafile "; cmd22 += rawDataPath; cmd22 += "raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
cc76079a 431 }
52c6d8aa 432
433 AliHLTConfiguration pubDDL1("pubDDL1", "FilePublisher", NULL, cmd1.c_str());
434 AliHLTConfiguration pubDDL2("pubDDL2", "FilePublisher", NULL, cmd2.c_str());
435 AliHLTConfiguration pubDDL3("pubDDL3", "FilePublisher", NULL, cmd3.c_str());
436 AliHLTConfiguration pubDDL4("pubDDL4", "FilePublisher", NULL, cmd4.c_str());
437 AliHLTConfiguration pubDDL5("pubDDL5", "FilePublisher", NULL, cmd5.c_str());
438 AliHLTConfiguration pubDDL6("pubDDL6", "FilePublisher", NULL, cmd6.c_str());
439 AliHLTConfiguration pubDDL7("pubDDL7", "FilePublisher", NULL, cmd7.c_str());
440 AliHLTConfiguration pubDDL8("pubDDL8", "FilePublisher", NULL, cmd8.c_str());
441 AliHLTConfiguration pubDDL9("pubDDL9", "FilePublisher", NULL, cmd9.c_str());
442 AliHLTConfiguration pubDDL10("pubDDL10", "FilePublisher", NULL, cmd10.c_str());
443 AliHLTConfiguration pubDDL11("pubDDL11", "FilePublisher", NULL, cmd11.c_str());
444 AliHLTConfiguration pubDDL12("pubDDL12", "FilePublisher", NULL, cmd12.c_str());
cc76079a 445 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
446 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
447 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
448 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
449 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
450 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
451 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
452 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
453 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
454 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
455 }
90af8855 456
457 // Build the DDL file publishers using AliRawReaderPublisher components.
458 if (buildRawReaderPubs)
459 {
52c6d8aa 460 string cmd1 = "-skipempty -minid 2560 -maxid 2560 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000001";
461 string cmd2 = "-skipempty -minid 2561 -maxid 2561 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000002";
462 string cmd3 = "-skipempty -minid 2562 -maxid 2562 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000004";
463 string cmd4 = "-skipempty -minid 2563 -maxid 2563 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000008";
464 string cmd5 = "-skipempty -minid 2564 -maxid 2564 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000010";
465 string cmd6 = "-skipempty -minid 2565 -maxid 2565 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000020";
466 string cmd7 = "-skipempty -minid 2566 -maxid 2566 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000040";
467 string cmd8 = "-skipempty -minid 2567 -maxid 2567 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000080";
468 string cmd9 = "-skipempty -minid 2568 -maxid 2568 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000100";
469 string cmd10 = "-skipempty -minid 2569 -maxid 2569 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000200";
470 string cmd11 = "-skipempty -minid 2570 -maxid 2570 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000400";
471 string cmd12 = "-skipempty -minid 2571 -maxid 2571 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x000800";
90af8855 472 string cmd13 = "-skipempty -minid 2572 -maxid 2572 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
473 string cmd14 = "-skipempty -minid 2573 -maxid 2573 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
474 string cmd15 = "-skipempty -minid 2574 -maxid 2574 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
475 string cmd16 = "-skipempty -minid 2575 -maxid 2575 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
476 string cmd17 = "-skipempty -minid 2576 -maxid 2576 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
477 string cmd18 = "-skipempty -minid 2577 -maxid 2577 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
478 string cmd19 = "-skipempty -minid 2578 -maxid 2578 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
479 string cmd20 = "-skipempty -minid 2579 -maxid 2579 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
480 string cmd21 = "-skipempty -minid 2816 -maxid 2816 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
481 string cmd22 = "-skipempty -minid 2817 -maxid 2817 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
482
52c6d8aa 483 AliHLTConfiguration pubDDL1("pubDDL1", "AliRawReaderPublisher", NULL, cmd1.c_str());
484 AliHLTConfiguration pubDDL2("pubDDL2", "AliRawReaderPublisher", NULL, cmd2.c_str());
485 AliHLTConfiguration pubDDL3("pubDDL3", "AliRawReaderPublisher", NULL, cmd3.c_str());
486 AliHLTConfiguration pubDDL4("pubDDL4", "AliRawReaderPublisher", NULL, cmd4.c_str());
487 AliHLTConfiguration pubDDL5("pubDDL5", "AliRawReaderPublisher", NULL, cmd5.c_str());
488 AliHLTConfiguration pubDDL6("pubDDL6", "AliRawReaderPublisher", NULL, cmd6.c_str());
489 AliHLTConfiguration pubDDL7("pubDDL7", "AliRawReaderPublisher", NULL, cmd7.c_str());
490 AliHLTConfiguration pubDDL8("pubDDL8", "AliRawReaderPublisher", NULL, cmd8.c_str());
491 AliHLTConfiguration pubDDL9("pubDDL9", "AliRawReaderPublisher", NULL, cmd9.c_str());
492 AliHLTConfiguration pubDDL10("pubDDL10", "AliRawReaderPublisher", NULL, cmd10.c_str());
493 AliHLTConfiguration pubDDL11("pubDDL11", "AliRawReaderPublisher", NULL, cmd11.c_str());
494 AliHLTConfiguration pubDDL12("pubDDL12", "AliRawReaderPublisher", NULL, cmd12.c_str());
90af8855 495 AliHLTConfiguration pubDDL13("pubDDL13", "AliRawReaderPublisher", NULL, cmd13.c_str());
496 AliHLTConfiguration pubDDL14("pubDDL14", "AliRawReaderPublisher", NULL, cmd14.c_str());
497 AliHLTConfiguration pubDDL15("pubDDL15", "AliRawReaderPublisher", NULL, cmd15.c_str());
498 AliHLTConfiguration pubDDL16("pubDDL16", "AliRawReaderPublisher", NULL, cmd16.c_str());
499 AliHLTConfiguration pubDDL17("pubDDL17", "AliRawReaderPublisher", NULL, cmd17.c_str());
500 AliHLTConfiguration pubDDL18("pubDDL18", "AliRawReaderPublisher", NULL, cmd18.c_str());
501 AliHLTConfiguration pubDDL19("pubDDL19", "AliRawReaderPublisher", NULL, cmd19.c_str());
502 AliHLTConfiguration pubDDL20("pubDDL20", "AliRawReaderPublisher", NULL, cmd20.c_str());
503 AliHLTConfiguration pubDDL21("pubDDL21", "AliRawReaderPublisher", NULL, cmd21.c_str());
504 AliHLTConfiguration pubDDL22("pubDDL22", "AliRawReaderPublisher", NULL, cmd22.c_str());
505 }
cc76079a 506
507 // Build the DDL reconstructor components for all the DDLs 13 to 22, that
508 // is for chambers 7 to 10 and trigger stations. We only need to build
509 // these components if we are are building the ddlreco or full chains.
510 if (buildDDLRecoComps)
511 {
1d8ae082 512 const char* recoverFlag = tryrecover ? "-tryrecover" : "";
52c6d8aa 513 for (int k = 1; k <= 22; k++)
1b3806c8 514 {
1d8ae082 515 string compId = Form("recDDL%d", k);
516 string name = (k <= 20) ? "MUONHitReconstructor" : "MUONTriggerReconstructor";
517 string parent = Form("pubDDL%d", k);
518 string cmd;
462e3880 519 const char* extraInfoFlags = k < 21 ? "-makeclusters -makechannels" : "-makedebuginfo";
1d8ae082 520 if (TString(lutDir) == "CDB")
521 {
522 const char* path = cdbManager->GetDefaultStorage()->GetURI().Data();
462e3880 523 cmd = Form("-ddl %d -cdbpath %s -run %d %s %s",
524 k, path, cdbManager->GetRun(), recoverFlag, extraInfoFlags
1d8ae082 525 );
526 }
527 else
528 {
462e3880 529 cmd = Form("-ddl %d -lut %s/Lut%d.dat %s %s",
530 k, lutDir, k, recoverFlag, extraInfoFlags
1d8ae082 531 );
532 }
533 if (k >= 21)
534 {
535 cmd += " -suppress_partial_triggers -dont_use_crateid -dont_use_localid";
536 }
537 AliHLTConfiguration recDDL(compId.c_str(), name.c_str(), parent.c_str(), cmd.c_str());
1b3806c8 538 }
1f50d9b1 539 }
540
541 TString startEventStr = "-firstevent ";
542 startEventStr += firstEvent;
ee3678d3 543
1f50d9b1 544 // Build the data source components to take data from simulated hits if
545 // we are building the tracker only chain with the 'sim' data source.
cc76079a 546 if (buildSimDataPubs)
547 {
52c6d8aa 548 AliHLTConfiguration recDDL1("recDDL1", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 1");
549 AliHLTConfiguration recDDL2("recDDL2", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 1");
550 AliHLTConfiguration recDDL3("recDDL3", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 2");
551 AliHLTConfiguration recDDL4("recDDL4", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 2");
552 AliHLTConfiguration recDDL5("recDDL5", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 3");
553 AliHLTConfiguration recDDL6("recDDL6", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 3");
554 AliHLTConfiguration recDDL7("recDDL7", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 4");
555 AliHLTConfiguration recDDL8("recDDL8", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 4");
556 AliHLTConfiguration recDDL9("recDDL9", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 5");
557 AliHLTConfiguration recDDL10("recDDL10", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 5");
558 AliHLTConfiguration recDDL11("recDDL11", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 6");
559 AliHLTConfiguration recDDL12("recDDL12", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 6");
1f50d9b1 560 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 7");
561 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 7");
562 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 8");
563 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 8");
564 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 9");
565 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 9");
566 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 10");
567 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 10");
568 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane left");
569 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane right");
cc76079a 570 }
571
572 // Build the data source components to take data from offline reconstructed
573 // objects if we are building the tracker only chain with the 'rec' data source.
574 if (buildRecDataPubs)
575 {
52c6d8aa 576 AliHLTConfiguration recDDL1("recDDL1", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 1");
577 AliHLTConfiguration recDDL2("recDDL2", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 1");
578 AliHLTConfiguration recDDL3("recDDL3", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 2");
579 AliHLTConfiguration recDDL4("recDDL4", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 2");
580 AliHLTConfiguration recDDL5("recDDL5", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 3");
581 AliHLTConfiguration recDDL6("recDDL6", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 3");
582 AliHLTConfiguration recDDL7("recDDL7", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 4");
583 AliHLTConfiguration recDDL8("recDDL8", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 4");
584 AliHLTConfiguration recDDL9("recDDL9", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 5");
585 AliHLTConfiguration recDDL10("recDDL10", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 5");
586 AliHLTConfiguration recDDL11("recDDL11", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 6");
587 AliHLTConfiguration recDDL12("recDDL12", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 6");
1f50d9b1 588 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 7");
589 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 7");
590 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 8");
591 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 8");
592 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 9");
593 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 9");
594 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 10");
595 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 10");
596 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane left");
597 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane right");
cc76079a 598 }
599
600 // Build the tracker component if we are building the tracker only or
601 // full chains.
602 if (buildTrackerComp)
603 {
bc5cb6d6 604 AliHLTConfiguration tracker(
605 "tracker",
606 "MUONMansoTrackerFSM",
607 "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22",
608 "-makecandidates"
609 );
cc76079a 610 }
52c6d8aa 611 if (buildFullTrackerComp)
612 {
613 AliHLTConfiguration fulltracker(
614 "tracker-full",
615 "MUONFullTracker",
616 "recDDL1 recDDL2 recDDL3 recDDL4 recDDL5 recDDL6 recDDL7 recDDL8 recDDL9 recDDL10 recDDL11"
617 " recDDL12 recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22",
618 ""
619 );
620 }
c9537879 621
622 // Build the dHLT trigger decision component if enabled.
623 if (buildDecisionComp)
624 {
52c6d8aa 625 const char* decisionSource = "tracker";
626 if (buildFullTrackerComp) decisionSource = "tracker-full";
627 AliHLTConfiguration decision("decision", "MUONDecisionComponent", decisionSource, "");
c9537879 628 }
fa41da55 629 if (buildESDComp)
630 {
631 const char* ESDSource = "tracker recDDL21 recDDL22 ";
632 if (buildFullTrackerComp) ESDSource = "tracker-full recDDL21 recDDL22 ";
633 AliHLTConfiguration ESD("ESD", AliHLTMUONConstants::ESDMakerId(), ESDSource, " -make_minimal_esd");
634 }
cc76079a 635
1f50d9b1 636 // Build the data sink to subscribe only to what has been created and
637 // to the data source we actaully want.
638 TString sources = "";
639 if (makeTracksOnly)
cc76079a 640 {
1f50d9b1 641 sources += "tracker ";
cc76079a 642 }
1f50d9b1 643 else
644 {
52c6d8aa 645 if (buildTrackerComp) sources += "tracker ";
646 if (buildFullTrackerComp) sources += "tracker-full ";
647 sources += "recDDL1 recDDL2 recDDL3 recDDL4 recDDL5 recDDL6 recDDL7 recDDL8 recDDL9 recDDL10 recDDL11"
648 " recDDL12 recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
1f50d9b1 649 }
c9537879 650 if (buildDecisionComp)
651 {
652 // Add the trigger decision component if it was enabled.
653 sources += " decision";
654 }
fa41da55 655 if (buildESDComp)
656 {
657 sources += " ESD ";
658 }
dba14d7d 659
660 // Build the data checker component if so requested.
661 if (checkData)
662 {
663 AliHLTConfiguration checker("checker", "MUONDataChecker", sources, "-warn_on_unexpected_block");
f064ef44 664 sources = "checker"; // Only add the checker to the sources in this case since it will forward just the bad events.
dba14d7d 665 }
666
1f50d9b1 667 if (useRootWriter)
668 {
669 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
d8cf7391 670 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-concatenate-events -datafile output.root -specfmt");
1f50d9b1 671 }
672 else
cc76079a 673 {
1f50d9b1 674 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
cc76079a 675 }
676
1f50d9b1 677 // Build and run the chain's tasks.
678 sys.BuildTaskList("sink");
90af8855 679 if (buildDDLFilePubs)
680 {
681 sys.Run(eventCount);
682 }
683 else
684 {
685 // Setup the raw reader.
686 AliRawReader* rawReader = AliRawReader::Create(rawDataPath);
687 if (rawReader == NULL)
688 {
689 cerr << "ERROR: Could not create raw reader." << endl;
690 return;
691 }
692 if (! rawReader->IsRawReaderValid())
693 {
694 cerr << "ERROR: Raw reader is not valid." << endl;
695 return;
696 }
697 AliHLTOfflineInterface::SetParamsToComponents(NULL, rawReader);
1d8ae082 698 rawReader->NextEvent(); // Need to call this once here or we will start at the wrong event.
90af8855 699 // Now step through the events.
700 for (int i = 0; i < firstEvent; i++) rawReader->NextEvent();
701 for (int i = firstEvent; i <= lastEvent; i++)
702 {
703 // The "(i == lastEvent) ? 1 : 0" part is to indicate a
704 // stop run command when we hit the last event.
705 sys.Run(1, (i == lastEvent) ? 1 : 0);
706 rawReader->NextEvent();
707 }
708 }
cc76079a 709}