138 const char*
inputDir =
"./athena24/run_grid/user.$.l1topoRates.EB_fullRun_00482596_1Oct25_RatesHistograms_XYZ.root.tgz/";
140 const char*
outputFile =
"CombinedMatrices.root";
143 std::vector<std::string> matrices = {
153 std::cerr <<
"Error: cannot open combined file to add L1TopoScore_matrix.\n";
157 TH2D* h_rates = (TH2D*)
fout->Get(
"rates_matrix_combined");
159 std::cerr <<
"Error: rates_matrix_combined not found!\n";
164 int nbx = h_rates->GetNbinsX();
165 int nby = h_rates->GetNbinsY();
167 TH2D* h_topo = (TH2D*)h_rates->Clone(
"L1TopoScore_matrix_combined");
171 for (
int ix = 1; ix <= nbx; ++ix) {
172 for (
int jy = 1; jy <= nby; ++jy) {
175 h_topo->SetBinContent(ix, jy, 1.0);
176 h_topo->SetBinError(ix, jy, 0.0);
180 double A = h_rates->GetBinContent(ix, ix);
181 double sigmaA = h_rates->GetBinError(ix, ix);
182 double B = h_rates->GetBinContent(jy, jy);
183 double sigmaB = h_rates->GetBinError(jy, jy);
184 double O = h_rates->GetBinContent(ix, jy);
185 double sigmaO = h_rates->GetBinError(ix, jy);
189 h_topo->SetBinContent(ix, jy, 0.0);
190 h_topo->SetBinError(ix, jy, 0.0);
195 h_topo->SetBinContent(ix, jy, 0.0);
196 h_topo->SetBinError(ix, jy, 0.0);
207 double dD_dO = (
A +
B - 2.0 *
O);
213 double dTS_dA = (
B * D -
N * dD_dA) / (D * D);
215 double dTS_dB = (
A * D -
N * dD_dB) / (D * D);
217 double dTS_dO = -
N * dD_dO / (D * D);
221 if (sigmaA > 0.0) varTS += (dTS_dA * dTS_dA) * (sigmaA * sigmaA);
222 if (sigmaB > 0.0) varTS += (dTS_dB * dTS_dB) * (sigmaB * sigmaB);
223 if (sigmaO > 0.0) varTS += (dTS_dO * dTS_dO) * (sigmaO * sigmaO);
225 double sigmaTS = (varTS > 0.0) ? std::sqrt(varTS) : 0.0;
227 h_topo->SetBinContent(ix, jy,
TS);
228 h_topo->SetBinError(ix, jy, sigmaTS);
235 std::cout <<
"L1TopoScore_matrix_combined written successfully.\n";