ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauEfficiencyCorrectionsTool.cxx
Go to the documentation of this file.
1
10
11// EDM include(s):
14
15// Local include(s):
19
21
22namespace TauAnalysisTools
23{
24
25//______________________________________________________________________________
27 : asg::AsgMetadataTool( sName )
28 , m_bIsData(false)
29 , m_bIsConfigured(false)
30{
31}
32
33//______________________________________________________________________________
37
38
39//______________________________________________________________________________
41{
42 // Greet the user:
43 ATH_MSG_INFO( "Initializing DiTauEfficiencyCorrectionsTool" );
44
46 ATH_MSG_WARNING("Truth match check will be skipped. This is ONLY FOR TESTING PURPOSE!");
47
48 if (m_sRecommendationTag == "2017-moriond")
50 else
51 {
52 ATH_MSG_FATAL("Unknown RecommendationTag: "<<m_sRecommendationTag);
53 return StatusCode::FAILURE;
54 }
55
56 // Add the affecting systematics to the global registry
58 if (!registry.registerSystematics(*this))
59 {
60 ATH_MSG_ERROR ("Unable to register the systematics");
61 return StatusCode::FAILURE;
62 }
63
65
66 return StatusCode::SUCCESS;
67}
68
69
70//______________________________________________________________________________
72{
73 if (!m_bIsConfigured)
74 {
75 const xAOD::EventInfo* xEventInfo = nullptr;
76 ATH_CHECK(evtStore()->retrieve(xEventInfo,"EventInfo"));
78 m_bIsConfigured = true;
79 }
80
81 return StatusCode::SUCCESS;
82}
83
84
85//______________________________________________________________________________
87{
88 ATH_MSG_DEBUG( "DiTauEfficiencyCorrectionsTool with name " << name() << " is configured as follows:" );
89 for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes) {
90 ATH_MSG_DEBUG( " EfficiencyCorrectionTypes " << iEfficiencyCorrectionType );
91 }
92 ATH_MSG_DEBUG( " InputFilePathJetIDHadTau " << m_sInputFilePathJetIDHadTau );
93 ATH_MSG_DEBUG( " VarNameJetIDHadTau " << m_sVarNameJetIDHadTau );
94 ATH_MSG_DEBUG( " RecommendationTag " << m_sRecommendationTag );
95}
96
97//______________________________________________________________________________
99 double& eff )
100{
101 eff = 1.;
102
103 if (m_bIsData)
105
106 double dToolEff = 1.;
107 CP::CorrectionCode tmpCorrectionCode = m_tTool->getEfficiencyScaleFactor(xDiTau, dToolEff);
108 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
109 return tmpCorrectionCode;
110
111 eff *= dToolEff;
113}
114
115//______________________________________________________________________________
117{
118 if (m_bIsData)
120
121 CP::CorrectionCode tmpCorrectionCode = m_tTool->applyEfficiencyScaleFactor(xDiTau);
122 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
123 {
124 return tmpCorrectionCode;
125 }
126
128}
129
131//______________________________________________________________________________
133{
134 if (m_tTool->isAffectedBySystematic(systematic))
135 return true;
136
137 return false;
138}
139
141//______________________________________________________________________________
143{
144 CP::SystematicSet sAffectingSystematics;
145 sAffectingSystematics.insert(m_tTool->affectingSystematics());
146
147 return sAffectingSystematics;
148}
149
151//______________________________________________________________________________
153{
154 CP::SystematicSet sRecommendedSystematics;
155 sRecommendedSystematics.insert(m_tTool->recommendedSystematics());
156
157 return sRecommendedSystematics;
158}
159
160//______________________________________________________________________________
162{
163 if (m_tTool->applySystematicVariation(sSystematicSet) == StatusCode::FAILURE)
164 {
165 ATH_MSG_ERROR( "failing in appying systematic uncertainty.");
166 return StatusCode::FAILURE;
167 }
168
169 return StatusCode::SUCCESS;
170}
171
172//=================================PRIVATE-PART=================================
173
174//______________________________________________________________________________
176{
177 std::string sDirectory = "TauAnalysisTools/" + std::string(sSharedFilesVersion) + "/EfficiencyCorrections/";
178 for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes)
179 {
180 if (iEfficiencyCorrectionType == SFJetIDHadTau)
181 {
182 // only set vars if they have been configured by the user
183 if (m_sInputFilePathJetIDHadTau.empty()) {
184 sDirectory = "TauAnalysisTools/00-04-00/EfficiencyCorrections/";
185 m_sInputFilePathJetIDHadTau = sDirectory+"JetID_TrueHadDiTau_2017-fall.root";
186 }
187 if (m_sVarNameJetIDHadTau.empty()) m_sVarNameJetIDHadTau = "DiTauScaleFactorJetIDHadTau";
188
189 std::string wp = ConvertJetIDToString(m_iJetIDLevel);
190
191 if (m_tTool.empty()){
192 asg::AsgToolConfig config("TauAnalysisTools::CommonDiTauEfficiencyTool/JetIDHadTauTool_"+wp);
193 ATH_CHECK(config.setProperty("InputFilePath", m_sInputFilePathJetIDHadTau));
194 ATH_CHECK(config.setProperty("VarName", m_sVarNameJetIDHadTau));
195 ATH_CHECK(config.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
196 ATH_CHECK(config.setProperty("WP", wp));
197 ATH_CHECK(config.makePrivateTool(m_tTool));
198 }
199 ATH_CHECK(m_tTool.retrieve());
200 }
201 else
202 {
203 ATH_MSG_WARNING("unsupported EfficiencyCorrectionsType with enum " << iEfficiencyCorrectionType);
204 }
205 }
206 return StatusCode::SUCCESS;
207}
208
209//______________________________________________________________________________
211{
212 switch(iLevel)
213 {
214 case JETIDNONE:
215 return "ditaureconstruction";
216 break;
218 return "jetbdtsigveryloose";
219 break;
220 case JETIDBDTLOOSE:
221 return "jetbdtsigloose";
222 break;
223 case JETIDBDTMEDIUM:
224 return "jetbdtsigmedium";
225 break;
226 case JETIDBDTTIGHT:
227 return "jetbdtsigtight";
228 break;
229 default:
230 assert(false && "No valid ID level passed. Breaking up ...");
231 break;
232 }
233 return "";
234}
235
236
237} // namespace TauAnalysisTools
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Efficiency scale factors and uncertainties for ditau jets.
static const char *const sSharedFilesVersion
Version of the calibration files.
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
StatusCode beginEvent()
Function called when a new events is loaded.
virtual StatusCode initialize()
Function initialising the tool.
StatusCode initializeTools_2017_moriond()
Initialize Moriond 2017 recommendations.
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
apply systematic variations
ToolHandle< IDiTauEfficiencyCorrectionsTool > m_tTool
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::DiTauJet &xDiTau, double &eff)
Get the ditau Efficiency Scale Factor as a return value.
DiTauEfficiencyCorrectionsTool(const std::string &sName)
Create a proper constructor for Athena.
virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::DiTauJet &xDiTau)
decorate the ditau jet with eff scale factor
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
returns whether this tool is affected by the given systematic
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
Gaudi::Property< std::vector< int > > m_vEfficiencyCorrectionTypes
virtual CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
virtual void printConfig() const
Print tool configuration.
AsgMetadataTool(const std::string &name)
Normal ASG tool constructor with a name.
an object that can create a AsgTool
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_SIMULATION
true: simulation, false: data
EventInfo_v1 EventInfo
Definition of the latest event info version.
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition DiTauJet.h:17