]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/macros/RunChain.C
Fixes to trigger reconstruction component to handle real data better.
[u/mrichter/AliRoot.git] / HLT / MUON / macros / RunChain.C
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        *
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
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
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.
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>
41  */
42
43 #if !defined(__CINT__) || defined(__MAKECINT__)
44 #include "AliRawReader.h"
45 #include "AliHLTOfflineInterface.h"
46 #include "AliCDBManager.h"
47 #include "AliHLTSystem.h"
48 #include "AliHLTConfiguration.h"
49 #include "AliLog.h"
50 #include "TString.h"
51 #include <iostream>
52 using std::cerr;
53 using std::endl;
54 #endif
55
56 /**
57  * Used to run the dimuon HLT (dHLT) chain in various configuration in a standalone
58  * configuration. This is normally used for debugging, testing and can also be used
59  * as an example of how to build chains for dHLT by hand.
60  *
61  * @param chainType  Specifies the type of chain to run. This can be one of the
62  *     following:
63  *       "full" - Run the full dHLT chain. (default)
64  *       "ddlreco" - Run only the reconstruction of the DDL raw data up to hits
65  *                   and trigger records.
66  *       "tracker" - Run the tracker only using hits and trigger records from
67  *                   AliRoot simulation or offline reconstruction.
68  * @param firstEvent  The event number of the first event to process. (default = 0)
69  * @param lastEvent  The event number of the last event to process. If this is
70  *     less than firstEvent then it is set to firstEvent automatically. (default = -1)
71  * @param output  Specifies the kind of output to generate. The options can be one
72  *     of the following:
73  *       "bin" - Generates all possible output and dumps it to binary files
74  *                  using the FileWriter component.
75  *       "root" - Generates all possible output and writes it to a ROOT file
76  *                  using the ROOTFileWriter component.
77  *       "tracks_bin" - Generates only track data and dumps it to binary files
78  *                  using the FileWriter component. This option is equivalent to
79  *                  'bin' if the chain type is 'ddlreco'.
80  *       "tracks_root" - Generates only track data and writes it to a ROOT file
81  *                  using the ROOTFileWriter component. This option is equivalent
82  *                  to 'bin' if the chain type is 'ddlreco'.
83  * @param dataSource  This is the data source from which to use hits and trigger
84  *     records when we are running the tracker only chain and the DDL raw data
85  *     reading method when running the 'full' or 'ddlreco' chain. If the
86  *     chainType = "full" or "ddlreco", then the possible options are:
87  *       "file"      - Reads the raw data directly from the DDL files. (default)
88  *       "rawreader" - Reads the raw data using the AliRawReader interface from
89  *               the current working directory.
90  *     If the chainType = "tracker", then the possible options are:
91  *       "sim" - Take data from GEANT hits. (default)
92  *       "rec" - Take data from offline reconstructed hits and local trigger
93  *               objects.
94  * @param logLevel  Specifies the amount of logging messages produced by the HLT
95  *     system. The possible options are:
96  *       "normal" - Shows warnings, errors and information.
97  *       "debug" - Shows all messages up to the debug level only for HLT and the
98  *                 same as normal for all other modules.
99  *       "max" - Shows everything including debug messages if they were compiled in.
100  *       "min" - Shows only error messages.
101  * @param lutDir  This is the directory in which the LUTs can be found.
102  *      If it is set to "CDB" (case sensitive) then the LUTs will be loaded from
103  *      CDB instead. The default behaviour is to read from the local CDB store.
104  * @param checkData  A flag for indicating if the event data should be checked
105  *      for consistency with the AliHLTMUONDataCheckerComponent.
106  * @param rawDataPath  The path of the raw data (i.e. path to the rawXX directories)
107  *      or can be the file name if using the "rawreader" option for dataSource.
108  * @param runNumber  Specifies the run number to use. If it is set to -1 then the
109  *      run number is not set if the CDB manager already has a run number set,
110  *      otherwise a default run number of 0 is used. The default value is -1.
111  * @param cdbPath  This gives the CDB path to use. If it is set to NULL then
112  *      the CDB path is not set if the CDB manager already has a default storage
113  *      CDB path set, otherwise a default value of "local://$ALICE_ROOT/OCDB" is used.
114  *      The default value is NULL.
115  * @param tryrecover  If this is true then the "-tryrecover" flag is set in the
116  *      raw data reconstruction components. This is useful if when running RunChain
117  *      log messages appear indicating that there was a problem decoding the raw data.
118  *      The "-tryrecover" flag will turn on recovery logic in the raw data decoders
119  *      to try and overcome errors in the data.
120  */
121 void RunChain(
122                 const char* chainType = "full",
123                 Int_t firstEvent = 0,
124                 Int_t lastEvent = -1,
125                 const char* output = "bin",
126                 const char* dataSource = "file",
127                 const char* logLevel = "normal",
128                 const char* lutDir = "CDB",
129                 bool checkData = false,
130                 const char* rawDataPath = "./",
131                 Int_t runNumber = -1,
132                 const char* cdbPath = NULL,
133                 bool tryrecover = false
134         )
135 {
136         // Setup the CDB default storage and run number if nothing was set.
137         AliCDBManager* cdbManager = AliCDBManager::Instance();
138         if (cdbManager == NULL)
139         {
140                 cerr << "ERROR: Global CDB manager object does not exist." << endl;
141                 return;
142         }
143         if (runNumber != -1)
144         {
145                 cdbManager->SetRun(runNumber);
146         }
147         else if (cdbManager->GetRun() == -1)
148         {
149                 cdbManager->SetRun(0);
150         }
151         if (cdbPath != NULL)
152         {
153                 cdbManager->SetDefaultStorage(cdbPath);
154         }
155         else if (cdbManager->GetDefaultStorage() == NULL)
156         {
157                 cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
158         }
159         
160         if (cdbManager->GetDefaultStorage() == NULL)
161         {
162                 cerr << "ERROR: There is no value for the default CDB storage, cannot continue." << endl;
163                 return;
164         }
165
166         // Make sure that the lastEvent is greater than firstEvent.
167         if (lastEvent < firstEvent)
168                 lastEvent = firstEvent;
169         int eventCount = lastEvent - firstEvent + 1;
170         
171         bool buildDDLFilePubs = false;
172         bool buildRawReaderPubs = false;
173         bool buildDDLRecoComps = false;
174         bool buildSimDataPubs = false;
175         bool buildRecDataPubs = false;
176         bool buildTrackerComp = false;
177         bool maxLogging = false;
178         bool debugLogging = false;
179         bool minLogging = false;
180         bool useRootWriter = false;
181         bool makeTracksOnly = false;
182         bool buildDecisionComp = true;
183         
184         // Parse the chainType, output, dataSource and logLevel option strings:
185         TString outOpt = output;
186         if (outOpt.CompareTo("bin", TString::kIgnoreCase) == 0)
187         {
188                 useRootWriter = false;
189         }
190         else if (outOpt.CompareTo("root", TString::kIgnoreCase) == 0)
191         {
192                 useRootWriter = true;
193         }
194         else if (outOpt.CompareTo("tracks_bin", TString::kIgnoreCase) == 0)
195         {
196                 useRootWriter = false;
197                 makeTracksOnly = true;
198         }
199         else if (outOpt.CompareTo("tracks_root", TString::kIgnoreCase) == 0)
200         {
201                 useRootWriter = true;
202                 makeTracksOnly = true;
203         }
204         else
205         {
206                 cerr << "ERROR: Unknown option for output: '" << output << "'" << endl;
207                 return;
208         }
209         
210         TString chainOpt = chainType;
211         if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
212         {
213                 buildDDLRecoComps = true;
214                 buildTrackerComp = true;
215                 
216                 TString dataOpt = dataSource;
217                 if (dataOpt.CompareTo("file", TString::kIgnoreCase) == 0)
218                 {
219                         buildDDLFilePubs = true;
220                 }
221                 else if (dataOpt.CompareTo("rawreader", TString::kIgnoreCase) == 0)
222                 {
223                         buildRawReaderPubs = true;
224                 }
225                 else
226                 {
227                         cerr << "ERROR: Unknown option for dataSource: '" << dataSource
228                                 << "'. Valid options are: 'file' or 'rawreader'" << endl;
229                         return;
230                 }
231         }
232         else if (chainOpt.CompareTo("ddlreco", TString::kIgnoreCase) == 0)
233         {
234                 buildDDLRecoComps = true;
235                 buildDecisionComp = false;
236                 
237                 TString dataOpt = dataSource;
238                 if (dataOpt.CompareTo("file", TString::kIgnoreCase) == 0)
239                 {
240                         buildDDLFilePubs = true;
241                 }
242                 else if (dataOpt.CompareTo("rawreader", TString::kIgnoreCase) == 0)
243                 {
244                         buildRawReaderPubs = true;
245                 }
246                 else
247                 {
248                         cerr << "ERROR: Unknown option for dataSource: '" << dataSource
249                                 << "'. Valid options are: 'file' or 'rawreader'" << endl;
250                         return;
251                 }
252         }
253         else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
254         {
255                 buildTrackerComp = true;
256                 
257                 TString dataOpt = dataSource;
258                 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
259                 {
260                         buildSimDataPubs = true;
261                 }
262                 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
263                 {
264                         buildRecDataPubs = true;
265                 }
266                 else
267                 {
268                         cerr << "ERROR: Unknown option for dataSource: '" << dataSource
269                                 << "'. Valid options are: 'sim' or 'rec'" << endl;
270                         return;
271                 }
272         }
273         else
274         {
275                 cerr << "ERROR: Unknown option for chainType: '" << chainType << "'" << endl;
276                 return;
277         }
278         
279         TString logOpt = logLevel;
280         if (logOpt.CompareTo("normal", TString::kIgnoreCase) == 0)
281         {
282                 // nothing to do.
283         }
284         else if (logOpt.CompareTo("debug", TString::kIgnoreCase) == 0)
285         {
286                 debugLogging = true;
287         }
288         else if (logOpt.CompareTo("max", TString::kIgnoreCase) == 0)
289         {
290                 maxLogging = true;
291         }
292         else if (logOpt.CompareTo("min", TString::kIgnoreCase) == 0)
293         {
294                 minLogging = true;
295         }
296         else
297         {
298                 cerr << "ERROR: Unknown option for logLevel: '" << logLevel << "'" << endl;
299                 return;
300         }
301         
302         // If we are supposed to make tracks only but are in a ddlreco chain
303         // then we clearly can only generate the DDL reconstructed data, so do that.
304         if (makeTracksOnly && ! buildTrackerComp)
305         {
306                 makeTracksOnly = false;
307         }
308         
309         // Now we can initialise the AliHLTSystem...
310         AliHLTSystem sys;
311         
312         // Start by setting up the logging.
313         if (maxLogging)
314         {
315                 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
316                 sys.SetGlobalLoggingLevel(kHLTLogAll);
317         }
318         if (debugLogging)
319         {
320                 AliLog::SetModuleDebugLevel("HLT", AliLog::kMaxType);
321                 sys.SetGlobalLoggingLevel(kHLTLogAll);
322         }
323         if (minLogging)
324         {
325                 sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(
326                         kHLTLogFatal | kHLTLogError
327                 ));
328         }
329         
330         sys.LoadComponentLibraries("libAliHLTUtil.so");
331         sys.LoadComponentLibraries("libAliHLTMUON.so");
332
333         // The DDL file publishers are only needed if we create the ddlreco or
334         // full chains. The filename lists are built assuming the aliroot rawXX/
335         // directory structure.
336         if (buildDDLFilePubs)
337         {
338                 string cmd13 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
339                 string cmd14 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
340                 string cmd15 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
341                 string cmd16 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
342                 string cmd17 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
343                 string cmd18 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
344                 string cmd19 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
345                 string cmd20 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
346                 string cmd21 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
347                 string cmd22 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
348                 for (int i = firstEvent; i < lastEvent+1; i++)
349                 {
350                         if (i != 0)
351                         {
352                                 cmd13 += " -nextevent";
353                                 cmd14 += " -nextevent";
354                                 cmd15 += " -nextevent";
355                                 cmd16 += " -nextevent";
356                                 cmd17 += " -nextevent";
357                                 cmd18 += " -nextevent";
358                                 cmd19 += " -nextevent";
359                                 cmd20 += " -nextevent";
360                                 cmd21 += " -nextevent";
361                                 cmd22 += " -nextevent";
362                         }
363                         char buf[16];
364                         sprintf(buf, "%d", i);
365                         cmd13 += " -datafile "; cmd13 += rawDataPath; cmd13 += "raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
366                         cmd14 += " -datafile "; cmd14 += rawDataPath; cmd14 += "raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
367                         cmd15 += " -datafile "; cmd15 += rawDataPath; cmd15 += "raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
368                         cmd16 += " -datafile "; cmd16 += rawDataPath; cmd16 += "raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
369                         cmd17 += " -datafile "; cmd17 += rawDataPath; cmd17 += "raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
370                         cmd18 += " -datafile "; cmd18 += rawDataPath; cmd18 += "raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
371                         cmd19 += " -datafile "; cmd19 += rawDataPath; cmd19 += "raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
372                         cmd20 += " -datafile "; cmd20 += rawDataPath; cmd20 += "raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
373                         cmd21 += " -datafile "; cmd21 += rawDataPath; cmd21 += "raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
374                         cmd22 += " -datafile "; cmd22 += rawDataPath; cmd22 += "raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
375                 }
376
377                 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
378                 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
379                 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
380                 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
381                 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
382                 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
383                 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
384                 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
385                 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
386                 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
387         }
388
389         // Build the DDL file publishers using AliRawReaderPublisher components.
390         if (buildRawReaderPubs)
391         {
392                 string cmd13 = "-skipempty -minid 2572 -maxid 2572 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
393                 string cmd14 = "-skipempty -minid 2573 -maxid 2573 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
394                 string cmd15 = "-skipempty -minid 2574 -maxid 2574 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
395                 string cmd16 = "-skipempty -minid 2575 -maxid 2575 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
396                 string cmd17 = "-skipempty -minid 2576 -maxid 2576 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
397                 string cmd18 = "-skipempty -minid 2577 -maxid 2577 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
398                 string cmd19 = "-skipempty -minid 2578 -maxid 2578 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
399                 string cmd20 = "-skipempty -minid 2579 -maxid 2579 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
400                 string cmd21 = "-skipempty -minid 2816 -maxid 2816 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
401                 string cmd22 = "-skipempty -minid 2817 -maxid 2817 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
402
403                 AliHLTConfiguration pubDDL13("pubDDL13", "AliRawReaderPublisher", NULL, cmd13.c_str());
404                 AliHLTConfiguration pubDDL14("pubDDL14", "AliRawReaderPublisher", NULL, cmd14.c_str());
405                 AliHLTConfiguration pubDDL15("pubDDL15", "AliRawReaderPublisher", NULL, cmd15.c_str());
406                 AliHLTConfiguration pubDDL16("pubDDL16", "AliRawReaderPublisher", NULL, cmd16.c_str());
407                 AliHLTConfiguration pubDDL17("pubDDL17", "AliRawReaderPublisher", NULL, cmd17.c_str());
408                 AliHLTConfiguration pubDDL18("pubDDL18", "AliRawReaderPublisher", NULL, cmd18.c_str());
409                 AliHLTConfiguration pubDDL19("pubDDL19", "AliRawReaderPublisher", NULL, cmd19.c_str());
410                 AliHLTConfiguration pubDDL20("pubDDL20", "AliRawReaderPublisher", NULL, cmd20.c_str());
411                 AliHLTConfiguration pubDDL21("pubDDL21", "AliRawReaderPublisher", NULL, cmd21.c_str());
412                 AliHLTConfiguration pubDDL22("pubDDL22", "AliRawReaderPublisher", NULL, cmd22.c_str());
413         }
414         
415         // Build the DDL reconstructor components for all the DDLs 13 to 22, that
416         // is for chambers 7 to 10 and trigger stations. We only need to build
417         // these components if we are are building the ddlreco or full chains.
418         if (buildDDLRecoComps)
419         {
420                 const char* recoverFlag = tryrecover ? "-tryrecover" : "";
421                 for (int k = 13; k <= 22; k++)
422                 {
423                         string compId = Form("recDDL%d", k);
424                         string name = (k <= 20) ? "MUONHitReconstructor" : "MUONTriggerReconstructor";
425                         string parent = Form("pubDDL%d", k);
426                         string cmd;
427                         const char* extraInfoFlags = k < 21 ? "-makeclusters -makechannels" : "-makedebuginfo";
428                         if (TString(lutDir) == "CDB")
429                         {
430                                 const char* path = cdbManager->GetDefaultStorage()->GetURI().Data();
431                                 cmd = Form("-ddl %d -cdbpath %s -run %d %s %s",
432                                         k, path, cdbManager->GetRun(), recoverFlag, extraInfoFlags
433                                 );
434                         }
435                         else
436                         {
437                                 cmd = Form("-ddl %d -lut %s/Lut%d.dat %s %s",
438                                         k, lutDir, k, recoverFlag, extraInfoFlags
439                                 );
440                         }
441                         if (k >= 21)
442                         {
443                                 cmd += " -suppress_partial_triggers -dont_use_crateid -dont_use_localid";
444                         }
445                         AliHLTConfiguration recDDL(compId.c_str(), name.c_str(), parent.c_str(), cmd.c_str());
446                 }
447         }
448
449         TString startEventStr = "-firstevent ";
450         startEventStr += firstEvent;
451         
452         // Build the data source components to take data from simulated hits if
453         // we are building the tracker only chain with the 'sim' data source.
454         if (buildSimDataPubs)
455         {
456                 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left  -chamber 7");
457                 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 7");
458                 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left  -chamber 8");
459                 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 8");
460                 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left  -chamber 9");
461                 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 9");
462                 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left  -chamber 10");
463                 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 10");
464                 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane left");
465                 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane right");
466         }
467         
468         // Build the data source components to take data from offline reconstructed
469         // objects if we are building the tracker only chain with the 'rec' data source.
470         if (buildRecDataPubs)
471         {
472                 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left  -chamber 7");
473                 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 7");
474                 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left  -chamber 8");
475                 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 8");
476                 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left  -chamber 9");
477                 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 9");
478                 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left  -chamber 10");
479                 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 10");
480                 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane left");
481                 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane right");
482         }
483         
484         // Build the tracker component if we are building the tracker only or
485         // full chains.
486         if (buildTrackerComp)
487         {
488                 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
489         }
490         
491         // Build the dHLT trigger decision component if enabled.
492         if (buildDecisionComp)
493         {
494                 AliHLTConfiguration decision("decision", "MUONDecisionComponent", "tracker", "");
495         }
496
497         // Build the data sink to subscribe only to what has been created and
498         // to the data source we actaully want.
499         TString sources = "";
500         if (makeTracksOnly)
501         {
502                 sources += "tracker ";
503         }
504         else
505         {
506                 if (buildTrackerComp)
507                         sources += "tracker ";
508                 sources += "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
509         }
510         if (buildDecisionComp)
511         {
512                 // Add the trigger decision component if it was enabled.
513                 sources += " decision";
514         }
515         
516         // Build the data checker component if so requested.
517         if (checkData)
518         {
519                 AliHLTConfiguration checker("checker", "MUONDataChecker", sources, "-warn_on_unexpected_block");
520                 sources = "checker";
521         }
522         
523         if (useRootWriter)
524         {
525                 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
526                 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-concatenate-events -datafile output.root -specfmt");
527         }
528         else
529         {
530                 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
531         }
532         
533         // Build and run the chain's tasks.
534         sys.BuildTaskList("sink");
535         if (buildDDLFilePubs)
536         {
537                 sys.Run(eventCount);
538         }
539         else
540         {
541                 // Setup the raw reader.
542                 AliRawReader* rawReader = AliRawReader::Create(rawDataPath);
543                 if (rawReader == NULL)
544                 {
545                         cerr << "ERROR: Could not create raw reader." << endl;
546                         return;
547                 }
548                 if (! rawReader->IsRawReaderValid())
549                 {
550                         cerr << "ERROR: Raw reader is not valid." << endl;
551                         return;
552                 }
553                 AliHLTOfflineInterface::SetParamsToComponents(NULL, rawReader);
554                 rawReader->NextEvent(); // Need to call this once here or we will start at the wrong event.
555                 // Now step through the events.
556                 for (int i = 0; i < firstEvent; i++) rawReader->NextEvent();
557                 for (int i = firstEvent; i <= lastEvent; i++)
558                 {
559                         // The "(i == lastEvent) ? 1 : 0" part is to indicate a
560                         // stop run command when we hit the last event.
561                         sys.Run(1, (i == lastEvent) ? 1 : 0);
562                         rawReader->NextEvent();
563                 }
564         }
565 }