ATLAS Offline Software
Classes | Macros | Functions
xAODFileReadTest.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/TEvent.h"
#include "xAODRootAccess/tools/Message.h"

Go to the source code of this file.

Classes

class  TEventClass
 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 xAODFileReadTest.cxx.

Function Documentation

◆ main()

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

Definition at line 93 of file xAODFileReadTest.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::TEvent::EAuxMode >( mode );
123  ++i;
124  }
125  } else {
126  fileNames.push_back( argv[ i ] );
127  }
128  }
129 
130  // Create the "TEvent" object used for the test:
131  TEventClass event( auxMode );
132 
133  // Loop over the specified input files:
134  for( const std::string& fileName : fileNames ) {
135 
136  // Open the file:
137  std::unique_ptr< TFile > ifile( TFile::Open( fileName.c_str(), "READ" ) );
138  if( ( ! ifile.get() ) || ifile->IsZombie() ) {
139  Error( APP_NAME, XAOD_MESSAGE( "Couldn't open file: %s" ),
140  fileName.c_str() );
141  return 1;
142  }
143  Info( APP_NAME, "Opened file: %s", fileName.c_str() );
144 
145  // Give it to TEvent:
146  R_CHECK( event.readFrom( ifile.get() ) );
147 
148  // Loop over the file's events:
149  const Long64_t entries = event.getEntries();
150  for( Long64_t entry = 0; entry < entries; ++entry ) {
151 
152  // Load the event:
153  if( event.getEntry( entry ) < 0 ) {
154  Error( APP_NAME,
155  XAOD_MESSAGE( "Failed to load entry %i from file: %s" ),
156  static_cast< int >( entry ), fileName.c_str() );
157  return 1;
158  }
159 
160  // Load the event:
161  R_CHECK( event.loadInputObjects() );
162 
163  // Tell the user where we are:
164  if( ( entry % 1000 == 0 ) || ( entry +1 == entries ) ) {
165  Info( APP_NAME, "===>>> Loaded entry %i / %i <<<===",
166  static_cast< int >( entry ), static_cast< int >( entries ) );
167  }
168  }
169  }
170 
171  // Return gracefully:
172  return 0;
173 }
R_CHECK
#define R_CHECK(EXP)
Helper macro.
Definition: xAODFileReadTest.cxx:26
get_generator_info.result
result
Definition: get_generator_info.py:21
checkxAOD.fileNames
fileNames
Definition: Tools/PyUtils/bin/checkxAOD.py:73
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
TEventClass
Class used for the test.
Definition: xAODFileReadTest.cxx:36
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:97
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
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
Preparation.mode
mode
Definition: Preparation.py:94
run_gep.ifile
ifile
Definition: run_gep.py:65
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::TEvent::EAuxMode
EAuxMode
Auxiliary store "mode".
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:95
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
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31