ATLAS Offline Software
JetUncertaintiesAlg.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 
7 
8 //
9 // includes
10 //
11 
13 
14 //
15 // method implementations
16 //
17 
18 namespace CP
19 {
20 
22  initialize ()
23  {
24  ANA_CHECK (m_uncertaintiesTool.retrieve());
28  if (!m_uncertaintiesToolPD.empty()) {
29  ANA_CHECK (m_uncertaintiesToolPD.retrieve());
31  }
34 
35  if (!m_isJESbtag.empty()) m_decIsJESbtag.emplace(m_isJESbtag);
36  const std::string labelB = "PartonTruthLabelID";
37  m_accTruthLabel.emplace(labelB);
38 
39  // CPU-optimisation: differentiate the systematics for the two tools
40  // in initialisation rather than execution
41  for (const auto&sys : m_systematicsList.systematicsVector())
42  {
43  if (sys.name().find("PseudoData") != std::string::npos) {
45  }
46  else {
47  m_systematicsVector.push_back(sys);
48  }
49  }
50  return StatusCode::SUCCESS;
51  }
52 
53 
54 
56  execute ()
57  {
58  for (const auto& sys : m_systematicsVector)
59  {
60  ANA_CHECK (m_uncertaintiesTool->applySystematicVariation (sys));
61  xAOD::JetContainer *jets = nullptr;
62  ANA_CHECK (m_jetHandle.getCopy (jets, sys));
63  for (xAOD::Jet *jet : *jets)
64  {
65  // we need to tell the JES flavour uncertainty tool whether each jet is b-tagged at truth-level
66  if (m_decIsJESbtag) {
67  (*m_decIsJESbtag)(*jet) = (*m_accTruthLabel)(*jet) == 5 ;
68  }
69  if (m_preselection.getBool (*jet, sys))
70  {
72  }
73  }
74  }
75  for (const auto& sys : m_systematicsVectorOnlyJERPseudoData)
76  {
77  ANA_CHECK (m_uncertaintiesToolPD->applySystematicVariation (sys));
78  xAOD::JetContainer *jets = nullptr;
79  ANA_CHECK (m_jetHandle.getCopy (jets, sys));
80  for (xAOD::Jet *jet : *jets)
81  {
82  if (m_preselection.getBool (*jet, sys))
83  {
85  }
86  }
87  }
88 
89  return StatusCode::SUCCESS;
90  }
91 }
CP::JetUncertaintiesAlg::execute
StatusCode execute() override
Definition: JetUncertaintiesAlg.cxx:56
CP::JetUncertaintiesAlg::m_isJESbtag
Gaudi::Property< std::string > m_isJESbtag
Definition: JetUncertaintiesAlg.h:69
CP::SysListHandle::addSystematics
StatusCode addSystematics(const CP::SystematicSet &recommended, const CP::SystematicSet &affecting)
register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystem...
Definition: SysListHandle.cxx:48
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
JetUncertaintiesAlg.h
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
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::JetUncertaintiesAlg::initialize
StatusCode initialize() override
Definition: JetUncertaintiesAlg.cxx:22
CP::JetUncertaintiesAlg::m_decIsJESbtag
std::optional< SG::AuxElement::Decorator< char > > m_decIsJESbtag
Definition: JetUncertaintiesAlg.h:70
CP::JetUncertaintiesAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition: JetUncertaintiesAlg.h:53
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::JetUncertaintiesAlg::m_uncertaintiesToolPD
ToolHandle< ICPJetUncertaintiesTool > m_uncertaintiesToolPD
the secondary jet uncertainties tool, for pseudo-data JER smearing
Definition: JetUncertaintiesAlg.h:40
ANA_CHECK_CORRECTION
#define ANA_CHECK_CORRECTION(helper, object, expr)
a helper check macro to work with OutOfValidityHelper
Definition: OutOfValidityHelper.h:132
CP::JetUncertaintiesAlg::m_accTruthLabel
std::optional< SG::AuxElement::Accessor< int > > m_accTruthLabel
Definition: JetUncertaintiesAlg.h:71
CP::OutOfValidityHelper::initialize
::StatusCode initialize()
standard initialize
Definition: OutOfValidityHelper.cxx:25
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::JetUncertaintiesAlg::m_systematicsVector
std::vector< CP::SystematicSet > m_systematicsVector
the vector of systematics (for CPU-optimisation)
Definition: JetUncertaintiesAlg.h:62
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::JetUncertaintiesAlg::m_uncertaintiesTool
ToolHandle< ICPJetUncertaintiesTool > m_uncertaintiesTool
the main jet uncertainties tool
Definition: JetUncertaintiesAlg.h:36
CP::JetUncertaintiesAlg::m_systematicsVectorOnlyJERPseudoData
std::vector< CP::SystematicSet > m_systematicsVectorOnlyJERPseudoData
the vector of pseudo-data JER systematics (for CPU-optimisation)
Definition: JetUncertaintiesAlg.h:66
CP::JetUncertaintiesAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: JetUncertaintiesAlg.h:44
CP::JetUncertaintiesAlg::m_outOfValidity
OutOfValidityHelper m_outOfValidity
the helper for OutOfValidity results
Definition: JetUncertaintiesAlg.h:58
CP::JetUncertaintiesAlg::m_jetHandle
SysCopyHandle< xAOD::JetContainer > m_jetHandle
the jet collection we run on
Definition: JetUncertaintiesAlg.h:48