//must have zee.root in the same directory TCanvas * zeemass() //returns the canvas which displays the histogram { TDirectory * f =(TDirectory *)new TFile("zee.root"); //opens file zee.root f=(TDirectory)f->Get("STNTUPLE"); //opens directory STNTUPLE TTree *h1=f->Get("h1"); //set h1 as a pointer to tree h1 TH1F *hist =new TH1F("hist","Mass of Z boson",100,81,101); //makes a histogram with 100 bins ranging from 81 to101 TLeaf *lmass = h1->GetLeaf("Eemass"); //Sets lmass as a pointer to the leaf for Eemass TLeaf *lcharge = h1->GetLeaf("Echarge"); TLeaf *lnel = h1->GetLeaf("Nel"); Int_t nev = lmass->GetBranch()->GetEntries(); //# of events for (Int_t i=0; iGetBranch()->GetEvent(i); //go to the ith event if(lnel->GetValue()==2) //only events with 2 electrons { lcharge->GetBranch()->GetEvent(i); if ((lcharge->GetValue(0))==-(lcharge->GetValue(1))) { lmass->GetBranch()->GetEvent(i); hist->Fill(lmass->GetValue(0)); //put Eemass in the histogram } } } TCanvas *c1=new TCanvas("c1","Mass of Z bososn",700,700); //creates a mew canvas hist->Draw(); //draw the histogram hist->Fit("gaus"); //fits a gauss curve to the histogram return (c1); }