ATLAS Offline Software
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>
11 using std::cout;
12 using std::cerr;
13 using 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 //________________________________________________________________________________
42 {}
43 
44 //================ calibration names =============================================
45 
46 //________________________________________________________________________________
47 const 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 
68  m_calibrationEffNames = names;
69 }
70 
71 //________________________________________________________________________________
72 const 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 //________________________________________________________________________________
87 void Analysis::CalibrationDataInterfaceBase::setSFCalibrationNames(const std::map<std::string, std::string>& names)
88 {
89  // Set the efficiency scale factor calibration names.
90 
91  m_calibrationSFNames = names;
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 //________________________________________________________________________________
117 std::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 //________________________________________________________________________________
138 std::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 //________________________________________________________________________________
146 double
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 }
Analysis::CalibrationDataInterfaceBase::EffCalibrationName
const std::string & EffCalibrationName(const std::string &flavour, unsigned int mapIndex=0) const
Main interface methods accessing the flavour tagging performance information.
Definition: CalibrationDataInterfaceBase.cxx:47
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Analysis::CalibrationDataInterfaceBase
Definition: CalibrationDataInterfaceBase.h:47
ClassImp
ClassImp(Analysis::CalibrationDataInterfaceBase) Analysis
Definition: CalibrationDataInterfaceBase.cxx:31
TRT_PAI_gasdata::SF
const float SF[NF]
Cross sections for Fluor.
Definition: TRT_PAI_gasdata.h:285
Analysis::CalibrationDataInterfaceBase::~CalibrationDataInterfaceBase
virtual ~CalibrationDataInterfaceBase()=0
default destructor
Definition: CalibrationDataInterfaceBase.cxx:41
Analysis::CalibrationDataInterfaceBase::SFCalibrationName
const std::string & SFCalibrationName(const std::string &flavour) const
Definition: CalibrationDataInterfaceBase.cxx:72
MakeFileForReductions.largest
float largest
Definition: MakeFileForReductions.py:95
Analysis::CalibrationDataInterfaceBase::CalibrationDataInterfaceBase
CalibrationDataInterfaceBase()
Analysis::CalibrationDataInterfaceBase::combinedUncertainty
double combinedUncertainty(double stat, const std::pair< double, double > &syst) const
utility function for combination of statistical and (a priori asymmetric) systematic uncertainty.
Definition: CalibrationDataInterfaceBase.cxx:147
python.subdetectors.mmg.names
names
Definition: mmg.py:8
beamspotman.stat
stat
Definition: beamspotman.py:266
Analysis::CalibrationDataInterfaceBase::setEffCalibrationNames
void setEffCalibrationNames(const std::map< std::string, std::vector< std::string > > &names)
Definition: CalibrationDataInterfaceBase.cxx:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Analysis::CalibrationDataInterfaceBase::getContainername
std::string getContainername(const std::string &flavour, bool SF, unsigned int mapIndex=0) const
auxiliary function for retrieval of container name
Definition: CalibrationDataInterfaceBase.cxx:118
Analysis::CalibrationDataInterfaceBase::setSFCalibrationNames
void setSFCalibrationNames(const std::map< std::string, std::string > &names)
Definition: CalibrationDataInterfaceBase.cxx:87
CalibrationDataInterfaceBase.h
Analysis::CalibrationDataInterfaceBase::getBasename
std::string getBasename(const std::string &name) const
auxiliary function for retrieval of name within the directory
Definition: CalibrationDataInterfaceBase.cxx:138