ATLAS Offline Software
DileptonInvariantMassWindowSelectorAlg.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 
15  : EL::AnaAlgorithm(name, pSvcLocator)
16  {}
17 
24 
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 electron container
46  const xAOD::IParticleContainer *electrons = nullptr;
49  // retrieve the electron container
50  const xAOD::IParticleContainer *muons = nullptr;
51  if (m_muonsHandle)
52  ANA_CHECK(m_muonsHandle.retrieve(muons, sys));
53 
54  // apply the requested selection
55  PtEtaPhiEVector lepton0, lepton1;
56  int total_leptons = 0;
57  bool isfilled0(false), isfilled1(false);
58  if (m_electronsHandle) {
59  for (const xAOD::IParticle *el : *electrons) {
61  total_leptons++;
62  if (!isfilled0){
63  lepton0.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
64  isfilled0 = true;
65  } else if (!isfilled1){
66  lepton1.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
67  isfilled1 = true;
68  } else {
69  break;
70  }
71  }
72  }
73  }
74  if (m_muonsHandle) {
75  for (const xAOD::IParticle *mu : *muons) {
77  total_leptons++;
78  if (!isfilled0){
79  lepton0.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
80  isfilled0 = true;
81  } else if (!isfilled1){
82  lepton1.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
83  isfilled1 = true;
84  } else {
85  break;
86  }
87  }
88  }
89  }
90 
91  if (total_leptons != 2){
92  ATH_MSG_ERROR("Exactly two leptons are required to compute the MLL window!");
93  return StatusCode::FAILURE;
94  }
95 
96  // compute MLL
97  float mll = (lepton0 + lepton1).M();
98 
99  // calculate decision
100  bool in_range = ( mll > m_mlllower && mll < m_mllupper );
101  bool decision = m_veto ? (!in_range) : in_range;
102  m_decoration.setBool(*evtInfo, decision, sys);
103  }
104  return StatusCode::SUCCESS;
105  }
106 } // namespace CP
CP::DileptonInvariantMassWindowSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
the muons selection
Definition: DileptonInvariantMassWindowSelectorAlg.h:67
CP::DileptonInvariantMassWindowSelectorAlg::m_mlllower
Gaudi::Property< float > m_mlllower
the lower limit of the MLL window
Definition: DileptonInvariantMassWindowSelectorAlg.h:43
CP::DileptonInvariantMassWindowSelectorAlg::m_veto
Gaudi::Property< bool > m_veto
whether to veto events instead of selecting them
Definition: DileptonInvariantMassWindowSelectorAlg.h:46
CP::DileptonInvariantMassWindowSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
the systematics
Definition: DileptonInvariantMassWindowSelectorAlg.h:49
CP::DileptonInvariantMassWindowSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electrons handle
Definition: DileptonInvariantMassWindowSelectorAlg.h:52
CP::DileptonInvariantMassWindowSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: DileptonInvariantMassWindowSelectorAlg.h:77
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::DileptonInvariantMassWindowSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muons handle
Definition: DileptonInvariantMassWindowSelectorAlg.h:62
CP::DileptonInvariantMassWindowSelectorAlg::initialize
virtual StatusCode initialize() override
Definition: DileptonInvariantMassWindowSelectorAlg.cxx:18
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
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::DileptonInvariantMassWindowSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: DileptonInvariantMassWindowSelectorAlg.h:72
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
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::DileptonInvariantMassWindowSelectorAlg::DileptonInvariantMassWindowSelectorAlg
DileptonInvariantMassWindowSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: DileptonInvariantMassWindowSelectorAlg.cxx:14
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::DileptonInvariantMassWindowSelectorAlg::execute
virtual StatusCode execute() override
Definition: DileptonInvariantMassWindowSelectorAlg.cxx:32
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::DileptonInvariantMassWindowSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition: DileptonInvariantMassWindowSelectorAlg.h:82
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
DileptonInvariantMassWindowSelectorAlg.h
CP::DileptonInvariantMassWindowSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
the electrons selection
Definition: DileptonInvariantMassWindowSelectorAlg.h:57
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::DileptonInvariantMassWindowSelectorAlg::m_mllupper
Gaudi::Property< float > m_mllupper
the upper limit of the MLL window
Definition: DileptonInvariantMassWindowSelectorAlg.h:40
CP::SysWriteSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysWriteSelectionHandle.cxx:34