ATLAS Offline Software
Loading...
Searching...
No Matches
testEGChargeIDSelector.cxx File Reference

Go to the source code of this file.

Macros

#define DUMMY_MSG(lvl, ARG)
#define MSG_DEBUG(ARG)
#define MSG_INFO(ARG)
#define MSG_WARNING(ARG)
#define MSG_ERROR(ARG)
#define MSG_FATAL(ARG)
#define MSG_ABORT(ARG)
#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 ) { \
MSG_ERROR("FAILED to execute" <<#ARG); \
return EXIT_FAILURE; \
} \
} while( false )

Definition at line 52 of file testEGChargeIDSelector.cxx.

52#define CHECK( ARG ) \
53 do { \
54 const bool result = ARG; \
55 if( ! result ) { \
56 MSG_ERROR("FAILED to execute" <<#ARG); \
57 return EXIT_FAILURE; \
58 } \
59 } while( false )

◆ DUMMY_MSG

#define DUMMY_MSG ( lvl,
ARG )
Value:
{dummymsg.msg(lvl)<<ARG<<endmsg ;}
#define endmsg

Definition at line 45 of file testEGChargeIDSelector.cxx.

◆ MSG_ABORT

#define MSG_ABORT ( ARG)
Value:
{DUMMY_MSG(MSG::FATAL, ARG); std::abort();}
#define DUMMY_MSG(lvl, ARG)

Definition at line 51 of file testEGChargeIDSelector.cxx.

◆ MSG_DEBUG

#define MSG_DEBUG ( ARG)
Value:
{DUMMY_MSG(MSG::DEBUG, ARG);}

Definition at line 46 of file testEGChargeIDSelector.cxx.

◆ MSG_ERROR

#define MSG_ERROR ( ARG)
Value:
{DUMMY_MSG(MSG::ERROR, ARG);}

Definition at line 49 of file testEGChargeIDSelector.cxx.

◆ MSG_FATAL

#define MSG_FATAL ( ARG)
Value:
{DUMMY_MSG(MSG::FATAL, ARG);}

Definition at line 50 of file testEGChargeIDSelector.cxx.

◆ MSG_INFO

#define MSG_INFO ( ARG)
Value:
{DUMMY_MSG(MSG::INFO, ARG);}

Definition at line 47 of file testEGChargeIDSelector.cxx.

◆ MSG_WARNING

#define MSG_WARNING ( ARG)
Value:
{DUMMY_MSG(MSG::WARNING, ARG);}

Definition at line 48 of file testEGChargeIDSelector.cxx.

Function Documentation

◆ main()

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

Definition at line 63 of file testEGChargeIDSelector.cxx.

63 {
64
65 // The application's name:
66 const char* APP_NAME = argv[ 0 ];
67
68 MSG::Level mylevel=MSG::DEBUG;
69 dummymsg.msg().setLevel(mylevel);
70 dummymsg.msg().setName(APP_NAME);
71 // Check if we received a file name:
72 if( argc < 2 ) {
73 MSG_ERROR("No file name received!" );
74 MSG_ERROR( " Usage: %s [xAOD file name]");
75 return EXIT_FAILURE;
76 }
77
78 // Initialise the application:
80
81 // Open the input file:
82 const TString fileName = argv[ 1 ];
83 Info( APP_NAME, "Opening file: %s", fileName.Data() );
84 std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
85 CHECK( ifile.get() );
86
87 // Check if we want to process Electron or Photon
88 bool isElectron = true;
89 if( argc < 4 ) {
90 Info (APP_NAME, "By default looking to Electron" );
91 } else {
92 int argv1 = atoi(argv[ 3 ]);
93 if(argv1 == 0) isElectron = false;
94 if(isElectron) Info( APP_NAME, "We are lookign to Electron-ID: %i", isElectron );
95 else Info( APP_NAME, "We are looking to Photon-ID" );
96 }
97 // Create a TEvent object (persistent store)
98
99 //For 2.4.5 testing
101 //For 2.3
102 //xAOD::TEvent pers( xAOD::TEvent::kBranchAccess );
103
104 // Create a TStore object (transient store)
105 xAOD::TStore trans;
106 CHECK( pers.readFrom( ifile.get() ) );
107 //
108 MSG_INFO("Number of events in the file: "<< pers.getEntries());
109
110 // Decide how many events to run over:
111 Long64_t entries = pers.getEntries();
112 if( argc > 2 ) {
113 const Long64_t e = atoll( argv[ 2 ] );
114 if( e < entries ) {
115 entries = e;
116 }
117 }
118
119
120 if (isElectron) {
121 //tight ECIDS
122 std::unique_ptr<AsgElectronChargeIDSelectorTool> m_electronECIDS = std::make_unique<AsgElectronChargeIDSelectorTool> ("tightECIDS");
123 std::string trainingfile = std::string(std::getenv("ROOTCOREBIN")) + "/data/ElectronPhotonSelectorTools/ECIDS_20161125for2017Moriond.root";
124 CHECK(m_electronECIDS->setProperty("TrainingFile", trainingfile));
125 CHECK(m_electronECIDS->setProperty("CutOnBDT", 0));
126 m_electronECIDS->msg().setLevel(mylevel);
127 CHECK(m_electronECIDS->initialize());
128
129 //Tight Likelihood electron
130 std::unique_ptr<AsgElectronLikelihoodTool> m_TightLH = std::make_unique<AsgElectronLikelihoodTool> ("TightLH");
131 CHECK(m_TightLH->setProperty("WorkingPoint", "TightLHElectron"));
132 m_TightLH->msg().setLevel(mylevel);
133 CHECK(m_TightLH->initialize());
134
135 // Loop over the events:
136 for( Long64_t entry = 0; entry < entries; ++entry ) {
137
138 // Tell the object which entry to look at:
139 pers.getEntry( entry );
140 MSG_INFO("============================");
141 MSG_INFO("Event: " <<entry);
142
144 CHECK(pers.retrieve(electrons, "Electrons"));
145
146 unsigned int counter=0;
147 for (const xAOD::Electron* el : *electrons) {
148 MSG_INFO("---------------------------");
149 MSG_INFO("Electron: " << counter);
150 MSG_INFO("Electron LH Tight accept result: " <<m_TightLH->accept(el));
151 // MSG_INFO("Electron stored LH Tight: " << el->passSelection("LHTight") );
152 MSG_INFO("Electron Cut ECIDS accept result: " <<m_electronECIDS->accept(el));
153 MSG_INFO("Electron stored Tight: " << el->passSelection("Tight") );
154 ++counter;
155 }
156 } // loop entries
157
158 } // is electron
159 else {
160 //Tight cut based photon
161 std::unique_ptr<AsgPhotonIsEMSelector> m_photonTightIsEMSelector = std::make_unique<AsgPhotonIsEMSelector> ("photonTightIsEMSelector");
162 CHECK(m_photonTightIsEMSelector->setProperty("WorkingPoint", "TightPhoton"));
163 m_photonTightIsEMSelector->msg().setLevel(mylevel);
164 CHECK(m_photonTightIsEMSelector->initialize());
165
166 // Loop over the events:
167 for( Long64_t entry = 0; entry < entries; ++entry ) {
168
169 // Tell the object which entry to look at:
170 pers.getEntry( entry );
171 MSG_INFO("============================");
172 MSG_INFO("Event: " <<entry);
173
174 const xAOD::PhotonContainer* photons;
175 CHECK(pers.retrieve(photons, "Photons"));
176 unsigned int counter=0;
177 for (const xAOD::Photon* ph : *photons) {
179 MSG_INFO("---------------------------");
180 MSG_INFO("Photon: " << counter);
181 MSG_INFO("Photon Tight accept result: " <<m_photonTightIsEMSelector->accept(ph));
182 ++counter;
183 }
184 }
185 }// loop entries
186 }
187
188
190 return 0;
191}
bool isElectron(const T &p)
Definition AtlasPID.h:202
#define APP_NAME
ReadStats & stats()
Access the object belonging to the current thread.
Definition IOStats.cxx:17
static IOStats & instance()
Singleton object accessor.
Definition IOStats.cxx:11
void printSmartSlimmingBranchList(bool autoIncludeLinks=false) const
Print the accessed variables, formatted for smart slimming.
Tool for accessing xAOD files outside of Athena.
@ kAthenaAccess
Access containers/objects like Athena does.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
double entries
Definition listroot.cxx:49
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
@ Info
Definition ZDCMsg.h:20
const uint16_t AuthorCaloTopo35
Photon reconstructed by SW CaloTopo35 seeded clusters.
Definition EgammaDefs.h:38
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".
#define MSG_INFO(ARG)
#define CHECK(ARG)
#define MSG_ERROR(ARG)