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 **************************************************************************/
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.
22 * Also make sure the LUTs are in the same directory or specify the directory
23 * with the lutDir parameter option.
26 #if !defined(__CINT__) || defined(__MAKECINT__)
27 #include "HLT/BASE/AliHLTSystem.h"
28 #include "HLT/BASE/AliHLTConfiguration.h"
36 /* @param chainType Specifies the type of chain to run. This can be one of the
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)
46 * @param output Specifies the kind of output to generate. The options can be one
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'.
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
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.
69 * @param lutDir This is the directory in which the LUTs can be found.
72 const char* chainType = "full",
75 const char* output = "bin",
76 const char* dataSource = "sim",
77 const char* logLevel = "normal",
78 const char* lutDir = "."
81 // Make sure that the lastEvent is greater than firstEvent.
82 if (lastEvent < firstEvent)
83 lastEvent = firstEvent;
84 int eventCount = lastEvent - firstEvent + 1;
86 bool buildDDLFilePubs = false;
87 bool buildDDLRecoComps = false;
88 bool buildSimDataPubs = false;
89 bool buildRecDataPubs = false;
90 bool buildTrackerComp = false;
91 bool maxLogging = false;
92 bool minLogging = false;
93 bool useRootWriter = false;
94 bool makeTracksOnly = false;
96 // Parse the chainType, output, dataSource and logLevel option strings:
97 TString outOpt = output;
98 if (outOpt.CompareTo("bin", TString::kIgnoreCase) == 0)
100 useRootWriter = false;
102 else if (outOpt.CompareTo("root", TString::kIgnoreCase) == 0)
104 useRootWriter = true;
106 else if (outOpt.CompareTo("tracks_bin", TString::kIgnoreCase) == 0)
108 useRootWriter = false;
109 makeTracksOnly = true;
111 else if (outOpt.CompareTo("tracks_root", TString::kIgnoreCase) == 0)
113 useRootWriter = true;
114 makeTracksOnly = true;
118 cerr << "ERROR: Unknown option for output: " << output << endl;
122 TString chainOpt = chainType;
123 if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
125 buildDDLFilePubs = true;
126 buildDDLRecoComps = true;
127 buildTrackerComp = true;
129 else if (chainOpt.CompareTo("ddlreco", TString::kIgnoreCase) == 0)
131 buildDDLFilePubs = true;
132 buildDDLRecoComps = true;
134 else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
136 buildTrackerComp = true;
138 TString dataOpt = dataSource;
139 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
141 buildSimDataPubs = true;
143 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
145 buildRecDataPubs = true;
149 cerr << "ERROR: Unknown option for dataSource: " << dataSource << endl;
155 cerr << "ERROR: Unknown option for chainType: " << chainType << endl;
159 TString logOpt = logLevel;
160 if (logOpt.CompareTo("normal", TString::kIgnoreCase) == 0)
164 else if (logOpt.CompareTo("max", TString::kIgnoreCase) == 0)
168 else if (logOpt.CompareTo("min", TString::kIgnoreCase) == 0)
174 cerr << "ERROR: Unknown option for logLevel: " << logLevel << endl;
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)
182 makeTracksOnly = false;
185 // Now we can initialise the AliHLTSystem...
188 // Start by setting up the logging.
191 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
192 sys.SetGlobalLoggingLevel(kHLTLogAll);
196 sys.SetGlobalLoggingLevel(kHLTLogError);
199 sys.LoadComponentLibraries("libAliHLTUtil.so");
200 sys.LoadComponentLibraries("libAliHLTMUON.so");
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)
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";
217 for (int i = firstEvent; i < lastEvent+1; i++)
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";
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";
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());
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)
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"));
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"));
275 TString startEventStr = "-firstevent ";
276 startEventStr += firstEvent;
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.
280 if (buildSimDataPubs)
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");
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)
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");
310 // Build the tracker component if we are building the tracker only or
312 if (buildTrackerComp)
314 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
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 = "";
322 sources += "tracker ";
326 if (buildTrackerComp)
327 sources += "tracker ";
328 sources += "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
332 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
333 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-datafile output.root -specfmt");
337 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
340 // Build and run the chain's tasks.
341 sys.BuildTaskList("sink");