ATLAS Offline Software
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 
14 using namespace TrigAnalysisTest;
15 using namespace std;
16 
17 
18 #ifdef ROOTCORE
19 # include <xAODRootAccess/TEvent.h>
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 
34 using namespace std;
35 using namespace Trig;
36 using namespace TrigConf;
37 using namespace xAOD;
38 
39 namespace 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
60  TEvent event(TEvent::kClassAccess);
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 }
xAODConfigTool.h
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
Trig
The common trigger namespace for trigger analysis tools.
Definition: LArCellMonAlg.h:33
TrigDecisionTool.h
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
RootCoreTestHarness.h
Trig::TrigDecisionTool
Definition: TrigDecisionTool.h:65
ReturnCheck.h
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
TestFactory.h
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
TEvent.h
Init.h
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
TrigAnalysisTest
Definition: BasicTriggerFired.cxx:30
asg::SgTEvent
Wrapper for TEvent to make it look like StoreGate.
Definition: SgTEvent.h:44
TrigAnalysisTest::runTrigAnalysisTest
int runTrigAnalysisTest(const std::string &testName)
Definition: RootCoreTestHarness.cxx:41
TrigAnalysisTest::GetTrigAnalysisTest
ITest * GetTrigAnalysisTest(const string &name)
Definition: TestFactory.cxx:22
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
Trig::TrigDecisionTool::initialize
StatusCode initialize()
Definition: TrigDecisionTool.cxx:45
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
SgTEvent.h
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31
TrigConf::xAODConfigTool
Trigger configuration metadata tool for xAOD analysis.
Definition: xAODConfigTool.h:55