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  // 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  // apply the requested selection, 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  // exit 1 if there were no leptons or 2 or more leptons in the event
103  if (lep_count == 0){
104  ATH_MSG_ERROR("No charged lepton in the event, cannot compute MWT!");
105  return StatusCode::FAILURE;
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  // calculate decision
115  bool decision = SignEnum::checkValue(m_mwtref.value(), m_signEnum, mwt);
116  m_decoration.setBool(*evtInfo, decision, sys);
117  }
118  return StatusCode::SUCCESS;
119  }
120 } // namespace CP
CP::TransverseMassSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muons handle
Definition: TransverseMassSelectorAlg.h:69
CP::TransverseMassSelectorAlg::m_metHandle
CP::SysReadHandle< xAOD::MissingETContainer > m_metHandle
the MET handle
Definition: TransverseMassSelectorAlg.h:79
CP::TransverseMassSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition: TransverseMassSelectorAlg.h:48
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::TransverseMassSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: TransverseMassSelectorAlg.h:92
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:84
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:56
CP::TransverseMassSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition: TransverseMassSelectorAlg.h:97
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:64
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:794
CP::TransverseMassSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: TransverseMassSelectorAlg.h:87
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:228
CP::TransverseMassSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
the muon selection
Definition: TransverseMassSelectorAlg.h:74
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:59
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
CP::TransverseMassSelectorAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
Definition: TransverseMassSelectorAlg.h:51
CP::SysWriteSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysWriteSelectionHandle.cxx:34