// // Daniel Pitzl, Apr 2012 // PostScript plots for GBL example CERN // root -l // .x cern2ps.C // #include "TCanvas.h" #include "TLatex.h" #include "TPostScript.h" #include "TF1.h" #include #include #include void cern2ps(){ // set styles: gStyle->SetTextFont(62);//62 = Helvetica bold gStyle->SetTextAlign(11); gStyle->SetTickLength( -0.02, "x" ); // tick marks outside gStyle->SetTickLength( -0.02, "y"); gStyle->SetLabelOffset( 0.022, "x" ); gStyle->SetLabelOffset( 0.022, "y" ); gStyle->SetTitleOffset( 1.3, "x" ); gStyle->SetTitleOffset( 2.0, "y" ); gStyle->SetLabelFont( 62, "X" ); gStyle->SetLabelFont( 62, "Y" ); gStyle->SetTitleFont( 62, "X" ); gStyle->SetTitleFont( 62, "Y" ); gStyle->SetTitleBorderSize(0); // no frame around global title gStyle->SetTitleAlign(13); // 13 = left top align gStyle->SetTitleX( 0.22 ); // global title gStyle->SetTitleY( 0.98 ); // global title gStyle->SetLineWidth(1);// frames gStyle->SetHistLineColor(4); // 4=blau gStyle->SetHistLineWidth(3); gStyle->SetHistFillColor(5); // 5=gelb // gStyle->SetHistFillStyle(4050); // 4050 = half transparent gStyle->SetHistFillStyle(1001); // 1001 = solid gStyle->SetFrameLineWidth(2); // statistics box: gStyle->SetOptStat(111111); gStyle->SetStatFormat("8.6g"); // more digits, default is 6.4g gStyle->SetStatFont(42); // 42 = Helvetica normal // gStyle->SetStatFont(62); // 62 = Helvetica bold gStyle->SetStatBorderSize(1); // no 'shadow' gStyle->SetStatX(0.95); gStyle->SetStatY(0.90); gStyle->SetPalette(1); // rainbow colors gStyle->SetHistMinimumZero(); // no zero suppression gStyle->SetOptDate(); gROOT->ForceStyle(); //-------------------------------------------------------------------- // square canvas: // topleft x, y, width x, y TCanvas *cv = new TCanvas("cv", "cv", 635, 246, 813, 837 ); // to get fCw 800 fCh 800 cv->SetBottomMargin(0.15); cv->SetLeftMargin(0.15); cv->SetRightMargin(0.05); gPad->Update();// required //-------------------------------------------------------------------- // ps file: TPostScript ps( "cern.ps", 111 ); // 111 = portrait ps.Range(16,24); //---------------------------------------------------------------------------- // res vs p // GBL empty telescope: Float_t GBLp[49] = { 1.000, 1.100, 1.210, 1.331, 1.464, 1.611, 1.772, 1.949, 2.144, 2.358, 2.594, 2.853, 3.138, 3.452, 3.797, 4.177, 4.595, 5.054, 5.560, 6.116, 6.727, 7.400, 8.140, 8.954, 9.850, 10.835, 11.918, 13.110, 14.421, 15.863, 17.449, 19.194, 21.114, 23.225, 25.548, 28.102, 30.913, 34.004, 37.404, 41.145, 45.259, 49.785, 54.764, 60.240, 66.264, 72.890, 80.180, 88.197, 97.017 }; // tilted: Float_t GBLrx[49] = { 21.82, 20.78, 19.83, 18.98, 18.20, 17.49, 16.83, 16.21, 15.63, 15.08, 14.55, 14.03, 13.54, 13.07, 12.61, 12.18, 11.78, 11.40, 11.05, 10.72, 10.43, 10.17, 9.94, 9.74, 9.56, 9.41, 9.28, 9.16, 9.07, 8.99, 8.92, 8.86, 8.81, 8.77, 8.74, 8.71, 8.69, 8.67, 8.65, 8.64, 8.63, 8.62, 8.61, 8.60, 8.60, 8.59, 8.59, 8.59, 8.58 }; Float_t GBLry[49] = { 16.16, 15.00, 13.95, 13.01, 12.16, 11.40, 10.71, 10.10, 9.55, 9.06, 8.61, 8.21, 7.85, 7.52, 7.22, 6.94, 6.68, 6.44, 6.21, 5.99, 5.78, 5.58, 5.38, 5.19, 5.02, 4.85, 4.69, 4.54, 4.40, 4.28, 4.17, 4.07, 3.98, 3.90, 3.84, 3.78, 3.73, 3.69, 3.65, 3.62, 3.60, 3.58, 3.56, 3.54, 3.53, 3.52, 3.51, 3.50, 3.50 }; // 0 deg: Float_t GBLrx0[49] = { 33.50, 32.31, 31.17, 30.08, 29.02, 28.01, 27.03, 26.11, 25.24, 24.42, 23.67, 22.98, 22.36, 21.80, 21.31, 20.87, 20.49, 20.16, 19.88, 19.64, 19.43, 19.26, 19.11, 18.99, 18.88, 18.80, 18.72, 18.66, 18.61, 18.57, 18.54, 18.51, 18.49, 18.47, 18.45, 18.44, 18.42, 18.42, 18.41, 18.40, 18.40, 18.39, 18.39, 18.39, 18.38, 18.38, 18.38, 18.38, 18.38 }; Float_t GBLry0[49] = { 23.79, 22.76, 21.82, 20.96, 20.17, 19.42, 18.72, 18.06, 17.42, 16.81, 16.22, 15.65, 15.11, 14.59, 14.10, 13.64, 13.22, 12.83, 12.48, 12.16, 11.88, 11.63, 11.42, 11.23, 11.07, 10.93, 10.81, 10.71, 10.63, 10.56, 10.50, 10.45, 10.41, 10.37, 10.35, 10.32, 10.30, 10.29, 10.27, 10.26, 10.25, 10.24, 10.24, 10.23, 10.23, 10.22, 10.22, 10.22, 10.22 }; int nGBL = 49; gStyle->SetLabelOffset( 0.012, "x" ); //gStyle->SetTitleOffset( 1.5, "x" ); gROOT->ForceStyle(); gPad->SetTicks(0,1);//ticks right gblx = new TGraph( nGBL, GBLp, GBLrx ); gblx->SetMinimum(0); gblx->SetMaximum(40); gblx->SetTitle("tilted CMS telescope resolution;p [GeV];GBL resolution at DUT [#mum]"); gblx->SetLineColor(4); gblx->SetLineWidth(2); gPad->SetLogx(); gPad->Update(); gblx->Draw("AC"); gbly = new TGraph( nGBL, GBLp, GBLry ); gbly->SetLineColor(2); gbly->SetLineWidth(2); gbly->Draw("C"); cv->Update(); // 0 deg: gblx = new TGraph( nGBL, GBLp, GBLrx0 ); gblx->SetMinimum(0); gblx->SetMaximum(40); gblx->SetTitle("0 deg CMS telescope resolution;p [GeV];GBL resolution at DUT [#mum]"); gblx->SetLineColor(4); gblx->SetLineWidth(2); gPad->SetLogx(); gPad->Update(); gblx->Draw("AC"); gbly = new TGraph( nGBL, GBLp, GBLry0 ); gbly->SetLineColor(2); gbly->SetLineWidth(2); gbly->Draw("C"); cv->Update(); //---------------------------------------------------------------------------- // done: ps.Close(); system("ps2pdf cern.ps"); system("rm -f cern.ps"); //delete cv; }