I have the following macro, which produces a nice TRatioPlot but won’t show the legend. The values in the constructor are copied from another macro where it works, and i chose them because I want the legend in the top right corner. Any ideas why it isn’t working?
void HitClusEVetoComparison(){
TFile *_file0 = TFile::Open("/Users/bethlong/Downloads/Run660_AnalysisOutputFile.root");
double bottommargin = 0.15;
double topmargin = 0.05;
double leftmargin = 0.06;
double rightmargin = 0.015;
gStyle->SetPadBottomMargin(bottommargin);
gStyle->SetPadTopMargin(topmargin);
gStyle->SetPadLeftMargin(leftmargin);
gStyle->SetPadRightMargin(rightmargin);
gStyle->SetOptStat(0);
TH1F* hEHit = (TH1F*) _file0->Get("EVetoHits/hEVetoHitCh");
TH1F* hEClu = (TH1F*) _file0->Get("EVetoClusters/hChEVetoCluster");
hEHit->SetTitle(";EVetoChannelID;");
hEClu->SetLineColor(kRed);
TCanvas* c = new TCanvas("c","c",900,700);
TRatioPlot* rEVeto = new TRatioPlot(hEHit,hEClu);
rEVeto->Draw();
TLegend* legend = new TLegend(0.81,0.81,0.98,0.970);
legend->AddEntry(hEHit,"Hit Occupancy");
legend->AddEntry(hEClu,"Cluster Occupancy");
legend->SetTextAlign(22);
legend->Draw();
rEVeto->SetLowBottomMargin(bottommargin);
rEVeto->SetUpTopMargin(topmargin);
rEVeto->SetLeftMargin(leftmargin);
rEVeto->SetRightMargin(rightmargin);
rEVeto->GetLowerRefYaxis()->SetTitle("NHits/NClusters");
}