ATLAS Offline Software
Loading...
Searching...
No Matches
RootCoreTestHarness.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 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
20# include <xAODRootAccess/Init.h>
22# include <AsgTools/SgTEvent.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 auto chain = new TChain("CollectionTree");
57 chain->Add(gSystem->Getenv("ROOTCORE_TEST_FILE"));
58
59 // Init data access to the trigger
61 if (!event.readFrom(chain).isSuccess()) {
62 return 1;
63 }
64
65 xAODConfigTool configTool("xAODConfigTool");
66 ToolHandle<TrigConf::ITrigConfigTool> configHandle(&configTool);
67 configHandle->initialize();
68
69 TrigDecisionTool trigDecTool("TrigDecTool");
70 trigDecTool.setProperty("ConfigTool",configHandle);
71 trigDecTool.setProperty("TrigDecisionKey","xTrigDecision");
72 trigDecTool.initialize();
73
74 asg::SgTEvent sgtevent(&event);
75 test->setEventStore( &sgtevent );
76
77 // Run the files
78 size_t nEntries = chain->GetEntries();
79 for (size_t entry = 0; entry < nEntries; entry++) {
80 event.getEntry(entry);
81
82 test->processEvent (trigDecTool);
83 }
84
85 // Clean up
86 return test->finalize();
87 }
88}
Trigger configuration metadata tool for xAOD analysis.
StatusCode initialize()
Dummy implementation of the initialisation function.
Wrapper for TEvent to make it look like StoreGate.
Definition SgTEvent.h:44
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
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