#include #include "TH2D.h" template tuple read2D(const char* fname, ARGS&&... args) { auto* h = new TH2D(std::forward(args)...); FILE* f = fopen(fname, "r"); double x, y, z; double xmin = 1e10; double xmax = -1e10; double ymin = 1e10; double ymax = -1e10; double zmin = 1e10; double zmax = -1e10; while (f && !feof(f)) { auto i = fscanf(f, "%lf %lf %lf", &y, &x, &z); if (3 != i) break; auto bin = h->FindBin(x, y); h->SetBinContent(bin, z); if (x > xmax) xmax = x; if (x < xmin) xmin = x; if (y > ymax) ymax = y; if (y < ymin) ymin = y; if (z > zmax) zmax = z; if (z < zmin) zmin = z; } fclose(f); return make_tuple(h, xmin, xmax, ymin, ymax, zmin, zmax); } void pixelHits(std::string fileName) { gStyle->SetOptStat(0); TCanvas *c1 = new TCanvas("c1", "c1",10,45,1024,512); c1->Range(0,-5.625,0.175,0.625); TH2D* distro; double xmin, xmax, ymin, ymax, zmin, zmax; tie(distro, xmin, xmax, ymin, ymax, zmin, zmax) = read2D(fileName.c_str(), "name", "title", 1024, -0.5, 1023.5, 512, -0.5, 511.5); distro->GetXaxis()->SetRangeUser(xmin, xmax); distro->GetYaxis()->SetRangeUser(ymin, ymax); distro->GetZaxis()->SetRangeUser(zmin, 0.99e4); distro->GetXaxis()->SetTitleFont(132); distro->GetXaxis()->SetLabelFont(132); distro->GetXaxis()->SetTitleOffset(0.9); distro->GetYaxis()->SetTitleFont(132); distro->GetYaxis()->SetLabelFont(132); distro->GetYaxis()->SetTitleOffset(1.5); distro->GetZaxis()->SetTitleFont(132); distro->GetZaxis()->SetLabelFont(132); distro->GetXaxis()->SetTitle("Row [Pixel]"); distro->GetYaxis()->SetTitle("Column [Pixel]"); distro->GetZaxis()->SetTitle("Hits"); distro->SetTitle(""); distro->DrawClone("coltext"); //distro->DrawClone("col"); }