ATLAS Offline Software
Loading...
Searching...
No Matches
CalibrationDataHistogramContainer Class Reference

This is the class holding information for histogram-based calibration results. More...

#include <CalibrationDataContainer.h>

Inheritance diagram for CalibrationDataHistogramContainer:
Collaboration diagram for CalibrationDataHistogramContainer:

Public Member Functions

 CalibrationDataHistogramContainer (const char *name="default")
virtual ~CalibrationDataHistogramContainer ()
virtual CalibrationStatus getResult (const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)
 retrieve the calibration result.
virtual CalibrationStatus getStatUncertainty (const CalibrationDataVariables &x, double &result)
 retrieve the calibration statistical uncertainty.
virtual CalibrationStatus getUncertainty (const std::string &unc, const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)
 retrieve the calibration uncertainty due to the given source.
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)
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)
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)
virtual bool isInterpolated () const
 Indicate whether histogram interpolation is used or not.
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).
virtual std::vector< double > getBinBoundaries (unsigned int vartype)
 Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametrization enum).
virtual int getEigenvectorReduction (unsigned int choice) const
 Retrieve the number of eigenvectors to be retained for the purpose of eigenvector variation reduction strategies.

Protected Attributes

std::map< unsigned int, std::vector< double > > m_binBoundaries
 Cache for bin boundary information.

Private Member Functions

double getInterpolatedResult (TH1 *hist) const
 Retrieve interpolated result (utility function)
double getInterpolatedUncertainty (TH1 *hist) const
 Retrieve interpolated result (utility function)
void checkBounds ()
 check the bounds of validity for this calibration object
virtual void computeVariableTypes ()
 utility for determining global bin number, subject to extrapolation constraints.
 ClassDef (CalibrationDataHistogramContainer, 2)

Private Attributes

THashList m_uncorrelatedSyst
 no need to persistify
bool m_interpolate
 If true, interpolate between bins rather than doing a straight bin-wise evaluation.

Detailed Description

This is the class holding information for histogram-based calibration results.

Definition at line 247 of file CalibrationDataContainer.h.

Constructor & Destructor Documentation

◆ CalibrationDataHistogramContainer()

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

◆ ~CalibrationDataHistogramContainer()

CalibrationDataHistogramContainer::~CalibrationDataHistogramContainer ( )
virtual

Definition at line 483 of file CalibrationDataContainer.cxx.

484{
485}

Member Function Documentation

◆ checkBounds()

void CalibrationDataHistogramContainer::checkBounds ( )
private

check the bounds of validity for this calibration object

Definition at line 673 of file CalibrationDataContainer.cxx.

674{
675 // Determine the bounds of validity for this calibration object. If an "extrapolation"
676 // uncertainty histogram exists, it is used to determine the (typically) looser bounds
677 // of validity appropriate for extrapolation uncertainties.
678
679 const TH1* hist = dynamic_cast<const TH1*>(m_objResult);
680 if (!hist) {
681 std::cerr << "in CalibrationDataHistogramContainer::checkBounds(): object type does not derive from TH1" << std::endl;
682 return;
683 } else if (hist->GetDimension() != int(m_variables.size())) {
684 std::cerr << "in CalibrationDataHistogramContainer::checkBounds(): given number of variable types ("
685 << m_variables.size() << ") doesn't match histogram dimension ("
686 << hist->GetDimension() << ")!" << std::endl;
687 return;
688 }
689 // if an extrapolation uncertainty histogram was provided, use this to determine a second set of validity bounds
690 const TH1* hExtrapolate = dynamic_cast<const TH1*>(GetValue("extrapolation"));
691 for (unsigned int t = 0; int(t) < hist->GetDimension(); ++t) {
692 const TAxis* axis; const TAxis* axis2 = 0;
693 switch (t) {
694 case 0: axis = hist->GetXaxis(); if (hExtrapolate) axis2 = hExtrapolate->GetXaxis(); break;
695 case 1: axis = hist->GetYaxis(); if (hExtrapolate) axis2 = hExtrapolate->GetYaxis(); break;
696 default: axis = hist->GetZaxis(); if (hExtrapolate) axis2 = hExtrapolate->GetZaxis();
697 }
698
699 // for (unsigned int t = 0; t < m_variables.size(); ++t) {
700 // if (m_variables[t] > m_upperBounds.size()) {
701 // std::cerr << "in CalibrationDataHistogramContainer::checkBounds(): variable " << t << "type ("
702 // << m_variables[t] << "exceeds maximum type number (" << m_upperBounds.size() << ")!"
703 // << std::endl;
704 // return;
705 // }
706 // }
707 m_upperBounds[m_variables[t]] = axis->GetXmax();
708 m_lowerBounds[m_variables[t]] = axis->GetXmin();
709 m_upperBoundsExtrapolated[m_variables[t]] = (axis2) ? axis2->GetXmax() : m_upperBounds[m_variables[t]];
710 m_lowerBoundsExtrapolated[m_variables[t]] = (axis2) ? axis2->GetXmin() : m_lowerBounds[m_variables[t]];
711 // std::cout << "debug: min = " << m_lowerBounds[m_variables[t]] << ", max = " << m_upperBounds[m_variables[t]]
712 // << ", extrap min = " << m_lowerBoundsExtrapolated[m_variables[t]] << ", extrap max = "
713 // << m_upperBoundsExtrapolated[m_variables[t]] << std::endl;
714 }
715}
std::vector< double > m_upperBoundsExtrapolated
(possibly looser) lower validity bounds for extrapolation
TObject * m_objResult
(possibly looser) upper validity bounds for extrapolation
std::vector< unsigned int > m_variables
don't persistify

◆ ClassDef()

Analysis::CalibrationDataHistogramContainer::ClassDef ( CalibrationDataHistogramContainer ,
2  )
private

◆ computeVariableTypes()

void CalibrationDataHistogramContainer::computeVariableTypes ( )
privatevirtual

utility for determining global bin number, subject to extrapolation constraints.

Parameters
histpointer to histogram containing actual bin boundary information
doExtrapolatespecifies whether or not an extrapolation uncertainty is being requested decode the 'uncertainty' objects' names to determine the relevant variable types

Implements Analysis::CalibrationDataContainer.

Definition at line 490 of file CalibrationDataContainer.cxx.

491{
492 // Compute the variable types for this container object, using the histogram axis labels.
493 // Valid axis labels can be found in the CalibrationDataContainer::typeFromString() method.
494 // Note that only the "result" histogram is inspected; it is assumed that all
495 // histograms provided use the same binning (a small exception is the "extrapolation"
496 // uncertainty histogram, which may have additional bins beyond the usual validity bounds).
497 //
498 // This function will be called upon first usage, and its results cached internally.
499 // It also calls checkBounds() to determine the validity bounds.
500
501 // cache pointer to central values histogram
502 if (! m_objResult) m_objResult = GetValue("result");
503
504 // histograms need a special treatment, as the coordinate titles are not actually stored
505 // with the title itself, but instead moved off to the axis titles...
506 const TH1* hobj = dynamic_cast<const TH1*>(m_objResult);
507 if (not hobj){
508 std::cerr << "in CalibrationDataHistogramContainer::computeVariableTypes(): dynamic_cast failed\n";
509 return;
510 }
511
512 int dims = hobj->GetDimension();
513 for (int dim = 0; dim < dims; ++dim) {
514 const TAxis* axis = 0;
515 switch (dim) {
516 case 0: axis = hobj->GetXaxis(); break;
517 case 1: axis = hobj->GetYaxis(); break;
518 default: axis = hobj->GetZaxis();
519 }
520 int vartype = typeFromString(axis->GetTitle());
521 if (vartype < 0) {
522 // Only flag the issue but otherwise take no action (assume non-argument use of a semicolon)
523 std::cerr << "in CalibrationDataHistogramContainer::computeVariableTypes(): cannot construct variable type from name "
524 << axis->GetTitle() << std::endl;
525 } else {
526 m_variables.push_back((unsigned int) vartype);
527 }
528 }
529
530 // After doing this, we should always have a non-null vector!
531 assert(m_variables.size() > 0);
532
533 // also compute the validity bounds for this calibration object
535}
int typeFromString(const std::string &key) const
Connection between variable names (on histogram axes etc.) and variable 'types' as used in actual eva...
void checkBounds()
check the bounds of validity for this calibration object
CalibrationDataHistogramContainer(const char *name="default")

◆ getBinBoundaries()

std::vector< double > CalibrationDataHistogramContainer::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.

Definition at line 952 of file CalibrationDataContainer.cxx.

953{
954 // Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametrization enum).
955 // An empty vector will be returned if the specified variable is not actually used.
956
957 // Ensure that the variable types have been computed at this point
958 if (m_variables.size() == 0) computeVariableTypes();
959
960 // Check whether the variable type is actually being used
961 std::vector<double> boundaries;
962 if (std::find(m_variables.begin(), m_variables.end(), vartype) == m_variables.end()) return boundaries;
963
964 // use cached information if available
965 std::map<unsigned int, std::vector<double> >::iterator it = m_binBoundaries.find(vartype);
966 if (it != m_binBoundaries.end()) return it->second;
967
968 // Retrieve the appropriate histogram axis
969 if (! m_objResult) m_objResult = GetValue("result");
970 const TH1* hobj = dynamic_cast<const TH1*>(m_objResult);
971 const TAxis* axis = 0;
972 if (m_variables[0] == vartype) axis = hobj->GetXaxis();
973 else if (m_variables[1] == vartype) axis = hobj->GetYaxis();
974 else axis = hobj->GetZaxis();
975
976 // Retrieve the actual bin boundaries
977 const TArrayD* bins = axis->GetXbins(); int nb = bins->GetSize();
978 for (int b = 0; b < nb; ++b) boundaries.push_back(bins->At(b));
979
980 m_binBoundaries[vartype] = boundaries;
981 return boundaries;
982}
static const std::vector< std::string > bins
virtual void computeVariableTypes()
utility for determining global bin number, subject to extrapolation constraints.
std::map< unsigned int, std::vector< double > > m_binBoundaries
Cache for bin boundary information.

◆ getEigenvectorReduction()

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

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}

◆ getInterpolatedResult()

double CalibrationDataHistogramContainer::getInterpolatedResult ( TH1 * hist) const
private

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}
double m_vars[MaxCalibrationVars]
don't persistify

◆ getInterpolatedUncertainty()

double CalibrationDataHistogramContainer::getInterpolatedUncertainty ( TH1 * hist) const
private

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}
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16

◆ getResult()

CalibrationStatus CalibrationDataHistogramContainer::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)

Implements Analysis::CalibrationDataContainer.

Definition at line 539 of file CalibrationDataContainer.cxx.

541{
542 // Retrieve the central value for the given input variables. There are cases where
543 // it may be useful to provide an alternative histogram rather than the original
544 // one; in such cases (notably used with eigenvector variations) it is possible to
545 // provide a pointer to this alternative histogram.
546 //
547 // x: input variables
548 // result: result
549 // obj: pointer to alternative results histogram
550 // extrapolate: set to true if bounds checking is to be carried out to looser
551 // validity bounds as relevant for extrapolation uncertainties
552 if (!obj) {
553 if (! m_objResult) {
554 m_objResult = GetValue("result");
555 }
557 }
558 TH1* hist = dynamic_cast<TH1*>(obj);
559 if (! hist) return Analysis::kError;
560
561 // select the relevant kinematic variables
563 // find the relevant "global" bin.
564 // Note the limitation: at most three dimensions are supported.
565 // TH1::FindFixBin() will ignore the variables not needed.
566 // Note: FindFixBin() is only available in "recent" ROOT versions (FindBin() is appropriate for older versions)
567 // (otherwise we need to rely on the ResetBit(TH1::kCanRebin) method having been used)
568 if (m_interpolate) {
570 } else {
571 Int_t bin = hist->FindFixBin(m_vars[0], m_vars[1], m_vars[2]);
572 result = hist->GetBinContent(bin);
573 }
574
575 return status;
576}
#define x
CalibrationStatus computeVariables(const CalibrationDataVariables &x, bool extrapolate=false)
compute the variables to be used for the given 'uncertainty'
double getInterpolatedResult(TH1 *hist) const
Retrieve interpolated result (utility function)
bool m_interpolate
If true, interpolate between bins rather than doing a straight bin-wise evaluation.
status
Definition merge.py:16

◆ getStatUncertainty()

CalibrationStatus CalibrationDataHistogramContainer::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

Implements Analysis::CalibrationDataContainer.

Definition at line 582 of file CalibrationDataContainer.cxx.

584{
585 // Retrieve the statistical uncertainty for the given input variables.
586 //
587 // x: input variables
588 // result: result
589
590 if (! m_objResult) {
591 m_objResult = GetValue("result");
592 }
593 TH1* hist = dynamic_cast<TH1*>(m_objResult);
594 if (! hist) {
595 std::cout << " getStatUncertainty error: no (valid) central values object!" << std::endl;
596 return Analysis::kError;
597 }
598
599 // select the relevant kinematic variables
601 // find the relevant "global" bin.
602 // Note the limitation: at most three dimensions are supported.
603 // TH1::FindFixBin() will ignore the variables not needed.
604 // Note: FindFixBin() is only available in "recent" ROOT versions (FindBin() is appropriate for older versions)
605 // (otherwise we need to rely on the ResetBit(TH1::kCanRebin) method having been used)
606 if (m_interpolate) {
607 // interpolating the uncertainties doesn't seem very sensible..
609 } else {
610 Int_t bin = hist->FindFixBin(m_vars[0], m_vars[1], m_vars[2]);
611 // Int_t bin = findBin(hist, false);
612 result = hist->GetBinError(bin);
613 }
614
615 return status;
616}
double getInterpolatedUncertainty(TH1 *hist) const
Retrieve interpolated result (utility function)

◆ getTagWeightAxis()

int CalibrationDataHistogramContainer::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.

Definition at line 935 of file CalibrationDataContainer.cxx.

936{
937 // Test whether this calibration object is one for "continuous" calibration
938 // (this has some subtle consequences for the treatment of bin-to-bin correlations).
939 // The return value will be -1 in case this is not a "continuous" calibration object,
940 // and the axis number (0 for X, 1 for Y, 2 for Z) otherwise.
941
942 // Ensure that the variable types have been computed at this point
943 if (m_variables.size() == 0) computeVariableTypes();
944
945 for (unsigned int type = 0; type < m_variables.size(); ++type)
946 if (m_variables[type] == kTagWeight) return int(type);
947 return -1;
948}

◆ getUncertainty()

CalibrationStatus CalibrationDataHistogramContainer::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)

Implements Analysis::CalibrationDataContainer.

Definition at line 622 of file CalibrationDataContainer.cxx.

625{
626 // Retrieve the uncertainty for the given input variables.
627 //
628 // unc: keyword indicating requested source of uncertainty. This should
629 // correspond to one of the histograms added explicitly as a systematic
630 // uncertainty or the keyword "statistics" (statistical uncertainties are
631 // accessed differently, see method getStatUncertainty()).
632 // x: input variables
633 // result: result
634 // obj: pointer to alternative or cached histogram
635
636 if (unc == "statistics") {
637 // treat statistical uncertainties separately (they are stored with the actual result)
638 double res;
640 if (code == Analysis::kError) return code;
641 result.first = res;
642 result.second = -res;
643 return code;
644 }
645
646 if (!obj) obj = GetValue(unc.c_str());
647 TH1* hist = dynamic_cast<TH1*>(obj);
648 if (! hist) return Analysis::kError;
649
650 // select the relevant kinematic variables
651 CalibrationStatus status = computeVariables(x, (unc == "extrapolation") );
652
653 if (m_interpolate) {
654 result.first = getInterpolatedResult(hist);
655 // symmetrise the uncertainty (as there is no code to interpolate the bin errors)
656 result.second = -result.first;
657 } else {
658 // TH1::FindFixBin() will ignore the variables not needed.
659 // Note: FindFixBin() is only available in "recent" ROOT versions (FindBin() is appropriate for older versions)
660 // (otherwise we need to rely on the ResetBit(TH1::kCanRebin) method having been used)
661 Int_t bin = hist->FindFixBin(m_vars[0], m_vars[1], m_vars[2]);
662 // the "first" and "second" entries are filled with the
663 // "positive" and "negative" uncertainties, respectively.
664 result.first = hist->GetBinContent(bin);
665 result.second = hist->GetBinError(bin);
666 }
667
668 return status;
669}
std::pair< std::vector< unsigned int >, bool > res
virtual CalibrationStatus getStatUncertainty(const CalibrationDataVariables &x, double &result)
retrieve the calibration statistical uncertainty.

◆ isBinCorrelated()

bool CalibrationDataHistogramContainer::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)

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}
THashList m_uncorrelatedSyst
no need to persistify

◆ isInterpolated()

bool CalibrationDataHistogramContainer::isInterpolated ( ) const
virtual

Indicate whether histogram interpolation is used or not.

Definition at line 751 of file CalibrationDataContainer.cxx.

752{
753 // Indicate whether histogram interpolation is used or not.
754
755 return m_interpolate;
756}

◆ setInterpolated()

void CalibrationDataHistogramContainer::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)

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}

◆ setUncorrelated()

void CalibrationDataHistogramContainer::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)

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}

Member Data Documentation

◆ m_binBoundaries

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

Cache for bin boundary information.

Definition at line 291 of file CalibrationDataContainer.h.

◆ m_interpolate

bool Analysis::CalibrationDataHistogramContainer::m_interpolate
private

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

Definition at line 299 of file CalibrationDataContainer.h.

◆ m_uncorrelatedSyst

THashList Analysis::CalibrationDataHistogramContainer::m_uncorrelatedSyst
private

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.


The documentation for this class was generated from the following files: