ATLAS Offline Software
Loading...
Searching...
No Matches
TauSmearingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
8
9// Local include(s):
12
14
15namespace TauAnalysisTools
16{
17
18TauSmearingTool::TauSmearingTool( const std::string& sName )
19 : asg::AsgMetadataTool( sName )
20{}
21
24
26{
27 ATH_MSG_INFO( "Initializing TauSmearingTool" );
28
30 ATH_MSG_WARNING("Truth match check will be skipped. This is ONLY FOR TESTING PURPOSE!");
31
32 if (m_sInputFilePath.empty()) {
33 std::string sDirectory = "TauAnalysisTools/" + std::string(sSharedFilesVersion) + "/Smearing/";
34
35 if(m_sRecommendationTag == "2025-prerec") {
36
37 if (m_sCampaign!="mc23" && m_sCampaign!="mc20"){
38 ATH_MSG_ERROR("unknown campaign (mc20|mc23):" << m_sCampaign);
39 return StatusCode::FAILURE;
40 }
41
42 if(m_useFastSim) {
43 ATH_MSG_WARNING("No fast-sim recommendation for tau smearing is available, using full sim");
44 }
45
46
47 if(m_useGNTau){
48 if (m_sCampaign=="mc23") {
49 m_sInputFilePath = sDirectory+"TES_TrueHadTau_GNTau_mc23_v0.root";
50 } else {
51 ATH_MSG_ERROR("Tau Smearing recommendations with GNTau are not available for "<< m_sCampaign);
52 }
53 } else {
54 if (m_sCampaign=="mc23") {
55 m_sInputFilePath = sDirectory+"TES_TrueHadTau_RNN_mc23_v3.root";
56 } else {
57 m_sInputFilePath = sDirectory+"TES_TrueHadTau_RNN_mc20_v2.root";
58 }
59 }
60
61 } else {
62 ATH_MSG_ERROR("unknown recommendation tag " << m_sRecommendationTag);
63 return StatusCode::FAILURE;
64 }
65 }
66
67 if (m_tCommonSmearingTool.empty()){
68 asg::AsgToolConfig config("TauAnalysisTools::CommonSmearingTool/TauSmearingTool");
69 ATH_CHECK(config.setProperty("InputFilePath", m_sInputFilePath));
70 ATH_CHECK(config.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
71 ATH_CHECK(config.setProperty("ApplyFading", m_bApplyFading));
72 ATH_CHECK(config.setProperty("MVATESQualityCheck", m_bMVATESQualityCheck));
73 ATH_CHECK(config.setProperty("ApplyInsituCorrection", m_bApplyInsituCorrection));
74 ATH_CHECK(config.setProperty("OutputLevel", this->msg().level()));
75 ATH_CHECK(config.makePrivateTool(m_tCommonSmearingTool));
76 }
78
79
80 // Add the affecting systematics to the global registry
82 if (!registry.registerSystematics(*this)) {
83 ATH_MSG_ERROR ("Unable to register the systematics");
84 return StatusCode::FAILURE;
85 }
86
87 return StatusCode::SUCCESS;
88}
89
90// auto detection of simulation flavour, used to cross check configuration of tool
91//______________________________________________________________________________
93{
94 if (inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) {
95 const xAOD::FileMetaData* fmd = nullptr;
96 ATH_CHECK( inputMetaStore()->retrieve( fmd, "FileMetaData" ) );
97 std::string simType("");
98 bool result = fmd->value( xAOD::FileMetaData::simFlavour , simType );
99 // if no result -> no simFlavor metadata, so must be data
100 if(result) std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
101
102 if( simType.find("ATLFAST3") != std::string::npos && !m_useFastSim){
103 ATH_MSG_WARNING("Input file is AF3 sample but you are _not_ using AF3 corrections and uncertainties, you should set \"useFastSim\" to \"true\"");
104 } else if (simType.find("FULLG4")!=std::string::npos && m_useFastSim){
105 ATH_MSG_WARNING("Input file is full simulation but you are using AF3 corrections and uncertainties, you should set \"useFastSim\" to \"false\"");
106 }
107 }
108
109 return StatusCode::SUCCESS;
110}
111
113{
114 return m_tCommonSmearingTool->applyCorrection(xTau);
115}
116
118{
119 return m_tCommonSmearingTool->correctedCopy(input, output);
120}
121
124{
125 return m_tCommonSmearingTool->isAffectedBySystematic( systematic );
126}
127
130{
131 return m_tCommonSmearingTool->affectingSystematics();
132}
133
136{
137 return m_tCommonSmearingTool->recommendedSystematics();
138}
139
141{
142 return m_tCommonSmearingTool->applySystematicVariation( sSystematicSet );
143}
144
145
146} // namespace TauAnalysisTools
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
static const char *const sSharedFilesVersion
Version of the calibration files.
Return value from object correction CP tools.
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.
ToolHandle< ITauSmearingTool > m_tCommonSmearingTool
virtual CP::CorrectionCode applyCorrection(xAOD::TauJet &xTau) const
Apply the correction on a modifyable object.
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
virtual StatusCode beginInputFile()
Function called when a new input file is opened.
virtual CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
virtual StatusCode initialize()
Function initialising the tool.
Gaudi::Property< bool > m_bMVATESQualityCheck
Gaudi::Property< std::string > m_sRecommendationTag
virtual CP::CorrectionCode correctedCopy(const xAOD::TauJet &input, xAOD::TauJet *&output) const
Create a corrected copy from a constant tau.
TauSmearingTool(const std::string &sName)
Create a proper constructor for Athena.
Gaudi::Property< std::string > m_sInputFilePath
Gaudi::Property< bool > m_bApplyFading
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematis
Gaudi::Property< bool > m_bApplyInsituCorrection
Gaudi::Property< std::string > m_sCampaign
Gaudi::Property< bool > m_useFastSim
Gaudi::Property< bool > m_bSkipTruthMatchCheck
Gaudi::Property< bool > m_useGNTau
AsgMetadataTool(const std::string &name)
Normal ASG tool constructor with a name.
MetaStorePtr_t inputMetaStore() const
Accessor for the input metadata store.
an object that can create a AsgTool
@ simFlavour
Fast or Full sim [string].
bool value(MetaDataType type, std::string &val) const
Get a pre-defined string value out of the object.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17
FileMetaData_v1 FileMetaData
Declare the latest version of the class.