Fixing code so that components use the new standard DDL_RAW data type.
[u/mrichter/AliRoot.git] / HLT / MUON / macros / RunChain.C
CommitLineData
cc76079a 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/* This macro is used to run the dHLT component chain within the AliHLTSystem
18 * framework, which is a simulation of the dHLT online system's output.
19 * To run this macro you must be in the same directory as the galice.root
20 * files or in the directory containing the rawXX/ directories produced from
21 * AliRoot simulations.
1f50d9b1 22 * Also make sure the LUTs are in the same directory or specify the directory
23 * with the lutDir parameter option.
cc76079a 24 */
25
26#if !defined(__CINT__) || defined(__MAKECINT__)
27#include "HLT/BASE/AliHLTSystem.h"
28#include "HLT/BASE/AliHLTConfiguration.h"
29#include "AliLog.h"
30#include "TString.h"
31#include <iostream>
32using std::cerr;
33using std::endl;
34#endif
35
36/* @param chainType Specifies the type of chain to run. This can be one of the
37 * following:
38 * "full" - Run the full dHLT chain. (default)
39 * "ddlreco" - Run only the reconstruction of the DDL raw data up to hits
40 * and trigger records.
41 * "tracker" - Run the tracker only using hits and trigger records from
42 * AliRoot simulation or offline reconstruction.
43 * @param firstEvent The event number of the first event to process. (default = 0)
44 * @param lastEvent The event number of the last event to process. If this is
45 * less than firstEvent then it is set to firstEvent automatically. (default = -1)
1f50d9b1 46 * @param output Specifies the kind of output to generate. The options can be one
47 * of the following:
48 * "bin" - Generates all possible output and dumps it to binary files
49 * using the FileWriter component.
50 * "root" - Generates all possible output and writes it to a ROOT file
51 * using the ROOTFileWriter component.
52 * "tracks_bin" - Generates only track data and dumps it to binary files
53 * using the FileWriter component. This option is equivalent to
54 * 'bin' if the chain type is 'ddlreco'.
55 * "tracks_root" - Generates only track data and writes it to a ROOT file
56 * using the ROOTFileWriter component. This option is equivalent
57 * to 'bin' if the chain type is 'ddlreco'.
cc76079a 58 * @param dataSource This is the data source from which to use hits and trigger
59 * records when we are running the tracker only chain. Note this parameter
60 * only makes sense if chainType = "tracker". The possible options are:
61 * "sim" - Take data from GEANT hits. (default)
62 * "rec" - Take data from offline reconstructed hits and local trigger
63 * objects.
64 * @param logLevel Specifies the amount of logging messages produced by the HLT
65 * system. The possible options are:
66 * "normal" - Shows warnings, errors and information.
67 * "max" - Shows everything including debug messages if they were compiled in.
68 * "min" - Shows only error messages.
1f50d9b1 69 * @param lutDir This is the directory in which the LUTs can be found.
cc76079a 70 */
71void RunChain(
72 const char* chainType = "full",
73 Int_t firstEvent = 0,
74 Int_t lastEvent = -1,
1f50d9b1 75 const char* output = "bin",
cc76079a 76 const char* dataSource = "sim",
1f50d9b1 77 const char* logLevel = "normal",
78 const char* lutDir = "."
cc76079a 79 )
80{
81 // Make sure that the lastEvent is greater than firstEvent.
82 if (lastEvent < firstEvent)
83 lastEvent = firstEvent;
84 int eventCount = lastEvent - firstEvent + 1;
85
86 bool buildDDLFilePubs = false;
87 bool buildDDLRecoComps = false;
88 bool buildSimDataPubs = false;
89 bool buildRecDataPubs = false;
cc76079a 90 bool buildTrackerComp = false;
cc76079a 91 bool maxLogging = false;
92 bool minLogging = false;
1f50d9b1 93 bool useRootWriter = false;
94 bool makeTracksOnly = false;
95
96 // Parse the chainType, output, dataSource and logLevel option strings:
97 TString outOpt = output;
98 if (outOpt.CompareTo("bin", TString::kIgnoreCase) == 0)
99 {
100 useRootWriter = false;
101 }
102 else if (outOpt.CompareTo("root", TString::kIgnoreCase) == 0)
103 {
104 useRootWriter = true;
105 }
106 else if (outOpt.CompareTo("tracks_bin", TString::kIgnoreCase) == 0)
107 {
108 useRootWriter = false;
109 makeTracksOnly = true;
110 }
111 else if (outOpt.CompareTo("tracks_root", TString::kIgnoreCase) == 0)
112 {
113 useRootWriter = true;
114 makeTracksOnly = true;
115 }
116 else
117 {
118 cerr << "ERROR: Unknown option for output: " << output << endl;
119 return;
120 }
cc76079a 121
cc76079a 122 TString chainOpt = chainType;
123 if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
124 {
125 buildDDLFilePubs = true;
126 buildDDLRecoComps = true;
127 buildTrackerComp = true;
cc76079a 128 }
1f50d9b1 129 else if (chainOpt.CompareTo("ddlreco", TString::kIgnoreCase) == 0)
cc76079a 130 {
131 buildDDLFilePubs = true;
132 buildDDLRecoComps = true;
cc76079a 133 }
134 else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
135 {
cc76079a 136 buildTrackerComp = true;
1f50d9b1 137
cc76079a 138 TString dataOpt = dataSource;
139 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
140 {
141 buildSimDataPubs = true;
142 }
143 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
144 {
145 buildRecDataPubs = true;
146 }
147 else
148 {
149 cerr << "ERROR: Unknown option for dataSource: " << dataSource << endl;
150 return;
151 }
152 }
1f50d9b1 153 else
154 {
155 cerr << "ERROR: Unknown option for chainType: " << chainType << endl;
156 return;
157 }
cc76079a 158
159 TString logOpt = logLevel;
a563b588 160 if (logOpt.CompareTo("normal", TString::kIgnoreCase) == 0)
cc76079a 161 {
162 // nothing to do.
163 }
a563b588 164 else if (logOpt.CompareTo("max", TString::kIgnoreCase) == 0)
cc76079a 165 {
166 maxLogging = true;
167 }
a563b588 168 else if (logOpt.CompareTo("min", TString::kIgnoreCase) == 0)
cc76079a 169 {
170 minLogging = true;
171 }
172 else
173 {
174 cerr << "ERROR: Unknown option for logLevel: " << logLevel << endl;
175 return;
176 }
177
1f50d9b1 178 // If we are supposed to make tracks only but are in a ddlreco chain
179 // then we clearly can only generate the DDL reconstructed data, so do that.
180 if (makeTracksOnly && ! buildTrackerComp)
181 {
182 makeTracksOnly = false;
183 }
184
cc76079a 185 // Now we can initialise the AliHLTSystem...
186 AliHLTSystem sys;
cc76079a 187
188 // Start by setting up the logging.
189 if (maxLogging)
190 {
191 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
192 sys.SetGlobalLoggingLevel(kHLTLogAll);
193 }
194 if (minLogging)
195 {
196 sys.SetGlobalLoggingLevel(kHLTLogError);
197 }
a563b588 198
1927abc3 199 sys.LoadComponentLibraries("libAliHLTUtil.so");
a563b588 200 sys.LoadComponentLibraries("libAliHLTMUON.so");
cc76079a 201
202 // The DDL file publishers are only needed if we create the ddlreco or
203 // full chains. The filename lists are built assuming the aliroot rawXX/
204 // directory structure.
205 if (buildDDLFilePubs)
206 {
668eee9f 207 string cmd13 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
208 string cmd14 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
209 string cmd15 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
210 string cmd16 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
211 string cmd17 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
212 string cmd18 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
213 string cmd19 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
214 string cmd20 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
215 string cmd21 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
216 string cmd22 = "-datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
cc76079a 217 for (int i = firstEvent; i < lastEvent+1; i++)
218 {
219 if (i != 0)
220 {
221 cmd13 += " -nextevent";
222 cmd14 += " -nextevent";
223 cmd15 += " -nextevent";
224 cmd16 += " -nextevent";
225 cmd17 += " -nextevent";
226 cmd18 += " -nextevent";
227 cmd19 += " -nextevent";
228 cmd20 += " -nextevent";
229 cmd21 += " -nextevent";
230 cmd22 += " -nextevent";
231 }
232 char buf[16];
233 sprintf(buf, "%d", i);
234 cmd13 += " -datafile raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
235 cmd14 += " -datafile raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
236 cmd15 += " -datafile raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
237 cmd16 += " -datafile raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
238 cmd17 += " -datafile raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
239 cmd18 += " -datafile raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
240 cmd19 += " -datafile raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
241 cmd20 += " -datafile raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
242 cmd21 += " -datafile raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
243 cmd22 += " -datafile raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
244 }
245
246 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
247 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
248 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
249 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
250 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
251 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
252 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
253 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
254 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
255 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
256 }
257
258 // Build the DDL reconstructor components for all the DDLs 13 to 22, that
259 // is for chambers 7 to 10 and trigger stations. We only need to build
260 // these components if we are are building the ddlreco or full chains.
261 if (buildDDLRecoComps)
262 {
b8d467da 263 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", TString("-ddl 13 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut13.dat"));
264 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", TString("-ddl 14 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut14.dat"));
265 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", TString("-ddl 15 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut15.dat"));
266 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", TString("-ddl 16 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut16.dat"));
267 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", TString("-ddl 17 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut17.dat"));
268 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", TString("-ddl 18 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut18.dat"));
269 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", TString("-ddl 19 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut19.dat"));
270 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", TString("-ddl 20 -buspatchmap ") + lutDir + TString("/BusToDetElem.dat -lut ") + lutDir + TString("/Lut20.dat"));
1927abc3 271 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", TString("-ddl 21 -lut ") + lutDir + TString("/Lut21.dat -suppress_partial_triggers"));
272 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", TString("-ddl 22 -lut ") + lutDir + TString("/Lut22.dat -suppress_partial_triggers"));
1f50d9b1 273 }
274
275 TString startEventStr = "-firstevent ";
276 startEventStr += firstEvent;
cc76079a 277
1f50d9b1 278 // Build the data source components to take data from simulated hits if
279 // we are building the tracker only chain with the 'sim' data source.
cc76079a 280 if (buildSimDataPubs)
281 {
1f50d9b1 282 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 7");
283 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 7");
284 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 8");
285 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 8");
286 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 9");
287 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 9");
288 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 10");
289 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 10");
290 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane left");
291 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane right");
cc76079a 292 }
293
294 // Build the data source components to take data from offline reconstructed
295 // objects if we are building the tracker only chain with the 'rec' data source.
296 if (buildRecDataPubs)
297 {
1f50d9b1 298 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 7");
299 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 7");
300 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 8");
301 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 8");
302 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 9");
303 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 9");
304 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 10");
305 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 10");
306 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane left");
307 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane right");
cc76079a 308 }
309
310 // Build the tracker component if we are building the tracker only or
311 // full chains.
312 if (buildTrackerComp)
313 {
314 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
315 }
316
1f50d9b1 317 // Build the data sink to subscribe only to what has been created and
318 // to the data source we actaully want.
319 TString sources = "";
320 if (makeTracksOnly)
cc76079a 321 {
1f50d9b1 322 sources += "tracker ";
cc76079a 323 }
1f50d9b1 324 else
325 {
326 if (buildTrackerComp)
327 sources += "tracker ";
328 sources += "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
329 }
330 if (useRootWriter)
331 {
332 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
333 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-datafile output.root -specfmt");
334 }
335 else
cc76079a 336 {
1f50d9b1 337 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
cc76079a 338 }
339
1f50d9b1 340 // Build and run the chain's tasks.
341 sys.BuildTaskList("sink");
cc76079a 342 sys.Run(eventCount);
343}