#include "TFile.h" #include "TH2F.h" #include "TTree.h" #include "TMath.h" #include "TCanvas.h" #include #include using namespace std; void plotDataV2() { gROOT->SetStyle("Plain"); TFile *f = new TFile("background_runs456_EXT1.root"); TTree *clusters_tree = (TTree*)f->Get("clusters_tree"); const Int_t n = 100000; // arbitrary initial size of the arrays const Double_t konst = 2.6e-4; // calibration factor const Double_t thrLow = 0.04; // low threshold in keV const Double_t thrHigh = 15; // high threshold in keV Int_t j = 0; // index for number of clusters with E > threshold Int_t bin = 100; TParameter* charge_total = NULL; // total charge of the cluster TParameter* charge_max_x = NULL; // total charge of the cluster TParameter* charge_max_y = NULL; // total charge of the cluster Double_t vecct[n]; Double_t charge_x[n]; Double_t charge_y[n]; clusters_tree->SetBranchAddress("charge_total",&charge_total); clusters_tree->SetBranchAddress("charge_max_x",&charge_max_x); clusters_tree->SetBranchAddress("charge_max_y",&charge_max_y); TH2* h1 = new TH2F("h1", "", bin, 4000, 9000, bin, 0, 5000); for (int i=0; iGetEntries(); i++) { clusters_tree->GetEntry(i); if ((konst*charge_total->GetVal() > thrLow) && (konst*charge_total->GetVal() < thrHigh)) { h1->Fill(charge_max_x->GetVal(),charge_max_y->GetVal()); j += 1; } } TCanvas *c = new TCanvas("c","c",800,600); c->cd(); h1->Draw("colz"); gStyle->SetOptStat(0); Double_t tab_bin_content[20]; Int_t jj = 0; for (int ii=0; ii<25000000; ii++) { if (h1->GetBinContent(ii) > 50) { int bin_x, bin_y, bin_z; h1->GetBinXYZ(ii, bin_x, bin_y, bin_z); tab_bin_content[jj] = h1->GetBinContent(ii); cout << "Bin value: " << h1->GetBinContent(ii) << " ----- x position: " << h1->GetXaxis()->GetBinLowEdge(bin_x) << " ----- y position: " << h1->GetYaxis()->GetBinLowEdge(bin_y) << endl; jj = jj + 1; } } }