Dear developers,
I am running a macro but it is not getting entries from the tree. I did the same work in another macro twodim.cc but it works. Can you please help me to resolve this problem.
#include <TFile.h>
#include <TTree.h>
#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 twodim_new()
{
TFile *f = new TFile("output1_ajeeb_Veto.root");
TTree *t = (TTree*)f->Get("AnaTree");
TH1F *h1 = new TH1F("h1","Z1_mass",100,0,200);
TH1F *h2 = new TH1F("h2","Z2_mass",100,0,200);
TH1F *h3 = new TH1F("h3","Z3_mass",100,0,200);
using namespace std;
Float_t VetoMu_px[50], VetoMu_py[50], VetoMu_pz[50], VetoMu_en[50], VetoMu_pt[50], VetoMu_eta[50], VetoMu_phi[50], VetoMu_iso[50];
Float_t VetoMu_ismuon[50], VetoMu_idTight[50];
Int_t VetoMu, VetoMu_charge[50];
t->SetBranchAddress("VetoMu_px",VetoMu_px);
t->SetBranchAddress("VetoMu_py",VetoMu_py);
t->SetBranchAddress("VetoMu_pz",VetoMu_pz);
t->SetBranchAddress("VetoMu_en",VetoMu_en);
t->SetBranchAddress("VetoMu",&VetoMu);
t->SetBranchAddress("VetoMu_charge",&VetoMu_charge);
t->SetBranchAddress("VetoMu_pt",&VetoMu_pt);
t->SetBranchAddress("VetoMu_eta",&VetoMu_eta);
t->SetBranchAddress("VetoMu_phi",&VetoMu_phi);
t->SetBranchAddress("VetoMu_idTight",&VetoMu_idTight);
t->SetBranchAddress("VetoMu_ismuon",&VetoMu_ismuon);
t->SetBranchAddress("VetoMu_iso",&VetoMu_iso);
TLorentzVector tmp(0,0,0,0), tmp1(0,0,0,0), tmp2(0,0,0,0), tmp3(0,0,0,0);
//int n1 = t->GetEntries();
for (int i=0;i<10000;i++) {
TLorentzVector tmp1, tmp2, tmp3;
t->GetEntry(i);
for(int m=0; m<VetoMu;m++) {
if(VetoMu<2)continue;
int m1=0, m2=1, m3=2;
if(m1==0) tmp1.SetPxPyPzE(VetoMu_px[m1], VetoMu_py[m1], VetoMu_pz[m1], VetoMu_en[m1]);
if(m2==1) tmp2.SetPxPyPzE(VetoMu_px[m2], VetoMu_py[m2], VetoMu_pz[m2], VetoMu_en[m2]);
if(m3==2) tmp3.SetPxPyPzE(VetoMu_px[m3], VetoMu_py[m3], VetoMu_pz[m3], VetoMu_en[m3]);
if (VetoMu_charge[m1]*VetoMu_charge[m2] < 0.) {
double z1_mass = (tmp1 + tmp2).M();
}
if (VetoMu_charge[m2]*VetoMu_charge[m3] < 0.) {
double z2_mass = (tmp2 + tmp3).M();
}
if (VetoMu_charge[m3]*VetoMu_charge[m1] < 0.) {
double z3_mass = (tmp1 + tmp3).M();
}
// t->Fill();
t->GetEntry(i);
h1->Fill(z1_mass);
h2->Fill(z2_mass);
h3->Fill(z3_mass);
}
}
TCanvas *c1 = new TCanvas("c1","c1",800,600) ;
c1->Divide(2,2);
c1->cd(1);
h1->Draw();
h1->GetXaxis()->SetTitle("Z_12_mass");
c1->cd(2);
h2->Draw();
h2->GetXaxis()->SetTitle("Z_32_mass");
c1->cd(3);
h3->Draw();
h3->GetXaxis()->SetTitle("Z_31_mass");
}
Cheers,
Nab
output1_ajeeb_Veto.root (28.2 KB)
twodim.cc (6.2 KB)