ATLAS Offline Software
Namespaces | Functions
testEGIdentificationPoints.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 "AsgTools/StandaloneToolHandle.h"
#include "PATCore/AcceptData.h"
#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h"
#include "EgammaAnalysisInterfaces/IAsgForwardElectronIsEMSelector.h"
#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h"
#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
#include "ElectronPhotonSelectorTools/egammaPIDdefs.h"
#include "AsgMessaging/MessageCheck.h"
#include "AsgMessaging/MsgStream.h"
#include "xAODCore/tools/IOStats.h"
#include "xAODCore/tools/ReadStats.h"

Go to the source code of this file.

Namespaces

 asg
 

Functions

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

Function Documentation

◆ main()

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

Definition at line 47 of file testEGIdentificationPoints.cxx.

47  {
48 
49  //
50  using namespace asg::msgSelectorCheck;
51  ANA_CHECK_SET_TYPE (int);
52  MSG::Level mylevel=MSG::INFO;
53  setMsgLevel(mylevel);
54  //
55 
56  // The application's name:
57  const char* APP_NAME = argv[ 0 ];
58 
59  // Check if we received a file name:
60  if( argc < 2 ) {
61  ANA_MSG_ERROR("No file name received!" );
62  ANA_MSG_ERROR( " Usage: %s [xAOD file name]");
63  return EXIT_FAILURE;
64  }
65 
66  // Initialise the application:
68 
69  // Open the input file:
70  const TString fileName = argv[ 1 ];
71  Info( APP_NAME, "Opening file: %s", fileName.Data() );
72  std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
73  ANA_CHECK( ifile.get() );
74 
75  // Check if we want to process Electron or Photon
76  bool isElectron = true;
77  if( argc < 4 ) {
78  Info (APP_NAME, "By default looking to Electron" );
79  } else {
80  int argv1 = atoi(argv[ 3 ]);
81  if(argv1 == 0) isElectron = false;
82  if(isElectron) Info( APP_NAME, "We are looking to Electron-ID: %i", isElectron );
83  else Info( APP_NAME, "We are looking to Photon-ID" );
84  }
85  // Create a TEvent object (persistent store)
86 
88 
89  // Create a TStore object (transient store)
90  xAOD::TStore trans;
91  ANA_CHECK( pers.readFrom( ifile.get() ) );
92  //
93  ANA_MSG_INFO("Number of events in the file: "<< pers.getEntries());
94 
95  // Decide how many events to run over:
96  Long64_t entries = pers.getEntries();
97  if( argc > 2 ) {
98  const Long64_t e = atoll( argv[ 2 ] );
99  if( e < entries ) {
100  entries = e;
101  }
102  }
103 
104 
105  if (isElectron) {
106  //Medium cut based Electrons
107 
108  asg::StandaloneToolHandle<IAsgElectronIsEMSelector> electronMediumIsEMSelector ("AsgElectronIsEMSelector/electronMediumIsEMSelector");
109  ANA_CHECK(electronMediumIsEMSelector.setProperty("WorkingPoint", "MediumElectron"));
110  ANA_CHECK(electronMediumIsEMSelector.setProperty("OutputLevel", mylevel));
111  ANA_CHECK(electronMediumIsEMSelector.initialize());
112 
113  asg::StandaloneToolHandle<IAsgElectronLikelihoodTool> electronMediumLHSelector ("AsgElectronLikelihoodTool/electronMediumLHSelector");
114  ANA_CHECK(electronMediumLHSelector.setProperty("WorkingPoint", "MediumLHElectron"));
115  ANA_CHECK(electronMediumLHSelector.setProperty("OutputLevel", mylevel));
116  ANA_CHECK(electronMediumLHSelector.initialize());
117 
118  asg::StandaloneToolHandle<IAsgElectronLikelihoodTool> electronMediumDNNSelector ("AsgElectronSelectorTool/electronMediumDNNSelector");
119  ANA_CHECK(electronMediumDNNSelector.setProperty("WorkingPoint", "MediumDNNElectron"));
120  ANA_CHECK(electronMediumDNNSelector.setProperty("OutputLevel", mylevel));
121  ANA_CHECK(electronMediumDNNSelector.initialize());
122 
123  // Loop over the events:
124  for( Long64_t entry = 0; entry < entries; ++entry ) {
125 
126  // Tell the object which entry to look at:
127  pers.getEntry( entry );
128  ANA_MSG_INFO("============================");
129  ANA_MSG_INFO("Event: " <<entry);
130 
132  ANA_CHECK(pers.retrieve(electrons, "Electrons"));
133 
134  unsigned int counter=0;
135  for (const xAOD::Electron* el : *electrons) {
136  ANA_MSG_INFO("---------------------------");
137  ANA_MSG_INFO("Electron: " << counter);
138  ANA_MSG_INFO("Electron LH Medium accept result: " <<bool(electronMediumLHSelector->accept(el)));
139  ANA_MSG_INFO("Electron DNN Medium accept result: " <<bool(electronMediumDNNSelector->accept(el)));
140  ANA_MSG_INFO("Electron Cut Medium accept result: " <<bool(electronMediumIsEMSelector->accept(el)));
141 
142  //Bitset manipulation
143  ANA_MSG_INFO("Decision as a bitset: ");
144  std::bitset<32> decision = electronMediumIsEMSelector->accept(el).getCutResultBitSet();
145  ANA_MSG_INFO("Result bitset: " <<decision);
146  std::bitset<32> isEMdecision = electronMediumIsEMSelector->accept(el).getCutResultInvertedBitSet() ;
147  ANA_MSG_INFO("isEM Result bitset: " << isEMdecision);
148  //
149  ANA_MSG_INFO("Masks: " );
150  std::bitset<32> MediumMask(egammaPID::ElectronMediumPP);
151  ANA_MSG_INFO("Medium mask: " << MediumMask);
152 
153  std::bitset<32> HadLeakageOnlyMask( 0x1 << egammaPID::ClusterHadronicLeakage_Electron);
154  ANA_MSG_INFO("HadLeakageOnly mask: " << HadLeakageOnlyMask);
155  //
156  std::bitset<32> MediumWithouHadLeakageMask( egammaPID::ElectronMediumPP ^ (0x1 << egammaPID::ClusterHadronicLeakage_Electron));
157  ANA_MSG_INFO("Medium Without Had Leakage mask: " << MediumWithouHadLeakageMask);
158  //
159 
160  bool passALLDecisionisem= (isEMdecision&MediumMask)==0;
161  std::bitset<32> passALLDecisionisemBitSet(isEMdecision&MediumMask);
162  ANA_MSG_INFO("Electron check all cuts via isem: "<< passALLDecisionisem << " ,bitset " << passALLDecisionisemBitSet);
163 
164  bool checkOnlyHadLeakageisem= (isEMdecision&HadLeakageOnlyMask)==0;
165  std::bitset<32> checkOnlyHadLeakageisemBitSet(isEMdecision&HadLeakageOnlyMask);
166  ANA_MSG_INFO("Electron check Only Had Leakage via isem:: "<< checkOnlyHadLeakageisem << " ,bitset " << checkOnlyHadLeakageisemBitSet);
167 
168  bool ignoreHadLeakageisem= (isEMdecision&MediumWithouHadLeakageMask)==0;
169  std::bitset<32> ignoreHadLeakageisemBitSet(isEMdecision&MediumWithouHadLeakageMask);
170  ANA_MSG_INFO("Electron ignore Had Leakage check all else via isem:: "<< ignoreHadLeakageisem << " ,bitset " << ignoreHadLeakageisemBitSet);
171 
172  ++counter;
173 
174 
175  }
176  } // loop entries
177  }// is electron
178  else {
179  //Tight cut based photon
180 
181  asg::StandaloneToolHandle<IAsgPhotonIsEMSelector> photonTightIsEMSelector ("AsgPhotonIsEMSelector/photonTightIsEMSelector");
182  ANA_CHECK(photonTightIsEMSelector.setProperty("WorkingPoint", "MediumPhoton"));
183  ANA_CHECK(photonTightIsEMSelector.setProperty("OutputLevel", mylevel));
184  ANA_CHECK(photonTightIsEMSelector.initialize());
185  // Loop over the events:
186  for( Long64_t entry = 0; entry < entries; ++entry ) {
187 
188  // Tell the object which entry to look at:
189  pers.getEntry( entry );
190  ANA_MSG_INFO("============================");
191  ANA_MSG_INFO("Event: " <<entry);
192 
193  const xAOD::PhotonContainer* photons;
194  ANA_CHECK(pers.retrieve(photons, "Photons"));
195  unsigned int counter=0;
196  for (const xAOD::Photon* ph : *photons) {
197  ANA_MSG_INFO("---------------------------");
198  ANA_MSG_INFO("Photon: " << counter);
199  ANA_MSG_INFO("Photon Tight accept result: " <<bool(photonTightIsEMSelector->accept(ph)));
200  ++counter;
201  }
202  }// loop entries
203  }
204 
206  return 0;
207 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
xAOD::IOStats::stats
ReadStats & stats()
Access the object belonging to the current thread.
Definition: IOStats.cxx:17
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
egammaPID::ClusterHadronicLeakage_Electron
@ ClusterHadronicLeakage_Electron
cluster leakage into the hadronic calorimeter
Definition: egammaPIDdefs.h:100
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
asg::StandaloneToolHandle
an "initializing" ToolHandle for stand-alone applications
Definition: StandaloneToolHandle.h:44
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
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
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
xAOD::Photon_v1
Definition: Photon_v1.h:37
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
egammaPID::ElectronMediumPP
const unsigned int ElectronMediumPP
Medium++ electron selecton.
Definition: egammaPIDdefs.h:320
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
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