ATLAS Offline Software
Loading...
Searching...
No Matches
xAODRNFileReadTest.cxx File Reference
#include <cstring>
#include <memory>
#include <vector>
#include <string>
#include <TFile.h>
#include <TError.h>
#include <TClass.h>
#include "xAODRootAccess/Init.h"
#include "xAODRootAccess/REvent.h"
#include "xAODRootAccess/tools/Message.h"

Go to the source code of this file.

Classes

class  REventClass
 Class used for the test. More...

Macros

#define R_CHECK(EXP)
 Helper macro.

Functions

int main (int argc, char *argv[])

Variables

static const char *const APP_NAME = "xAODFileReadTest"
 The name of the application.

Macro Definition Documentation

◆ R_CHECK

#define R_CHECK ( EXP)
Value:
do { \
const auto result = EXP; \
if( ! result.isSuccess() ) { \
Error( APP_NAME, XAOD_MESSAGE( "Failed to execute: %s" ), #EXP ); \
return 1; \
} \
} while( 0 )
#define APP_NAME
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.

Helper macro.

Definition at line 26 of file xAODRNFileReadTest.cxx.

26#define R_CHECK( EXP ) \
27 do { \
28 const auto result = EXP; \
29 if( ! result.isSuccess() ) { \
30 Error( APP_NAME, XAOD_MESSAGE( "Failed to execute: %s" ), #EXP ); \
31 return 1; \
32 } \
33 } while( 0 )

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 95 of file xAODRNFileReadTest.cxx.

95 {
96
97 // Initialise the environment:
99
100 // Provide usage instructions if not enough options were given:
101 if( ( argc < 2 ) ||
102 ( ! strcmp( argv[ 1 ], "-h" ) ) ||
103 ( ! strcmp( argv[ 1 ], "--help" ) ) ) {
104 Info( APP_NAME, "Usage: %s [options] <file1> [file2]...", APP_NAME );
105 Info( APP_NAME, "Options:" );
106 Info( APP_NAME, " -m <access mode>" );
107 Info( APP_NAME, " 0: Branch access" );
108 Info( APP_NAME, " 1: Class access (default)" );
109 Info( APP_NAME, " 2: Athena access" );
110 return 1;
111 }
112
113 // Decode the command line options:
114 std::vector< std::string > fileNames;
115 for( int i = 1; i < argc; ++i ) {
116 fileNames.push_back( argv[ i ] );
117 }
118
119 // Create the "REvent" object used for the test:
121
122 // Loop over the specified input files:
123 for( const std::string& fileName : fileNames ) {
124
125 // // Open the file:
126 Info( APP_NAME, "Opening file: %s", fileName.c_str() );
127
128 // Give it to Event:
129
130 // Call readFrom to setup REvent for reading
131 R_CHECK( event.readFrom( fileName ) );
132
133 // Loop over the file's events:
134 const Long64_t entries = event.getEntries();
135 for( Long64_t entry = 0; entry < entries; ++entry ) {
136
137 // Load the event:
138 if( event.getEntry( entry ) < 0 ) {
140 XAOD_MESSAGE( "Failed to load entry %i from file: %s" ),
141 static_cast< int >( entry ), fileName.c_str() );
142 return 1;
143 }
144
145 // Load the event:
146 R_CHECK( event.loadInputObjects() );
147
148 // Tell the user where we are:
149 if( ( entry % 1000 == 0 ) || ( entry +1 == entries ) ) {
150 Info( APP_NAME, "===>>> Loaded entry %i / %i <<<===",
151 static_cast< int >( entry ), static_cast< int >( entries ) );
152 }
153 }
154 }
155
156 // Return gracefully:
157 return 0;
158}
Class used for the test.
double entries
Definition listroot.cxx:49
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
@ Info
Definition ZDCMsg.h:20
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
#define R_CHECK(EXP)
Helper macro.

Variable Documentation

◆ APP_NAME

const char* const APP_NAME = "xAODFileReadTest"
static

The name of the application.

Definition at line 23 of file xAODRNFileReadTest.cxx.