#include //Purpose: Simple example of how to make plots from file made by TElecand.cc // //User can specify file name as an argument .x ele_example.C("myfile.hbk") // void ele_example(Char_t* filename="ele_cand.root"){ //Set up the style gROOT->SetStyle("Plain"); gStyle->SetTitleFont(32); //Title box font (32=italic times bold) gStyle->SetTitleX(0.1); //Title box x position (top left-hand corner) gStyle->SetTitleY(0.995); //Title box y position (default value) gStyle->SetTitleW(0.6); //Title box width as fraction of pad size gStyle->SetTitleH(0.08); //Title box height as fraction of pad size //Open the file TFile* f=new TFile(filename); f->ls(); //Open a canvas TCanvas* myc = new TCanvas("Electrons","Example plot: default/tight/loose/stacked",400,500); myc->Clear(); myc->Divide(2,2); //Draw ET histograms for default, tight and loose electrons myc->cd(1);//draw stntuple default f->cd("ElectronBlock/default"); ncem_Et->Draw(); myc->cd(2);//draw tight f->cd("ElectronBlock/tight"); ncem_Et->Draw(); myc->cd(3);//draw loose f->cd("ElectronBlock/loose"); ncem_Et->Draw(); myc->cd(4);//stack them - have to add tight and loose together and store in "both" f->cd("ElectronBlock/default"); ncem_Et->Draw(); f->cd("ElectronBlock/loose"); TH1F* both = (TH1F*) ncem_Et->Clone(); both->SetName("both"); f->cd("ElectronBlock/tight"); both->Add(ncem_Et); both->SetFillColor(4); both->SetFillStyle(3004); both->Draw("same"); ncem_Et->SetFillColor(4); ncem_Et->Draw("same"); //Add a legend leg =new TLegend(0.65,0.75,0.75,0.85,""); leg->SetFillColor(0); f->cd("ElectronBlock/default"); leg->AddEntry(ncem_Et,"Default"); leg->AddEntry(both,"Loose","F"); f->cd("ElectronBlock/tight"); leg->AddEntry(ncem_Et,"Tight","F"); leg->Draw(); return; }