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
20
21namespace TauAnalysisTools
22{
23
24//______________________________________________________________________________
26 : asg::AsgMetadataTool( sName )
28 , m_bIsData(false)
29 , m_bIsConfigured(false)
30{
31}
32
33//______________________________________________________________________________
39
40
41//______________________________________________________________________________
43{
44 // Greet the user:
45 ATH_MSG_INFO( "Initializing DiTauEfficiencyCorrectionsTool" );
46
48 ATH_MSG_WARNING("Truth match check will be skipped. This is ONLY FOR TESTING PURPOSE!");
49
50 if (m_sRecommendationTag == "2017-moriond")
52 else
53 {
54 ATH_MSG_FATAL("Unknown RecommendationTag: "<<m_sRecommendationTag);
55 return StatusCode::FAILURE;
56 }
57
58 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
59 {
60 ATH_CHECK((**it).setProperty("OutputLevel", this->msg().level()));
61 ATH_CHECK((**it).initialize());
62 }
63
64 // Add the affecting systematics to the global registry
66 if (!registry.registerSystematics(*this))
67 {
68 ATH_MSG_ERROR ("Unable to register the systematics");
69 return StatusCode::FAILURE;
70 }
71
73
74 return StatusCode::SUCCESS;
75}
76
77
78//______________________________________________________________________________
80{
81 if (!m_bIsConfigured)
82 {
83 const xAOD::EventInfo* xEventInfo = nullptr;
84 ATH_CHECK(evtStore()->retrieve(xEventInfo,"EventInfo"));
86 m_bIsConfigured = true;
87 }
88
89 return StatusCode::SUCCESS;
90}
91
92
93//______________________________________________________________________________
95{
96 ATH_MSG_DEBUG( "DiTauEfficiencyCorrectionsTool with name " << name() << " is configured as follows:" );
97 for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes) {
98 ATH_MSG_DEBUG( " EfficiencyCorrectionTypes " << iEfficiencyCorrectionType );
99 }
100 ATH_MSG_DEBUG( " InputFilePathJetIDHadTau " << m_sInputFilePathJetIDHadTau );
101 ATH_MSG_DEBUG( " VarNameJetIDHadTau " << m_sVarNameJetIDHadTau );
102 ATH_MSG_DEBUG( " RecommendationTag " << m_sRecommendationTag );
103}
104
105//______________________________________________________________________________
107 double& eff )
108{
109 eff = 1.;
110
111 if (m_bIsData)
113
114 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
115 {
116 double dToolEff = 1.;
117 CP::CorrectionCode tmpCorrectionCode = (**it)->getEfficiencyScaleFactor(xDiTau, dToolEff);
118 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
119 return tmpCorrectionCode;
120 eff *= dToolEff;
121 }
123}
124
125//______________________________________________________________________________
127{
128 if (m_bIsData)
130
131 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
132 {
133 CP::CorrectionCode tmpCorrectionCode = (**it)->applyEfficiencyScaleFactor(xDiTau);
134 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
135 {
136 return tmpCorrectionCode;
137 }
138 }
140}
141
143//______________________________________________________________________________
145{
146 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
147 if ((**it)->isAffectedBySystematic(systematic))
148 return true;
149 return false;
150}
151
153//______________________________________________________________________________
155{
156 CP::SystematicSet sAffectingSystematics;
157 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
158 sAffectingSystematics.insert((**it)->affectingSystematics());
159 return sAffectingSystematics;
160}
161
163//______________________________________________________________________________
165{
166 CP::SystematicSet sRecommendedSystematics;
167 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
168 {
169 sRecommendedSystematics.insert((**it)->recommendedSystematics());
170 }
171 return sRecommendedSystematics;
172}
173
174//______________________________________________________________________________
176{
177 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
178 if ((**it)->applySystematicVariation(sSystematicSet) == StatusCode::FAILURE)
179 {
180 return StatusCode::FAILURE;
181 }
182 return StatusCode::SUCCESS;
183}
184
185//=================================PRIVATE-PART=================================
186
187//______________________________________________________________________________
189{
190 std::string sDirectory = "TauAnalysisTools/" + std::string(sSharedFilesVersion) + "/EfficiencyCorrections/";
191 for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes)
192 {
193 if (iEfficiencyCorrectionType == SFJetIDHadTau)
194 {
195 // only set vars if they have been configured by the user
196 if (m_sInputFilePathJetIDHadTau.empty()) {
197 sDirectory = "TauAnalysisTools/00-04-00/EfficiencyCorrections/";
198 m_sInputFilePathJetIDHadTau = sDirectory+"JetID_TrueHadDiTau_2017-fall.root";
199 }
200 if (m_sVarNameJetIDHadTau.empty()) m_sVarNameJetIDHadTau = "DiTauScaleFactorJetIDHadTau";
201
203 m_vCommonEfficiencyTools.push_back(tTool);
205 ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathJetIDHadTau));
206 ATH_CHECK(tTool->setProperty("VarName", m_sVarNameJetIDHadTau));
207 ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
208 ATH_CHECK(tTool->setProperty("WP", ConvertJetIDToString(m_iJetIDLevel)));
209 }
210 else
211 {
212 ATH_MSG_WARNING("unsupported EfficiencyCorrectionsType with enum " << iEfficiencyCorrectionType);
213 }
214 }
215 return StatusCode::SUCCESS;
216}
217
218//______________________________________________________________________________
220{
221 switch(iLevel)
222 {
223 case JETIDNONE:
224 return "ditaureconstruction";
225 break;
227 return "jetbdtsigveryloose";
228 break;
229 case JETIDBDTLOOSE:
230 return "jetbdtsigloose";
231 break;
232 case JETIDBDTMEDIUM:
233 return "jetbdtsigmedium";
234 break;
235 case JETIDBDTTIGHT:
236 return "jetbdtsigtight";
237 break;
238 default:
239 assert(false && "No valid ID level passed. Breaking up ...");
240 break;
241 }
242 return "";
243}
244
245
246} // namespace TauAnalysisTools
#define ASG_MAKE_ANA_TOOL(handle, type)
create the tool in the given tool handle
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(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.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
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.
std::vector< asg::AnaToolHandle< IDiTauEfficiencyCorrectionsTool > * > m_vCommonEfficiencyTools
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
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.
a modified tool handle that allows its owner to configure new tools from the C++ side
AsgMetadataTool(const std::string &name)
Normal ASG tool constructor with a name.
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