hi,
I want to bin a 2D histogram so that it will look like the plot attached below. Bet when I run my macro it will not plot any thing. Also it is taking a long time in processing. I do not know what i am doing wrong.
I am attaching my macro below.
#include "TLegend.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "TAxis.h"
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <math.h>
#include "TH2F.h"
void pt_eta_selmu()
{
TFile *f = new TFile("May26_2.root");
if(!f) {
std::cout<<"FILE CAN'T BE OPENED"<<std::endl;
}
TTree *t2 = (TTree*)f->Get("demo/AnaTree");
TH2F *h1 = new TH2F("h1","hist_SelMu",100,0,300,100,-3,3);
t2->Draw("SelMu_eta:SelMu_pt >> h1","","TextE COL Z");
// h1->GetXaxis()->SetTitle("SelMu_pt");
// h1->GetYaxis()->SetTitle("SelMu_eta");
for (int i=0;i<=h1->GetXaxis()->GetNbins();i++)
{
for (int j=0;j<=h1->GetYaxis()->GetNbins();j++)
{
double Num = h1->GetBinContent(i,j);
}
}
// h1->GetXaxis()->SetTitle("SelMu_pt");
// h1->GetYaxis()->SetTitle("SelMu_eta");
// t2->Draw("SelMu_eta:SelMu_pt >> h1","","TextE COL Z");
h1->Draw("TextE COL Z");
cout<< "--------------- Entries of Neumerator -------------------- " <<endl;
int NXx = h1->GetXaxis()->GetNbins();
int NYy = h1->GetYaxis()->GetNbins();
cout<< "Nx " <<NXx<<endl;
cout<< "Ny " <<NYy<<endl;
for (int i=1;i<=NXx;i++) {
for (int j=1;j<=NYy;j++) {
}
cout<< " " <<endl;
}
h1->SetXTitle(" Pt_{T} [GeV/c] ");
h1->SetYTitle(" #eta ");
//h1-> SetTitleSize(0.05, "Y");
//h1-> SetTitleSize(0.05, "X");
}
Cheers,
Nab