Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:20

0001 #include "TCanvas.h"
0002 #include "TH1.h"
0003 #include "TH1D.h"
0004 #include "TLegend.h"
0005 #include "TPad.h"
0006 #include "TPaveText.h"
0007 #include "TROOT.h"
0008 
0009 #include "../interface/TkAlStyle.h"
0010 
0011 void testTkAlStyle() {
0012   //gROOT->ProcessLine(".L ../src/TkAlStyle.cc++g");
0013   TkAlStyle::set(PRELIMINARY);  // set publication status
0014 
0015   TCanvas* can = new TCanvas("can", "can", 500, 500);
0016   can->cd();
0017 
0018   // Create dummy histograms representing validation plots,
0019   // e.g. DMR plots, for a particular alignment object, using
0020   // line style accordingly
0021   TH1* h1 = new TH1D("h1", ";x title;y title", 100, -10, 10);
0022   h1->FillRandom("gaus", 1000);
0023   h1->SetLineColor(TkAlStyle::color(IDEALAlign));
0024   h1->SetLineStyle(TkAlStyle::style(IDEALAlign));
0025   h1->GetYaxis()->SetRangeUser(0, 110);
0026 
0027   TH1* h2 = new TH1D("h2", ";x title;y title", 100, -10, 10);
0028   h2->FillRandom("gaus", 500);
0029   h2->SetLineColor(TkAlStyle::color(CRAFTAlign));
0030   h2->SetLineStyle(TkAlStyle::style(CRAFTAlign));
0031   h2->GetYaxis()->SetRangeUser(0, 110);
0032 
0033   h1->Draw();
0034   h2->Draw("same");
0035 
0036   // Add a title that specifies the data-taking era
0037   // (title specifies also the publication label "CMS Preliminary"
0038   // etc. according to the status set above)
0039   TPaveText* title = TkAlStyle::standardRightTitle(CRAFT15);
0040   title->Draw("same");
0041 
0042   // Add a legend at the top left with 2 entries stretching
0043   // over 60% of the pad's width. Legend labels depend on
0044   // the alignment object.
0045   TLegend* leg = TkAlStyle::legend("top left", 2, 0.6);
0046   leg->AddEntry(h1, TkAlStyle::toTString(IDEALAlign), "L");
0047   leg->AddEntry(h2, TkAlStyle::toTString(CRAFTAlign), "L");
0048   leg->Draw("same");
0049 
0050   gPad->RedrawAxis();
0051   can->SaveAs("test.pdf");
0052 }
0053 
0054 // main function for unit test
0055 int main(int argc, char** argv) { testTkAlStyle(); }