ATLAS Offline Software
Loading...
Searching...
No Matches
DileptonInvariantMassSelectorAlg.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
8#include "Math/Vector4D.h"
9
10using ROOT::Math::PtEtaPhiEVector;
11
12namespace CP {
13
15 : EL::AnaAlgorithm(name, pSvcLocator)
16 {}
17
33
35 // accessors
36 static const SG::ConstAccessor<float> acc_pt_dressed("pt_dressed");
37 static const SG::ConstAccessor<float> acc_eta_dressed("eta_dressed");
38 static const SG::ConstAccessor<float> acc_phi_dressed("phi_dressed");
39 static const SG::ConstAccessor<float> acc_e_dressed("e_dressed");
40
41 for (const auto &sys : m_systematicsList.systematicsVector()) {
42 // retrieve the EventInfo
43 const xAOD::EventInfo *evtInfo = nullptr;
44 ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
45
46 // default-decorate EventInfo
47 m_decoration.setBool(*evtInfo, 0, sys);
48
49 // check the preselection
50 if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
51 continue;
52
53 // retrieve the electron container
54 const xAOD::IParticleContainer *electrons = nullptr;
56 ANA_CHECK(m_electronsHandle.retrieve(electrons, sys));
57 // retrieve the electron container
58 const xAOD::IParticleContainer *muons = nullptr;
59 if (m_muonsHandle)
60 ANA_CHECK(m_muonsHandle.retrieve(muons, sys));
61
62 // apply the requested selection
63 PtEtaPhiEVector lepton0, lepton1;
64 int total_leptons = 0;
65 bool isfilled0(false), isfilled1(false);
67 for (const xAOD::IParticle *el : *electrons) {
68 if (!m_electronSelection || m_electronSelection.getBool(*el, sys)) {
69 total_leptons++;
70 if (!isfilled0){
72 lepton0.SetCoordinates(acc_pt_dressed(*el),
73 acc_eta_dressed(*el),
74 acc_phi_dressed(*el),
75 acc_e_dressed(*el));
76 else
77 lepton0.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
78 isfilled0 = true;
79 } else if (!isfilled1){
81 lepton1.SetCoordinates(acc_pt_dressed(*el),
82 acc_eta_dressed(*el),
83 acc_phi_dressed(*el),
84 acc_e_dressed(*el));
85 else
86 lepton1.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
87 isfilled1 = true;
88 } else {
89 break;
90 }
91 }
92 }
93 }
94 if (m_muonsHandle) {
95 for (const xAOD::IParticle *mu : *muons) {
96 if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) {
97 total_leptons++;
98 if (!isfilled0){
100 lepton0.SetCoordinates(acc_pt_dressed(*mu),
101 acc_eta_dressed(*mu),
102 acc_phi_dressed(*mu),
103 acc_e_dressed(*mu));
104 else
105 lepton0.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
106 isfilled0 = true;
107 } else if (!isfilled1){
109 lepton1.SetCoordinates(acc_pt_dressed(*mu),
110 acc_eta_dressed(*mu),
111 acc_phi_dressed(*mu),
112 acc_e_dressed(*mu));
113 else
114 lepton1.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
115 isfilled1 = true;
116 } else {
117 break;
118 }
119 }
120 }
121 }
122
123 if (total_leptons != 2){
124 ATH_MSG_ERROR("Exactly two leptons are required to compute the MLL!");
125 return StatusCode::FAILURE;
126 }
127
128 // compute MLL
129 float mll = (lepton0 + lepton1).M();
130
131 // calculate decision
132 bool decision = SignEnum::checkValue(m_mllref.value(), m_signEnum, mll);
133 m_decoration.setBool(*evtInfo, decision, sys);
134 }
135 return StatusCode::SUCCESS;
136 }
137} // namespace CP
#define ATH_MSG_ERROR(x)
#define ANA_CHECK(EXP)
check whether the given expression was successful
CP::SysReadSelectionHandle m_electronSelection
the electrons selection
CP::SysReadSelectionHandle m_preselection
the preselection
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
CP::SysReadSelectionHandle m_muonSelection
the muons selection
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muons handle
Gaudi::Property< std::string > m_sign
the comparison (GT, LT, etc)
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electrons handle
DileptonInvariantMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Gaudi::Property< float > m_mllref
the 2-lepton mass against which to compare
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Helper class to provide constant type-safe access to aux data.
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition SignEnums.h:37
static const std::map< std::string, ComparisonOperator > stringToOperator
the map between user inputs and comparison operators
Definition SignEnums.h:27
EventInfo_v1 EventInfo
Definition of the latest event info version.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.