ATLAS Offline Software
xAODTrigConfReadTest.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 // $Id: xAODTrigConfReadTest.cxx 718019 2016-01-15 15:52:18Z tbold $
6 
7 // System include(s):
8 #include <memory>
9 
10 // ROOT include(s):
11 #ifdef ROOTCORE
12 # include <TFile.h>
13 # include <TError.h>
14 #endif // ROOTCORE
15 
16 // Infrastructure include(s):
17 #ifdef ROOTCORE
18 # include "xAODRootAccess/Init.h"
19 # include "xAODRootAccess/TEvent.h"
21 #endif // ROOTCORE
22 
23 // ASG include(s):
24 #include "AsgTools/ToolHandle.h"
26 
27 // Local include(s):
29 
30 int main( int argc, char* argv[] ) {
31 
32  // Get the application's name:
33  const char* APP_NAME = argv[ 0 ];
34 
35  // Check that we received at least one file name:
36  if( argc < 2 ) {
37  ::Error( APP_NAME, "Usage: %s <xAOD file1> [xAOD file2]...", APP_NAME );
38  return 1;
39  }
40 
41  // Initialise the application:
43 
44  // Create a TEvent object:
46 
47  // Create the trigger configuration tool:
48  TrigConf::xAODConfigTool configTool( "xAODConfigTool" );
49  // configTool.setProperty( "MetaObjectName", "Bla" );
50  configTool.setProperty( "OutputLevel", MSG::VERBOSE ).ignore();
51  if( configTool.initialize().isFailure() ) {
52  ::Error( APP_NAME, "Couldn't initialise the trigger configuration tool" );
53  return 1;
54  }
55 
56  // Try creating ToolHandles for this tool:
57  ToolHandle< TrigConf::ITrigConfigTool > handle( "xAODConfigTool" );
58  ToolHandleArray< TrigConf::ITrigConfigTool > handleArray{ "xAODConfigTool" };
59 
60  // Check if they can be retrieved:
61  if( handle.retrieve().isFailure() || handleArray.retrieve().isFailure() ) {
63  "Couldn't retrieve the tested tool through tool handles" );
64  return 1;
65  }
66 
67  // Loop over the files:
68  for( int i = 1; i < argc; ++i ) {
69 
70  // Open the input file:
71  std::unique_ptr< ::TFile > ifile( ::TFile::Open( argv[ i ], "READ" ) );
72  if( ! ifile.get() ) {
73  ::Error( APP_NAME, "Couldn't open file: %s", argv[ i ] );
74  return 1;
75  }
76  ::Info( APP_NAME, "Opened file: %s", argv[ i ] );
77 
78  // Connect the TEvent object to it:
80 
81  // Loop over a few events:
82  const ::Long64_t entries = event.getEntries();
83  for( ::Long64_t entry = 0; entry < entries; ++entry ) {
84 
85  // Get the current entry:
86  event.getEntry( entry );
87 
88  // Print some additional info for the first 10 events:
89  if( entry < 10 ) {
90  ::Info( APP_NAME, "Processing entry %i", static_cast< int >( entry ) );
91 
92  // Get some information out of the tested tool:
93  ::Info( APP_NAME, "SMK: %i, L1PSK: %i, HLTPSK: %i",
94  static_cast< int >( configTool.masterKey() ),
95  static_cast< int >( configTool.lvl1PrescaleKey() ),
96  static_cast< int >( configTool.hltPrescaleKey() ) );
97  ::Info( APP_NAME, " Number of L1 items: %i",
98  static_cast< int >( configTool.ctpConfig()->menu().items().size() ) );
99  ::Info( APP_NAME, " Number of HLT chains: %i",
100  static_cast< int >( configTool.chains().size() ) );
101  ::Info( APP_NAME, " L1 menu " );
102  configTool.ctpConfig()->print("", 100);
103  }
104 
105  // Give some feedback of where we are:
106  if( ! ( entry % 100 ) ) {
107  ::Info( APP_NAME, "Processed %i/%i events",
108  static_cast< int >( entry ),
109  static_cast< int >( entries ) );
110  }
111  }
112  }
113 
114  // Return gracefully:
115  return 0;
116 }
TestSUSYToolsAlg.ifile
ifile
Definition: TestSUSYToolsAlg.py:92
RETURN_CHECK
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition: ReturnCheck.h:26
xAODConfigTool.h
TrigConf::xAODConfigTool::lvl1PrescaleKey
virtual uint32_t lvl1PrescaleKey() const override
Get the LVL1 prescale key.
Definition: xAODConfigTool.cxx:136
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
TrigConf::xAODConfigTool::hltPrescaleKey
virtual uint32_t hltPrescaleKey() const override
Get the HLT prescale key.
Definition: xAODConfigTool.cxx:206
ReturnCheck.h
main
int main(int argc, char *argv[])
Definition: xAODTrigConfReadTest.cxx:30
TrigConf::xAODConfigTool::ctpConfig
virtual const CTPConfig * ctpConfig() const override
Get the LVL1 trigger menu.
Definition: xAODConfigTool.cxx:114
ToolHandleArray.h
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:132
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
TEvent.h
Init.h
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
TrigConf::xAODConfigTool::initialize
virtual StatusCode initialize() override
Function initialising the tool.
Definition: xAODConfigTool.cxx:78
TrigConf::CTPConfig::menu
const Menu & menu() const
Definition: CTPConfig.h:38
TrigConf::Menu::items
const ItemContainer & items() const
Definition: Menu.h:140
TrigConf::xAODConfigTool::chains
virtual const HLTChainList & chains() const override
Get the HLT chains.
Definition: xAODConfigTool.cxx:165
entries
double entries
Definition: listroot.cxx:49
TrigConf::xAODConfigTool::masterKey
virtual uint32_t masterKey() const override
Get the Super Master Key.
Definition: xAODConfigTool.cxx:187
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
xAOD::TEvent::kBranchAccess
@ kBranchAccess
Access auxiliary data branch-by-branch.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:96
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
ToolHandle.h
TrigConf::CTPConfig::print
virtual void print(const std::string &indent="", unsigned int detail=1) const override
Definition: CTPConfig.cxx:93
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
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