Dear Developers,
Kindly check this macro,it is not getting entries from tree to plot a simple variable met_pt. I is giving a warning
" Warning: Automatic variable W_mass is allocated missing.cc:39:
Error in TTree::Fill: Failed filling branch:AnaTree.tzq_w, nbytes=-1, entry=430521
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)
"
and donot get enteries.
The macro is
#include <TROOT.h>
#include <TH1.h>
#include <TH2.h>
#include <TSystem.h>
#include <vector>
#include <TLorentzVector.h>
#include <math.h>
#include "TMath.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <map>
#include <TFileMerger.h>
void missing()
{
TFile *f = new TFile("May26_2.root");
TTree *t = (TTree*)f->Get("demo/AnaTree");
TH1F *h4 = new TH1F("h1","pt",100,0,200);
using namespace std;
Float_t met_pt, met_phi;
t->SetBranchAddress("met_pt",met_pt);
t->SetBranchAddress("met_phi",met_phi);
TLorentzVector tmp4(0,0,0,0);
for (int i=0;i<10000;i++) {
TLorentzVector tmp4;
t->GetEntry(i);
//float met_pt=0;
tmp4.SetPtEtaPhiM(met_pt, 0, met_phi, 0);
//tmp4.SetE(tmp4.Pt());
W_mass = tmp4.M();
t->Fill();
h4->Fill(W_mass);
}
TCanvas *c1 = new TCanvas("c1","c1",800,600) ;
h4->Draw();
}
Root file path is /afs/cern.ch/user/n/nmajeed/public
Cheers,
Nab