ATLAS Offline Software
Loading...
Searching...
No Matches
CalibrationDataInterfaceBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7
8#include "TMath.h"
9
10#include <iostream>
11using std::cout;
12using std::cerr;
13using std::endl;
14
16// //
17// CalibrationDataInterfaceBase //
18// //
19// This is the base class for user-level b-tagging calibration information. //
20// It is a left-over of the aim for commonality between Athena access (through the //
21// deprecated CalibrationDataInterfaceTool class) and stand-alone (framework independent) //
22// access as provided by the CalibrationDataInterfaceROOT class. //
23// //
24// The only functionality provided at present is that of maintaining the list of //
25// calibration object names to be used in physics analyses. //
26// //
27// CalibrationDataInterfaceBase.cxx, (c) ATLAS Detector software //
29
30#ifndef __CINT__
32#endif
33
34//________________________________________________________________________________
36{}
37
38//================ Destructor ==================================================
39
40//________________________________________________________________________________
43
44//================ calibration names =============================================
45
46//________________________________________________________________________________
47const std::string& Analysis::CalibrationDataInterfaceBase::EffCalibrationName(const std::string& flavour,
48 unsigned int mapIndex) const
49{
50 // Return the MC efficiency name for the given flavour.
51 // Note that no check is performed on the validity of the flavour.
52
53 try {
54 return m_calibrationEffNames.at(flavour)[mapIndex];
55 }
56 catch (const std::out_of_range& e) {
57 std::cerr << "EffCalibrationName: flavour '" << flavour << "' is not known." << std::endl;
58 throw e;
59 }
60}
61
62//________________________________________________________________________________
64 std::vector<std::string> >& names)
65{
66 // Set the MC efficiency names.
67
69}
70
71//________________________________________________________________________________
72const std::string& Analysis::CalibrationDataInterfaceBase::SFCalibrationName(const std::string& flavour) const
73{
74 // Return the efficiency scale factor calibration name for the given flavour.
75 // Note that no check is performed on the validity of the flavour.
76
77 try {
78 return m_calibrationSFNames.at(flavour);
79 }
80 catch (const std::out_of_range& e) {
81 std::cerr << "SFCalibrationName: flavour '" << flavour << "' is not known." << std::endl;
82 throw e;
83 }
84}
85
86//________________________________________________________________________________
87void Analysis::CalibrationDataInterfaceBase::setSFCalibrationNames(const std::map<std::string, std::string>& names)
88{
89 // Set the efficiency scale factor calibration names.
90
92}
93
94// //________________________________________________________________________________
95// std::string
96// Analysis::CalibrationDataInterfaceBase::getBasename (const std::string& OP,
97// const std::string& flavour,
98// const std::string& extra,
99// bool SF, unsigned int mapIndex) const
100// {
101// // Construct the full pathname corresponding to the container indicated by the combination
102// // of tagging operating point, jet flavour, and a possible extra extension. The calibration
103// // container name (stored internally) is also attached.
104
105// std::string basename(OP);
106// basename += "/";
107// basename += (flavour == "N/A") ? "Light" : flavour;
108// basename += "/";
109// // future: use map<>::find
110// basename += SF ? m_calibrationSFNames[flavour] : m_calibrationEffNames[flavour][mapIndex];
111// basename += extra;
112
113// return basename;
114// }
115
116//________________________________________________________________________________
117std::string
119 bool SF, unsigned int mapIndex) const
120{
121 // Construct the full pathname corresponding to the container indicated by the combination
122 // of tagging operating point, jet flavour, and a possible extra extension. The calibration
123 // container name (stored internally) is also attached.
124
125 const std::vector<std::string>& effNames = m_calibrationEffNames.at(flavour);
126 if (!SF && mapIndex >= effNames.size()) {
127 std::cerr << "getContainername: given mapIndex=" << mapIndex << " incompatible with array size "
128 << effNames.size() << "; resetting to 0" << std::endl;
129 mapIndex = 0;
130 }
131 std::string name = SF ? m_calibrationSFNames.at(flavour) : effNames[mapIndex];
132 name += SF ? "_SF" : "_Eff";
133
134 return name;
135}
136
137//________________________________________________________________________________
138std::string Analysis::CalibrationDataInterfaceBase::getBasename (const std::string& name) const
139{
140 // Retrieve the name within the directory starting from the full name
141
142 return name.substr(name.find_last_of('/')+1, std::string::npos);
143}
144
145//________________________________________________________________________________
146double
148 const std::pair<double, double>& syst) const
149{
150 // Return the total (combined statistical and systematic) uncertainty started from
151 // its individual components. The result is symmetrised by using only the larger of
152 // the (a priori asymmetric) up- and downward systematic uncertainties.
153
154 // The systematic uncertainty is (a priori) asymmetric, but this interface doesn't
155 // at present allow for asymmetric uncertainties.
156 // Address this by taking the larger (absolute) value of the two.
157 double largest = syst.first;
158 if (TMath::Abs(syst.second) > TMath::Abs(largest)) largest = syst.second;
159
160 return TMath::Sqrt(stat*stat + largest*largest);
161}
ClassImp(Analysis::CalibrationDataInterfaceBase) Analysis
This class provides some common functionality for other classes wishing to access Flavour Tagging per...
std::map< std::string, std::vector< std::string > > m_calibrationEffNames
this simply collects the per-flavour properties.
const std::string & SFCalibrationName(const std::string &flavour) const
void setEffCalibrationNames(const std::map< std::string, std::vector< std::string > > &names)
std::string getContainername(const std::string &flavour, bool SF, unsigned int mapIndex=0) const
auxiliary function for string concatenation
void setSFCalibrationNames(const std::map< std::string, std::string > &names)
const std::string & EffCalibrationName(const std::string &flavour, unsigned int mapIndex=0) const
Main interface methods accessing the flavour tagging performance information.
virtual ~CalibrationDataInterfaceBase()=0
default destructor
std::string getBasename(const std::string &name) const
auxiliary function for retrieval of name within the directory
std::map< std::string, std::string > m_calibrationSFNames
double combinedUncertainty(double stat, const std::pair< double, double > &syst) const
utility function for combination of statistical and (a priori asymmetric) systematic uncertainty.