ATLAS Offline Software
Loading...
Searching...
No Matches
RootCoreTestHarness.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//
6// Code to run a test of a given name.
7//
8
10
12#include <iostream>
13
14using namespace TrigAnalysisTest;
15using namespace std;
16
17
18#ifdef ROOTCORE
19# include <xAODRootAccess/Event.h>
20# include <xAODRootAccess/Init.h>
22# include <AsgTools/SgEvent.h>
23#endif
24
27
28#include "TChain.h"
29#include "TError.h"
30#include "TFile.h"
31#include "TH1F.h"
32#include "TSystem.h"
33
34using namespace std;
35using namespace Trig;
36using namespace TrigConf;
37using namespace xAOD;
38
39namespace TrigAnalysisTest {
40
41 int runTrigAnalysisTest (const std::string &testName)
42 {
43 // Fetch the test to run it.
44 auto test = GetTrigAnalysisTest(testName);
45 if (test == nullptr) {
46 cout << "Unable to load test" << endl;
47 return 1;
48 }
49
50 // Initialize (as done for all xAOD standalone programs!)
51 if (!xAOD::Init(testName.c_str()).isSuccess()) {
52 return 1;
53 }
54
55 // Load up the proper file we should be checking against.
56 std::unique_ptr< TFile > file( TFile::Open( gSystem->Getenv("ROOTCORE_TEST_FILE"), "READ" ) );
57
58
59 // Init data access to the trigger
61 if (!event) {
62 cout << "cannot read from file: " << file << endl;
63 return 1;
64 }
65
66 xAODConfigTool configTool("xAODConfigTool");
67 ToolHandle<TrigConf::ITrigConfigTool> configHandle(&configTool);
68 if (!configHandle->initialize().isSuccess()) return 1;
69
70 TrigDecisionTool trigDecTool("TrigDecTool");
71 if (!trigDecTool.setProperty("ConfigTool",configHandle)) return 1;
72 if (!trigDecTool.setProperty("TrigDecisionKey","xTrigDecision")) return 1;
73 if (!trigDecTool.initialize()) return 1;
74
75 asg::SgEvent sgevent(event.get());
76 test->setEventStore( &sgevent );
77
78 // Run the files
79 size_t nEntries = event->getEntries();
80 for (size_t entry = 0; entry < nEntries; entry++) {
81 event->getEntry(entry);
82
83 test->processEvent (trigDecTool);
84 }
85
86 // Clean up
87 return test->finalize();
88 }
89}
Trigger configuration metadata tool for xAOD analysis.
StatusCode initialize()
Dummy implementation of the initialisation function.
Wrapper for Event to make it look like StoreGate.
Definition SgEvent.h:44
static std::unique_ptr< Event > createAndReadFrom(TFile &file)
static method to create an Event object and readFrom a file, given by a TFile.
Definition EventIO.cxx:43
ITest * GetTrigAnalysisTest(const string &name)
int runTrigAnalysisTest(const std::string &testName)
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
The common trigger namespace for trigger analysis tools.
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
TFile * file