ATLAS Offline Software
PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Photon.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 // Include what you use!
8 #include <map>
9 #include <string>
10 
11 #include "TopEvent/EventTools.h"
12 
14 using namespace TopObjectSelectionTools;
15 
16 namespace top {
17  Photon::Photon(double ptcut, double etamax, IsolationBase* isolation) :
18  m_ptcut(ptcut),
19  m_etamax(etamax),
20  m_photon_selection("DFCommonPhotonsIsEMTight"),
21  m_loose_photon_selection("DFCommonPhotonsIsEMLoose"),
22  m_isolation(isolation) {
23  }
24 
25  Photon::Photon(double ptcut, double etamax,
26  const std::string& tightID,
27  const std::string& looseID,
28  IsolationBase* isolation) :
29  m_ptcut(ptcut),
30  m_etamax(etamax),
31  m_photon_selection(tightID),
32  m_loose_photon_selection(looseID),
33  m_isolation(isolation) {
34  // Make a map of shortcuts e.g "Tight = DFCommonPhotonsIsEMTight"
35  std::map<std::string, std::string> id_map;
36  id_map["Tight"] = "DFCommonPhotonsIsEMTight";
37  id_map["Loose"] = "DFCommonPhotonsIsEMLoose";
38  id_map["None"] = "None";
39  // If ID in map then set it to full name, else keep as is.
40  if (id_map.find(tightID) != id_map.end()) m_photon_selection = id_map[tightID];
41  if (id_map.find(looseID) != id_map.end()) m_loose_photon_selection = id_map[looseID];
42 
43  m_deadHVTool.setTypeAndName("AsgDeadHVCellRemovalTool/deadHVTool");
44  top::check(m_deadHVTool.retrieve(), "Failed to setup Egamma DeadHVCellRemovalTool");
45  }
46 
47  bool Photon::passSelection(const xAOD::Photon& ph) const {
48  if (!passSelectionNoIsolation(ph, m_photon_selection)) return false;
49 
50  if (m_isolation && !m_isolation->passSelection(ph)) return false;
51 
52  return true;
53  }
54 
55  bool Photon::passSelectionLoose(const xAOD::Photon& ph) const {
56  if (!passSelectionNoIsolation(ph, m_loose_photon_selection)) return false;
57 
58  if (m_isolation && !m_isolation->passSelectionLoose(ph)) return false;
59 
60  return true;
61  }
62 
64  const std::string& photon_selection) const {
65  // Photon author : AuthorPhoton/AuthorAmbiguous.
66  // Also, for special-case recovery of soft photons:
67  // xAOD::EgammaParameters::AuthorCaloTopo35.
69  && ph.author() != xAOD::EgammaParameters::AuthorAmbiguous) return false;
70 
71  if (ph.pt() < m_ptcut) return false;
72 
73  // removing bad photon cluser [http://cern.ch/go/kp8F]
74  if (!ph.isGoodOQ(xAOD::EgammaParameters::BADCLUSPHOTON)) return false;
75 
76  // Photon selection using derivation decorations
77  if (photon_selection != "None")
78  if (!ph.auxdataConst<char>(photon_selection)) return false;
79 
80  if (!ph.caloCluster()) return false;
81 
82  float abs_eta = std::abs(ph.caloCluster()->etaBE(2));
83  if (abs_eta > m_etamax) return false;
84 
85  // Remove crack region
86  if (abs_eta > 1.37 && abs_eta < 1.52) return false;
87 
88  // Photon cleaning
89  static const SG::AuxElement::ConstAccessor<char> accDFCommonPhotonsCleaning("DFCommonPhotonsCleaning");
90  static const SG::AuxElement::ConstAccessor<char> accDFCommonPhotonsCleaningNoTime("DFCommonPhotonsCleaningNoTime");
91 
92  if (!accDFCommonPhotonsCleaning(ph)) return false;
93  if (!accDFCommonPhotonsCleaningNoTime(ph)) return false;
94 
95  // removing photon cluster in EMEC bad HV regions
96  // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/EGammaIdentificationRun2#Removal_of_Electron_Photon_clust
97  if (!m_deadHVTool->accept(ph)) return false;
98 
99 
100  return true;
101  }
102 
103  void Photon::print(std::ostream& os) const {
104  os << "Photon\n";
105  os << " * pT > " << m_ptcut << "\n";
106  os << " * |eta| < " << m_etamax << "\n";
107  os << " * Photon PID: " << m_photon_selection << "\n";
108  os << " * Loose Photon PID: " << m_loose_photon_selection << "\n";
109  if (!m_isolation) os << " * No isolation requirement\n";
110  else m_isolation->print(os);
111  }
112 } // namespace top
top::Photon::m_isolation
std::unique_ptr< top::IsolationBase > m_isolation
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Photon.h:103
top::Photon::m_etamax
double m_etamax
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Photon.h:92
top::Photon::m_photon_selection
std::string m_photon_selection
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Photon.h:94
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
IAsgDeadHVCellRemovalTool::accept
virtual bool accept(const xAOD::Egamma *part) const =0
top::Photon::print
void print(std::ostream &) const override
Print some useful information about the photon selection.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Photon.cxx:103
asg::AnaToolHandle::retrieve
StatusCode retrieve()
initialize the tool
asg::AnaToolHandle::setTypeAndName
void setTypeAndName(const std::string &val_typeAndName)
set the value of type and name
xAOD::Egamma_v1::author
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
Definition: Egamma_v1.cxx:166
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
Pythia8_A14_NNPDF23LO_forMGHT_EvtGen.ptcut
float ptcut
Definition: Pythia8_A14_NNPDF23LO_forMGHT_EvtGen.py:9
MsgCategory.h
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
SG::AuxElement::auxdataConst
Accessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name) const
Fetch an aux data variable, as a const reference.
xAOD::CaloCluster_v1::etaBE
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
Definition: CaloCluster_v1.cxx:644
xAOD::EgammaParameters::AuthorAmbiguous
const uint16_t AuthorAmbiguous
Object Reconstructed by standard cluster-based algorithm.
Definition: EgammaDefs.h:32
xAOD::Egamma_v1::caloCluster
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Definition: Egamma_v1.cxx:388
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
top::Photon::passSelectionLoose
bool passSelectionLoose(const xAOD::Photon &ph) const override
The loose selection.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Photon.cxx:55
top::Photon::m_deadHVTool
asg::AnaToolHandle< IAsgDeadHVCellRemovalTool > m_deadHVTool
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Photon.h:107
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
xAOD::EgammaParameters::BADCLUSPHOTON
const uint32_t BADCLUSPHOTON
Definition: EgammaDefs.h:124
top::Photon::m_ptcut
double m_ptcut
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Photon.h:89
top::Photon::passSelectionNoIsolation
bool passSelectionNoIsolation(const xAOD::Photon &ph, const std::string &photon_selection) const
Do all the cuts except for the isolation.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Photon.cxx:63
xAOD::Photon_v1
Definition: Photon_v1.h:37
top::IsolationBase
A common base for implementing isolation cuts.
Definition: IsolationTools.h:16
Photon.h
xAOD::EgammaParameters::AuthorPhoton
const uint16_t AuthorPhoton
Object Reconstructed by standard cluster-based algorithm.
Definition: EgammaDefs.h:28
xAOD::Egamma_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: Egamma_v1.cxx:65
top::Photon::Photon
Photon(double ptcut, double etamax, IsolationBase *isolation)
Class to help select good photons.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Photon.cxx:17
top::Photon::m_loose_photon_selection
std::string m_loose_photon_selection
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Photon.h:95
top::Photon::passSelection
bool passSelection(const xAOD::Photon &ph) const override
The cuts to select good photons for your analysis should be implemented in here.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Photon.cxx:47
xAOD::Egamma_v1::isGoodOQ
bool isGoodOQ(uint32_t mask) const
Check object quality. Return True is it is Good Object Quality.
Definition: Egamma_v1.cxx:236