#include "myroot.h" #include "CalcEff.h" void main() { printf("Welcome to mcTest.C\n"); TChain *mcdata = new TChain("h1"); Int_t ntrk; Float_t the_trk[50]; Int_t sle_trk[50]; Int_t mcse_trk[50]; TH1F *hist1 = new TH1F("hist1","mcse",300,0,3); TH1F *hist2 = new TH1F("hist2","sle",300,0,3); TCanvas *c1 = new TCanvas("c1","c1",600,650); // The program ends somewhere here. When I had the TCanvas statement // placed in a later part of the program, just before the hist3.Draw, // the program failed there. printf("Adding data to chain\n"); mcdata->Add("../other/mcdis96_03.root"); printf("Setting Branch Addresses\n"); mcdata->SetBranchAddress("ntrk",&ntrk); mcdata->SetBranchAddress("the_trk",the_trk); mcdata->SetBranchAddress("sle_trk",sle_trk); mcdata->SetBranchAddress("mcse_trk",mcse_trk); Int_t nevents = mcdata->GetEntries(); printf("Entering Loop\n"); for(Int_t i = 0; i < nevents; i++) { mcdata->GetEvent(i); for(Int_t j = 0; j < ntrk; j++) { if(mcse_trk[j]==1) { hist1->Fill(the_trk[j]); if(sle_trk[j]==1) { hist2->Fill(the_trk[j]); } } } } TH1F *hist3 = new TH1F("hist3","eff",300,0,3); CalcEff(*hist1,*hist2,*hist3); printf("Eff calculated\n"); TPad *pad1 = new TPad("pad1","pad1",0.02,0.02,0.98,0.98,10); pad1->Draw(); hist3->Draw("e1p"); }