ATLAS Offline Software
Classes | Macros | Functions
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. More...
 

Functions

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

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 )

Helper macro.

Definition at line 27 of file xAODRNFileReadTest.cxx.

Function Documentation

◆ main()

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

Definition at line 93 of file xAODRNFileReadTest.cxx.

93  {
94 
95  // Initialise the environment:
96  R_CHECK( xAOD::Init() );
97 
98  // Provide usage instructions if not enough options were given:
99  if( ( argc < 2 ) ||
100  ( ! strcmp( argv[ 1 ], "-h" ) ) ||
101  ( ! strcmp( argv[ 1 ], "--help" ) ) ) {
102  Info( APP_NAME, "Usage: %s [options] <file1> [file2]...", APP_NAME );
103  Info( APP_NAME, "Options:" );
104  Info( APP_NAME, " -m <access mode>" );
105  Info( APP_NAME, " 0: Branch access" );
106  Info( APP_NAME, " 1: Class access (default)" );
107  Info( APP_NAME, " 2: Athena access" );
108  return 1;
109  }
110 
111  // Decode the command line options:
112  std::vector< std::string > fileNames;
114  for( int i = 1; i < argc; ++i ) {
115  if( ! strcmp( argv[ i ], "-m" ) ) {
116  if( i + 1 >= argc ) {
117  ::Error( APP_NAME,
118  XAOD_MESSAGE( "No access mode specified after -m" ) );
119  return 1;
120  } else {
121  const long mode = ::strtol( argv[ i + 1 ], 0, 10 );
122  auxMode = static_cast< xAOD::Experimental::REvent::EAuxMode >( mode );
123  ++i;
124  }
125  } else {
126  fileNames.push_back( argv[ i ] );
127  }
128  }
129 
130  // Create the "REvent" object used for the test:
131  REventClass event( auxMode );
132 
133  // Loop over the specified input files:
134  for( const std::string& fileName : fileNames ) {
135 
136  // // Open the file:
137  Info( APP_NAME, "Opening file: %s", fileName.c_str() );
138 
139  // Give it to REvent:
140 
141  // Call readFrom to setup REvent for reading
143 
144  // Loop over the file's events:
145  const Long64_t entries = event.getEntries();
146  for( Long64_t entry = 0; entry < entries; ++entry ) {
147 
148  // Load the event:
149  if( event.getEntry( entry ) < 0 ) {
150  Error( APP_NAME,
151  XAOD_MESSAGE( "Failed to load entry %i from file: %s" ),
152  static_cast< int >( entry ), fileName.c_str() );
153  return 1;
154  }
155 
156  // Load the event:
157  R_CHECK( event.loadInputObjects() );
158 
159  // Tell the user where we are:
160  if( ( entry % 1000 == 0 ) || ( entry +1 == entries ) ) {
161  Info( APP_NAME, "===>>> Loaded entry %i / %i <<<===",
162  static_cast< int >( entry ), static_cast< int >( entries ) );
163  }
164  }
165  }
166 
167  // Return gracefully:
168  return 0;
169 }
get_generator_info.result
result
Definition: get_generator_info.py:21
checkxAOD.fileNames
fileNames
Definition: Tools/PyUtils/bin/checkxAOD.py:79
xAOD::Experimental::REvent::EAuxMode
EAuxMode
Auxiliary store "mode".
Definition: REvent.h:118
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
REventClass
Class used for the test.
Definition: xAODRNFileReadTest.cxx:36
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
POOL::TEvent::getEntry
int getEntry(long entry)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:185
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
Preparation.mode
mode
Definition: Preparation.py:107
R_CHECK
#define R_CHECK(EXP)
Helper macro.
Definition: xAODRNFileReadTest.cxx:26
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:19
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::Experimental::REvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: REvent.h:120
entries
double entries
Definition: listroot.cxx:49
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31