1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
6 * for The ALICE HLT Project. *
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 **************************************************************************/
18 * @file testGlobalTriggerComponent.C
19 * @author Artur Szostak <artursz@iafrica.com>
22 * This macro is used to test the AliHLTGlobalTriggerComponent class.
23 * A number of tests are run with the AliHLTSystem framework to check that
24 * the automatically generated global trigger logic is generated correctly.
26 * This macro can also be used to debug the configuration that fails.
27 * If a configuration test fails then the global trigger logic implementation
28 * is left in a generated file with a name of the form \<AliHLTGlobalTriggerImpl_*.cxx\>.
29 * For example a file named like: AliHLTGlobalTriggerImpl_08869e64_c54b_11de_9717_0101007fbeef.cxx
30 * One can make manual modifications to this file and then rerun the test with
31 * these manual modifications with the following command in aliroot:
32 * .x testGlobalTriggerComponent.C+(\<configVersion\>,"\<AliHLTGlobalTriggerImpl_*\>")
33 * where \<configVersion\> is the appropriate config version number as passed to the
34 * TriggerConfig.C file to initialise the configuration we want to test. Also take note
35 * that we only specify the root of the file name without the .cxx file name extention.
36 * For our example file name the command to execute in aliroot would be:
37 * .x testGlobalTriggerComponent.C+(2,"AliHLTGlobalTriggerImpl_08869e64_c54b_11de_9717_0101007fbeef")
38 * where we are testing the 2nd trigger configuration in TriggerConfig.C.
41 #if defined(__CINT__) && (! defined(__MAKECINT__))
42 #error This macro must be compiled. Try running as testGlobalTriggerComponent.C++, but remember to load the libAliHLTTrigger.so library first.
45 #if !defined(__CINT__) || defined(__MAKECINT__)
47 #include "TClassTable.h"
50 #include "AliHLTReadoutList.h"
51 #include "AliHLTTriggerDomain.h"
52 #include "AliHLTTriggerDecision.h"
53 #include "AliHLTGlobalTriggerDecision.h"
54 #include "AliHLTEventSummary.h"
55 #include "AliHLTSystem.h"
56 #include "AliHLTConfiguration.h"
57 #include "Riostream.h"
61 * Generates some sample input data and writes it into 8 files named
62 * testInputFile1.root ... testInputFile8.root
64 void GenerateInputData()
66 bool loadedLibs = false;
67 if (gClassTable->GetID("AliHLTGlobalTriggerComponent") < 0)
69 gSystem->Load("libAliHLTUtil.so");
70 gSystem->Load("libAliHLTTRD.so");
71 gSystem->Load("libAliHLTMUON.so");
72 gSystem->Load("libAliHLTTrigger.so");
76 AliHLTReadoutList readoutList1("TPC");
77 AliHLTTriggerDomain triggerDomain1;
78 triggerDomain1.Add("CLUSTERS", "TPC ");
79 triggerDomain1.Add("TRACKS", "TPC ");
80 triggerDomain1.Add(readoutList1);
81 AliHLTTriggerDecision decision1(true, "triggerTPC", triggerDomain1, "TPC has data");
83 AliHLTReadoutList readoutList2a("MUONTRK");
84 AliHLTReadoutList readoutList2b("MUONTRG");
85 AliHLTTriggerDomain triggerDomain2;
86 triggerDomain2.Add("TRACKS", "MUON");
87 triggerDomain2.Add(readoutList2a);
88 triggerDomain2.Add(readoutList2b);
89 AliHLTTriggerDecision decision2(true, "triggerMUON", triggerDomain2, "MUON has data");
91 AliHLTReadoutList readoutList3("ITSSSD");
92 AliHLTTriggerDomain triggerDomain3;
93 triggerDomain3.Add("*******", "SSD ");
94 triggerDomain3.Add(readoutList3);
95 AliHLTTriggerDecision decision3(true, "triggerSSD", triggerDomain3, "SSD has data");
97 AliHLTEventSummary summary1;
98 summary1.SetTriggerClass(0x1);
100 AliHLTEventSummary summary2;
101 summary2.SetTriggerClass(0x2);
103 TFile* file = new TFile("testInputFile1.root", "RECREATE");
104 decision1.Write("triggerTPC");
105 decision2.Write("triggerMUON");
106 decision3.Write("triggerSSD");
107 summary2.Write("summary");
110 file = new TFile("testInputFile2.root", "RECREATE");
111 decision1.Write("triggerTPC");
112 summary2.Write("summary");
115 file = new TFile("testInputFile3.root", "RECREATE");
116 decision2.Write("triggerMUON");
117 summary1.Write("summary");
120 file = new TFile("testInputFile4.root", "RECREATE");
121 decision3.Write("triggerSSD");
122 summary2.Write("summary");
125 file = new TFile("testInputFile5.root", "RECREATE");
126 decision1.Write("triggerTPC");
127 decision2.Write("triggerMUON");
128 summary1.Write("summary");
131 file = new TFile("testInputFile6.root", "RECREATE");
132 decision1.Write("triggerTPC");
133 decision3.Write("triggerSSD");
134 summary2.Write("summary");
137 file = new TFile("testInputFile7.root", "RECREATE");
138 decision2.Write("triggerMUON");
139 decision3.Write("triggerSSD");
140 summary1.Write("summary");
143 file = new TFile("testInputFile8.root", "RECREATE");
148 gSystem->Unload("libAliHLTTrigger.so");
149 gSystem->Unload("libAliHLTMUON.so");
150 gSystem->Unload("libAliHLTTRD.so");
151 gSystem->Unload("libAliHLTUtil.so");
156 * Runs a small global trigger test chain with the different configuration as specified
157 * in TriggerConfig.C.
158 * \param config The configuration version to pass to TriggerConfig.C
159 * \param usecint If true then the global trigger component uses CINT to interpret
160 * the code rather than compiling it.
161 * \param debug If true then the global trigger component generates extra debug
162 * statements in the on the fly AliHLTGlobalTriggerImp_*.cxx file.
163 * \param numOfEvents The number of events to run the chain for.
164 * \param customClass Names the custom class that should be loaded from the file
165 * <i>\<customClass\>.cxx</i>. This is useful for debugging only. i.e. you can
166 * edit a generated logic file and test it by hand.
168 void RunTrigger(int config = 0, bool usecint = false, bool debug = false, int numOfEvents = 8, const char* customClass = NULL)
171 sys.ScanOptions("ECS=CTP_TRIGGER_CLASS=00:TRIGGER-ALL:00-01-02-03-04-05-06-07-08-09-10-11-12-13-14-15-16-17");
172 sys.LoadComponentLibraries("libAliHLTUtil.so");
173 sys.LoadComponentLibraries("libAliHLTTRD.so");
174 sys.LoadComponentLibraries("libAliHLTMUON.so");
175 sys.LoadComponentLibraries("libAliHLTTrigger.so");
178 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
179 sys.SetGlobalLoggingLevel(kHLTLogAll);
182 TString cmdline = "-datatype ROOTTOBJ 'HLT ' ";
183 for (int i = 1; i <= 8; i++)
185 if (i > 1) cmdline += " -nextevent";
186 cmdline += Form(" -datafile testInputFile%d.root", i);
188 AliHLTConfiguration pub("pub", "ROOTFilePublisher", NULL, cmdline.Data());
190 cmdline = Form("-config $ALICE_ROOT/HLT/trigger/test/TriggerConfig.C(%d)"
191 " -includepath $ALICE_ROOT/include -includepath $ALICE_ROOT/HLT/BASE"
192 " -includepath $ALICE_ROOT/HLT/trigger -include AliHLTEventSummary.h",
195 if (customClass != NULL) cmdline += Form(" -usecode %s.cxx %s", customClass, customClass);
196 if (usecint) cmdline += " -cint";
197 if (debug) cmdline += " -debug";
198 AliHLTConfiguration proc("proc", "HLTGlobalTrigger", "pub", cmdline.Data());
200 AliHLTConfiguration sink("sink", "ROOTFileWriter", "proc", "-datafile testOutputFile.root -concatenate-events");
202 sys.BuildTaskList("sink");
205 1, // Stop chain at end of run.
206 0x1, // Active CTP trigger mask.
213 * This method calls the RunTrigger method in an independant aliroot process.
214 * This is necessary since we get memory corruption if we run too many instances of
215 * AliHLTSystem in the same process.
218 int config = 0, bool usecint = false, bool debug = false,
219 int numOfEvents = 8, const char* customClass = NULL,
220 bool showOutput = false
223 const char* redirection = "> /dev/null";
224 const char* classNameString = "NULL";
225 if (showOutput) redirection = "";
226 if (customClass != NULL) classNameString = Form("\"%s\"", customClass);
227 const char* command = Form(
229 "gSystem->Load(\"libAliHLTUtil.so\");\n"
230 "gSystem->Load(\"libAliHLTTRD.so\");\n"
231 "gSystem->Load(\"libAliHLTMUON.so\");\n"
232 "gSystem->Load(\"libAliHLTTrigger.so\");\n"
233 "gSystem->SetIncludePath(\"-I${ALICE_ROOT}/include"
234 " -I${ALICE_ROOT}/HLT/BASE -I${ALICE_ROOT}/HLT/trigger\");\n"
235 ".L $ALICE_ROOT/HLT/trigger/test/testGlobalTriggerComponent.C+\n"
236 "RunTrigger(%d,%d,%d,%d,%s);\n"
245 gSystem->Exec(command);
249 * Checks that a particular decision is as expected and prints error messages
251 * \param testName The name of the test being run.
252 * \param eventNum The number of the event being checked.
253 * \param decision The global trigger decision being checked.
254 * \param expectedResult The expected global trigger result.
255 * \param expectedDomain The expected resulting global trigger domain.
256 * \param expectedDescription The expected resulting trigger description.
257 * \returns true if the decision is as expected.
260 const char* testName,
262 AliHLTGlobalTriggerDecision* decision,
264 AliHLTTriggerDomain expectedDomain,
265 TString expectedDescription
268 if (decision == NULL)
270 cerr << "ERROR (Test: " << testName
271 << "): No decision found where expected for event "
272 << eventNum << "." << endl;
275 if (decision->Result() != expectedResult)
277 cerr << "ERROR (Test: " << testName
278 << "): The result does not match the expected value for event "
279 << eventNum << ". Got " << decision->Result() << " but expected "
280 << expectedResult << "." << endl;
283 if (decision->TriggerDomain() != expectedDomain)
285 cerr << "ERROR (Test: " << testName
286 << "): The domain does not match the expected value for event "
287 << eventNum << ". Got:" << endl;
288 decision->TriggerDomain().Print();
289 cerr << "but expected:" << endl;
290 expectedDomain.Print();
293 if (decision->Description() != expectedDescription)
295 cerr << "ERROR (Test: " << testName
296 << "): The description does not match the expected value for event "
297 << eventNum << ". Got '" << decision->Description() << "' but expected '"
298 << expectedDescription << "'." << endl;
305 /// Routine for checking the result of the PriorityGroupTestConfig() config in TriggerConfig.C
306 bool CheckPriorityGroupTestConfig(const char* testName = "Priority group config")
308 AliHLTGlobalTriggerDecision* decision = NULL;
311 AliHLTTriggerDomain domainTPC("CLUSTERS:TPC ,TRACKS:TPC ");
312 domainTPC.Add(AliHLTReadoutList("TPC"));
313 AliHLTTriggerDomain domainMUON("TRACKS:MUON");
314 domainMUON.Add(AliHLTReadoutList("MUONTRK"));
315 domainMUON.Add(AliHLTReadoutList("MUONTRG"));
316 AliHLTTriggerDomain domainSSD("*******:SSD ");
317 domainSSD.Add(AliHLTReadoutList("ITSSSD"));
319 TFile* file = new TFile("testOutputFile.root", "READ");
321 // Triggers in events (i.e. input triggers):
322 // event 1: TPC MUON SSD
330 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;1"));
331 result = Check(testName, 1, decision, true, domainSSD, "Fast SSD trigger");
332 if (! result) goto cleanup;
333 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;2"));
334 result = Check(testName, 2, decision, true, domainTPC, "TPC trigger");
335 if (! result) goto cleanup;
336 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;3"));
337 result = Check(testName, 3, decision, true, domainMUON, "MUON trigger");
338 if (! result) goto cleanup;
339 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;4"));
340 result = Check(testName, 4, decision, true, domainSSD, "MUON trigger");
341 if (! result) goto cleanup;
342 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;5"));
343 result = Check(testName, 5, decision, true, domainMUON, "MUON trigger");
344 if (! result) goto cleanup;
345 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;6"));
346 result = Check(testName, 6, decision, true, domainSSD, "Fast SSD trigger");
347 if (! result) goto cleanup;
348 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;7"));
349 result = Check(testName, 7, decision, true, domainMUON | domainSSD, "MUON trigger");
350 if (! result) goto cleanup;
351 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;8"));
352 result = Check(testName, 8, decision, false, AliHLTTriggerDomain(), "No trigger");
353 if (! result) goto cleanup;
359 if (decision != NULL)
361 cout << "========== Dumping incorrect decision ========== " << endl;
369 /// Routine for checking the result of the SingleGroupTestConfig() config in TriggerConfig.C
370 bool CheckSingleGroupTestConfig(const char* testName = "Single group config")
372 AliHLTGlobalTriggerDecision* decision = NULL;
375 AliHLTTriggerDomain domainTPC("CLUSTERS:TPC ,TRACKS:TPC ");
376 domainTPC.Add(AliHLTReadoutList("TPC"));
377 AliHLTTriggerDomain domainMUON("TRACKS:MUON");
378 domainMUON.Add(AliHLTReadoutList("MUONTRK"));
379 domainMUON.Add(AliHLTReadoutList("MUONTRG"));
380 AliHLTTriggerDomain domainSSD("*******:SSD ");
381 domainSSD.Add(AliHLTReadoutList("ITSSSD"));
383 TFile* file = new TFile("testOutputFile.root", "READ");
385 // Triggers in events (i.e. input triggers):
386 // event 1: TPC MUON SSD
394 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;1"));
395 result = Check(testName, 1, decision, true, domainTPC | domainMUON | domainSSD, "TPC trigger,MUON trigger,SSD trigger");
396 if (! result) goto cleanup;
397 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;2"));
398 result = Check(testName, 2, decision, true, domainTPC, "TPC trigger");
399 if (! result) goto cleanup;
400 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;3"));
401 result = Check(testName, 3, decision, true, domainMUON, "MUON trigger");
402 if (! result) goto cleanup;
403 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;4"));
404 result = Check(testName, 4, decision, true, domainSSD, "SSD trigger");
405 if (! result) goto cleanup;
406 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;5"));
407 result = Check(testName, 5, decision, true, domainTPC | domainMUON, "TPC trigger,MUON trigger");
408 if (! result) goto cleanup;
409 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;6"));
410 result = Check(testName, 6, decision, true, domainTPC | domainSSD, "TPC trigger,SSD trigger");
411 if (! result) goto cleanup;
412 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;7"));
413 result = Check(testName, 7, decision, true, domainMUON | domainSSD, "MUON trigger,SSD trigger");
414 if (! result) goto cleanup;
415 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;8"));
416 result = Check(testName, 8, decision, false, AliHLTTriggerDomain(), "");
417 if (! result) goto cleanup;
423 if (decision != NULL)
425 cout << "========== Dumping incorrect decision ========== " << endl;
433 /// Routine for checking the result of the PrescalarTestConfig() config in TriggerConfig.C
434 bool CheckPrescalarTestConfig(const char* testName = "Prescalar config")
436 AliHLTGlobalTriggerDecision* decision = NULL;
439 AliHLTTriggerDomain domainTPC("CLUSTERS:TPC ,TRACKS:TPC ");
440 domainTPC.Add(AliHLTReadoutList("TPC"));
441 AliHLTTriggerDomain domainMUON("TRACKS:MUON");
442 domainMUON.Add(AliHLTReadoutList("MUONTRK"));
443 domainMUON.Add(AliHLTReadoutList("MUONTRG"));
444 AliHLTTriggerDomain domainSSD("*******:SSD ");
445 domainSSD.Add(AliHLTReadoutList("ITSSSD"));
446 AliHLTTriggerDomain defaultDomain("*******:HLT ");
448 TFile* file = new TFile("testOutputFile.root", "READ");
450 // Triggers in events (i.e. input triggers):
451 // event 1: TPC MUON SSD
459 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;1"));
460 result = Check(testName, 1, decision, true, domainTPC, "TPC trigger");
461 if (! result) goto cleanup;
462 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;2"));
463 result = Check(testName, 2, decision, false, defaultDomain, "No trigger");
464 if (! result) goto cleanup;
465 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;3"));
466 result = Check(testName, 3, decision, true, domainMUON, "MUON trigger");
467 if (! result) goto cleanup;
468 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;4"));
469 result = Check(testName, 4, decision, false, defaultDomain, "No trigger");
470 if (! result) goto cleanup;
471 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;5"));
472 result = Check(testName, 5, decision, true, domainMUON, "MUON trigger");
473 if (! result) goto cleanup;
474 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;6"));
475 result = Check(testName, 6, decision, true, domainTPC, "TPC trigger");
476 if (! result) goto cleanup;
477 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;7"));
478 result = Check(testName, 7, decision, true, domainMUON, "MUON trigger");
479 if (! result) goto cleanup;
480 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;8"));
481 result = Check(testName, 8, decision, false, defaultDomain, "No trigger");
482 if (! result) goto cleanup;
488 if (decision != NULL)
490 cout << "========== Dumping incorrect decision ========== " << endl;
498 /// Routine for checking the result of the SymbolTestConfig() config in TriggerConfig.C
499 bool CheckSymbolTestConfig(const char* testName = "Symbol config")
501 AliHLTGlobalTriggerDecision* decision = NULL;
504 AliHLTTriggerDomain domainAll("*******:***,-DAQRDOUT:TST");
505 AliHLTTriggerDomain domainPHOS("CLUSTERS:PHOS,TRACKS:PHOS");
506 AliHLTTriggerDomain domainTPC("CLUSTERS:TPC ,TRACKS:TPC ");
507 domainTPC.Add(AliHLTReadoutList("TPC"));
508 AliHLTTriggerDomain domainMUON("TRACKS:MUON");
509 domainMUON.Add(AliHLTReadoutList("MUONTRK"));
510 domainMUON.Add(AliHLTReadoutList("MUONTRG"));
511 AliHLTTriggerDomain domainSSD("*******:SSD ");
512 domainSSD.Add(AliHLTReadoutList("ITSSSD"));
514 TFile* file = new TFile("testOutputFile.root", "READ");
516 // Triggers in events (i.e. input triggers) and trigger classes in AliHLTEventSummary:
517 // event 1: TPC MUON SSD, 0x2
518 // event 2: TPC , 0x2
519 // event 3: MUON , 0x1
520 // event 4: SSD , 0x2
521 // event 5: TPC MUON , 0x1
522 // event 6: TPC SSD , 0x2
523 // event 7: MUON SSD , 0x1
524 // event 8: (empty) , 0x0
525 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;1"));
526 result = Check(testName, 1, decision, true, domainAll - AliHLTTriggerDomain("DAQRDOUT:EMC"), "Pass through");
527 if (! result) goto cleanup;
528 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;2"));
529 result = Check(testName, 2, decision, true, domainTPC | domainPHOS, "Trigger class 2");
530 if (! result) goto cleanup;
531 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;3"));
532 result = Check(testName, 3, decision, false, AliHLTTriggerDomain(), "");
533 if (! result) goto cleanup;
534 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;4"));
535 result = Check(testName, 4, decision, true, domainPHOS, "Trigger class 2");
536 if (! result) goto cleanup;
537 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;5"));
538 result = Check(testName, 5, decision, true, domainAll - AliHLTTriggerDomain("DAQRDOUT:EMC"), "Pass through");
539 if (! result) goto cleanup;
540 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;6"));
541 result = Check(testName, 6, decision, true, domainTPC | domainPHOS, "Trigger class 2");
542 if (! result) goto cleanup;
543 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;7"));
544 result = Check(testName, 7, decision, false, AliHLTTriggerDomain(), "");
545 if (! result) goto cleanup;
546 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;8"));
547 result = Check(testName, 8, decision, false, AliHLTTriggerDomain(), "");
548 if (! result) goto cleanup;
554 if (decision != NULL)
556 cout << "========== Dumping incorrect decision ========== " << endl;
564 /// Routine for checking the result of the ComplexTestConfig() config in TriggerConfig.C
565 bool CheckComplexTestConfig(const char* testName = "Complex config")
567 AliHLTGlobalTriggerDecision* decision = NULL;
570 AliHLTTriggerDomain domainAll("*******:***,-DAQRDOUT:TST,-DAQRDOUT:EMC");
571 AliHLTTriggerDomain domainPHOS("CLUSTERS:PHOS,TRACKS:PHOS");
572 AliHLTTriggerDomain domainTPC("CLUSTERS:TPC ,TRACKS:TPC ");
573 domainTPC.Add(AliHLTReadoutList("TPC"));
574 AliHLTTriggerDomain domainMUON("TRACKS:MUON");
575 domainMUON.Add(AliHLTReadoutList("MUONTRK"));
576 domainMUON.Add(AliHLTReadoutList("MUONTRG"));
577 AliHLTTriggerDomain domainSSD("*******:SSD ");
578 domainSSD.Add(AliHLTReadoutList("ITSSSD"));
580 TFile* file = new TFile("testOutputFile.root", "READ");
582 // Triggers in events (i.e. input triggers) and trigger classes in AliHLTEventSummary:
583 // event 1: TPC MUON SSD, 0x2
584 // event 2: TPC , 0x2
585 // event 3: MUON , 0x1
586 // event 4: SSD , 0x2
587 // event 5: TPC MUON , 0x1
588 // event 6: TPC SSD , 0x2
589 // event 7: MUON SSD , 0x1
590 // event 8: (empty) , 0x0
591 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;1"));
592 result = Check(testName, 1, decision, true, domainAll, "Pass through");
593 if (! result) goto cleanup;
594 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;2"));
595 result = Check(testName, 2, decision, true, domainTPC, "Slow trigger");
596 if (! result) goto cleanup;
597 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;3"));
598 result = Check(testName, 3, decision, true, domainMUON, "MUON trigger 2");
599 if (! result) goto cleanup;
600 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;4"));
601 result = Check(testName, 4, decision, true, domainSSD | domainPHOS, "SSD trigger 2");
602 if (! result) goto cleanup;
603 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;5"));
604 result = Check(testName, 5, decision, true, domainMUON, "MUON trigger 2");
605 if (! result) goto cleanup;
606 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;6"));
607 result = Check(testName, 6, decision, true, domainSSD | domainPHOS, "SSD trigger 2");
608 if (! result) goto cleanup;
609 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;7"));
610 result = Check(testName, 7, decision, true, domainSSD | domainMUON, "SSD trigger 1,MUON trigger 1");
611 if (! result) goto cleanup;
612 decision = dynamic_cast<AliHLTGlobalTriggerDecision*>(file->Get("HLTGlobalTrigger;8"));
613 result = Check(testName, 8, decision, true, domainAll, "Pass through");
614 if (! result) goto cleanup;
620 if (decision != NULL)
622 cout << "========== Dumping incorrect decision ========== " << endl;
630 typedef bool (*CheckFunctionType)(const char* testName);
633 * This will check the results of a global trigger run with a particular checking
634 * routine and for different combinations of -cint and -debug flags passed to the
635 * global trigger component.
636 * It is important to check these flag combinations to make sure that everything
637 * is functioning the same under all the different combinations as it should.
638 * \param function The checking routine to use.
639 * \param version The trigger menu configuration version to use in <i>RunTrigger</i>.
640 * \param testName The name of the test being run.
641 * \param numOfEvents The number of events to run the chain for.
642 * \param customClass Name of the custom class as passed to <i>RunTrigger</i>.
643 * \param showOutput If true then the output from the RunTrigger method is not suppressed.
644 * \returns true if the different checks succeeded and false otherwise.
646 bool CheckDifferentModes(
647 CheckFunctionType function, int version, const char* testName,
648 int numOfEvents = 8, const char* customClass = NULL,
649 bool showOutput = false
652 TString name = testName;
653 name += " in debug mode";
654 cout << "#################### Running test: " << name.Data() << " ####################" << endl;
655 CallRunTrigger(version, false, true, numOfEvents, customClass, showOutput);
656 if (! function(testName)) return false;
657 gSystem->Exec("rm -f testOutputFile.root"); // Cleanup output file for next test.
660 cout << "#################### Running test: " << name.Data() << " ####################" << endl;
661 CallRunTrigger(version, false, false, numOfEvents, customClass, showOutput);
662 if (! function(testName)) return false;
663 gSystem->Exec("rm -f testOutputFile.root"); // Cleanup output file for next test.
666 name += " interpreted with CINT in debug mode";
667 cout << "#################### Running test: " << name.Data() << " ####################" << endl;
668 CallRunTrigger(version, true, true, numOfEvents, customClass, showOutput);
669 if (! function(testName)) return false;
670 gSystem->Exec("rm -f testOutputFile.root"); // Cleanup output file for next test.
673 name += " interpreted with CINT";
674 cout << "#################### Running test: " << name.Data() << " ####################" << endl;
675 CallRunTrigger(version, true, false, numOfEvents, customClass, showOutput);
676 if (! function(testName)) return false;
677 gSystem->Exec("rm -f testOutputFile.root"); // Cleanup output file for next test.
683 * Runs several tests for the AliHLTGlobalTriggerComponent class.
684 * We specifically test if the global trigger menu configuration is interpreted
685 * correctly and the trigger logic generated correctly on the fly.
686 * \param configVersion The appropriate version number of the config being tested
687 * which is passed to TriggerConfig.C.
688 * \param customClass Name of the custom class as passed to <i>CheckDifferentModes</i>.
689 * \returns true if the different checks succeeded and false otherwise.
690 * \param numOfEvents The number of events to run the chain for.
691 * \returns true if all the tests succeeded and false otherwise.
693 bool testGlobalTriggerComponent(int configVersion = -1, const char* customClass = NULL, int numOfEvents = 8)
697 if (configVersion != -1)
699 CheckFunctionType function = NULL;
700 switch (configVersion)
702 case 0: function = CheckPriorityGroupTestConfig; break;
703 case 1: function = CheckSingleGroupTestConfig; break;
704 case 2: function = CheckPrescalarTestConfig; break;
705 case 3: function = CheckSymbolTestConfig; break;
706 case 4: function = CheckComplexTestConfig; break;
708 cerr << "ERROR: Invalid value for configVersion specified." << endl;
711 bool result = CheckDifferentModes(
714 Form("Config version %d", configVersion),
722 if (! CheckDifferentModes(CheckPriorityGroupTestConfig, 0, "Priority group config", numOfEvents, customClass)) return false;
723 if (! CheckDifferentModes(CheckSingleGroupTestConfig, 1, "Single group config", numOfEvents, customClass)) return false;
724 if (! CheckDifferentModes(CheckPrescalarTestConfig, 2, "Prescalar config", numOfEvents, customClass)) return false;
725 if (! CheckDifferentModes(CheckSymbolTestConfig, 3, "Symbol config", numOfEvents, customClass)) return false;
726 if (! CheckDifferentModes(CheckComplexTestConfig, 4, "Complex config", numOfEvents, customClass)) return false;
728 // Cleanup all temporary files generated.
729 gSystem->Exec("rm -f testOutputFile.root testInputFile*.root AliHLTGlobalTriggerImpl*");
736 int main(int /*argc*/, const char** /*argv*/)
738 bool resultOk = testGlobalTriggerComponent();
739 if (not resultOk) return 1;
743 #endif // __MAKECINT__