ATLAS Offline Software
METSystematicsTool.h
Go to the documentation of this file.
1 
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 
35 namespace met {
36 
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 {
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(""),
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
68  enum SystApplied {
69  NONE ,
80  };
81 
82  class METSystematicsTool : public virtual IMETSystematicsTool,
83  public asg::AsgTool,
84  public CP::SystematicsTool
85  {
86  // This macro defines the constructor with the interface declaration
88 
89  // FRIEND_TEST( METSystTest, TestGetEventInfo );
90  FRIEND_TEST( METSystTest, TestDefaultHistosFilled );
91  FRIEND_TEST( METSystTest, TestJetTrkHistosFilled );
92  FRIEND_TEST( METSystTest, TestAddAffectingSystematic );
93  FRIEND_TEST( METSystTest, TestProjectST );
94  FRIEND_TEST( METSystTest, TestProjectST2 );
95 
96  public:
97 
98  //Constructor
99  METSystematicsTool(const std::string& name);
100 
101  //Destructor
102  // virtual ~METSystematicsTool();
103 
104  StatusCode softTrkSystInitialize(); //initialize softTrk scale/reo histos from config file
105  StatusCode softCaloSystInitialize();//initialize softCalo scale/reso histos from config file
106  StatusCode jetTrkSystInitialize(); //initialize jetTrk scale/reso histos from config file
107 
108  //required asg tool interface functions
110 
111  //required correction tool functions
112  //we don't inherit from CorrectionTool directly, since we don't want to implement applyContainerCorrection
113  CP::CorrectionCode applyCorrection(xAOD::MissingET& inputMet,
115  CP::CorrectionCode correctedCopy(const xAOD::MissingET& met, xAOD::MissingET*& outputmet,
117  //We don't want these for MET since we only apply systematics to the soft term, and this may be unclear
118  //virtual CP::CorrectionCode applyContainerCorrection(xAOD::MissingETContainer& inputs, const CP::xAOD::EventInfo& eInfo) const;
119  //virtual CP::CorrectionCode applyContainerCorrection(xAOD::MissingETContainer& inputs, const CP::xAOD::EventInfo& eInfo) const;
120 
121  //required ISystematicTool functions
126  StatusCode sysApplySystematicVariation(const CP::SystematicSet&); //when inheriting from SystematicsTool, we should only have to implement this one
127 
128  void setRandomSeed(int seed) const;
129 
130  private:
131 
132  //default constructor
134 
135  //this saves the the currently applied systematic as an enum for faster lookup
137 
138  //these are the internal computation functions
140  xAOD::MissingETContainer const * METcont,
141  xAOD::EventInfo const & eInfo
142  ) const;
146  TRandom3* getTLSRandomGen() const;
147 
148  //declared properties
149  Gaudi::Property<std::string> m_configPrefix{this, "ConfigPrefix", "METUtilities/R22_PreRecs", ""};
150  Gaudi::Property<std::string> m_configSoftTrkFile{this, "ConfigSoftTrkFile", "TrackSoftTerms-pflow.config", ""};
151  Gaudi::Property<std::string> m_configJetTrkFile{this, "ConfigJetTrkFile", "", ""};
152  Gaudi::Property<std::string> m_configSoftCaloFile{this, "ConfigSoftCaloFile", "", ""};
153  Gaudi::Property<bool> m_useDevArea{this, "UseDevArea", false, ""};
154 
155  std::unique_ptr<TH3D> m_shiftpara_pthard_njet_mu{};
156  std::unique_ptr<TH3D> m_resopara_pthard_njet_mu{};
157  std::unique_ptr<TH3D> m_resoperp_pthard_njet_mu{};
158  std::unique_ptr<TH2D> m_jet_systRpt_pt_eta{};
159  std::unique_ptr<TH1D> m_h_calosyst_scale{};
160  std::unique_ptr<TH1D> m_h_calosyst_reso{};
161 
162  mutable boost::thread_specific_ptr<TRandom3> m_rand_tls; // thread-specific random number generator
163 
164  //internal property
165  int m_units{-1};//by default = -1, not set. Set to 1 (MeV) if not value found in config file
166 
167  int getNPV() const;
168  xAOD::EventInfo const * getDefaultEventInfo() const;
169 
170 
171  //Read/write handles
172  SG::ReadHandleKey<xAOD::VertexContainer> m_VertexContKey{this, "VertexContainer", "PrimaryVertices", ""};
173  SG::ReadHandleKey<xAOD::MissingETContainer> m_TruthContKey{this, "TruthContainer", "MET_Truth", ""};
174  SG::ReadHandleKey<xAOD::EventInfo> m_EventInfoKey{this, "EventInfo", "EventInfo", ""};
175 
177  StatusCode extractHistoPath(std::string & histfile, std::string & systpath, std::string & configdir, std::string & suffix, SystType const & type);
178 
179  missingEt calcPtHard(xAOD::MissingETContainer const * const cont) const;
180  missingEt caloSyst_scale(missingEt const &softTerms , double const scale) const;
181  missingEt caloSyst_reso (missingEt const &softTerms) const;
182  missingEt softTrkSyst_scale (missingEt const & softTerms, missingEt const & ptHard, double const shift) const;
183  missingEt softTrkSyst_reso (missingEt const & softTerms, missingEt const & ptHard, double const shift, double const smearpara,
184  double const smearperp) const;
185  missingEt projectST (missingEt const & softTerms, missingEt const & ptHard) const;
186 
187 
188 
189  };//METSystematicsTool
190 
191 }
192 
193 #endif //METUTILIES_METSYSTEMATICSTOOL_H
194 
195 // LocalWords: METSystematicsTool
met::METSystematicsTool
Definition: METSystematicsTool.h:85
met::METSystematicsTool::m_resoperp_pthard_njet_mu
std::unique_ptr< TH3D > m_resoperp_pthard_njet_mu
Definition: METSystematicsTool.h:157
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
IMETSystematicsTool
Definition: IMETSystematicsTool.h:71
met::METSystematicsTool::internalSoftTermApplyCorrection
CP::CorrectionCode internalSoftTermApplyCorrection(xAOD::MissingET &softMet, xAOD::MissingETContainer const *METcont, xAOD::EventInfo const &eInfo) const
Definition: METSystematicsTool.cxx:343
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
PropertyWrapper.h
met::METSystematicsTool::m_configJetTrkFile
Gaudi::Property< std::string > m_configJetTrkFile
Definition: METSystematicsTool.h:151
hotSpotInTAG.suffix
string suffix
Definition: hotSpotInTAG.py:186
met::missingEt::missingEt
missingEt(double mpx_in, double mpy_in, double sumet_in)
Definition: METSystematicsTool.h:44
met::METSystematicsTool::jetTrkSystInitialize
StatusCode jetTrkSystInitialize()
Definition: METSystematicsTool.cxx:144
met::obj_link_t
ElementLink< xAOD::IParticleContainer > obj_link_t
Definition: METMaker.h:38
met::missingEt::mpy
double mpy
Definition: METSystematicsTool.h:60
met::METSystematicsTool::applySystematicVariation
StatusCode applySystematicVariation(const CP::SystematicSet &set)
effects: configure this tool for the given list of systematic variations.
Definition: METSystematicsTool.h:125
met::METSystematicsTool::softTrkSystInitialize
StatusCode softTrkSystInitialize()
Definition: METSystematicsTool.cxx:173
met::METSystematicsTool::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: METSystematicsTool.cxx:83
met::SystApplied
SystApplied
Definition: METSystematicsTool.h:68
met::METSystematicsTool::getTLSRandomGen
TRandom3 * getTLSRandomGen() const
Definition: METSystematicsTool.cxx:876
met::MET_SOFTCALO_RESO
@ MET_SOFTCALO_RESO
Definition: METSystematicsTool.h:77
met::METSystematicsTool::applyCorrection
CP::CorrectionCode applyCorrection(xAOD::MissingET &inputMet, const xAOD::MissingETAssociationHelper &helper) const
Definition: METSystematicsTool.cxx:243
met::missingEt::missingEt
missingEt(double mpx_in, double mpy_in, double sumet_in, std::string const &iname, MissingETBase::Types::bitmask_t const &isource)
Definition: METSystematicsTool.h:51
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::SystematicsTool::affectingSystematics
virtual SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
Definition: SystematicsTool.cxx:40
met::missingEt::source
MissingETBase::Types::bitmask_t source
Definition: METSystematicsTool.h:63
MissingETBase
General namespace for MET EDM software.
Definition: MissingETAssociation_v1.h:454
met::METSystematicsTool::affectingSystematics
CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
Definition: METSystematicsTool.h:123
met::METSystematicsTool::m_configPrefix
Gaudi::Property< std::string > m_configPrefix
Definition: METSystematicsTool.h:149
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
met::MET_JETTRK_SCALEDOWN
@ MET_JETTRK_SCALEDOWN
Definition: METSystematicsTool.h:79
CP::SystematicsTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
Definition: SystematicsTool.cxx:74
IMETSystematicsTool.h
met::METSystematicsTool::isAffectedBySystematic
bool isAffectedBySystematic(const CP::SystematicVariation &var) const
returns: whether this tool is affected by the given systematic guarantee: no-fail
Definition: METSystematicsTool.h:122
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
MissingETBase::Types::bitmask_t
uint64_t bitmask_t
Type for status word bit mask.
Definition: MissingETBase.h:39
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
D3PD::Types
std::tuple< WrapType< TYPES >... > Types
A simple tuple of multiple types.
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:61
met::METSystematicsTool::m_h_calosyst_scale
std::unique_ptr< TH1D > m_h_calosyst_scale
Definition: METSystematicsTool.h:159
met::METSystematicsTool::caloSyst_scale
missingEt caloSyst_scale(missingEt const &softTerms, double const scale) const
Definition: METSystematicsTool.cxx:608
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
met::METSystematicsTool::m_configSoftCaloFile
Gaudi::Property< std::string > m_configSoftCaloFile
Definition: METSystematicsTool.h:152
met::NONE
@ NONE
Definition: METSystematicsTool.h:69
met::METSystematicsTool::m_appliedSystEnum
SystApplied m_appliedSystEnum
Definition: METSystematicsTool.h:136
met::METSystematicsTool::addMETAffectingSystematics
StatusCode addMETAffectingSystematics()
Definition: METSystematicsTool.cxx:41
met::MET_SOFTCALO_SCALEUP
@ MET_SOFTCALO_SCALEUP
Definition: METSystematicsTool.h:75
met::METSystematicsTool::recommendedSystematics
CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
Definition: METSystematicsTool.h:124
met::METSystematicsTool::m_h_calosyst_reso
std::unique_ptr< TH1D > m_h_calosyst_reso
Definition: METSystematicsTool.h:160
met::MET_SOFTTRK_RESOPARA
@ MET_SOFTTRK_RESOPARA
Definition: METSystematicsTool.h:72
met::METSystematicsTool::m_rand_tls
boost::thread_specific_ptr< TRandom3 > m_rand_tls
Definition: METSystematicsTool.h:162
met
Definition: IMETSignificance.h:24
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CP::SystematicsTool::recommendedSystematics
virtual SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
Definition: SystematicsTool.cxx:47
CP::SystematicsTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematic guarantee: no-fail
Definition: SystematicsTool.cxx:32
met::MET_SOFTTRK_RESOCORR
@ MET_SOFTTRK_RESOCORR
Definition: METSystematicsTool.h:74
met::METSystematicsTool::calcPtHard
missingEt calcPtHard(xAOD::MissingETContainer const *const cont) const
Definition: METSystematicsTool.cxx:674
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
met::METSystematicsTool::m_units
int m_units
Definition: METSystematicsTool.h:165
met::missingEt::name
std::string name
Definition: METSystematicsTool.h:62
xAOD::MissingET_v1
Principal data object for Missing ET.
Definition: MissingET_v1.h:25
met::METSystematicsTool::getDefaultEventInfo
xAOD::EventInfo const * getDefaultEventInfo() const
Definition: METSystematicsTool.cxx:847
met::METSystematicsTool::m_useDevArea
Gaudi::Property< bool > m_useDevArea
Definition: METSystematicsTool.h:153
met::METSystematicsTool::calcJetTrackMETWithSyst
CP::CorrectionCode calcJetTrackMETWithSyst(xAOD::MissingET &jettrkmet, const xAOD::MissingETAssociationHelper &helper) const
Definition: METSystematicsTool.cxx:511
xAODType
Definition: ObjectType.h:13
met::METSystematicsTool::getNPV
int getNPV() const
Definition: METSystematicsTool.cxx:858
SystematicsTool.h
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
met::METSystematicsTool::setRandomSeed
void setRandomSeed(int seed) const
Definition: METSystematicsTool.cxx:885
met::METSystematicsTool::correctedCopy
CP::CorrectionCode correctedCopy(const xAOD::MissingET &met, xAOD::MissingET *&outputmet, const xAOD::MissingETAssociationHelper &helper) const
Definition: METSystematicsTool.cxx:287
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
met::MET_SOFTCALO_SCALEDOWN
@ MET_SOFTCALO_SCALEDOWN
Definition: METSystematicsTool.h:76
met::missingEt::sumet
double sumet
Definition: METSystematicsTool.h:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
met::missingEt
Definition: METSystematicsTool.h:42
met::METSystematicsTool::m_shiftpara_pthard_njet_mu
std::unique_ptr< TH3D > m_shiftpara_pthard_njet_mu
Definition: METSystematicsTool.h:155
met::METSystematicsTool::softTrkSyst_scale
missingEt softTrkSyst_scale(missingEt const &softTerms, missingEt const &ptHard, double const shift) const
Definition: METSystematicsTool.cxx:639
met::METSystematicsTool::caloSyst_reso
missingEt caloSyst_reso(missingEt const &softTerms) const
Definition: METSystematicsTool.cxx:615
xAOD::MissingETAssociationHelper
Definition: MissingETAssociationHelper.h:26
met::SystType
SystType
Definition: IMETSystematicsTool.h:46
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
met::METSystematicsTool::sysApplySystematicVariation
StatusCode sysApplySystematicVariation(const CP::SystematicSet &)
effects: configure this tool for the given list of systematic variations.
Definition: METSystematicsTool.cxx:208
met::MET_SOFTTRK_RESOPERP
@ MET_SOFTTRK_RESOPERP
Definition: METSystematicsTool.h:73
G4AtlasPhysicsOption::UnknownType
@ UnknownType
Definition: IPhysicsOptionTool.h:26
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
met::METSystematicsTool::m_jet_systRpt_pt_eta
std::unique_ptr< TH2D > m_jet_systRpt_pt_eta
Definition: METSystematicsTool.h:158
met::METSystematicsTool::projectST
missingEt projectST(missingEt const &softTerms, missingEt const &ptHard) const
Definition: METSystematicsTool.cxx:658
met::missingEt::missingEt
missingEt()
Definition: METSystematicsTool.h:43
VertexContainer.h
CP::SystematicsTool
Base class for CP tools providing systematic variations.
Definition: SystematicsTool.h:48
met::METSystematicsTool::m_VertexContKey
SG::ReadHandleKey< xAOD::VertexContainer > m_VertexContKey
Definition: METSystematicsTool.h:172
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
met::missingEt::mpx
double mpx
Definition: METSystematicsTool.h:59
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
met::METSystematicsTool::m_configSoftTrkFile
Gaudi::Property< std::string > m_configSoftTrkFile
Definition: METSystematicsTool.h:150
met::METSystematicsTool::m_TruthContKey
SG::ReadHandleKey< xAOD::MissingETContainer > m_TruthContKey
Definition: METSystematicsTool.h:173
met::MET_SOFTTRK_SCALEUP
@ MET_SOFTTRK_SCALEUP
Definition: METSystematicsTool.h:70
met::METSystematicsTool::m_resopara_pthard_njet_mu
std::unique_ptr< TH3D > m_resopara_pthard_njet_mu
Definition: METSystematicsTool.h:156
met::MET_JETTRK_SCALEUP
@ MET_JETTRK_SCALEUP
Definition: METSystematicsTool.h:78
MissingETAssociationMap.h
met::METSystematicsTool::getCorrectedJetTrackMET
CP::CorrectionCode getCorrectedJetTrackMET(xAOD::MissingET &jettrkmet, const xAOD::MissingETAssociationHelper &helper) const
Definition: METSystematicsTool.cxx:589
met::METSystematicsTool::METSystematicsTool
METSystematicsTool()
AsgTool.h
met::METSystematicsTool::extractHistoPath
StatusCode extractHistoPath(std::string &histfile, std::string &systpath, std::string &configdir, std::string &suffix, SystType const &type)
Definition: METSystematicsTool.cxx:729
module_driven_slicing.histfile
histfile
Definition: module_driven_slicing.py:571
met::METSystematicsTool::FRIEND_TEST
FRIEND_TEST(METSystTest, TestDefaultHistosFilled)
met::METSystematicsTool::m_EventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
Definition: METSystematicsTool.h:174
MissingETAssociationHelper.h
met::METSystematicsTool::softTrkSyst_reso
missingEt softTrkSyst_reso(missingEt const &softTerms, missingEt const &ptHard, double const shift, double const smearpara, double const smearperp) const
Definition: METSystematicsTool.cxx:644
met::METSystematicsTool::softCaloSystInitialize
StatusCode softCaloSystInitialize()
Definition: METSystematicsTool.cxx:108
MissingETContainer.h
met::MET_SOFTTRK_SCALEDOWN
@ MET_SOFTTRK_SCALEDOWN
Definition: METSystematicsTool.h:71
python.LArRawChannelBuilderCrestConfig.Source
Source
Definition: LArRawChannelBuilderCrestConfig.py:115