ATLAS Offline Software
Loading...
Searching...
No Matches
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
20namespace CP
21{
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
40 ANA_CHECK (m_systematicsList.initialize());
41 m_wpDec = std::make_unique<SG::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::Decorator<uint32_t> > ("selectEta");
60 auto oqDec = std::make_unique<SG::Decorator<uint32_t> > ("goodOQ");
61 auto cleanDec = std::make_unique<SG::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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define ANA_CHECK(EXP)
check whether the given expression was successful
EgammaFSRForMuonsCollectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Gaudi::Property< std::string > m_selectionName
SysListHandle m_systematicsList
the systematics list we run
Gaudi::Property< float > m_dRMax
Protected data:
std::unique_ptr< SG::Decorator< char > > m_wpDec
Decorator for electron or photon working point - used to add additional el/ph.
SysReadHandle< xAOD::IParticleContainer > m_egammaContKey
SysReadHandle< xAOD::MuonContainer > m_muonContKey
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
float theta() const
Returns the parameter, which has range 0 to .
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
@ Electron
The object is an electron.
Definition ObjectType.h:46
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
TrackParticle_v1 TrackParticle
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Electron_v1 Electron
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.