|
NAGASH 0.9.8
Next Generation Analysis System
|
provide tools for manipulating ROOT histograms More...
#include "NAGASH/HistTool.h"
Public Member Functions | |
| HistTool (std::shared_ptr< MSGTool > MSG) | |
| void | Asymmetry (TH1 *A, TH1 *B, TH1 *Asy) |
| Calculate the asymmetry between two histograms. | |
| void | Chi2 (TH1 *A, TH1 *B, TH1 *C) |
| Calculate the \(\chi^2\) between two histograms. | |
| double | Chi2 (TH1D *A, TH1D *B, TH2D *CorrA=nullptr, TH2D *CorrB=nullptr) |
| Calculate the \(\chi^2\) between two histograms. | |
| void | ConvertCorrToCov (TH2D *corr, TH1D *h, TH2D *cov) |
| Convert correlation matrix to covariance matrix. | |
| void | ConvertCovToCorr (TH2D *covar, TH2D *corr) |
| Convert covariance matrix to correlation matrix. | |
| void | ConvertCovToError (TH2D *hcov, TH1D *herr) |
| Convert covariance matrix to error histogram. | |
| void | ConvertMatrixToTH2D (const TMatrixD &mat, TH2D *h2d) |
| Convert a matrix to a 2D histogram. | |
| std::vector< double > | ConvertTH1DErrorToVector (TH1D *h1d) |
| Convert the errors of a 1D histogram to a vector. | |
| std::vector< double > | ConvertTH1DToVector (TH1D *h1d) |
| Convert the contents of a 1D histogram to a vector. | |
| std::vector< std::vector< double > > | ConvertTH2DErrorToVector (TH2D *h2d, const TString &priority="XY") |
| Convert the errors of a 2D histogram to a vector. | |
| TMatrixD | ConvertTH2DToMatrix (TH2D *h2d) |
| Convert a 2D histogram to a matrix. | |
| std::vector< std::vector< double > > | ConvertTH2DToVector (TH2D *h2d, const TString &priority="XY") |
| Convert the contents of a 2D histogram to a vector. | |
| void | ConvertTH2DToVectorTH1D (TH2D *h2d, const std::vector< TH1D * > &vh1d, const TString &priority="XY") |
| Convert a 2D histogram into a vector of 1D histograms. | |
| std::vector< std::vector< std::vector< double > > > | ConvertTH3DErrorToVector (TH3D *h3d, const TString &priority="XYZ") |
| Convert the errors of a 3D histogram to a vector. | |
| std::vector< std::vector< std::vector< double > > > | ConvertTH3DToVector (TH3D *h3d, const TString &priority="XYZ") |
| Convert the contents of a 3D histogram to a vector. | |
| void | ConvertTH3DToVectorTH1D (TH3D *h3d, const std::vector< std::vector< TH1D * > > &vh1d, const TString &priority="XYZ") |
| Convert a 3D histogram into a 2D vector of 1D histograms. | |
| void | ConvertVectorTH1DToTH1D (const std::vector< TH1D * > &vh1d, TH1D *targeth1d) |
| Fuse a vector of 1D histograms into one 1D histogram. | |
| void | ConvertVectorToTH1D (TH1D *h1, const std::vector< double > &v1, const std::vector< double > &v1err=std::vector< double >()) |
| Convert vectors to a histogram. | |
| void | ConvertVectorToTH2D (TH2D *h2, const std::vector< std::vector< double > > &v2, const std::vector< std::vector< double > > &v2err=std::vector< std::vector< double > >()) |
| Convert vectors to a 2D histogram. | |
| void | ConvertVectorToTH3D (TH3D *h3, const std::vector< std::vector< std::vector< double > > > &v3, const std::vector< std::vector< std::vector< double > > > &v3err=std::vector< std::vector< std::vector< double > > >()) |
| Convert vectors to a 3D histogram. | |
| void | Delta (TH1 *A, TH1 *B, TH1 *D, bool dosep=false) |
| Calculate the difference between two histograms. | |
| void | ProcessHistLink (const TString &type, const std::vector< TH1 * > &input, TH1 *res) |
| constructor | |
| void | ProcessHistLink (std::function< double(const std::vector< double > &)>, std::function< double(const std::vector< double > &, const std::vector< double > &)>, const std::vector< TH1 * > &input, TH1 *res) |
| Create a new histogram based on the input histograms. | |
| void | ProcessHistLink (std::function< void(const std::vector< TH1 * > &, TH1 *)>, const std::vector< TH1 * > &input, TH1 *res) |
| Create a new histogram based on the input histograms. | |
| void | Pull (TH1 *A, TH1 *B, TH1 *P) |
| Calculate the pull between two histograms. | |
| void | Ratio (TH1 *A, TH1 *B, TH1 *R, bool dosep=false) |
| Calculate the ratio between two histograms. | |
Static Public Member Functions | |
| template<typename T > | |
| static std::vector< T > | ConvertVector2DToVector1D (const std::vector< std::vector< T > > &v2d) |
| Flatten 2D vector to a 1D vector. | |
| template<typename T > | |
| static std::vector< T > | ConvertVector2DToVector1D (std::vector< std::vector< T > > &&v2d) |
| Flatten 2D vector to a 1D vector. | |
Protected Attributes | |
| Uncertainty | unc |
Additional Inherited Members | |
Protected Member Functions inherited from NAGASH::Tool | |
| Tool ()=delete | |
| Tool (const Tool &tool)=delete | |
| Tool (std::shared_ptr< MSGTool > MSG) | |
| Constructor. | |
| Tool (Tool &&tool)=delete | |
| virtual | ~Tool ()=default |
| std::shared_ptr< MSGTool > | MSGUser () |
| return the MSGTool inside. | |
| Tool & | operator= (const Tool &tool)=delete |
| Tool & | operator= (Tool &&tool)=delete |
provide tools for manipulating ROOT histograms
Definition at line 16 of file HistTool.h.
|
inline |
Definition at line 19 of file HistTool.h.
| void HistTool::Asymmetry | ( | TH1 * | A, |
| TH1 * | B, | ||
| TH1 * | Asy | ||
| ) |
Calculate the asymmetry between two histograms.
| [in] | A | histogram A. |
| [in] | B | histogram B. |
| [out] | Asy | the asymmetry histogram \((A+B)/(A-B)\). |
Definition at line 143 of file HistTool.cxx.
| void HistTool::Chi2 | ( | TH1 * | A, |
| TH1 * | B, | ||
| TH1 * | C | ||
| ) |
Calculate the \(\chi^2\) between two histograms.
| [in] | A | histogram A. |
| [in] | B | histogram B. |
| [out] | C | \((A-B)^2/(\sigma^2(A)+\sigma^2(B))\). |
Definition at line 331 of file HistTool.cxx.
| double HistTool::Chi2 | ( | TH1D * | A, |
| TH1D * | B, | ||
| TH2D * | CorrA = nullptr, |
||
| TH2D * | CorrB = nullptr |
||
| ) |
Calculate the \(\chi^2\) between two histograms.
| A | histogram A. |
| B | histogram B. |
| CorrA | covariance matrix of A. |
| CorrB | covariance matrix of B. |
Definition at line 442 of file HistTool.cxx.
| void HistTool::ConvertCorrToCov | ( | TH2D * | corr, |
| TH1D * | h, | ||
| TH2D * | cov | ||
| ) |
Convert correlation matrix to covariance matrix.
| [in] | corr | Input correlation matrix. |
| [in] | h | the histogram whose error would be used to calculate the covariance matrix. |
| [out] | cov | the output covariance matrix. |
Definition at line 603 of file HistTool.cxx.
| void HistTool::ConvertCovToCorr | ( | TH2D * | covar, |
| TH2D * | corr | ||
| ) |
Convert covariance matrix to correlation matrix.
| [in] | covar | input covariance matrix. |
| [out] | corr | output correlation matrix. |
Definition at line 524 of file HistTool.cxx.
| void HistTool::ConvertCovToError | ( | TH2D * | hcov, |
| TH1D * | herr | ||
| ) |
Convert covariance matrix to error histogram.
| [in] | hcov | the input covariance matrix. |
| [out] | herr | the output error. |
Definition at line 566 of file HistTool.cxx.
| void HistTool::ConvertMatrixToTH2D | ( | const TMatrixD & | mat, |
| TH2D * | h2d | ||
| ) |
Convert a matrix to a 2D histogram.
| mat | the input matrix. |
| h2d | the output 2D histogram. |
Definition at line 1321 of file HistTool.cxx.
| std::vector< double > HistTool::ConvertTH1DErrorToVector | ( | TH1D * | h1d | ) |
Convert the errors of a 1D histogram to a vector.
| h1d | the input histogram. |
Definition at line 830 of file HistTool.cxx.
| std::vector< double > HistTool::ConvertTH1DToVector | ( | TH1D * | h1d | ) |
Convert the contents of a 1D histogram to a vector.
| h1d | the input histogram. |
Definition at line 809 of file HistTool.cxx.
| std::vector< std::vector< double > > HistTool::ConvertTH2DErrorToVector | ( | TH2D * | h2d, |
| const TString & | priority = "XY" |
||
| ) |
Convert the errors of a 2D histogram to a vector.
| h2d | the input histogram. |
| priority | the priority of the axis to be converted, can be either "XY" or "YX". |
Definition at line 900 of file HistTool.cxx.
| TMatrixD HistTool::ConvertTH2DToMatrix | ( | TH2D * | h2d | ) |
Convert a 2D histogram to a matrix.
| h2d | the input 2D histogram. |
Definition at line 1301 of file HistTool.cxx.
| std::vector< std::vector< double > > HistTool::ConvertTH2DToVector | ( | TH2D * | h2d, |
| const TString & | priority = "XY" |
||
| ) |
Convert the contents of a 2D histogram to a vector.
| h2d | the input histogram. |
| priority | the priority of the axis to be converted, can be either "XY" or "YX". |
Definition at line 852 of file HistTool.cxx.
| void HistTool::ConvertTH2DToVectorTH1D | ( | TH2D * | h2d, |
| const std::vector< TH1D * > & | vh1d, | ||
| const TString & | priority = "XY" |
||
| ) |
Convert a 2D histogram into a vector of 1D histograms.
| [in] | h2d | the input 2D histogram. |
| [out] | vh1d | the output vector of 1D histograms. |
| [in] | priority | the priority of the axis to be converted, can be either "XY" or "YX". |
Definition at line 1227 of file HistTool.cxx.
| std::vector< std::vector< std::vector< double > > > HistTool::ConvertTH3DErrorToVector | ( | TH3D * | h3d, |
| const TString & | priority = "XYZ" |
||
| ) |
Convert the errors of a 3D histogram to a vector.
| h3d | the input histogram. |
| priority | the priority of the axis to be converted, can be either "XYZ", XZY", "ZXY", "ZYX", "YZX" or "YXZ". |
Definition at line 1074 of file HistTool.cxx.
| std::vector< std::vector< std::vector< double > > > HistTool::ConvertTH3DToVector | ( | TH3D * | h3d, |
| const TString & | priority = "XYZ" |
||
| ) |
Convert the contents of a 3D histogram to a vector.
| h3d | the input histogram. |
| priority | the priority of the axis to be converted, can be either "XYZ", XZY", "ZXY", "ZYX", "YZX" or "YXZ". |
Definition at line 948 of file HistTool.cxx.
| void HistTool::ConvertTH3DToVectorTH1D | ( | TH3D * | h3d, |
| const std::vector< std::vector< TH1D * > > & | vh1d, | ||
| const TString & | priority = "XYZ" |
||
| ) |
Convert a 3D histogram into a 2D vector of 1D histograms.
| [in] | h3d | the input 3D histogram. |
| [out] | vh1d | the output 2D vector of 1D histograms. |
| [in] | priority | the priority of the axis to be converted, can be either "XYZ", "XZY", "ZXY", "ZYX", "YZX", or "YXZ". |
Definition at line 1260 of file HistTool.cxx.
|
inlinestatic |
Flatten 2D vector to a 1D vector.
| T | type of the vector. |
| v2d | input 2D vector with const reference. |
Definition at line 70 of file HistTool.h.
|
inlinestatic |
Flatten 2D vector to a 1D vector.
| T | type of the vector. |
| v2d | input 2D vector with right value reference. |
Definition at line 85 of file HistTool.h.
| void HistTool::ConvertVectorTH1DToTH1D | ( | const std::vector< TH1D * > & | vh1d, |
| TH1D * | targeth1d | ||
| ) |
Fuse a vector of 1D histograms into one 1D histogram.
| [in] | vh1d | the input vector of 1D histograms. |
| [out] | targeth1d | the output 1D histogram. |
Definition at line 1199 of file HistTool.cxx.
| void HistTool::ConvertVectorToTH1D | ( | TH1D * | h1, |
| const std::vector< double > & | v1, | ||
| const std::vector< double > & | v1err = std::vector<double>() |
||
| ) |
Convert vectors to a histogram.
| [out] | h1 | output histogram. |
| [in] | v1 | vector of the contents of the histogram. |
| [in] | v1err | vector of the errors of the histogram. |
Definition at line 648 of file HistTool.cxx.
| void HistTool::ConvertVectorToTH2D | ( | TH2D * | h2, |
| const std::vector< std::vector< double > > & | v2, | ||
| const std::vector< std::vector< double > > & | v2err = std::vector<std::vector<double>>() |
||
| ) |
Convert vectors to a 2D histogram.
| [out] | h2 | output histogram. |
| [in] | v2 | the contents of the histogram. |
| [in] | v2err | the errors of the histogram. |
Definition at line 685 of file HistTool.cxx.
| void HistTool::ConvertVectorToTH3D | ( | TH3D * | h3, |
| const std::vector< std::vector< std::vector< double > > > & | v3, | ||
| const std::vector< std::vector< std::vector< double > > > & | v3err = std::vector<std::vector<std::vector<double>>>() |
||
| ) |
Convert vectors to a 3D histogram.
| [out] | h3 | output histogram. |
| [in] | v3 | the contents of the histogram. |
| [in] | v3err | the errors of the histogram. |
Definition at line 738 of file HistTool.cxx.
| void HistTool::Delta | ( | TH1 * | A, |
| TH1 * | B, | ||
| TH1 * | D, | ||
| bool | dosep = false |
||
| ) |
Calculate the difference between two histograms.
| [in] | A | histogram A. |
| [in] | B | histogram B. |
| [out] | D | the difference histogram \((A-B)\). |
| [in] | dosep | seperate the error or not, if do seperate, ignore A's error. |
Definition at line 197 of file HistTool.cxx.
| void HistTool::ProcessHistLink | ( | const TString & | type, |
| const std::vector< TH1 * > & | input, | ||
| TH1 * | res | ||
| ) |
constructor
Create a new histogram based on the input histograms.
| [in] | type | the kind of the histogram you want to create. Possible values are: Asymmetry, Delta, Ratio, Chi2 and Pull. |
| [in] | input | the input set of histograms. |
| [out] | res | output histogram. |
Definition at line 15 of file HistTool.cxx.
| void HistTool::ProcessHistLink | ( | std::function< double(const std::vector< double > &)> | contentfunction, |
| std::function< double(const std::vector< double > &, const std::vector< double > &)> | errorfunction, | ||
| const std::vector< TH1 * > & | input, | ||
| TH1 * | res | ||
| ) |
Create a new histogram based on the input histograms.
| [in] | contentfunction | the function to calculate the new histogram content. |
| [in] | errorfunction | the function to calculate the new histogram error. |
| [in] | input | the input set of histograms. |
| [out] | res | the output histogram. |
Definition at line 72 of file HistTool.cxx.
| void HistTool::ProcessHistLink | ( | std::function< void(const std::vector< TH1 * > &, TH1 *)> | func, |
| const std::vector< TH1 * > & | input, | ||
| TH1 * | res | ||
| ) |
Create a new histogram based on the input histograms.
| [in] | func | the function to calculate the new histogram. |
| [in] | input | the input set of histograms. |
| [out] | res | the output histogram. |
Definition at line 119 of file HistTool.cxx.
| void HistTool::Pull | ( | TH1 * | A, |
| TH1 * | B, | ||
| TH1 * | P | ||
| ) |
Calculate the pull between two histograms.
| [in] | A | histogram A. |
| [in] | B | histogram B. |
| [out] | P | pull histogram \((A-B)/\sqrt{\sigma^2(A)+\sigma^2(B)}\). |
Definition at line 386 of file HistTool.cxx.
| void HistTool::Ratio | ( | TH1 * | A, |
| TH1 * | B, | ||
| TH1 * | R, | ||
| bool | dosep = false |
||
| ) |
Calculate the ratio between two histograms.
| [in] | A | histogram A. |
| [in] | B | histogram B. |
| [out] | R | the ratio histogram \((A/B)\). |
| [in] | dosep | seperate the error or not, if do seperate, ignore A's error. |
Definition at line 253 of file HistTool.cxx.
|
protected |
Definition at line 62 of file HistTool.h.