12 Eigen::MatrixXd
ret(mat->GetNrows(), mat->GetNcols());
14 for(
int i = 0;
i < mat->GetNrows(); ++
i){
15 for(
int j = 0;
j < mat->GetNcols(); ++
j){
16 ret.coeffRef(
i,
j) = (*mat)(
i,
j);
27 for(
int i = 0;
i < mat.rows(); ++
i){
28 for(
int j = 0;
j < mat.cols(); ++
j){
36 double LogLikelihood(
const Eigen::ArrayXd& ea,
const Eigen::ArrayXd& oa,
bool useOverflow)
38 assert(ea.size() == oa.size());
42 const int bufferBins = useOverflow ? 0 : -1;
44 for(
int i = 0;
i < ea.size()+bufferBins; ++
i){
52 double Chi2CovMx(
const Eigen::ArrayXd&
e,
const Eigen::ArrayXd&
o,
const Eigen::MatrixXd& covmxinv)
54 assert(e.size() == covmxinv.rows()+2);
56 Eigen::ArrayXd
diff = e-
o;
58 const Eigen::ArrayXd diffSub(Eigen::Map<Eigen::ArrayXd>(diff.data()+1, diff.size()-2));
60 return diffSub.matrix().dot(covmxinv*diffSub.matrix());
70 std::set<int> nullRows;
73 bool rowIsNull =
true;
87 std::cerr <<
" Notice: covariance matrix has " << nullRows.size() <<
" null rows.\n" 88 <<
"They will be removed before inverting and added back afterwards." <<
std::endl;
91 Eigen::MatrixXd invMx(mx.rows() - nullRows.size(),
92 mx.cols() - nullRows.size());
93 unsigned int skippedRows = 0;
96 if (nullRows.find(
row) != nullRows.end())
101 unsigned int skippedCols = 0;
102 for (
int col = 0;
col < mx.cols();
col++)
106 if (nullRows.find(
col) != nullRows.end())
112 invMx(
col-skippedCols,
row-skippedRows) = invMx(
row-skippedRows,
col-skippedCols) = mx(
row,
col);
116 invMx = invMx.inverse();
119 if (!nullRows.empty())
122 Eigen::MatrixXd retMx(mx.rows(), mx.cols());
123 for (
int row = 0;
row < mx.rows();
row++)
125 if (nullRows.find(
row) != nullRows.end())
131 unsigned int skippedCols = skippedRows;
132 for (
int col = 0;
col < mx.cols();
col++)
134 if (nullRows.find(
col) != nullRows.end())
double Chi2CovMx(const Eigen::ArrayXd &e, const Eigen::ArrayXd &o, const Eigen::MatrixXd &covmxinv)
Cuts and Vars for the 2020 FD DiF Study.
TMatrixD TMatrixDFromEigenMatrixXd(const Eigen::MatrixXd &mat)
double LogLikelihood(const Eigen::ArrayXd &ea, const Eigen::ArrayXd &oa, bool useOverflow)
The log-likelihood formula from the PDG.
Eigen::MatrixXd SymmMxInverse(const Eigen::MatrixXd &mx)
Eigen::MatrixXd EigenMatrixXdFromTMatrixD(const TMatrixD *mat)
assert(nhit_max >=nhit_nbins)