ATLAS Offline Software
MissingETPlusTransverseMassSelectorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 namespace CP {
10 
12  : EL::AnaAlgorithm(name, pSvcLocator)
13  {}
14 
22 
26 
27  m_signEnum = SignEnum::stringToOperator.at( m_sign );
28 
29  return StatusCode::SUCCESS;
30  }
31 
33  // accessors
34  static const SG::AuxElement::ConstAccessor<float> acc_pt_dressed("pt_dressed");
35  static const SG::AuxElement::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;
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 
71  if (m_electronsHandle) {
72  for (const xAOD::IParticle *el : *electrons) {
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) {
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
CP::MissingETPlusTransverseMassSelectorAlg::m_sumref
Gaudi::Property< float > m_sumref
the MET+MWT threshold against which to compare
Definition: MissingETPlusTransverseMassSelectorAlg.h:42
CP::MissingETPlusTransverseMassSelectorAlg::execute
virtual StatusCode execute() override
Definition: MissingETPlusTransverseMassSelectorAlg.cxx:32
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
CP::MissingETPlusTransverseMassSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electron input handle
Definition: MissingETPlusTransverseMassSelectorAlg.h:59
MissingETPlusTransverseMassSelectorAlg.h
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SysWriteSelectionHandle::setBool
void setBool(const SG::AuxElement &element, bool selection, const CP::SystematicSet &sys) const
set the selection decoration
CP::MissingETPlusTransverseMassSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition: MissingETPlusTransverseMassSelectorAlg.h:48
CP::MissingETPlusTransverseMassSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: MissingETPlusTransverseMassSelectorAlg.h:92
met
Definition: IMETSignificance.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
CP::MissingETPlusTransverseMassSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: MissingETPlusTransverseMassSelectorAlg.h:87
CP::MissingETPlusTransverseMassSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
the systematics
Definition: MissingETPlusTransverseMassSelectorAlg.h:56
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::MissingETPlusTransverseMassSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition: MissingETPlusTransverseMassSelectorAlg.h:97
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
CP::MissingETPlusTransverseMassSelectorAlg::m_metTerm
Gaudi::Property< std::string > m_metTerm
the MET term
Definition: MissingETPlusTransverseMassSelectorAlg.h:84
SignEnum::checkValue
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition: SignEnums.h:35
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::MissingETPlusTransverseMassSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
the muon selection
Definition: MissingETPlusTransverseMassSelectorAlg.h:74
CP::MissingETPlusTransverseMassSelectorAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
Definition: MissingETPlusTransverseMassSelectorAlg.h:51
CP::MissingETPlusTransverseMassSelectorAlg::MissingETPlusTransverseMassSelectorAlg
MissingETPlusTransverseMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: MissingETPlusTransverseMassSelectorAlg.cxx:11
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::MissingETPlusTransverseMassSelectorAlg::m_sign
Gaudi::Property< std::string > m_sign
the comparison (GT, LT, etc)
Definition: MissingETPlusTransverseMassSelectorAlg.h:45
CP::MissingETPlusTransverseMassSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muon input handle
Definition: MissingETPlusTransverseMassSelectorAlg.h:69
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::MissingETPlusTransverseMassSelectorAlg::m_metHandle
CP::SysReadHandle< xAOD::MissingETContainer > m_metHandle
the MET handle
Definition: MissingETPlusTransverseMassSelectorAlg.h:79
CP::MissingETPlusTransverseMassSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
the electrons selection
Definition: MissingETPlusTransverseMassSelectorAlg.h:64
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
CP::MissingETPlusTransverseMassSelectorAlg::initialize
virtual StatusCode initialize() override
Definition: MissingETPlusTransverseMassSelectorAlg.cxx:15
CP::SysWriteSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysWriteSelectionHandle.cxx:34