#include #include #include #include "TCanvas.h" #include "TStyle.h" #include "TH1.h" #include "TGaxis.h" #include "TRandom.h" #include "TObject.h" #include "TPoint.h" #include #include #include #include #include #include #include #include #include "TMath.h" using namespace std; #include #include "TH1.h" #include #include "TMath.h" #include #include "TBranch.h" #include "TBasket.h" void savewmass() { gStyle->SetOptStat(1001); TCanvas* c1 = new TCanvas("wmass","w-mass",50,50,800,600); TFile *f1 = new TFile("WW.root"); TFile *f2 = new TFile("TT.root"); TFile *f3 = new TFile("DY.root"); TH1F *h1 = (TH1F*)f1->Get("W_Tran_mass"); h1->SetFillColor(6); TH1F *h2 = (TH1F*)f2->Get("W_Tran_mass"); h2->SetFillColor(4); TH1F *h3 = (TH1F*)f3->Get("W_Tran_mass"); h3->SetFillColor(3); THStack* hs= new THStack("hs","W-Mass stacked histograms"); c1->cd(1); hs->Add(h1); hs->Add(h2); hs->Add(h3); hs->GetXaxis()->SetTitle("GeV"); hs->GetYaxis()->SetTitle("# of entries"); hs->Draw(); TLegend *leg = new TLegend(0.6,0.8,0.9,0.9); leg->AddEntry(h1,"WW","f"); leg->AddEntry(h2,"TT","f"); leg->AddEntry(h3,"DY","f"); leg->Draw(); }