Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:41

0001 TH1F* hist_bx_mean;
0002 TH1F* hist_bx_95;
0003 
0004 const Int_t nBins = 4;
0005 const Int_t nBins_2 = 3;
0006 
0007 void LoopersPlots() {
0008   setStyle();
0009   
0010   hist_bx_mean = new TH1F("hist_bx_mean","Bunch Crossing vs Pseudorapidity;Pseudorapidity |#eta|;Bunch Crossings [25 ns]",
0011               10,0.0,1.0);
0012   hist_bx_95 = new TH1F("hist_bx_95","Bunch Crossing vs Pseudorapidity;Pseudorapidity |#eta|;Bunch Crossings [25 ns]",
0013             10,0.0,1.0);
0014   
0015   // fill with Loopers analalysis numbers
0016   Double_t Pseudorapidity[nBins]     = { 0.0      , 0.3      , 0.6      , 1.5      };
0017   Double_t BunchCrossing_Mean[nBins] = { 1.3105   , 0.752343 , 0.56186  , 0.614987 };
0018   Double_t BunchCrossing_RMS[nBins]  = { 0.851869 , 0.455688 , 0.289731 , 0.318793 };
0019   Double_t BunchCrossing_95[nBins]   = { 2.85     , 1.45     , 1.05     , 1.25     };
0020   
0021   for(Int_t i=0; i<nBins; i++) {
0022     // bunch crossings
0023     hist_bx_mean->Fill( Pseudorapidity[i] , BunchCrossing_Mean[i] );
0024     hist_bx_mean->SetBinError( hist_bx_mean->FindBin(Pseudorapidity[i]) , BunchCrossing_RMS[i] );
0025     hist_bx_95->Fill(   Pseudorapidity[i] , BunchCrossing_95[i]   );
0026   }
0027 
0028   hist_bx_mean_pT_eta00 = new TH1F("hist_bx_mean_pT_eta00",
0029                    "Bunch Crossing vs Transverse Momentum |#eta|=0;Transverse Momentum p_{T} [GeV/c];Bunch Crossings [25 ns]",
0030                    100,0.0,1.0);
0031   hist_bx_mean_pT_eta00->GetYaxis()->SetRangeUser(0.0,3.2);
0032   
0033   hist_bx_95_pT_eta00 = new TH1F("hist_bx_95_pT_eta00",
0034                  "Bunch Crossing vs Transverse Momentum |#eta|=0;Transverse Momentum p_{T} [GeV/c];Bunch Crossings [25 ns]",
0035                  100,0.0,1.0);
0036   hist_bx_95_pT_eta00->GetYaxis()->SetRangeUser(0.0,3.2);
0037   
0038   hist_bx_mean_pT_eta03 = new TH1F("hist_bx_mean_pT_eta03",
0039                    "Bunch Crossing vs Transverse Momentum |#eta|=0.3;Transverse Momentum p_{T} [GeV/c];Bunch Crossings [25 ns]",
0040                    100,0.0,1.0);
0041   hist_bx_mean_pT_eta03->GetYaxis()->SetRangeUser(0.0,3.2);
0042   
0043   hist_bx_95_pT_eta03 = new TH1F("hist_bx_95_pT_eta03",
0044                  "Bunch Crossing vs Transverse Momentum |#eta|=0.3;Transverse Momentum p_{T} [GeV/c];Bunch Crossings [25 ns]",
0045                  100,0.0,1.0);
0046   hist_bx_95_pT_eta03->GetYaxis()->SetRangeUser(0.0,3.2);
0047   
0048   // fill with Loopers analalysis numbers
0049   Double_t TransverseMomentum[nBins_2]          = { 0.2      , 0.4      , 0.6      };
0050   Double_t BunchCrossing_Mean_pT_eta00[nBins_2] = { 0.302835 , 0.702969 , 1.3105   };
0051   Double_t BunchCrossing_RMS_pT_eta00[nBins_2]  = { 0.135268 , 0.479322 , 0.851869 };
0052   Double_t BunchCrossing_95_pT_eta00[nBins_2]   = { 0.45     , 1.55     , 2.85     };
0053   Double_t BunchCrossing_Mean_pT_eta03[nBins_2] = { 0.264885 , 0.555507 , 0.752343 };
0054   Double_t BunchCrossing_RMS_pT_eta03[nBins_2]  = { 0.131494 , 0.388753 , 0.455688 };
0055   Double_t BunchCrossing_95_pT_eta03[nBins_2]   = { 0.45     , 1.35     , 1.45     };
0056   
0057   for(Int_t i=0; i<nBins_2; i++) {
0058     // bunch crossings
0059     hist_bx_mean_pT_eta00->Fill( TransverseMomentum[i] , BunchCrossing_Mean_pT_eta00[i] );
0060     hist_bx_mean_pT_eta00->SetBinError( hist_bx_mean_pT_eta00->FindBin(TransverseMomentum[i]) , BunchCrossing_RMS_pT_eta00[i] );
0061     hist_bx_95_pT_eta00->Fill(   TransverseMomentum[i] , BunchCrossing_95_pT_eta00[i]   );
0062     hist_bx_mean_pT_eta03->Fill( TransverseMomentum[i] , BunchCrossing_Mean_pT_eta03[i] );
0063     hist_bx_mean_pT_eta03->SetBinError( hist_bx_mean_pT_eta03->FindBin(TransverseMomentum[i]) , BunchCrossing_RMS_pT_eta03[i] );
0064     hist_bx_95_pT_eta03->Fill(   TransverseMomentum[i] , BunchCrossing_95_pT_eta03[i]   );
0065   }
0066   
0067   // draw
0068   drawHistos( hist_bx_95          , hist_bx_mean          , "bx"       );
0069   drawHistos( hist_bx_95_pT_eta00 , hist_bx_mean_pT_eta00 , "bx_eta00" );
0070   drawHistos( hist_bx_95_pT_eta03 , hist_bx_mean_pT_eta03 , "bx_eta03" );
0071   //
0072 }
0073 
0074 void drawHistos(TH1F* myHisto, TH1F* myHisto_err, TString myName) {
0075   //
0076   setStyle();
0077   //
0078   myHisto->SetMarkerColor(kBlue);
0079   myHisto->SetMarkerSize(1.5);
0080   myHisto->SetMarkerStyle(20);
0081   //  
0082   myHisto_err->SetMarkerColor(kRed);
0083   myHisto_err->SetMarkerSize(1.5);
0084   myHisto_err->SetMarkerStyle(21);
0085   //  
0086   
0087   // canvas
0088   TCanvas can("can","can",1000,900);
0089   can.Range(0,0,25,25);
0090   can.Divide(1,2);
0091   can.SetFillColor(kWhite);
0092   can.cd(1);
0093   //
0094   myHisto->GetXaxis()->SetNoExponent(1);
0095   myHisto->GetXaxis()->SetNdivisions(myHisto->GetNbinsX());
0096   myHisto->GetYaxis()->SetNdivisions(504);
0097   //
0098   myHisto->Draw("P,E2");
0099   //
0100   can.cd(2);
0101   //
0102   myHisto_err->GetXaxis()->SetNoExponent(1);
0103   myHisto_err->GetYaxis()->SetNoExponent(1);
0104   myHisto_err->GetXaxis()->SetNdivisions(myHisto_err->GetNbinsX());
0105   myHisto_err->GetYaxis()->SetNdivisions(504);
0106   //
0107   myHisto_err->Draw("P");
0108   //
0109   //
0110   can.Update();
0111   can.SaveAs( Form( "LoopersPlots_%s.eps", myName.Data() ) );
0112   can.SaveAs( Form( "LoopersPlots_%s.gif", myName.Data() ) );
0113   can.SaveAs( Form( "LoopersPlots_%s.C"  , myName.Data() ) );
0114   //
0115 }
0116 
0117 void drawHistos(TGraphAsymmErrors* myHisto, TH1F* myHisto_low, TH1F* myHisto_high , TString myName) {
0118   //
0119   setStyle();
0120   //
0121   myHisto->SetMarkerColor(kBlue);
0122   myHisto->SetMarkerSize(1.5);
0123   myHisto->SetMarkerStyle(20);
0124   myHisto->SetLineWidth(2);
0125   //
0126   myHisto_low->SetFillColor(kWhite);
0127   myHisto_low->SetLineColor(kGreen);
0128   myHisto_low->SetLineWidth(4);
0129   //  
0130   myHisto_high->SetFillColor(kWhite);
0131   myHisto_high->SetLineColor(kRed);
0132   myHisto_high->SetLineWidth(4);
0133   //  
0134   // canvas
0135   TCanvas can("can","can",1000,800);
0136   can.Range(0,0,25,25);
0137   can.SetFillColor(kWhite);
0138   can.cd();
0139   //
0140   myHisto->GetXaxis()->SetNoExponent(1);
0141   myHisto->GetXaxis()->SetNdivisions(myHisto->GetN());
0142   myHisto->GetYaxis()->SetNdivisions(504);
0143   //
0144   myHisto->Draw("AP,E1");
0145   myHisto_low->Draw("L,SAME");
0146   myHisto_high->Draw("L,SAME");
0147   //
0148   // Legenda
0149   TLegend* theLegend = new TLegend(0.70, 0.70, 0.89, 0.89);
0150   theLegend->AddEntry( myHisto_low  , "95% CL lower limit" , "L" );
0151   theLegend->AddEntry( myHisto      , "EW Fit"             , "P" );
0152   theLegend->AddEntry( myHisto_high , "EW Fit upper limit" , "L" );
0153   theLegend->Draw();
0154   //
0155   can.Update();
0156   can.SaveAs( Form( "LoopersPlots_%s.eps", myName.Data() ) );
0157   can.SaveAs( Form( "LoopersPlots_%s.gif", myName.Data() ) );
0158   can.SaveAs( Form( "LoopersPlots_%s.C"  , myName.Data() ) );
0159   //
0160 }
0161 
0162 void drawHistos(TH1F* myHisto_1, TH1F* myHisto_2 , TString myName) {
0163   //
0164   setStyle();
0165   //
0166   myHisto_1->SetFillColor(kWhite);
0167   myHisto_1->SetLineColor(kBlack);
0168   myHisto_1->SetLineWidth(2);
0169   myHisto_1->SetMarkerStyle(20);
0170   myHisto_1->SetMarkerColor(kBlue);
0171   //  
0172   myHisto_2->SetFillColor(kWhite);
0173   myHisto_2->SetLineColor(kBlack);
0174   myHisto_2->SetLineWidth(2);
0175   myHisto_2->SetMarkerStyle(21);
0176   myHisto_2->SetMarkerColor(kRed);
0177   //  
0178   // canvas
0179   TCanvas can("can","can",1000,800);
0180   can.Range(0,0,25,25);
0181   can.SetFillColor(kWhite);
0182   can.cd();
0183   //
0184   //  myHisto_mean->GetXaxis()->SetNoExponent(1);
0185   //  myHisto_mean->GetXaxis()->SetNdivisions(myHisto->GetN());
0186   //  myHisto_mean->GetYaxis()->SetNdivisions(504);
0187   //
0188   myHisto_1->Draw("P");
0189   myHisto_2->Draw("PE1,SAME");
0190   //
0191   // Legenda
0192   TLegend* theLegend = new TLegend(0.70, 0.70, 0.89, 0.89);
0193   theLegend->AddEntry( myHisto_1 , "95%" , "P" );
0194   theLegend->AddEntry( myHisto_2 , "Mean"  , "P" );
0195   theLegend->Draw();
0196   //
0197   can.Update();
0198   can.SaveAs( Form( "LoopersPlots_%s.eps", myName.Data() ) );
0199   can.SaveAs( Form( "LoopersPlots_%s.gif", myName.Data() ) );
0200   can.SaveAs( Form( "LoopersPlots_%s.C"  , myName.Data() ) );
0201   //
0202 }
0203 
0204 void setStyle(){
0205   // Style
0206   gStyle->SetOptStat(0000);
0207   gStyle->SetOptFit(1111);
0208   gStyle->SetFuncColor(kRed);
0209   //
0210   gStyle->SetLabelSize(0.04,"x,y,z");
0211   gStyle->SetTitleSize(0.05,"x,y,z");
0212   gStyle->SetTitleOffset(0.8,"x,y,z");
0213   gStyle->SetTitleFontSize(0.06);
0214   //
0215   //  gStyle->SetPadLeftMargin(0.10);
0216   //  gStyle->SetPadBottomMargin(0.10);
0217   //
0218   gStyle->SetHistLineWidth(1);
0219   //
0220   gStyle->SetPaintTextFormat("g");
0221   //
0222   gStyle->SetTitleBorderSize(0);
0223   gStyle->SetTitleFillColor(0);
0224   gStyle->SetTitleFont(12,"pad");
0225   gStyle->SetTitleFontSize(0.04);
0226   gStyle->SetTitleX(0.075);
0227   gStyle->SetTitleY(0.950);
0228   //
0229 }
0230