ATLAS Offline Software
Loading...
Searching...
No Matches
METSystematicsTool.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5*/
6
7// METSystematicsTool.h
8// Header file for class METSystematicsTool
9// Author: Russell Smith <rsmith@cern.ch>
11#ifndef METUTILITIES_METSYSTEMATICSTOOL_H
12#define METUTILITIES_METSYSTEMATICSTOOL_H
13
17#include "AsgTools/AsgTool.h"
18
20
21#include "TH1.h"
22#include "TH2.h"
23#include "TH3.h"
24#include "TRandom3.h"
25
27
31
32#include "boost/thread/tss.hpp"
33#include "gtest/gtest_prod.h"
34
35namespace met {
36
37 typedef ElementLink<xAOD::IParticleContainer> obj_link_t;
38
39 //we create this to avoid calling the xAOD::MissingET constructor
40 //since it creates a private store which is slow
41 //please forgive the code duplication :)
42 struct missingEt {
43 missingEt() : mpx(0), mpy(0), sumet(0), name(""), source(static_cast<MissingETBase::Types::bitmask_t>(MissingETBase::Source::Type::UnknownType)){}
44 missingEt(double mpx_in, double mpy_in, double sumet_in) :
45 mpx(mpx_in),
46 mpy(mpy_in),
47 sumet(sumet_in),
48 name(""),
49 source(static_cast<MissingETBase::Types::bitmask_t>(MissingETBase::Source::Type::UnknownType))
50 {}
51 missingEt(double mpx_in, double mpy_in, double sumet_in, std::string const & iname, MissingETBase::Types::bitmask_t const & isource ) :
52 mpx(mpx_in),
53 mpy(mpy_in),
54 sumet(sumet_in),
55 name(iname),
56 source(isource)
57 {}
58
59 double mpx;
60 double mpy;
61 double sumet;
62 std::string name;
64 };
65
66 //this is to speed up applyCorrection lookup.
67 //we still store the full list in appliedSystematics()/m_appliedSystematics
83
85 public asg::AsgTool,
87 {
88 // This macro defines the constructor with the interface declaration
90
91 // FRIEND_TEST( METSystTest, TestGetEventInfo );
92 FRIEND_TEST( METSystTest, TestDefaultHistosFilled );
93 FRIEND_TEST( METSystTest, TestJetTrkHistosFilled );
94 FRIEND_TEST( METSystTest, TestAddAffectingSystematic );
95 FRIEND_TEST( METSystTest, TestProjectST );
96 FRIEND_TEST( METSystTest, TestProjectST2 );
97
98 public:
99
100 //Constructor
102
103 //Destructor
104 // virtual ~METSystematicsTool();
105
106 StatusCode softTrkSystInitialize(); //initialize softTrk scale/reo histos from config file
107 StatusCode softCaloSystInitialize();//initialize softCalo scale/reso histos from config file
108 StatusCode jetTrkSystInitialize(); //initialize jetTrk scale/reso histos from config file
109
110 //required asg tool interface functions
111 StatusCode initialize();
112
113 //required correction tool functions
114 //we don't inherit from CorrectionTool directly, since we don't want to implement applyContainerCorrection
119 //We don't want these for MET since we only apply systematics to the soft term, and this may be unclear
120 //virtual CP::CorrectionCode applyContainerCorrection(xAOD::MissingETContainer& inputs, const CP::xAOD::EventInfo& eInfo) const;
121 //virtual CP::CorrectionCode applyContainerCorrection(xAOD::MissingETContainer& inputs, const CP::xAOD::EventInfo& eInfo) const;
122
123 //required ISystematicTool functions
128 StatusCode sysApplySystematicVariation(const CP::SystematicSet&); //when inheriting from SystematicsTool, we should only have to implement this one
129
130 void setRandomSeed(unsigned long seed) const;
131
132 private:
133
134 //default constructor
136
137 //this saves the the currently applied systematic as an enum for faster lookup
139
140 //these are the internal computation functions
142 xAOD::MissingETContainer const * METcont,
143 xAOD::EventInfo const & eInfo
144 ) const;
148 TRandom3* getTLSRandomGen() const;
149
150 //declared properties
151 Gaudi::Property<std::string> m_configPrefix{this, "ConfigPrefix", "METUtilities/R22_PreRecs", ""};
152 Gaudi::Property<std::string> m_configSoftTrkFile{this, "ConfigSoftTrkFile", "TrackSoftTerms-pflow_Dec24.config", ""};
153 Gaudi::Property<std::string> m_configJetTrkFile{this, "ConfigJetTrkFile", "", ""};
154 Gaudi::Property<std::string> m_configSoftCaloFile{this, "ConfigSoftCaloFile", "", ""};
155 Gaudi::Property<bool> m_useDevArea{this, "UseDevArea", false, ""};
156
157 std::unique_ptr<TH3D> m_trk_shiftpara_pthard_njet_mu{};
158 std::unique_ptr<TH3D> m_trk_resopara_pthard_njet_mu{};
159 std::unique_ptr<TH3D> m_trk_resoperp_pthard_njet_mu{};
160 std::unique_ptr<TH3D> m_calo_shiftpara_pthard_njet_mu{};
161 std::unique_ptr<TH3D> m_calo_resopara_pthard_njet_mu{};
162 std::unique_ptr<TH3D> m_calo_resoperp_pthard_njet_mu{};
163 std::unique_ptr<TH2D> m_jet_systRpt_pt_eta{};
164
165 mutable boost::thread_specific_ptr<TRandom3> m_rand_tls; // thread-specific random number generator
166
167 //internal property
168 int m_units{-1};//by default = -1, not set. Set to 1 (MeV) if not value found in config file
169
170 int getNPV() const;
171 xAOD::EventInfo const * getDefaultEventInfo() const;
172
173
174 //Read/write handles
175 SG::ReadHandleKey<xAOD::VertexContainer> m_VertexContKey{this, "VertexContainer", "PrimaryVertices", ""};
176 SG::ReadHandleKey<xAOD::MissingETContainer> m_TruthContKey{this, "TruthContainer", "MET_Truth", ""};
177 SG::ReadHandleKey<xAOD::EventInfo> m_EventInfoKey{this, "EventInfo", "EventInfo", ""};
178
179 StatusCode addMETAffectingSystematics();
180 StatusCode extractHistoPath(std::string & histfile, std::string & systpath, std::string & configdir, std::string & suffix, SystType const & type);
181
182 missingEt calcPtHard(xAOD::MissingETContainer const * const cont) const;
183 missingEt variedSoftTerm (missingEt const & softTerms, missingEt const & ptHard, double varPara, double varPerp) const;
184 missingEt projectST (missingEt const & softTerms, missingEt const & ptHard) const;
185
186
187
188 };//METSystematicsTool
189
190}
191
192#endif //METUTILIES_METSYSTEMATICSTOOL_H
193
194// LocalWords: METSystematicsTool
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid from which a ReadHandle is made.
Return value from object correction CP tools.
Class to wrap a set of SystematicVariations.
Base class for CP tools providing systematic variations.
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematic guarantee: no-fail
virtual SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
virtual SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
Return value from object correction CP tools.
Property holding a SG store/key/clid from which a ReadHandle is made.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
void setRandomSeed(unsigned long seed) const
SG::ReadHandleKey< xAOD::VertexContainer > m_VertexContKey
Gaudi::Property< std::string > m_configSoftCaloFile
std::unique_ptr< TH3D > m_calo_resopara_pthard_njet_mu
CP::SystematicSet affectingSystematics() const
the list of all systematics this tool can be affected by
CP::SystematicSet recommendedSystematics() const
the list of all systematics this tool recommends to use
StatusCode initialize()
Dummy implementation of the initialisation function.
std::unique_ptr< TH3D > m_calo_resoperp_pthard_njet_mu
TRandom3 * getTLSRandomGen() const
CP::CorrectionCode internalSoftTermApplyCorrection(xAOD::MissingET &softMet, xAOD::MissingETContainer const *METcont, xAOD::EventInfo const &eInfo) const
std::unique_ptr< TH3D > m_calo_shiftpara_pthard_njet_mu
bool isAffectedBySystematic(const CP::SystematicVariation &var) const
Declare the interface that this class provides.
CP::CorrectionCode getCorrectedJetTrackMET(xAOD::MissingET &jettrkmet, const xAOD::MissingETAssociationHelper &helper) const
CP::CorrectionCode correctedCopy(const xAOD::MissingET &met, xAOD::MissingET *&outputmet, const xAOD::MissingETAssociationHelper &helper) const
Gaudi::Property< std::string > m_configSoftTrkFile
CP::CorrectionCode applyCorrection(xAOD::MissingET &inputMet, const xAOD::MissingETAssociationHelper &helper) const
StatusCode extractHistoPath(std::string &histfile, std::string &systpath, std::string &configdir, std::string &suffix, SystType const &type)
missingEt variedSoftTerm(missingEt const &softTerms, missingEt const &ptHard, double varPara, double varPerp) const
METSystematicsTool(const std::string &name)
std::unique_ptr< TH3D > m_trk_resopara_pthard_njet_mu
Gaudi::Property< std::string > m_configJetTrkFile
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
std::unique_ptr< TH3D > m_trk_shiftpara_pthard_njet_mu
SG::ReadHandleKey< xAOD::MissingETContainer > m_TruthContKey
std::unique_ptr< TH2D > m_jet_systRpt_pt_eta
FRIEND_TEST(METSystTest, TestDefaultHistosFilled)
StatusCode sysApplySystematicVariation(const CP::SystematicSet &)
effects: configure this tool for the given list of systematic variations.
CP::CorrectionCode calcJetTrackMETWithSyst(xAOD::MissingET &jettrkmet, const xAOD::MissingETAssociationHelper &helper) const
Gaudi::Property< std::string > m_configPrefix
missingEt calcPtHard(xAOD::MissingETContainer const *const cont) const
StatusCode applySystematicVariation(const CP::SystematicSet &set)
effects: configure this tool for the given list of systematic variations.
xAOD::EventInfo const * getDefaultEventInfo() const
Gaudi::Property< bool > m_useDevArea
std::unique_ptr< TH3D > m_trk_resoperp_pthard_njet_mu
boost::thread_specific_ptr< TRandom3 > m_rand_tls
missingEt projectST(missingEt const &softTerms, missingEt const &ptHard) const
STL class.
Select isolated Photons, Electrons and Muons.
uint64_t bitmask_t
Type for status word bit mask.
General namespace for MET EDM software.
ElementLink< xAOD::IParticleContainer > obj_link_t
@ MET_JETTRK_SCALEDOWN
@ MET_SOFTTRK_SCALEUP
@ MET_SOFTCALO_RESOCORR
@ MET_SOFTCALO_SCALEUP
@ MET_SOFTCALO_SCALEDOWN
@ MET_SOFTTRK_RESOPARA
@ MET_SOFTTRK_RESOCORR
@ MET_SOFTTRK_RESOPERP
@ MET_JETTRK_SCALEUP
@ MET_SOFTCALO_RESOPERP
@ MET_SOFTCALO_RESOPARA
@ MET_SOFTTRK_SCALEDOWN
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
MissingET_v1 MissingET
Version control by type defintion.
missingEt(double mpx_in, double mpy_in, double sumet_in, std::string const &iname, MissingETBase::Types::bitmask_t const &isource)
MissingETBase::Types::bitmask_t source
missingEt(double mpx_in, double mpy_in, double sumet_in)