Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EgammaFSRForMuonsCollectorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // EgammaFSRForMuonsCollectorAlg
7 //
8 // Algorithm to collect photons and electrons which close in dR
9 // to muons as FSR candidates
11 
14 #include <xAODEgamma/Electron.h>
15 
17 
19 
20 namespace CP
21 {
22  EgammaFSRForMuonsCollectorAlg::EgammaFSRForMuonsCollectorAlg(const std::string &name, ISvcLocator *svcLoc)
23  : EL::AnaAlgorithm(name, svcLoc)
24  {
25  }
26 
28  {
29  // Greet the user:
30  ATH_MSG_INFO("Initialising");
31 
32  // WP ID selection
33  if (m_selectionName.empty()) {
34  ATH_MSG_ERROR("Empty string passed as WP selection flag!");
35  return StatusCode::FAILURE;
36  }
37 
41  m_wpDec = std::make_unique<SG::AuxElement::Decorator<char> > (m_selectionName.value());
42 
43  if (!m_vetoFSR) {
44  ATH_MSG_INFO("Reading container " << m_egammaContKey.getNamePattern() << " for FSR search for muons from " << m_muonContKey.getNamePattern() << ". Those passing " << m_selectionName.value() << " are also accepted.");
45  }
46  else {
47  ATH_MSG_INFO("Reading container " << m_egammaContKey.getNamePattern() << " for FSR search for muons from " << m_muonContKey.getNamePattern() << ". The electrons or photons matching FSR requirements with muons will be vetoed with " << m_selectionName.value());
48 
49  }
50 
51  // Return gracefully:
52  return StatusCode::SUCCESS;
53  }
54 
55 
57  {
58 
59  auto selDec = std::make_unique<SG::AuxElement::Decorator<uint32_t> > ("selectEta");
60  auto oqDec = std::make_unique<SG::AuxElement::Decorator<uint32_t> > ("goodOQ");
61  auto cleanDec = std::make_unique<SG::AuxElement::Decorator<uint32_t> > ("isClean");
62 
63  // Loop over systematics
64  for (const auto& sys : m_systematicsList.systematicsVector()) {
65 
66 
67  // Retrieve electrons or photons
68  const xAOD::IParticleContainer* egammaCont = nullptr;
69  ANA_CHECK (m_egammaContKey.retrieve (egammaCont, sys));
70 
71  // Retrieve muons
72  const xAOD::MuonContainer* muonCont = nullptr;
73  ANA_CHECK (m_muonContKey.retrieve (muonCont, sys));
74 
75  // Loop over each electron or photon. If already passing WP selection, decorate passWPorFSR as true
76  // If m_vetoFSR is set, then reverse logic is used - require electron or photon to pass WP selection,
77  // and then veto is if if passes the FSR selection
78  for ( auto eg : *egammaCont ) {
79  if (!m_vetoFSR) {
80  // Standard logic - If passes std WP, accept
81  if ((*m_wpDec)(*eg) == 1) {
82  ATH_MSG_DEBUG("Eg passed WP - pt, eta: " << eg->type() << ", " << eg->pt()/1000. << ", " << eg->eta() << ", " << (*m_wpDec)(*eg) );
83  continue; // ok, skip to next el/ph
84  }
85  else ATH_MSG_DEBUG("Eg failed WP: " << m_selectionName.value() << ", " << (*m_wpDec)(*eg) );
86  }
87  else {
88  // Inverted logic - If passes std WP, continue with the FSR search
89  if ((*m_wpDec)(*eg) == 1) {
90  ATH_MSG_DEBUG("Veto FSR: Eg passed WP - pt, eta: " << eg->type() << ", " << eg->pt()/1000. << ", " << eg->eta() << ", " << (*m_wpDec)(*eg) );
91 
92  }
93  else {
94  ATH_MSG_DEBUG("Veto FSR: Eg failed WP: " << m_selectionName.value() << ", " << (*m_wpDec)(*eg) << " skipping." );
95  continue; // ok, skip to next el/ph
96  }
97  }
98 
99  const xAOD::Electron* el = (eg->type() == xAODType::Electron) ? dynamic_cast<const xAOD::Electron*>(eg) : 0;
100 
101  ATH_MSG_DEBUG( "Incoming eg: pt, eta, phi " << eg->pt()/1000. << ", " << eg->eta() << ", " << eg->phi() << ", is electron " << (el != 0));
102 
103  // Loop over muons and check dR
104  for ( auto mu : *muonCont ) {
105 
106  float dR = xAOD::P4Helpers::deltaR(*eg, *mu);
107 
108  ATH_MSG_DEBUG( "dR with mu: pt, eta, phi " << dR << ", " << mu->pt()/1000. << ", " << mu->eta() << ", " << mu->phi() );
109 
110  if (dR < m_dRMax) {
111 
112  // if electron (not photon) check track matching
113  bool elmutrackmatchOK = true; // default true for photons
114  if (el) {
115  const xAOD::TrackParticle* electron_track = el->trackParticle();
117  const xAOD::TrackParticle* muon_track = mu->primaryTrackParticle();
118 
119  elmutrackmatchOK =
120  ( (std::abs(electron_track->theta()- muon_track->theta()) < 0.01) &&
121  (xAOD::P4Helpers::deltaPhi(electron_track->phi(), muon_track->phi()) < 0.01) );
122  ATH_MSG_DEBUG( "dtheta trk " << std::abs(electron_track->theta()- muon_track->theta()) << ", dphi trk "
123  << xAOD::P4Helpers::deltaPhi(electron_track->phi(), muon_track->phi()));
124  if (elOrig_track) ATH_MSG_DEBUG( "origTrk: dtheta trk " << std::abs(elOrig_track->theta()- muon_track->theta()) << ", dphi trk "
125  << xAOD::P4Helpers::deltaPhi(elOrig_track->phi(), muon_track->phi()));
126  if (elmutrackmatchOK) ATH_MSG_DEBUG( "track match OK");
127  else ATH_MSG_DEBUG( "track match NOT OK");
128  }
129  if (elmutrackmatchOK) {
130  (*m_wpDec)(*eg) = (m_vetoFSR) ? 0 : 1;
131  ATH_MSG_DEBUG( "dR OK - wp " << (*m_wpDec)(*eg) );
132 
133  if (selDec->isAvailable(*eg)) ATH_MSG_DEBUG( "selectEta: " << (*selDec)(*eg) );
134  if (oqDec->isAvailable(*eg)) ATH_MSG_DEBUG( "goodOQ: " << (*oqDec)(*eg) );
135  if (cleanDec->isAvailable(*eg)) ATH_MSG_DEBUG( "isClean: " << (*cleanDec)(*eg) );
136 
137  break;
138  }
139  }
140  ATH_MSG_DEBUG( "dR not OK");
141  }
142  }
143  }
144 
145  ATH_MSG_DEBUG("Done !");
146 
147  return StatusCode::SUCCESS;
148  }
149 
150 }
CP::EgammaFSRForMuonsCollectorAlg::EgammaFSRForMuonsCollectorAlg
EgammaFSRForMuonsCollectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: EgammaFSRForMuonsCollectorAlg.cxx:22
CP::EgammaFSRForMuonsCollectorAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: EgammaFSRForMuonsCollectorAlg.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleTest.eg
eg
Definition: ParticleTest.py:29
CP::EgammaFSRForMuonsCollectorAlg::m_wpDec
std::unique_ptr< SG::AuxElement::Decorator< char > > m_wpDec
Decorator for electron or photon working point - used to add additional el/ph.
Definition: EgammaFSRForMuonsCollectorAlg.h:55
xAODP4Helpers.h
CP::EgammaFSRForMuonsCollectorAlg::m_vetoFSR
Gaudi::Property< bool > m_vetoFSR
Definition: EgammaFSRForMuonsCollectorAlg.h:52
CP::EgammaFSRForMuonsCollectorAlg::m_dRMax
Gaudi::Property< float > m_dRMax
Protected data:
Definition: EgammaFSRForMuonsCollectorAlg.h:39
ElectronxAODHelpers.h
xAOD::P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: xAODP4Helpers.h:69
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::EgammaFSRForMuonsCollectorAlg::initialize
StatusCode initialize() override
Definition: EgammaFSRForMuonsCollectorAlg.cxx:27
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::EgammaFSRForMuonsCollectorAlg::m_egammaContKey
SysReadHandle< xAOD::IParticleContainer > m_egammaContKey
Definition: EgammaFSRForMuonsCollectorAlg.h:46
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
CP::EgammaFSRForMuonsCollectorAlg::m_muonContKey
SysReadHandle< xAOD::MuonContainer > m_muonContKey
Definition: EgammaFSRForMuonsCollectorAlg.h:48
CP::EgammaFSRForMuonsCollectorAlg::m_selectionName
Gaudi::Property< std::string > m_selectionName
Definition: EgammaFSRForMuonsCollectorAlg.h:50
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAODType::Electron
@ Electron
The object is an electron.
Definition: ObjectType.h:46
xAOD::Electron_v1
Definition: Electron_v1.h:34
EgammaFSRForMuonsCollectorAlg.h
CP::EgammaFSRForMuonsCollectorAlg::execute
StatusCode execute() override
Definition: EgammaFSRForMuonsCollectorAlg.cxx:56
xAOD::EgammaHelpers::getOriginalTrackParticle
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
Definition: ElectronxAODHelpers.cxx:11
CP::SysReadHandle::getNamePattern
virtual std::string getNamePattern() const override
get the name pattern before substitution
Electron.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
xAOD::TrackParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
SelectionHelpers.h