ATLAS Offline Software
Loading...
Searching...
No Matches
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 )
#define APP_NAME

Definition at line 25 of file testClassifier.cxx.

25#define CHECK( ARG ) \
26do { \
27 const bool result = ARG; \
28 if( ! result ) { \
29 ::Error( APP_NAME, "Failed to execute: \"%s\"", \
30#ARG ); \
31 return 1; \
32 } \
33 } while( false )

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}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Tool for accessing xAOD files outside of Athena.
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
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Electron_v1 Electron
Definition of the current "egamma version".
#define CHECK(ARG)