ATLAS Offline Software
Macros | Functions
testClassifier.cxx File Reference
#include <memory>
#include <cstdlib>
#include <TFile.h>
#include <TError.h>
#include <TString.h>
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/PhotonContainer.h"
#include "MCTruthClassifier/MCTruthClassifier.h"
#include "MCTruthClassifier/MCTruthClassifierDefs.h"
Include dependency graph for testClassifier.cxx:

Go to the source code of this file.

Macros

#define CHECK(ARG)
 

Functions

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

Macro Definition Documentation

◆ CHECK

#define CHECK (   ARG)
Value:
do { \
const bool result = ARG; \
if( ! result ) { \
::Error( APP_NAME, "Failed to execute: \"%s\"", \
#ARG ); \
return 1; \
} \
} while( false )

Definition at line 26 of file testClassifier.cxx.

Function Documentation

◆ main()

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

Definition at line 35 of file testClassifier.cxx.

35  {
36 
37  // The application's name:
38  const char* APP_NAME = argv[ 0 ];
39  // Check if we received a file name:
40  if( argc < 2 ) {
41  Error( APP_NAME, "No file name received!" );
42  Error( APP_NAME, " Usage: %s [xAOD file name]", APP_NAME );
43  return 1;
44  }
45 
46  // Initialise the application:
48 
49  // Open the input file:
50  const TString fileName = argv[ 1 ];
51  Info( APP_NAME, "Opening file: %s", fileName.Data() );
52  std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
53  CHECK( ifile.get() );
54 
55  // Create a TEvent object:
57  CHECK( event.readFrom( ifile.get() ) );
58  Info( APP_NAME, "Number of events in the file: %i",
59  static_cast< int >( event.getEntries() ) );
60 
61  // Decide how many events to run over:
62  Long64_t entries = event.getEntries();
63  if( argc > 2 ) {
64  const Long64_t e = atoll( argv[ 2 ] );
65  if( e < entries ) {
66  entries = e;
67  }
68  }
69 
70  MCTruthClassifier myClassifier ("myClassifier");
71  CHECK( myClassifier.initialize() );
72 
73  // Loop over the events:
74  for( Long64_t entry = 0; entry < entries; ++entry ) {
75 
76  // Tell the object which entry to look at:
77  event.getEntry( entry );
78 
79  std::cout << "=================NEXT EVENT==========================" << std::endl;
80 
81  //Electrons
83  CHECK( event.retrieve(electrons, "Electrons") );
84 
87  unsigned int i = 0;
88 
89  for (; el_it != el_it_last; ++el_it, ++i) {
90  const xAOD::Electron* el = (*el_it);
91  std::cout << "Electron " << el << " Num " << i << std::endl;
92  std::cout << "xAOD pt = " << (*el_it)->pt() << std::endl;
93  Info (APP_NAME,"Electron #%d", i);
94  std::pair<MCTruthPartClassifier::ParticleType,MCTruthPartClassifier::ParticleOrigin>
95  classification = myClassifier.particleTruthClassifier(*el_it);
96 
97  static SG::AuxElement::Accessor<int> tT("truthType") ;
98  if (tT.isAvailable(**el_it)){;
99  Info (APP_NAME,"Electron Type from Reco returns %d ", tT(**el_it) );
100  }
101  Info (APP_NAME,"Electron Type from Analysis Base returns %d ", classification.first );
102  static SG::AuxElement::Accessor<int> tO("truthOrigin") ;
103  if (tO.isAvailable(**el_it)){;
104  Info (APP_NAME,"Electron Origin from Reco returns %d ", tO(**el_it) );
105  }
106  Info (APP_NAME,"Electron Origin from Analysis Base returns %d ", classification.second );
107  }
108  Info( APP_NAME, "===>>> done processing event #%lld ",entry);
109  }
110 
111  // Return gracefully:
112  return 0;
113 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
get_generator_info.result
result
Definition: get_generator_info.py:21
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
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)
lumiFormat.i
int i
Definition: lumiFormat.py:85
POOL::TEvent::getEntries
long getEntries()
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:124
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
CHECK
#define CHECK(ARG)
Definition: testClassifier.cxx:25
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::Electron_v1
Definition: Electron_v1.h:34
MCTruthClassifier
Definition: MCTruthClassifier.h:56
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:74
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
LArCellNtuple.ifile
string ifile
Definition: LArCellNtuple.py:133
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31