]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/macros/RunChain.C
Adding options to control the data output better. Specifically to write to ROOT files...
[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
199 sys.LoadComponentLibraries("libAliHLTMUON.so");
cc76079a 200
201 // The DDL file publishers are only needed if we create the ddlreco or
202 // full chains. The filename lists are built assuming the aliroot rawXX/
203 // directory structure.
204 if (buildDDLFilePubs)
205 {
206 string cmd13 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x001000";
207 string cmd14 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x002000";
208 string cmd15 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x004000";
209 string cmd16 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x008000";
210 string cmd17 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x010000";
211 string cmd18 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x020000";
212 string cmd19 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x040000";
213 string cmd20 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x080000";
214 string cmd21 = "-datatype 'DDLTRIGR' 'MUON' -dataspec 0x100000";
215 string cmd22 = "-datatype 'DDLTRIGR' 'MUON' -dataspec 0x200000";
216 for (int i = firstEvent; i < lastEvent+1; i++)
217 {
218 if (i != 0)
219 {
220 cmd13 += " -nextevent";
221 cmd14 += " -nextevent";
222 cmd15 += " -nextevent";
223 cmd16 += " -nextevent";
224 cmd17 += " -nextevent";
225 cmd18 += " -nextevent";
226 cmd19 += " -nextevent";
227 cmd20 += " -nextevent";
228 cmd21 += " -nextevent";
229 cmd22 += " -nextevent";
230 }
231 char buf[16];
232 sprintf(buf, "%d", i);
233 cmd13 += " -datafile raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
234 cmd14 += " -datafile raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
235 cmd15 += " -datafile raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
236 cmd16 += " -datafile raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
237 cmd17 += " -datafile raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
238 cmd18 += " -datafile raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
239 cmd19 += " -datafile raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
240 cmd20 += " -datafile raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
241 cmd21 += " -datafile raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
242 cmd22 += " -datafile raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
243 }
244
245 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
246 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
247 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
248 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
249 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
250 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
251 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
252 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
253 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
254 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
255 }
256
257 // Build the DDL reconstructor components for all the DDLs 13 to 22, that
258 // is for chambers 7 to 10 and trigger stations. We only need to build
259 // these components if we are are building the ddlreco or full chains.
260 if (buildDDLRecoComps)
261 {
1f50d9b1 262 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", TString("ddl 12 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut12.dat"));
263 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", TString("ddl 13 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut13.dat"));
264 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", TString("ddl 14 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut14.dat"));
265 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", TString("ddl 15 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut15.dat"));
266 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", TString("ddl 16 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut16.dat"));
267 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", TString("ddl 17 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut17.dat"));
268 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", TString("ddl 18 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut18.dat"));
269 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", TString("ddl 19 buspatchmap ") + lutDir + TString("/BusToDetElem.dat lut ") + lutDir + TString("/Lut19.dat"));
270 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", TString("ddl 0 lut ") + lutDir + TString("/Lut20.dat reglocmap ") + lutDir + TString("/RegionalToLocalCard.dat"));
271 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", TString("ddl 1 lut ") + lutDir + TString("/Lut21.dat reglocmap ") + lutDir + TString("/RegionalToLocalCard.dat"));
272 }
273
274 TString startEventStr = "-firstevent ";
275 startEventStr += firstEvent;
cc76079a 276
1f50d9b1 277 // Build the data source components to take data from simulated hits if
278 // we are building the tracker only chain with the 'sim' data source.
cc76079a 279 if (buildSimDataPubs)
280 {
1f50d9b1 281 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 7");
282 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 7");
283 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 8");
284 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 8");
285 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 9");
286 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 9");
287 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane left -chamber 10");
288 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -simdata -plane right -chamber 10");
289 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane left");
290 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -hitdata -plane right");
cc76079a 291 }
292
293 // Build the data source components to take data from offline reconstructed
294 // objects if we are building the tracker only chain with the 'rec' data source.
295 if (buildRecDataPubs)
296 {
1f50d9b1 297 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 7");
298 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 7");
299 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 8");
300 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 8");
301 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 9");
302 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 9");
303 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane left -chamber 10");
304 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, startEventStr + " -recdata -plane right -chamber 10");
305 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane left");
306 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, startEventStr + " -recdata -plane right");
cc76079a 307 }
308
309 // Build the tracker component if we are building the tracker only or
310 // full chains.
311 if (buildTrackerComp)
312 {
313 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
314 }
315
1f50d9b1 316 // Build the data sink to subscribe only to what has been created and
317 // to the data source we actaully want.
318 TString sources = "";
319 if (makeTracksOnly)
cc76079a 320 {
1f50d9b1 321 sources += "tracker ";
cc76079a 322 }
1f50d9b1 323 else
324 {
325 if (buildTrackerComp)
326 sources += "tracker ";
327 sources += "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22";
328 }
329 if (useRootWriter)
330 {
331 AliHLTConfiguration convert("convert", "MUONRootifier", sources, "");
332 AliHLTConfiguration sink("sink", "ROOTFileWriter", "convert", "-datafile output.root -specfmt");
333 }
334 else
cc76079a 335 {
1f50d9b1 336 AliHLTConfiguration sink("sink", "FileWriter", sources, "-datafile output.dat -specfmt");
cc76079a 337 }
338
1f50d9b1 339 // Build and run the chain's tasks.
340 sys.BuildTaskList("sink");
cc76079a 341 sys.Run(eventCount);
342}