7 #include <TDirectory.h>
13 template<
typename TH2X = TH2>
14 void SaveCorr (
const std::unique_ptr<TH2X>& cov, TString
name, TDirectory * d)
17 auto corr = unique_ptr<TH2>(
dynamic_cast<TH2*
>(cov->Clone(
name)));
20 TString title = cov->GetTitle();
21 title.ReplaceAll(
"covariance",
"correlation");
22 corr->SetTitle(title);
24 const int Nx = corr->GetNbinsX(),
25 Ny = corr->GetNbinsY();
27 for (
int x = 1; x <= Nx; ++x) {
28 double denx = sqrt(cov->GetBinContent(x, x));
29 for (
int y = 1; y <= Ny; ++y) {
30 double deny = sqrt(cov->GetBinContent(y, y));
32 if (denx > 0 && deny > 0) {
33 double content = cov->GetBinContent(x, y);
35 corr->SetBinContent(x, y, content);
36 if (x != y && abs(content) >= 1.) cout << x <<
' ' << y <<
' ' << content << endl;
39 corr->SetBinContent(x, y, 0);
44 corr->SetDirectory(d);