#include <iostream>
#include <fstream>
void tprofile2polyRealisticModuleError(
Int_t numEvents = 1000000)
{
ifstream infile;
TString dir =
gROOT->GetTutorialDir();
dir.Append("/hist/data/tprofile2poly_tutorial.data");
infile.open(dir.Data());
if (!infile)
{
std::cerr << dir.Data() << std::endl;
std::cerr << "Error code: " << strerror(errno) << std::endl;
return;
}
vector<pair<Double_t, Double_t>> allCoords;
while (infile >> a >> b) {
pair<Double_t, Double_t> coord(a, b);
allCoords.push_back(coord);
}
if (allCoords.size() % 3 != 0) {
cout << "[ERROR] Bad file" << endl;
return;
}
for (
Int_t i = 0; i < allCoords.size(); i += 3) {
x[0] = allCoords[i + 0].first;
y[0] = allCoords[i + 0].second;
x[1] = allCoords[i + 1].first;
y[1] = allCoords[i + 1].second;
x[2] = allCoords[i + 2].first;
y[2] = allCoords[i + 2].second;
th2p->AddBin(3, x, y);
avg->AddBin(3, x, y);
err->AddBin(3, x, y);
}
for (int j = 0; j < numEvents; ++j) {
if (th2p->IsInsideBin(4, r1, r2)) val = rok - rbad1;
if (th2p->IsInsideBin(20, r1, r2)) val = rok - rbad2;
if (th2p->IsInsideBin(13, r1, r2)) val = rok + rbad1;
if (th2p->IsInsideBin(37, r1, r2)) val = rok + rbad2;
th2p->Fill(r1, r2, val);
avg->Fill(r1, r2, val);
err->Fill(r1, r2, val);
}
th2p->SetStats(0);
th2p->Draw("COLZ");
avg->SetStats(0);
avg->Draw("COLZ");
err->SetStats(0);
err->SetContentToError();
err->Draw("COLZ");
}