ATLAS Offline Software
DiLepSkimTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // DiLepSkimTools.cxx, (c) ATLAS Detector software
8 // Author: Dominik Krauss (krauss@mpp.mpg.de)
9 
10 // Athena
14 #include "xAODMuon/MuonContainer.h"
15 
16 DerivationFramework::DiLepSkim::DiLepSkim(const std::string& t, const std::string& n, const IInterface* p)
17  : AthAlgTool(t, n, p), m_dlf("DerivationFramework::DiLepFilters/DiLepFilters"),
18  m_filter_prop(0), m_filter(Filters::None)
19 {
20  declareInterface<DerivationFramework::ISkimmingTool>(this);
21  declareProperty("Filter", m_filter_prop);
22 }
23 
25 {
26  ATH_MSG_VERBOSE("initialize() ...");
27 
28  CHECK(m_dlf.retrieve());
29 
30  m_filter = static_cast<Filters>(m_filter_prop);
31  if(m_filter == Filters::None)
32  {
33  ATH_MSG_ERROR("No DESD filter specified!");
34  return StatusCode::FAILURE;
35  }
36 
37  ATH_CHECK(m_electronKey.initialize());
38  ATH_CHECK(m_muonKey.initialize());
39  ATH_CHECK(m_photonKey.initialize());
40 
41  return StatusCode::SUCCESS;
42 }
43 
45 {
46  // we check the filters only if at least one trigger is passed
47  uint32_t passFlags = 0;
48  if(!m_dlf->GetTriggers(passFlags)) return false;
49 
50  // retrieve particle containers
51  SG::ReadHandle<xAOD::ElectronContainer> elc(m_electronKey);
52  if( !elc.isValid() ) {
53  msg(MSG::WARNING) << "No Jet container found, will skip this event" << endmsg;
54  return false;
55  }
57  if( !muc.isValid() ) {
58  msg(MSG::WARNING) << "No Muon container found, will skip this event" << endmsg;
59  return false;
60  }
62  if( !phc.isValid() ) {
63  msg(MSG::WARNING) << "No Photon container found, will skip this event" << endmsg;
64  return false;
65  }
66 
67  // loop over containers and check filters
68  if(m_filter == Filters::SiEl)
69  {
70  for(const xAOD::Electron* el: *elc)
71  {
72  if(m_dlf->PassSiEl(passFlags, *el)) return true;
73  }
74  }
75  else if(m_filter == Filters::SiPhX)
76  {
77  for(auto ph1 = phc->cbegin(); ph1 != phc->cend(); ph1++)
78  {
79  for(const xAOD::Electron* el: *elc)
80  {
81  if(m_dlf->PassSiPhX(passFlags, **ph1, *el)) return true;
82  }
83  for(auto ph2 = ph1+1; ph2 != phc->cend(); ph2++)
84  {
85  if(m_dlf->PassSiPhX(passFlags, **ph1, **ph2)) return true;
86  }
87  for(const xAOD::Muon* mu: *muc)
88  {
89  if(m_dlf->PassSiPhX(passFlags, **ph1, *mu)) return true;
90  }
91  }
92  }
93  else if(m_filter == Filters::SiMu)
94  {
95  for(const xAOD::Muon* mu: *muc)
96  {
97  if(m_dlf->PassSiMu(passFlags, *mu)) return true;
98  }
99  }
100  else if(m_filter == Filters::SiMuBa)
101  {
102  for(const xAOD::Muon* mu: *muc)
103  {
104  if(m_dlf->PassSiMuBa(passFlags, *mu)) return true;
105  }
106  }
107  else if(m_filter == Filters::DiEl)
108  {
109  for(auto el1 = elc->cbegin(); el1 != elc->cend(); el1++)
110  {
111  for(auto el2 = el1+1; el2 != elc->cend(); el2++)
112  {
113  if(m_dlf->PassDiEl(passFlags, **el1, **el2)) return true;
114  }
115  }
116  }
117  else if(m_filter == Filters::DiPh)
118  {
119  for(auto ph1 = phc->cbegin(); ph1 != phc->cend(); ph1++)
120  {
121  for(auto ph2 = ph1+1; ph2 != phc->cend(); ph2++)
122  {
123  if(m_dlf->PassDiPh(passFlags, **ph1, **ph2)) return true;
124  }
125  }
126  }
127  else if(m_filter == Filters::DiElPh)
128  {
129  for(const xAOD::Electron* el: *elc)
130  {
131  for(const xAOD::Photon* ph: *phc)
132  {
133  if(m_dlf->PassDiElPh(passFlags, *el, *ph)) return true;
134  }
135  }
136  }
137  else if(m_filter == Filters::DiLoElPh)
138  {
139  for(const xAOD::Electron* el: *elc)
140  {
141  for(const xAOD::Photon* ph: *phc)
142  {
143  if(m_dlf->PassDiLoElPh(passFlags, *el, *ph)) return true;
144  }
145  }
146  }
147 
148  return false;
149 }
DiLepSkimTools.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
DerivationFramework::DiLepSkim::initialize
StatusCode initialize() override
Definition: DiLepSkimTools.cxx:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DataVector::cend
const_iterator cend() const noexcept
Return a const_iterator pointing past the end of the collection.
DerivationFramework::DiLepSkim::Filters
Filters
Definition: DiLepSkimTools.h:28
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
DerivationFramework::DiLepSkim::DiLepSkim
DiLepSkim(const std::string &t, const std::string &n, const IInterface *p)
Definition: DiLepSkimTools.cxx:16
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ElectronContainer.h
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework::DiLepSkim::m_filter_prop
int m_filter_prop
Definition: DiLepSkimTools.h:40
xAOD::Electron_v1
Definition: Electron_v1.h:34
MuonContainer.h
xAOD::Photon_v1
Definition: Photon_v1.h:37
DataVector::cbegin
const_iterator cbegin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::DiLepSkim::eventPassesFilter
bool eventPassesFilter() const override
Check that the current event passes this filter.
Definition: DiLepSkimTools.cxx:44
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
PhotonContainer.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7