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
36 ANA_CHECK(m_systematicsList.initialize());
37
38 if (!m_vetoFSR) {
39 ATH_MSG_INFO("Reading container " << m_egammaContKey.getNamePattern() << " for FSR search for muons from " << m_muonContKey.getNamePattern() << ". Those passing " << m_wpSelection.getSelectionName() << " are also accepted.");
40 }
41 else {
42 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_outputDec.getDecorName());
43 }
44
45 // Return gracefully:
46 return StatusCode::SUCCESS;
47 }
48
49
51 {
52 // Loop over systematics
53 for (const auto& sys : m_systematicsList.systematicsVector()) {
54
55 // Retrieve electrons or photons
56 const xAOD::IParticleContainer* egammaCont = nullptr;
57 ANA_CHECK(m_egammaContKey.retrieve(egammaCont, sys));
58
59 // Retrieve muons
60 const xAOD::MuonContainer* muonCont = nullptr;
61 ANA_CHECK(m_muonContKey.retrieve(muonCont, sys));
62
63 // Loop over each electron or photon and compute the combined selection
64 for (const xAOD::IParticle* eg : *egammaCont) {
65
66 // Read the WP selection (if configured)
67 bool passesWP = m_wpSelection.getBool(*eg, sys);
68
69 // Check if this particle passes FSR criteria (close to a muon)
70 bool passesFSR = false;
71
72 const xAOD::Electron* el = (eg->type() == xAOD::Type::Electron)
73 ? dynamic_cast<const xAOD::Electron*>(eg) : nullptr;
74
75 ATH_MSG_DEBUG("Incoming eg: pt, eta, phi " << eg->pt()/1000. << ", "
76 << eg->eta() << ", " << eg->phi() << ", is electron " << (el != nullptr)
77 << ", passesWP " << passesWP);
78
79 // Loop over muons and check dR
80 for (const xAOD::Muon* mu : *muonCont) {
81 float dR = xAOD::P4Helpers::deltaR(*eg, *mu);
82
83 ATH_MSG_DEBUG("dR with mu: " << dR << ", pt, eta, phi "
84 << mu->pt()/1000. << ", " << mu->eta() << ", " << mu->phi());
85
86 if (dR < m_dRMax) {
87 // if electron (not photon) check track matching
88 bool elmutrackmatchOK = true; // default true for photons
89 if (el) {
90 const xAOD::TrackParticle* electron_track = el->trackParticle();
92 const xAOD::TrackParticle* muon_track = mu->primaryTrackParticle();
93
94 if (electron_track && muon_track) {
95 elmutrackmatchOK =
96 (std::abs(electron_track->theta() - muon_track->theta()) < 0.01) &&
97 (xAOD::P4Helpers::deltaPhi(electron_track->phi(), muon_track->phi()) < 0.01);
98 ATH_MSG_DEBUG("dtheta trk " << std::abs(electron_track->theta() - muon_track->theta())
99 << ", dphi trk " << xAOD::P4Helpers::deltaPhi(electron_track->phi(), muon_track->phi()));
100 if (elOrig_track) {
101 ATH_MSG_DEBUG("origTrk: dtheta trk " << std::abs(elOrig_track->theta() - muon_track->theta())
102 << ", dphi trk " << xAOD::P4Helpers::deltaPhi(elOrig_track->phi(), muon_track->phi()));
103 }
104 } else {
105 elmutrackmatchOK = false;
106 }
107 ATH_MSG_DEBUG("track match " << (elmutrackmatchOK ? "OK" : "NOT OK"));
108 }
109
110 if (elmutrackmatchOK) {
111 passesFSR = true;
112 ATH_MSG_DEBUG("FSR match found");
113 break;
114 }
115 }
116 }
117
118 // Compute and write the output selection
119 char outputValue;
120 if (!m_vetoFSR) {
121 // Normal mode: output = WP || FSR
122 outputValue = (passesWP || passesFSR) ? 1 : 0;
123 } else {
124 // Veto mode: output = WP && !FSR
125 outputValue = (passesWP && !passesFSR) ? 1 : 0;
126 }
127
128 m_outputDec.set(*eg, outputValue, sys);
129 ATH_MSG_DEBUG("Output selection: " << static_cast<int>(outputValue)
130 << " (passesWP=" << passesWP << ", passesFSR=" << passesFSR << ")");
131 }
132 }
133
134 ATH_MSG_DEBUG("Done !");
135
136 return StatusCode::SUCCESS;
137 }
138
139}
#define ATH_CHECK
Evaluate an expression and check for errors.
#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
SysReadSelectionHandle m_wpSelection
the input WP selection to combine with FSR
SysWriteDecorHandle< char > m_outputDec
the output combined WP||FSR selection
SysListHandle m_systematicsList
the systematics list we run
Gaudi::Property< float > m_dRMax
Protected data:
SysReadHandle< xAOD::IParticleContainer > m_egammaContKey
SysReadHandle< xAOD::MuonContainer > m_muonContKey
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Class providing the definition of the 4-vector interface.
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:
Muon_v1 Muon
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.