Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:40:37

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