Hi!
Recently I’ve started learning Root. Now I’m supposed to draw histograms form NTuple file. Well, maybe it sounds trivial, but I’ve got some problems. My program doesn’t show any erros but also any histograms…
I’ve done:
root group.phys-higgs.10878592._000001.hist-output.root
root [1] .ls
root [2] NOMINAL->MakeClass("MyAnalysis")
(NOMINAL is a name of branch in which is leaf I wanted to draw.)
Which gave me MyAnalysis.h and MyAnalysis.C files. I tried to write my code for histogram for one leaf of my NTuple in MyAnalysis.C and it looks like this:
#define MyAnalysis_cxx
#include "MyAnalysis.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void MyAnalysis::Loop()
{
TH1F *h0 = new TH1F("h0" ,"tau 0 transverse momentum",100,0,485);
//that part was automaticly made in MyAnalysi.C
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
//And this is my try
h0->Fill(ditau_tau0_pt);
TCanvas *can = new TCanvas("can","can",600,600);
can->cd();
h0->Draw();
TFile outputFile("histoanal.root","RECREATE");
outputFile.cd();
h0->Write();
outputFile.Close();
}
I will apreciate any help. Thank you in advace!