]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/macros/RunChain.C
Adding a macro to run the dHLT chain. This can be used as an example until AliHLTReco...
[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.
22 */
23
24#if !defined(__CINT__) || defined(__MAKECINT__)
25#include "HLT/BASE/AliHLTSystem.h"
26#include "HLT/BASE/AliHLTConfiguration.h"
27#include "AliLog.h"
28#include "TString.h"
29#include <iostream>
30using std::cerr;
31using std::endl;
32#endif
33
34/* @param chainType Specifies the type of chain to run. This can be one of the
35 * following:
36 * "full" - Run the full dHLT chain. (default)
37 * "ddlreco" - Run only the reconstruction of the DDL raw data up to hits
38 * and trigger records.
39 * "tracker" - Run the tracker only using hits and trigger records from
40 * AliRoot simulation or offline reconstruction.
41 * @param firstEvent The event number of the first event to process. (default = 0)
42 * @param lastEvent The event number of the last event to process. If this is
43 * less than firstEvent then it is set to firstEvent automatically. (default = -1)
44 * @param dataSource This is the data source from which to use hits and trigger
45 * records when we are running the tracker only chain. Note this parameter
46 * only makes sense if chainType = "tracker". The possible options are:
47 * "sim" - Take data from GEANT hits. (default)
48 * "rec" - Take data from offline reconstructed hits and local trigger
49 * objects.
50 * @param logLevel Specifies the amount of logging messages produced by the HLT
51 * system. The possible options are:
52 * "normal" - Shows warnings, errors and information.
53 * "max" - Shows everything including debug messages if they were compiled in.
54 * "min" - Shows only error messages.
55 */
56void RunChain(
57 const char* chainType = "full",
58 Int_t firstEvent = 0,
59 Int_t lastEvent = -1,
60 const char* dataSource = "sim",
61 const char* logLevel = "normal"
62 )
63{
64 // Make sure that the lastEvent is greater than firstEvent.
65 if (lastEvent < firstEvent)
66 lastEvent = firstEvent;
67 int eventCount = lastEvent - firstEvent + 1;
68
69 bool buildDDLFilePubs = false;
70 bool buildDDLRecoComps = false;
71 bool buildSimDataPubs = false;
72 bool buildRecDataPubs = false;
73 bool trackerOnly = false;
74 bool buildTrackerComp = false;
75 bool buildDDLRecoSink = false;
76 bool buildTrackerSink = false;
77 bool maxLogging = false;
78 bool minLogging = false;
79
80 // Parse the chainType, dataSource and logLevel option strings:
81 TString chainOpt = chainType;
82 if (chainOpt.CompareTo("full", TString::kIgnoreCase) == 0)
83 {
84 buildDDLFilePubs = true;
85 buildDDLRecoComps = true;
86 buildTrackerComp = true;
87 buildTrackerSink = true;
88 }
89 else if (chainOpt.CompareTo("DDLreco", TString::kIgnoreCase) == 0)
90 {
91 buildDDLFilePubs = true;
92 buildDDLRecoComps = true;
93 buildDDLRecoSink = true;
94 }
95 else if (chainOpt.CompareTo("tracker", TString::kIgnoreCase) == 0)
96 {
97 trackerOnly = true;
98 buildTrackerComp = true;
99 buildTrackerSink = true;
100 }
101 else
102 {
103 cerr << "ERROR: Unknown option for chainType: " << chainType << endl;
104 return;
105 }
106
107 if (trackerOnly)
108 {
109 TString dataOpt = dataSource;
110 if (dataOpt.CompareTo("sim", TString::kIgnoreCase) == 0)
111 {
112 buildSimDataPubs = true;
113 }
114 else if (dataOpt.CompareTo("rec", TString::kIgnoreCase) == 0)
115 {
116 buildRecDataPubs = true;
117 }
118 else
119 {
120 cerr << "ERROR: Unknown option for dataSource: " << dataSource << endl;
121 return;
122 }
123 }
124
125 TString logOpt = logLevel;
126 if (logOpt.CompareTo("normal", TString::kIgnoreCase) != 0)
127 {
128 // nothing to do.
129 }
130 else if (logOpt.CompareTo("max", TString::kIgnoreCase) != 0)
131 {
132 maxLogging = true;
133 }
134 else if (logOpt.CompareTo("min", TString::kIgnoreCase) != 0)
135 {
136 minLogging = true;
137 }
138 else
139 {
140 cerr << "ERROR: Unknown option for logLevel: " << logLevel << endl;
141 return;
142 }
143
144 // Now we can initialise the AliHLTSystem...
145 AliHLTSystem sys;
146 sys.LoadComponentLibraries("libAliHLTMUON.so");
147
148 // Start by setting up the logging.
149 if (maxLogging)
150 {
151 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
152 sys.SetGlobalLoggingLevel(kHLTLogAll);
153 }
154 if (minLogging)
155 {
156 sys.SetGlobalLoggingLevel(kHLTLogError);
157 }
158
159 // The DDL file publishers are only needed if we create the ddlreco or
160 // full chains. The filename lists are built assuming the aliroot rawXX/
161 // directory structure.
162 if (buildDDLFilePubs)
163 {
164 string cmd13 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x001000";
165 string cmd14 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x002000";
166 string cmd15 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x004000";
167 string cmd16 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x008000";
168 string cmd17 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x010000";
169 string cmd18 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x020000";
170 string cmd19 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x040000";
171 string cmd20 = "-datatype 'DDLTRACK' 'MUON' -dataspec 0x080000";
172 string cmd21 = "-datatype 'DDLTRIGR' 'MUON' -dataspec 0x100000";
173 string cmd22 = "-datatype 'DDLTRIGR' 'MUON' -dataspec 0x200000";
174 for (int i = firstEvent; i < lastEvent+1; i++)
175 {
176 if (i != 0)
177 {
178 cmd13 += " -nextevent";
179 cmd14 += " -nextevent";
180 cmd15 += " -nextevent";
181 cmd16 += " -nextevent";
182 cmd17 += " -nextevent";
183 cmd18 += " -nextevent";
184 cmd19 += " -nextevent";
185 cmd20 += " -nextevent";
186 cmd21 += " -nextevent";
187 cmd22 += " -nextevent";
188 }
189 char buf[16];
190 sprintf(buf, "%d", i);
191 cmd13 += " -datafile raw"; cmd13 += buf; cmd13 += "/MUONTRK_2572.ddl";
192 cmd14 += " -datafile raw"; cmd14 += buf; cmd14 += "/MUONTRK_2573.ddl";
193 cmd15 += " -datafile raw"; cmd15 += buf; cmd15 += "/MUONTRK_2574.ddl";
194 cmd16 += " -datafile raw"; cmd16 += buf; cmd16 += "/MUONTRK_2575.ddl";
195 cmd17 += " -datafile raw"; cmd17 += buf; cmd17 += "/MUONTRK_2576.ddl";
196 cmd18 += " -datafile raw"; cmd18 += buf; cmd18 += "/MUONTRK_2577.ddl";
197 cmd19 += " -datafile raw"; cmd19 += buf; cmd19 += "/MUONTRK_2578.ddl";
198 cmd20 += " -datafile raw"; cmd20 += buf; cmd20 += "/MUONTRK_2579.ddl";
199 cmd21 += " -datafile raw"; cmd21 += buf; cmd21 += "/MUONTRG_2816.ddl";
200 cmd22 += " -datafile raw"; cmd22 += buf; cmd22 += "/MUONTRG_2817.ddl";
201 }
202
203 AliHLTConfiguration pubDDL13("pubDDL13", "FilePublisher", NULL, cmd13.c_str());
204 AliHLTConfiguration pubDDL14("pubDDL14", "FilePublisher", NULL, cmd14.c_str());
205 AliHLTConfiguration pubDDL15("pubDDL15", "FilePublisher", NULL, cmd15.c_str());
206 AliHLTConfiguration pubDDL16("pubDDL16", "FilePublisher", NULL, cmd16.c_str());
207 AliHLTConfiguration pubDDL17("pubDDL17", "FilePublisher", NULL, cmd17.c_str());
208 AliHLTConfiguration pubDDL18("pubDDL18", "FilePublisher", NULL, cmd18.c_str());
209 AliHLTConfiguration pubDDL19("pubDDL19", "FilePublisher", NULL, cmd19.c_str());
210 AliHLTConfiguration pubDDL20("pubDDL20", "FilePublisher", NULL, cmd20.c_str());
211 AliHLTConfiguration pubDDL21("pubDDL21", "FilePublisher", NULL, cmd21.c_str());
212 AliHLTConfiguration pubDDL22("pubDDL22", "FilePublisher", NULL, cmd22.c_str());
213 }
214
215 // Build the DDL reconstructor components for all the DDLs 13 to 22, that
216 // is for chambers 7 to 10 and trigger stations. We only need to build
217 // these components if we are are building the ddlreco or full chains.
218 if (buildDDLRecoComps)
219 {
220 AliHLTConfiguration recDDL13("recDDL13", "MUONHitReconstructor", "pubDDL13", "ddl 12 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut12.dat");
221 AliHLTConfiguration recDDL14("recDDL14", "MUONHitReconstructor", "pubDDL14", "ddl 13 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut13.dat");
222 AliHLTConfiguration recDDL15("recDDL15", "MUONHitReconstructor", "pubDDL15", "ddl 14 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut14.dat");
223 AliHLTConfiguration recDDL16("recDDL16", "MUONHitReconstructor", "pubDDL16", "ddl 15 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut15.dat");
224 AliHLTConfiguration recDDL17("recDDL17", "MUONHitReconstructor", "pubDDL17", "ddl 16 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut16.dat");
225 AliHLTConfiguration recDDL18("recDDL18", "MUONHitReconstructor", "pubDDL18", "ddl 17 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut17.dat");
226 AliHLTConfiguration recDDL19("recDDL19", "MUONHitReconstructor", "pubDDL19", "ddl 18 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut18.dat");
227 AliHLTConfiguration recDDL20("recDDL20", "MUONHitReconstructor", "pubDDL20", "ddl 19 buspatchmap /afsuser/indranildas/Lut/BusToDetElem.dat lut /afsuser/indranildas/Lut/Lut19.dat");
228 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerReconstructor", "pubDDL21", "ddl 0 lut /afsuser/indranildas/Lut/Lut20.dat reglocmap /afsuser/indranildas/Lut/RegionalToLocalCard.dat");
229 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerReconstructor", "pubDDL22", "ddl 1 lut /afsuser/indranildas/Lut/Lut21.dat reglocmap /afsuser/indranildas/Lut/RegionalToLocalCard.dat");
230 }
231
232 // Build the data source components to take data from simulated hits if
233 // we are building the tracker only chain with the 'sim' data source.
234 if (buildSimDataPubs)
235 {
236 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, "-simdata -plane left -chamber 7");
237 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, "-simdata -plane right -chamber 7");
238 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, "-simdata -plane left -chamber 8");
239 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, "-simdata -plane right -chamber 8");
240 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, "-simdata -plane left -chamber 9");
241 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, "-simdata -plane right -chamber 9");
242 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, "-simdata -plane left -chamber 10");
243 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, "-simdata -plane right -chamber 10");
244 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, "-hitdata -plane left");
245 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, "-hitdata -plane right");
246 }
247
248 // Build the data source components to take data from offline reconstructed
249 // objects if we are building the tracker only chain with the 'rec' data source.
250 if (buildRecDataPubs)
251 {
252 AliHLTConfiguration recDDL13("recDDL13", "MUONRecHitsSource", NULL, "-recdata -plane left -chamber 7");
253 AliHLTConfiguration recDDL14("recDDL14", "MUONRecHitsSource", NULL, "-recdata -plane right -chamber 7");
254 AliHLTConfiguration recDDL15("recDDL15", "MUONRecHitsSource", NULL, "-recdata -plane left -chamber 8");
255 AliHLTConfiguration recDDL16("recDDL16", "MUONRecHitsSource", NULL, "-recdata -plane right -chamber 8");
256 AliHLTConfiguration recDDL17("recDDL17", "MUONRecHitsSource", NULL, "-recdata -plane left -chamber 9");
257 AliHLTConfiguration recDDL18("recDDL18", "MUONRecHitsSource", NULL, "-recdata -plane right -chamber 9");
258 AliHLTConfiguration recDDL19("recDDL19", "MUONRecHitsSource", NULL, "-recdata -plane left -chamber 10");
259 AliHLTConfiguration recDDL20("recDDL20", "MUONRecHitsSource", NULL, "-recdata -plane right -chamber 10");
260 AliHLTConfiguration recDDL21("recDDL21", "MUONTriggerRecordsSource", NULL, "-recdata -plane left");
261 AliHLTConfiguration recDDL22("recDDL22", "MUONTriggerRecordsSource", NULL, "-recdata -plane right");
262 }
263
264 // Build the tracker component if we are building the tracker only or
265 // full chains.
266 if (buildTrackerComp)
267 {
268 AliHLTConfiguration tracker("tracker", "MUONMansoTrackerFSM", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "");
269 }
270
271 // Build the data sink to subscribe to the DDL reconstructor objects if
272 // we are building the 'ddlreco' chain.
273 if (buildTrackerSink)
274 {
275 AliHLTConfiguration sink("sink", "FileWriter", "tracker", "-datafile output.dat -specfmt=_0x%08x");
276 sys.BuildTaskList("sink");
277 }
278
279 // Build the data sink to subscribe only to the tracker if we are building
280 // the 'tracker' or 'full' chains.
281 if (buildDDLRecoSink)
282 {
283 AliHLTConfiguration sinkDDL("sinkDDL", "FileWriter", "recDDL13 recDDL14 recDDL15 recDDL16 recDDL17 recDDL18 recDDL19 recDDL20 recDDL21 recDDL22", "-datafile output.dat -specfmt=_0x%08x");
284 sys.BuildTaskList("sinkDDL");
285 }
286
287 sys.Run(eventCount);
288}