15 void tprofile2polyRealisticModuleError(Int_t numEvents = 1000000)
17 TCanvas *c1 =
new TCanvas(
"c1",
"4 Malfunctioning Panels", 800, 400);
21 auto th2p =
new TH2Poly();
22 auto avg =
new TProfile2Poly();
23 auto err =
new TProfile2Poly();
26 TString dir = gROOT->GetTutorialDir();
27 dir.Append(
"/hist/data/tprofile2poly_tutorial.data");
28 infile.open(dir.Data());
32 std::cerr << dir.Data() << std::endl;
33 std::cerr <<
"Error code: " << strerror(errno) << std::endl;
37 vector<pair<Double_t, Double_t>> allCoords;
39 while (infile >> a >> b) {
40 pair<Double_t, Double_t> coord(a, b);
41 allCoords.push_back(coord);
44 if (allCoords.size() % 3 != 0) {
45 cout <<
"[ERROR] Bad file" << endl;
50 for (Int_t i = 0; i < allCoords.size(); i += 3) {
51 x[0] = allCoords[i + 0].first;
52 y[0] = allCoords[i + 0].second;
53 x[1] = allCoords[i + 1].first;
54 y[1] = allCoords[i + 1].second;
55 x[2] = allCoords[i + 2].first;
56 y[2] = allCoords[i + 2].second;
57 th2p->AddBin(3, x, y);
64 for (
int j = 0; j < numEvents; ++j) {
65 Double_t r1 = ran.Gaus(0, 10);
66 Double_t r2 = ran.Gaus(0, 8);
67 Double_t rok = ran.Gaus(20, 2);
68 Double_t rbad1 = ran.Gaus(1, 2);
69 Double_t rbad2 = ran.Gaus(2, 0);
73 if (th2p->IsInsideBin(4, r1, r2)) val = rok - rbad1;
74 if (th2p->IsInsideBin(20, r1, r2)) val = rok - rbad2;
75 if (th2p->IsInsideBin(13, r1, r2)) val = rok + rbad1;
76 if (th2p->IsInsideBin(37, r1, r2)) val = rok + rbad2;
79 th2p->Fill(r1, r2, val);
80 avg->Fill(r1, r2, val);
81 err->Fill(r1, r2, val);
87 th2p->SetTitle(
"total hits");
92 avg->SetTitle(
"average charge");
97 err->SetContentToError();
98 err->SetTitle(
"error");