// This macro is to be used on a root file produced with the // event.C selector. #include "StandardLabels.C" void Edarkhits(void) { char fname[256]; sprintf(fname,"darkhits.root"); TFile *f = new TFile(fname); TH1D *Edarkhits = (TH1D*)gROOT->FindObject("Edarkhits"); TCanvas *c1 = new TCanvas(); c1->SetTicks(); c1->SetGrid(); Edarkhits->SetStats(0); Edarkhits->GetXaxis()->SetRangeUser(-0.5, 30.5); Edarkhits->SetFillColor(kAzure); Edarkhits->SetFillStyle(3000); Edarkhits->SetLineColor(kBlack); Edarkhits->SetLineWidth(2.0); Edarkhits->Draw(); double xmean = Edarkhits->GetMean(); double ymax = Edarkhits->GetMaximum(); char str[256]; sprintf(str, "mean: %3.1f MeV", xmean); TPaveText *txt = new TPaveText(20.0, 0.5*ymax, 30.0, 0.75*ymax); txt->AddText(str); txt->Draw(); TLine *l = new TLine(xmean, 0.0, xmean, 1.05*ymax); l->SetLineStyle(2); l->SetLineWidth(4); l->Draw(); StandardLabels1D(Edarkhits, "From mcsmear"); c1->SaveAs("Edarkhits.png"); c1->SaveAs("Edarkhits.pdf"); }