ATLAS Offline Software
Loading...
Searching...
No Matches
MissingETPlusTransverseMassSelectorAlg.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
9namespace CP {
10
12 : EL::AnaAlgorithm(name, pSvcLocator)
13 {}
14
31
33 // accessors
34 static const SG::ConstAccessor<float> acc_pt_dressed("pt_dressed");
35 static const SG::ConstAccessor<float> acc_phi_dressed("phi_dressed");
36
37 for (const auto &sys : m_systematicsList.systematicsVector()) {
38 // retrieve the EventInfo
39 const xAOD::EventInfo *evtInfo = nullptr;
40 ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
41
42 // default-decorate EventInfo
43 m_decoration.setBool(*evtInfo, 0, sys);
44
45 // check the preselection
46 if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
47 continue;
48
49 // retrieve the MET container
50 const xAOD::MissingETContainer *met = nullptr;
51 ANA_CHECK(m_metHandle.retrieve(met, sys));
52 // retrieve the electron container
53 const xAOD::IParticleContainer *electrons = nullptr;
55 ANA_CHECK(m_electronsHandle.retrieve(electrons, sys));
56 // retrieve the electron container
57 const xAOD::IParticleContainer *muons = nullptr;
58 if (m_muonsHandle)
59 ANA_CHECK(m_muonsHandle.retrieve(muons, sys));
60
61 // compute the W boson transverse mass
62 if ((*met)[m_metTerm.value()] == nullptr) {
63 ANA_MSG_ERROR("The MET term " << m_metTerm.value() << " doesn't exist! Aborting.");
64 return StatusCode::FAILURE;
65 }
66 float etmiss_pt = (*met)[m_metTerm.value()]->met();
67 float etmiss_phi = (*met)[m_metTerm.value()]->phi();
68 float lep_pt, lep_phi;
69 int lep_count = 0;
70
72 for (const xAOD::IParticle *el : *electrons) {
73 if (!m_electronSelection || m_electronSelection.getBool(*el, sys)){
75 lep_pt = acc_pt_dressed(*el);
76 lep_phi = acc_phi_dressed(*el);
77 } else {
78 lep_pt = el->pt();
79 lep_phi = el->phi();
80 }
81 lep_count++;
82 break;
83 }
84 }
85 }
86 if (m_muonsHandle) {
87 for (const xAOD::IParticle *mu : *muons) {
88 if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) {
90 lep_pt = acc_pt_dressed(*mu);
91 lep_phi = acc_phi_dressed(*mu);
92 } else {
93 lep_pt = mu->pt();
94 lep_phi = mu->phi();
95 }
96 lep_count++;
97 break;
98 }
99 }
100 }
101
102 if (lep_count == 0){
103 ATH_MSG_ERROR("No charged lepton in the event, cannot compute MWT!");
104 return StatusCode::FAILURE;
105 }
106
107 if (lep_count > 1){
108 ATH_MSG_ERROR("More than one lepton is associated with this event - cannot determine which is the W decay lepton.");
109 return StatusCode::FAILURE;
110 }
111
112 float mwt = sqrt(2. * lep_pt * etmiss_pt * (1. - std::cos(lep_phi - etmiss_phi)));
113
114 // compute the sum
115 float sum = etmiss_pt + mwt;
116
117 // calculate decision
118 bool decision = SignEnum::checkValue(m_sumref.value(), m_signEnum, sum);
119 m_decoration.setBool(*evtInfo, decision, sys);
120 }
121 return StatusCode::SUCCESS;
122 }
123} // namespace CP
#define ATH_MSG_ERROR(x)
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
MissingETPlusTransverseMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
CP::SysReadSelectionHandle m_muonSelection
the muon selection
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muon input handle
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
CP::SysReadHandle< xAOD::MissingETContainer > m_metHandle
the MET handle
Gaudi::Property< std::string > m_sign
the comparison (GT, LT, etc)
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
CP::SysReadSelectionHandle m_electronSelection
the electrons selection
CP::SysReadSelectionHandle m_preselection
the preselection
Gaudi::Property< float > m_sumref
the MET+MWT threshold against which to compare
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electron input handle
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.