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
13namespace TauAnalysisTools
14{
15
16TauSmearingTool::TauSmearingTool( const std::string& sName )
17 : asg::AsgMetadataTool( sName )
18 , m_tCommonSmearingTool(sName+"_CommonSmearingTool", this)
19{}
20
23
25{
26 ATH_MSG_INFO( "Initializing TauSmearingTool" );
27
29 ATH_MSG_WARNING("Truth match check will be skipped. This is ONLY FOR TESTING PURPOSE!");
30
31 if (m_sInputFilePath.empty()) {
32 std::string sDirectory = "TauAnalysisTools/" + std::string(sSharedFilesVersion) + "/Smearing/";
33
34 if(m_sRecommendationTag == "2025-prerec") {
35
36 if (m_sCampaign!="mc23" && m_sCampaign!="mc20"){
37 ATH_MSG_ERROR("unknown campaign (mc20|mc23):" << m_sCampaign);
38 return StatusCode::FAILURE;
39 }
40
41 if(m_useFastSim) {
42 ATH_MSG_WARNING("No fast-sim recommendation for tau smearing is available, using full sim");
43 }
44
45 if (m_sCampaign=="mc23") {
46 m_sInputFilePath = sDirectory+"TES_TrueHadTau_RNN_mc23_v1.root";
47 } else {
48 m_sInputFilePath = sDirectory+"TES_TrueHadTau_RNN_mc20_v1.root";
49 }
50
51 } else if (m_sRecommendationTag == "2022-prerec") {
52
53 ATH_MSG_WARNING("2022-prerec tag are pre-recommendations superseeded by 2025-prerec");
54
55 if (m_sCampaign!="mc21" && m_sCampaign!="mc20"){
56 ATH_MSG_ERROR("unknown campaign (mc20|mc21):" << m_sCampaign);
57 return StatusCode::FAILURE;
58 }
59
60 if (m_sGenerator!="PoPy" && m_sCampaign!="Sherpa"){
61 ATH_MSG_ERROR("unknown generator tag (PoPy|Sherpa):" << m_sCampaign);
62 return StatusCode::FAILURE;
63 }
64
65 if(m_useFastSim) {
66 ATH_MSG_WARNING("No fast-sim recommendation for tau smearing is available, using full sim");
67 }
68
69 if (m_sGenerator == "PoPy" && m_sCampaign=="mc20") m_sInputFilePath = sDirectory+"TES_TrueHadTau_PoPy8_mc20-prerec_v2.root";
70 if (m_sCampaign=="mc21") {
71 m_sInputFilePath = sDirectory+"TES_TrueHadTau_PoPy8_mc21-prerec_v2.root";
72 if (m_sGenerator=="Sherpa")ATH_MSG_WARNING("No Sherpa mc21 recommendations available yet, using PoPy8!");
73 }
74 if (m_sGenerator == "Sherpa" && m_sCampaign=="mc20") m_sInputFilePath = sDirectory+"TES_TrueHadTau_Sherpa2211-prerec_v2.root";
75 }
76 else {
77 ATH_MSG_ERROR("unknown recommendation tag " << m_sRecommendationTag);
78 return StatusCode::FAILURE;
79 }
80 }
82 ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath));
83 ATH_CHECK(m_tCommonSmearingTool.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
84 ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyFading", m_bApplyFading));
85 ATH_CHECK(m_tCommonSmearingTool.setProperty("MVATESQualityCheck", m_bMVATESQualityCheck));
86 ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyInsituCorrection", m_bApplyInsituCorrection));
87 ATH_CHECK(m_tCommonSmearingTool.setProperty("OutputLevel", this->msg().level()));
88 ATH_CHECK(m_tCommonSmearingTool.initialize());
89
90 // Add the affecting systematics to the global registry
92 if (!registry.registerSystematics(*this)) {
93 ATH_MSG_ERROR ("Unable to register the systematics");
94 return StatusCode::FAILURE;
95 }
96
97 return StatusCode::SUCCESS;
98}
99
100// auto detection of simulation flavour, used to cross check configuration of tool
101//______________________________________________________________________________
103{
104 if (inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) {
105 const xAOD::FileMetaData* fmd = nullptr;
106 ATH_CHECK( inputMetaStore()->retrieve( fmd, "FileMetaData" ) );
107 std::string simType("");
108 bool result = fmd->value( xAOD::FileMetaData::simFlavour , simType );
109 // if no result -> no simFlavor metadata, so must be data
110 if(result) std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
111
112 if( simType.find("ATLFAST3") != std::string::npos && !m_useFastSim){
113 ATH_MSG_WARNING("Input file is AF3 sample but you are _not_ using AF3 corrections and uncertainties, you should set \"useFastSim\" to \"true\"");
114 } else if (simType.find("FULLG4")!=std::string::npos && m_useFastSim){
115 ATH_MSG_WARNING("Input file is full simulation but you are using AF3 corrections and uncertainties, you should set \"useFastSim\" to \"false\"");
116 }
117 }
118
119 return StatusCode::SUCCESS;
120}
121
123{
124 return m_tCommonSmearingTool->applyCorrection(xTau);
125}
126
128{
129 return m_tCommonSmearingTool->correctedCopy(input, output);
130}
131
134{
135 return m_tCommonSmearingTool->isAffectedBySystematic( systematic );
136}
137
140{
141 return m_tCommonSmearingTool->affectingSystematics();
142}
143
146{
147 return m_tCommonSmearingTool->recommendedSystematics();
148}
149
151{
152 return m_tCommonSmearingTool->applySystematicVariation( sSystematicSet );
153}
154
155
156} // 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_INFO(x)
#define ATH_MSG_WARNING(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.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
asg::AnaToolHandle< 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.
Gaudi::Property< std::string > m_sGenerator
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
AsgMetadataTool(const std::string &name)
Normal ASG tool constructor with a name.
MetaStorePtr_t inputMetaStore() const
Accessor for the input metadata store.
@ 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:114
TauJet_v3 TauJet
Definition of the current "tau version".
FileMetaData_v1 FileMetaData
Declare the latest version of the class.