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

#include <CalibrationDataEigenVariations.h>

Inheritance diagram for Analysis::CalibrationDataEigenVariations:
Collaboration diagram for Analysis::CalibrationDataEigenVariations:

Public Types

typedef std::set< size_t > IndexSet
 
typedef std::set< IndexSetIndexSuperSet
 

Public Member Functions

 CalibrationDataEigenVariations (const std::string &cdipath, const std::string &tagger, const std::string &wp, const std::string &jetcollection, CalibrationDataHistogramContainer *cnt, bool excludeRecommendedUncertaintySet=false, bool base=true)
 normal constructor. More...
 
virtual ~CalibrationDataEigenVariations ()
 
void excludeNamedUncertainty (const std::string &name, CalibrationDataContainer *cnt)
 exclude the source of uncertainty indicated by name from eigenvector calculations More...
 
virtual void initialize (double min_variance=1.0E-20)
 carry out the eigenvector computations. More...
 
void removeVariations (const IndexSet &set)
 remove all variations in the given set More...
 
void removeVariations (const IndexSuperSet &set)
 remove all variations in any of the given sets More...
 
void mergeVariationsFrom (const size_t &index)
 merge all variations starting from the given index More...
 
void mergeVariations (const IndexSet &set)
 merge all variations in the given set More...
 
void mergeVariations (const IndexSuperSet &set)
 merge all variations in any of the given sets More...
 
unsigned int getNumberOfNamedVariations () const
 retrieve the number of named variations More...
 
std::vector< std::string > listNamedVariations () const
 list the named variations More...
 
unsigned int getNamedVariationIndex (const std::string &name) const
 retrieve the integer index corresponding to the named variation. More...
 
unsigned int getNumberOfEigenVariations ()
 retrieve the number of eigenvector variations More...
 
bool getEigenvectorVariation (unsigned int variation, TH1 *&up, TH1 *&down)
 obtain the "up" and "down" variations for the given eigenvector number. More...
 
bool getNamedVariation (const std::string &name, TH1 *&up, TH1 *&down)
 obtain the "up" and "down" variations for the named uncertainty. More...
 
bool getNamedVariation (unsigned int nameIndex, TH1 *&up, TH1 *&down)
 obtain the "up" and "down" variations for the source uncertainty pointed to by the given index (which is assumed to correspond to the value retrieved using getNamedVariationIndex()). More...
 
bool isExtrapolationVariation (unsigned int nameIndex) const
 flag whether the given index corresponds to an extrapolation variation More...
 
virtual TMatrixDSym getEigenCovarianceMatrix ()
 also provide (some) access to the underlying information: covariance matrix corresponding to eigenvector variations More...
 
TMatrixDSym getEigenCovarianceMatrixFromVariations ()
 covariance matrix corresponding to eigenvector variations constructed from the eigen-variation More...
 
TMatrixD getJacobianReductionMatrix ()
 matrix to remove unecessary rows and columns from covariance More...
 
bool EigenVectorRecomposition (const std::string &label, std::map< std::string, std::map< std::string, float >> &coefficientMap)
 Eigenvector recomposition method. More...
 
void setVerbose (bool)
 

Protected Attributes

bool m_initialized
 flag whether the initialization has been carried out More...
 
bool m_validate
 
std::map< std::string, unsigned int > m_namedIndices
 named variations More...
 
std::vector< std::pair< TH1 *, TH1 * > > m_named
 
int m_namedExtrapolation
 named variation index for the special case of extrapolation uncertainties More...
 
std::vector< std::pair< TH1 *, TH1 * > > m_eigen
 eigenvector variations More...
 
bool m_statVariations
 indicate whether statistical uncertainties are stored as variations More...
 
std::string m_cdipath
 
std::string m_taggername
 
std::string m_wp
 
std::string m_jetauthor
 
double m_totalvariance
 
double m_capturedvariance
 
bool m_verbose
 

Private Attributes

CalibrationDataHistogramContainerm_cnt
 container object containing the basic information More...
 

Detailed Description

Definition at line 27 of file CalibrationDataEigenVariations.h.

Member Typedef Documentation

◆ IndexSet

Definition at line 29 of file CalibrationDataEigenVariations.h.

◆ IndexSuperSet

Definition at line 30 of file CalibrationDataEigenVariations.h.

Constructor & Destructor Documentation

◆ CalibrationDataEigenVariations()

Analysis::CalibrationDataEigenVariations::CalibrationDataEigenVariations ( const std::string &  cdipath,
const std::string &  tagger,
const std::string &  wp,
const std::string &  jetcollection,
CalibrationDataHistogramContainer cnt,
bool  excludeRecommendedUncertaintySet = false,
bool  base = true 
)

normal constructor.

The second argument, if true, will attempt to retrieve a 'recommended' set of uncertainties to be excluded from EV decomposition

◆ ~CalibrationDataEigenVariations()

CalibrationDataEigenVariations::~CalibrationDataEigenVariations ( )
virtual

Definition at line 355 of file CalibrationDataEigenVariations.cxx.

356 {
357  // delete all variation histograms owned by us
358  for (vector<pair<TH1*, TH1*> >::iterator it = m_eigen.begin(); it != m_eigen.end(); ++it) {
359  delete it->first;
360  delete it->second;
361  }
362 
363  for (vector<pair<TH1*, TH1*> >::iterator it = m_named.begin(); it != m_named.end(); ++it) {
364  delete it->first;
365  delete it->second;
366  }
367 }

Member Function Documentation

◆ EigenVectorRecomposition()

bool CalibrationDataEigenVariations::EigenVectorRecomposition ( const std::string &  label,
std::map< std::string, std::map< std::string, float >> &  coefficientMap 
)

Eigenvector recomposition method.

Definition at line 1109 of file CalibrationDataEigenVariations.cxx.

1111 {
1112  // Calculating eigen vector recomposition coefficient map and pass to
1113  // user by reference. Return true if method success. Return false and
1114  // will not modify coefficientMap if function failed.
1115  //
1116  // label: flavour label
1117  // coefficientMap: (reference to) coefficentMap which will be used as return value.
1118 
1119  if (! m_initialized) initialize();
1120 
1121  std::vector<TH1*> originSF_hvec;
1122  std::vector<TH1*> eigenSF_hvec;
1123 
1124  // Retrieving information for calculation
1125  std::vector<string>fullUncList = m_cnt->listUncertainties();
1126  std::vector<string> uncList;
1127  for (unsigned int t = 0; t < fullUncList.size(); ++t) {
1128  // entries that should never be included
1129  if (fullUncList[t] == "comment" || fullUncList[t] == "result" || fullUncList[t] == "combined" ||
1130  fullUncList[t] == "statistics" || fullUncList[t] == "systematics" || fullUncList[t] == "MCreference" ||
1131  fullUncList[t] == "MChadronisation" || fullUncList[t] == "extrapolation" || fullUncList[t] == "ReducedSets" ||
1132  fullUncList[t] == "excluded_set") continue;
1133 
1134  // entries that can be excluded if desired
1135  if (m_namedIndices.find(fullUncList[t]) != m_namedIndices.end()) continue;
1136 
1137  TH1* hunc = dynamic_cast<TH1*>(m_cnt->GetValue(fullUncList[t].c_str()));
1138  if (not hunc){
1139  std::cerr<<"CalibrationDataEigenVariations::EigenVectorRecomposition: dynamic cast failed\n";
1140  continue;
1141  }
1142 
1143  Int_t nx = hunc->GetNbinsX();
1144  Int_t ny = hunc->GetNbinsY();
1145  Int_t nz = hunc->GetNbinsZ();
1146  Int_t bin = 0;
1147  bool retain = false; // Retain the histogram?
1148 
1149  // discard empty histograms
1150  // Read all bins without underflow&overflow
1151  for(Int_t binx = 1; binx <= nx; binx++)
1152  for(Int_t biny = 1; biny <= ny; biny++)
1153  for(Int_t binz = 1; binz <= nz; binz++){
1154  bin = hunc->GetBin(binx, biny, binz);
1155  if (fabs(hunc->GetBinContent(bin)) > 1E-20){
1156  retain = true;
1157  break;
1158  }
1159  }// end hist bin for-loop
1160  if (!retain){
1161  if (m_verbose) std::cout<<"Eigenvector Recomposition: Empty uncertainty "<<fullUncList.at(t)<<" is discarded."<<std::endl;
1162  continue; // discard the vector
1163  }
1164 
1165  uncList.push_back(fullUncList.at(t));
1166  originSF_hvec.push_back(hunc);
1167  }
1168 
1169  TH1* nom = dynamic_cast<TH1*>(m_cnt->GetValue("result")); // Nominal SF hist
1170  if (not nom){
1171  if (m_verbose) std::cout<<"Eigenvector Recomposition: dynamic cast failed\n";
1172  return false;
1173  }
1174  int dim = nom->GetDimension();
1175  Int_t nx = nom->GetNbinsX();
1176  Int_t ny = nom->GetNbinsY();
1177  Int_t nz = nom->GetNbinsZ();
1178  Int_t nbins = nx;
1179  if(dim > 1) nbins *= ny;
1180  if(dim > 2) nbins *= nz;
1181  TMatrixD matSF(uncList.size(), nbins);
1182  Int_t col = 0; // mark the column number
1183  // Fill the Delta SF Matrix
1184  for(unsigned int i = 0; i < uncList.size(); i++){
1185  col = 0;
1186  // Loop all bins except underflow&overflow bin
1187  for(int binz = 1; binz <= nz; binz++)
1188  for(int biny = 1; biny <= ny; biny++)
1189  for(int binx = 1; binx <= nx; binx++){
1190  Int_t bin = originSF_hvec.at(i)->GetBin(binx, biny, binz);
1191  TMatrixDRow(matSF,i)[col] = originSF_hvec[i]->GetBinContent(bin);
1192  col++;
1193  }
1194  }
1195 
1196  // get eigen vectors of scale factors. Note that this is not the original eigen-vector.
1197  int nEigen = getNumberOfEigenVariations();
1198  TH1* up = nullptr;
1199  TH1* down = nullptr;
1200  for (int i = 0; i < nEigen; i++){
1201  if (!getEigenvectorVariation(i, up, down)){
1202  std::cerr<<"EigenVectorRecomposition: Error on retrieving eigenvector "<<i<<std::endl;
1203  return false;
1204  }
1205  //Need uncertainty value so subtract central calibration here.
1206  up->Add(nom, -1);
1207  eigenSF_hvec.push_back(up);
1208  }
1209  TMatrixD matEigen(nEigen, nbins);
1210 
1211  // Fill the Eigen Matrix
1212  for(int i = 0; i < nEigen; i++){
1213  col = 0;
1214  // Read 300 bins without underflow&overflow
1215  for(int binz = 1; binz <= nz; binz++)
1216  for(int biny = 1; biny <= ny; biny++)
1217  for(int binx = 1; binx <= nx; binx++){
1218  Int_t bin = eigenSF_hvec.at(i)->GetBin(binx, biny, binz);
1219  TMatrixDRow(matEigen,i)[col] = eigenSF_hvec[i]->GetBinContent(bin);
1220  col++;
1221  }
1222  }
1223 
1224  // Sanity check:
1225  TMatrixD matEigenOriginal = matEigen;
1226  TMatrixD matEigenTranspose = matEigen;
1227  matEigenTranspose = matEigenTranspose.T();
1228  TMatrixD matOriginalTimesTranspose = matEigenOriginal*matEigenTranspose;
1229  TMatrixD matEigenInvert = matEigenTranspose*matOriginalTimesTranspose.Invert();
1230  //(matEigenOriginal*matEigenInvert).DrawClone("colz"); // This should give us an identity matrix
1231 
1232  TMatrixD matCoeff = matSF*matEigenInvert;
1233  int nRows = matCoeff.GetNrows();
1234  int nCols = matCoeff.GetNcols();
1235  std::map<std::string, float> temp_map;
1236  for (int col = 0; col < nCols; col++){
1237  temp_map.clear();
1238  for(int row = 0; row < nRows; row++){
1239  temp_map[uncList[row]] = TMatrixDRow(matCoeff, row)[col];
1240  }
1241  coefficientMap["Eigen_"+label+"_"+std::to_string(col)] = temp_map;
1242  }
1243 
1244  return true;
1245 }

◆ excludeNamedUncertainty()

void CalibrationDataEigenVariations::excludeNamedUncertainty ( const std::string &  name,
CalibrationDataContainer cnt 
)

exclude the source of uncertainty indicated by name from eigenvector calculations

Definition at line 371 of file CalibrationDataEigenVariations.cxx.

372 {
373  // Exclude the source of uncertainty identified by the given name from being used
374  // in the construction of the covariance matrix to be diagonalised.
375  // Notes:
376  // - Some names returned by CalibrationDataContainer::listUncertainties() are not
377  // meaningful in this context, and specifying them is not allowed.
378  // - Once the eigenvector diagonalisation has been carried out, this method may
379  // not be used anymore.
380 
381  if (m_initialized) {
382  std::cerr << "CalibrationDataEigenVariations::excludeNamedUncertainty error:" << " initialization already done" << std::endl;
383  } else if (name == "comment" || name == "result" || name == "systematics" ||
384  name == "statistics" || name == "combined" || name == "extrapolation" ||
385  name == "MCreference" || name == "MChadronisation" || name == "ReducedSets" ||
386  name == "excluded_set" || name == "" || name == " ") // <--- these last two handle some cases that may turn up
387  {
388  std::cerr << "CalibrationDataEigenVariations::excludeNamedUncertainty error:" << " name " << name << " not allowed" << std::endl;
389  }
390  // in case multiple uncertainties should be discarded
391  else if (name.back() == '*'){
392  std::string temp_name = name.substr(0, name.size()-1); //remove "*"
393  std::vector<std::string> uncs = m_cnt->listUncertainties();
394  std::vector<std::string> unc_subgroup;
395  std::copy_if(uncs.begin(), uncs.end(), back_inserter(unc_subgroup),
396  [&temp_name](const std::string& el) {
397  return el.compare(0, temp_name.size(), temp_name) == 0;
398  });
399  if (m_verbose) std::cout <<"Found a group of uncertainties to exclude: " <<name <<" found " <<unc_subgroup.size() <<" uncertainties corresponding to the query" <<std::endl;
400  for (const auto& single_name : unc_subgroup){
401  // only really add if the entry is not yet in the list
402  if (m_namedIndices.find(single_name) == m_namedIndices.end()) {
403  if (m_verbose) std::cout << "Name : " << single_name << std::endl;
404  m_named.push_back(std::pair<TH1*, TH1*>(0, 0));
405  m_namedIndices[single_name] = m_named.size()-1;
406  }
407  }
408  }
409  else if (! cnt->GetValue(name.c_str())){
410  std::cerr << "CalibrationDataEigenVariations::excludeNamedUncertainty error:" << " uncertainty named " << name << " not found" << std::endl;
411  }
412 }

◆ getEigenCovarianceMatrix()

TMatrixDSym CalibrationDataEigenVariations::getEigenCovarianceMatrix ( )
virtual

also provide (some) access to the underlying information: covariance matrix corresponding to eigenvector variations

Reimplemented in Analysis::CalibrationDataGlobalEigenVariations.

Definition at line 416 of file CalibrationDataEigenVariations.cxx.

417 {
418  // Construct the covariance matrix that is to be diagonalised.
419  // Note that extrapolation uncertainties (identified by the keyword "extrapolation,
420  // this will pertain mostly to the extrapolation to high jet pt) are always excluded
421  // since by definition they will not apply to the normal calibration bins. Instead
422  // this uncertainty has to be dealt with as a named variation. In addition there are
423  // other items ("combined", "systematics") that will not be dealt with correctly
424  // either and hence are excluded as well).
425  //
426  // Note that if an explicit covariance matrix is supplied (at present this may be
427  // the case only for statistical uncertainties: in the case of "continuous tagging",
428  // multinomial statistics applies so bin-to-bin correlations exist) this will be
429  // used instead of constructing the statistical uncertainties' covariance matrix on
430  // the fly.
431 
432  // retrieve the central calibration
433  TH1* result = dynamic_cast<TH1*>(m_cnt->GetValue("result"));
434  if (not result){
435  std::cerr<<"CalibrationDataEigenVariations::getEigenCovarianceMatrix(): failed dynamic cast to TH1*\n";
436  return TMatrixDSym();
437  }
438 
439  // loop over the uncertainties to construct the covariance matrix for all uncertainties
440  // to be addressed using the eigenvector method.
441 
442  // First, treat the statistics separately.
443  // Account for the possibility that this is handled as a (non-trivial) covariance matrix
444  TMatrixDSym* sCov = dynamic_cast<TMatrixDSym*>(m_cnt->GetValue("statistics"));
445 
446  // Alternatively, statistical uncertainties may be accounted for as variations (i.e., much like systematic uncertainties).
447  // In that case, we create a null matrix here and add the statistical contributions along with the systematic ones.
448  TMatrixDSym cov = (sCov) ? *sCov : getStatCovarianceMatrix(result, m_statVariations);
449 
450  // Then loop through the list of (other) uncertainties
451  std::vector<string> uncs = m_cnt->listUncertainties();
452  for (unsigned int t = 0; t < uncs.size(); ++t) {
453  // entries that should never be included
454  if (uncs[t] == "comment" || uncs[t] == "result" || uncs[t] == "combined" ||
455  uncs[t] == "statistics" || uncs[t] == "systematics" || uncs[t] == "MCreference" ||
456  uncs[t] == "MChadronisation" || uncs[t] == "extrapolation" || uncs[t] == "ReducedSets" ||
457  uncs[t] == "excluded_set") continue;
458  // entries that can be excluded if desired
459  if (m_namedIndices.find(uncs[t]) != m_namedIndices.end()) continue;
460  TH1* hunc = dynamic_cast<TH1*>(m_cnt->GetValue(uncs[t].c_str()));
461  if (not hunc){
462  std::cerr<< "CalibrationDataEigenVariations::getEigenCovarianceMatrix(): dynamic cast failed\n";
463  continue;
464  }
465  cov += getSystCovarianceMatrix(result, hunc, m_cnt->isBinCorrelated(uncs[t]), m_cnt->getTagWeightAxis()); // <-------- This is where we add the covariance matrices together to form the "total covariance"
466  }
467 
468  return cov;
469 }

◆ getEigenCovarianceMatrixFromVariations()

TMatrixDSym CalibrationDataEigenVariations::getEigenCovarianceMatrixFromVariations ( )

covariance matrix corresponding to eigenvector variations constructed from the eigen-variation

Definition at line 473 of file CalibrationDataEigenVariations.cxx.

474 {
475  // Construct the (Eigen-variation part of the) covariance matrix from the individual variations.
476  // This must be called _after_ initialize()!
477 
478  // retrieve the central calibration
479  TH1 *result = dynamic_cast<TH1*>(m_cnt->GetValue("result"));
480  TMatrixD jac = getJacobianReductionMatrix();
481  int nbins = jac.GetNcols();
482  TMatrixDSym cov(nbins);
483  auto variation = std::make_unique<double[]>(nbins);
484 
485  for (const std::pair<TH1*, TH1*>& it : m_eigen){ // m_eigen is vector of pairs of TH1* which point to TH1's representing the upVariation and downVariation respectively
486  TH1* resultVariedUp = it.first; // <--------------- This is the "result" but "varied" upwards - i.e. how the result would look like if the systematic "it" was imposed
487  for (unsigned int u = 0; u < (unsigned int) nbins; ++u) variation[u] = resultVariedUp->GetBinContent(u) - result->GetBinContent(u);
488  for (int u = 0; u < nbins; ++u){
489  for (int v = 0; v < nbins; ++v){
490  cov(u, v) += variation[u]*variation[v];
491  }
492  }
493  }
494 
495  return cov;
496 }

◆ getEigenvectorVariation()

bool CalibrationDataEigenVariations::getEigenvectorVariation ( unsigned int  variation,
TH1 *&  up,
TH1 *&  down 
)

obtain the "up" and "down" variations for the given eigenvector number.

The return value will be false if the eigenvector number is invalid.

Definition at line 1018 of file CalibrationDataEigenVariations.cxx.

1020 {
1021  // Return the pointers to the up- and downward variation histogram for the specified
1022  // eigenvector variation. In case of an invalid variation number, null pointers will
1023  // be returned and the return value will be false.
1024  //
1025  // variation: eigenvector variation number
1026  // up: (reference to) pointer to upward variation histogram
1027  // down: (reference to) pointer to downward variation histogram
1028 
1029  if (! m_initialized) initialize();
1030 
1031  if (variation < m_eigen.size()) {
1032  up = m_eigen[variation].first;
1033  down = m_eigen[variation].second;
1034  return true;
1035  }
1036 
1037  up = down = 0;
1038  return false;
1039 }

◆ getJacobianReductionMatrix()

TMatrixD CalibrationDataEigenVariations::getJacobianReductionMatrix ( )

matrix to remove unecessary rows and columns from covariance

Definition at line 500 of file CalibrationDataEigenVariations.cxx.

501 {
502  // Construct the matrix that removes the rows and columns that fail to influence
503  // the eigen-variations. To reduce the covariance matrix, do the following:
504  //
505  // TMatrixDSym cov = getEigenCovarianceMatrix();
506  // TMatrixDSym jac = getJacobianReductionMatrix(); // <------------ This is an upper triangular matrix of 1's. Similarity transformation will do...
507  // TMatrixDSym redSystematicCovMatrix = cov.Similarity(jac);
508 
509  // retrieve the central calibration
510  TH1* result = dynamic_cast<TH1*>(m_cnt->GetValue("result"));
511  if (not result){
512  std::cerr<<"CalibrationDataEigenVariations::getJacobianReductionMatrix(): dynamic cast failed\n";
513  return TMatrixD();
514  }
515 
516  // loop over the uncertainties to construct the covariance matrix for all uncertainties
517  // to be addressed using the eigenvector method.
518 
519  // Retrieve the un-compressed Eigenvector variation covariance matrix
520  // (only needed to check for unexpected singularities)
521  TMatrixDSym cov = getEigenCovarianceMatrix();
522 
523  // Compute the original number of bins
524  int nbins = result->GetNbinsX()+2;
525  int ndim = result->GetDimension();
526  if (ndim > 1) nbins*= (result->GetNbinsY()+2);
527  if (ndim > 2) nbins*= (result->GetNbinsZ()+2);
528 
529  // Start by "compressing" the covariance matrix (removing columns/rows containing zeros only)
530  int nZeros=0;
531  std::vector<int> zeroComponents;
532  if (cov.GetNrows() != nbins) {
533  std::cerr << " error: covariance matrix size (" << cov.GetNrows() << ") doesn't match histogram size (" << nbins << ")" << std::endl;
534  return TMatrixDSym();
535  }
536 
537  // First flag all the zeros
538  for (int i = 0; i < nbins; ++i) {
539  // Directly identify the under- and overflow bins
540  Int_t binx, biny, binz;
541  result->GetBinXYZ(i, binx, biny, binz);
542  if ((binx == 0 || binx == result->GetNbinsX()+1) ||
543  (ndim > 1 && (biny == 0 || biny == result->GetNbinsY()+1)) ||
544  (ndim > 2 && (binz == 0 || binz == result->GetNbinsZ()+1)))
545  {
546  ++nZeros;
547  zeroComponents.push_back(i);
548  }
549  // Try a first (quick) identification of rows/columns of zeros by the first element in each row
550  // If "successful", check the whole row in more detail
551  else if (fabs(cov(i,0)) < 1e-10) {
552  bool isThereANonZero(false);
553  for (int j = 0; j < nbins; ++j) {
554  if (fabs(cov(i,j)) > 1e-10) {
555  isThereANonZero=true; break;
556  }
557  }
558  if (! isThereANonZero) {
559  ++nZeros;
560  zeroComponents.push_back(i);
561  }
562  }
563  }
564 
565  // **** COMMENTED OUT FOR NOW.
566  // Leave it here in case the calibration method will change again in the future.
567  // No need to reweight the SF by the efficiency of that bin (MCreference always = 0)
568 
569  // Determine whether the container is for "continuous" calibration.
570  // This is important since the number of independent scale factors (for each pt or eta bin)
571  // is reduced by 1 compared to the number of tag weight bins (related to the fact that the fractions
572  // of events in tag weight bins have to sum up to unity).
573  // int axis = m_cnt->getTagWeightAxis();
574  // bool doContinuous = false; unsigned int weightAxis = 0;
575 
576  // if (axis >= 0) {
577  // doContinuous = true;
578  // // weightAxis = (unsigned int) axis;
579  // // In this case, verify that the special "uncertainty" entry that is in fact the reference MC tag
580  // // weight fractions is present. These tag weight fractions are needed in order to carry out the
581  // // diagonalisation successfully.
582  // if (! dynamic_cast<TH1*>(m_cnt->GetValue("MCreference"))) {
583  // std::cerr << " Problem: continuous calibration object found without MC reference tag weight histogram " << std::endl;
584  // return TMatrixDSym();
585  // }
586  // }
587 
588  // Only relevant for continuous calibration containers, but in order to void re-computation we
589  // retrieve them here
590  // Int_t nbinx = result->GetNbinsX()+2, nbiny = result->GetNbinsY()+2, nbinz = result->GetNbinsZ()+2;
591 
592  // // If we are indeed dealing with a "continuous" calibration container, ignore one tag weight row
593  // const int skipTagWeightBin = 1; // NB this follows the histogram's bin numbering
594  // if (doContinuous) {
595  // for (Int_t binx = 1; binx < nbinx-1; ++binx)
596  // for (Int_t biny = 1; biny < nbiny-1; ++biny)
597  // for (Int_t binz = 1; binz < nbinz-1; ++binz) {
598  // if ((weightAxis == 0 && binx == skipTagWeightBin) ||
599  // (weightAxis == 1 && biny == skipTagWeightBin) ||
600  // (weightAxis == 2 && binz == skipTagWeightBin)) {
601  // // At this point we simply add these to the 'null' elements
602  // ++nZeros;
603  // zeroComponents.push_back(result->GetBin(binx, biny, binz));
604  // }
605  // }
606  // }
607 
608  if (nZeros >= nbins) {
609  std::cerr << " Problem. Found n. " << nZeros << " while size of matrix is " << nbins << std::endl;
610  return TMatrixDSym();
611  }
612 
613  int size = nbins - nZeros; // <--- Tis the size of the matrix removing zeros from the covariance matrix
614 
615  TMatrixT<double> matrixVariationJacobian(size,nbins);
616  int nMissed=0;
617  for (int i = 0; i < nbins; ++i) { //full size
618  bool missed=false;
619  for (unsigned int s = 0; s < zeroComponents.size(); ++s) { // <-------- Basically what this does is it flags "missed" for a given "i" of the full bin size
620  if (zeroComponents.at(s) == i) { // <-------- if "i" is in "zeroComponents". Breaks (because it found that it's to be missed)
621  missed = true;
622  break;
623  }
624  }
625  if (missed) { // <-------- Finally, if "i" is to be missed, increase "nMissed" by one, and....
626  ++nMissed;
627  continue;
628  }
629  matrixVariationJacobian(i-nMissed,i)=1; // <-------- ... this ALWAYS adds a one. If zero "nMissed", add to diagonal. otherwise off-diagonal
630  } // <-------- This matrix only add 1's on/off diagonal, upper triangular matrix
631 
632  return matrixVariationJacobian;
633 }

◆ getNamedVariation() [1/2]

bool CalibrationDataEigenVariations::getNamedVariation ( const std::string &  name,
TH1 *&  up,
TH1 *&  down 
)

obtain the "up" and "down" variations for the named uncertainty.

The return value will be false if the given name is not listed as being excluded from the eigenvector calculations.

Definition at line 1043 of file CalibrationDataEigenVariations.cxx.

1045 {
1046  // Return the pointers to the up- and downward variation histogram for the specified
1047  // named variation. In case of an invalid named variation, null pointers will
1048  // be returned and the return value will be false.
1049  //
1050  // name: named variation
1051  // up: (reference to) pointer to upward variation histogram
1052  // down: (reference to) pointer to downward variation histogram
1053 
1054  map<string, unsigned int>::const_iterator it = m_namedIndices.find(name);
1055  if (it != m_namedIndices.end()) return getNamedVariation(it->second, up, down);
1056 
1057  up = down = 0;
1058  return false;
1059 }

◆ getNamedVariation() [2/2]

bool CalibrationDataEigenVariations::getNamedVariation ( unsigned int  nameIndex,
TH1 *&  up,
TH1 *&  down 
)

obtain the "up" and "down" variations for the source uncertainty pointed to by the given index (which is assumed to correspond to the value retrieved using getNamedVariationIndex()).

The return value will be false if the index is out of bounds.

Definition at line 1063 of file CalibrationDataEigenVariations.cxx.

1065 {
1066  // Return the pointers to the up- and downward variation histogram for the specified
1067  // named variation. In case of an invalid named variation number, null pointers will
1068  // be returned and the return value will be false.
1069  //
1070  // nameIndex: named variation number
1071  // up: (reference to) pointer to upward variation histogram
1072  // down: (reference to) pointer to downward variation histogram
1073 
1074  if (! m_initialized) initialize();
1075 
1076  if (nameIndex < m_named.size()) {
1077  up = m_named[nameIndex].first;
1078  down = m_named[nameIndex].second;
1079  return true;
1080  }
1081 
1082  up = down = 0;
1083  return false;
1084 }

◆ getNamedVariationIndex()

unsigned int CalibrationDataEigenVariations::getNamedVariationIndex ( const std::string &  name) const

retrieve the integer index corresponding to the named variation.

This can be used to speed up computations by avoiding string comparisons. Note that this function is not protected against passing an invalid name.

Definition at line 1088 of file CalibrationDataEigenVariations.cxx.

1089 {
1090  // Return the integer index corresponding to the named variation.
1091  // Note that no checks are made on the validity of the name provided.
1092 
1093  map<string, unsigned int>::const_iterator it = m_namedIndices.find(name);
1094  return it->second;
1095 }

◆ getNumberOfEigenVariations()

unsigned int CalibrationDataEigenVariations::getNumberOfEigenVariations ( )

retrieve the number of eigenvector variations

Definition at line 1010 of file CalibrationDataEigenVariations.cxx.

1011 {
1012  if (! m_initialized) initialize();
1013  return m_eigen.size();
1014 }

◆ getNumberOfNamedVariations()

unsigned int CalibrationDataEigenVariations::getNumberOfNamedVariations ( ) const

retrieve the number of named variations

Definition at line 988 of file CalibrationDataEigenVariations.cxx.

989 {
990  // Returns the number of named variations
991 
992  return m_namedIndices.size();
993 }

◆ initialize()

void CalibrationDataEigenVariations::initialize ( double  min_variance = 1.0E-20)
virtual

carry out the eigenvector computations.

Exclusion of any source of uncertainty has to be done before calling this method

Reimplemented in Analysis::CalibrationDataGlobalEigenVariations.

Definition at line 637 of file CalibrationDataEigenVariations.cxx.

638 {
639  // This is this class's most important method, in the sense that it does all the
640  // math and constructs all "variation" histograms (for both eigenvector and named
641  // named variations). This constitutes the full initialisation of the class.
642  // This method is meant to be called only after all calls (if any) to the
643  // CalibrationDataEigenVariations::excludeNamedUncertainty() method.
644 
645  // retrieve the central calibration
646  TH1* result = dynamic_cast<TH1*>(m_cnt->GetValue("result"));
647  if (not result){
648  std::cerr<<"CalibrationDataEigenVariations::initialize: dynamic cast failed\n";
649  return;
650  }
651  // First step: construct the original covariance matrix
652  TMatrixDSym cov = getEigenCovarianceMatrix();
653  TMatrixDSym corr(result->GetNbinsX()*result->GetNbinsY()*result->GetNbinsZ()); // We want to construct the correlation matrix in order to compare the final eigenvariations correlation matrix to it
654 
655  int rowc = 0;
656  for (int row = 0 ; row < cov.GetNrows() ; row++){
657  int colc = 0;
658  bool colb = false;
659  for (int col = 0 ; col < cov.GetNcols() ; col++){
660  if(!cov(row,col) || !cov(row,row) || !cov(col,col) || cov(row,row)<1.0e-6 || cov(col,col)<1.0e-6 ) continue; // really don't want to divide by zero...
661  colb=true;
662  long double rowvar = sqrt(cov(row,row));
663  long double colvar = sqrt(cov(col,col));
664  corr(rowc,colc) = cov(row,col)/(rowvar * colvar); // divide each element by the variance
665  colc++;
666  }
667  if (colb){
668  rowc++;
669  }
670  }
671 
672  // Second step: create the variations for the named sources of uncertainty (easy...)
674  pair<TH1*, TH1*>& p = m_named[it->second];
675  TH1* hunc = (TH1*) m_cnt->GetValue(it->first.c_str());
676  TString namedvar("namedVar");
677  namedvar += it->first.c_str();
678  TString namedvarUp(namedvar); namedvarUp += "_up";
679  TString namedvarDown(namedvar); namedvarDown += "_down";
680  TH1* resultVariedUp = (TH1*)result->Clone(namedvarUp); resultVariedUp->Add(hunc, 1.0); resultVariedUp->SetDirectory(0);
681  TH1* resultVariedDown = (TH1*)result->Clone(namedvarDown); resultVariedDown->Add(hunc, -1.0); resultVariedDown->SetDirectory(0);
682  p.first = resultVariedUp;
683  p.second = resultVariedDown;
684  }
685  // Refinement: add the "extrapolation" uncertainty as a named uncertainty, if the histogram is provided
686  // This is a bit special, since the extrapolation uncertainty histogram has a different size than other histograms
687  if (TH1* hunc = (TH1*) m_cnt->GetValue("extrapolation")) { // this is just saying "if it exists"...
688  TH1* resultVariedUp = (TH1*) hunc->Clone("extrapolation_up"); resultVariedUp->SetDirectory(0);
689  TH1* resultVariedDown = (TH1*) hunc->Clone("extrapolation_down"); resultVariedDown->SetDirectory(0);
690  Int_t nbinx = hunc->GetNbinsX()+2, nbiny = hunc->GetNbinsY()+2, nbinz = hunc->GetNbinsZ()+2;
691  Int_t firstbinx = hunc->GetXaxis()->FindFixBin(result->GetXaxis()->GetBinCenter(1));
692  Int_t firstbiny = result->GetDimension() > 1 ? hunc->GetYaxis()->FindFixBin(result->GetYaxis()->GetBinCenter(1)) : 1;
693  Int_t firstbinz = result->GetDimension() > 2 ? hunc->GetZaxis()->FindFixBin(result->GetZaxis()->GetBinCenter(1)) : 1;
694  for (Int_t binx = 1; binx < nbinx-1; ++binx) {
695  Int_t binxResult = binx - firstbinx + 1;
696  if (binxResult < 1) binxResult = 1;
697  if (binxResult > result->GetNbinsX()) binxResult = result->GetNbinsX();
698  for (Int_t biny = 1; biny < nbiny-1; ++biny) {
699  Int_t binyResult = biny - firstbiny + 1;
700  if (binyResult > result->GetNbinsY()) binyResult = result->GetNbinsY();
701  for (Int_t binz = 1; binz < nbinz-1; ++binz) {
702  Int_t binzResult = binz - firstbinz + 1;
703  if (binzResult > result->GetNbinsZ()) binzResult = result->GetNbinsZ();
704  Int_t bin = hunc->GetBin(binx, biny, binz);
705  double contResult = result->GetBinContent(binxResult, binyResult, binzResult);
706  resultVariedUp->SetBinContent(bin, contResult + hunc->GetBinContent(bin));
707  resultVariedDown->SetBinContent(bin, contResult - hunc->GetBinError(bin));
708  }
709  }
710  }
711  m_named.push_back(std::make_pair(resultVariedUp, resultVariedDown));
712  m_namedExtrapolation = m_namedIndices["extrapolation"] = m_named.size()-1;
713  }
714 
715  // Third step: compute the eigenvector variations corresponding to the remaining sources of uncertainty
716  int nbins = result->GetNbinsX()+2;
717  int ndim = result->GetDimension();
718  if (ndim > 1) nbins*= (result->GetNbinsY()+2);
719  if (ndim > 2) nbins*= (result->GetNbinsZ()+2);
720 
721 
722  // // Determine whether the container is for "continuous" calibration.
723  // // This is important since the number of independent scale factors (for each pt or eta bin)
724  // // is reduced by 1 compared to the number of tag weight bins (related to the fact that the fractions
725  // // of events in tag weight bins have to sum up to unity).
726  // int axis = m_cnt->getTagWeightAxis();
727  // bool doContinuous = false; unsigned int weightAxis = 0;
728 
729  //if (axis >= 0) {
730  // doContinuous = true;
731  // weightAxis = (unsigned int) axis;
732  // // In this case, verify that the special "uncertainty" entry that is in fact the reference MC tag
733  // // weight fractions is present. These tag weight fractions are needed in order to carry out the
734  // // diagonalisation successfully.
735  // NOTE: MCreference is not used at the moment (always 0 in the CDI). Comment it out.
736  // if (! dynamic_cast<TH1*>(m_cnt->GetValue("MCreference"))) {
737  // std::cerr << " Problem: continuous calibration object found without MC reference tag weight histogram " << std::endl;
738  // return;
739  // }
740  //}
741 
742  // Only relevant for continuous calibration containers, but in order to void re-computation we
743  // retrieve them here
744  // Int_t nbinx = result->GetNbinsX()+2, nbiny = result->GetNbinsY()+2, nbinz = result->GetNbinsZ()+2;
745 
746  TMatrixT<double> matrixVariationJacobian = getJacobianReductionMatrix();
747  int size = matrixVariationJacobian.GetNrows();
748 
749  // Reduce the matrix to one without the zeros, using a "similarity" transformation
750 
751  const TMatrixDSym matrixCovariance = cov.Similarity(matrixVariationJacobian);
752 
753  // Carry out the Eigenvector decomposition on this matrix
754  TMatrixDSymEigen eigenValueMaker (matrixCovariance);
755  TVectorT<double> eigenValues = eigenValueMaker.GetEigenValues();
756  TMatrixT<double> eigenVectors = eigenValueMaker.GetEigenVectors();
757  TMatrixT<double> matrixVariations (size,size);
758 
759  //compute the total variance by summing the eigenvalues
760  m_totalvariance = eigenValues.Sum(); //
761 
762  for (int i = 0; i < size; ++i) {
763  //now go back
764  for (int r = 0; r < size; ++r)
765  //first index is the variation number, second corresponds to the pT bin //<--------- The "eigenvariations" matrix is the "C" matrix which has CKC^T = I with "K" being the o.g. covariance matrix, and "I" is the identity
766  matrixVariations(i,r) = -1.0*eigenVectors[r][i]*sqrt(fabs(eigenValues[i])); // <--------- So the result is a matrix (eigenvariation) which is the eigenvector scaled by the sqrt(eigenvalue)
767  } // <------- matrixVariations: each row is one variation, each column is the pT bin.
768 
769  TMatrixT<double> matrixVariationsWithZeros = matrixVariations * matrixVariationJacobian;
770 
771  // Construct the initial set of variations from this
772  for (int i = 0; i < matrixVariationsWithZeros.GetNrows(); ++i) {
773  // TString superstring(result->GetName());
774  // superstring += "_eigenVar";
775  TString superstring("eigenVar");
776  superstring+=i;
777 
778  TString nameUp(superstring); nameUp += "_up";
779  TString nameDown(superstring); nameDown += "_down";
780  // TString nameUnc(superstring); nameUnc+= "_unc";
781 
782  TH1* resultVariedUp = (TH1*)result->Clone(nameUp); resultVariedUp->SetDirectory(0); // <------- clone "result" hist, call it "up", and SetDirectory(0) means histogram doesn't belong to any directory.
783  TH1* resultVariedDown = (TH1*)result->Clone(nameDown); resultVariedDown->SetDirectory(0);
784 
785  for (int u = 0; u < nbins; ++u) {
786  resultVariedUp->SetBinContent(u,result->GetBinContent(u) + matrixVariationsWithZeros(i,u)); // <----- This actually constructs the up-variation histogram!
787  resultVariedDown->SetBinContent(u,result->GetBinContent(u) - matrixVariationsWithZeros(i,u)); // <--- This likewise constructs the down-var., bin-by-bin.
788  }
789 
790  m_eigen.push_back(std::make_pair(resultVariedUp, resultVariedDown));
791 
792  } //end eigenvector size
793 
794  // Remove variations that are below the given tolerance (effectively meaning that they don't have any effect) // <--------- Here we prune systematics
795  IndexSet final_set; // <-------- What's IndexSet? It's a typedef of std::set<size_t>, where size_t = int
796  size_t current_set = 0;
797  for (size_t index = 0; index < m_eigen.size(); ++index) {
798  bool keep_variation = false;
799  TH1 *up = static_cast<TH1*>(m_eigen[index].first->Clone()); up->SetDirectory(0);
800 
801  up->Add(result, -1.0);
802 
803  for (int bin = 1; bin <= nbins; ++bin) {
804  if (fabs(up->GetBinContent(bin)) > min_variance) { // <----- If you find even ONE bin with big enough variance, we keep the whole systematic.
805  keep_variation = true;
806  break;
807  }
808  }
809  delete up;
810  if (!keep_variation){ // <------ At this stage, if we find no bins in the systematic with large enough variation, we insert it to "final_set" for removal/pruning
811  final_set.insert(current_set);
812  } else {
813  m_capturedvariance += eigenValues[index]; // let's add up the variance that the eigenvariation contributes to the total
814  }
815  ++current_set;
816  }
817  if (final_set.size() > 0)
818  if (m_verbose) std::cout << "CalibrationDataEigenVariations: Removing " << final_set.size() << " eigenvector variations leading to sub-tolerance effects, retaining " << m_eigen.size()-final_set.size() << " variations" << std::endl;
819 
820  removeVariations(final_set); // <----------------- This method actually performs the reduction. The above logic simply flags which variations to GET RID OF, inserting them into "final_set"
821 
822  if (m_verbose) std::cout << " The total variance is " << m_totalvariance << " and the reduction captured " << 100*(m_capturedvariance/m_totalvariance) << "% of this." << std::endl;
826  if (m_validate){ // <---- this flag can be set manually in a local checkout of this package (temporary fix)
827  validate_reduction(cov.GetNrows(), corr, m_eigen, result, "SFEigen", m_taggername, m_wp, m_jetauthor); // <------ This method is simply here to report the matrix comparison, for reduction scheme validation
828  }
829 
830  m_initialized = true;
831 }

◆ isExtrapolationVariation()

bool CalibrationDataEigenVariations::isExtrapolationVariation ( unsigned int  nameIndex) const

flag whether the given index corresponds to an extrapolation variation

Definition at line 1099 of file CalibrationDataEigenVariations.cxx.

1100 {
1101  // Verifies whether the given named variation index corresponds to the extrapolation
1102  // uncertainty.
1103 
1104  return (m_namedExtrapolation == int(nameIndex));
1105 }

◆ listNamedVariations()

vector< string > CalibrationDataEigenVariations::listNamedVariations ( ) const

list the named variations

Definition at line 997 of file CalibrationDataEigenVariations.cxx.

998 {
999  // Provides the list of named variations
1000 
1002  for (map<string, unsigned int>::const_iterator it = m_namedIndices.begin(); it != m_namedIndices.end(); ++it){
1003  names.push_back(it->first);
1004  }
1005  return names;
1006 }

◆ mergeVariations() [1/2]

void CalibrationDataEigenVariations::mergeVariations ( const IndexSet set)

merge all variations in the given set

Definition at line 877 of file CalibrationDataEigenVariations.cxx.

878 {
879  IndexSuperSet sset;
880  sset.insert(set);
881  mergeVariations(sset);
882 }

◆ mergeVariations() [2/2]

void CalibrationDataEigenVariations::mergeVariations ( const IndexSuperSet set)

merge all variations in any of the given sets

Definition at line 886 of file CalibrationDataEigenVariations.cxx.

887 {
888  // check for overlap
890  for (IndexSuperSet::iterator set_it = set.begin(); set_it != set.end(); ++set_it) {
891  for (IndexSet::iterator subset_it = set_it->begin(); subset_it != set_it->end(); ++subset_it){
892  if (checker.count(*subset_it) == 0 && *subset_it <= m_eigen.size())
893  checker.insert(*subset_it);
894  else {
895  std::cerr << "Error in CalibrationDataEigenVariations::mergeVariations: \
896  IndexSets must not overlap and must lie between 1 and " << m_eigen.size() << ". Aborting!" << std::endl;
897  return;
898  }
899  }
900  }
901 
902  // retrieve the central calibration
903  TH1 *result = static_cast<TH1*>(m_cnt->GetValue("result"));
904  IndexSet toDelete;
905  int nbins = result->GetNbinsX()+2;
906  int ndim = result->GetDimension();
907  if (ndim > 1) nbins *= (result->GetNbinsY()+2);
908  if (ndim > 2) nbins *= (result->GetNbinsZ()+2);
909 
910  // TH1 *var_up_final = static_cast<TH1*>(result->Clone()),
911  // *var_down_final = static_cast<TH1*>(result->Clone());
912 
913  // var_up_final->Reset();
914  // var_down_final->Reset();
915 
916  // complex sum
917  for (IndexSuperSet::iterator set_it = set.begin(); set_it != set.end(); ++set_it) {
918  if (set_it->empty()) continue;
919 
920  double sum_H_up = 0.0, sum_H_down = 0.0;
921  size_t lowest_index = *set_it->lower_bound(0);
922  TH1 *total_var_up = static_cast<TH1*>(m_eigen[lowest_index].first->Clone()),
923  *total_var_down = static_cast<TH1*>(m_eigen[lowest_index].second->Clone());
924  total_var_up->SetDirectory(0);
925  total_var_down->SetDirectory(0);
926 
927  total_var_up->Reset();
928  total_var_down->Reset();
929 
930  // sum all other variations
931  for (IndexSet::iterator subset_it = set_it->begin();
932  subset_it != set_it->end(); ++subset_it) {
933  size_t actual_index = *subset_it;
934 
935  if (actual_index != lowest_index) toDelete.insert(*subset_it);
936 
937  TH1 *partial_var_up = static_cast<TH1*>(m_eigen[actual_index].first->Clone()),
938  *partial_var_down = static_cast<TH1*>(m_eigen[actual_index].second->Clone());
939  partial_var_up->SetDirectory(0);
940  partial_var_down->SetDirectory(0);
941 
942  partial_var_up->Add(result, -1.0); // <----- Is this correct? Should it be +1?
943  partial_var_down->Add(result, -1.0);
944  for (int i = 0; i < nbins; ++i) {
945  partial_var_down->SetBinContent(i, -1.0*partial_var_down->GetBinContent(i));
946  }
947 
948  for (int u = 0; u < nbins; ++u) {
949  double sum_up = total_var_up->GetBinContent(u),
950  sum_down = total_var_down->GetBinContent(u);
951  for (int v = 0; v < nbins; ++v) {
952  sum_up += partial_var_up->GetBinContent(u)*partial_var_up->GetBinContent(v);
953  sum_H_up += partial_var_up->GetBinContent(u)*partial_var_up->GetBinContent(v);
954  sum_down += partial_var_down->GetBinContent(u)*partial_var_down->GetBinContent(v);
955  sum_H_down += partial_var_down->GetBinContent(u)*partial_var_down->GetBinContent(v);
956  }
957  total_var_up->SetBinContent(u, sum_up);
958  total_var_down->SetBinContent(u, sum_down);
959  }
960  delete partial_var_up;
961  delete partial_var_down;
962  }
963 
964  // final part of complex summing
965  for (int i = 0; i < nbins; ++i) {
966  if (sum_H_up != 0.0)
967  total_var_up->SetBinContent(i, total_var_up->GetBinContent(i)/sqrt(sum_H_up));
968  else
969  total_var_up->SetBinContent(i, 0.0);
970  if (sum_H_down != 0.0)
971  total_var_down->SetBinContent(i, -1.0*total_var_down->GetBinContent(i)/sqrt(sum_H_down));
972  else
973  total_var_down->SetBinContent(i, 0.0);
974  }
975 
976  total_var_up->Add(result);
977  total_var_down->Add(result);
978 
979  m_eigen[lowest_index].first = total_var_up;
980  m_eigen[lowest_index].second = total_var_down;
981  }
982 
983  removeVariations(toDelete);
984 }

◆ mergeVariationsFrom()

void CalibrationDataEigenVariations::mergeVariationsFrom ( const size_t &  index)

merge all variations starting from the given index

Definition at line 863 of file CalibrationDataEigenVariations.cxx.

864 {
865  // Merge all systematic variation starting from the given index.
866  // The resulting merged variation replaces the first entry in the list
867  // (i.e., the entry specified by the index).
868  IndexSet simple_set;
869 
870  for (size_t it = index; it < m_eigen.size(); ++it)
871  simple_set.insert(it);
872  mergeVariations(simple_set);
873 }

◆ removeVariations() [1/2]

void CalibrationDataEigenVariations::removeVariations ( const IndexSet set)

remove all variations in the given set

Definition at line 835 of file CalibrationDataEigenVariations.cxx.

836 {
837  if (set.size() == 0) return;
838 
839  std::vector<std::pair<TH1*, TH1*> > new_eigen;
840  for (size_t index = 0; index < m_eigen.size(); ++index){
841  if (set.count(index) == 0) new_eigen.push_back(m_eigen[index]);
842  else { delete m_eigen[index].first; delete m_eigen[index].second; }
843  }
844  m_eigen = new_eigen;
845 }

◆ removeVariations() [2/2]

void CalibrationDataEigenVariations::removeVariations ( const IndexSuperSet set)

remove all variations in any of the given sets

Definition at line 849 of file CalibrationDataEigenVariations.cxx.

850 {
851  IndexSet simple_set;
852 
853  for (IndexSuperSet::iterator set_it = set.begin(); set_it != set.end(); ++set_it) {
854  for (IndexSet::iterator subset_it = set_it->begin(); subset_it != set_it->end(); ++subset_it)
855  simple_set.insert(*subset_it);
856  }
857 
858  removeVariations(simple_set);
859 }

◆ setVerbose()

void CalibrationDataEigenVariations::setVerbose ( bool  verbose)

Definition at line 1247 of file CalibrationDataEigenVariations.cxx.

1247  {
1248  m_verbose = verbose;
1249 }

Member Data Documentation

◆ m_capturedvariance

double Analysis::CalibrationDataEigenVariations::m_capturedvariance
protected

Definition at line 137 of file CalibrationDataEigenVariations.h.

◆ m_cdipath

std::string Analysis::CalibrationDataEigenVariations::m_cdipath
protected

Definition at line 129 of file CalibrationDataEigenVariations.h.

◆ m_cnt

CalibrationDataHistogramContainer* Analysis::CalibrationDataEigenVariations::m_cnt
private

container object containing the basic information

Definition at line 100 of file CalibrationDataEigenVariations.h.

◆ m_eigen

std::vector<std::pair<TH1*, TH1*> > Analysis::CalibrationDataEigenVariations::m_eigen
protected

eigenvector variations

Definition at line 116 of file CalibrationDataEigenVariations.h.

◆ m_initialized

bool Analysis::CalibrationDataEigenVariations::m_initialized
protected

flag whether the initialization has been carried out

Definition at line 105 of file CalibrationDataEigenVariations.h.

◆ m_jetauthor

std::string Analysis::CalibrationDataEigenVariations::m_jetauthor
protected

Definition at line 132 of file CalibrationDataEigenVariations.h.

◆ m_named

std::vector<std::pair<TH1*, TH1*> > Analysis::CalibrationDataEigenVariations::m_named
protected

Definition at line 110 of file CalibrationDataEigenVariations.h.

◆ m_namedExtrapolation

int Analysis::CalibrationDataEigenVariations::m_namedExtrapolation
protected

named variation index for the special case of extrapolation uncertainties

Definition at line 113 of file CalibrationDataEigenVariations.h.

◆ m_namedIndices

std::map<std::string, unsigned int> Analysis::CalibrationDataEigenVariations::m_namedIndices
protected

named variations

Definition at line 109 of file CalibrationDataEigenVariations.h.

◆ m_statVariations

bool Analysis::CalibrationDataEigenVariations::m_statVariations
protected

indicate whether statistical uncertainties are stored as variations

Definition at line 119 of file CalibrationDataEigenVariations.h.

◆ m_taggername

std::string Analysis::CalibrationDataEigenVariations::m_taggername
protected

Definition at line 130 of file CalibrationDataEigenVariations.h.

◆ m_totalvariance

double Analysis::CalibrationDataEigenVariations::m_totalvariance
protected

Definition at line 136 of file CalibrationDataEigenVariations.h.

◆ m_validate

bool Analysis::CalibrationDataEigenVariations::m_validate
protected

Definition at line 106 of file CalibrationDataEigenVariations.h.

◆ m_verbose

bool Analysis::CalibrationDataEigenVariations::m_verbose
protected

Definition at line 139 of file CalibrationDataEigenVariations.h.

◆ m_wp

std::string Analysis::CalibrationDataEigenVariations::m_wp
protected

Definition at line 131 of file CalibrationDataEigenVariations.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
query_example.row
row
Definition: query_example.py:24
beamspotman.r
def r
Definition: beamspotman.py:676
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
IndexSet
Analysis::CalibrationDataEigenVariations::m_named
std::vector< std::pair< TH1 *, TH1 * > > m_named
Definition: CalibrationDataEigenVariations.h:110
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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Analysis::CalibrationDataEigenVariations::m_initialized
bool m_initialized
flag whether the initialization has been carried out
Definition: CalibrationDataEigenVariations.h:105
Analysis::CalibrationDataEigenVariations::getNumberOfEigenVariations
unsigned int getNumberOfEigenVariations()
retrieve the number of eigenvector variations
Definition: CalibrationDataEigenVariations.cxx:1010
Analysis::CalibrationDataHistogramContainer::getTagWeightAxis
virtual int getTagWeightAxis()
Test whether this calibration object is one for "continuous" calibration (this has some subtle conseq...
Definition: CalibrationDataContainer.cxx:935
index
Definition: index.py:1
Analysis::CalibrationDataEigenVariations::m_statVariations
bool m_statVariations
indicate whether statistical uncertainties are stored as variations
Definition: CalibrationDataEigenVariations.h:119
Analysis::CalibrationDataHistogramContainer::isBinCorrelated
bool isBinCorrelated(const std::string &unc) const
Indicate whether the given uncertainty is correlated from bin to bin or not (note that this function ...
Definition: CalibrationDataContainer.cxx:719
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
Analysis::CalibrationDataEigenVariations::m_totalvariance
double m_totalvariance
Definition: CalibrationDataEigenVariations.h:136
skel.it
it
Definition: skel.GENtoEVGEN.py:396
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
Analysis::CalibrationDataEigenVariations::m_taggername
std::string m_taggername
Definition: CalibrationDataEigenVariations.h:130
bin
Definition: BinsDiffFromStripMedian.h:43
Analysis::CalibrationDataEigenVariations::initialize
virtual void initialize(double min_variance=1.0E-20)
carry out the eigenvector computations.
Definition: CalibrationDataEigenVariations.cxx:637
Analysis::CalibrationDataEigenVariations::getJacobianReductionMatrix
TMatrixD getJacobianReductionMatrix()
matrix to remove unecessary rows and columns from covariance
Definition: CalibrationDataEigenVariations.cxx:500
Analysis::CalibrationDataEigenVariations::getEigenCovarianceMatrix
virtual TMatrixDSym getEigenCovarianceMatrix()
also provide (some) access to the underlying information: covariance matrix corresponding to eigenvec...
Definition: CalibrationDataEigenVariations.cxx:416
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
Analysis::CalibrationDataEigenVariations::IndexSuperSet
std::set< IndexSet > IndexSuperSet
Definition: CalibrationDataEigenVariations.h:30
Analysis::CalibrationDataEigenVariations::m_eigen
std::vector< std::pair< TH1 *, TH1 * > > m_eigen
eigenvector variations
Definition: CalibrationDataEigenVariations.h:116
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Analysis::CalibrationDataEigenVariations::m_wp
std::string m_wp
Definition: CalibrationDataEigenVariations.h:131
Analysis::CalibrationDataContainer::listUncertainties
std::vector< std::string > listUncertainties() const
retrieve the list of "uncertainties" accessible to this object.
Definition: CalibrationDataContainer.cxx:120
Analysis::CalibrationDataEigenVariations::m_capturedvariance
double m_capturedvariance
Definition: CalibrationDataEigenVariations.h:137
lumiFormat.i
int i
Definition: lumiFormat.py:85
vector< string >
python.subdetectors.mmg.names
names
Definition: mmg.py:8
Analysis::CalibrationDataEigenVariations::m_namedIndices
std::map< std::string, unsigned int > m_namedIndices
named variations
Definition: CalibrationDataEigenVariations.h:109
Analysis::CalibrationDataEigenVariations::getEigenvectorVariation
bool getEigenvectorVariation(unsigned int variation, TH1 *&up, TH1 *&down)
obtain the "up" and "down" variations for the given eigenvector number.
Definition: CalibrationDataEigenVariations.cxx:1018
CalibCoolCompareRT.up
up
Definition: CalibCoolCompareRT.py:109
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
AnalysisUtils::copy_if
Out copy_if(In first, const In &last, Out res, const Pred &p)
Definition: IFilterUtils.h:30
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
RPDUtils::nCols
unsigned constexpr int nCols
Definition: RPDUtils.h:25
PlotSFuncertainty.nom
nom
Definition: PlotSFuncertainty.py:141
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Analysis::CalibrationDataEigenVariations::removeVariations
void removeVariations(const IndexSet &set)
remove all variations in the given set
Definition: CalibrationDataEigenVariations.cxx:835
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
query_example.col
col
Definition: query_example.py:7
Analysis::CalibrationDataEigenVariations::m_jetauthor
std::string m_jetauthor
Definition: CalibrationDataEigenVariations.h:132
Analysis::CalibrationDataEigenVariations::m_verbose
bool m_verbose
Definition: CalibrationDataEigenVariations.h:139
python.PyAthena.v
v
Definition: PyAthena.py:154
DeMoScan.index
string index
Definition: DeMoScan.py:364
Analysis::CalibrationDataEigenVariations::m_validate
bool m_validate
Definition: CalibrationDataEigenVariations.h:106
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
Analysis::CalibrationDataEigenVariations::m_namedExtrapolation
int m_namedExtrapolation
named variation index for the special case of extrapolation uncertainties
Definition: CalibrationDataEigenVariations.h:113
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
Analysis::CalibrationDataEigenVariations::getNamedVariation
bool getNamedVariation(const std::string &name, TH1 *&up, TH1 *&down)
obtain the "up" and "down" variations for the named uncertainty.
Definition: CalibrationDataEigenVariations.cxx:1043
Analysis::CalibrationDataEigenVariations::m_cnt
CalibrationDataHistogramContainer * m_cnt
container object containing the basic information
Definition: CalibrationDataEigenVariations.h:100
RPDUtils::nRows
unsigned constexpr int nRows
Definition: RPDUtils.h:24
Analysis::CalibrationDataEigenVariations::mergeVariations
void mergeVariations(const IndexSet &set)
merge all variations in the given set
Definition: CalibrationDataEigenVariations.cxx:877
dumpTriggerInfo.checker
checker
Definition: dumpTriggerInfo.py:20