ATLAS Offline Software
CommonEfficiencyTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TAUANALYSISTOOLS_COMMONEFFICIENCYTOOL_H
6 #define TAUANALYSISTOOLS_COMMONEFFICIENCYTOOL_H
7 
8 /*
9  author: Dirk Duschinger
10  mail: dirk.duschinger@cern.ch
11 */
12 
13 // Framework include(s):
14 #include "AsgTools/AsgTool.h"
15 
16 // EDM include(s):
17 #include "xAODTau/TauJet.h"
20 
21 // Local include(s):
22 #include "TauAnalysisTools/Enums.h"
25 
26 // ROOT include(s):
27 #include "TFile.h"
28 #include "TKey.h"
29 
30 namespace TauAnalysisTools
31 {
32 
33 // forward declaration
34 class TauEfficiencyCorrectionsTool;
35 
37  : public virtual ITauEfficiencyCorrectionsTool
38  , public asg::AsgTool
39 {
42 
43 public:
44 
45  CommonEfficiencyTool(const std::string& sName);
46 
48 
49  virtual StatusCode initialize();
50 
51  // CommonEfficiencyTool pure virtual public functionality
52  //__________________________________________________________________________
53 
54  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::TauJet& tau, double& dEfficiencyScaleFactor,
55  unsigned int iRunNumber = 0, unsigned int iMu = 0 );
56 
58  unsigned int iRunNumber = 0, unsigned int iMu = 0);
59 
61  virtual bool isAffectedBySystematic( const CP::SystematicVariation& systematic ) const;
62 
65 
68 
71  virtual StatusCode applySystematicVariation ( const CP::SystematicSet& sSystematicSet);
72 
73  virtual bool isSupportedRunNumber( int /*iRunNumber*/ ) const
74  {
75  return true;
76  };
77 
78 protected:
79 
80  std::string ConvertProngToString(const int iProngness) const;
81  std::string ConvertMuToString(const int iMu) const;
82  std::string ConvertDecayModeToString(const int iDecayMode) const;
83 
84  typedef std::tuple<TObject*,
85  CP::CorrectionCode (*)(const TObject* oObject,
86  double& dEfficiencyScaleFactor,
87  double dVars[] ) > tTupleObjectFunc;
88  typedef std::map<std::string, tTupleObjectFunc > tSFMAP;
89  // In gcc10 builds, cling gets confused by the type of m_mSF and produces
90  // an ugly warning message. Hide this from cling to suppress that
91  // (substitute another unique_ptr so that the class layout remains the same).
92 #ifdef __CLING__
93  std::unique_ptr<int> m_dummy;
94 #else
95  std::unique_ptr< tSFMAP > m_mSF;
96 #endif
97 
98  std::unordered_map < CP::SystematicSet, std::string > m_mSystematicSets;
100  std::map<std::string, int> m_mSystematics;
101  std::map<std::string, std::string> m_mSystematicsHistNames;
102 
103  std::function<double(const xAOD::TauJet& xTau)> m_fX;
104  std::function<double(const xAOD::TauJet& xTau)> m_fY;
105 
106  void ReadInputs(const TFile& fFile);
107  void addHistogramToSFMap(TKey* kKey, const std::string& sKeyName);
108 
109  virtual CP::CorrectionCode getValue(const std::string& sHistName,
110  const xAOD::TauJet& xTau,
111  double& dEfficiencyScaleFactor) const;
112 
113  static CP::CorrectionCode getValueTH1(const TObject* oObject,
114  double& dEfficiencyScaleFactor,
115  double dVars[]
116  );
117  static CP::CorrectionCode getValueTH2(const TObject* oObject,
118  double& dEfficiencyScaleFactor,
119  double dVars[]
120  );
121  static CP::CorrectionCode getValueTH3(const TObject* oObject,
122  double& dEfficiencyScaleFactor,
123  double dVars[]
124  );
125  static CP::CorrectionCode getValueTF1(const TObject* oObject,
126  double& dEfficiencyScaleFactor,
127  double dVars[]
128  );
129 
130  void generateSystematicSets();
131 
132 protected:
133 
136 
137  std::string m_sInputFilePath;
138  std::string m_sInputFileName;
139  std::string m_sWP;
140  std::string m_sVarName;
141  std::string m_sSFHistName;
147 
149 
153 };
154 } // namespace TauAnalysisTools
155 
156 #endif // TAUANALYSISTOOLS_COMMONEFFICIENCYTOOL_H
TauAnalysisTools
Definition: TruthCollectionMakerTau.h:16
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
TauAnalysisTools::CommonEfficiencyTool::m_eCheckTruth
TruthMatchedParticleType m_eCheckTruth
Definition: CommonEfficiencyTool.h:148
TauAnalysisTools::CommonEfficiencyTool::ReadInputs
void ReadInputs(const TFile &fFile)
Definition: CommonEfficiencyTool.cxx:444
Enums.h
TauAnalysisTools::CommonEfficiencyTool::m_mSystematics
std::map< std::string, int > m_mSystematics
Definition: CommonEfficiencyTool.h:100
TauAnalysisTools::CommonEfficiencyTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::TauJet &tau, double &dEfficiencyScaleFactor, unsigned int iRunNumber=0, unsigned int iMu=0)
Declare the interface that the class provides.
Definition: CommonEfficiencyTool.cxx:155
TauAnalysisTools::CommonEfficiencyTool::m_bSkipTruthMatchCheck
bool m_bSkipTruthMatchCheck
Definition: CommonEfficiencyTool.h:142
TauAnalysisTools::CommonEfficiencyTool::m_sSystematicSet
const CP::SystematicSet * m_sSystematicSet
Definition: CommonEfficiencyTool.h:99
TauAnalysisTools::CommonEfficiencyTool::ConvertProngToString
std::string ConvertProngToString(const int iProngness) const
Definition: CommonEfficiencyTool.cxx:393
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
TauAnalysisTools::CommonEfficiencyTool::tSFMAP
std::map< std::string, tTupleObjectFunc > tSFMAP
Definition: CommonEfficiencyTool.h:88
TauAnalysisTools::CommonEfficiencyTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &sSystematicSet)
configure this tool for the given list of systematic variations.
Definition: CommonEfficiencyTool.cxx:342
TauAnalysisTools::CommonEfficiencyTool::m_sVarName
std::string m_sVarName
Definition: CommonEfficiencyTool.h:140
CP::SystematicVariation
Definition: SystematicVariation.h:47
TauAnalysisTools::CommonEfficiencyTool::getValueTH3
static CP::CorrectionCode getValueTH3(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])
Definition: CommonEfficiencyTool.cxx:766
TauAnalysisTools::CommonEfficiencyTool::tTupleObjectFunc
std::tuple< TObject *, CP::CorrectionCode(*)(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[]) > tTupleObjectFunc
Definition: CommonEfficiencyTool.h:87
ITauEfficiencyCorrectionsTool.h
TauAnalysisTools::CommonEfficiencyTool::isSupportedRunNumber
virtual bool isSupportedRunNumber(int) const
check if run number is supported in recommendations
Definition: CommonEfficiencyTool.h:73
TauAnalysisTools::CommonEfficiencyTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematics
Definition: CommonEfficiencyTool.cxx:306
TauAnalysisTools::CommonEfficiencyTool::~CommonEfficiencyTool
~CommonEfficiencyTool()
Definition: CommonEfficiencyTool.cxx:99
TauAnalysisTools::CommonEfficiencyTool::m_mSystematicSets
std::unordered_map< CP::SystematicSet, std::string > m_mSystematicSets
Definition: CommonEfficiencyTool.h:98
TauAnalysisTools::CommonEfficiencyTool::getValue
virtual CP::CorrectionCode getValue(const std::string &sHistName, const xAOD::TauJet &xTau, double &dEfficiencyScaleFactor) const
Definition: CommonEfficiencyTool.cxx:669
TauAnalysisTools::CommonEfficiencyTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
Definition: CommonEfficiencyTool.cxx:326
TauAnalysisTools::CommonEfficiencyTool::m_sWP
std::string m_sWP
Definition: CommonEfficiencyTool.h:139
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TauAnalysisTools::CommonEfficiencyTool::m_mSF
std::unique_ptr< tSFMAP > m_mSF
Definition: CommonEfficiencyTool.h:95
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
TauAnalysisTools::CommonEfficiencyTool
Definition: CommonEfficiencyTool.h:39
TauAnalysisTools::CommonEfficiencyTool::m_fX
std::function< double(const xAOD::TauJet &xTau)> m_fX
Definition: CommonEfficiencyTool.h:103
TauAnalysisTools::CommonEfficiencyTool::m_iJetIDLevel
int m_iJetIDLevel
Definition: CommonEfficiencyTool.h:145
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
TauAnalysisTools::CommonEfficiencyTool::m_bSFIsAvailable
bool m_bSFIsAvailable
Definition: CommonEfficiencyTool.h:150
TauAnalysisTools::CommonEfficiencyTool::getValueTH2
static CP::CorrectionCode getValueTH2(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])
Definition: CommonEfficiencyTool.cxx:734
TauAnalysisTools::CommonEfficiencyTool::m_sSFHistName
std::string m_sSFHistName
Definition: CommonEfficiencyTool.h:141
TauAnalysisTools::CommonEfficiencyTool::m_sInputFilePath
std::string m_sInputFilePath
Definition: CommonEfficiencyTool.h:137
TauAnalysisTools::CommonEfficiencyTool::generateSystematicSets
void generateSystematicSets()
Definition: CommonEfficiencyTool.cxx:606
TauAnalysisTools::CommonEfficiencyTool::m_sAffectingSystematics
CP::SystematicSet m_sAffectingSystematics
Definition: CommonEfficiencyTool.h:134
TauAnalysisTools::CommonEfficiencyTool::m_bUseTauSubstructure
bool m_bUseTauSubstructure
Definition: CommonEfficiencyTool.h:144
TauAnalysisTools::TruthMatchedParticleType
TruthMatchedParticleType
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/Enums.h:95
TauAnalysisTools::CommonEfficiencyTool::m_fY
std::function< double(const xAOD::TauJet &xTau)> m_fY
Definition: CommonEfficiencyTool.h:104
TauAnalysisTools::CommonEfficiencyTool::ConvertMuToString
std::string ConvertMuToString(const int iMu) const
Definition: CommonEfficiencyTool.cxx:403
TauAnalysisTools::CommonEfficiencyTool::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: CommonEfficiencyTool.cxx:113
TauAnalysisTools::CommonEfficiencyTool::addHistogramToSFMap
void addHistogramToSFMap(TKey *kKey, const std::string &sKeyName)
Definition: CommonEfficiencyTool.cxx:555
TauAnalysisTools::CommonEfficiencyTool::m_bSFIsAvailableChecked
bool m_bSFIsAvailableChecked
Definition: CommonEfficiencyTool.h:151
TauAnalysisTools::CommonEfficiencyTool::CommonEfficiencyTool
CommonEfficiencyTool(const std::string &sName)
Create a proper constructor for Athena.
Definition: CommonEfficiencyTool.cxx:74
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
TauJet.h
TauAnalysisTools::CommonEfficiencyTool::ConvertDecayModeToString
std::string ConvertDecayModeToString(const int iDecayMode) const
Definition: CommonEfficiencyTool.cxx:415
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CorrectionCode.h
TauAnalysisTools::CommonEfficiencyTool::m_bNoMultiprong
bool m_bNoMultiprong
Definition: CommonEfficiencyTool.h:143
AsgTool.h
TruthParticle.h
TauAnalysisTools::CommonEfficiencyTool::m_sInputFileName
std::string m_sInputFileName
Definition: CommonEfficiencyTool.h:138
TauAnalysisTools::CommonEfficiencyTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
Definition: CommonEfficiencyTool.cxx:317
TauAnalysisTools::CommonEfficiencyTool::applyEfficiencyScaleFactor
virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::TauJet &xTau, unsigned int iRunNumber=0, unsigned int iMu=0)
Decorate the tau with its efficiency.
Definition: CommonEfficiencyTool.cxx:275
TauAnalysisTools::ITauEfficiencyCorrectionsTool
Definition: ITauEfficiencyCorrectionsTool.h:31
TauAnalysisTools::CommonEfficiencyTool::m_bSplitMu
bool m_bSplitMu
Definition: CommonEfficiencyTool.h:152
TauAnalysisTools::CommonEfficiencyTool::m_mSystematicsHistNames
std::map< std::string, std::string > m_mSystematicsHistNames
Definition: CommonEfficiencyTool.h:101
HelperFunctions.h
TauAnalysisTools::CommonEfficiencyTool::getValueTH1
static CP::CorrectionCode getValueTH1(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])
Definition: CommonEfficiencyTool.cxx:704
TauAnalysisTools::CommonEfficiencyTool::getValueTF1
static CP::CorrectionCode getValueTF1(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])
Definition: CommonEfficiencyTool.cxx:801
TauAnalysisTools::CommonEfficiencyTool::m_sRecommendedSystematics
CP::SystematicSet m_sRecommendedSystematics
Definition: CommonEfficiencyTool.h:135
TauAnalysisTools::CommonEfficiencyTool::m_iEleIDLevel
int m_iEleIDLevel
Definition: CommonEfficiencyTool.h:146