ATLAS Offline Software
FakeBkgCalculatorAlg.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 
9 
10 namespace CP {
11 
13 
17 
21 
24 
25  ANA_CHECK(m_fakeTool.retrieve());
27 
29 
30  return StatusCode::SUCCESS;
31  }
32 
34 
35  static const SG::AuxElement::Decorator<char> dec_lepton_tight("TightForFakeBkgCalculation");
36  static const SG::AuxElement::Accessor<char> flagAcc("TightForFakeBkgCalculation");
37 
38  ANA_MSG_DEBUG(" ----> FakeBkgCalculatorAlg::execute()");
39  for (const auto &sys : m_systematicsList.systematicsVector()) {
40  const xAOD::EventInfo *evtInfo = nullptr;
41  const xAOD::ElectronContainer *electrons = nullptr;
42  const xAOD::MuonContainer *muons = nullptr;
43 
44  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
45 
46  m_fakeToolOutput.set(*evtInfo, -1, sys); // default value
47  if ( m_preselection && !m_preselection.getBool(*evtInfo, sys)) continue;
48 
51 
53  for (const xAOD::Electron *t : *electrons) {
55  leptons.push_back(t);
56  dec_lepton_tight(*leptons.back()) = m_electronSelectionTarget.getBool(*t, sys);
57  }
58  for (const xAOD::Muon *t : *muons) {
59  if( m_muonSelection && !m_muonSelection.getBool(*t, sys)) continue;
60  leptons.push_back(t);
61  dec_lepton_tight(*leptons.back()) = m_muonSelectionTarget.getBool(*t, sys);
62  }
63 
64  for (const xAOD::IParticle *t : leptons)
65  ANA_MSG_DEBUG("lepton type = "<<t->type()<<", pt = "<<t->pt()<<" , eta = "<<t->eta()<<", tight = "<<bool(flagAcc(*t)));
66 
67  ANA_CHECK(m_fakeTool->addEvent(leptons));
68  float asmWgt = 0.;
69  ANA_CHECK(m_fakeTool->applySystematicVariation({})); // the nominal MM weight is computed
70  ANA_CHECK(m_fakeTool->getEventWeight(asmWgt, m_definition, m_process));
71  ANA_MSG_DEBUG(" ----> asmWgt = "<<asmWgt);
72 
73  m_fakeToolOutput.set(*evtInfo, asmWgt, sys);
74  }
75 
76  return StatusCode::SUCCESS;
77  }
78 
79 } // namespace
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
CP::FakeBkgCalculatorAlg::m_muonSelectionTarget
CP::SysReadSelectionHandle m_muonSelectionTarget
Definition: FakeBkgCalculatorAlg.h:59
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
CP::FakeBkgCalculatorAlg::m_fakeToolOutput
CP::SysWriteDecorHandle< float > m_fakeToolOutput
Definition: FakeBkgCalculatorAlg.h:76
CP::FakeBkgCalculatorAlg::execute
virtual StatusCode execute() override
Definition: FakeBkgCalculatorAlg.cxx:33
CP::FakeBkgCalculatorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition: FakeBkgCalculatorAlg.h:43
CP::FakeBkgCalculatorAlg::m_definition
Gaudi::Property< std::string > m_definition
Definition: FakeBkgCalculatorAlg.h:39
CP::FakeBkgCalculatorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
Definition: FakeBkgCalculatorAlg.h:56
CP::FakeBkgCalculatorAlg::m_electronSelectionTarget
CP::SysReadSelectionHandle m_electronSelectionTarget
Definition: FakeBkgCalculatorAlg.h:49
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::FakeBkgCalculatorAlg::initialize
virtual StatusCode initialize() override
Definition: FakeBkgCalculatorAlg.cxx:12
CP::FakeBkgCalculatorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
Definition: FakeBkgCalculatorAlg.h:67
FakeBkgCalculatorAlg.h
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
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
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ConstDataVector::back
ElementProxy back()
Access the last element in the collection as an lvalue.
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
CP::FakeBkgCalculatorAlg::m_fakeTool
ToolHandle< ILinearFakeBkgTool > m_fakeTool
Definition: FakeBkgCalculatorAlg.h:71
CP::FakeBkgCalculatorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
Definition: FakeBkgCalculatorAlg.h:46
CP::FakeBkgCalculatorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
Definition: FakeBkgCalculatorAlg.h:36
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::FakeBkgCalculatorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition: FakeBkgCalculatorAlg.h:53
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CP::FakeBkgCalculatorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
Definition: FakeBkgCalculatorAlg.h:63
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::FakeBkgCalculatorAlg::m_process
Gaudi::Property< std::string > m_process
Definition: FakeBkgCalculatorAlg.h:40
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288