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  // accessors
34  static const SG::AuxElement::ConstAccessor<float> acc_pt_dressed("pt_dressed");
35  static const SG::AuxElement::ConstAccessor<float> acc_eta_dressed("eta_dressed");
36  static const SG::AuxElement::ConstAccessor<float> acc_phi_dressed("phi_dressed");
37  static const SG::AuxElement::ConstAccessor<float> acc_e_dressed("e_dressed");
38 
39  for (const auto &sys : m_systematicsList.systematicsVector()) {
40  // retrieve the EventInfo
41  const xAOD::EventInfo *evtInfo = nullptr;
42  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
43 
44  // default-decorate EventInfo
45  m_decoration.setBool(*evtInfo, 0, sys);
46 
47  // check the preselection
48  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
49  continue;
50 
51  // retrieve the electron container
52  const xAOD::IParticleContainer *electrons = nullptr;
55  // retrieve the electron container
56  const xAOD::IParticleContainer *muons = nullptr;
57  if (m_muonsHandle)
58  ANA_CHECK(m_muonsHandle.retrieve(muons, sys));
59 
60  // apply the requested selection
61  PtEtaPhiEVector lepton0, lepton1;
62  int total_leptons = 0;
63  bool isfilled0(false), isfilled1(false);
64  if (m_electronsHandle) {
65  for (const xAOD::IParticle *el : *electrons) {
67  total_leptons++;
68  if (!isfilled0){
70  lepton0.SetCoordinates(acc_pt_dressed(*el),
71  acc_eta_dressed(*el),
72  acc_phi_dressed(*el),
73  acc_e_dressed(*el));
74  else
75  lepton0.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
76  isfilled0 = true;
77  } else if (!isfilled1){
79  lepton1.SetCoordinates(acc_pt_dressed(*el),
80  acc_eta_dressed(*el),
81  acc_phi_dressed(*el),
82  acc_e_dressed(*el));
83  else
84  lepton1.SetCoordinates(el->pt(), el->eta(), el->phi(), el->e());
85  isfilled1 = true;
86  } else {
87  break;
88  }
89  }
90  }
91  }
92  if (m_muonsHandle) {
93  for (const xAOD::IParticle *mu : *muons) {
95  total_leptons++;
96  if (!isfilled0){
98  lepton0.SetCoordinates(acc_pt_dressed(*mu),
99  acc_eta_dressed(*mu),
100  acc_phi_dressed(*mu),
101  acc_e_dressed(*mu));
102  else
103  lepton0.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
104  isfilled0 = true;
105  } else if (!isfilled1){
107  lepton1.SetCoordinates(acc_pt_dressed(*mu),
108  acc_eta_dressed(*mu),
109  acc_phi_dressed(*mu),
110  acc_e_dressed(*mu));
111  else
112  lepton1.SetCoordinates(mu->pt(), mu->eta(), mu->phi(), mu->e());
113  isfilled1 = true;
114  } else {
115  break;
116  }
117  }
118  }
119  }
120 
121  if (total_leptons != 2){
122  ATH_MSG_ERROR("Exactly two leptons are required to compute the MLL window!");
123  return StatusCode::FAILURE;
124  }
125 
126  // compute MLL
127  float mll = (lepton0 + lepton1).M();
128 
129  // calculate decision
130  bool in_range = ( mll > m_mlllower && mll < m_mllupper );
131  bool decision = m_veto ? (!in_range) : in_range;
132  m_decoration.setBool(*evtInfo, decision, sys);
133  }
134  return StatusCode::SUCCESS;
135  }
136 } // namespace CP
CP::DileptonInvariantMassWindowSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
the muons selection
Definition: DileptonInvariantMassWindowSelectorAlg.h:72
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:54
CP::DileptonInvariantMassWindowSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_electronsHandle
the electrons handle
Definition: DileptonInvariantMassWindowSelectorAlg.h:57
CP::DileptonInvariantMassWindowSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: DileptonInvariantMassWindowSelectorAlg.h:82
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::DileptonInvariantMassWindowSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::IParticleContainer > m_muonsHandle
the muons handle
Definition: DileptonInvariantMassWindowSelectorAlg.h:67
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: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::DileptonInvariantMassWindowSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: DileptonInvariantMassWindowSelectorAlg.h:77
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:794
CP::DileptonInvariantMassWindowSelectorAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
Definition: DileptonInvariantMassWindowSelectorAlg.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:87
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:62
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