ATLAS Offline Software
DileptonInvariantMassSelectorAlg.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 #include "Math/Vector4D.h"
9 
10 using ROOT::Math::PtEtaPhiEVector;
11 
12 namespace CP {
13 
14  DileptonInvariantMassSelectorAlg::DileptonInvariantMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
15  : EL::AnaAlgorithm(name, pSvcLocator)
16  {}
17 
24 
28 
29  m_signEnum = SignEnum::stringToOperator.at( m_sign );
30 
31  return StatusCode::SUCCESS;
32  }
33 
35  // accessors
36  static const SG::AuxElement::ConstAccessor<float> acc_pt_dressed("pt_dressed");
37  static const SG::AuxElement::ConstAccessor<float> acc_eta_dressed("eta_dressed");
38  static const SG::AuxElement::ConstAccessor<float> acc_phi_dressed("phi_dressed");
39  static const SG::AuxElement::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;
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);
66  if (m_electronsHandle) {
67  for (const xAOD::IParticle *el : *electrons) {
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) {
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
DileptonInvariantMassSelectorAlg.h
CP::DileptonInvariantMassSelectorAlg::execute
virtual StatusCode execute() override
Definition: DileptonInvariantMassSelectorAlg.cxx:34
CP::DileptonInvariantMassSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition: DileptonInvariantMassSelectorAlg.h:88
CP::DileptonInvariantMassSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: DileptonInvariantMassSelectorAlg.h:83
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
CP::DileptonInvariantMassSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition: DileptonInvariantMassSelectorAlg.h:52
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::DileptonInvariantMassSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electrons handle
Definition: DileptonInvariantMassSelectorAlg.h:58
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
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::DileptonInvariantMassSelectorAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
Definition: DileptonInvariantMassSelectorAlg.h:47
CP::DileptonInvariantMassSelectorAlg::m_mllref
Gaudi::Property< float > m_mllref
the 2-lepton mass against which to compare
Definition: DileptonInvariantMassSelectorAlg.h:41
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::DileptonInvariantMassSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: DileptonInvariantMassSelectorAlg.h:78
CP::DileptonInvariantMassSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
the electrons selection
Definition: DileptonInvariantMassSelectorAlg.h:63
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::DileptonInvariantMassSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muons handle
Definition: DileptonInvariantMassSelectorAlg.h:68
CP::DileptonInvariantMassSelectorAlg::m_sign
Gaudi::Property< std::string > m_sign
the comparison (GT, LT, etc)
Definition: DileptonInvariantMassSelectorAlg.h:44
CP::DileptonInvariantMassSelectorAlg::DileptonInvariantMassSelectorAlg
DileptonInvariantMassSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: DileptonInvariantMassSelectorAlg.cxx:14
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::DileptonInvariantMassSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
the systematics
Definition: DileptonInvariantMassSelectorAlg.h:55
CP::DileptonInvariantMassSelectorAlg::initialize
virtual StatusCode initialize() override
Definition: DileptonInvariantMassSelectorAlg.cxx:18
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
CP::DileptonInvariantMassSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
the muons selection
Definition: DileptonInvariantMassSelectorAlg.h:73