13{
14
15TauResolutionTool::TauResolutionTool( const std::string& sName )
16 :
asg::AsgMetadataTool( sName )
17{}
18
19TauResolutionTool::~TauResolutionTool()
20{}
21
23{
25
26
28 std::unique_ptr<TFile> calFile(TFile::Open(calFilePath.c_str(), "READ"));
30
31
32 TGraph* graph = nullptr;
33 std::string graphName="";
34 for (size_t decayModeIndex = 0; decayModeIndex < DecayModeBinning; ++decayModeIndex) {
36
37
38 graphName =
"tauRec/Graph_from_ResolutionEt_tauRec_" + m_decayModeNames[decayModeIndex] +
"_" + m_etaBinNames[
etaIndex];
39 graph = dynamic_cast<TGraph*> (calFile->Get(graphName.c_str()));
40 if(graph){
41 m_caloResMaxEt[decayModeIndex][
etaIndex] = TMath::MaxElement(graph->GetN(), graph->GetX());
42 m_caloRes[decayModeIndex][
etaIndex] = std::unique_ptr<TGraph>(graph);
44 }
45 else {
46 ATH_MSG_FATAL(
"Failed to get an object with name " << graphName);
47 return StatusCode::FAILURE;
48 }
49
50 graphName = "FinalCalib/Graph_from_ResolutionEt_FinalCalib_" + m_decayModeNames[decayModeIndex] + "_" + m_etaBinNames.at(etaIndex);
51 graph = dynamic_cast<TGraph*> (calFile->Get(graphName.c_str()));
52 if(graph){
53 m_mvaResMaxEt.at(decayModeIndex).at(etaIndex) = TMath::MaxElement(graph->GetN(), graph->GetX());
54 m_mvaRes.at(decayModeIndex).at(etaIndex) = std::unique_ptr<TGraph>(graph);
56 }
57 else {
58 ATH_MSG_FATAL(
"Failed to get an object with name " << graphName);
59 return StatusCode::FAILURE;
60 }
61 }
62 }
63 calFile->Close();
64
65 return StatusCode::SUCCESS;
66}
67
68
69bool TauResolutionTool::isValid(
const xAOD::TauJet& tau)
const {
73 return false;
74 }
75
76 int etaIndex = getEtaIndex(
tau.etaTauEnergyScale());
77 if (etaIndex > 4) {
79 return false;
80 }
81
82 return true;
83}
84
85int TauResolutionTool::getEtaIndex(
float eta)
const {
86 float abseta = std::abs(
eta);
87
88 if (abseta < 0.3) {
89 return 0;
90 }
91 if (abseta < 0.8) {
92 return 1;
93 }
94 if (abseta < 1.3) {
95 return 2;
96 }
97 if (abseta < 1.6) {
98 return 3;
99 }
100 if (abseta < 2.6) {
101 return 4;
102 }
103
104 return 99;
105}
106
110
112}
113
115 return static_cast<int>(decayMode);
116}
117
118double TauResolutionTool::getMvaEnergyResolution(
const xAOD::TauJet& tau)
const {
119
120
122
124 int decayModeIndex = getDecayModeIndex(decayMode);
125
127
128 double pt = std::min(
tau.ptFinalCalib(), m_mvaResMaxEt.at(decayModeIndex).at(etaIndex));
129 double resolution = m_mvaRes.at(decayModeIndex).at(etaIndex)->Eval(pt);
130
132}
133
134double TauResolutionTool::getCaloResolution(
double et,
int decayModeIndex,
int etaIndex)
const {
135 double x = std::min(
et, m_caloResMaxEt.at(decayModeIndex).at(etaIndex));
136 double resolution = m_caloRes.at(decayModeIndex).at(etaIndex)->Eval(
x);
137
139}
140
141bool TauResolutionTool::getTESCompatibility(
const xAOD::TauJet& tau)
const {
142 if (!
isValid(tau))
return false;
143
145 int decayModeIndex = getDecayModeIndex(decayMode);
146
147 int etaIndex = getEtaIndex(
tau.etaTauEnergyScale());
148
149 double caloSigma =
tau.ptTauEnergyScale() * getCaloResolution(
tau.ptTauEnergyScale(), decayModeIndex, etaIndex);
150 double deltaEt =
tau.ptFinalCalib() -
tau.ptTauEnergyScale();
151
152 bool compatibility = true;
153
154 if (std::abs(deltaEt) > 5 * caloSigma) {
155 compatibility = false;
156 }
157
158 return compatibility;
159}
160
161}
Scalar eta() const
pseudorapidity method
bool isValid() const
Test to see if the link can be dereferenced.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
double resolution[nGasTypes][nParametersResolution]
::StatusCode StatusCode
StatusCode definition for legacy code.
uint16_t etaIndex(double eta, bool &inRange)
TauJet_v3 TauJet
Definition of the current "tau version".
Extra patterns decribing particle interation process.