ATLAS Offline Software
Macros | Functions
testEGChargeIDSelector.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 "xAODEgamma/Electron.h"
#include "xAODEgamma/Photon.h"
#include "ElectronPhotonSelectorTools/AsgPhotonIsEMSelector.h"
#include "ElectronPhotonSelectorTools/AsgForwardElectronIsEMSelector.h"
#include "ElectronPhotonSelectorTools/AsgElectronIsEMSelector.h"
#include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h"
#include "ElectronPhotonSelectorTools/AsgElectronChargeIDSelectorTool.h"
#include "AsgMessaging/AsgMessaging.h"
#include "xAODCore/tools/IOStats.h"
#include "xAODCore/tools/ReadStats.h"

Go to the source code of this file.

Macros

#define DUMMY_MSG(lvl, ARG)   {dummymsg.msg(lvl)<<ARG<<endmsg ;}
 
#define MSG_DEBUG(ARG)   {DUMMY_MSG(MSG::DEBUG, ARG);}
 
#define MSG_INFO(ARG)   {DUMMY_MSG(MSG::INFO, ARG);}
 
#define MSG_WARNING(ARG)   {DUMMY_MSG(MSG::WARNING, ARG);}
 
#define MSG_ERROR(ARG)   {DUMMY_MSG(MSG::ERROR, ARG);}
 
#define MSG_FATAL(ARG)   {DUMMY_MSG(MSG::FATAL, ARG);}
 
#define MSG_ABORT(ARG)   {DUMMY_MSG(MSG::FATAL, ARG); std::abort();}
 
#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 53 of file testEGChargeIDSelector.cxx.

◆ DUMMY_MSG

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

Definition at line 46 of file testEGChargeIDSelector.cxx.

◆ MSG_ABORT

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

Definition at line 52 of file testEGChargeIDSelector.cxx.

◆ MSG_DEBUG

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

Definition at line 47 of file testEGChargeIDSelector.cxx.

◆ MSG_ERROR

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

Definition at line 50 of file testEGChargeIDSelector.cxx.

◆ MSG_FATAL

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

Definition at line 51 of file testEGChargeIDSelector.cxx.

◆ MSG_INFO

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

Definition at line 48 of file testEGChargeIDSelector.cxx.

◆ MSG_WARNING

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

Definition at line 49 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) {
178  if(ph->author() != xAOD::EgammaParameters::AuthorCaloTopo35){
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 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
AsgPhotonIsEMSelector::initialize
virtual StatusCode initialize()
AlgTool initialize method.
Definition: AsgPhotonIsEMSelector.cxx:89
MSG_INFO
#define MSG_INFO(ARG)
Definition: testEGChargeIDSelector.cxx:47
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::IOStats::stats
ReadStats & stats()
Access the object belonging to the current thread.
Definition: IOStats.cxx:17
xAOD::TEvent::kAthenaAccess
@ kAthenaAccess
Access containers/objects like Athena does.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:101
AsgElectronLikelihoodTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override final
The main accept method: using the generic interface.
Definition: AsgElectronLikelihoodTool.cxx:868
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
MSG_ERROR
#define MSG_ERROR(ARG)
Definition: testEGChargeIDSelector.cxx:49
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
AsgElectronChargeIDSelectorTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations.
Definition: AsgElectronChargeIDSelectorTool.cxx:81
AsgPhotonIsEMSelector::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const
Accept with generic interface.
Definition: AsgPhotonIsEMSelector.cxx:227
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
xAOD::EgammaParameters::AuthorCaloTopo35
const uint16_t AuthorCaloTopo35
Photon reconstructed by SW CaloTopo35 seeded clusters.
Definition: EgammaDefs.h:38
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
AsgElectronChargeIDSelectorTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override final
Method to get the plain AcceptInfo.
Definition: AsgElectronChargeIDSelectorTool.cxx:614
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
xAOD::IOStats::instance
static IOStats & instance()
Singleton object accessor.
Definition: IOStats.cxx:11
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::ReadStats::printSmartSlimmingBranchList
void printSmartSlimmingBranchList(bool autoIncludeLinks=false) const
Print the accessed variables, formatted for smart slimming.
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
CHECK
#define CHECK(ARG)
Definition: testEGChargeIDSelector.cxx:52
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
xAOD::Photon_v1
Definition: Photon_v1.h:37
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
entries
double entries
Definition: listroot.cxx:49
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
AsgElectronLikelihoodTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations.
Definition: AsgElectronLikelihoodTool.cxx:80
LArCellNtuple.ifile
string ifile
Definition: LArCellNtuple.py:133
test_pyathena.counter
counter
Definition: test_pyathena.py:15
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