ATLAS Offline Software
TransverseMassSelectorAlg.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 
11  TransverseMassSelectorAlg::TransverseMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
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  for (const auto &sys : m_systematicsList.systematicsVector()) {
34  // retrieve the EventInfo
35  const xAOD::EventInfo *evtInfo = nullptr;
36  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
37 
38  // default-decorate EventInfo
39  m_decoration.setBool(*evtInfo, 0, sys);
40 
41  // check the preselection
42  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
43  continue;
44 
45  // retrieve the MET container
46  const xAOD::MissingETContainer *met = nullptr;
47  ANA_CHECK(m_metHandle.retrieve(met, sys));
48  // retrieve the electron container
49  const xAOD::IParticleContainer *electrons = nullptr;
52  // retrieve the electron container
53  const xAOD::IParticleContainer *muons = nullptr;
54  if (m_muonsHandle)
55  ANA_CHECK(m_muonsHandle.retrieve(muons, sys));
56 
57  // apply the requested selection, compute the W boson transverse mass
58  float etmiss_pt = (*met)[m_metTerm.value()]->met();
59  float etmiss_phi = (*met)[m_metTerm.value()]->phi();
60  float lep_pt, lep_phi;
61  int lep_count = 0;
62 
63  if (m_electronsHandle) {
64  for (const xAOD::IParticle *el : *electrons) {
66  lep_pt = el->pt();
67  lep_phi = el->phi();
68  lep_count++;
69  break;
70  }
71  }
72  }
73  if (m_muonsHandle) {
74  for (const xAOD::IParticle *mu : *muons) {
76  lep_pt = mu->pt();
77  lep_phi = mu->phi();
78  lep_count++;
79  break;
80  }
81  }
82  }
83 
84  // exit 1 if there were no leptons or 2 or more leptons in the event
85  if (lep_count == 0){
86  ATH_MSG_ERROR("No charged lepton in the event, cannot compute MWT!");
87  return StatusCode::FAILURE;
88  }
89  if (lep_count > 1){
90  ATH_MSG_ERROR("More than one lepton is associated with this event - cannot determine which is the W decay lepton.");
91  return StatusCode::FAILURE;
92  }
93 
94  float mwt = sqrt(2. * lep_pt * etmiss_pt * (1. - std::cos(lep_phi - etmiss_phi)));
95 
96  // calculate decision
97  bool decision = SignEnum::checkValue(m_mwtref.value(), m_signEnum, mwt);
98  m_decoration.setBool(*evtInfo, decision, sys);
99  }
100  return StatusCode::SUCCESS;
101  }
102 } // namespace CP
CP::TransverseMassSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muons handle
Definition: TransverseMassSelectorAlg.h:64
CP::TransverseMassSelectorAlg::m_metHandle
CP::SysReadHandle< xAOD::MissingETContainer > m_metHandle
the MET handle
Definition: TransverseMassSelectorAlg.h:74
CP::TransverseMassSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition: TransverseMassSelectorAlg.h:48
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
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::TransverseMassSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: TransverseMassSelectorAlg.h:87
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::TransverseMassSelectorAlg::initialize
virtual StatusCode initialize() override
Definition: TransverseMassSelectorAlg.cxx:15
CP::SysWriteSelectionHandle::setBool
void setBool(const SG::AuxElement &element, bool selection, const CP::SystematicSet &sys) const
set the selection decoration
CP::TransverseMassSelectorAlg::m_metTerm
Gaudi::Property< std::string > m_metTerm
the MET term
Definition: TransverseMassSelectorAlg.h:79
met
Definition: IMETSignificance.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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::TransverseMassSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
the systematics
Definition: TransverseMassSelectorAlg.h:51
CP::TransverseMassSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition: TransverseMassSelectorAlg.h:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::TransverseMassSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
the electron selection
Definition: TransverseMassSelectorAlg.h:59
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
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
CP::TransverseMassSelectorAlg::m_sign
Gaudi::Property< std::string > m_sign
the comparison (GT, LT, etc)
Definition: TransverseMassSelectorAlg.h:45
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::TransverseMassSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: TransverseMassSelectorAlg.h:82
CP::TransverseMassSelectorAlg::TransverseMassSelectorAlg
TransverseMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: TransverseMassSelectorAlg.cxx:11
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CP::TransverseMassSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
the muon selection
Definition: TransverseMassSelectorAlg.h:69
TransverseMassSelectorAlg.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::TransverseMassSelectorAlg::m_mwtref
Gaudi::Property< float > m_mwtref
the MWT cut against which to compare
Definition: TransverseMassSelectorAlg.h:42
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::TransverseMassSelectorAlg::execute
virtual StatusCode execute() override
Definition: TransverseMassSelectorAlg.cxx:32
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::TransverseMassSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electron handle
Definition: TransverseMassSelectorAlg.h:54
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
CP::SysWriteSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysWriteSelectionHandle.cxx:34