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  for (const auto &sys : m_systematicsList.systematicsVector()) {
36  // retrieve the EventInfo
37  const xAOD::EventInfo *evtInfo = nullptr;
38  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
39 
40  // default-decorate EventInfo
41  m_decoration.setBool(*evtInfo, 0, sys);
42 
43  // check the preselection
44  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
45  continue;
46 
47  // retrieve the electron container
48  const xAOD::IParticleContainer *electrons = nullptr;
51  // retrieve the electron container
52  const xAOD::IParticleContainer *muons = nullptr;
53  if (m_muonsHandle)
54  ANA_CHECK(m_muonsHandle.retrieve(muons, sys));
55 
56  // apply the requested selection
57  PtEtaPhiEVector lepton0, lepton1;
58  int total_leptons = 0;
59  bool isfilled0(false), isfilled1(false);
60  if (m_electronsHandle) {
61  for (const xAOD::IParticle *el : *electrons) {
63  total_leptons++;
64  if (!isfilled0){
65  lepton0.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
66  isfilled0 = true;
67  } else if (!isfilled1){
68  lepton1.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
69  isfilled1 = true;
70  } else {
71  break;
72  }
73  }
74  }
75  }
76  if (m_muonsHandle) {
77  for (const xAOD::IParticle *mu : *muons) {
79  total_leptons++;
80  if (!isfilled0){
81  lepton0.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
82  isfilled0 = true;
83  } else if (!isfilled1){
84  lepton1.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
85  isfilled1 = true;
86  } else {
87  break;
88  }
89  }
90  }
91  }
92 
93  if (total_leptons != 2){
94  ATH_MSG_ERROR("Exactly two leptons are required to compute the MLL!");
95  return StatusCode::FAILURE;
96  }
97 
98  // compute MLL
99  float mll = (lepton0 + lepton1).M();
100 
101  // calculate decision
102  bool decision = SignEnum::checkValue(m_mllref.value(), m_signEnum, mll);
103  m_decoration.setBool(*evtInfo, decision, sys);
104  }
105  return StatusCode::SUCCESS;
106  }
107 } // 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:83
CP::DileptonInvariantMassSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: DileptonInvariantMassSelectorAlg.h:78
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
CP::DileptonInvariantMassSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition: DileptonInvariantMassSelectorAlg.h:47
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:53
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_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:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:73
CP::DileptonInvariantMassSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
the electrons selection
Definition: DileptonInvariantMassSelectorAlg.h:58
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:63
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:50
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:68