ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Analysis::CalibrationDataMappedHistogramContainer Class Reference

#include <CalibrationDataContainer.h>

Inheritance diagram for Analysis::CalibrationDataMappedHistogramContainer:
Collaboration diagram for Analysis::CalibrationDataMappedHistogramContainer:

Classes

class  Bin
 Helper class for the specification of custom binning. More...
 

Public Types

enum  CalibrationParametrization { kPt = 0, kEta = 1, kAbsEta = 2, kTagWeight = 3 }
 

Public Member Functions

 CalibrationDataMappedHistogramContainer (const char *name="default")
 
virtual ~CalibrationDataMappedHistogramContainer ()
 
virtual CalibrationStatus getResult (const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)
 retrieve the calibration result. More...
 
virtual CalibrationStatus getStatUncertainty (const CalibrationDataVariables &x, double &result)
 retrieve the calibration statistical uncertainty. More...
 
virtual CalibrationStatus getUncertainty (const std::string &unc, const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)
 retrieve the calibration uncertainty due to the given source. More...
 
virtual bool isInterpolated () const
 Indicate whether histogram interpolation is used or not. More...
 
virtual int getTagWeightAxis ()
 Test whether this calibration object is one for "continuous" calibration (this has some subtle consequences for the treatment of bin-to-bin correlations). More...
 
void setMappedVariables (const std::vector< std::string > &variables)
 Set (by hand) the variables that will be mapped onto a single histogram axis. More...
 
std::vector< std::string > getMappedVariables () const
 List which variables get mapped onto a single histogram axis. More...
 
virtual std::vector< double > getBinBoundaries (unsigned int vartype)
 Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametrization enum). More...
 
unsigned int addBin (const Bin &bin)
 Add mapping bin. More...
 
unsigned int getNMappedBins () const
 return the number of mapped bins More...
 
bool isBinCorrelated (const std::string &unc) const
 Indicate whether the given uncertainty is correlated from bin to bin or not (note that this function is to be used only for systematic uncertainties) More...
 
void setUncorrelated (const std::string &unc)
 Indicate that the given uncertainty is to be treated uncorrelated from bin to bin (note that the default is for all systematic uncertainties to be treated as correlated) More...
 
void setInterpolated (bool doInterpolate)
 Indicate whether results are to be interpolated between bins or not (this feature is thought to be useful mostly for MC efficiencies) More...
 
virtual int getEigenvectorReduction (unsigned int choice) const
 Retrieve the number of eigenvectors to be retained for the purpose of eigenvector variation reduction strategies. More...
 
std::vector< std::string > listUncertainties () const
 retrieve the list of "uncertainties" accessible to this object. More...
 
CalibrationStatus getUncertainties (const CalibrationDataVariables &x, std::map< std::string, Analysis::UncertaintyResult > &all)
 retrieve the list of "uncertainties" accessible to this object. More...
 
std::string getComment () const
 retrieve the comments entered for this calibration, if any More...
 
std::string getHadronisation () const
 retrieve the 'hadronisation reference' entered for this calibration, if any More...
 
std::string getExcludedUncertainties () const
 retrieve the (semicolon-separated) set of uncertainties that are recommended for removal from the eigenvector decomposition More...
 
CalibrationStatus getSystUncertainty (const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)
 retrieve the calibration total systematic uncertainty More...
 
void setResult (TObject *obj)
 insert the main object for this calibration More...
 
void setComment (const std::string &text)
 insert the given text as comment for this calibration More...
 
void setHadronisation (const std::string &text)
 insert the given text as the 'hadronisation reference' for this calibration More...
 
void setExcludedUncertainties (const std::string &text)
 insert the set of uncertainties that are recommended for removal from the eigenvector decomposition. More...
 
void setUncertainty (const std::string &unc, TObject *obj)
 insert the relevant object for the requested source of 'uncertainty' More...
 
void restrictToRange (bool restrict)
 If true, this will restrict the variables used to be within the (specified) range of validity. More...
 
bool isRangeRestricted () const
 allow the user to inspect the above information More...
 
double getLowerBound (unsigned int vartype, bool extrapolate=false) const
 retrieve the lower bound of validity for the requested variable type More...
 
double getUpperBound (unsigned int vartype, bool extrapolate=false) const
 retrieve the upper bound of validity for the requested variable type More...
 
std::vector< std::pair< double, double > > getBounds ()
 allow the user to inspect the bounds of validity More...
 
std::vector< unsigned int > getVariableTypes ()
 utility to retrieve variable types
More...
 

Static Public Member Functions

static bool isNearlyEqual (double a, double b)
 utility for comparison of doubles More...
 

Protected Member Functions

int typeFromString (const std::string &key) const
 Connection between variable names (on histogram axes etc.) and variable 'types' as used in actual evaluations. More...
 
CalibrationStatus computeVariables (const CalibrationDataVariables &x, bool extrapolate=false)
 Compute the variables to be used. More...
 

Protected Attributes

std::map< unsigned int, std::vector< double > > m_binBoundaries
 Cache for bin boundary information. More...
 
std::vector< double > m_lowerBounds
 
std::vector< double > m_upperBounds
 
std::vector< double > m_lowerBoundsExtrapolated
 
std::vector< double > m_upperBoundsExtrapolated
 (possibly looser) lower validity bounds for extrapolation More...
 
TObject * m_objResult
 (possibly looser) upper validity bounds for extrapolation More...
 
TObject * m_objSystematics
 don't persistify More...
 
double m_vars [MaxCalibrationVars]
 don't persistify More...
 
std::vector< unsigned int > m_variables
 don't persistify More...
 

Private Member Functions

Int_t findBin ()
 don't persistify More...
 
Int_t findMappedBin (const double *x)
 
void checkBounds ()
 check the bounds of validity for this calibration object More...
 
virtual void computeVariableTypes ()
 decode the 'uncertainty' objects' names to determine the relevant variable types More...
 
 ClassDef (CalibrationDataMappedHistogramContainer, 1)
 
double getInterpolatedResult (TH1 *hist) const
 Retrieve interpolated result (utility function) More...
 
double getInterpolatedUncertainty (TH1 *hist) const
 Retrieve interpolated result (utility function) More...
 

Private Attributes

std::vector< std::string > m_mapped
 mapped variables. More...
 
unsigned int m_beginMapped
 starting position of mapped variables More...
 
std::vector< Binm_bins
 don't persistify More...
 
unsigned int m_lastBin
 
THashList m_uncorrelatedSyst
 no need to persistify More...
 
bool m_interpolate
 If true, interpolate between bins rather than doing a straight bin-wise evaluation. More...
 
bool m_restrict
 persistency not needed for this variable More...
 

Detailed Description

This is the class holding information for histogram-based calibration results, in cases where 'irregular' binning is used (e.g., if the binning in one variable depends on another variable), or where the dimensionality becomes too high for even 3D histograms (so that a mapping is needed to use THx).

Using this class instead of the 'regular' histogram container will imply a performance penalty, as bin numberings are not assumed to feature any regularity.

Definition at line 335 of file CalibrationDataContainer.h.

Member Enumeration Documentation

◆ CalibrationParametrization

The following enums are intended to contain the list of (kinematic or other) variables in terms of which results (and the corresponding uncertainties) are given. They are useful mainly for internal purposes, but the user may access them nevertheless.

Enumerator
kPt 
kEta 
kAbsEta 
kTagWeight 

Definition at line 63 of file CalibrationDataContainer.h.

63  {
64  kPt = 0, // calibrated jet pt
65  kEta = 1, // jet eta
66  kAbsEta = 2, // jet |eta|
67  kTagWeight = 3 // tagging output (relevant for "continuous" calibration)
68  };

Constructor & Destructor Documentation

◆ CalibrationDataMappedHistogramContainer()

Analysis::CalibrationDataMappedHistogramContainer::CalibrationDataMappedHistogramContainer ( const char *  name = "default")

◆ ~CalibrationDataMappedHistogramContainer()

CalibrationDataMappedHistogramContainer::~CalibrationDataMappedHistogramContainer ( )
virtual

Definition at line 1024 of file CalibrationDataContainer.cxx.

1025 {
1026 }

Member Function Documentation

◆ addBin()

unsigned int CalibrationDataMappedHistogramContainer::addBin ( const Bin bin)

Add mapping bin.

The return value is the bin number.

Definition at line 1284 of file CalibrationDataContainer.cxx.

1285 {
1286  // Add a bin to the present list
1287  // Note the absence of a -1 in the return value: this is because ROOT's histogram axes start counting from 1
1288 
1289  m_bins.push_back(bin);
1290  return m_bins.size();
1291 }

◆ checkBounds()

void CalibrationDataMappedHistogramContainer::checkBounds ( )
private

check the bounds of validity for this calibration object

Definition at line 1090 of file CalibrationDataContainer.cxx.

1091 {
1092  // Check the bounds of validity for this calibration object.
1093  // See the CalibrationDataHistogramContainer::checkBounds() method. The difference is
1094  // that the 'mapped' dimensions need to be handled separately (this is carried out by
1095  // looping over the mapped bins and inspecting each bin's validity bounds individually).
1096  // Note that extrapolation uncertainties are not covered at this point.
1097 
1098  const TH1* hist = dynamic_cast<const TH1*>(m_objResult);
1099  if (!hist) {
1100  std::cerr << "in CalibrationDataHistogramContainer::checkBounds(): object type does not derive from TH1" << std::endl;
1101  return;
1102  } else if (hist->GetDimension() + int(m_mapped.size()) - 1 != int(m_variables.size())) {
1103  std::cerr << "in CalibrationDataMappedHistogramContainer::checkBounds(): given number of variable types ("
1104  << m_variables.size() << ") doesn't match (mapped) histogram dimension ("
1105  << hist->GetDimension() + m_mapped.size() - 1 << ")!" << std::endl;
1106  return;
1107  }
1108 
1109  // Carry out the only cross-check that's possible for the binning: check that the dimensionality
1110  // for all bins matches the number of variables specified for the mapping
1111  for (unsigned int bin = 0; bin < m_bins.size(); ++bin)
1112  assert(m_bins[bin].getDimension() == m_mapped.size());
1113 
1114  for (unsigned int t = 0, t2 = 0; int(t) < hist->GetDimension(); ++t) {
1115  const TAxis* axis = 0;
1116  switch (t) {
1117  case 0: axis = hist->GetXaxis(); break;
1118  case 1: axis = hist->GetYaxis(); break;
1119  default: axis = hist->GetZaxis();
1120  }
1121 
1122  // Special case for the mapped dimension: here the only thing that can be done is to
1123  // cycle through all Bins and inspect the boundaries of each bin manually.
1124  if (t == m_beginMapped) {
1125  for (unsigned int mapped = 0; mapped < m_mapped.size(); ++mapped) {
1126  for (unsigned int bin = 0; bin < m_bins.size(); ++bin) {
1127  double amax = m_bins[bin].getUpperBound(mapped), amin = m_bins[bin].getLowerBound(mapped);
1128  if (bin == 0 || amax > m_upperBounds[m_variables[t2]]) m_upperBounds[m_variables[t2]] = amax;
1129  if (bin == 0 || amin < m_lowerBounds[m_variables[t2]]) m_lowerBounds[m_variables[t2]] = amin;
1130  }
1131  ++t2;
1132  }
1133  } else {
1134  // for (unsigned int t = 0; t < m_variables.size(); ++t) {
1135  // if (m_variables[t] > m_upperBounds.size()) {
1136  // std::cerr << "in CalibrationDataHistogramContainer::checkBounds(): variable " << t << "type ("
1137  // << m_variables[t] << "exceeds maximum type number (" << m_upperBounds.size() << ")!"
1138  // << std::endl;
1139  // return;
1140  // }
1141  // }
1142  double amax = axis->GetXmax(), amin = axis->GetXmin();
1143  if (amax < m_upperBounds[m_variables[t2]]) m_upperBounds[m_variables[t2]] = amax;
1144  if (amin > m_lowerBounds[m_variables[t2]]) m_lowerBounds[m_variables[t2]] = amin;
1145  ++t2;
1146  }
1147  }
1148 }

◆ ClassDef()

Analysis::CalibrationDataMappedHistogramContainer::ClassDef ( CalibrationDataMappedHistogramContainer  ,
 
)
private

◆ computeVariables()

CalibrationStatus CalibrationDataContainer::computeVariables ( const CalibrationDataVariables x,
bool  extrapolate = false 
)
protectedinherited

Compute the variables to be used.

Parameters
xuser-supplied (kinematic or other) variables
extrapolateset to "true" for the evaluation of extrapolation uncertainties
Returns
kSuccess, kRange, or kExtrapolatedRange, depending on the kinematic variables

Definition at line 307 of file CalibrationDataContainer.cxx.

308 {
309  // Determine which variables are to be used, and insert them in a separate array (which is only used internally).
310  // The return value is used to indicate whether any input co-ordinate was out of bounds; where a distinction
311  // is made between being outside the extrapolation region (kExtrapolatedRange) or merely the calibration region
312  // (kRange).
313  // The "extrapolate" variable is used to flag whether an extrapolation uncertainty applies
314  // (this should anyway occur only for histogram containers).
315  // This is also the place where any computations are being done (e.g. jet pt values are divided by 1000
316  // to convert them from MeV to GeV).
317 
318  // ensure that the variable types have been computed properly
319  if (m_variables.size() == 0) computeVariableTypes();
320 
321  // also keep track of whether the variables are within bounds
323 
324  // std::cout << "computeVariables(): input jet pt: " << x.jetPt << ", eta " << x.jetEta << ", tag weight " << x.jetTagWeight << std::endl;
325 
326  for (unsigned int var = 0; var < m_variables.size(); ++var) {
327  switch (m_variables[var]) {
328  case kPt:
329  // assume that the input values are given in MeV but the performance calibration in GeV!
330  m_vars[var] = x.jetPt * 0.001;
331  break;
332  case kEta:
333  m_vars[var] = x.jetEta;
334  break;
335  case kAbsEta:
336  m_vars[var] = x.jetEta;
337  if (m_vars[var] < 0) m_vars[var] *= -1.0;
338  break;
339  case kTagWeight:
340  m_vars[var] = x.jetTagWeight;
341  }
343  if (status != kExtrapolatedRange) {
345  // std::cout << "computeVariables(): variable " << var << ", value: " << m_vars[var] << ", setting status to " << status << std::endl;
346  }
347  if (m_restrict) m_vars[var] = getLowerBound(m_variables[var], extrapolate) + rangeEpsilon;
348  } else if (m_vars[var] >= getUpperBound(m_variables[var], extrapolate)) {
349  if (status != kExtrapolatedRange) {
351  // std::cout << "computeVariables(): variable " << var << ", value: " << m_vars[var] << ", extrapolate? " << extrapolate
352  // << ", upper bound: " << getUpperBound(m_variables[var],extrapolate)
353  // << " (extrapolation bound: " << getUpperBound(m_variables[var],true) << "), setting status to " << status << std::endl;
354  }
355  if (m_restrict) m_vars[var] = getUpperBound(m_variables[var], extrapolate) - rangeEpsilon;
356  }
357  }
358 
359  // std::cout << "computeVariables(): output variables: " << m_vars[0] << ", " << m_vars[1] << ", " << m_vars[2] << std::endl;
360 
361  return status;
362 }

◆ computeVariableTypes()

void CalibrationDataMappedHistogramContainer::computeVariableTypes ( )
privatevirtual

decode the 'uncertainty' objects' names to determine the relevant variable types

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 1030 of file CalibrationDataContainer.cxx.

1031 {
1032  // Compute the variable types for this container object.
1033  // The computation differs from that used for the parent CalibrationDataHistogramContainer
1034  // class, as also the 'mapped' variables (the variables that are mapped onto a single histogram
1035  // axis) need to be accounted for properly. This is handled as a special case.
1036 
1037  // cache pointer to central values histogram
1038  if (! m_objResult) m_objResult = GetValue("result");
1039 
1040  // histograms need a special treatment, as the coordinate titles are not actually stored
1041  // with the title itself, but instead moved off to the axis titles...
1042  const TH1* hobj = dynamic_cast<const TH1*>(m_objResult);
1043  if (not hobj){
1044  std::cerr << "in CalibrationDataMappedHistogramContainer::computeVariableTypes(): dynamic cast failed\n";
1045  return;
1046  }
1047 
1048  int dims = hobj->GetDimension();
1049  for (int dim = 0; dim < dims; ++dim) {
1050  const TAxis* axis = 0;
1051  switch (dim) {
1052  case 0: axis = hobj->GetXaxis(); break;
1053  case 1: axis = hobj->GetYaxis(); break;
1054  default: axis = hobj->GetZaxis();
1055  }
1056  std::string var(axis->GetTitle());
1057  if (var == "mapped") {
1058  // Special case: mapped variables, so make sure to specify the original variables (not the mapped ones).
1059  // Note that the code here assumes that the mapping is identical for all objects..
1060  for (unsigned int m = 0; m < m_mapped.size(); ++m) {
1061  int vartype = typeFromString(m_mapped[m]);
1062  // this check should never fail; therefore, bail out if this does happen
1063  assert (! (vartype < 0));
1064  m_variables.push_back((unsigned int)vartype);
1065  }
1066  // In this case, also flag _where_ in the resulting list of variables the mapping starts
1067  m_beginMapped = dim;
1068  } else {
1069  int vartype = typeFromString(var);
1070  if (vartype < 0) {
1071  // Only flag the issue but otherwise take no action (assume non-argument use of a semicolon)
1072  std::cerr << "in CalibrationDataMappedHistogramContainer::computeVariableTypes(): cannot construct variable type from name "
1073  << var << std::endl;
1074  } else {
1075  m_variables.push_back((unsigned int)vartype);
1076  }
1077  }
1078  }
1079 
1080  // After doing this, we should always have a non-null vector!
1081  assert(m_variables.size() > 0);
1082 
1083  // Also compute the validity bounds for this calibration object
1085 }

◆ findBin()

Int_t CalibrationDataMappedHistogramContainer::findBin ( )
private

don't persistify

find the bin number corresponding to the input variables

Definition at line 1326 of file CalibrationDataContainer.cxx.

1327 {
1328  // Find the bin corresponding to the computed variables (the computation is assumed to have just
1329  // taken place and resulted in the m_vars array having been filled appropriately)
1330 
1331  Int_t mapped[3] = {0};
1332  const TH1* hist = dynamic_cast<const TH1*>(m_objResult);
1333  if (not hist){
1334  std::cerr << "CalibrationDataMappedHistogramContainer::findBin(): dynamic cast failed\n";
1335  return 0;
1336  }
1337  Int_t ndim = hist->GetDimension();
1338  // Push the mapped variables onto an array.
1339  // Since we derive from TH1 this need never be more than 3 elements long.
1340  for (unsigned int dim = 0; dim < (unsigned int) ndim; ++dim) {
1341  if (dim == m_beginMapped) {
1342  if ((mapped[dim] = findMappedBin(&(m_vars[dim]))) < 0) return -1;
1343  } else {
1344  const TAxis* axis = 0;
1345  switch (dim) {
1346  case 0: axis = hist->GetXaxis(); break;
1347  case 1: axis = hist->GetYaxis(); break;
1348  default: axis = hist->GetZaxis();
1349  }
1350  mapped[dim] = axis->FindFixBin((dim < m_beginMapped) ? m_vars[dim] : m_vars[dim+m_mapped.size()-1]);
1351  }
1352  }
1353  return hist->GetBin(mapped[0], mapped[1], mapped[2]);
1354 }

◆ findMappedBin()

Int_t CalibrationDataMappedHistogramContainer::findMappedBin ( const double *  x)
private

Definition at line 1305 of file CalibrationDataContainer.cxx.

1306 {
1307  // Find the mapped bin corresponding to the variables used for the mapping
1308 
1309  if (m_bins[m_lastBin].contains(x)) return m_lastBin + 1; // First check quickly whether the last bin (cached) matches
1310 
1311  // Search the whole array for a match
1312  for (unsigned int bin = 0; bin < m_bins.size(); ++bin)
1313  if (m_bins[bin].contains(x)) {
1314  m_lastBin = bin;
1315  return m_lastBin + 1;
1316  }
1317  std::cerr << "CalibrationDataMappedHistogramContainer::findMappedBin(): unable to find bin for mapping variables:";
1318  for (unsigned int d = 0; d < m_mapped.size(); ++d) std::cerr << "\t" << x[d];
1319  std::cerr << std::endl;
1320  // -1 means invalid..
1321  return -1;
1322 }

◆ getBinBoundaries()

std::vector< double > CalibrationDataMappedHistogramContainer::getBinBoundaries ( unsigned int  vartype)
virtual

Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametrization enum).

An empty vector will be returned if the specified variable is not actually used.

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 1358 of file CalibrationDataContainer.cxx.

1359 {
1360  // Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametrization enum).
1361  // An empty vector will be returned if the specified variable is not actually used.
1362 
1363  // Ensure that the variable types have been computed at this point
1364  if (m_variables.size() == 0) computeVariableTypes();
1365 
1366  // use cached information if available
1367  std::map<unsigned int, std::vector<double> >::iterator it = m_binBoundaries.find(vartype);
1368  if (it != m_binBoundaries.end()) return it->second;
1369 
1370  // Check whether the variable type is actually being used
1371  std::vector<double> boundaries;
1372  int var = -1;
1373  for (unsigned int v = 0; v < m_variables.size(); ++v)
1374  if (m_variables[v] == vartype) var = (int) v;
1375  if (var == -1) return boundaries;
1376 
1377  // Retrieve the appropriate histogram axis
1378  if (! m_objResult) m_objResult = GetValue("result");
1379  const TH1* hobj = dynamic_cast<const TH1*>(m_objResult);
1380 
1381  if (var >= int(m_beginMapped) && var < int(m_beginMapped + m_mapped.size())) {
1382  // Special case of a mapped variable. In this case, test all Bins for their boundaries
1383  unsigned int mapped = var - m_beginMapped;
1384  for (unsigned int bin = 0; bin < m_bins.size(); ++bin) {
1385  double binBoundaries[2];
1386  binBoundaries[0] = m_bins[bin].getLowerBound(mapped);
1387  binBoundaries[1] = m_bins[bin].getUpperBound(mapped);
1388  // Insert the bin boundaries, if not already present (the test is whether the relative difference
1389  // is smaller than 1e-8)
1390  if (boundaries.size() == 0) {
1391  boundaries.push_back(binBoundaries[0]); boundaries.push_back(binBoundaries[1]);
1392  } else {
1393  for (unsigned int ib = 0; ib < 2; ++ib) {
1394  double newvalue = binBoundaries[ib];
1395  bool done = false;
1396  for (std::vector<double>::iterator it = boundaries.begin(); it != boundaries.end(); ++it) {
1397  if (isNearlyEqual(newvalue, *it)) {
1398  // consider this value to have been inserted already
1399  done = true; break;
1400  } else if (newvalue < *it) {
1401  // the interesting case: insert the new value
1402  boundaries.insert(it, newvalue);
1403  done = true; break;
1404  }
1405  }
1406  // last case: new value is larger than any of the values in the array so far
1407  if (! done) boundaries.push_back(newvalue);
1408  }
1409  }
1410  }
1411  } else {
1412  // Normal case:
1413  unsigned int dim = (var < int(m_beginMapped)) ? var : var + 1 - m_mapped.size();
1414  const TAxis* axis = 0;
1415  switch (dim) {
1416  case 0: axis = hobj->GetXaxis(); break;
1417  case 1: axis = hobj->GetYaxis(); break;
1418  default: axis = hobj->GetZaxis();
1419  }
1420  // Retrieve the actual bin boundaries
1421  const TArrayD* bins = axis->GetXbins(); int nb = bins->GetSize();
1422  for (int b = 0; b < nb; ++b) boundaries.push_back(bins->At(b));
1423  }
1424 
1425  m_binBoundaries[vartype] = boundaries;
1426  return boundaries;
1427 }

◆ getBounds()

std::vector< std::pair< double, double > > CalibrationDataContainer::getBounds ( )
inherited

allow the user to inspect the bounds of validity

Definition at line 391 of file CalibrationDataContainer.cxx.

392 {
393  // List the validity bounds relevant to this container.
394 
395  // ensure that the variable types have been computed properly
396  if (m_variables.size() == 0) computeVariableTypes();
397 
398  std::vector<std::pair<double, double> > bounds;
399  for (unsigned int t = 0; t < m_lowerBounds.size() && t <= kAbsEta; ++t) {
400  bounds.push_back(std::make_pair(m_lowerBounds[t], m_upperBounds[t]));
401  }
402  return bounds;
403 }

◆ getComment()

std::string CalibrationDataContainer::getComment ( ) const
inherited

retrieve the comments entered for this calibration, if any

Definition at line 190 of file CalibrationDataContainer.cxx.

191 {
192  // Retrieve the comments for this calibration (if any)
193 
194  TObject* obj = GetValue("comment");
195  if (! obj) return std::string("");
196  TObjString* s = dynamic_cast<TObjString*>(obj);
197  if (! s ) return std::string("");
198  return std::string(s->GetName());
199 }

◆ getEigenvectorReduction()

int CalibrationDataHistogramContainer::getEigenvectorReduction ( unsigned int  choice) const
virtualinherited

Retrieve the number of eigenvectors to be retained for the purpose of eigenvector variation reduction strategies.

Parameters
choicespecification of the reduction option (integer corresponding to the CalibrationDataInterfaceROOT::EVReductionStrategy enum)
Returns
number of eigenvector variations to be retained; -1 if the required information is lacking

Definition at line 986 of file CalibrationDataContainer.cxx.

987 {
988  TObject* obj = GetValue("ReducedSets");
989  if (! obj) return -1;
990  TVectorT<double>* v = dynamic_cast<TVectorT<double>* >(obj);
991  if (! (v && v->GetNoElements() > int(choice)) ) return -1;
992  return int((*v)[choice]);
993 }

◆ getExcludedUncertainties()

std::string CalibrationDataContainer::getExcludedUncertainties ( ) const
inherited

retrieve the (semicolon-separated) set of uncertainties that are recommended for removal from the eigenvector decomposition

Definition at line 217 of file CalibrationDataContainer.cxx.

218 {
219  // Retrieve the (semicolon-separated) set of uncertainties that are recommended for removal from the eigenvector decomposition (if any)
220  const static std::string null("");
221 
222  TObject* obj = GetValue("excluded_set");
223  if (! obj) return null;
224  TObjString* s = dynamic_cast<TObjString*>(obj);
225  if (! s ) return null;
226  return std::string(s->GetName());
227 }

◆ getHadronisation()

std::string CalibrationDataContainer::getHadronisation ( ) const
inherited

retrieve the 'hadronisation reference' entered for this calibration, if any

Definition at line 203 of file CalibrationDataContainer.cxx.

204 {
205  // Retrieve the hadronisation reference for this calibration (if any)
206  const static std::string null("");
207 
208  TObject* obj = GetValue("MChadronisation");
209  if (! obj) return null;
210  TObjString* s = dynamic_cast<TObjString*>(obj);
211  if (! s ) return null;
212  return std::string(s->GetName());
213 }

◆ getInterpolatedResult()

double CalibrationDataHistogramContainer::getInterpolatedResult ( TH1 hist) const
privateinherited

Retrieve interpolated result (utility function)

Definition at line 760 of file CalibrationDataContainer.cxx.

761 {
762  // Small utility function (intended for internal use only) for the retrieval of interpolated results
763 
764  switch (hist->GetDimension()) {
765  case 3:
766  return hist->Interpolate(m_vars[0], m_vars[1], m_vars[2]);
767  case 2:
768  return hist->Interpolate(m_vars[0], m_vars[1]);
769  case 1:
770  default:
771  return hist->Interpolate(m_vars[0]);
772  }
773 }

◆ getInterpolatedUncertainty()

double CalibrationDataHistogramContainer::getInterpolatedUncertainty ( TH1 hist) const
privateinherited

Retrieve interpolated result (utility function)

Definition at line 777 of file CalibrationDataContainer.cxx.

778 {
779  TAxis* xAxis = hist->GetXaxis();
780  TAxis* yAxis = 0; TAxis* zAxis = 0;
781  Double_t x0,x1,y0,y1;
782 
783  Int_t ndim = hist->GetDimension();
784  if (ndim == 1) {
785  // Code copied from TH1::Interpolate()
786 
787  Int_t xbin = hist->FindBin(m_vars[0]);
788 
789  if(m_vars[0] <= hist->GetBinCenter(1)) {
790  return hist->GetBinError(1);
791  } else if(m_vars[0] >= hist->GetBinCenter(hist->GetNbinsX())) {
792  return hist->GetBinError(hist->GetNbinsX());
793  }
794 
795  if(m_vars[0] <= hist->GetBinCenter(xbin)) {
796  y0 = hist->GetBinError(xbin-1);
797  x0 = hist->GetBinCenter(xbin-1);
798  y1 = hist->GetBinError(xbin);
799  x1 = hist->GetBinCenter(xbin);
800  } else {
801  y0 = hist->GetBinError(xbin);
802  x0 = hist->GetBinCenter(xbin);
803  y1 = hist->GetBinError(xbin+1);
804  x1 = hist->GetBinCenter(xbin+1);
805  }
806  return y0 + (m_vars[0]-x0)*((y1-y0)/(x1-x0));
807 
808  } else if (ndim == 2) {
809 
810  // Code copied from TH2::Interpolate()
811 
812  Double_t f=0;
813  x1 = y1 = 0;
814  Double_t x2=0,y2=0;
815  Double_t dx,dy;
816  yAxis = hist->GetYaxis();
817  Int_t bin_x = xAxis->FindBin(m_vars[0]);
818  Int_t bin_y = yAxis->FindBin(m_vars[1]);
819  if (bin_x<1 || bin_x>hist->GetNbinsX() || bin_y<1 || bin_y>hist->GetNbinsY()) {
820  Error("Interpolate","Cannot interpolate outside histogram domain.");
821  return 0;
822  }
823  // Int_t quadrant = 0; // CCW from UR 1,2,3,4
824  // which quadrant of the bin (bin_P) are we in?
825  dx = xAxis->GetBinUpEdge(bin_x)-m_vars[0];
826  dy = yAxis->GetBinUpEdge(bin_y)-m_vars[1];
827  if (dx<=xAxis->GetBinWidth(bin_x)/2 && dy<=yAxis->GetBinWidth(bin_y)/2) {
828  // quadrant = 1; // upper right
829  x1 = xAxis->GetBinCenter(bin_x);
830  y1 = yAxis->GetBinCenter(bin_y);
831  x2 = xAxis->GetBinCenter(bin_x+1);
832  y2 = yAxis->GetBinCenter(bin_y+1);
833  } else if (dx>xAxis->GetBinWidth(bin_x)/2 && dy<=yAxis->GetBinWidth(bin_y)/2) {
834  // quadrant = 2; // upper left
835  x1 = xAxis->GetBinCenter(bin_x-1);
836  y1 = yAxis->GetBinCenter(bin_y);
837  x2 = xAxis->GetBinCenter(bin_x);
838  y2 = yAxis->GetBinCenter(bin_y+1);
839  } else if (dx>xAxis->GetBinWidth(bin_x)/2 && dy>yAxis->GetBinWidth(bin_y)/2) {
840  // quadrant = 3; // lower left
841  x1 = xAxis->GetBinCenter(bin_x-1);
842  y1 = yAxis->GetBinCenter(bin_y-1);
843  x2 = xAxis->GetBinCenter(bin_x);
844  y2 = yAxis->GetBinCenter(bin_y);
845  } else {
846  // quadrant = 4; // lower right
847  x1 = xAxis->GetBinCenter(bin_x);
848  y1 = yAxis->GetBinCenter(bin_y-1);
849  x2 = xAxis->GetBinCenter(bin_x+1);
850  y2 = yAxis->GetBinCenter(bin_y);
851  }
852  Int_t bin_x1 = xAxis->FindBin(x1);
853  if(bin_x1<1) bin_x1=1;
854  Int_t bin_x2 = xAxis->FindBin(x2);
855  if(bin_x2>hist->GetNbinsX()) bin_x2=hist->GetNbinsX();
856  Int_t bin_y1 = yAxis->FindBin(y1);
857  if(bin_y1<1) bin_y1=1;
858  Int_t bin_y2 = yAxis->FindBin(y2);
859  if(bin_y2>hist->GetNbinsY()) bin_y2=hist->GetNbinsY();
860  Int_t bin_q22 = hist->GetBin(bin_x2,bin_y2);
861  Int_t bin_q12 = hist->GetBin(bin_x1,bin_y2);
862  Int_t bin_q11 = hist->GetBin(bin_x1,bin_y1);
863  Int_t bin_q21 = hist->GetBin(bin_x2,bin_y1);
864  Double_t q11 = hist->GetBinError(bin_q11);
865  Double_t q12 = hist->GetBinError(bin_q12);
866  Double_t q21 = hist->GetBinError(bin_q21);
867  Double_t q22 = hist->GetBinError(bin_q22);
868  Double_t d = 1.0*(x2-x1)*(y2-y1);
869  f = 1.0*q11/d*(x2-m_vars[0])*(y2-m_vars[1])
870  + 1.0*q21/d*(m_vars[0]-x1)*(y2-m_vars[1])
871  + 1.0*q12/d*(x2-m_vars[0])*(m_vars[1]-y1)
872  + 1.0*q22/d*(m_vars[0]-x1)*(m_vars[1]-y1);
873  return f;
874 
875  } else {
876 
877  // Copied from TH3::Interpolate()
878 
879  yAxis = hist->GetYaxis();
880  zAxis = hist->GetZaxis();
881 
882  Int_t ubx = xAxis->FindBin(m_vars[0]);
883  if ( m_vars[0] < xAxis->GetBinCenter(ubx) ) ubx -= 1;
884  Int_t obx = ubx + 1;
885 
886  Int_t uby = yAxis->FindBin(m_vars[1]);
887  if ( m_vars[1] < yAxis->GetBinCenter(uby) ) uby -= 1;
888  Int_t oby = uby + 1;
889 
890  Int_t ubz = zAxis->FindBin(m_vars[2]);
891  if ( m_vars[2] < zAxis->GetBinCenter(ubz) ) ubz -= 1;
892  Int_t obz = ubz + 1;
893 
894 
895  // if ( IsBinUnderflow(GetBin(ubx, uby, ubz)) ||
896  // IsBinOverflow (GetBin(obx, oby, obz)) ) {
897  if (ubx <=0 || uby <=0 || ubz <= 0 ||
898  obx > xAxis->GetNbins() || oby > yAxis->GetNbins() || obz > zAxis->GetNbins() ) {
899  }
900 
901  Double_t xw = xAxis->GetBinCenter(obx) - xAxis->GetBinCenter(ubx);
902  Double_t yw = yAxis->GetBinCenter(oby) - yAxis->GetBinCenter(uby);
903  Double_t zw = zAxis->GetBinCenter(obz) - zAxis->GetBinCenter(ubz);
904 
905  Double_t xd = (m_vars[0] - xAxis->GetBinCenter(ubx)) / xw;
906  Double_t yd = (m_vars[1] - yAxis->GetBinCenter(uby)) / yw;
907  Double_t zd = (m_vars[2] - zAxis->GetBinCenter(ubz)) / zw;
908 
909 
910  Double_t v[] = { hist->GetBinError( ubx, uby, ubz ), hist->GetBinError( ubx, uby, obz ),
911  hist->GetBinError( ubx, oby, ubz ), hist->GetBinError( ubx, oby, obz ),
912  hist->GetBinError( obx, uby, ubz ), hist->GetBinError( obx, uby, obz ),
913  hist->GetBinError( obx, oby, ubz ), hist->GetBinError( obx, oby, obz ) };
914 
915 
916  Double_t i1 = v[0] * (1 - zd) + v[1] * zd;
917  Double_t i2 = v[2] * (1 - zd) + v[3] * zd;
918  Double_t j1 = v[4] * (1 - zd) + v[5] * zd;
919  Double_t j2 = v[6] * (1 - zd) + v[7] * zd;
920 
921 
922  Double_t w1 = i1 * (1 - yd) + i2 * yd;
923  Double_t w2 = j1 * (1 - yd) + j2 * yd;
924 
925 
926  Double_t result = w1 * (1 - xd) + w2 * xd;
927 
928  return result;
929  };
930 }

◆ getLowerBound()

double CalibrationDataContainer::getLowerBound ( unsigned int  vartype,
bool  extrapolate = false 
) const
inherited

retrieve the lower bound of validity for the requested variable type

Parameters
vartypevariable type
extrapolatetrue only if an extrapolation uncertainty is requested

Definition at line 366 of file CalibrationDataContainer.cxx.

367 {
368  // Utility function returning the lower validity bound for the given variable type.
369  // The "extrapolate" variable flags whether normal validity bounds are to be used,
370  // or instead those relevant for the extrapolation uncertainty.
371 
372  double minDefault = (vartype == kAbsEta || vartype == kPt) ? 0 : -std::numeric_limits<double>::max();
373  if (! (vartype < m_lowerBounds.size())) return minDefault;
374  return extrapolate ? m_lowerBoundsExtrapolated[vartype] : m_lowerBounds[vartype];
375 }

◆ getMappedVariables()

std::vector< std::string > CalibrationDataMappedHistogramContainer::getMappedVariables ( ) const

List which variables get mapped onto a single histogram axis.

Definition at line 1275 of file CalibrationDataContainer.cxx.

1276 {
1277  // List which variables get mapped onto a single histogram axis
1278 
1279  return m_mapped;
1280 }

◆ getNMappedBins()

unsigned int CalibrationDataMappedHistogramContainer::getNMappedBins ( ) const

return the number of mapped bins

Definition at line 1295 of file CalibrationDataContainer.cxx.

1296 {
1297  // Return the number of mapped bins
1298  // Note the absence of a -1 in the return value: this is because ROOT's histogram axes start counting from 1
1299 
1300  return m_bins.size();
1301 }

◆ getResult()

CalibrationStatus CalibrationDataMappedHistogramContainer::getResult ( const CalibrationDataVariables x,
double &  result,
TObject *  obj = 0,
bool  extrapolate = false 
)
virtual

retrieve the calibration result.

Parameters
xuser-supplied (kinematic or other) variables
resultrequested result
objobject holding the requested result (it will be computed if not provided)
extrapolateflag that extrapolation applies (should only be relevant when using eigenvector variations)
Returns
status code (see above)

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 1152 of file CalibrationDataContainer.cxx.

1154 {
1155  // Retrieve the central value for the given input variables. There are cases where
1156  // it may be useful to provide an alternative histogram rather than the original
1157  // one; in such cases (notably used with eigenvector variations) it is possible to
1158  // provide a pointer to this alternative histogram.
1159  // The method here differs from CalibrationDataHistogramContainer::getResult()
1160  // since histogram interpolation does not make sense for mapped bins.
1161  //
1162  // x: input variables
1163  // result: result
1164  // obj: pointer to alternative results histogram
1165 
1166  if (!obj) {
1167  if (! m_objResult) {
1168  m_objResult = GetValue("result");
1169  }
1170  obj = m_objResult;
1171  }
1172  TH1* hist = dynamic_cast<TH1*>(obj);
1173  if (! hist) return Analysis::kError;
1174 
1175  // select the relevant kinematic variables
1177  // find the relevant "global" bin and retrieve its contents
1178  result = hist->GetBinContent(findBin());
1179 
1180  return status;
1181 }

◆ getStatUncertainty()

CalibrationStatus CalibrationDataMappedHistogramContainer::getStatUncertainty ( const CalibrationDataVariables x,
double &  result 
)
virtual

retrieve the calibration statistical uncertainty.

Parameters
xuser-supplied (kinematic or other) variables
resultrequested statistical uncertainty
Returns
status code (see above) Note the changed signature compared to getUncertainty(), getResult() etc.: this is because the statistical uncertainty computation always needs the result object, and only in case of the function interface also the covariance matrix

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 1185 of file CalibrationDataContainer.cxx.

1187 {
1188  // Retrieve the statistical uncertainty for the given input variables.
1189  //
1190  // x: input variables
1191  // result: result
1192 
1193  if (! m_objResult) {
1194  m_objResult = GetValue("result");
1195  }
1196  TH1* hist = dynamic_cast<TH1*>(m_objResult);
1197  if (! hist) return Analysis::kError;
1198 
1199  // select the relevant kinematic variables
1201  // find the relevant "global" bin and retrieve its contents
1202  result = hist->GetBinError(findBin());
1203 
1204  return status;
1205 }

◆ getSystUncertainty()

CalibrationStatus CalibrationDataContainer::getSystUncertainty ( const CalibrationDataVariables x,
UncertaintyResult result,
TObject *  obj = 0 
)
inherited

retrieve the calibration total systematic uncertainty

See also
getUncertainty()

Definition at line 101 of file CalibrationDataContainer.cxx.

103 {
104  // short-hand for the total systematic uncertainty retrieval.
105  // For "normal" usage (retrieval of central values and total uncertainties), the total systematic
106  // uncertainty object needs to be accessed frequently. In order to avoid nee
107 
108  // cache the pointer to the "systematics" object (to avoid string comparisons)
109  if (!obj) {
110  if (! m_objSystematics) {
111  m_objSystematics = GetValue("systematics");
112  }
114  }
115  return getUncertainty("systematics", x, result, obj);
116 }

◆ getTagWeightAxis()

int CalibrationDataMappedHistogramContainer::getTagWeightAxis ( )
virtual

Test whether this calibration object is one for "continuous" calibration (this has some subtle consequences for the treatment of bin-to-bin correlations).

The return value will be -1 in case this is not a "continuous" calibration object, and the axis number (0 for X, 1 for Y, 2 for Z) otherwise.

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 1249 of file CalibrationDataContainer.cxx.

1250 {
1251  // Test whether this calibration object is one for "continuous" calibration
1252  // (this has some subtle consequences for the treatment of bin-to-bin correlations).
1253  // The return value will be -1 in case this is not a "continuous" calibration object,
1254  // and the axis number (0 for X, 1 for Y, 2 for Z) otherwise.
1255 
1256  for (unsigned int type = 0; type < m_variables.size(); ++type)
1257  if (m_variables[type] == kTagWeight) {
1258  int hist_type = int(type);
1259  return (hist_type > int(m_beginMapped)) ? hist_type - m_mapped.size() + 1 : hist_type;
1260  }
1261  return -1;
1262 }

◆ getUncertainties()

CalibrationStatus CalibrationDataContainer::getUncertainties ( const CalibrationDataVariables x,
std::map< std::string, Analysis::UncertaintyResult > &  all 
)
inherited

retrieve the list of "uncertainties" accessible to this object.

A few uncertainty names are predetermined: "result", "comment", "statistics", "systematics". Individual sources of systematic uncertainty can be added by the user.

Definition at line 137 of file CalibrationDataContainer.cxx.

139 {
140  // Retrieve all uncertainties for this calibration.
141 
144 
145  // first treat the "result" entry separately
146  double single_result;
147  CalibrationStatus code = getResult(x, single_result);
148  if (code == Analysis::kError) {
149  std::cerr << "in CalibrationDataContainer::getUncertainties(): error retrieving result!" << std::endl;
150  return code;
151  }
152  else if (code != Analysis::kSuccess) mycode = code;
153  result.first = single_result;
154  result.second = 0;
155  all[std::string("result")] = result;
156 
157  // similar for the "statistics" entry
158  code = getStatUncertainty(x, single_result);
159  if (code == Analysis::kError) {
160  std::cerr << "in CalibrationDataContainer::getUncertainties(): error retrieving stat. uncertainty!" << std::endl;
161  return code;
162  }
163  else if (code != Analysis::kSuccess) mycode = code;
164  result.first = single_result;
165  result.second = -single_result;
166  all[std::string("statistics")] = result;
167 
168  // then cycle through the other (systematic) uncertainties
169  TIter it(GetTable());
170  while (TPair* pair = (TPair*) it()) {
171  std::string spec(pair->Key()->GetName());
172  // ignore these specific entries
173  if (spec == "comment" || spec == "result" || spec == "statistics" || spec == "MChadronisation" || spec == "excluded_set") continue;
174  code = getUncertainty(spec, x, result, pair->Value());
175  // we should never be finding any errors
176  if (code == Analysis::kError) {
177  std::cerr << "in CalibrationDataContainer::getUncertainties(): error retrieving named uncertainty "
178  << spec << "!" << std::endl;
179  return code;
180  }
181  // this assumes that non-success codes are likely to be correlated between uncertainty sources
182  else if (code != Analysis::kSuccess) mycode = code;
183  all[spec] = result;
184  }
185  return mycode;
186 }

◆ getUncertainty()

CalibrationStatus CalibrationDataMappedHistogramContainer::getUncertainty ( const std::string &  unc,
const CalibrationDataVariables x,
UncertaintyResult result,
TObject *  obj = 0 
)
virtual

retrieve the calibration uncertainty due to the given source.

Parameters
xuser-supplied (kinematic or other) variables
uncuncertainty specification
resultrequested uncertainty (for both positive and negative variation, if available)
objobject holding the requested uncertainty information (it will be computed if not provided)
Returns
status code (see above)

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 1209 of file CalibrationDataContainer.cxx.

1212 {
1213  // Retrieve the uncertainty for the given input variables.
1214  //
1215  // unc: keyword indicating requested source of uncertainty. This should
1216  // correspond to one of the histograms added explicitly as a systematic
1217  // uncertainty or the keyword "statistics" (statistical uncertainties are
1218  // accessed differently, see method getStatUncertainty()).
1219  // x: input variables
1220  // result: result
1221  // obj: pointer to alternative or cached histogram
1222 
1223  // treat statistical uncertainties separately (they are stored with the actual result)
1224  if (unc == "statistics") {
1225  double res;
1227  if (code == Analysis::kError) return code;
1228  result.first = res;
1229  result.second = -res;
1230  return code;
1231  }
1232 
1233  if (!obj) obj = GetValue(unc.c_str());
1234  TH1* hist = dynamic_cast<TH1*>(obj);
1235  if (! hist) return Analysis::kError;
1236 
1237  // select the relevant kinematic variables
1239  // find the relevant "global" bin and retrieve its contents
1240  Int_t bin = findBin();
1241  result.first = hist->GetBinError(bin);
1242  result.second = hist->GetBinError(bin);
1243 
1244  return status;
1245 }

◆ getUpperBound()

double CalibrationDataContainer::getUpperBound ( unsigned int  vartype,
bool  extrapolate = false 
) const
inherited

retrieve the upper bound of validity for the requested variable type

Parameters
vartypevariable type
extrapolatetrue only if an extrapolation uncertainty is requested

Definition at line 379 of file CalibrationDataContainer.cxx.

380 {
381  // Utility function returning the upper validity bound for the given variable type.
382  // The "extrapolate" variable flags whether normal validity bounds are to be used,
383  // or instead those relevant for the extrapolation uncertainty.
384 
385  if (! (vartype < m_lowerBounds.size())) return std::numeric_limits<double>::max();
386  return extrapolate ? m_upperBoundsExtrapolated[vartype] : m_upperBounds[vartype];
387 }

◆ getVariableTypes()

std::vector< unsigned int > CalibrationDataContainer::getVariableTypes ( )
inherited

utility to retrieve variable types

Definition at line 408 of file CalibrationDataContainer.cxx.

409 {
410  // List the variable types used for this calibration object.
411  // The meaning of the types is encapsulated by the CalibrationParametrization enum.
412 
413  // ensure that the variable types have been computed properly
414  if (m_variables.size() == 0) computeVariableTypes();
415 
416  return m_variables;
417 }

◆ isBinCorrelated()

bool CalibrationDataHistogramContainer::isBinCorrelated ( const std::string &  unc) const
inherited

Indicate whether the given uncertainty is correlated from bin to bin or not (note that this function is to be used only for systematic uncertainties)

Definition at line 719 of file CalibrationDataContainer.cxx.

720 {
721  // Indicate whether the given uncertainty is correlated from bin to bin or not
722  // (note that this function is to be used only for _systematic_ uncertainties)
723  return (m_uncorrelatedSyst.FindObject(unc.c_str()) == 0);
724 }

◆ isInterpolated()

virtual bool Analysis::CalibrationDataMappedHistogramContainer::isInterpolated ( ) const
inlinevirtual

Indicate whether histogram interpolation is used or not.

Not applicable here.

Reimplemented from Analysis::CalibrationDataHistogramContainer.

Definition at line 346 of file CalibrationDataContainer.h.

346 { return false; }

◆ isNearlyEqual()

bool CalibrationDataContainer::isNearlyEqual ( double  a,
double  b 
)
staticinherited

utility for comparison of doubles

Definition at line 1744 of file CalibrationDataContainer.cxx.

1744  {
1745  // Simple utility function testing whether two double values are sufficiently similar.
1746  // The test carried out is on their relative difference, which should be within a given tolerance.
1747 
1748  static const double tolerance = 1.e-8;
1749 
1750  double diff = a - b;
1751  double ref = std::fabs(a) + std::fabs(b);
1752  return (ref == 0 || std::fabs(diff) < tolerance*ref);
1753 }

◆ isRangeRestricted()

bool Analysis::CalibrationDataContainer::isRangeRestricted ( ) const
inlineinherited

allow the user to inspect the above information

Definition at line 162 of file CalibrationDataContainer.h.

162 { return m_restrict; }

◆ listUncertainties()

std::vector< std::string > CalibrationDataContainer::listUncertainties ( ) const
inherited

retrieve the list of "uncertainties" accessible to this object.

A few uncertainty names are predetermined: "result", "comment", "statistics", "systematics". Individual sources of systematic uncertainty can be added by the user.

Definition at line 120 of file CalibrationDataContainer.cxx.

121 {
122  // Retrieve the list of uncertainties for this calibration.
123  // Note that this is an un-pruned list: it contains also entries that
124  // are not proper uncertainties (e.g. "result", "comment")
125 
126  std::vector<std::string> uncertainties;
127  TIter it(GetTable());
128  while (TPair* pair = (TPair*) it()) {
129  std::string spec(pair->Key()->GetName());
130  uncertainties.push_back(spec);
131  }
132  return uncertainties;
133 }

◆ restrictToRange()

void Analysis::CalibrationDataContainer::restrictToRange ( bool  restrict)
inlineinherited

If true, this will restrict the variables used to be within the (specified) range of validity.

Note that this is a policy decision and as such not intrinsic to the data; but it is cumbersome to carry this information around everywhere.

Definition at line 159 of file CalibrationDataContainer.h.

159 { m_restrict = restrict; }

◆ setComment()

void CalibrationDataContainer::setComment ( const std::string &  text)
inherited

insert the given text as comment for this calibration

Definition at line 255 of file CalibrationDataContainer.cxx.

256 {
257  // Insert (or replace) the comment field. This needs to be handled somewhat
258  // specially as TString itself doesn't inherit from TObject.
259  //
260  // text: comment field (will be converted to TObjString)
261 
262  if (TPair* p = (TPair*) FindObject("comment")) DeleteEntry(p->Key());
263  Add(new TObjString("comment"), new TObjString(text.c_str()));
264 }

◆ setExcludedUncertainties()

void CalibrationDataContainer::setExcludedUncertainties ( const std::string &  text)
inherited

insert the set of uncertainties that are recommended for removal from the eigenvector decomposition.

Parameters
textsemicolon-separated list of uncertainties

Definition at line 280 of file CalibrationDataContainer.cxx.

281 {
282  // Insert (or replace) the (semicolon-separated) list of uncertainties that are recommended to be excluded from the eigenvector decomposition
283  //
284  // text: the (semicolon-separated) list of uncertainties in string form (will be converted to TObjString)
285 
286  if (TPair* p = (TPair*) FindObject("excluded_set")) DeleteEntry(p->Key());
287  Add(new TObjString("excluded_set"), new TObjString(text.c_str()));
288 }

◆ setHadronisation()

void CalibrationDataContainer::setHadronisation ( const std::string &  text)
inherited

insert the given text as the 'hadronisation reference' for this calibration

Definition at line 268 of file CalibrationDataContainer.cxx.

269 {
270  // Insert (or replace) the hadronisation reference.
271  //
272  // text: hadronisation reference in string form (will be converted to TObjString)
273 
274  if (TPair* p = (TPair*) FindObject("MChadronisation")) DeleteEntry(p->Key());
275  Add(new TObjString("MChadronisation"), new TObjString(text.c_str()));
276 }

◆ setInterpolated()

void CalibrationDataHistogramContainer::setInterpolated ( bool  doInterpolate)
inherited

Indicate whether results are to be interpolated between bins or not (this feature is thought to be useful mostly for MC efficiencies)

Definition at line 740 of file CalibrationDataContainer.cxx.

741 {
742  // Indicate whether results are to be interpolated between bins or not
743  // (this feature is thought to be useful mostly for MC efficiencies).
744  // The default is not to use any interpolation.
745 
746  m_interpolate = doInterpolate;
747 }

◆ setMappedVariables()

void CalibrationDataMappedHistogramContainer::setMappedVariables ( const std::vector< std::string > &  variables)

Set (by hand) the variables that will be mapped onto a single histogram axis.

Definition at line 1266 of file CalibrationDataContainer.cxx.

1267 {
1268  // Set (by hand) the variables that will be mapped onto a single histogram axis
1269 
1270  m_mapped = variables;
1271 }

◆ setResult()

void CalibrationDataContainer::setResult ( TObject *  obj)
inherited

insert the main object for this calibration

Definition at line 244 of file CalibrationDataContainer.cxx.

245 {
246  // Specialization of the setUncertainty() method: insert the calibration result
247  //
248  // obj: object to be entered (needs to inherit from TObject)
249 
250  setUncertainty(std::string("result"), obj);
251 }

◆ setUncertainty()

void CalibrationDataContainer::setUncertainty ( const std::string &  unc,
TObject *  obj 
)
inherited

insert the relevant object for the requested source of 'uncertainty'

Definition at line 231 of file CalibrationDataContainer.cxx.

232 {
233  // Insert (or replace) the given object at the position indicated by the given index.
234  //
235  // unc: uncertainty index
236  // obj: object to be entered (needs to inherit from TObject)
237 
238  if (TPair* p = (TPair*) FindObject(unc.c_str())) DeleteEntry(p->Key());
239  Add(new TObjString(unc.c_str()), obj);
240 }

◆ setUncorrelated()

void CalibrationDataHistogramContainer::setUncorrelated ( const std::string &  unc)
inherited

Indicate that the given uncertainty is to be treated uncorrelated from bin to bin (note that the default is for all systematic uncertainties to be treated as correlated)

Definition at line 728 of file CalibrationDataContainer.cxx.

729 {
730  // Indicate that the given uncertainty is to be treated uncorrelated from bin to bin
731  // (the default is for all systematic uncertainties to be treated as correlated).
732  // This method is not normall intended to be used during physics analysis; this
733  // information is written to and read back from the calibration file.
734 
735  m_uncorrelatedSyst.Add(new TObjString(unc.c_str()));
736 }

◆ typeFromString()

int CalibrationDataContainer::typeFromString ( const std::string &  key) const
protectedinherited

Connection between variable names (on histogram axes etc.) and variable 'types' as used in actual evaluations.

Normal result values are positive (or 0); a negative return value indicates that the string is not known)

Definition at line 292 of file CalibrationDataContainer.cxx.

293 {
294  // Small utility function collecting the correspondence between axis labels and (integer) variable indices.
295  // In case of an unknown label, a negative number will be returned to flag the issue.
296 
297  if (key == "eta") return kEta;
298  else if (key == "abseta") return kAbsEta;
299  else if (key == "pt") return kPt;
300  else if (key == "tagweight") return kTagWeight;
301  // return value for unknown keywords
302  else return -1;
303 }

Member Data Documentation

◆ m_beginMapped

unsigned int Analysis::CalibrationDataMappedHistogramContainer::m_beginMapped
private

starting position of mapped variables

Definition at line 399 of file CalibrationDataContainer.h.

◆ m_binBoundaries

std::map<unsigned int, std::vector<double> > Analysis::CalibrationDataHistogramContainer::m_binBoundaries
protectedinherited

Cache for bin boundary information.

Definition at line 291 of file CalibrationDataContainer.h.

◆ m_bins

std::vector<Bin> Analysis::CalibrationDataMappedHistogramContainer::m_bins
private

don't persistify

calibration bins

Definition at line 402 of file CalibrationDataContainer.h.

◆ m_interpolate

bool Analysis::CalibrationDataHistogramContainer::m_interpolate
privateinherited

If true, interpolate between bins rather than doing a straight bin-wise evaluation.

Definition at line 299 of file CalibrationDataContainer.h.

◆ m_lastBin

unsigned int Analysis::CalibrationDataMappedHistogramContainer::m_lastBin
private

Definition at line 404 of file CalibrationDataContainer.h.

◆ m_lowerBounds

std::vector<double> Analysis::CalibrationDataContainer::m_lowerBounds
protectedinherited

Definition at line 210 of file CalibrationDataContainer.h.

◆ m_lowerBoundsExtrapolated

std::vector<double> Analysis::CalibrationDataContainer::m_lowerBoundsExtrapolated
protectedinherited

Definition at line 213 of file CalibrationDataContainer.h.

◆ m_mapped

std::vector<std::string> Analysis::CalibrationDataMappedHistogramContainer::m_mapped
private

mapped variables.

These have to be specified when creating the object, for there is no way to transmit this information otherwise.

Definition at line 396 of file CalibrationDataContainer.h.

◆ m_objResult

TObject* Analysis::CalibrationDataContainer::m_objResult
protectedinherited

(possibly looser) upper validity bounds for extrapolation

cached variables for code speed-up

Definition at line 217 of file CalibrationDataContainer.h.

◆ m_objSystematics

TObject* Analysis::CalibrationDataContainer::m_objSystematics
protectedinherited

don't persistify

Definition at line 218 of file CalibrationDataContainer.h.

◆ m_restrict

bool Analysis::CalibrationDataContainer::m_restrict
privateinherited

persistency not needed for this variable

specifies whether the performance evaluation is to be done strictly within the range of validity

Definition at line 230 of file CalibrationDataContainer.h.

◆ m_uncorrelatedSyst

THashList Analysis::CalibrationDataHistogramContainer::m_uncorrelatedSyst
privateinherited

no need to persistify

list here the systematic uncertainties that are not correlated from bin to bin

Definition at line 296 of file CalibrationDataContainer.h.

◆ m_upperBounds

std::vector<double> Analysis::CalibrationDataContainer::m_upperBounds
protectedinherited

Definition at line 211 of file CalibrationDataContainer.h.

◆ m_upperBoundsExtrapolated

std::vector<double> Analysis::CalibrationDataContainer::m_upperBoundsExtrapolated
protectedinherited

(possibly looser) lower validity bounds for extrapolation

Definition at line 214 of file CalibrationDataContainer.h.

◆ m_variables

std::vector<unsigned int> Analysis::CalibrationDataContainer::m_variables
protectedinherited

don't persistify

specification of variable type per object (result / uncertainty)

Definition at line 223 of file CalibrationDataContainer.h.

◆ m_vars

double Analysis::CalibrationDataContainer::m_vars[MaxCalibrationVars]
protectedinherited

don't persistify

Definition at line 220 of file CalibrationDataContainer.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Analysis::CalibrationDataContainer::getUncertainty
virtual CalibrationStatus getUncertainty(const std::string &unc, const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)=0
retrieve the calibration uncertainty due to the given source.
Analysis::CalibrationDataMappedHistogramContainer
Definition: CalibrationDataContainer.h:335
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
checkCoolLatestUpdate.variables
variables
Definition: checkCoolLatestUpdate.py:13
PlotCalibFromCool.zAxis
zAxis
Definition: PlotCalibFromCool.py:76
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.App.bins
bins
Definition: App.py:410
Analysis::CalibrationDataMappedHistogramContainer::computeVariableTypes
virtual void computeVariableTypes()
decode the 'uncertainty' objects' names to determine the relevant variable types
Definition: CalibrationDataContainer.cxx:1030
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
Analysis::CalibrationDataContainer::m_restrict
bool m_restrict
persistency not needed for this variable
Definition: CalibrationDataContainer.h:230
hist_file_dump.d
d
Definition: hist_file_dump.py:137
Analysis::CalibrationDataContainer::m_upperBounds
std::vector< double > m_upperBounds
Definition: CalibrationDataContainer.h:211
plotmaker.hist
hist
Definition: plotmaker.py:148
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
Analysis::CalibrationDataHistogramContainer::m_interpolate
bool m_interpolate
If true, interpolate between bins rather than doing a straight bin-wise evaluation.
Definition: CalibrationDataContainer.h:299
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
Analysis::CalibrationDataContainer::computeVariableTypes
virtual void computeVariableTypes()=0
decode the 'uncertainty' objects' names to determine the relevant variable types
Analysis::CalibrationDataContainer::m_objSystematics
TObject * m_objSystematics
don't persistify
Definition: CalibrationDataContainer.h:218
skel.it
it
Definition: skel.GENtoEVGEN.py:423
bin
Definition: BinsDiffFromStripMedian.h:43
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
Analysis::CalibrationDataContainer::getResult
virtual CalibrationStatus getResult(const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)=0
retrieve the calibration result.
Analysis::CalibrationDataContainer::getLowerBound
double getLowerBound(unsigned int vartype, bool extrapolate=false) const
retrieve the lower bound of validity for the requested variable type
Definition: CalibrationDataContainer.cxx:366
Analysis::CalibrationDataContainer::kAbsEta
@ kAbsEta
Definition: CalibrationDataContainer.h:66
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
Analysis::kSuccess
@ kSuccess
Definition: CalibrationDataVariables.h:57
Analysis::CalibrationDataMappedHistogramContainer::m_mapped
std::vector< std::string > m_mapped
mapped variables.
Definition: CalibrationDataContainer.h:396
Analysis::CalibrationDataContainer::m_variables
std::vector< unsigned int > m_variables
don't persistify
Definition: CalibrationDataContainer.h:223
Analysis::CalibrationDataContainer::m_vars
double m_vars[MaxCalibrationVars]
don't persistify
Definition: CalibrationDataContainer.h:220
Analysis::CalibrationDataContainer::computeVariables
CalibrationStatus computeVariables(const CalibrationDataVariables &x, bool extrapolate=false)
Compute the variables to be used.
Definition: CalibrationDataContainer.cxx:307
doubleTestComp.j1
j1
Definition: doubleTestComp.py:21
Analysis::kExtrapolatedRange
@ kExtrapolatedRange
Definition: CalibrationDataVariables.h:59
Analysis::CalibrationDataContainer::kEta
@ kEta
Definition: CalibrationDataContainer.h:65
Analysis::kError
@ kError
Definition: CalibrationDataVariables.h:60
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
Analysis::CalibrationDataHistogramContainer::m_uncorrelatedSyst
THashList m_uncorrelatedSyst
no need to persistify
Definition: CalibrationDataContainer.h:296
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
Analysis::CalibrationDataHistogramContainer::m_binBoundaries
std::map< unsigned int, std::vector< double > > m_binBoundaries
Cache for bin boundary information.
Definition: CalibrationDataContainer.h:291
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
Analysis::kRange
@ kRange
Definition: CalibrationDataVariables.h:58
Analysis::UncertaintyResult
std::pair< double, double > UncertaintyResult
The following typedef is for convenience: most uncertainties can be asymmetric.
Definition: CalibrationDataContainer.h:33
plotBeamSpotCompare.xd
xd
Definition: plotBeamSpotCompare.py:220
Analysis::CalibrationDataMappedHistogramContainer::findBin
Int_t findBin()
don't persistify
Definition: CalibrationDataContainer.cxx:1326
Analysis::CalibrationDataContainer::m_objResult
TObject * m_objResult
(possibly looser) upper validity bounds for extrapolation
Definition: CalibrationDataContainer.h:217
Analysis::CalibrationDataContainer::m_lowerBoundsExtrapolated
std::vector< double > m_lowerBoundsExtrapolated
Definition: CalibrationDataContainer.h:213
tolerance
Definition: suep_shower.h:17
python.grid.Add
def Add(name)
Definition: grid.py:41
Analysis::CalibrationStatus
CalibrationStatus
Definition: CalibrationDataVariables.h:56
Analysis::CalibrationDataMappedHistogramContainer::m_bins
std::vector< Bin > m_bins
don't persistify
Definition: CalibrationDataContainer.h:402
pmontree.code
code
Definition: pmontree.py:443
Analysis::CalibrationDataContainer::m_lowerBounds
std::vector< double > m_lowerBounds
Definition: CalibrationDataContainer.h:210
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
Analysis::CalibrationDataContainer::typeFromString
int typeFromString(const std::string &key) const
Connection between variable names (on histogram axes etc.) and variable 'types' as used in actual eva...
Definition: CalibrationDataContainer.cxx:292
Analysis::CalibrationDataContainer::kTagWeight
@ kTagWeight
Definition: CalibrationDataContainer.h:67
Analysis::CalibrationDataMappedHistogramContainer::checkBounds
void checkBounds()
check the bounds of validity for this calibration object
Definition: CalibrationDataContainer.cxx:1090
Analysis::CalibrationDataContainer::setUncertainty
void setUncertainty(const std::string &unc, TObject *obj)
insert the relevant object for the requested source of 'uncertainty'
Definition: CalibrationDataContainer.cxx:231
Analysis::CalibrationDataContainer::isNearlyEqual
static bool isNearlyEqual(double a, double b)
utility for comparison of doubles
Definition: CalibrationDataContainer.cxx:1744
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64
Analysis::CalibrationDataMappedHistogramContainer::m_beginMapped
unsigned int m_beginMapped
starting position of mapped variables
Definition: CalibrationDataContainer.h:399
python.PyAthena.v
v
Definition: PyAthena.py:157
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
a
TList * a
Definition: liststreamerinfos.cxx:10
ref
const boost::regex ref(r_ef)
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TH1
Definition: rootspy.cxx:268
Analysis::CalibrationDataContainer::getUpperBound
double getUpperBound(unsigned int vartype, bool extrapolate=false) const
retrieve the upper bound of validity for the requested variable type
Definition: CalibrationDataContainer.cxx:379
Analysis::CalibrationDataMappedHistogramContainer::m_lastBin
unsigned int m_lastBin
Definition: CalibrationDataContainer.h:404
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
mapped
std::vector< std::string > mapped
Definition: hcg.cxx:51
python.AtlRunQueryAMI.choice
int choice
Definition: AtlRunQueryAMI.py:210
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
Analysis::CalibrationDataMappedHistogramContainer::findMappedBin
Int_t findMappedBin(const double *x)
Definition: CalibrationDataContainer.cxx:1305
MuonHough::extrapolate
float extrapolate(const MuonLayerHough::Maximum &ref, const MuonLayerHough::Maximum &ex, bool doparabolic=false)
Definition: MuonLayerHough.cxx:519
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
Analysis::CalibrationDataContainer::kPt
@ kPt
Definition: CalibrationDataContainer.h:64
merge.status
status
Definition: merge.py:17
Analysis::CalibrationDataMappedHistogramContainer::getStatUncertainty
virtual CalibrationStatus getStatUncertainty(const CalibrationDataVariables &x, double &result)
retrieve the calibration statistical uncertainty.
Definition: CalibrationDataContainer.cxx:1185
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
python.PyAthena.obj
obj
Definition: PyAthena.py:135
Analysis::CalibrationDataContainer::getStatUncertainty
virtual CalibrationStatus getStatUncertainty(const CalibrationDataVariables &x, double &result)=0
retrieve the calibration statistical uncertainty.
doubleTestComp.j2
j2
Definition: doubleTestComp.py:22
Analysis::CalibrationDataContainer::m_upperBoundsExtrapolated
std::vector< double > m_upperBoundsExtrapolated
(possibly looser) lower validity bounds for extrapolation
Definition: CalibrationDataContainer.h:214
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37