예제 #1
0
//__________________________________________________________________________
void etaDependence_V2Ana()
{
  gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+");
  gStyle->SetOptFit(0);

 //  TFile *f1 = new TFile("inclusive150_jpsi/InclusiveYield/ep21/xopt21_mbFixedIncl/summary/saved_histo.root");
//   const char* nameoutfile[2] = {"",
// 				"ep21_xopt21_mbFixedIncl"
//   };

//   const char* eventPlane[2] = {"",
// 			       "EP: etHF"
//   };

//   TFile *f1 = new TFile("inclusive150_jpsi/InclusiveYield/ep23/xopt21_bit1/summary/saved_histo.root");
//   const char* nameoutfile[2] = {"",
// 				"ep23_xopt21_bit1"
//   };
  
//   const char* eventPlane[2] = {"",
// 			       "EP: etHFm"
//   };

  TFile *f1 = new TFile("inclusive150_jpsi/InclusiveYield/ep22/xopt21_bit2/summary/saved_histo.root");
  const char* nameoutfile[2] = {"",
				"ep22_xopt21_bit2"
  };
  
  const char* eventPlane[2] = {"",
			       "EP: etHFp"
  };


  const int ncentbins = 2;
  const int nrapbins  = 4;
  const int nptbins   = 3; 
  int    cts[ncentbins]  = {10, 60};
  double raps[nrapbins]  = {0.0, 1.2,  1.6,  2.4};
  double pts[nptbins]    = {3.0, 6.5, 40.0};

  const char* signal[4]   = {"","NSig","NPr","NNp"};
  const char* legend[4]   = {"","J/#psi","Prompt J/#psi","Non-prompt J/#psi"};
  int choseSignal         = 1; // 1:inclusive 2:prompt 3:non-prompt
  const char* chosenSignal= signal[choseSignal];

  // options
  bool bDoDebug        = false;
  bool bSavePlots      = true; 
  int centrality_start = 0;
  int centrality_end   = 1;
 
  int pt_start = 0;
  int pt_end   = 2;
  int nPads    = pt_end-pt_start;  

  TGraphErrors *g[10][10][10];
  double pr[10][10][10], ep[10][10][10], chi[10][10][10], ndf[10][10][10];
  double vals[4];
   
  char gTmp[512];
  char tmp0[512],tmp2[512], tmp3[512], tmp4[512], tmp5[512], tmp6[512];
  double vraps1, vraps2, vpts1, vpts2;
  int vcts1, vcts2;
  
  for(int mcent = centrality_start; mcent < centrality_end; mcent++)
    {
      vcts1 = cts[mcent]; 
      vcts2 = cts[mcent+1];
      cout<<"Centrlality bin: "<<vcts1<<"-"<<vcts2<<endl;
      
      for(int iy = 0; iy < 4; iy+=2)
	{
	  vraps1 = raps[iy];
	  vraps2 = raps[iy+1];
	  cout<<"Rapidity bin: "<<vraps1<<"-"<<vraps2<<endl;
	  if (iy==0) {pt_start=1;}
	  else pt_start=0;
	  cout<<"Pt_start = "<<pt_start<<endl;
	  for(int jpt = pt_start; jpt < pt_end; jpt++)
	    {
	      cout<<" producing the TGraphs : "<<mcent<<" "<<iy<<" "<<jpt<<" "<<endl;
	      
	      sprintf(gTmp,"rap%.1f-%.1f_cent%d-%d_pT%.1f-%.1f_%s",vraps1,vraps2,vcts1,vcts2,pts[jpt],pts[jpt+1],chosenSignal);
	      cout<<"TGraph name : "<<gTmp<<endl;
	      TGraphErrors *pgTemp =  (TGraphErrors*)f1->Get(gTmp);
	      g[mcent][iy][jpt]  = pgTemp;
	      if(!g[mcent][iy][jpt]) {cout<<"Warning: No graph found !!!!"<<endl;continue;}
	      cout<<g[mcent][iy][jpt]<<endl;
	      double b[4];
	      GetV2(g[mcent][iy][jpt], b);
	      
	      pr[mcent][iy][jpt]  = b[0];
	      ep[mcent][iy][jpt]  = b[1];
	      chi[mcent][iy][jpt] = b[2];
	      ndf[mcent][iy][jpt] = b[3];
	      
	    }//pt bin loop
	}//rapidity loop
    }//centrlaity loop
  
  // #############################  Drawing: 
  TLatex *lt1 = new TLatex();
  lt1->SetNDC();
  
  for(int mcent = centrality_start; mcent < centrality_end; mcent++)
    {
      vcts1  = cts[mcent]; 
      vcts2  = cts[mcent+1];
      cout<<"Canvas Centrality: "<<vcts1<<"-"<<vcts2<<endl;

      TCanvas *pc1 = new TCanvas("pc1",Form("pcV2_%d-%d",vcts1,vcts2),0,0,1200,750);
      TH1F    *pp  = new TH1F("pp",
			      Form(";|#phi_{J/#psi} - #Psi_{RP}|;#frac{1}{N_{total J/#psi}} #frac{dN}{d#phi}"),
			      4,0,TMath::PiOver2());
      pp->SetMaximum(1.2);
      pp->SetMinimum(0.2);
      makeMultiPanelCanvas(pc1,nPads,2,0.0,0.0,0.2,0.15,0.02);
           
      int ind = 0;
      for(int ky = 0; ky < 4; ky+=2)
	{
	  vraps1 = raps[ky];
	  vraps2 = raps[ky+1];
	  cout << "Canvas Rapidity = "<< vraps1 << "\t"<<vraps2<<endl;
	  //	  if (ky==0) pt_start=1;
	  for(int lpt = pt_start; lpt < pt_end; lpt++)
	    {
	      pc1->cd(ind+1);
	      vpts1 = pts[lpt]; 
	      vpts2 = pts[lpt+1];
	      pp->Draw();
	      ind++;
	      	      
	      lt1->SetTextSize(0.05);
	      if(ind == 1) 
		{
		  lt1->DrawLatex(0.75,0.8,Form("|y| < %.1f",vraps2));       // rapidity
		  lt1->DrawLatex(0.25,0.3,Form("%d - %d %%",vcts1, vcts2));
		  lt1->DrawLatex(0.25,0.15,Form("%s",eventPlane[1]));
		}
	      if(ind == 3) 
		{
		  lt1->DrawLatex(0.75,0.8,Form("%.1f < |y| < %.1f",vraps1,vraps2));       // rapidity	
		}
	      if(!g[mcent][ky][lpt]) 
		{
		  cout<<"No graph! continued !!!!"<<endl;
		  continue;
		}
	      cout<<"#### Drawing: cent:"<<vcts1<<"-"<<vcts2<<"\t rapidity"<<vraps1<<"-"<<vraps2<<"\t pt"<<vpts1<<"-"<<vpts2<<endl;
	      g[mcent][ky][lpt]->Draw("pz");
	      if(ind<3)
		{// drapwing v2 value and pt
		  lt1->DrawLatex(0.1,0.15,Form("v_{2}: %.4f #pm %.4f (#chi^{2} / ndof: %.3f / %.0f)", pr[mcent][ky][lpt], ep[mcent][ky][lpt], chi[mcent][ky][lpt], ndf[mcent][ky][lpt]));
		  lt1->DrawLatex(0.1,0.07,Form("%.1f < p_{T} <%.1f", vpts1, vpts2)); 
		} else if(ind==4) 
		{
		  lt1->DrawLatex(0.1,0.3,Form("v_{2}: %.4f #pm %.4f (#chi^{2} / ndof: %.3f / %.0f)", pr[mcent][ky][lpt], ep[mcent][ky][lpt], chi[mcent][ky][lpt], ndf[mcent][ky][lpt]));
		  lt1->DrawLatex(0.1,0.22,Form("%.1f < p_{T} <%.1f", vpts1, vpts2)); 
		} else 
		{
		  lt1->DrawLatex(0.25,0.3,Form("v_{2}: %.4f #pm %.4f (#chi^{2} / ndof: %.3f / %.0f)", pr[mcent][ky][lpt], ep[mcent][ky][lpt], chi[mcent][ky][lpt], ndf[mcent][ky][lpt]));
		  lt1->DrawLatex(0.25,0.22,Form("%.1f < p_{T} <%.1f", vpts1, vpts2));
		}
	    }// pt loop
	}//y bin loop
  
     //_______ stuff to write
  pc1->cd(1);
  TLatex *tex1 = new TLatex(0.25,0.95,"CMS Preliminary");
  tex1->SetNDC();
  tex1->SetTextAlign(13);
  tex1->SetTextFont(43);
  tex1->SetTextSize(23);
  tex1->SetLineWidth(1);
  tex1->Draw();

  TLatex *tex2 = new TLatex(0.25,0.89,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  tex2->SetNDC();
  tex2->SetTextAlign(13);
  tex2->SetTextFont(43);
  tex2->SetTextSize(18);
  tex2->SetLineWidth(2);
  tex2->Draw();

  TLatex *tex3 = new TLatex(0.25,0.83,"L_{int} = 150 #mub^{-1}");
  tex3->SetNDC();
  tex3->SetTextAlign(13);
  tex3->SetTextFont(43);
  tex3->SetTextSize(18);
  tex3->SetLineWidth(2);
  tex3->Draw();

  lt1->DrawLatex(0.75,0.25,Form("%s",legend[choseSignal]));  // what signal is
  if(bSavePlots)
    {
      pc1->SaveAs(Form("%s_%s_Jpsi_%d_%d_150mub.png",chosenSignal,nameoutfile[1],vcts1,vcts2));
      pc1->SaveAs(Form("%s_%s_Jpsi_%d_%d_150mub.pdf",chosenSignal,nameoutfile[1],vcts1,vcts2));
      
      pc1->Clear();
    }
    }// centrality loop

  //_______________ SUMMARY!!!!
  TCanvas *c2 = new TCanvas("c2","c2");
  // makeMultiPanelCanvas(c2,1,1,0.0,0.0,0.2,0.15,0.02);
  
  double ptBinsFwd[2]      = {4.75, 23.5};
  double ptErrsFwd[3]      = {0.0, 0.0};
  double ptBinsBar[2]      = {23.5};
  double ptErrsBar[2]      = {0.0};

  TH1F *hPad2 = new TH1F("hPad2",";p_{T};Uncorrected v2;",1,0,40);
  hPad2->SetMaximum(0.3);
  hPad2->SetMinimum(-0.3);
  TLegend *leg1 = new TLegend(0.2,0.75,0.45,0.9);
  leg1->SetFillColor(0);
  c2->cd(1);
      
  // [centrality][rapidity][pt]
  double v2PtBarr[1]    = {pr[0][0][1]};
  double v2PtBarrErr[1] = {ep[0][0][1]};

  double v2PtForw[2]    = {pr[0][2][0], pr[0][2][1]};  
  double v2PtForwErr[2] = {ep[0][2][0], ep[0][2][1]};
  
  TGraphErrors *gPtBarr = new TGraphErrors(1, ptBinsBar, v2PtBarr, ptErrsBar, v2PtBarrErr);  
  TGraphErrors *gPtForw = new TGraphErrors(2, ptBinsFwd, v2PtForw, ptErrsFwd, v2PtForwErr);  
  gPtBarr->SetMarkerStyle(20);
  gPtBarr->SetMarkerSize(1.2);
  gPtBarr->SetMarkerColor(kBlue+2);
  
  gPtForw->SetMarkerStyle(21);
  gPtForw->SetMarkerSize(1.2);
  gPtForw->SetMarkerColor(kRed+2);
  
  hPad2->Draw();
  gPtBarr->Draw("p");
  gPtForw->Draw("p");
  c2->Update();
 
  leg1->AddEntry(gPtBarr,"|y| < 1.2","P");
  leg1->AddEntry(gPtForw,"1.6 < |y| < 2.4","P");
  lt1->DrawLatex(0.7,0.15,Form("%s",eventPlane[1]));
  lt1->SetTextSize(0.06);
  lt1->DrawLatex(0.7,0.25,Form("%d - %d %%",cts[0],cts[1]));


  //_______ stuff to write
  leg1->Draw("same");
 TLatex *tex4 = new TLatex(0.65,0.93,"CMS Preliminary");
  tex4->SetNDC();
  tex4->SetTextAlign(13);
  tex4->SetTextFont(43);
  tex4->SetTextSize(23);
  tex4->SetLineWidth(1);
  tex4->Draw();

  TLatex *tex5 = new TLatex(0.65,0.87,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  tex5->SetNDC();
  tex5->SetTextAlign(13);
  tex5->SetTextFont(43);
  tex5->SetTextSize(18);
  tex5->SetLineWidth(2);
  tex5->Draw();

  TLatex *tex6 = new TLatex(0.65,0.81,"L_{int} = 150 #mub^{-1}");
  tex6->SetNDC();
  tex6->SetTextAlign(13);
  tex6->SetTextFont(43);
  tex6->SetTextSize(18);
  tex6->SetLineWidth(2);
  tex6->Draw();
  lt1->DrawLatex(0.8,0.6,Form("%s",legend[choseSignal]));  // what signal is
  c2->Update();
  if(bSavePlots)
    {
      c2->SaveAs(Form("%s_jpsi_%s_v2_y.png",chosenSignal,nameoutfile[1]));
      c2->SaveAs(Form("%s_jpsi_%s_v2_y.pdf",chosenSignal,nameoutfile[1]));
    }
 
}
예제 #2
0
파일: extractK.C 프로젝트: cmstas/ZMet2012
void extractK( bool exclusive , bool printplot , bool bveto ){

  //char* iter = (char*) "V00-01-04";
  char* iter = (char*) "V00-02-00";

  //char* suffix = "";
  char* suffix = "_2jets";

  TChain *data = new TChain("T1");
  //data->Add(Form("../output/%s/data_ALL_53X_baby%s.root",iter,suffix));
  //data->Add(Form("../output/%s/data_53X_baby%s.root",iter,suffix));
  //data->Add(Form("../output/%s/data_2012C_53X_baby%s.root",iter,suffix));

  data->Add(Form("../output/%s/data_53X_2012A_baby%s.root",iter,suffix));
  data->Add(Form("../output/%s/data_53X_2012B_baby%s.root",iter,suffix));
  data->Add(Form("../output/%s/data_53X_2012C_baby%s.root",iter,suffix));
  data->Add(Form("../output/%s/data_53X_2012D_baby%s.root",iter,suffix));

  TChain *mc = new TChain("T1");
  mc->Add(Form("../output/%s/ttbar_53X_baby%s.root"       ,iter,suffix));
  //mc->Add(Form("../output/%s/zjets_full_53X_baby%s.root"  ,iter,suffix));
  mc->Add(Form("../output/%s/zjets_53X_baby%s.root"  ,iter,suffix));
  mc->Add(Form("../output/%s/ww_53X_baby%s.root"          ,iter,suffix));
  mc->Add(Form("../output/%s/wz_53X_baby%s.root"          ,iter,suffix));
  mc->Add(Form("../output/%s/zz_53X_baby%s.root"          ,iter,suffix));
  mc->Add(Form("../output/%s/t_53X_baby%s.root"           ,iter,suffix));
  mc->Add(Form("../output/%s/ttZ_53X_baby%s.root"         ,iter,suffix));
  mc->Add(Form("../output/%s/ttW_53X_baby%s.root"         ,iter,suffix));
  mc->Add(Form("../output/%s/VVV_53X_baby%s.root"         ,iter,suffix));

  //mc->Add(Form("../output/%s/ttbar_baby%s.root",iter,suffix));
  //mc->Add(Form("../output/%s/zjets_baby%s.root",iter,suffix));
  //mc->Add(Form("../output/%s/ww_baby%s.root",iter,suffix));
  //mc->Add(Form("../output/%s/t_baby%s.root",iter,suffix));

  TCut pfleptons("pflep1.pt() > 20 && pflep2.pt() > 20");
  TCut transveto("el1tv==0 && el2tv==0");
  TCut Zmass("dilmasspf>81 && dilmasspf<101");
  TCut njets2("njets>=2");
  TCut em("leptype==2");
  TCut nb0("nbcsvm==0");
  TCut mjj("mjj>70.0 && mjj<110.0");
  TCut nlep2("nlep==2");
  TCut pt40cuts("njets40>=2");
  TCut pt2010("lep1.pt()>20 && lep2.pt()>10");
  TCut pt2020("lep1.pt()>20 && lep2.pt()>20");
  TCut filters("csc==0 && hbhe==1 && hcallaser==1 && ecaltp==1 && trkfail==1 && eebadsc==1 && hbhenew==1");
  TCut runrange("isdata==0 || (run<197556 || run>198913)");

  TCut sel;
  sel += em;
  sel += filters;
  sel += runrange;
  //sel += transveto;
  
  if( pt40 ){
    //sel += pt40cuts;
    sel += "njets40>=3";
    sel += pt2020;
  }

  else{
    sel += njets2;
    //sel += pfleptons;
    sel += pt2020;
  }

  if( bveto ){
    sel += nb0;
    //sel += mjj;
    //sel += nlep2;
  }

  TCut weight("vtxweight * weight");
  //TCut weight("1");

  cout << "Using selection : " << sel.GetTitle() << endl;
  cout << "Using weight    : " << weight.GetTitle() << endl;

  cout << "OF entries (total)  " << data->GetEntries(sel+em) << endl;
  cout << "OF entries (Z mass) " << data->GetEntries(sel+Zmass+em) << endl;
  cout << "K                   " << (float) data->GetEntries(sel+Zmass+em) / (float) data->GetEntries(sel+em) << endl;

  int mynbins = 6;
  if( bveto ) mynbins = 7;

  const unsigned int nbins = mynbins;

  TCut metcuts[nbins];

  if( bveto ){
    if( exclusive ){
      metcuts[0] = TCut("pfmet>0   && pfmet<30" );
      metcuts[1] = TCut("pfmet>30  && pfmet<60" );
      metcuts[2] = TCut("pfmet>60  && pfmet<80" );
      metcuts[3] = TCut("pfmet>80  && pfmet<100");
      metcuts[4] = TCut("pfmet>100 && pfmet<150");
      metcuts[5] = TCut("pfmet>150 && pfmet<200");
      metcuts[6] = TCut("pfmet>200");
    }else{
      metcuts[0] = TCut("pfmet>0");
      metcuts[1] = TCut("pfmet>30");
      metcuts[2] = TCut("pfmet>60");
      metcuts[3] = TCut("pfmet>80");
      metcuts[4] = TCut("pfmet>100");
      metcuts[5] = TCut("pfmet>150");
      metcuts[6] = TCut("pfmet>200");

    }
  }

  else{
    if( exclusive ){
      metcuts[0] = TCut("pfmet>0   && pfmet<30" );
      metcuts[1] = TCut("pfmet>30  && pfmet<60" );
      metcuts[2] = TCut("pfmet>60  && pfmet<100");
      metcuts[3] = TCut("pfmet>100 && pfmet<200");
      metcuts[4] = TCut("pfmet>200 && pfmet<300");
      metcuts[5] = TCut("pfmet>300");
    }else{
      metcuts[0] = TCut("pfmet>0");
      metcuts[1] = TCut("pfmet>30");
      metcuts[2] = TCut("pfmet>60");
      metcuts[3] = TCut("pfmet>100");
      metcuts[4] = TCut("pfmet>200");
      metcuts[5] = TCut("pfmet>300");
    }
  }

  float K[nbins];
  float Kerr[nbins];

  float KMC[nbins];
  float KMCerr[nbins];

  TH1F* htot = new TH1F("htot","",1,0,1);
  TH1F* hZ   = new TH1F("hZ"  ,"",1,0,1);
  htot->Sumw2();
  hZ->Sumw2();

  for( int i = 0 ; i < nbins ; ++i ){
    float tot = (float) data->GetEntries(sel+em+metcuts[i]);
    float   Z = (float) data->GetEntries(sel+em+metcuts[i]+Zmass);
    
    K[i]    = Z/tot;
    Kerr[i] = sqrt(Z)/tot;

    // float totMC = (float) mc->GetEntries(sel+em+metcuts[i]);
    // float   ZMC = (float) mc->GetEntries(sel+em+metcuts[i]+Zmass);
    
    // KMC[i]    = ZMC/totMC;
    // KMCerr[i] = sqrt(ZMC)/totMC;

    mc->Draw("0.5>>htot" , (sel+em+metcuts[i]      ) * weight );
    mc->Draw("0.5>>hZ"   , (sel+em+metcuts[i]+Zmass) * weight );

    float   totMC     = htot->GetBinContent(1);
    float   ZMC       = hZ->GetBinContent(1);
    float   totMCerr  = htot->GetBinError(1);
    float   ZMCerr    = hZ->GetBinError(1);

    KMC[i]    = ZMC    / totMC;
    //KMCerr[i] = ZMCerr / totMC;
    KMCerr[i] = KMC[i] * sqrt(pow( totMCerr/totMC , 2 ) + pow( ZMCerr/ZMC , 2 ) );

    cout << endl;
    cout << "--------------------------------------------------------------" << endl;
    cout << metcuts[i].GetTitle() << endl << endl;
    cout << "data  : " << endl;
    cout << "total : " << tot << endl;
    cout << "Z     : " <<   Z << endl;
    cout << "K     : " << Form("%.2f +/- %.3f",K[i],Kerr[i]) << endl << endl;
    cout << "MC    : " << endl;
    cout << "total : " << totMC << endl;
    cout << "Z     : " <<   ZMC << endl;
    cout << "K     : " << Form("%.2f +/- %.3f",KMC[i],KMCerr[i]) << endl;
    cout << "--------------------------------------------------------------" << endl;
    cout << endl;
  }

  float x[nbins];
  float xerr[nbins];
  
  for(int i = 0 ; i < nbins ; ++i ){
    x[i]    = i+1;
    xerr[i] = 0;
  }

  TCanvas *c1 = new TCanvas();
  c1->cd();
  gPad->SetGridy();

  TH2F* hdummy = new TH2F("hdummy","",nbins,0.5,nbins+0.5,10,0,0.2);
  hdummy->Draw();
  hdummy->GetXaxis()->SetTitle("E_{T}^{miss} [GeV]");
  hdummy->GetYaxis()->SetTitle("K");
  if( bveto ){
    if( exclusive ){
      hdummy->GetXaxis()->SetBinLabel(1,"0-30");
      hdummy->GetXaxis()->SetBinLabel(2,"30-60");
      hdummy->GetXaxis()->SetBinLabel(3,"60-80");
      hdummy->GetXaxis()->SetBinLabel(4,"80-100");
      hdummy->GetXaxis()->SetBinLabel(5,"100-150");
      hdummy->GetXaxis()->SetBinLabel(6,"150-200");
      hdummy->GetXaxis()->SetBinLabel(7,">200");
    }
    else{
      hdummy->GetXaxis()->SetBinLabel(1,">0");
      hdummy->GetXaxis()->SetBinLabel(2,">30");
      hdummy->GetXaxis()->SetBinLabel(3,">60");
      hdummy->GetXaxis()->SetBinLabel(4,">80");
      hdummy->GetXaxis()->SetBinLabel(5,">100");
      hdummy->GetXaxis()->SetBinLabel(6,">150");
      hdummy->GetXaxis()->SetBinLabel(7,">200");
    }
  }
  else{
    if( exclusive ){
      hdummy->GetXaxis()->SetBinLabel(1,"0-30");
      hdummy->GetXaxis()->SetBinLabel(2,"30-60");
      hdummy->GetXaxis()->SetBinLabel(3,"60-100");
      hdummy->GetXaxis()->SetBinLabel(4,"100-200");
      hdummy->GetXaxis()->SetBinLabel(5,"200-300");
      hdummy->GetXaxis()->SetBinLabel(6,">300");
    }
    else{
      hdummy->GetXaxis()->SetBinLabel(1,">0");
      hdummy->GetXaxis()->SetBinLabel(2,">30");
      hdummy->GetXaxis()->SetBinLabel(3,">60");
      hdummy->GetXaxis()->SetBinLabel(4,">100");
      hdummy->GetXaxis()->SetBinLabel(5,">200");
      hdummy->GetXaxis()->SetBinLabel(6,">300");
    }
  }

  TGraphErrors *gr   = new TGraphErrors(nbins,x,K,xerr,Kerr);
  TGraphErrors *grMC = new TGraphErrors(nbins,x,KMC,xerr,KMCerr);
  gr->GetXaxis()->SetTitle("E_{T}^{miss} bin");
  gr->GetYaxis()->SetTitle("K");
  gr->SetMaximum(0.2);
  grMC->SetLineColor(2);
  grMC->SetMarkerColor(2);
  grMC->SetMarkerStyle(25);

  gr->Draw("sameP");
  grMC->Draw("sameP");

  TLegend* leg = new TLegend(0.2,0.2,0.4,0.4);
  leg->AddEntry(gr,"data","lp");
  leg->AddEntry(grMC,"MC","lp");
  leg->SetFillColor(0);
  leg->SetBorderSize(1);
  leg->Draw();

  if( printplot ){

    if( bveto ){
      if(exclusive ) c1->Print("../plots/extractK_exclusive_bveto.pdf");
      else           c1->Print("../plots/extractK_inclusive_bveto.pdf");
    }

    else{
      if(exclusive ) c1->Print("../plots/extractK_exclusive.pdf");
      else           c1->Print("../plots/extractK_inclusive.pdf");
    }

  }

}
예제 #3
0
파일: compare_y.C 프로젝트: goni/Dimuons
void compare_y(bool bSavePlots       = true,
               bool bDoDebug         = 1, // adds some numbers, numerator, denominator, to help figure out if things are read properly
               int whichCompare      = 1,//0: no TnP corrections; 1: w/ TnP corr on Data; 2: w/ TnP corr on MC; 3: lxy w/ TnP on MC
               const char* inputDir  = "../readFitTable", // the place where the input root files, with the histograms are
               const char* outputDir = "figs/compare")// where the output figures will be
{
  gSystem->mkdir(Form("./%s/png",outputDir), kTRUE);
  gSystem->mkdir(Form("./%s/pdf",outputDir), kTRUE);

  // set the style
  setTDRStyle();

 // type of available comparisons:
  const char* compWhat[4] = {"noTnP","dataTnP","mcTnP","lxyTnP"};

  const int nInHist = 3;
  const char* yieldHistNames[nInHist] = {"y", "y_mb", "mb"};

  //-----------------------------------------
  // input files: are in the filesRaa_2015.h


 // open the files with yields and do the math
  TFile *fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[0]));
  TFile *fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[1]));
  
  TFile *fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[0]));
  TFile *fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[1]));

  TFile *fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile[0]));
  TFile *fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile[1]));

  switch(whichCompare){
  case 0:
    cout << "You are making Raa, with NOT TnP corrections whatsoever!"<<endl;
    fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[0]));
    fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[1]));
  
    fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[0]));
    fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[1]));

    fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[0]));
    fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[1]));
    break;

  case 2:
    cout << "You are making Raa, with TnP corrections applied on MC!"<<endl;
    fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[0]));
    fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[1]));
  
    fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[0]));
    fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[1]));
    break;

  case 3: 
    cout << "You are making Raa, with Lxy and TnP corrections applie on MC!"<<endl;
    fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[0]));
    fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[1]));
  
    fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[0]));
    fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[1]));
    break;

  case 1:
  default:
    cout<<" You are doing Raa Nominal: TnP on data!"<<endl;
    break;
  }
 
  if (!fYesWeighFile_aa->IsOpen() || !fYesWeighFile_pp->IsOpen()|| !fNoWeighFile_aa->IsOpen() || !fNoWeighFile_pp->IsOpen() || !fEffFile_aa->IsOpen() || !fEffFile_pp->IsOpen()) {
    cout << "One or more input files are missing" << endl;
    return ;
  }

  TH1F *phRaw_pr_pp; 
  TH1F *phCorr_pr_pp;
  TH1F *phEff_pr_pp;
  TH1F *phRaw_pr_aa; 
  TH1F *phCorr_pr_aa;
  TH1F *phEff_pr_aa;

  TH1F *phRaw_npr_pp; 
  TH1F *phCorr_npr_pp;
  TH1F *phEff_npr_pp;
  TH1F *phRaw_npr_aa; 
  TH1F *phCorr_npr_aa;
  TH1F *phEff_npr_aa;

 // to store the ratio of ev-by-ev  and traditionally corrected yields in each case
  TH1F *ahRatio_pr_pp[nInHist];
  TH1F *ahRatio_npr_pp[nInHist];
  TH1F *ahRatio_pr_aa[nInHist];
  TH1F *ahRatio_npr_aa[nInHist];

  
  for(int ih=0; ih<nInHist;ih++) // for each kinematic range
  {
    TString hist_pr(Form("phPrp_%s",yieldHistNames[ih]));
    TString hist_npr(Form("phNPrp_%s",yieldHistNames[ih]));
    
    cout<<"histogram input name: "<< hist_pr<<"\t"<<hist_npr<<endl; 

    // prompt histos
    phRaw_pr_pp  = (TH1F*)fNoWeighFile_pp->Get(hist_pr);
    phCorr_pr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_pr);
    phRaw_pr_aa  = (TH1F*)fNoWeighFile_aa->Get(hist_pr);
    phCorr_pr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_pr);
    
    // non-prompt histos
    phRaw_npr_pp  = (TH1F*)fNoWeighFile_pp->Get(hist_npr);
    phCorr_npr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_npr);
    phRaw_npr_aa  = (TH1F*)fNoWeighFile_aa->Get(hist_npr);
    phCorr_npr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_npr);

    // efficiency histos
    phEff_pr_pp  = (TH1F*)fEffFile_pp->Get(hist_pr);
    phEff_npr_pp = (TH1F*)fEffFile_pp->Get(hist_npr);
    phEff_pr_aa  = (TH1F*)fEffFile_aa->Get(hist_pr);
    phEff_npr_aa = (TH1F*)fEffFile_aa->Get(hist_npr);

 //---------------  corrected yields in the traditional way (simple division for the moment)
    // store the yield_Ratio histos:  ev_by_ev/(raw*eff), 
    ahRatio_pr_pp[ih]  = (TH1F *)phCorr_pr_pp->Clone();
    ahRatio_pr_pp[ih]->SetDirectory(0);
    ahRatio_pr_pp[ih]->Divide(phRaw_pr_pp);
    ahRatio_pr_pp[ih]->Multiply(phEff_pr_pp);// correct the raw with it's efficiency

    ahRatio_npr_pp[ih]  = (TH1F *)phCorr_npr_pp->Clone();
    ahRatio_npr_pp[ih]->SetDirectory(0);
    ahRatio_npr_pp[ih]->Divide(phRaw_npr_pp);
    ahRatio_npr_pp[ih]->Multiply(phEff_npr_pp);

    ahRatio_pr_aa[ih]  = (TH1F *)phCorr_pr_aa->Clone();
    ahRatio_pr_aa[ih]->SetDirectory(0);
    ahRatio_pr_aa[ih]->Divide(phRaw_pr_aa);
    ahRatio_pr_aa[ih]->Multiply(phEff_pr_aa);

    ahRatio_npr_aa[ih]  = (TH1F *)phCorr_npr_aa->Clone();
    ahRatio_npr_aa[ih]->SetDirectory(0);
    ahRatio_npr_aa[ih]->Divide(phRaw_npr_aa);
    ahRatio_npr_aa[ih]->Multiply(phEff_npr_aa);

    double scaleFactor = ppLumi/nMbEvents;
    double scale_cent = 1/(adTaaMB[0]*adDeltaCentMB[0]);
  
    int numBins = 0;
    if(ih==0) numBins = nBinsY;
    if(ih==1) numBins = nBinsY3;
    if(ih==2) numBins = nBinsMB;

    cout << "Number of bins: " << numBins<<endl;

    for(int ibin=1; ibin<=numBins; ibin++)
    {
      double raa_pr=0, raaErr_pr=0, raa_npr=0, raaErr_npr=0;
      double raaTrad_pr=0, raaTradErr_pr=0, raaTrad_npr=0, raaTradErr_npr=0;

      //prompt
      double dRelErrRaw_pr_pp  = phRaw_pr_pp->GetBinError(ibin)/phRaw_pr_pp->GetBinContent(ibin);
      double dRelErrRaw_pr_aa  = phRaw_pr_aa->GetBinError(ibin)/phRaw_pr_aa->GetBinContent(ibin);
    
      double yieldRatio_pr     = phCorr_pr_aa->GetBinContent(ibin)/phCorr_pr_pp->GetBinContent(ibin);
      
      double yieldRatioTrad_pr = (phRaw_pr_aa->GetBinContent(ibin)/phRaw_pr_pp->GetBinContent(ibin))
        * (phEff_pr_pp->GetBinContent(ibin)/phEff_pr_aa->GetBinContent(ibin));

      raa_pr      =  yieldRatio_pr * scaleFactor * scale_cent;
      raaErr_pr   = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raa_pr;

      raaTrad_pr      =  yieldRatioTrad_pr * scaleFactor * scale_cent;
      raaTradErr_pr   = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raaTrad_pr;

      //non-prompt
      // get the rel uncert from the raw sample
      double dRelErrRaw_npr_pp  = phRaw_npr_pp->GetBinError(ibin)/phRaw_npr_pp->GetBinContent(ibin);
      double dRelErrRaw_npr_aa  = phRaw_npr_aa->GetBinError(ibin)/phRaw_npr_aa->GetBinContent(ibin);
      double yieldRatio_npr     = phCorr_npr_aa->GetBinContent(ibin)/phCorr_npr_pp->GetBinContent(ibin);
      double yieldRatioTrad_npr = phRaw_npr_aa->GetBinContent(ibin)/phRaw_npr_pp->GetBinContent(ibin)
          * (phEff_npr_pp->GetBinContent(ibin)/phEff_npr_aa->GetBinContent(ibin));

      raa_npr    = yieldRatio_npr * scaleFactor * scale_cent;
      raaErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raa_npr;

      raaTrad_npr= yieldRatioTrad_npr * scaleFactor * scale_cent;
      raaTradErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raaTrad_npr;

     
      // fill the corresponding array
      switch(ih){
      case 0:
        prJpsi_y[ibin-1]       = raa_pr;
        prJpsiErr_y[ibin-1]    = raaErr_pr;
        nonPrJpsi_y[ibin-1]    = raa_npr;
        nonPrJpsiErr_y[ibin-1] = raaErr_npr;

        prJpsiTrad_y[ibin-1]       = raaTrad_pr;
        prJpsiTradErr_y[ibin-1]    = raaTradErr_pr;              
        nonPrJpsiTrad_y[ibin-1]    = raaTrad_npr;
        nonPrJpsiTradErr_y[ibin-1] = raaTradErr_npr;

        if(bDoDebug)
        {
          cout<<"yield_pr_aa "<<phCorr_pr_aa->GetBinContent(ibin)<<"\t yield_pr_pp "<<phCorr_pr_pp->GetBinContent(ibin)<<endl;
          cout<<"yield_npr_aa "<<phCorr_npr_aa->GetBinContent(ibin)<<"\t yield_npr_pp "<<phCorr_npr_pp->GetBinContent(ibin)<<endl;
          cout<<"!!!!! raa_pr = "<<raa_pr<<"\t raa_npr= "<<raa_npr<<endl;
        }
        break;
   
      case 1:
        prJpsi_y_y[ibin-1]        = raa_pr;
        prJpsiErr_y_y[ibin-1]     = raaErr_pr;
        nonPrJpsi_y_y[ibin-1]     = raa_npr;
        nonPrJpsiErr_y_y[ibin-1]  = raaErr_npr;

        prJpsiTrad_y_y[ibin-1]        = raaTrad_pr;
        prJpsiTradErr_y_y[ibin-1]     = raaTradErr_pr;
        nonPrJpsiTrad_y_y[ibin-1]     = raaTrad_npr;
        nonPrJpsiTradErr_y_y[ibin-1]  = raaTradErr_npr;

        if(bDoDebug)
        {
          cout<<"yield_npr_aa "<<phCorr_npr_aa->GetBinContent(ibin)<<"\t yield_pr_pp "<<phCorr_npr_pp->GetBinContent(ibin)<<endl;
          cout<<setprecision(2);
          cout<<"!!!!! raa_pr = "<<raa_pr<<"\t raa_npr= "<<raa_npr<<endl;
        }
        break;

      case 2:
        // mb
        prJpsi_mb[0]         = raa_pr;
        prJpsiErr_mb[0]      = raaErr_pr;       
        nonPrJpsi_mb[0]      = raa_npr;
        nonPrJpsiErr_mb[0]      = raaErr_npr;

        prJpsiTrad_mb[0]     = raaTrad_pr;
        prJpsiTradErr_mb[0]  = raaTradErr_pr;       
        nonPrJpsiTrad_mb[0]  = raaTrad_npr;
        nonPrJpsiTradErr_mb[0]  = raaTradErr_npr;


        break;
      }
    }//loop end: for(int ibin=1; ibin<=numBins; ibin++)
  }//loop end: for(int ih=0; ih<nInHist;ih++)

  // ***** //Drawing
  // pr
  TGraphErrors *gPrJpsi     = new TGraphErrors(nBinsY, binsY, prJpsi_y, binsYErr, prJpsiErr_y);
  TGraphErrors *gPrJpsi_mb  = new TGraphErrors(nBinsMB, binsYMB, prJpsi_mb, binsYMBErr, prJpsiErr_mb);
  TGraphErrors *gPrJpsi_y_y = new TGraphErrors(nBinsY3, binsY3, prJpsi_y_y, binsY3Err, prJpsiErr_y_y);
 
  // nonPr   
  TGraphErrors *gNonPrJpsi    = new TGraphErrors(nBinsY, binsY, nonPrJpsi_y, binsYErr, nonPrJpsiErr_y);
  TGraphErrors *gNonPrJpsi_mb = new TGraphErrors(nBinsMB, binsYMB, nonPrJpsi_mb, binsYMBErr, nonPrJpsiErr_mb);
  TGraphErrors *gNonPrJpsi_y_y= new TGraphErrors(nBinsY3, binsY3, nonPrJpsi_y_y, binsY3Err, nonPrJpsiErr_y_y);

  //------------ trad
// pr
  TGraphErrors *gPrJpsiTrad    = new TGraphErrors(nBinsY, binsY, prJpsiTrad_y, binsYErr, prJpsiTradErr_y);
  TGraphErrors *gPrJpsiTrad_mb = new TGraphErrors(nBinsMB, binsYMB, prJpsiTrad_mb, binsYMBErr, prJpsiTradErr_mb);
  TGraphErrors *gPrJpsiTrad_y_y= new TGraphErrors(nBinsY3, binsY3, prJpsiTrad_y_y, binsY3Err, prJpsiTradErr_y_y);
 
  // nonPr   
  TGraphErrors *gNonPrJpsiTrad    = new TGraphErrors(nBinsY, binsY, nonPrJpsiTrad_y, binsYErr, nonPrJpsiTradErr_y);
  TGraphErrors *gNonPrJpsiTrad_mb = new TGraphErrors(nBinsMB, binsYMB, nonPrJpsiTrad_mb, binsYMBErr, nonPrJpsiTradErr_mb);
  TGraphErrors *gNonPrJpsiTrad_y_y= new TGraphErrors(nBinsY3, binsY3, nonPrJpsiTrad_y_y, binsY3Err, nonPrJpsiTradErr_y_y);

  //-------------------------------------------------------------------
  // **************** marker colors
  gPrJpsi->SetMarkerColor(kRed);
  gNonPrJpsi->SetMarkerColor(kOrange+2);

  //mnbias colors
  gPrJpsi_mb->SetMarkerColor(kCyan+2);
  gNonPrJpsi_mb->SetMarkerColor(kCyan+2);

  gPrJpsi_y_y->SetMarkerColor(kBlue-4);
  gNonPrJpsi_y_y->SetMarkerColor(kBlue-4);

  //--------- marker style  
  gPrJpsi->SetMarkerStyle(21);
  gPrJpsi_y_y->SetMarkerStyle(34);
  gNonPrJpsi->SetMarkerStyle(29);
  gNonPrJpsi_y_y->SetMarkerStyle(34);

  //mb
  gPrJpsi_mb->SetMarkerStyle(33);
  gNonPrJpsi_mb->SetMarkerStyle(33);
  
  // marker size
  gPrJpsi->SetMarkerSize(1.2);
  gPrJpsi_y_y->SetMarkerSize(1.7);
  gNonPrJpsi->SetMarkerSize(1.7);
  gNonPrJpsi_y_y->SetMarkerSize(1.7);

  //mb
  gPrJpsi_mb->SetMarkerSize(1.5);
  gNonPrJpsi_mb->SetMarkerSize(1.5);


  //--------------- traditional stuff
  gPrJpsiTrad->SetMarkerStyle(25);
  gPrJpsiTrad_y_y->SetMarkerStyle(28);
  gNonPrJpsiTrad->SetMarkerStyle(30);
  gNonPrJpsiTrad_y_y->SetMarkerStyle(28);

  //mb
  gPrJpsiTrad_mb->SetMarkerStyle(27);
  gNonPrJpsiTrad_mb->SetMarkerStyle(27);
  
  // marker size
  gPrJpsiTrad->SetMarkerSize(1.2);
  gPrJpsiTrad_y_y->SetMarkerSize(1.7);
  gNonPrJpsiTrad->SetMarkerSize(1.7);
  gNonPrJpsiTrad_y_y->SetMarkerSize(1.7);

  //mb
  gPrJpsiTrad_mb->SetMarkerSize(1.5);
  gNonPrJpsiTrad_mb->SetMarkerSize(1.5);

 // same for the raa denominator and nominator yields histograms
  for(int ih=0; ih<nInHist;ih++) // for each kinematic range
  {
    ahRatio_pr_pp[ih]->SetMarkerStyle(20);
    ahRatio_npr_pp[ih]->SetMarkerStyle(20);
    ahRatio_pr_aa[ih]->SetMarkerStyle(20);
    ahRatio_npr_aa[ih]->SetMarkerStyle(20);
    if(ih==2)
      {
        ahRatio_pr_pp[ih]->SetMarkerColor(kCyan+2);
        ahRatio_npr_pp[ih]->SetMarkerColor(kCyan+2);
        ahRatio_pr_aa[ih]->SetMarkerColor(kCyan+2);
        ahRatio_npr_aa[ih]->SetMarkerColor(kCyan+2);
      }
  }


  //-------------------------------------------
  TF1 *f4 = new TF1("f4","1",0,2.4);
  f4->SetLineWidth(1);
  f4->GetXaxis()->SetTitle("|y|");
  f4->GetXaxis()->SetNdivisions(-6);
  f4->GetYaxis()->SetTitle("R_{AA}");
  f4->GetYaxis()->SetRangeUser(0.0,1.5);
  f4->GetXaxis()->CenterTitle(kTRUE);

  //---------------- general stuff
  TLatex *lcent = new TLatex(1.1,1.03,"Cent. 0-100%");
  lcent->SetTextFont(42);
  lcent->SetTextSize(0.05);

  TLatex *lpt = new TLatex(1.1,0.9,"6.5 < p_{T} < 30 GeV/c");
  lpt->SetTextFont(42);
  lpt->SetTextSize(0.05);

  TLatex *lPr = new TLatex(0.2,1.35,"Prompt J/#psi");
  lPr->SetTextFont(42);
  lPr->SetTextSize(0.05);

  TLatex *lNpr = new TLatex(0.2,1.35,"Non-prompt J/#psi");
  lNpr->SetTextFont(42);
  lNpr->SetTextSize(0.05);

 //  -----------------------for comparison purposes
  // axis for the yields
  TF1 *fBin = new TF1("fBin","1",0,8);
  fBin->SetLineWidth(1);
  fBin->GetXaxis()->SetTitle("Bin number");
  fBin->GetYaxis()->SetTitle("Yield ratio");
  fBin->GetYaxis()->SetRangeUser(0.5,2);
  fBin->GetXaxis()->CenterTitle(kTRUE);

  TLatex *lRatio = new TLatex(0.5,1.7,"Yield: Ev-by-Ev/Trad. correction");
  lRatio->SetTextFont(42);
  lRatio->SetTextSize(0.05);

  TLatex *lPP = new TLatex(0.5,1.8,"[email protected]");
  lPP->SetTextFont(42);
  lPP->SetTextSize(0.05);

  TLatex *lAA = new TLatex(0.5,1.8,"[email protected]");
  lAA->SetTextFont(42);
  lAA->SetTextSize(0.05);



  // ##################################################### pr plots
  TCanvas *c1 = new TCanvas("c1","c1",1200,400);
  c1->Divide(3,1);
  c1->cd(1);
  f4->Draw();// axis
  lPr->Draw();
  lcent->Draw();
  lpt->Draw();

  gPrJpsi->Draw("P");
  gPrJpsiTrad->Draw("P");

  c1->cd(2);
  fBin->Draw();// axis
  gPad->SetGridy();
  lPP->Draw();
  lRatio->Draw();

  ahRatio_pr_pp[0]->Draw("sames");
  
  c1->cd(3);
  fBin->Draw();// axis
  gPad->SetGridy();
  lAA->Draw();
  lRatio->Draw();

  ahRatio_pr_aa[0]->Draw("sames");

  if(bSavePlots)
  {
    c1->SaveAs(Form("%s/pdf/PrJpsi_vsY_%s.pdf",outputDir,compWhat[whichCompare]));
    c1->SaveAs(Form("%s/png/PrJpsi_vsY_%s.png",outputDir,compWhat[whichCompare]));
  }
  
  //-------------------minbias dependence
  TCanvas *c11b = new TCanvas("c11b","c11b",1200,400);
  c11b->Divide(3,1);
  c11b->cd(1);
  f4->Draw();

  lPr->Draw();
  lcent->Draw();
  lpt->Draw();

  gPrJpsi_mb->Draw("P");
  gPrJpsi_y_y->Draw("P");

  gPrJpsiTrad_mb->Draw("P");
  gPrJpsiTrad_y_y->Draw("P");
 
  c11b->cd(2);
  fBin->Draw();
  gPad->SetGridy();
  lPP->Draw();
  lRatio->Draw();

  ahRatio_pr_pp[1]->Draw("sames");
  ahRatio_pr_pp[2]->Draw("sames");

  c11b->cd(3);
  fBin->Draw();
  gPad->SetGridy();
  lAA->Draw();
  lRatio->Draw();
  ahRatio_pr_aa[1]->Draw("sames");
  ahRatio_pr_aa[2]->Draw("sames");

  gPad->RedrawAxis();

  if(bSavePlots)
  {
    c11b->SaveAs(Form("%s/pdf/PrJpsi_vsY_mb_%s.pdf",outputDir,compWhat[whichCompare]));
    c11b->SaveAs(Form("%s/png/PrJpsi_vsY_mb_%s.png",outputDir,compWhat[whichCompare]));
  }

  //  // ############################################## non-pr   
  //  // ############################################## non-pr 
  //  // ############################################## non-pr
  TCanvas *c2 = new TCanvas("c2","c2",1200,400);
  c2->Divide(3,1);
  c2->cd(1);
  f4->Draw();// axis
  lNpr->Draw();
  lcent->Draw();
  lpt->Draw();

  gNonPrJpsi->Draw("P");
  gNonPrJpsiTrad->Draw("P");

  c2->cd(2);
  fBin->Draw();// axis
  gPad->SetGridy();
  lPP->Draw();
  lRatio->Draw();

  ahRatio_npr_pp[0]->Draw("sames");
  
  c2->cd(3);
  fBin->Draw();// axis
  gPad->SetGridy();
  lAA->Draw();
  lRatio->Draw();

  ahRatio_npr_aa[0]->Draw("sames");

  if(bSavePlots)
  {
    c2->SaveAs(Form("%s/pdf/NonPrJpsi_vsY_%s.pdf",outputDir,compWhat[whichCompare]));
    c2->SaveAs(Form("%s/png/NonPrJpsi_vsY_%s.png",outputDir,compWhat[whichCompare]));
  }
  //-------------------minbias dependence
  TCanvas *c22b = new TCanvas("c22b","c22b",1200,400);
  c22b->Divide(3,1);
  c22b->cd(1);
  f4->Draw();

  lNpr->Draw();
  lcent->Draw();
  lpt->Draw();

  gNonPrJpsi_mb->Draw("P");
  gNonPrJpsi_y_y->Draw("P");

  gNonPrJpsiTrad_mb->Draw("P");
  gNonPrJpsiTrad_y_y->Draw("P");
 
  c22b->cd(2);
  fBin->Draw();
  gPad->SetGridy();
  lPP->Draw();
  lRatio->Draw();

  ahRatio_npr_pp[1]->Draw("sames");
  ahRatio_npr_pp[2]->Draw("sames");

  c22b->cd(3);
  fBin->Draw();
  gPad->SetGridy();
  lAA->Draw();
  lRatio->Draw();
  ahRatio_npr_aa[1]->Draw("sames");
  ahRatio_npr_aa[2]->Draw("sames");

  gPad->RedrawAxis();

  if(bSavePlots)
  {
    c11b->SaveAs(Form("%s/pdf/NonPrJpsi_vsY_mb_%s.pdf",outputDir,compWhat[whichCompare]));
    c11b->SaveAs(Form("%s/png/NonPrJpsi_vsY_mb_%s.png",outputDir,compWhat[whichCompare]));
  }

  
}
예제 #4
0
void PlotPtTresh2() {
	//  gROOT->ProcessLine(".L ./tdrstyle.C");
	//  setTDRStyle();
	Int_t r=1; 
	

	TFile *f1 = new TFile("histo_file_QCDPU50GEM2019.root");
	
	char  histo[40], histo1[40], histo2[40], histoDC[40];
	
	TH1F *hInitialBarrel = (TH1F*)f1->Get("hInitialBarrel"); 
	TH1F *hInitialEndcap = (TH1F*)f1->Get("hInitialEndcap"); 	
	
	TH1F *hPtBarrel = (TH1F*)f1->Get("hMuonPtFinal_Barrel"); 
	TH1F *hPtHE = (TH1F*)f1->Get("hMuonPtFinal_HE"); 
	TH1F *hPtFull = (TH1F*)f1->Get("hMuonPtFinal_Full"); 
	TH1F *hInitial = (TH1F*)f1->Get("entries_after_vertex"); 
	TH1F *hWP2012Pt = (TH1F*)f1->Get("hMuonPtWP2012"); 
	TH1F *h_HTot = (TH1F*)f1->Get("H_tot"); 
	TH1F *initial_entries = (TH1F*)f1->Get("initial_entries"); 
	
	cout<<"Htot"<<h_HTot->Integral()<<"  initial entries  "<<initial_entries->Integral()<<endl;
	
	int  Ninitial=hInitial->Integral();    
	cout<<" initial  "<<Ninitial<<endl;
	cout<<" initial  barrel "<<hInitialBarrel->Integral()<<endl;
	cout<<" initial endcap"<<hInitialEndcap->Integral()<<endl;
	
	cout<<" after muon barrel  "<<hPtBarrel->Integral()<<endl;
	cout<<" after muon HE  "<<hPtHE->Integral()<<endl;
	
	float MuonEff2012[1] =0;
	MuonEff2012[0]= hWP2012Pt->Integral()/hInitial->Integral();
	float Err_MuonEff2012[1];
	Err_MuonEff2012[0]=(TMath::Sqrt(Err_MuonEff2012[0]*(1-Err_MuonEff2012[0])))/Ninitial;
	//cout<<"Muon Eff WP 2012 "<<hWP2012Pt->Integral()/hInitial->Integral()<<endl;
	
	/////////////////////////compute selection eff as a function of muon pt threshold/////////////////////////////
	int EvAfterPtCut_HE[100]; float EffSel[100], xgr[100], ex[100],ey[100], EffSelFull[100], eyfull[100], Eff_Barrel[100], Eff_Endcap[100], err_Eff_barrel[100],err_Eff_endcap[100];
	int EvAfterPtCut_Barrel[100]; 
	int EvAfterPtCut[100];
	int EvAfterPtCut_BB[100];	
	int EvAfterPtCut_EE[100];	
	
	//  std::cout<<" Muon Pt in |eta|<2.4 "<<hMuonTot->Integral(0,200)<<endl;
	
	for(int i=0;i<40;i++){
		EvAfterPtCut_Barrel[i]=hPtBarrel->Integral(10,100);
		EvAfterPtCut_HE[i]=hPtHE->Integral(i+1,100);
		
		EvAfterPtCut[i]=hPtFull->Integral(i+1,100); 
		EvAfterPtCut_BB[i] =hPtBarrel->Integral(i+1,100);
		EvAfterPtCut_EE[i] =hPtHE->Integral(i+1,100);
		
		EffSelFull[i] = EvAfterPtCut[i] / (hInitialBarrel->Integral() + hInitialEndcap->Integral() );		
		Eff_Barrel[i]= EvAfterPtCut_BB[i]/hInitialBarrel->Integral();  
		Eff_Endcap[i]=EvAfterPtCut_EE[i]/hInitialEndcap->Integral();  
		
		std::cout<<i*2<<" nev after pt cut barrel "<<EvAfterPtCut_BB[i]<<"  nev after pt cut endcap  "<<EvAfterPtCut_HE[i]<<"  eff sel  "<<endl;
		
		xgr[i]=i*2;
		ex[i]=0; 
		EffSel[i]=(EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i])/(hInitial->Integral());
		
		ey[i]=TMath::Sqrt((EffSel[i]*(1-EffSel[i])))/hInitial->Integral();
		eyfull[i]=TMath::Sqrt((EffSelFull[i]*(1-EffSelFull[i])))/hInitial->Integral();
		//  std::cout<<i*2<<" nev after pt cut barrel || endcap "<<EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i]<<" eff sel  "<<EffSel[i]<<" errore "<<ey[i]<<endl;
	}
	
	double xgr12[1]; xgr12[0]=13.0; 
	double ex12[1]; ex12[0]=0.; 
	TGraphErrors* gr = new TGraphErrors(26,xgr,EffSel,ex,ey);
	TGraphErrors* gr_full = new TGraphErrors(26,xgr,EffSelFull,ex,eyfull);
	TGraph* gr12 = new TGraph(1);
	gr12->SetPoint(0,20,MuonEff2012[0]);
	
	TGraphErrors* gr_BB = new TGraphErrors(26,xgr,Eff_Barrel,ex,ey);	
	TGraphErrors* gr_EE = new TGraphErrors(26,xgr,Eff_Endcap,ex,ey);	
	
	///////////////////////////////////////////************************************////////////////////////////////////////////
	TCanvas *Canv5 = new TCanvas("Canv5","Palle",800,700);
	gr->SetMarkerStyle(24);  
	gr12->SetMarkerStyle(23); 
	gr->SetMarkerColor(kRed);  
	gr12->SetMarkerColor(kBlue);  
	gr->SetTitle(" Selection Efficiency as a function of muon pt threshold ");
	gr->GetYaxis()->SetTitle("Selection Efficiency");
	gr->GetYaxis()->SetTitleOffset(1.4);
	gr->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)");
	
	gr->SetMarkerSize(1.2);  
	gr12->SetMarkerSize(1.4); 
	
	gr->Draw("ACP");
	gr12->Draw("CP");
	gr->SetMinimum(0.5);
	TLegend* legend = new TLegend( 0.15, 0.5, 0.75, 0.7);
	legend->SetTextSize(0.025);
	legend->SetFillColor(0);
	legend->AddEntry(gr, "PU=50 wGEM (P_{T}^{#mu, barrel}>20, |#eta|<2.1)","p");
	legend->AddEntry(gr12, "PU=50 wGEM 2012 WP  (P_{T}^{#mu Full Accept}>24,|#eta|<2.1)","p");
	Canv5->cd();
	legend->Draw("same");
	Canv5->SaveAs("WHPtTresh.pdf");
	
	///////////////////////////////////////////************************************////////////////////////////////////////////
	
	TCanvas *Canv6 = new TCanvas("Canv6","StraPalle",800,700);
	gr_full->SetMarkerStyle(24);  
	gr_full->SetMarkerColor(kBlue);
	
	gr_BB->SetMarkerStyle(24);  
	gr_EE->SetMarkerStyle(24);  
	
	gr_BB->SetMarkerColor(kGreen);  
	gr_EE->SetMarkerColor(kMagenta);  
	
	gr_full->SetTitle(" Selection Efficiency as a function of muon pt threshold ");
	gr_full->GetYaxis()->SetTitle("Selection Efficiency");
	gr_full->GetYaxis()->SetTitleOffset(1.4);
	gr_full->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)");
	gr_BB->Draw("ACP");
	gr_full->Draw("CP");
//	gr_BB->Draw("CP");
	gr_EE->Draw("CP");
	//gr12->Draw("CP");
	//gr_full->SetMinimum(0.1);
	gr_BB->SetMinimum(0.);
	gr_BB->SetMaximum(0.001);
	gPad->SetGrid();
	gPad->Update();
	
	TLegend* legend = new TLegend( 0.65, 0.7, 0.85, 0.9);
	legend->SetTextSize(0.025);
	legend->SetFillColor(0);
	legend->AddEntry(gr_full, "full acceptance","p");
	legend->AddEntry(gr_BB, "|#eta|<1.6","p");
	legend->AddEntry(gr_EE, "1.6<|#eta|<2.1","p");
	Canv6->cd();
	legend->Draw("same");
	Canv6->SaveAs("QCD_threshold_fullAcc.pdf");
	
	
}
int
TrackParametrization( TString csvfile="fitslices_out.csv" )
{

  /* Read data from input file */
  TTree *tres = new TTree();
  tres->ReadFile( csvfile, "ptrue:etatrue:psig:psig_err:pmean:pmean_err:norm", ',' );

  /* Print read-in tree */
  tres->Print();

  /* colors array */
  unsigned colors[8] = {1,2,3,4,6,7,14,16};

  /* Create vector of theta values to include for visualization*/
  vector< double > etas_vis;
  etas_vis.push_back(-2.75);
  etas_vis.push_back(-2.25);
  etas_vis.push_back(-1.75);
  etas_vis.push_back(-0.25);
  etas_vis.push_back( 0.25);
  etas_vis.push_back( 1.75);
  etas_vis.push_back( 2.25);

//  etas_vis.push_back(-3.25);
//  etas_vis.push_back(-2.25);
//  etas_vis.push_back(-1.25);
//  etas_vis.push_back(-0.25);
//  etas_vis.push_back( 0.25);
//  etas_vis.push_back( 1.25);
//  etas_vis.push_back( 2.25);
//  etas_vis.push_back( 3.25);

  /* Create vector of theta values to include for fitting*/
  vector< double > etas_fit;
  for ( double eta = -4.45; eta < 4.5; eta += 0.1 )
    etas_fit.push_back( eta );

  /* Create fit function */
  TF1* f_momres = new TF1("f_momres", "sqrt( [0]*[0] + [1]*[1]*x*x )" );

  cout << "\nFit function: " << f_momres->GetTitle() << "\n" << endl;

  /* Create scratch canvas */
  TCanvas *cscratch = new TCanvas("cscratch");

  /* Create framehistogram */
  TH1F* hframe = new TH1F("hframe","",100,0,40);
  hframe->GetYaxis()->SetRangeUser(0,0.15);
  hframe->GetYaxis()->SetNdivisions(505);
  hframe->GetXaxis()->SetTitle("Momentum (GeV/c)");
  hframe->GetYaxis()->SetTitle("#sigma_{p}/p");

  /* create combined canvas plot */
  TCanvas *c1 = new TCanvas();
  hframe->Draw();

  /* Create legend */
  TLegend* leg_eta = new TLegend( 0.2, 0.6, 0.5, 0.9);
  leg_eta->SetNColumns(2);

  /* Create ofstream to write fit parameter results */
  ofstream ofsfit("track_momres_new.csv");
  ofsfit<<"eta,par1,par1err,par2,par2err"<<endl;

  /* Create resolution-vs-momentum plot with fits for each selected theta value */
  for ( int i = 0; i < etas_fit.size(); i++ )
    {
      /* Switch to scratch canvas */
      cscratch->cd();

      double eta = etas_fit.at(i);

      /* No tracking outside -4 < eta < 4 */
      if ( eta < -4 || eta > 4 )
	continue;

      cout << "\n***Eta = " << eta << endl;

      /* Define range of theta because float comparison with fixed value doesn't work
	 too well for cuts in ROOT trees */
      double eta_min = eta * 0.999;
      double eta_max = eta * 1.001;

      /* Cut for tree */
      TCut cutx( Form("ptrue > 1 && ( (etatrue > 0 && (etatrue > %f && etatrue < %f)) || (etatrue < 0 && (etatrue < %f && etatrue > %f)) )", eta_min, eta_max, eta_min, eta_max) );

      /* "Draw" tree on scratch canvas to fill V1...V4 arrays */
      tres->Draw("psig:ptrue:psig_err:0", cutx );

      /* Create TGraphErrors with selected data from tree */
      TGraphErrors *gres = new TGraphErrors( tres->GetEntries(cutx),
					     &(tres->GetV2())[0],
					     &(tres->GetV1())[0],
					     &(tres->GetV4())[0],
					     &(tres->GetV3())[0] );

      /* reset function parameters before fit */
      f_momres->SetParameter(0,0.1);
      f_momres->SetParameter(1,0.1);

      /* Only plot pseudorapidities listed on etas_vis; if not plotting, still do the fit */
      bool vis = false;
      int vi = 0;

      for ( vi = 0; vi < etas_vis.size(); vi++ )
	{
	  if ( abs( etas_vis.at(vi) - eta ) < 0.001 )
	    {
	      vis = true;
	      break;
	    }
	}

      if ( vis )
	{
	  /* Add graph to legend */
	  leg_eta->AddEntry(gres, Form("#eta = %.1f", eta), "P");

	  /* Add graph to plot */
	  c1->cd();
	  gres->SetMarkerColor(colors[vi]);
	  gres->Draw("Psame");
	  f_momres->SetLineColor(colors[vi]);
	  gres->Fit(f_momres);
	}
      else
	{
	  gres->Fit(f_momres);
	}

      /* Write fir results to file */
      double par1 = f_momres->GetParameter(0);
      double par1err = f_momres->GetParError(0);
      double par2 = f_momres->GetParameter(1);
      double par2err = f_momres->GetParError(1);
      ofsfit << eta << "," << par1 << "," << par1err << "," << par2 << "," << par2err << endl;

    }

  /* Draw legend */
  c1->cd();
  //TCanvas *c2 = new TCanvas();
  //hframe->Draw();
  leg_eta->Draw();

  /* Print plots */
  c1->Print("track_momres_vareta.eps");
  //c2->Print("track_momres_vareta_legend.eps");

  /* Close output stream */
  ofsfit.close();

  return 0;
}
예제 #6
0
void acceptance_cT()
{
//=========Macro generated from canvas: c/c
//=========  (Mon Oct 26 11:10:32 2015) by ROOT version6.02/05
   TCanvas *c = new TCanvas("c", "c",0,22,700,500);
   gStyle->SetOptStat(0);
   c->Range(-2.75,-0.025,22.75,0.225);
   c->SetFillColor(0);
   c->SetBorderMode(0);
   c->SetBorderSize(2);
   c->SetFrameBorderMode(0);
   c->SetFrameBorderMode(0);
   
   TH2F *dummy31 = new TH2F("dummy31","dummy3",400,-0.2,20.2,100,0,0.2);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   dummy31->SetLineColor(ci);
   dummy31->GetXaxis()->SetTitle("c#tau [mm]");
   dummy31->GetXaxis()->SetLabelFont(42);
   dummy31->GetXaxis()->SetLabelSize(0.035);
   dummy31->GetXaxis()->SetTitleSize(0.035);
   dummy31->GetXaxis()->SetTitleFont(42);
   dummy31->GetYaxis()->SetTitle("#epsilon_{rec} = N_{rec}/N_{tot}");
   dummy31->GetYaxis()->SetLabelFont(42);
   dummy31->GetYaxis()->SetLabelSize(0.035);
   dummy31->GetYaxis()->SetTitleSize(0.035);
   dummy31->GetYaxis()->SetTitleFont(42);
   dummy31->GetZaxis()->SetLabelFont(42);
   dummy31->GetZaxis()->SetLabelSize(0.035);
   dummy31->GetZaxis()->SetTitleSize(0.035);
   dummy31->GetZaxis()->SetTitleFont(42);
   dummy31->Draw("");
   
   Double_t Graph0_fx1001[11] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5,
   10,
   20};
   Double_t Graph0_fy1001[11] = {
   0.0865404,
   0.08294682,
   0.06949495,
   0.04645202,
   0.0157633,
   0.005542929,
   0.00155303,
   0.0009974747,
   0.0002651515,
   6.47017e-05,
   2.397917e-05};
   Double_t Graph0_fex1001[11] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph0_fey1001[11] = {
   0.0009990599,
   0.0009899688,
   0.0009035941,
   0.000747844,
   0.0004493916,
   0.0002638154,
   0.0001399232,
   0.0001121687,
   5.785313e-05,
   1.3794e-05,
   9.063167e-06};
   TGraphErrors *gre = new TGraphErrors(11,Graph0_fx1001,Graph0_fy1001,Graph0_fex1001,Graph0_fey1001);
   gre->SetName("Graph0");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1001 = new TH1F("Graph_Graph1001","Graph",100,0,22);
   Graph_Graph1001->SetMinimum(0);
   Graph_Graph1001->SetMaximum(0.09629192);
   Graph_Graph1001->SetDirectory(0);
   Graph_Graph1001->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1001->SetLineColor(ci);
   Graph_Graph1001->GetXaxis()->SetLabelFont(42);
   Graph_Graph1001->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetXaxis()->SetTitleFont(42);
   Graph_Graph1001->GetYaxis()->SetLabelFont(42);
   Graph_Graph1001->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetYaxis()->SetTitleFont(42);
   Graph_Graph1001->GetZaxis()->SetLabelFont(42);
   Graph_Graph1001->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1001);
   
   gre->Draw(" pl");
   
   Double_t Graph1_fx1002[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph1_fy1002[9] = {
   0.08208333,
   0.07862374,
   0.06748737,
   0.04597222,
   0.01659091,
   0.005892857,
   0.001868687,
   0.0009974747,
   0.0004419192};
   Double_t Graph1_fex1002[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fey1002[9] = {
   0.0009753636,
   0.000956385,
   0.000891407,
   0.0007441589,
   0.0004538785,
   0.0002733515,
   0.0001534615,
   0.0001121687,
   7.468147e-05};
   gre = new TGraphErrors(9,Graph1_fx1002,Graph1_fy1002,Graph1_fex1002,Graph1_fey1002);
   gre->SetName("Graph1");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(2);
   gre->SetMarkerColor(2);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","Graph",100,0,5.5);
   Graph_Graph1002->SetMinimum(0);
   Graph_Graph1002->SetMaximum(0.09132784);
   Graph_Graph1002->SetDirectory(0);
   Graph_Graph1002->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1002->SetLineColor(ci);
   Graph_Graph1002->GetXaxis()->SetLabelFont(42);
   Graph_Graph1002->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetXaxis()->SetTitleFont(42);
   Graph_Graph1002->GetYaxis()->SetLabelFont(42);
   Graph_Graph1002->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetYaxis()->SetTitleFont(42);
   Graph_Graph1002->GetZaxis()->SetLabelFont(42);
   Graph_Graph1002->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1002);
   
   gre->Draw(" pl");
   
   Double_t Graph2_fx1003[6] = {
   0,
   0.1,
   0.2,
   0.5,
   2,
   5};
   Double_t Graph2_fy1003[6] = {
   0.0749858,
   0.0642268,
   0.04502717,
   0.01693182,
   0.002222281,
   0.0003815789};
   Double_t Graph2_fex1003[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph2_fey1003[6] = {
   0.0009926071,
   0.0008800606,
   0.0007643529,
   0.0004584384,
   0.0001707546,
   7.084391e-05};
   gre = new TGraphErrors(6,Graph2_fx1003,Graph2_fy1003,Graph2_fex1003,Graph2_fey1003);
   gre->SetName("Graph2");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(3);
   gre->SetMarkerColor(3);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1003 = new TH1F("Graph_Graph1003","Graph",100,0,5.5);
   Graph_Graph1003->SetMinimum(0);
   Graph_Graph1003->SetMaximum(0.08354517);
   Graph_Graph1003->SetDirectory(0);
   Graph_Graph1003->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1003->SetLineColor(ci);
   Graph_Graph1003->GetXaxis()->SetLabelFont(42);
   Graph_Graph1003->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetXaxis()->SetTitleFont(42);
   Graph_Graph1003->GetYaxis()->SetLabelFont(42);
   Graph_Graph1003->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetYaxis()->SetTitleFont(42);
   Graph_Graph1003->GetZaxis()->SetLabelFont(42);
   Graph_Graph1003->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1003);
   
   gre->Draw(" pl");
   
   Double_t Graph3_fx1004[11] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5,
   10,
   20};
   Double_t Graph3_fy1004[11] = {
   0.05958333,
   0.06207908,
   0.06051768,
   0.05941919,
   0.05516582,
   0.04303571,
   0.02356061,
   0.01513298,
   0.006989796,
   0.002367956,
   0.0007142042};
   Double_t Graph3_fex1004[11] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph3_fey1004[11] = {
   0.0008541653,
   0.0008617826,
   0.000847272,
   0.0008400378,
   0.0008153701,
   0.0007247769,
   0.000538956,
   0.0004451866,
   0.0002975439,
   6.810597e-05,
   4.035479e-05};
   gre = new TGraphErrors(11,Graph3_fx1004,Graph3_fy1004,Graph3_fex1004,Graph3_fey1004);
   gre->SetName("Graph3");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(4);
   gre->SetMarkerColor(4);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1004 = new TH1F("Graph_Graph1004","Graph",100,0,22);
   Graph_Graph1004->SetMinimum(0);
   Graph_Graph1004->SetMaximum(0.06916757);
   Graph_Graph1004->SetDirectory(0);
   Graph_Graph1004->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1004->SetLineColor(ci);
   Graph_Graph1004->GetXaxis()->SetLabelFont(42);
   Graph_Graph1004->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1004->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1004->GetXaxis()->SetTitleFont(42);
   Graph_Graph1004->GetYaxis()->SetLabelFont(42);
   Graph_Graph1004->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1004->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1004->GetYaxis()->SetTitleFont(42);
   Graph_Graph1004->GetZaxis()->SetLabelFont(42);
   Graph_Graph1004->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1004->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1004->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1004);
   
   gre->Draw(" pl");
   
   Double_t Graph4_fx1005[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph4_fy1005[9] = {
   0.1375897,
   0.137474,
   0.1364046,
   0.1359975,
   0.1364646,
   0.132096,
   0.1211862,
   0.1061111,
   0.07766414};
   Double_t Graph4_fex1005[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1005[9] = {
   0.001244048,
   0.001242555,
   0.00123208,
   0.001218037,
   0.001219797,
   0.001203145,
   0.001165513,
   0.001147773,
   0.0009510256};
   gre = new TGraphErrors(9,Graph4_fx1005,Graph4_fy1005,Graph4_fex1005,Graph4_fey1005);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(6);
   gre->SetMarkerColor(6);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1005 = new TH1F("Graph_Graph1005","Graph",100,0,5.5);
   Graph_Graph1005->SetMinimum(0.07050106);
   Graph_Graph1005->SetMaximum(0.1450458);
   Graph_Graph1005->SetDirectory(0);
   Graph_Graph1005->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1005->SetLineColor(ci);
   Graph_Graph1005->GetXaxis()->SetLabelFont(42);
   Graph_Graph1005->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1005->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1005->GetXaxis()->SetTitleFont(42);
   Graph_Graph1005->GetYaxis()->SetLabelFont(42);
   Graph_Graph1005->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1005->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1005->GetYaxis()->SetTitleFont(42);
   Graph_Graph1005->GetZaxis()->SetLabelFont(42);
   Graph_Graph1005->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1005->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1005->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1005);
   
   gre->Draw(" pl");
   
   TLegend *leg = new TLegend(0.5387931,0.5813953,0.887931,0.8816068,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.045);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph0","m_{#gamma D}=0.250 GeV","PL");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph1","m_{#gamma D}=0.275 GeV","PL");
   entry->SetLineColor(2);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(2);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","m_{#gamma D}=0.300 GeV","PL");
   entry->SetLineColor(3);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(3);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph3","m_{#gamma D}=2.000 GeV","PL");
   entry->SetLineColor(4);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(4);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph4","m_{#gamma D}=8.500 GeV","PL");
   entry->SetLineColor(6);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(6);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.4195977,0.9339831,0.5804023,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("dummy3");
   pt->Draw();
   c->Modified();
   c->cd();
   c->SetSelected(c);
}
예제 #7
0
v62pt_compare()
{
  gROOT->Reset();
  gROOT->SetStyle("MyStyle");
//  gROOT->LoadMacro("v2pt_12cen_MyDef.C");
  // gROOT->LoadMacro("MyDef.C");
  gStyle->SetTextFont(43);
  gStyle->SetLabelFont(43,"x");
  gStyle->SetLabelFont(43,"y");
  gStyle->SetLabelFont(43,"z");
  gStyle->SetTitleFont(43,"x");
  gStyle->SetTitleFont(43,"y");
  gStyle->SetTitleFont(43,"z");
  gStyle->SetEndErrorSize(0);

  double textsize = 19;

//int   mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray};
int   mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray};
int   mcol2[4]={6,2,4,8};

//int   msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}};
int   msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}};


//float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1};
float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6};
float msiz2[4]={1.5,1.5,1.5,1.5};
//
// arrays
//
const int Mfiles=50;
int   ndp[Mfiles];
char *cfn[Mfiles];
char *cft[Mfiles];
const int Mpoints=40;
double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints];
double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints];
double nxa[Mfiles][Mpoints],nxe[Mfiles][Mpoints];
double nya[Mfiles][Mpoints],nye[Mfiles][Mpoints];
double mxa[Mfiles][Mpoints],mxe[Mfiles][Mpoints];
double mya[Mfiles][Mpoints],mye[Mfiles][Mpoints];

double aexl[Mfiles][Mpoints],aexh[Mfiles][Mpoints];
double aeyl[Mfiles][Mpoints],aeyh[Mfiles][Mpoints];



double ra[Mfiles][Mpoints],re[Mfiles][Mpoints];

const int Mpads=14;


char  *htit[Mpads];
char  *atit[Mpads][3];
double ptit[Mpads][2];
double hxmin[Mpads],hxmax[Mpads];
double hymin[Mpads],hymax[Mpads];
double lxmin[Mpads],lxmax[Mpads];
double lymin[Mpads],lymax[Mpads];


 
  //
  // Data input
  //
  char *cjob="v2pt_12cen_4x3";
  int i=-1;


  // histogram parameter
  htit[0]="0-5%";
  htit[1]="5-10%";
  htit[2]="10-15%";
  htit[3]="15-20%";
  htit[4]="20-25%";
  htit[5]="25-30%";
  htit[6]="30-35%";
  htit[7]="35-40%";
  htit[8]="40-50%";
  htit[9]="50-60%";
  htit[10]="60-70%";
  htit[11]="70-80%";
  for (int ip=0;ip<Mpads;ip++)
  {
    //  hxmin[ip]=0.0; hxmax[ip]=11.9;
    hxmin[ip]=0.0001; hxmax[ip]=8.3;
    hymin[ip]=0.0001; hymax[ip]=0.029;
    lxmin[ip]=0.08; lxmax[ip]=0.35;
    lymin[ip]=0.4; lymax[ip]=0.65;
    ptit[ip][0]=5.0; ptit[ip][1]=0.08*0.27;// position legends 
    atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{6}{#Psi_{222}}";
  }
  //
  // Read data and create vector files
  //

  double tmp;
  const int nw=12;
  const int npt=16;
  ifstream inEP;
  inEP.open("../outv62_corrFlow.txt");
  for(int i=0; i<nw-3; i++){
      inEP>>tmp; inEP>>tmp;
    for(int j=0; j<npt+4; j++){
      inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j];
      //inEP>>xa[i][j]; inEP>>ya[i][j]; inEP>>ye[i][j]; inEP>>tmp;
      xe[i][j]=0.0;
    }
  }
  inEP.close();

  ifstream inSP;
  inSP.open("./data_v62ep.txt");
  for(int i=0; i<nw-3; i++){
      inSP>>tmp; inSP>>tmp;
    for(int j=0; j<npt-1; j++){
      inSP>>nxa[i][j]; inSP>>nya[i][j]; inSP>>nye[i][j]; inSP>>tmp; 
      nxe[i][j]=0.0; nye[i][j]=sqrt(nye[i][j]*nye[i][j] + tmp*tmp);
    }
  }
  inSP.close();
  ifstream inSP;
  inSP.open("/Users/shengquantuo/Downloads/tmp2/figures_-0.8_00.8/outv6222Asteve.txt");
  for(int i=0; i<nw-3; i++){
    for(int j=0; j<npt+2; j++){
      inSP>>mxa[i][j]; inSP>>mya[i][j]; inSP>>mye[i][j]; 
      mxe[i][j]=0.0;
    }
  }
  inSP.close();

  for(int i=0; i<nw-1; i++){
    cout<<"sys for cent: "<<i<<endl;
    for(int j=0; j<10; j++){
      cout<<nxa[i][j]<<"   "<<fabs(ya[i][j]-nya[i][j])/fabs(ya[i][j])<<"     "<<fabs(ye[i][j])/fabs(ya[i][j])<<endl;
    }
  }

  TCanvas *can=new TCanvas("can","can",10,10,1050*0.9,800*0.85);

  can->Divide(4,3,0,0); //sticks the pads with no space inbetween 
  
  TH1D *h1[nw];
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);
    if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02);
    char ch1[8];
    sprintf(ch1,"h1_%d",iw);
    h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]);
    h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]);
    h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]);
    h1[iw]->GetXaxis()->CenterTitle(1);
    h1[iw]->GetYaxis()->CenterTitle(1);

    // futz with the axes
    h1[iw]->GetYaxis()->SetNdivisions(606);
    h1[iw]->GetXaxis()->SetNdivisions(606);

      h1[iw]->GetYaxis()->SetTitleSize(textsize);
      h1[iw]->GetYaxis()->SetTitleOffset(3.5);
      h1[iw]->GetYaxis()->SetLabelSize(textsize);
      h1[iw]->GetXaxis()->SetTitleSize(textsize);
      h1[iw]->GetXaxis()->SetTitleOffset(3.0);
      h1[iw]->GetXaxis()->SetLabelSize(textsize);
     // h1[iw]->GetXaxis()->SetLabelOffset(1.2);

    h1[iw]->Draw();
  }
  //
  // Draw! 
  //
  cout << "Now Draw!" << endl;
  TGraphErrors *ge;
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);

    //
    if (iw==0)
    {
      tex=new TLatex(1.1,0.08,"CMS PbPb #sqrt{s_{NN}}=2.76TeV");
      tex->SetTextSize(textsize*0.85);
      //tex->Draw();
      tex=new TLatex(1.5,0.07,"|#eta|<0.8");
      tex->SetTextSize(textsize);
      //tex->Draw();
    }
    if (iw < 4) tex=new TLatex(ptit[iw][0]*1.1,ptit[iw][1]*1.1,htit[iw]);
    else tex=new TLatex(ptit[iw][0]*1.1,ptit[iw][1]*1.1,htit[iw]);
    if ( iw == 0)   tex->SetTextSize(textsize);
    else if (iw == 8) tex->SetTextSize(textsize);
    else  tex->SetTextSize(textsize);
    tex->Draw();
    //
    // Legend
    //
    TLegend *leg = new TLegend(lxmin[iw]*0.6,lymin[iw],lxmax[iw]*0.6,lymax[iw]*1.2);
    leg->SetTextSize(textsize);
    //
    // Read data
    //
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=4;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(16,&mxa[j][0],&mya[j][0],&mxe[j][0],&mye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(24);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"v_{6}{SP}(Sanders,|#eta|<0.8)","p");
    }
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=1;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(19,&xa[j][0],&ya[j][0],&xe[j][0],&ye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(msty[im][1]);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"v_{6}{SP} (Tuo, |#eta|<0.8)","p");
    }
    if (iw==9) leg->Draw();

    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=2;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(19,&nxa[j][0],&nya[j][0],&nxe[j][0],&nye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(25);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"v_{6}{EP} (11005, |#eta|<0.8)","p");
    }

  }
  cout << "end of process" << endl;
  can->cd();
  can->Print("./figures/v62_pt_5TeVShengquanSteve.png");
  can->Print("./figures/v62_pt_5TeVShengquanSteve.pdf");
}
예제 #8
0
void ana_Run11_eff()
{

  const int rebin = 1;

  TFile *f = TFile::Open("Rootfiles/Run11_eff.root","read");

  // Run with weigth
  TH2F *hMcPtVsEta = (TH2F*)f->Get("mcJpsiPtY");
  TH2F *hRcPtVsEta = (TH2F*)f->Get("hHt2JpsiPE");

  draw2D(hMcPtVsEta);
  draw2D(hRcPtVsEta);

  hMcPtVsEta->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6);
  TH1F *hMcPt = (TH1F*)hMcPtVsEta->ProjectionY("hMcPt");
  hMcPt->Rebin(rebin);
  hMcPt->SetMarkerStyle(20);
  draw1D(hMcPt,"",kTRUE);

  hRcPtVsEta->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6);
  TH1F *hRcPt = (TH1F*)hRcPtVsEta->ProjectionY("hRcPt");
  hRcPt->Rebin(rebin);
  hRcPt->SetMarkerStyle(21);
  hRcPt->SetMarkerColor(2);
  hRcPt->SetLineColor(2);
  hRcPt->Draw("sames P");

  TH1F *hRatio = (TH1F*)hRcPt->Clone("hRatio_fromRunning");
  hRatio->Rebin(100);
  hMcPt->Rebin(100);
  hRatio->Divide(hMcPt);
  cEff = draw1D(hRatio,"");

  // Run without weight
  TH2F *hMcPtVsEtaNoWeight = (TH2F*)f->Get("mcJpsiPtY_Or");
  draw2D(hMcPtVsEtaNoWeight);  

  TH2F *hMcPtVsRcNoWeight = (TH2F*)f->Get("hJpsiRcvsMC_Cut1");
  hMcPtVsRcNoWeight->RebinX(rebin);
  hMcPtVsRcNoWeight->RebinY(rebin);
  draw2D(hMcPtVsRcNoWeight);

  hMcPtVsEtaNoWeight->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6);
  TH1F *hMcPtNoWeight = (TH1F*)hMcPtVsEtaNoWeight->ProjectionY("hMcPtNoWeight");
  hMcPtNoWeight->Rebin(rebin);
  hMcPtNoWeight->SetMarkerStyle(20);
  hMcPtNoWeight->SetMinimum(1);
  draw1D(hMcPtNoWeight,"",kTRUE);

  TH1F *hRcPtNoWeight = (TH1F*)hMcPtVsRcNoWeight->ProjectionX("hRcPtNoWeight");
  hRcPtNoWeight->SetMarkerStyle(21);
  hRcPtNoWeight->SetMarkerColor(2);
  hRcPtNoWeight->SetLineColor(2);
  hRcPtNoWeight->Draw("sames P");

  TH1F *hRatioNoWeight = (TH1F*)hRcPtNoWeight->Clone("hRatioNoWeight");
  hRatioNoWeight->Divide(hMcPtNoWeight);
  cEff->cd();
  hRatioNoWeight->SetMarkerColor(4);
  hRatioNoWeight->Draw("samesP");

  // weight with input histogram
  TH1F *hMcPtWeight = (TH1F*)hMcPtNoWeight->Clone("hMcPtWeight");
  TH2F *hMcPtVsRcWeight = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcWeight");
  for(int ibin=1; ibin<=hMcPtVsRcNoWeight->GetNbinsX(); ibin++)
    {
      double scale = hMcPt->GetBinContent(ibin);
      hMcPtWeight->SetBinContent(ibin,hMcPtWeight->GetBinContent(ibin)*scale);
      hMcPtWeight->SetBinError(ibin,hMcPtWeight->GetBinError(ibin)*scale);
      for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++)
	{
	  hMcPtVsRcWeight->SetBinContent(ibin,jbin,hMcPtVsRcWeight->GetBinContent(ibin,jbin)*scale);
	  hMcPtVsRcWeight->SetBinError(ibin,jbin,hMcPtVsRcWeight->GetBinError(ibin,jbin)*scale);
	}
    }
  TH1F *hRcPtWeight = (TH1F*)hMcPtVsRcWeight->ProjectionY("hRcPtWeight");
  hRcPtWeight->SetMarkerStyle(21);
  hRcPtWeight->SetMarkerColor(2);
  hRcPtWeight->SetLineColor(2);

  draw2D(hMcPtVsRcWeight);
  draw1D(hMcPtWeight,"",kTRUE);
  hRcPtWeight->Draw("sames P");
  
  TH1F *hRatioWeight = (TH1F*)hRcPtWeight->Clone("hRatioWeight");
  hRatioWeight->Divide(hMcPtWeight);
  cEff->cd();
  hRatioWeight->SetMarkerColor(6);
  hRatioWeight->Draw("samesP");

  TH1F *hCheck = (TH1F*)hRatioWeight->Clone("check");
  hCheck->Divide(hRatio);
  draw1D(hCheck);

  // weight with fitted function
  TCanvas *c = new TCanvas("Fit","Fit",800,600);
  SetPadMargin(gPad,0.15,0.15);
  gPad->SetLogy();
  TH1F *h = new TH1F("histogram",";;;",7,0,30);
  h->GetYaxis()->SetRangeUser(1e-7,100);
  h->Draw();

  TFile *fdata = TFile::Open("Rootfiles/Spectrum_in_bin.root","read");
  TGraphErrors	*gr = (TGraphErrors*)fdata->Get("gall");
  gr->SetMarkerColor(1);
  gr->SetLineColor(1);
  gr->GetXaxis()->SetRangeUser(0,30);
  gr->Draw("sames PE");
  TF1 *func = new TF1("func",InvPt,0,30,4);
  func->SetParameters(0.4,-0.4796,4.229,-7.54);
  gr->Fit(func,"RL");

  TH1F *hMcPtFunc = (TH1F*)hMcPtNoWeight->Clone("hMcPtFunc");
  TH2F *hMcPtVsRcFunc = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcFunc");
  for(int ibin=1; ibin<=hMcPtVsRcFunc->GetNbinsX(); ibin++)
    {
      double scale = func->Eval(hMcPtFunc->GetBinCenter(ibin));
      hMcPtFunc->SetBinContent(ibin,hMcPtFunc->GetBinContent(ibin)*scale);
      hMcPtFunc->SetBinError(ibin,hMcPtFunc->GetBinError(ibin)*scale);
      for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++)
	{
	  hMcPtVsRcFunc->SetBinContent(ibin,jbin,hMcPtVsRcFunc->GetBinContent(ibin,jbin)*scale);
	  hMcPtVsRcFunc->SetBinError(ibin,jbin,hMcPtVsRcFunc->GetBinError(ibin,jbin)*scale);
	}
    }
  TH1F *hRcPtFunc = (TH1F*)hMcPtVsRcFunc->ProjectionY("hRcPtFunc");
  hRcPtFunc->SetMarkerStyle(21);
  hRcPtFunc->SetMarkerColor(2);
  hRcPtFunc->SetLineColor(2);
  hMcPtVsRcFunc->GetZaxis()->SetRangeUser(1e-4,1e2);
  draw2D(hMcPtVsRcFunc);
  hMcPtFunc->GetYaxis()->SetRangeUser(1e-4,5e4);
  draw1D(hMcPtFunc,"",kTRUE);
  hRcPtFunc->Draw("sames P");

  TH1F *hRatioFunc = (TH1F*)hRcPtFunc->Clone("hRatioFunc");
  hRatioFunc->Rebin(100);
  hMcPtFunc->Rebin(100);
  hRatioFunc->Divide(hMcPtFunc);
  cEff->cd();
  hRatioFunc->SetMarkerColor(5);
  hRatioFunc->Draw("samesP");
  
  TH1F *hCheck2 = (TH1F*)hRatioFunc->Clone("check2");
  hCheck2->Divide(hRatio);
  draw1D(hCheck2);

}
예제 #9
0
파일: plotpidket2.C 프로젝트: XuQiao/phenix
void plotpidket(){
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetStripDecimals(0);

  float mpion = 0.13957;
  float mkaon = 0.49368;
  float mproton = 0.93827;

  float pt[13], ept[12], v2[13], ev2[13], sv2[13];
  ifstream fin("run12dAu_fvtx0s_hadron_v2_0_5.txt");
  for(int i=0; i<13; i++){
    ept[i]=0;
    fin>>pt[i]>>v2[i]>>ev2[i];
  }
  fin.close();

  TGraphErrors *grhadron = new TGraphErrors(13, pt, v2, ept, ev2);


  ifstream fin("run12dAu_fvtx0s_pion_v2_0_5.txt");

  for(int i=0; i<13; i++){
    ept[i]=0;
    fin>>pt[i]>>v2[i]>>ev2[i];
    pt[i]= sqrt(pt[i]**2+mpion**2)-mpion;

    pt[i] = pt[i]/2.0;
    v2[i] = v2[i]/2.0;
    ev2[i] = ev2[i]/2.0;
  }
  fin.close();

  TGraphErrors *grpion = new TGraphErrors(13, pt, v2, ept, ev2);

  ifstream fin("run12dAu_fvtx0s_kaon_v2_0_5.txt");

  for(int i=0; i<13; i++){
    ept[i]=0;
    fin>>pt[i]>>v2[i]>>ev2[i];
    pt[i]= sqrt(pt[i]**2+mkaon**2)-mkaon;

    pt[i] = pt[i]/2.0;
    v2[i] = v2[i]/2.0;
    ev2[i] = ev2[i]/2.0;
  }
  fin.close();

  TGraphErrors *grkaon = new TGraphErrors(13, pt, v2, ept, ev2);

  ifstream fin2("run12dAu_fvtx0s_proton_v2_0_5.txt");

  for(int i=0; i<13; i++){
    pt[i]=0;
    fin2>>pt[i]>>v2[i]>>ev2[i];
    pt[i]= sqrt(pt[i]**2+mproton**2)-mproton;

    pt[i] = pt[i]/3.0;
    v2[i] = v2[i]/3.0;
    ev2[i] = ev2[i]/3.0;

    cout<<pt[i]<<endl;
  }
  fin2.close();

  TGraphErrors *grproton = new TGraphErrors(13, pt, v2, ept, ev2);

  c1=new TCanvas("c1","c1");
  c1->SetFillColor(10);
  c1->cd();

  TH1F *h = new TH1F("h","h",21, 0, 2.1);
  h->SetMinimum(-0.02);
  h->SetMaximum(0.18);
  h->SetMarkerStyle(20);
  h->SetMarkerSize(1.2);
  h->Draw();

  h->GetYaxis()->SetTitleOffset(0.9);
  h->GetYaxis()->SetTitleSize(0.05);
  h->GetYaxis()->SetTitle("v_{2}/n_{q}");

  h->GetXaxis()->SetTitle("KE_{T}/n_{q} (GeV)");
  h->GetXaxis()->SetTitleSize(0.04);
  h->GetYaxis()->CenterTitle(kTRUE);
  h->GetXaxis()->CenterTitle(kTRUE);

  grkaon->SetMarkerStyle(21);
  grkaon->SetMarkerSize(1.2);
  grkaon->SetMarkerColor(6);
  grkaon->Draw("P");

  grpion->SetMarkerStyle(20);
  grpion->SetMarkerSize(1.2);
  grpion->SetMarkerColor(2);
  grpion->Draw("P");

  grproton->SetMarkerStyle(24);
  grproton->SetMarkerSize(1.2);
  grproton->SetMarkerColor(4);
  grproton->Draw("P");

  TLegend *leg1 = new TLegend(0.60,0.58,0.90,0.88);
  leg1->SetFillColor(10);
  leg1->SetLineStyle(4000);
  leg1->SetLineColor(10);
  leg1->SetLineWidth(0.);
  leg1->SetTextSize(0.05);
  leg1->SetBorderSize(0);
  leg1->AddEntry(grpion,"0~5%","");
  leg1->AddEntry(grpion,"pion","P");
  leg1->AddEntry(grkaon,"kaon","P");
  leg1->AddEntry(grproton,"proton","P");
  leg1->Draw();

}
예제 #10
0
void higgs_hlt87(){

  float x[16], ex[16];
  float x2[18], ex2[18];
  float x3[19], ex3[19];

  TFile *_fileggh[19];
  _fileggh[0] = TFile::Open("ggh_m60_8TeV/output.root"); 
  _fileggh[1] = TFile::Open("ggh_m65_8TeV/output.root"); 
  _fileggh[2] = TFile::Open("ggh_m70_8TeV/output.root"); 
  _fileggh[3] = TFile::Open("ggh_m75_8TeV/output.root"); 
  _fileggh[4] = TFile::Open("ggh_m80_8TeV/output.root"); 
  _fileggh[5] = TFile::Open("ggh_m85_8TeV/output.root"); 
  _fileggh[6] = TFile::Open("ggh_m90_8TeV/output.root");
  _fileggh[7] = TFile::Open("ggh_m95_8TeV/output.root");
  _fileggh[8] = TFile::Open("ggh_m100_8TeV/output.root");
  _fileggh[9] = TFile::Open("ggh_m105_8TeV/output.root");
  _fileggh[10] = TFile::Open("ggh_m110_8TeV/output.root");
  _fileggh[11] = TFile::Open("ggh_m115_8TeV/output.root");
  _fileggh[12] = TFile::Open("ggh_m120_8TeV/output.root");
  _fileggh[13] = TFile::Open("ggh_m125_8TeV/output.root");
  _fileggh[14] = TFile::Open("ggh_m130_8TeV/output.root");
  _fileggh[15] = TFile::Open("ggh_m135_8TeV/output.root");
  _fileggh[16] = TFile::Open("ggh_m140_8TeV/output.root");
  _fileggh[17] = TFile::Open("ggh_m145_8TeV/output.root");
  _fileggh[18] = TFile::Open("ggh_m150_8TeV/output.root");
  
  TFile *_filetth[19];
  _filetth[0] = TFile::Open("tth_m60_8TeV/output.root"); 
  _filetth[1] = TFile::Open("tth_m65_8TeV/output.root"); 
  _filetth[2] = TFile::Open("tth_m70_8TeV/output.root"); 
  _filetth[3] = TFile::Open("tth_m75_8TeV/output.root"); 
  _filetth[4] = TFile::Open("tth_m80_8TeV/output.root"); 
  _filetth[5] = TFile::Open("tth_m85_8TeV/output.root"); 
  _filetth[6] = TFile::Open("tth_m90_8TeV/output.root");
  _filetth[7] = TFile::Open("tth_m95_8TeV/output.root");
  _filetth[8] = TFile::Open("tth_m100_8TeV/output.root");
  _filetth[9] = TFile::Open("tth_m105_8TeV/output.root");
  _filetth[10] = TFile::Open("tth_m110_8TeV/output.root");
  _filetth[11] = TFile::Open("tth_m115_8TeV/output.root");
  _filetth[12] = TFile::Open("tth_m120_8TeV/output.root");
  _filetth[13] = TFile::Open("tth_m125_8TeV/output.root");
  _filetth[14] = TFile::Open("tth_m130_8TeV/output.root");
  _filetth[15] = TFile::Open("tth_m135_8TeV/output.root");
  _filetth[16] = TFile::Open("tth_m140_8TeV/output.root");
  _filetth[17] = TFile::Open("tth_m145_8TeV/output.root");
  _filetth[18] = TFile::Open("tth_m150_8TeV/output.root");

  TFile *_filevbf[19];
  _filevbf[0] = TFile::Open("vbf_m60_8TeV/output.root"); 
  _filevbf[1] = TFile::Open("vbf_m65_8TeV/output.root"); 
  _filevbf[2] = TFile::Open("vbf_m70_8TeV/output.root"); 
  _filevbf[3] = TFile::Open("vbf_m75_8TeV/output.root"); 
  _filevbf[4] = TFile::Open("vbf_m80_8TeV/output.root"); 
  _filevbf[5] = TFile::Open("vbf_m85_8TeV/output.root"); 
  _filevbf[6] = TFile::Open("vbf_m90_8TeV/output.root");
  _filevbf[7] = TFile::Open("vbf_m95_8TeV/output.root");
  _filevbf[8] = TFile::Open("vbf_m100_8TeV/output.root");
  _filevbf[9] = TFile::Open("vbf_m105_8TeV/output.root");
  _filevbf[10] = TFile::Open("vbf_m110_8TeV/output.root");
  _filevbf[11] = TFile::Open("vbf_m115_8TeV/output.root");
  _filevbf[12] = TFile::Open("vbf_m120_8TeV/output.root");
  _filevbf[13] = TFile::Open("vbf_m125_8TeV/output.root");
  _filevbf[14] = TFile::Open("vbf_m130_8TeV/output.root");
  _filevbf[15] = TFile::Open("vbf_m135_8TeV/output.root");
  _filevbf[16] = TFile::Open("vbf_m140_8TeV/output.root");
  _filevbf[17] = TFile::Open("vbf_m145_8TeV/output.root");
  _filevbf[18] = TFile::Open("vbf_m150_8TeV/output.root");

  TFile *_filewzh[19];
  _filewzh[0] = TFile::Open("wzh_m60_8TeV/output.root"); 
  _filewzh[1] = TFile::Open("wzh_m65_8TeV/output.root"); 
  _filewzh[2] = TFile::Open("wzh_m70_8TeV/output.root"); 
  _filewzh[3] = TFile::Open("wzh_m75_8TeV/output.root"); 
  _filewzh[4] = TFile::Open("wzh_m80_8TeV/output.root"); 
  _filewzh[5] = TFile::Open("wzh_m85_8TeV/output.root"); 
  _filewzh[6] = TFile::Open("wzh_m90_8TeV/output.root");
  _filewzh[7] = TFile::Open("wzh_m95_8TeV/output.root");
  _filewzh[8] = TFile::Open("wzh_m100_8TeV/output.root");
  _filewzh[9] = TFile::Open("wzh_m105_8TeV/output.root");
  _filewzh[10] = TFile::Open("wzh_m110_8TeV/output.root");
  _filewzh[11] = TFile::Open("wzh_m115_8TeV/output.root");
  _filewzh[12] = TFile::Open("wzh_m120_8TeV/output.root");
  _filewzh[13] = TFile::Open("wzh_m125_8TeV/output.root");
  _filewzh[14] = TFile::Open("wzh_m130_8TeV/output.root");
  _filewzh[15] = TFile::Open("wzh_m135_8TeV/output.root");
  _filewzh[16] = TFile::Open("wzh_m140_8TeV/output.root");
  _filewzh[17] = TFile::Open("wzh_m140_8TeV/output.root");
  _filewzh[18] = TFile::Open("wzh_m145_8TeV/output.root");

  float avEFFggh[19];
  float avEFFtth[19];
  float avEFFwzh[19];
  float avEFFvbf[19];
  float avERRggh[19];
  float avERRtth[19];
  float avERRwzh[19];
  float avERRvbf[19];

  float mass_value=55.;
  
  for(int k=0;k<19;k++){
    mass_value=mass_value+5.;
    x3[k]  = mass_value;
    ex3[k] = 0;
    avEFFggh[k] = efficiency(_fileggh[k]);
    avEFFtth[k] = efficiency(_filetth[k]);
    avEFFvbf[k] = efficiency(_filevbf[k]);
    avEFFwzh[k] = efficiency(_filewzh[k]);

    avERRggh[k] = error(_fileggh[k]);
    avERRwzh[k] = error(_filewzh[k]);
    avERRtth[k] = error(_filetth[k]);
    avERRvbf[k] = error(_filevbf[k]);
  }
 
  cout << x3[0] <<" : " << avEFFggh[0] << "------" << avERRggh[0] << endl;
  cout << x3[1] <<" : " << avEFFggh[1] << "------" << avERRggh[1] << endl;
  cout << x3[2] <<" : " << avEFFggh[2] << "------" << avERRggh[2] << endl;
  cout << x3[3] <<" : " << avEFFggh[3] << "------" << avERRggh[3] << endl;
    
  TGraphErrors * ggh = new TGraphErrors(19,x3,avEFFggh,ex3,avERRggh);
  TGraphErrors * vbf = new TGraphErrors(19,x3,avEFFvbf,ex3,avERRvbf);
  TGraphErrors * wzh = new TGraphErrors(19,x3,avEFFwzh,ex3,avERRwzh);
  TGraphErrors * tth = new TGraphErrors(19,x3,avEFFtth,ex3,avERRtth);

  ggh->SetMarkerStyle(22);ggh->SetMarkerSize(2.0); 
  vbf->SetMarkerStyle(23);vbf->SetMarkerSize(2.0); 
  wzh->SetMarkerStyle(20);wzh->SetMarkerSize(2.0); 
  tth->SetMarkerStyle(21);tth->SetMarkerSize(2.0); 

  ggh->SetMarkerColor(kRed);
  vbf->SetMarkerColor(kBlue);
  wzh->SetMarkerColor(kGreen);
  tth->SetMarkerColor(kBlack);

  tth->GetXaxis()->SetTitle("M_{H} (GeV)");  tth->GetYaxis()->SetTitle("#epsilon");
  ggh->GetXaxis()->SetTitle("M_{H} (GeV)");  ggh->GetYaxis()->SetTitle("#epsilon");
  vbf->GetXaxis()->SetTitle("M_{H} (GeV)");  vbf->GetYaxis()->SetTitle("#epsilon");
  wzh->GetXaxis()->SetTitle("M_{H} (GeV)");  wzh->GetYaxis()->SetTitle("#epsilon");
  
  TCanvas *C1 = new TCanvas("C1","Global Efficiency",200,10,1200,800);
  C1->SetFillColor(10);
  C1->Draw();
  C1->cd();

  float min=0.0;
  float max=1.0;
  ggh->SetMinimum(min);ggh->SetMaximum(max);
  vbf->SetMinimum(min);vbf->SetMaximum(max);
  wzh->SetMinimum(min);wzh->SetMaximum(max);
  tth->SetMinimum(min);tth->SetMaximum(max);
  
  ggh->Draw("AP"); 
  vbf->Draw("Psame"); 
  wzh->Draw("Psame"); 
  tth->Draw("Psame"); 

  C1->Update();

  TLegend *leg = new TLegend(0.6,0.35,0.7,0.2);
  //leg->AddEntry(glui,"gluino split-SUSY","lp");                                                                                                               
  //leg->AddEntry(stop,"stop MSSM","lp");                                                                                                                       
  leg->AddEntry(ggh,"ggh","p");
  leg->AddEntry(vbf,"vbf","p");
  leg->AddEntry(tth,"tth","p");
  leg->AddEntry(wzh,"wzh","p");
  leg->SetFillColor(0);
  leg->Draw("same");
  
  C1->SaveAs("summary87.png");

  min=0.9;
  max=1.0;
  ggh->SetMinimum(min);ggh->SetMaximum(max);
  vbf->SetMinimum(min);vbf->SetMaximum(max);
  wzh->SetMinimum(min);wzh->SetMaximum(max);
  tth->SetMinimum(min);tth->SetMaximum(max);
  
  ggh->Draw("AP"); 
  vbf->Draw("Psame"); 
  wzh->Draw("Psame"); 
  tth->Draw("Psame"); 

  C1->Update();

  TLegend *leg = new TLegend(0.6,0.35,0.7,0.2);
  //leg->AddEntry(glui,"gluino split-SUSY","lp");                                                                                                               
  //leg->AddEntry(stop,"stop MSSM","lp");                                                                                                                       
  leg->AddEntry(ggh,"ggh","p");
  leg->AddEntry(vbf,"vbf","p");
  leg->AddEntry(tth,"tth","p");
  leg->AddEntry(wzh,"wzh","p");
  leg->SetFillColor(0);
  leg->Draw("same");
  
  C1->SaveAs("summary87_0p9.png");

  min=0.7;
  max=1.0;
  
  ggh->SetMinimum(min);ggh->SetMaximum(max);
  vbf->SetMinimum(min);vbf->SetMaximum(max);
  wzh->SetMinimum(min);wzh->SetMaximum(max);
  tth->SetMinimum(min);tth->SetMaximum(max);
  
  ggh->Draw("AP"); 
  vbf->Draw("Psame"); 
  wzh->Draw("Psame"); 
  tth->Draw("Psame"); 

  C1->Update();

  TLegend *leg = new TLegend(0.6,0.35,0.7,0.2);
  leg->AddEntry(ggh,"ggh","p");
  leg->AddEntry(vbf,"vbf","p");
  leg->AddEntry(tth,"tth","p");
  leg->AddEntry(wzh,"wzh","p");
  leg->SetFillColor(0);
  leg->Draw("same");
  
  C1->SaveAs("summary87_0p7.png");

  exit(0);
}
void MakeRelDiffPlots(TProfile *MC, TProfile *DATA, TProfile *GEO, std::string nametag, TFile* outputfile_ptr){
  std::string filename;

  //=========Macro generated from canvas: c1/c1
  //=========  (Wed Jul 27 17:25:29 2016) by ROOT version5.34/25
  TCanvas *c1 = new TCanvas("c1", "c1",19,48,700,500);

  c1->Range(-0.5063291,-0.1924051,2.658228,1.010127);
  c1->SetFillColor(0);
  c1->SetBorderMode(0);
  c1->SetBorderSize(2);
  c1->SetTickx(1);
  c1->SetTicky(1);
  c1->SetLeftMargin(0.16);
  c1->SetRightMargin(0.05);
  c1->SetTopMargin(0.05);
  c1->SetBottomMargin(0.16);
  c1->SetFrameBorderMode(0);

  c1->Modified();
  c1->cd();
  c1->SetSelected(c1);

std::cout << ">>> !!! DEBUG LINE: " << "1" << " !!!" << std::endl; 

  MC->SetMarkerColor(1);
  MC->SetMarkerStyle(20);
  MC->SetMarkerSize(0.9);
  //MC->SetMinimum(0);
  //MC->SetMaximum(2);
  MC->SetEntries(2552568);
  MC->SetStats(0);
  MC->SetLineWidth(2);
  MC->GetXaxis()->SetTitle("|#font[152]{h}_{#font[52]{e}}|");
  MC->GetXaxis()->SetLabelFont(42);
  MC->GetXaxis()->SetLabelSize(0.05);
  MC->GetXaxis()->SetTitleSize(0.05);
  MC->GetXaxis()->SetTitleOffset(1.4);
  MC->GetXaxis()->SetTitleFont(42);
  MC->GetYaxis()->SetTitle("E1/E2");
  MC->GetYaxis()->SetLabelFont(42);
  MC->GetYaxis()->SetLabelSize(0.05);
  MC->GetYaxis()->SetTitleSize(0.05);
  MC->GetYaxis()->SetTitleOffset(1.4);
  MC->GetYaxis()->SetTitleFont(42);
  MC->GetZaxis()->SetLabelFont(42);
  MC->GetZaxis()->SetLabelSize(0.05);
  MC->GetZaxis()->SetTitleSize(0.05);
  MC->GetZaxis()->SetTitleFont(42);
  MC->Draw();

std::cout << ">>> !!! DEBUG LINE: " << "2" << " !!!" << std::endl; 

  GEO->SetMarkerColor(2);
  GEO->SetMarkerStyle(15);
  GEO->SetMarkerSize(0.9);
  GEO->Draw("same");

  TLegend* legend = new TLegend(0.172,0.2,0.55,0.3);
  legend->SetBorderSize(0);  // no border
  legend->SetFillStyle(0);
  legend->SetTextSize(0.04);
  legend->AddEntry(MC,"MC15c nom. geo.","P");
  legend->AddEntry(GEO,"MC15c s2984","P");
  legend->Draw("same");

  filename = "output/E1E2" + nametag + "_mc2015_s2984.png";
  c1->SaveAs(filename.c_str());

  TH1D * temp1 = MC->ProjectionX("temp1");
  TH1D * temp2 = GEO->ProjectionX("temp2");
  TH1D * h3 = new TH1D(*temp1);

  h3->Add(MC, GEO, -1, 1);
  h3->Sumw2();
  h3->Divide(MC);
  h3->GetYaxis()->SetTitle("#font[152]{d}_{#font[52]{rel}}#font[52]{E_{1/2}}");
  MC->GetYaxis()->SetTitleSize(0.02);
  h3->SetMarkerColor(1);
  h3->SetMarkerStyle(20);
  h3->SetMarkerSize(0.9);
  h3->SetMinimum(-0.05);
  h3->SetMaximum(0.25);
  h3->Draw();

  TLine *line = new TLine(0,0,2.5,0);
  line->SetLineColor(kBlack);
  line->SetLineStyle(2);
  line->Draw("same");

  filename = "output/E1E2" + nametag + "_mc2015_s2984_Diff.png";
  c1->SaveAs(filename.c_str());

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "_mc2015_s2984_Diff";
  h3->Write(filename.c_str());


  //Different formatting on the above plot for OCIP symposium talk
  h3->GetYaxis()->SetTitle("#font[52]{E_{1/2}}");
  MC->GetYaxis()->SetTitleSize(0.02);
  h3->SetMarkerColor(4);
  h3->SetMarkerStyle(20);
  h3->SetMarkerSize(1.2);
  h3->SetMinimum(-0.4);
  h3->SetMaximum(0.2);
  h3->SetStats(0);
  h3->Draw();

  line->Draw("same");

  filename = "output/E1E2" + nametag + "_mc2015_s2984_Diff_formatted.png";
  c1->SaveAs(filename.c_str());

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "_mc2015_s2984_Diff_formatted";
  h3->Write(filename.c_str());

  delete temp1;
  delete temp2;

  //Create a TGraphErrors that holds the relative difference plot (ie the same plot as above, but centered vertically at 0. And in a TGraphErrors instead of a profile, for error propagation (I guess)).
  
  double temp_x;
  double temp_y;
  std::vector<double> relDiff_x;
  std::vector<double> relDiff_y;
  std::vector<double> relDiff_y_errors;

  for(int i=0; i!=(h3->GetXaxis()->GetNbins()); i++) {
    temp_x = h3->GetBinCenter(i+1); 
    temp_y = h3->GetBinContent(i+1); 
    relDiff_x.push_back(temp_x);
    relDiff_y.push_back(temp_y);
    relDiff_y_errors.push_back(h3->GetBinError(i+1));
  }

  TGraphErrors* relDiff = new TGraphErrors(h3->GetXaxis()->GetNbins(),&relDiff_x[0], &relDiff_y[0], 0, &relDiff_y_errors[0]);
  relDiff -> Draw("APE");

//for (double element : relDiff_y_errors) {std::cout << element << std::endl;}

  relDiff->SetLineWidth(2);
  relDiff->SetMarkerColor(1);
  relDiff->SetMarkerStyle(20);
  relDiff->SetMarkerSize(1.2);
  //relDiff->SetMaximum(1);
  //relDiff->SetMinimum(-1);
  relDiff->GetXaxis()->SetTitle("|#font[152]{h}_{#font[52]{e}}|");
  relDiff->GetXaxis()->SetLabelFont(42);
  relDiff->GetXaxis()->SetLabelSize(0.05);
  relDiff->GetXaxis()->SetTitleSize(0.05);
  relDiff->GetXaxis()->SetTitleOffset(1.4);
  relDiff->GetXaxis()->SetTitleFont(42);
  relDiff->GetYaxis()->SetLabelFont(42);
  relDiff->GetYaxis()->SetLabelSize(0.05);
  relDiff->GetYaxis()->SetTitleSize(0.05);
  relDiff->GetYaxis()->SetTitleOffset(1.4);
  relDiff->GetYaxis()->SetTitleFont(42);
  relDiff->GetYaxis()->SetTitle("#font[152]{d}_{#font[52]{rel}}#font[52]{E_{1/2}}");

  TLine *line0 = new TLine(0,0,2.7,0);
  line0->SetLineColor(kBlack);
  line0->SetLineStyle(2);
  line0->Draw("same");

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "_mc2015_s2984_relDiff";
  relDiff->Write(filename.c_str());

 //Now make a plot with data and the alternate geometry
  TH1D * DATA_temp = DATA->ProjectionX("DATA_temp");
  TH1D * GEO_temp  = GEO->ProjectionX("GEO_temp");
  TH1D * h4 = new TH1D(*GEO_temp);

  DATA_temp->SetMarkerColor(2);
  DATA_temp->SetMarkerStyle(15);
  DATA_temp->SetMarkerSize(0.9);

  GEO_temp->SetMarkerColor(1);
  GEO_temp->SetMarkerStyle(15);
  GEO_temp->SetMarkerSize(0.9);
  GEO_temp->SetMinimum(0);
  GEO_temp->SetMaximum(2);
  GEO_temp->GetXaxis()->SetTitle("|#font[152]{h}_{#font[52]{e}}|");
  GEO_temp->GetYaxis()->SetTitle("#font[52]{E_{1/2}}");

  GEO_temp->Draw("PE");
  DATA_temp->Draw("PEsame");

  TLegend* legend2 = new TLegend(0.172,0.8,0.55,0.9);
  legend2->SetBorderSize(0);  // no border
  legend2->SetFillStyle(0);
  legend2->SetTextSize(0.04);
  legend2->AddEntry(GEO_temp,"MC15c s2984","P");
  legend2->AddEntry(DATA_temp,"Data 2015-16","P");
  legend2->Draw("same");

  filename = "output/E1E2" + nametag + "mc2015_s2984_both_data.png";
  c1->SaveAs(filename.c_str());

  h4->Add(GEO_temp, DATA_temp, -1, 1);
  h4->Divide(GEO_temp);
  h4->GetYaxis()->SetTitle("#font[152]{D}#font[52]{E_{1/2}^{data,s2984}}");
  //h4->GetYaxis()->SetTitleSize(0.02);
  h4->SetMarkerColor(1);
  h4->SetMarkerStyle(20);
  h4->SetMarkerSize(0.9);
  h4->SetMinimum(-0.3);
  h4->SetMaximum(0.3);
  h4->Draw();
/*
  for(int i=0; i!=GEO_temp->GetXaxis()->GetNbins(); i++) {
    std::cout << ">>> !!! DEBUG LINE: " << "GEO_temp->GetBinContent() " << GEO_temp->GetBinContent(i)  << std::endl; 
  }   
*/
  line->Draw("same");

  filename = "output/E1E2" + nametag + "mc2015_s2984_rel_data.png";
  c1->SaveAs(filename.c_str());

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "mc2015_s2984_rel_data";
  h4->Write(filename.c_str());

  delete h3;
  delete h4;
  delete DATA_temp;
  delete GEO_temp;
  delete c1;
}
예제 #12
0
v723pt_compare()
{
  gROOT->Reset();
  gROOT->SetStyle("MyStyle");
//  gROOT->LoadMacro("v2pt_12cen_MyDef.C");
  // gROOT->LoadMacro("MyDef.C");
  gStyle->SetTextFont(43);
  gStyle->SetLabelFont(43,"x");
  gStyle->SetLabelFont(43,"y");
  gStyle->SetLabelFont(43,"z");
  gStyle->SetTitleFont(43,"x");
  gStyle->SetTitleFont(43,"y");
  gStyle->SetTitleFont(43,"z");
  gStyle->SetEndErrorSize(0);

  double textsize = 19;

//int   mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray};
int   mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray};
int   mcol2[4]={6,2,4,8};

//int   msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}};
int   msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}};


//float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1};
float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6};
float msiz2[4]={1.5,1.5,1.5,1.5};
//
// arrays
//
const int Mfiles=50;
int   ndp[Mfiles];
char *cfn[Mfiles];
char *cft[Mfiles];
const int Mpoints=40;
double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints];
double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints];
double nxa[Mfiles][Mpoints],nxe[Mfiles][Mpoints];
double nya[Mfiles][Mpoints],nye[Mfiles][Mpoints];

double aexl[Mfiles][Mpoints],aexh[Mfiles][Mpoints];
double aeyl[Mfiles][Mpoints],aeyh[Mfiles][Mpoints];



double ra[Mfiles][Mpoints],re[Mfiles][Mpoints];

const int Mpads=14;


char  *htit[Mpads];
char  *atit[Mpads][3];
double ptit[Mpads][2];
double hxmin[Mpads],hxmax[Mpads];
double hymin[Mpads],hymax[Mpads];
double lxmin[Mpads],lxmax[Mpads];
double lymin[Mpads],lymax[Mpads];


 
  //
  // Data input
  //
  char *cjob="v2pt_12cen_4x3";
  int i=-1;


  // histogram parameter
  htit[0]="0-5%";
  htit[1]="5-10%";
  htit[2]="10-15%";
  htit[3]="15-20%";
  htit[4]="20-25%";
  htit[5]="25-30%";
  htit[6]="30-35%";
  htit[7]="35-40%";
  htit[8]="40-50%";
  htit[9]="50-60%";
  htit[10]="60-70%";
  htit[11]="70-80%";
  for (int ip=0;ip<Mpads;ip++)
  {
    //  hxmin[ip]=0.0; hxmax[ip]=11.9;
    hxmin[ip]=0.0001; hxmax[ip]=6.8;
    //hymin[ip]=-0.6001; hymax[ip]=4.099;
    hymin[ip]=0.48; hymax[ip]=1.52;
    lxmin[ip]=0.04; lxmax[ip]=0.15;
    lymin[ip]=0.56; lymax[ip]=0.65;
    //ptit[ip][0]=4.0; ptit[ip][1]=3.308;// position legends 
    ptit[ip][0]=4.0; ptit[ip][1]=1.168;// position legends 
    //atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="#chi_{422}";
    atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{7}{#Psi_{223}} ratio";
  }
  //
  // Read data and create vector files
  //

  double tmp;
  const int nw=12;
  const int npt=15;
  ifstream inEP;
  inEP.open("../outv723_corrFlow.txt");
  for(int i=0; i<nw; i++){
      inEP>>tmp; inEP>>tmp;
    for(int j=0; j<npt+5; j++){
      inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j];
      if(ye[i][j]<0) ye[i][j]=-ye[i][j];
      xe[i][j]=0.0;
    }
  }
  inEP.close();

  ifstream inSP;
  inSP.open("./Stevedata/mv723m.txt");
  for(int i=0; i<nw; i++){
      //inSP>>tmp; inSP>>tmp;
    for(int j=0; j<npt+3; j++){
      inSP>>nxa[i][j]; inSP>>nya[i][j]; inSP>>nye[i][j];
      nxe[i][j]=0.0;

      nya[i][j]=nya[i][j]/ya[i][j];
      nye[i][j]=ye[i][j]/ya[i][j];
    }
  }
  inSP.close();


  TCanvas *can=new TCanvas("can","can",10,10,1050*0.9,800*0.85);

  can->Divide(4,3,0,0); //sticks the pads with no space inbetween 
  
  TH1D *h1[nw];
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);
    if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02);
    char ch1[8];
    sprintf(ch1,"h1_%d",iw);
    h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]);
    h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]);
    h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]);
    h1[iw]->GetXaxis()->CenterTitle(1);
    h1[iw]->GetYaxis()->CenterTitle(1);

    // futz with the axes
    h1[iw]->GetYaxis()->SetNdivisions(606);
    h1[iw]->GetXaxis()->SetNdivisions(606);

      h1[iw]->GetYaxis()->SetTitleSize(textsize);
      h1[iw]->GetYaxis()->SetTitleOffset(3.0);
      h1[iw]->GetYaxis()->SetLabelSize(textsize);
      h1[iw]->GetXaxis()->SetTitleSize(textsize);
      h1[iw]->GetXaxis()->SetTitleOffset(3.0);
      h1[iw]->GetXaxis()->SetLabelSize(textsize);
     // h1[iw]->GetXaxis()->SetLabelOffset(1.2);

    h1[iw]->Draw();
  }
  //
  // Draw! 
  //
  cout << "Now Draw!" << endl;
  TGraphErrors *ge;
  for (int iw=0;iw<nw-2;iw++)
  {
    can->cd(iw+1);

    //
    if (iw==0)
    {
      tex=new TLatex(1.5,8.08,"CMS PbPb #sqrt{s_{NN}}=2.76TeV");
      tex->SetTextSize(textsize);
      //tex->Draw();
      tex=new TLatex(1.5,7.07,"|#eta|<0.8");
      tex->SetTextSize(textsize);
      tex->Draw();
    }
    if (iw < 4) tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
    else tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
    if ( iw == 0)   tex->SetTextSize(textsize);
    else if (iw == 8) tex->SetTextSize(textsize);
    else  tex->SetTextSize(textsize);
    tex->Draw();
    //
    // Legend
    //
    TLegend *leg = new TLegend(lxmin[iw]*3.3,lymin[iw]*1.3,lxmax[iw]*2.2,lymax[iw]*1.3);
    leg->SetTextSize(textsize);
    //
    // Read data
    //
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=1;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(16,&xa[j][0],&nya[j][0],&xe[j][0],&nye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(msty[im][1]);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"Steve/Shengquan","p");
    }
    if (iw==1) leg->Draw();
    TLine *line = new TLine(0,1,6.8,1);
    line->SetLineStyle(2);
    line->Draw();
/*
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=2;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(16,&nxa[j][0],&nya[j][0],&nxe[j][0],&nye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(25);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"Steve","p");
    }
*/
  }
  cout << "end of process" << endl;
  can->cd();
  can->Print("./figures/v723_pt_12cent.png");
  can->Print("./figures/v723_pt_12cent.pdf");
}
예제 #13
0
int main(int argc, char**argv)
{

// Set style options
	gROOT->Reset();
	gROOT->SetStyle("Plain");

	gStyle->SetPadTickX(1);
	gStyle->SetPadTickY(1);
	gStyle->SetOptTitle(0);
	gStyle->SetOptStat(0);
	gStyle->SetOptFit(0);
	gStyle->SetFitFormat("6.3g");
	gStyle->SetPalette(1);

	gStyle->SetTextFont(42);
	gStyle->SetTextSize(0.05);
	gStyle->SetTitleFont(42, "xyz");
	gStyle->SetTitleSize(0.05);
	gStyle->SetLabelFont(42, "xyz");
	gStyle->SetLabelSize(0.05);
	gROOT->ForceStyle();

/// Input File MCTruth IC Map , RECO IC map, MC IC set after calibration (Usually set with miscalibration 5%)
/// and StatPrecision IC coefficient obtained from CalibrationBarrel.cpp

	if(argc != 2) {
		std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ;
		return 1;
	}

	std::string configFileName = argv[1];
	std::shared_ptr<edm::ParameterSet> parameterSet = edm::readConfig(configFileName);
	edm::ParameterSet Options = parameterSet -> getParameter<edm::ParameterSet>("Options");

	std::string inputFile = "NULL";
	if(Options.existsAs<std::string>("inputFile"))
		inputFile = Options.getParameter<std::string>("inputFile");

	std::string fileMCTruth = "NULL";
	if(Options.existsAs<std::string>("fileMCTruth"))
		fileMCTruth = Options.getParameter<std::string>("fileMCTruth");

	std::string fileMCRecoIC = "NULL";
	if(Options.existsAs<std::string>("fileMCRecoIC"))
		fileMCRecoIC = Options.getParameter<std::string>("fileMCRecoIC");

	std::string fileStatPrecision = "NULL";
	if(Options.existsAs<std::string>("fileStatPrecision"))
		fileStatPrecision = Options.getParameter<std::string>("fileStatPrecision");

	TApplication* theApp = new TApplication("Application", &argc, argv);


	TFile *f1 = TFile::Open(fileMCTruth.c_str());
	TFile *f2 = TFile::Open(fileMCRecoIC.c_str());
	TFile *f3 = TFile::Open(inputFile.c_str());
	TFile *f4 = TFile::Open(fileStatPrecision.c_str());

	if( f1 == 0 || f2 == 0 || f3 == 0 || f4 == 0) return -1;

	TH2F *hcmapMcT = (TH2F*)f1->Get("h_scale_map");
	TH2F *hcmapMcR = (TH2F*)f2->Get("h_scale_map");

	TH2F * hcmap1 = (TH2F*)hcmapMcT->Clone("hcmap1");
	hcmap1->Reset();
	TH1F * hringdiff = new TH1F("hringdiff", "difference of ring average", 100, -0.1, 0.1);

	for (int jbin = 1; jbin < hcmap1-> GetNbinsY(); jbin++) {
		for (int ibin = 1; ibin < hcmap1-> GetNbinsX() + 1; ibin++) {
			hcmap1->SetBinContent(ibin, jbin, hcmapMcT->GetBinContent(ibin, jbin) / hcmapMcR->GetBinContent(ibin, jbin));
		}
	}


	TH2F * miscalib_map = (TH2F*) f3 -> Get("h_scalib_EB");
	TH2F *hcL3 = (TH2F*)f3->Get("h_scale_map");

	TH2F *hcmap2 = (TH2F*)hcL3 ->Clone("hcmap2");
	hcmap2->Reset();

	for (int jbin = 1; jbin < hcmap2-> GetNbinsY() + 1; jbin++) {
		for (int ibin = 1; ibin < hcmap2-> GetNbinsX() + 1; ibin++) {
			hcmap2->SetBinContent(ibin, jbin, miscalib_map->GetBinContent(ibin, jbin)*hcL3->GetBinContent(ibin, jbin));
		}
	}

/// IC Histogramm in Eta ring and 2D map difference
	TH2F * h2 = new TH2F("h2", "h2", 400, 0.5, 1.5, 400, 0.5, 1.5);
	TH2F * h2diff = (TH2F*)hcmap1->Clone("h2diff");
	h2diff->Reset();
	TH1F *hdiff = new TH1F("hdiff", "hdiff", 400, -0.5, 0.5);

	char hname[100];

	TH1F *hspread[172];
	for (int jbin = 1; jbin < hcmap1-> GetNbinsY() + 1; jbin++) {
		int etaring = hcmap1-> GetYaxis()->GetBinCenter(jbin);
		sprintf(hname, "hspread_ring_ieta%02d", etaring);
		hspread[jbin - 1] = new TH1F(hname, hname, 400, -0.5, 0.5);
	}

	for (int jbin = 1; jbin < hcmap1-> GetNbinsY() + 1; jbin++) {
		float etaring = hcmap1-> GetYaxis()->GetBinCenter(jbin);
		for (int ibin = 1; ibin < hcmap1-> GetNbinsX() + 1; ibin++) {
			float c1 = hcmap1->GetBinContent(ibin, jbin);
			float c2 = hcmap2->GetBinContent(ibin, jbin);
			if (c1 != 0 && c2 != 0 ) {
				hspread[jbin - 1]->Fill( c1 - c2 );
				h2->Fill(c1, c2);
				h2diff->SetBinContent(ibin, jbin, c1 - c2);
				if (fabs(etaring) < 40) hdiff->Fill(c1 - c2);

			}
		}
	}

/// Final Plot in eta ring (stat prescision and scale)
	TGraphErrors *sigma_vs_ieta = new TGraphErrors();
	sigma_vs_ieta->SetMarkerStyle(20);
	sigma_vs_ieta->SetMarkerSize(1);
	sigma_vs_ieta->SetMarkerColor(kBlue + 2);

	TGraphErrors *rms_vs_ieta = new TGraphErrors();
	rms_vs_ieta->SetMarkerStyle(24);
	rms_vs_ieta->SetMarkerSize(1);
	rms_vs_ieta->SetMarkerColor(kBlue + 2);

	TGraphErrors *scale_vs_ieta = new TGraphErrors();
	scale_vs_ieta->SetMarkerStyle(20);
	scale_vs_ieta->SetMarkerSize(1);
	scale_vs_ieta->SetMarkerColor(kBlue + 2);

/// Gaussian Fit of spread coefficient dstribution
	TF1 *fgaus = new TF1("fgaus", "gaus", -1, 1);
	int np = 0;
	for (int i = 1; i < hcmap1-> GetNbinsY() + 1; i++) {
		float etaring = hcmap1-> GetYaxis()->GetBinCenter(i);
		if (etaring == 0.5) continue;
		if ( hspread[i - 1]->GetEntries() == 0) {
			sigma_vs_ieta-> SetPoint(np, etaring, -100);
			np++;
			continue;
		}
		hspread[i - 1]->Fit("fgaus", "Q");
		sigma_vs_ieta-> SetPoint(np, etaring, fgaus->GetParameter(2));
		sigma_vs_ieta-> SetPointError(np, 0, fgaus->GetParError(2));
		rms_vs_ieta  -> SetPoint(np, etaring, hspread[i - 1]->GetRMS());
		rms_vs_ieta  -> SetPointError(np, 0, hspread[i - 1]->GetRMSError() );
		scale_vs_ieta-> SetPoint(np, etaring, fgaus->GetParameter(1));
		scale_vs_ieta-> SetPointError(np, 0, fgaus->GetParError(1));
		if( fabs(etaring) < 20 ) {
			hringdiff->Fill( fgaus->GetParameter(1) );
		}
		np++;
	}

	/// Final Plot
	TGraphErrors* gr_stat_prec = (TGraphErrors*) f4->Get("gr_stat_prec");
	TCanvas *csigma = new TCanvas("csigma", "csigma");
	csigma->SetGridx();
	csigma->SetGridy();
	sigma_vs_ieta->GetHistogram()->GetYaxis()-> SetRangeUser(0.00, 0.2);
	sigma_vs_ieta->GetHistogram()->GetXaxis()-> SetRangeUser(-85, 85);
	sigma_vs_ieta->GetHistogram()->GetYaxis()-> SetTitle("#sigma");
	sigma_vs_ieta->GetHistogram()->GetXaxis()-> SetTitle("ieta");
	sigma_vs_ieta->Draw("ap");
	rms_vs_ieta->Draw("psame");
	gr_stat_prec->Draw("psame");


/// Residual Plot (spread - statistical precision)
	TGraphErrors* residual = new TGraphErrors();

	for(int pp = 0; pp < gr_stat_prec->GetN(); pp++) {
		double eta1, eta2, tot, stat;
		gr_stat_prec->GetPoint(pp, eta1, stat);
		sigma_vs_ieta->GetPoint(pp, eta2, tot);
		if(eta1 != eta2) {
			cout << "error different ring " << eta1 << "  " << eta2 << endl;
		}
		double res = tot * tot - stat * stat;
		if (res > 0) res = sqrt(res);
		else res = -sqrt(fabs(res));
		double errres = sqrt( pow(tot * sigma_vs_ieta->GetErrorY(pp), 2) + pow(stat * gr_stat_prec->GetErrorY(pp), 2)) / fabs(res);
		residual->SetPoint(pp, eta1, res);
		residual->SetPointError(pp, 0, errres);
	}

/// Residual spread plot
	TCanvas *cres = new TCanvas("cres", "cresidual");
	cres->SetGridx();
	cres->SetGridy();
	residual->GetHistogram()->GetYaxis()-> SetRangeUser(-0.1, 0.1);
	residual->GetHistogram()->GetXaxis()-> SetRangeUser(-85, 85);
	residual->GetHistogram()->GetYaxis()-> SetTitle("residual");
	residual->GetHistogram()->GetXaxis()-> SetTitle("ieta");
	residual ->SetMarkerStyle(20);
	residual->SetMarkerSize(1);
	residual->SetMarkerColor(kGreen + 2);
	residual->GetYaxis()->SetTitle("residual");
	residual->GetXaxis()->SetTitle("i#eta");
	residual->Draw("ap");

/// scale vs eta plot
	TCanvas *cscale = new TCanvas("cscale", "cscale");
	cscale->SetGridx();
	cscale->SetGridy();
	scale_vs_ieta->GetHistogram()->GetYaxis()-> SetRangeUser(-0.1, 0.1);
	scale_vs_ieta->GetHistogram()->GetXaxis()-> SetRangeUser(-85, 85);
	scale_vs_ieta->GetHistogram()->GetYaxis()-> SetTitle("c_{1}-c_{2}");
	scale_vs_ieta->GetHistogram()->GetXaxis()-> SetTitle("ieta");
	scale_vs_ieta->Draw("ap");

/// IC Diff map
	TCanvas *cmap2 = new TCanvas("cmap2", "cmap2", 500, 500);
	cmap2->SetGridx();
	cmap2->SetGridy();
	cmap2 -> cd();
	cmap2->SetLeftMargin(0.1);
	cmap2->SetRightMargin(0.15);
	h2->GetXaxis()->SetRangeUser(0.85, 1.15);
	h2->GetYaxis()->SetRangeUser(0.85, 1.15);
	h2->GetXaxis()->SetTitle("C_{1}");
	h2->GetYaxis()->SetTitle("C_{2}");
	h2->Draw("colz");

	TCanvas *cdiff = new TCanvas("cdiff", "cdiff", 700, 500);
	cdiff->SetGridx();
	cdiff->SetGridy();
	cdiff -> cd();
	cdiff->SetLeftMargin(0.1);
	cdiff->SetRightMargin(0.15);
	h2diff->GetZaxis()->SetRangeUser(-0.05, 0.05);
	h2diff->GetXaxis()->SetTitle("i#phi");
	h2diff->GetYaxis()->SetTitle("i#eta");
	h2diff->Draw("colz");

	theApp->Run();

	return 0;
}
예제 #14
0
void FDC_Timing(bool save = 0){
  
  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("FDC_Efficiency");
  if(!dir) return;
  dir->cd();

  gDirectory->cd("Residuals");

  TCanvas *cWireTiming = new TCanvas("cWireTiming", "WireTiming", 1000, 800);
  cWireTiming->Divide(6,4);
  
  double cell[24];
  double cell_err[24];
  double wire[24];
  double wire_err[24];

  double cath[24];
  double cath_err[24];
    
  double delta[24];
  double delta_err[24];
    
  double pull[24];
  double pull_err[24];

  for(unsigned int icell=1; icell<=24; icell++){
    cWireTiming->cd(icell);

    cell[icell-1] = icell;
    cell_err[icell-1] = 0;
    
    char hname[256];
    sprintf(hname, "hWireTime_cell[%d]", icell);
    TH1 *hWire = (TH1*)(gDirectory->Get(hname));
      
    hWire->GetXaxis()->SetTitle("Wire Time (ns)");
    //hWire->Draw();

    int tzero_bin = hWire->GetMaximumBin();
    double tzero = hWire->GetXaxis()->GetBinCenter(tzero_bin);

    TF1 *fwire = new TF1("fwire", "gaus(0)", tzero - 10, tzero + 10);
    fwire->SetLineColor(2);
    fwire->SetNpx(600);
    fwire->SetParameter(1,tzero);
    hWire->Fit("fwire","q0r");
    wire[icell-1] = fwire->GetParameter(1);
    wire_err[icell-1] = fwire->GetParError(1);

    sprintf(hname, "hCathodeTime_cell[%d]", icell);
    TH1 *hCathode = (TH1*)(gDirectory->Get(hname));
      
    hCathode->GetXaxis()->SetTitle("Cathode Time (ns)");
    //hCathode->Draw();

    tzero_bin = hCathode->GetMaximumBin();
    tzero = hCathode->GetXaxis()->GetBinCenter(tzero_bin);
    hCathode->GetXaxis()->SetRangeUser(tzero-40,tzero+40);

    TF1 *fcath = new TF1("fcath", "gaus(0)", tzero - 20, tzero + 20);
    fcath->SetLineColor(2);
    fcath->SetNpx(600);
    fcath->SetParameter(1,tzero);
    hCathode->Fit("fcath","qr");
    cath[icell-1] = fcath->GetParameter(1);
    cath_err[icell-1] = fcath->GetParError(1);

    sprintf(hname, "hDeltaTime_cell[%d]", icell);
    TH1 *hDelta = (TH1*)(gDirectory->Get(hname));
      
    hDelta->GetXaxis()->SetTitle("Wire Time - Cathode Time (ns)");
    hDelta->Draw();

    tzero_bin = hDelta->GetMaximumBin();
    tzero = hDelta->GetXaxis()->GetBinCenter(tzero_bin);

    TF1 *fdelta = new TF1("fdelta", "gaus(0)", tzero - 5, tzero + 5);
    fdelta->SetLineColor(2);
    fdelta->SetNpx(600);
    fdelta->SetParameter(1,tzero);
    hDelta->Fit("fdelta","qr");
    delta[icell-1] = fdelta->GetParameter(1);
    delta_err[icell-1] = fdelta->GetParError(1);

    sprintf(hname, "hPullTime_cell[%d]", icell);
    TH1 *hPull = (TH1*)(gDirectory->Get(hname));

    hPull->GetXaxis()->SetTitle("Pseudo Time (from pull) (ns)");
    //hPull->Draw();

    tzero_bin = hPull->GetMaximumBin();
    tzero = hPull->GetXaxis()->GetBinCenter(tzero_bin);
    hPull->GetXaxis()->SetRangeUser(tzero-10,tzero+10);

    TF1 *fpull = new TF1("fpull", "gaus(0)", tzero - 5, tzero + 3);
    fpull->SetLineColor(2);
    fpull->SetNpx(600);
    fpull->SetParameter(1,tzero);
    hPull->Fit("fpull","q0r");
    pull[icell-1] = fpull->GetParameter(1);
    pull_err[icell-1] = fpull->GetParError(1);

  }
  
  TCanvas *cTiming = new TCanvas("cTiming", "Timing", 1400, 1000);
  cTiming->Divide(2,2);
  cTiming->cd(1);
  
  TGraphErrors *gWireTiming = new TGraphErrors(24, cell, wire, cell_err, wire_err);
  gWireTiming->SetTitle("; Cell # ; Wire Timing (ns)");
  gWireTiming->SetMarkerColor(1);
  gWireTiming->SetMarkerStyle(8);
  gWireTiming->Draw("AP");

  cTiming->cd(2);
  TGraphErrors *gCathTiming = new TGraphErrors(24, cell, cath, cell_err, cath_err);
  gCathTiming->SetTitle("; Cell # ; Cathode Timing (ns)");
  gCathTiming->SetMarkerColor(2);
  gCathTiming->SetMarkerStyle(8);
  gCathTiming->Draw("AP");

  cTiming->cd(3);
  TGraphErrors *gDelta = new TGraphErrors(24, cell, delta, cell_err, delta_err);
  gDelta->SetTitle("; Cell # ; Wire - Cathode Timing (ns)");
  gDelta->SetMarkerColor(4);
  gDelta->SetMarkerStyle(8);
  gDelta->Draw("AP");

  cTiming->cd(4);
  TGraphErrors *gPull = new TGraphErrors(24, cell, pull, cell_err, pull_err);
  gPull->SetTitle("; Cell # ; Pseudo Time from Pull (ns)");
  gPull->SetMarkerColor(6);
  gPull->SetMarkerStyle(8);
  gPull->Draw("AP");
}
예제 #15
0
파일: Fit.C 프로젝트: zhangzc11/CPTV
void Fit()
{  
  TH1::AddDirectory(kFALSE);  /* Without this fitted histogram will be lost after return */
  //gStyle->SetStatH(0.5);
  //gStyle->SetStatW(0.6);
  //gROOT->ProcessLine(".L CapT.C");

  TF1 HCapT_F("HCapT", CapT, 0, 1500e-6, 3);

  HCapT_F.SetParNames  ("N", "LambdaCap","FlatBkg");

  HCapT_F.SetParLimits( 2, 0, 10000);

  //  TFile f("EH1_AD1.root");
  //  h->Fit("HCapT","","",5e-6,800e-6);
  //  return;

  const int TotalNo = 7;

  string file[7] = {
    "../01_MakeHisto/ForBi214/EH0_AD1.root",
    "../01_MakeHisto/Bi214/EH1_AD1.root",
    "../01_MakeHisto/Bi214/EH1_AD2.root",
    "../01_MakeHisto/Bi214/EH2_AD1.root",
    "../01_MakeHisto/Bi214/EH3_AD1.root",
    "../01_MakeHisto/Bi214/EH3_AD2.root",
    "../01_MakeHisto/Bi214/EH3_AD3.root"
  };

  string title[7] = {
    "EH0_AD1",
    "EH1_AD1",
    "EH1_AD2",
    "EH2_AD1",
    "EH3_AD1",
    "EH3_AD2",
    "EH3_AD3"
  };

  TH1F* h[7];  /* Fit result */
  double x[7];
  double x_e[7] = {0,0,0,0,0,0,0};
  double LambdaCap[7], LambdaCap_e[7];
  double Background[7], Background_e[7];

  for( int AdNo = 0; AdNo<TotalNo; AdNo++ )  {

    cout<<file[AdNo]<<endl;

    TFile f( file[AdNo].c_str() );
    h[AdNo] = (TH1F*)f.Get("h");

    HCapT_F.SetParameters(0.02, 4700     ,1);
    h[AdNo]->Fit("HCapT","L","",5e-6,1500e-6);

    x[AdNo]         = AdNo;

    LambdaCap[AdNo]   = HCapT_F.GetParameter(1);
    LambdaCap_e[AdNo] = HCapT_F.GetParError(1);
    
    Background[AdNo]  = HCapT_F.GetParameter(2);
    Background_e[AdNo]= HCapT_F.GetParError(2);
    f.Close();
  }
  
  for( int AdNo = 0; AdNo<TotalNo; AdNo++ )  {
    
    TCanvas* c = new TCanvas(file[AdNo].c_str(),file[AdNo].c_str());
    c->SetLogy();
    h[AdNo]->GetXaxis()->SetTitle("Capture time [s]");
    h[AdNo]->GetYaxis()->SetTitle("Entries / 3e-6 s");
    h[AdNo]->GetYaxis()->SetTitleOffset(1.2);
    h[AdNo]->SetTitle( title[AdNo].c_str() );
    h[AdNo]->SetName( title[AdNo].c_str() );
    h[AdNo]->Draw("E");
    
    cout<<"LambdaCap: "<<LambdaCap[AdNo]<<"+/-"<<LambdaCap_e[AdNo]
	<<"\t Background: "<<Background[AdNo]<<"+/-"<<Background_e[AdNo]<<endl;

    c->Print( (title[AdNo]+".ps").c_str() );
  }

  /* Calculate average with the first 3 ADs */
  double LambdaCap_ave = 0, LambdaCap_ttl_w = 0; 
  double LambdaCap_ave_err;
  double w;
  for( int AdNo = 1; AdNo<=6; AdNo++ )  {

    w = (1/LambdaCap_e[AdNo])*(1/LambdaCap_e[AdNo]);
    LambdaCap_ttl_w += w;
    LambdaCap_ave += LambdaCap[AdNo] * w;
  }
  LambdaCap_ave = LambdaCap_ave/LambdaCap_ttl_w;
  LambdaCap_ave_err = sqrt(1/LambdaCap_ttl_w);

  cout<<"Average: "<<endl;
  cout<<"LambdaCap: "<<LambdaCap_ave<<" +- "<<LambdaCap_ave_err<<endl;
  

  TGraphErrors* gLambdaCap = new TGraphErrors(TotalNo-1,&x[1],&LambdaCap[1],&x_e[1],&LambdaCap_e[1]);
  gLambdaCap->SetTitle("LambdaCap");
  gLambdaCap->SetMarkerColor(4);
  gLambdaCap->SetMarkerStyle(21);
  TCanvas* cLambdaCap = new TCanvas;
  gLambdaCap->GetXaxis()->SetTitle("Ad Number");
  gLambdaCap->GetYaxis()->SetTitle("1/Capture time [1/s]");
  gLambdaCap->GetYaxis()->SetTitleOffset(1.3);
  gLambdaCap->Draw("ALP");
  cLambdaCap->Print("LambdaCap.ps");
}
예제 #16
0
파일: drawAvsB.C 프로젝트: miquork/jecsys
// Determine sensitivity to tracker dynamic inefficiency
// by studying ratio of jet responses in Runs G and F (and BCD / F, E / F)
void drawAvsB() {

  setTDRStyle();

  string epocha = "BCD";//"BCD";//"H";//"F";//"BCD";//"F";//"E";//"BCD";//"F";
  string epochb = "GH";//"G";//"BCD";//"G";//"E";//"E";//"F";//"G";

  // Add the rest as well
  string epocha2 = "";//"EF";
  string epochb2 = "";//"G";

  string type = "data";

  vector<string> methods;
  methods.push_back("mpfchs1");
  methods.push_back("ptchs");
  bool nozjptb = false;
  bool nogjmpf = false;
  bool nogjptb = true;
  bool mjvsjes = false;
  
  vector<string> samples;
  samples.push_back("zeejet");
  samples.push_back("zmmjet");
  samples.push_back("gamjet");
  //samples.push_back("multijet");

  cout << "draw"<<epocha<<"vs"<<epochb<<endl;
  const char *ct = type.c_str();
  const char *pa = epocha.c_str();
  const char *pb = epochb.c_str();

  const char *pa2 = epocha2.c_str();
  const char *pb2 = epochb2.c_str();

  TFile *fg = new TFile(Form("rootfiles/jecdata%s.root",pb),"READ");
  assert(fg && !fg->IsZombie());

  TFile *ff = new TFile(Form("rootfiles/jecdata%s.root",pa),"READ");
  assert(ff && !ff->IsZombie());

  TFile *fg2(0), *ff2(0);
  if (epochb2!="") fg2 = new TFile(Form("rootfiles/jecdata%s.root",pb2),"READ");
  if (epocha2!="") ff2 = new TFile(Form("rootfiles/jecdata%s.root",pa2),"READ");

  TH1D *h = new TH1D("h",
		     Form(";p_{T,ref} (GeV);%s ratio (%s / %s)",
			  (type=="ratio" ? "Data/MC" :
			   type=="data" ? "Data/data" : "MC/MC"),
			  (epocha + (epocha2!="" ? "+"+epocha2 : "")).c_str(),
			  (epochb + (epochb2!="" ? "+"+epochb2 : "")).c_str()),
		     3470,30,3500);
  h->SetMinimum(0.90);
  h->SetMaximum(1.15);
  h->GetXaxis()->SetMoreLogLabels();
  h->GetXaxis()->SetNoExponent();

  if (epocha=="F" && epochb=="G")
    lumi_13TeV = "Run2016F+G, 3.1+7.1 fb^{-1}";
  if (epocha=="BCD" && epochb=="G")
    lumi_13TeV = "Run2016BCD+H, 12.9+8.8 fb^{-1}";
  if (epocha=="BCD" && epochb=="G")
    lumi_13TeV = "Run2016BCD+FearlyGH, 12.9+16.8 fb^{-1}";
  if (epocha=="BCD" && epochb=="F")
    lumi_13TeV = "Run2016BCD+F, 13+3.1 fb^{-1}";
  if (epocha=="BCD" && epochb=="E")
    lumi_13TeV = "Run2016BCD+E, 13+4.0 fb^{-1}";
  if (epocha=="E" && epochb=="F")
    lumi_13TeV = "Run2016E+F, 4.0+3.1 fb^{-1}";
  if (epocha=="F" && epochb=="E")
    lumi_13TeV = "Run2016E+F, 4.0+3.1 fb^{-1}";

  if ((epocha=="BCDEF" && epochb=="GH") ||
      (epocha=="BCD" && epocha2=="EF" && epochb=="H" && epochb2=="G")) 
    lumi_13TeV = "Run2016BCDEF+GH, 19.7+16.8 fb^{-1}";
  if (epocha=="EF" && epochb=="BCD")
    lumi_13TeV = "Run2016BCD+EF, 12.9+6.8 fb^{-1}";
  if (epocha=="H" && epochb=="G")
    lumi_13TeV = "Run2016G+H, 8.0+8.8 fb^{-1}";

  if ((epocha=="BCD" && epocha2=="EF" && epochb=="G" && epochb2=="H")) 
    lumi_13TeV = "Run2016BCDFearly+FlateGH, 19.7+16.8 fb^{-1}";

  if ((epocha=="BCD" && epocha2=="" && ((epochb=="GH" && epochb2=="") ||
					(epochb=="G" && epochb2=="H"))))
    lumi_13TeV = "Run2016BCD+FlateGH, 12.9+16.8 fb^{-1}";
  if ((epocha=="EF" && epocha2=="" && ((epochb=="GH" && epochb2=="") ||
				       (epochb=="G" && epochb2=="H"))))
    lumi_13TeV = "Run2016EF+FlateGH, 6.8+16.8 fb^{-1}";

  if ((epocha=="EF" && epocha2=="" && epochb=="G" && epochb2=="H")) 
    lumi_13TeV = "Run2016EFearly+FlateGH, 6.8+16.8 fb^{-1}";


  TCanvas *c1 = tdrCanvas("c1",h,4,11,true);
  c1->SetLogx();

  TLatex *tex = new TLatex();
  tex->SetNDC(); tex->SetTextSize(0.045);

  TMultiGraph *mg = new TMultiGraph();
  string s = "draw"+epocha+(epocha2!="" ? "p" + epocha2 : "")
    +"vs"+epochb+(epochb2!="" ? "p" + epochb2 : "");

  TGraphErrors *gmjb(0), *gmpf(0);

  for (unsigned int im = 0; im != methods.size(); ++im) {
    const char *cm = methods[im].c_str();

    tex->DrawLatex(0.20,0.75-0.06*im,cm);
    s += "_" + methods[im];

  for (unsigned int is = 0; is != samples.size(); ++is) {

    const char *cs = samples[is].c_str();
    TGraphErrors *gg = (TGraphErrors*)fg->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
    cout << cm << " " << cs << endl << flush;
    assert(gg);
    if (fg2) {
      TGraphErrors *gg2 = (TGraphErrors*)fg2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
      assert(gg2);
      gg = addGraph(gg,gg2);
    }
    
    TGraphErrors *gf = (TGraphErrors*)ff->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
    assert(gf);
    if (ff2) {
      TGraphErrors *gf2 = (TGraphErrors*)ff2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
      assert(gf2);
      gf = addGraph(gf,gf2);
    }
    
    if (!(gf->GetN()==gg->GetN())) {

      // Remove highest pT point is that is the offender (BCD vs GH)
      if (gg->GetN()>gf->GetN() &&
	  fabs(gg->GetX()[gg->GetN()-1]/gf->GetX()[gf->GetN()-1]-1)>0.1 &&
	  fabs(gg->GetX()[gg->GetN()-2]/gf->GetX()[gf->GetN()-1]-1)<0.1) {
	cout << "Remove point B(N-1)" << endl;
	gg->RemovePoint(gg->GetN()-1);
      }
      else {
	cout << "sample " << samples[is] << " method " << methods[im]
	     << " gf->N: " << gf->GetN() << " gg->N: " << gg->GetN() << endl;
	cout << " x_gf(N-1)=" << gf->GetX()[gf->GetN()-1]
	     << " x_gg(N-1)=" << gg->GetX()[gg->GetN()-1]
	     << " x_gg(N-2)=" << gg->GetX()[gg->GetN()-2] << endl;
      }

      assert(gf->GetN()==gg->GetN());
    }

    TGraphErrors *g = (TGraphErrors*)gg->Clone(Form("ge_%s_%s",cm,cs));
    for (int i = 0; i != g->GetN(); ++i) {
      double yg = gg->GetY()[i];
      double yf = gf->GetY()[i];
      g->SetPoint(i, gg->GetX()[i], yf / yg);
      double ex = gg->GetEX()[i];
      double eg = gg->GetEY()[i];
      double ef = gf->GetEY()[i];
      g->SetPointError(i, ex, yf/yg*sqrt(pow(eg/yg,2)+pow(ef/yf,2)));
    }
    //g->Draw(is==0 ? "AP" : "SAMEP");
    g->SetLineWidth(1+is);
    g->Draw("SAMEPZ");

    if (samples[is]=="gamjet" && methods[im]=="mpfchs1" && nogjmpf) {
      tex->SetTextColor(kBlue);
      tex->DrawLatex(0.20,0.63,"#gamma+jet MPF excl. from fit");
      tex->SetTextColor(kBlack);
    }
    else if (samples[is]=="gamjet" && methods[im]=="ptchs" && nogjptb) {
      tex->SetTextColor(kBlue);
      tex->DrawLatex(0.20,0.63,"#gamma+jet p_{T}^{bal} excl. from fit");
      tex->SetTextColor(kBlack);
    }
    else if ((samples[is]=="zmmjet" || samples[is]=="zeejet") &&
	     methods[im]=="ptchs" && nozjptb) {
      tex->SetTextColor(kRed);
      tex->DrawLatex(0.20,0.63,"Z+jet p_{T}^{bal} excl. from fit");
      tex->SetTextColor(kBlack);
    }
    else if (samples[is]=="multijet") {
      g->SetMarkerColor(kGray+1);
      g->SetLineColor(kGray+1);
      if (methods[im]=="ptchs") gmjb = g;
      if (methods[im]=="mpfchs1") gmpf = g;
    }
    else
      mg->Add(g);
  } // for is
  } // for im
  
  if (nogjmpf) s += "_nogjmpf";
  if (nogjptb) s += "_nogptb";
  if (nozjptb) s += "_nozptb";
  if (mjvsjes) {
    s += "_mjvsjes";
    tex->SetTextColor(kBlack);
    tex->DrawLatex(0.20,0.58,"Multijet vs JES fit");
  }

  TF1 *fjes = new TF1("fjes",jesFit,30,2200,2);
  fjes->SetParameters(0.99,0.05);
  mg->Fit(fjes,"RN");
  fjes->SetLineColor(kBlack);
  fjes->SetLineStyle(kDashed);
  fjes->SetLineWidth(2);
  fjes->SetRange(10.,3500.);
  fjes->Draw("SAME");
  
  //TF1 *ft = new TF1("ft","1-[0]-[1]*pow(x,[2]) + ([3]+[4]*log(x))/x",30,2200);
  //ft->SetParameters(0,0.05,-0.5,1,0.1);
  //ft->FixParameter(3,0);

  // Logarithmic sigmoid
  //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-log(abs([1])))"
  //	       "/(log(abs([2])+abs([1]))-log(abs([1])))))", 30,2200);
  //ft->SetParameters(0.98, 150, 50);
  TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))",30,2200);
  //ft->SetParameters(0.98,log(145),log(190)-log(145));
  //ft->SetParameters(0.982,4.967,0.271);
  //ft->SetParameters(0.976,5.040,0.370); // ENDCAP
  //ft->SetParameters(0.985,5.0,0.3);
  ft->SetParameters(0.985,5.025,0.3);
  //ft->FixParameter(1,5.03); // semi-weighted average of BCD and EF
  //ft->FixParameter(2,0.395); // combined fit to BCD+EF / G+H 

  // ( 12.9*5.055+6.8*5.000)/(12.9+6.8)
  ft->FixParameter(1,5.036); // semi-weighted average of BCD/GH and EF/GH
  // ( 12.9*0.344 + 6.8*0.455)/(12.9+6.8)
  ft->FixParameter(2,0.391); // combined fit to BCD+EF / GH 

  // Log-sigmoid + powerlaw
  //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))"
  //	       "*(1-[3]*pow(x,[4]))",30,2200);
  //ft->SetParameters(0.982,4.967,0.271,0.1,-0.2);
  // Double powerlaw
  //TF1 *ft = new TF1("ft","[4]-[0]*pow(x,[1])-[2]*pow(x,[3])",30,2200);
  //ft->SetParameters(0.05,-0.15,0.01,-0.3,1);
  

  mg->Fit(ft,"RN");
  ft->SetLineColor(kBlue);
  ft->SetLineWidth(2);
  ft->SetRange(10.,3500.);
  ft->Draw("SAME");

  // Map multijet with response ratio
  if (gmpf) { // we have multijet available
    TGraphErrors *gmpf2 = (TGraphErrors*)gmpf->Clone("gmpf2");
    gmpf2->SetMarkerColor(kBlack);//kGray+1);
    gmpf2->SetLineColor(kBlack);//kGray+1);
    for (int i = 0; i != gmpf->GetN(); ++i) {
      if (mjvsjes) {
	gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i],
			fjes->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]);
	gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i],
			     gmpf->GetEY()[i]);
      }
      else {
	gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i],
			ft->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]);
	gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i],
			     gmpf->GetEY()[i]);
      }
    }
    gmpf2->Draw("SAMEPz");
  } // multijet

  tex->SetTextColor(kBlue);
  tex->DrawLatex(0.50,0.85,Form("#chi^{2} / NDF = %1.1f / %d",
				ft->GetChisquare(),
				ft->GetNDF()));
  tex->SetTextColor(kBlack);
  tex->SetTextSize(0.040);
  tex->DrawLatex(0.50,0.80,Form("(#chi^{2} / NDF = %1.1f / %d)",
				fjes->GetChisquare(),
				fjes->GetNDF()));


  tex->SetTextColor(kBlue-9);
  tex->SetTextSize(0.030);
  tex->DrawLatex(0.20,0.25,ft->GetExpFormula());
  tex->DrawLatex(0.20,0.20,
		 Form("p_{0}=%1.3f#pm%1.3f"
		      ", p_{1}=%1.3f#pm%1.3f"
		      ", p_{2}=%1.3f#pm%1.3f",
		      ft->GetParameter(0),ft->GetParError(0),
		      ft->GetParameter(1),ft->GetParError(1),
		      ft->GetParameter(2),ft->GetParError(2)));
  if (ft->GetNpar()>3)
    tex->DrawLatex(0.20,0.17,
		   Form("p_{3}=%1.3f#pm%1.3f"
			", p_{4}=%1.3f#pm%1.3f",
			ft->GetParameter(3),ft->GetParError(3),
			ft->GetParameter(4),ft->GetParError(4)));

  c1->SaveAs(Form("pdf/%s.pdf",s.c_str()));

  for (int i = 0; i != ft->GetNpar(); ++i) {
    cout << Form("%s%1.4g",i==0 ? "{" : ", ",ft->GetParameter(i));
  }
  cout << "}" << endl;
    

}
예제 #17
0
void CalibrationFit(){
  gStyle->SetOptFit(0000);

  Int_t nbins = 7;
/*
  Double_t energy[7] = {88.0336, 122.1,  356.0,  511.0,  662.0,  835.0,   1173.0};
  Double_t energyError[7] = {0.0,     0.0,    0.0,    0.0,    0.0,    0.0,     0.0};
  Double_t channel[7] = {1206.0,  1690.0, 4778.0, 6691.0, 8514.0, 10616.0, 14798.0};
  Double_t channelError[7] = {79.0,    66.0,   176.0,  214.0,  241.0,  266.0,   319.0}; 
*/

  Double_t energy[7] = {0.384, 0.356,1.275,0.511,0.662,1.333,1.173};
  Double_t energyError[7] = {0.0,     0.0,    0.0,    0.0,    0.0,    0.0,     0.0};
  Double_t channel[7] = {4209.0, 3608.0, 14310.0,5956.0, 7644.0, 14880.0, 13220.0};
  Double_t channelError[7] = {1.7,9.7,5.387,1.6,1.5,12.94,12.79};

  // histogram parameters
  Int_t ntbin = 16384;       // number of total bins in the data
  Int_t nbin = 16384;       // number of  bins in the final plot

  TCanvas *myc4 =new TCanvas("myc4","Fit");

  // book histogram
  TGraphErrors *graphCalib = new TGraphErrors(nbins, energy, channel, energyError, channelError);

	/*
  graphCalib->SetXTitle("Energy");
  graphCalib->SetYTitle("Channel Number");
	*/

  //fitting
  Double_t par[1];  //par[0]= peak, par[1]=mean, par[2]=width, par[3]->par[6] for poly

  //define fit
//  TF1 *fit1 = new TF1("fit1",GaussPoly, 4000.,10000.,7); // range & number of parameters 
  TF1 *fit1 = new TF1("fit1",Pol1, 2000.,8000.,7); // range & number of parameters 
  fit1 ->SetParameters(0.0, .1); 
  fit1->SetLineWidth(1);
  fit1->SetLineColor(kGreen);	
  Double_t xl1=0.;
  Double_t xh1=1300;
//  hist3  ->Fit("fit1","R"," ",xl1,xh1);
//  hist3->Draw();
  graphCalib->Fit(fit1,"R"," ",xl1,xh1);
  graphCalib->SetMarkerColor(4);
  graphCalib->SetLineColor(4);
  graphCalib->SetMarkerStyle(20);
  graphCalib->SetMarkerSize(0.5);

  Double_t Intercept = fit1->GetParameter(0);
  Double_t Slope     = fit1->GetParameter(1);

  graphCalib->Draw("AP");

  /*
  graphCalib->GetParameters(&par[0]);

  Double_t Intercept=par[0];
  Double_t Slope=par[1];
  */

  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextFont(1);
  text->SetTextColor(kRed);

  char tex[100];
  
  text->SetTextSize(0.045);
  sprintf(tex,"Intercept: %2.1f \n",Intercept);
  text->DrawLatex(0.15, 0.7, tex);
  sprintf(tex,"Slope: %3.1f \n",Slope);
  text->DrawLatex(0.15, 0.8, tex);
 

  }
예제 #18
0
void plot_cent_allQQ(bool isPaper=false)
{
  gStyle->SetOptFit(0);
  gStyle->SetOptStat(0);

  // incl. and prompt J/psi
  // 0-100, 0-10, 10-20, 20-30, 30-40, 40-50, 50-100
  double promptTAA[] = {5.6625, 23.1857, 14.4777, 8.7830, 5.0892, 2.7484, 0.4682};
  double promptTAAError[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

  double promptNpart[] = {113.0518, 355.3528, 261.4178, 187.1470, 129.9835, 86.2622, 22.0709};
  double promptNpartError[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

  double promptNcoll[] = {362.4007, 1483.8875, 926.5725, 562.1105, 325.7105, 175.8948, 29.9663};
  double promptNcollError[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
  double promptrelCentBinWidth[] = {10.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.0};


  // Upsilon
  // 0-100, 0-10, 10-20, 20-100
  double upsTAA[] = {5.6625, 23.1857, 14.4777, 2.3702};
  double upsTAAError[] = {0.0, 0.0, 0.0, 0.0};

  double upsNpart[] = {113.0518, 355.3528, 261.4178, 64.2184};
  double upsNpartError[] = {0.0, 0.0, 0.0, 0.0};

  double upsNcoll[] = {362.4007, 1483.8875, 926.5725, 151.6934};
  double upsNcollError[] = {0.0, 0.0, 0.0, 0.0};
  double upsrelCentBinWidth[] = {10.0, 1.0, 1.0, 8.0};

  // non-prompt J/psi
  // 0-100, 0-20, 20-100
  double nonPromptTAA[] = {5.6625, 18.8317, 2.3702};
  double nonPromptTAAError[] = {0.0, 0.0, 0.0};

  double nonPromptNpart[] = {113.0518, 308.3853, 64.2184};
  double nonPromptNpartError[] = {0.0, 0.0, 0.0};

  double nonPromptNcoll[] = {362.4007, 1205.2300, 151.6934};
  double nonPromptNcollError[] = {0.0, 0.0, 0.0};
  double nonPromptrelCentBinWidth[] = {10.0, 2.0, 8.0};

  double promptSystX[] = {10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0};
  double nonPromptSystX[] = {10.0, 10.0, 10.0, 10.0, 10.0};
  double upsSystX[] = {10.0, 10.0, 10.0, 10.0, 10.0};

  
  double inclJpsiCent[] = {2.41, 1.78, 1.93, 2.37, 3.73, 5.23, 4.67};
  double inclJpsiCentError[] = {0.15, 0.20, 0.24, 0.33, 0.53, 0.81, 0.80};
  double inclJpsiCentSyst[] = {0.37, 0.28, 0.30, 0.37, 0.62, 0.93, 0.97};  

  double promptJpsiCent[] = {1.79, 1.18, 1.29, 2.18, 2.97, 3.88, 3.58};
  double promptJpsiCentError[] = {0.13, 0.17, 0.21, 0.33, 0.49, 0.75, 0.70};
  double promptJpsiCentSyst[] = {0.28, 0.18, 0.20, 0.34, 0.50, 0.69, 0.74};
    

  double inclJpsiCent2[] = {2.41, 1.84, 3.46};
  double inclJpsiCent2Error[] = {0.15, 0.15, 0.26};
  double inclJpsiCent2Syst[] = {0.37, 0.28, 0.57};

  double promptJpsiCent2[] = {1.79, 1.23, 2.85};
  double promptJpsiCent2Error[] = {0.13, 0.14, 0.25};
  double promptJpsiCent2Syst[] = {0.28, 0.18, 0.47};

  double nonPromptJpsiCent[] = {0.60, 0.59, 0.60};
  double nonPromptJpsiCentError[] = {0.09, 0.12, 0.14};
  double nonPromptJpsiCentSyst[] = {0.09, 0.10, 0.10};
  
  double upsCent[] = {0.485, 0.347, 0.643, 0.517};
  double upsCentError[] = {0.066, 0.096, 0.144, 0.101};
  double upsCentSyst[] = {0.089, 0.069, 0.118, 0.101};

  double upsCent2[] = {0.485, 0.468, 0.517};
  double upsCent2Error[] = {0.066, 0.081, 0.101};
  double upsCent2Syst[] = {0.089, 0.094, 0.101};

  TGraphErrors *gInclJpsiCent = new TGraphErrors(7, promptNpart, inclJpsiCent, promptNpartError, inclJpsiCentError);
  TGraphErrors *gPromptJpsiCent = new TGraphErrors(7, promptNpart, promptJpsiCent, promptNpartError, promptJpsiCentError);
  TGraphErrors *gNonPromptJpsiCent = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiCent, nonPromptNpartError, nonPromptJpsiCentError);
  TGraphErrors *gUpsCent = new TGraphErrors(4, upsNpart, upsCent, upsNpartError, upsCentError);

  TGraphErrors *gInclJpsiCentSyst = new TGraphErrors(7, promptNpart, inclJpsiCent, promptSystX, inclJpsiCentSyst);
  TGraphErrors *gPromptJpsiCentSyst = new TGraphErrors(7, promptNpart, promptJpsiCent, promptSystX, promptJpsiCentSyst);
  TGraphErrors *gNonPromptJpsiCentSyst = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiCent, nonPromptSystX, nonPromptJpsiCentSyst);
  TGraphErrors *gUpsCentSyst = new TGraphErrors(4, upsNpart, upsCent, upsSystX, upsCentSyst);

  TGraphErrors *gInclJpsiCentP = new TGraphErrors(7, promptNpart, inclJpsiCent, promptNpartError, promptNpartError);
  TGraphErrors *gPromptJpsiCentP = new TGraphErrors(7, promptNpart, promptJpsiCent, promptNpartError, promptNpartError);
  TGraphErrors *gNonPromptJpsiCentP = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiCent, nonPromptNpartError, nonPromptNpartError);
  TGraphErrors *gUpsCentP = new TGraphErrors(4, upsNpart, upsCent, upsNpartError, upsNpartError);


  TGraphErrors *gInclJpsiMB = new TGraphErrors(1, promptNpart, inclJpsiCent, promptNpartError, inclJpsiCentError);
  TGraphErrors *gPromptJpsiMB = new TGraphErrors(1, promptNpart, promptJpsiCent, promptNpartError, promptJpsiCentError);
  TGraphErrors *gNonPromptJpsiMB = new TGraphErrors(1, nonPromptNpart, nonPromptJpsiCent, nonPromptNpartError, nonPromptJpsiCentError);
  TGraphErrors *gUpsMB = new TGraphErrors(1, upsNpart, upsCent, upsNpartError, upsCentError);

  TGraphErrors *gInclJpsiMBSyst = new TGraphErrors(1, promptNpart, inclJpsiCent, promptSystX, inclJpsiCentSyst);
  TGraphErrors *gPromptJpsiMBSyst = new TGraphErrors(1, promptNpart, promptJpsiCent, promptSystX, promptJpsiCentSyst);
  TGraphErrors *gNonPromptJpsiMBSyst = new TGraphErrors(1, nonPromptNpart, nonPromptJpsiCent, nonPromptSystX, nonPromptJpsiCentSyst);
  TGraphErrors *gUpsMBSyst = new TGraphErrors(1, upsNpart, upsCent, upsSystX, upsCentSyst);  


  TGraphErrors *gInclJpsiCent2 = new TGraphErrors(3, nonPromptNpart, inclJpsiCent2, nonPromptNpartError, inclJpsiCent2Error);
  TGraphErrors *gPromptJpsiCent2 = new TGraphErrors(3, nonPromptNpart, promptJpsiCent2, nonPromptNpartError, promptJpsiCent2Error);
  TGraphErrors *gInclJpsiCent2Syst = new TGraphErrors(3, nonPromptNpart, inclJpsiCent2, nonPromptSystX, inclJpsiCent2Syst);
  TGraphErrors *gPromptJpsiCent2Syst = new TGraphErrors(3, nonPromptNpart, promptJpsiCent2, nonPromptSystX, promptJpsiCent2Syst);


  // Remove MB point
  gInclJpsiCent->RemovePoint(0);
  gPromptJpsiCent->RemovePoint(0);
  gNonPromptJpsiCent->RemovePoint(0);
  gUpsCent->RemovePoint(0);

  gInclJpsiCentP->RemovePoint(0);
  gPromptJpsiCentP->RemovePoint(0);
  gNonPromptJpsiCentP->RemovePoint(0);
  gUpsCentP->RemovePoint(0);

  gInclJpsiCentSyst->RemovePoint(0);
  gPromptJpsiCentSyst->RemovePoint(0);
  gNonPromptJpsiCentSyst->RemovePoint(0);
  gUpsCentSyst->RemovePoint(0);

  gInclJpsiCent2->RemovePoint(0);
  gPromptJpsiCent2->RemovePoint(0);
  gInclJpsiCent2Syst->RemovePoint(0);
  gPromptJpsiCent2Syst->RemovePoint(0);


  gInclJpsiCent->SetName("gInclJpsiCent");
  gPromptJpsiCent->SetName("gPromptJpsiCent");
  gNonPromptJpsiCent->SetName("gNonPromptJpsiCent");

  gInclJpsiMB->SetName("gInclJpsiMB");
  gPromptJpsiMB->SetName("gPromptJpsiMB");
  gNonPromptJpsiMB->SetName("gNonPromptJpsiMB");

  gUpsCent->SetName("gUpsCent");
  gUpsMB->SetName("gUpsMB");

  gInclJpsiCent2->SetName("gInclJpsiCent2");
  gPromptJpsiCent2->SetName("gPromptJpsiCent2");

  gInclJpsiCentP->SetName("gInclJpsiCentP");
  gPromptJpsiCentP->SetName("gPromptJpsiCentP");
  gNonPromptJpsiCentP->SetName("gNonPromptJpsiCentP");
  gUpsCentP->SetName("gUpsCentP");

  gInclJpsiCentSyst->SetName("gInclJpsiCentSyst");
  gPromptJpsiCentSyst->SetName("gPromptJpsiCentSyst");
  gNonPromptJpsiCentSyst->SetName("gNonPromptJpsiCentSyst");

  gInclJpsiMBSyst->SetName("gInclJpsiMBSyst");
  gPromptJpsiMBSyst->SetName("gPromptJpsiMBSyst");
  gNonPromptJpsiMBSyst->SetName("gNonPromptJpsiMBSyst");

  gUpsCentSyst->SetName("gUpsCentSyst");
  gUpsMBSyst->SetName("gUpsMBSyst");

  gInclJpsiCent2Syst->SetName("gInclJpsiCent2Syst");
  gPromptJpsiCent2Syst->SetName("gPromptJpsiCent2Syst");

  // gInclJpsiCentSyst->SetFillColor(kGray+1);
  // gPromptJpsiCentSyst->SetFillColor(kAzure-9);
  // gNonPromptJpsiCentSyst->SetFillColor(kRed-10);
  // gUpsCentSyst->SetFillColor(kGreen-10);
  // gInclJpsiMBSyst->SetFillColor(kGray+1);
  // gPromptJpsiMBSyst->SetFillColor(kAzure-9);
  // gNonPromptJpsiMBSyst->SetFillColor(kRed-10);
  // gUpsMBSyst->SetFillColor(kGreen-10);
  // gInclJpsiCent->SetMarkerColor(kBlack);
  // gPromptJpsiCent->SetMarkerColor(kBlue);
  // gNonPromptJpsiCent->SetMarkerColor(kRed);
  // gUpsCent->SetMarkerColor(kGreen+2);

  gInclJpsiCentSyst->SetFillColor(kAzure-9);
  gPromptJpsiCentSyst->SetFillColor(kRed-9);
  gNonPromptJpsiCentSyst->SetFillColor(kOrange-9);
  gUpsCentSyst->SetFillColor(kGreen-9);

  gInclJpsiMBSyst->SetFillStyle(0);
  gPromptJpsiMBSyst->SetFillStyle(0);
  gNonPromptJpsiMBSyst->SetFillStyle(0);
  gUpsMBSyst->SetFillStyle(0);

  gInclJpsiMBSyst->SetLineWidth(3);
  gPromptJpsiMBSyst->SetLineWidth(3);
  gNonPromptJpsiMBSyst->SetLineWidth(3);
  gUpsMBSyst->SetLineWidth(3);

  gInclJpsiMBSyst->SetLineColor(kAzure-9);
  gPromptJpsiMBSyst->SetLineColor(kRed-9);
  gNonPromptJpsiMBSyst->SetLineColor(kOrange-9);
  gUpsMBSyst->SetLineColor(kGreen-9);

  if (isPaper) {
    gInclJpsiCent->SetMarkerColor(kBlue+1);
    gPromptJpsiCent->SetMarkerColor(kRed+2);
  }
  else {
    gInclJpsiCent->SetMarkerColor(kBlue);
    gPromptJpsiCent->SetMarkerColor(kRed);
  }
  gNonPromptJpsiCent->SetMarkerColor(kOrange+2);
  gUpsCent->SetMarkerColor(kGreen+2);

  gInclJpsiCent->SetMarkerStyle(20);
  gPromptJpsiCent->SetMarkerStyle(21);
  gNonPromptJpsiCent->SetMarkerStyle(29);
  gUpsCent->SetMarkerStyle(33);

  if (isPaper) {
    gInclJpsiMB->SetMarkerColor(kBlue+1);
    gPromptJpsiMB->SetMarkerColor(kRed+2);
  }
  else {
    gInclJpsiMB->SetMarkerColor(kBlue);
    gPromptJpsiMB->SetMarkerColor(kRed);
  }

  gNonPromptJpsiMB->SetMarkerColor(kOrange+2);
  gUpsMB->SetMarkerColor(kGreen+2);

  gInclJpsiMB->SetMarkerStyle(24);
  gPromptJpsiMB->SetMarkerStyle(25);
  gNonPromptJpsiMB->SetMarkerStyle(30);
  gUpsMB->SetMarkerStyle(27);

  gInclJpsiCent->SetMarkerSize(1.2);
  gInclJpsiMB->SetMarkerSize(1.2);

  gPromptJpsiCent->SetMarkerSize(1.2);
  gPromptJpsiMB->SetMarkerSize(1.2);

  gNonPromptJpsiCent->SetMarkerSize(2.0);
  gNonPromptJpsiMB->SetMarkerSize(2.0);

  gUpsCent->SetMarkerSize(2.0);
  gUpsMB->SetMarkerSize(2.0);

  gInclJpsiCentP->SetMarkerStyle(24);
  gPromptJpsiCentP->SetMarkerStyle(25);
  gNonPromptJpsiCentP->SetMarkerStyle(30);
  gUpsCentP->SetMarkerStyle(27);

  gInclJpsiCentP->SetMarkerColor(kBlack);
  gPromptJpsiCentP->SetMarkerColor(kBlack);
  gNonPromptJpsiCentP->SetMarkerColor(kBlack);
  gUpsCentP->SetMarkerColor(kBlack);

  gInclJpsiCentP->SetMarkerSize(1.2);
  gPromptJpsiCentP->SetMarkerSize(1.2);
  gNonPromptJpsiCentP->SetMarkerSize(2.0);
  gUpsCentP->SetMarkerSize(2.0);


  TH1F *f1 = new TH1F("f1","f1",1,0,400);
  TH1F *f1l = new TH1F("f1l","f1l",1,0,400);
  f1->SetBinContent(1,9.2);
  f1l->SetBinContent(1,3.8);
  f1->SetBinError(1,0.0);
  f1l->SetBinError(1,0.0);

  f1->SetLineWidth(1);
  f1->SetLineStyle(1);
  f1->SetFillColor(kGray);
  f1->SetFillStyle(1001);
  f1l->SetLineWidth(1);
  f1l->SetLineStyle(1);
  f1l->SetFillColor(10);
  f1l->SetFillStyle(1001);
  f1->GetXaxis()->SetTitle("N_{part}");
  f1->GetYaxis()->SetTitle("1/T_{AA} dN/dy (nb)");
  f1->GetXaxis()->CenterTitle(kTRUE);
  f1->GetYaxis()->SetRangeUser(0.0, 12.0);

  TCanvas *c1 = new TCanvas("c1","c1");

  f1->Draw("HIST2");
  f1l->Draw("HIST2same");
  gInclJpsiCentSyst->Draw("2");
  gPromptJpsiCentSyst->Draw("2");
  gInclJpsiCent->Draw("P");
  gPromptJpsiCent->Draw("P");
  gInclJpsiCentP->Draw("P");
  gPromptJpsiCentP->Draw("P");

  TLegend *leg1 = new TLegend(0.22,0.56,0.90,0.76);
  leg1->SetFillStyle(1001);
  leg1->SetFillColor(10);
  leg1->SetBorderSize(0);
  leg1->SetMargin(0.2);
  leg1->SetTextSize(0.04);

  leg1->AddEntry(gInclJpsiCent,"Inclusive J/#psi","P");
  leg1->AddEntry(gPromptJpsiCent,"Prompt J/#psi","P");
  leg1->AddEntry(f1,"pp interpolation (arXiv:1103.2394)","F");
  leg1->Draw();


  TLatex *pre = new TLatex(125,11.0,"CMS Preliminary");
  pre->SetTextFont(42);
  pre->SetTextSize(0.05);
  pre->Draw();

  TLatex *l1 = new TLatex(125,10.0,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  l1->SetTextFont(42);
  l1->SetTextSize(0.05);
  l1->Draw();

  // TLatex *ly = new TLatex(200.0,5.25,"0.0 < |y| < 2.4");
  // ly->Draw();
  // TLatex *lpt = new TLatex(200.0,4.5,"6.5 < p_{T} < 30.0 GeV/c");
  // lpt->Draw();


  TLatex *ly = new TLatex(20.0,1.35,"0.0 < |y| < 2.4");
  ly->Draw();
  TLatex *lpt = new TLatex(20.0,0.6,"6.5 < p_{T} < 30.0 GeV/c");
  lpt->Draw();

  gPad->RedrawAxis();

  TCanvas *c1a = new TCanvas("c1a","c1a");

  TH1F *f1a = new TH1F("f1a","f1a",1,0,400);
  TH1F *f1al = new TH1F("f1al","f1al",1,0,400);
  f1a->SetBinContent(1,9.2*0.23); // MB high pT b-fraction
  f1al->SetBinContent(1,3.8*0.23); // MB high pT b-fraction
  f1a->SetBinError(1,0.0);
  f1al->SetBinError(1,0.0);

  f1a->SetLineWidth(1);
  f1a->SetLineStyle(1);
  f1a->SetFillColor(kGray);
  f1a->SetFillStyle(1001);
  f1al->SetLineWidth(1);
  f1al->SetLineStyle(1);
  f1al->SetFillColor(10);
  f1al->SetFillStyle(1001);
  f1a->GetXaxis()->SetTitle("N_{part}");
  f1a->GetYaxis()->SetTitle("1/T_{AA} dN/dy (nb)");
  f1a->GetXaxis()->CenterTitle(kTRUE);
  f1a->GetYaxis()->SetRangeUser(0.0,2.76);

  f1a->Draw("HIST2");
  f1al->Draw("HIST2same");
  gNonPromptJpsiCentSyst->Draw("2");
  gNonPromptJpsiCent->Draw("P");
  gNonPromptJpsiCentP->Draw("P");
  gNonPromptJpsiMBSyst->Draw("2");
  gNonPromptJpsiMB->Draw("P");


  TLegend *leg1a = new TLegend(0.22,0.56,0.90,0.69);
  leg1a->SetFillStyle(1001);
  leg1a->SetFillColor(kWhite);
  leg1a->SetBorderSize(0);
  leg1a->SetMargin(0.2);
  leg1a->SetTextSize(0.04);
  leg1a->SetNColumns(2);
  leg1a->SetColumnSeparation(-0.78);

  // leg1a->AddEntry(gNonPromptJpsiCent,"Non-prompt J/#psi (0-20%, 20-100%)","P");
  leg1a->AddEntry(gNonPromptJpsiCent,"Non-prompt J/#psi","P");
  leg1a->AddEntry(gNonPromptJpsiMB,"(0-100%)","P");
  //  leg1a->AddEntry(gNonPromptJpsiMB,"Non-prompt J/#psi (0-100%)","P");
  leg1a->AddEntry(f1a,"pp interpolation (arXiv:1103.2394)","F");
  leg1a->Draw();

  TLatex *prea = new TLatex(125,2.53,"CMS Preliminary");
  prea->SetTextFont(42);
  prea->SetTextSize(0.05);
  prea->Draw();

  TLatex *l1a = new TLatex(125,2.30,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  l1a->SetTextSize(0.05);
  l1a->Draw();

  // TLatex *l1a = new TLatex(125,2.30,"L_{int} = 7.28");
  // l1a->SetTextSize(0.05);
  // l1a->Draw();

  // TLatex *lya = new TLatex(200.0,1.2075,"0.0 < |y| < 2.4");
  // lya->Draw();
  // TLatex *lpta = new TLatex(200.0,1.035,"6.5 < p_{T} < 30.0 GeV/c");
  // lpta->Draw();
  TLatex *lya = new TLatex(20.0,0.3105,"0.0 < |y| < 2.4");
  lya->Draw();
  TLatex *lpta = new TLatex(20.0,0.138,"6.5 < p_{T} < 30.0 GeV/c");
  lpta->Draw();

  gPad->RedrawAxis();
  
  TCanvas *c1b = new TCanvas("c1b","c1b");
  c1b->SetLogy();
  // TF1 *f1b = new TF1("f1b","0.753",0,400);
  // f1b->SetLineWidth(1);
  // f1b->SetLineStyle(2);
  // f1b->GetXaxis()->SetTitle("N_{part}");
  // f1b->GetYaxis()->SetTitle("1/T_{AA} dN/dy (pb)");
  // f1b->GetXaxis()->CenterTitle(kTRUE);

  // f1b->Draw();
  // f1b->GetYaxis()->SetRangeUser(0.0,1.6);

  TH1F *f1b = new TH1F("f1b","f1b",1,0,400);
  TH1F *f1bl = new TH1F("f1bl","f1bl",1,0,400);
  f1b->SetBinContent(1,0.753+sqrt(0.029*0.029+0.072*0.072));
  f1bl->SetBinContent(1,0.753-sqrt(0.029*0.029+0.072*0.072));
  f1b->SetBinError(1,0.0);
  f1bl->SetBinError(1,0.0);

  f1b->SetLineWidth(1);
  f1b->SetLineStyle(1);
  f1b->SetFillColor(kGray);
  f1b->SetFillStyle(1001);
  f1bl->SetLineWidth(2);
  f1bl->SetLineStyle(3);
  f1bl->SetFillColor(10);
  f1bl->SetFillStyle(1001);
  f1b->GetXaxis()->SetTitle("N_{part}");
  f1b->GetYaxis()->SetTitle("1/T_{AA} dN/dy (pb)");
  f1b->GetXaxis()->CenterTitle(kTRUE);
  f1b->GetYaxis()->SetRangeUser(0.0,1.8);



  TH1F *f2b = new TH1F("f2b","f2b",1,0,400);
  TH1F *f2bl = new TH1F("f2bl","f2bl",1,0,400);
  f2b->SetBinContent(1,7.37 + (0.13*0.13 + 0.61*0.61));
  f2bl->SetBinContent(1,7.37 - sqrt(0.13*0.13 + 0.42*0.42));
  f2b->SetBinError(1,0.0);
  f2bl->SetBinError(1,0.0);

  f2b->SetLineWidth(2);
  f2b->SetLineStyle(2);
  f2b->SetFillColor(kGray);
  f2b->SetFillStyle(1001);
  f2bl->SetLineWidth(1);
  f2bl->SetLineStyle(1);
  f2bl->SetFillColor(10);
  f2bl->SetFillStyle(1001);
  f2b->GetXaxis()->SetTitle("N_{part}");
  f2b->GetYaxis()->SetTitle("1/T_{AA} dN/dy (pb)");
  f2b->GetXaxis()->CenterTitle(kTRUE);
  f2b->GetYaxis()->SetRangeUser(0.1,20);


  f2b->Draw("HIST2");
  // f2bl->Draw("HIST2same");
  //  f1b->Draw("HIST2");
  f1bl->Draw("HIST2same");

  gUpsCentSyst->Draw("2");
  gUpsCent->Draw("P");
  gUpsCentP->Draw("P");
  gUpsMBSyst->Draw("2");
  gUpsMB->Draw("P");

  TLegend *leg1b = new TLegend(0.22,0.51,0.90,0.76);
  leg1b->SetFillStyle(1001);
  leg1b->SetFillColor(kWhite);
  leg1b->SetBorderSize(0);
  leg1b->SetMargin(0.2);
  leg1b->SetTextSize(0.04);
  leg1b->SetNColumns(2);
  leg1b->SetColumnSeparation(-1.25);
  leg1b->AddEntry(gUpsCent,"#Upsilon(1S)","P");
  leg1b->AddEntry(gUpsMB,"(0-100%)","P");
  leg1b->AddEntry(f1b,"CDF p#bar{p}  #sqrt{s} = 1.8 TeV","L");
  leg1b->AddEntry(f1b," ","");
  leg1b->AddEntry(f1b,"(PRL 75, 4358 (1995))","");
  leg1b->AddEntry(f2b," ","");
  leg1b->AddEntry(f2b,"CMS pp  #sqrt{s} = 7 TeV","L");
  leg1b->AddEntry(f2b," ","");
  leg1b->AddEntry(f2b,"(arXiv:1012.5545)","");
  leg1b->Draw();

  //  TLatex *preb = new TLatex(125,9.1667,"CMS Preliminary");
  TLatex *preb = new TLatex(125,12.816,"CMS Preliminary");
  preb->SetTextFont(42);
  preb->SetTextSize(0.05);
  preb->Draw();

  //  TLatex *l1b = new TLatex(125,8.889,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  TLatex *l1b = new TLatex(125,8.752,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  l1b->SetTextSize(0.05);
  l1b->Draw();

  TLatex *lyb = new TLatex(20.0,0.185,"0.0 < |y| < 2.4");
  //  TLatex *lyb = new TLatex(20.0,0.2025,"0.0 < |y| < 2.4");
  lyb->Draw();
  TLatex *lptb = new TLatex(20.0,0.130,"0.0 < p_{T} < 20.0 GeV/c");
  //  TLatex *lptb = new TLatex(20.0,0.09,"0.0 < p_{T} < 20.0 GeV/c");
  lptb->Draw();

  gPad->RedrawAxis();

  c1->SaveAs("inclJpsi_cent.pdf");
  c1a->SaveAs("nonpromptJpsi_cent.pdf");
  c1b->SaveAs("upsilon_cent.pdf");

  c1->SaveAs("inclJpsi_cent.png");
  c1a->SaveAs("nonpromptJpsi_cent.png");
  c1b->SaveAs("upsilon_cent.png");



  double bfractionCent[] = {0.2550, 0.3337, 0.3268, 0.0786, 0.2003, 0.2550, 0.2317};
  double bfractionCentError[] = {0.0351, 0.0723, 0.0833, 0.0541, 0.0738, 0.0966, 0.0885};
  double bfractionCentSyst[] = {0.0510, 0.0667, 0.0654, 0.0157, 0.0401, 0.0510, 0.0463}; // fixme: update syst. uncertainties

  double bfractionCoarseCent[] = {0.2550, 0.3289, 0.1757};
  double bfractionCoarseCentError[] = {0.0351, 0.0583, 0.0401};
  double bfractionCoarseCentSyst[] = {0.0510, 0.0658, 0.0351}; // fixme: update syst. uncertainties
  
  
  TGraphErrors *gBfractionCent = new TGraphErrors(7, promptNpart, bfractionCent, promptNpartError, bfractionCentError);

  TGraphErrors *gBfractionCentSyst = new TGraphErrors(7, promptNpart, bfractionCent, promptSystX, bfractionCentSyst);

  TGraphErrors *gBfractionCoarseCent = new TGraphErrors(3, nonPromptNpart, bfractionCoarseCent, nonPromptNpartError, bfractionCoarseCentError);

  TGraphErrors *gBfractionCoarseCentSyst = new TGraphErrors(3, nonPromptNpart, bfractionCoarseCent, nonPromptSystX, bfractionCoarseCentSyst);

  TGraphErrors *gBfractionCoarseCentP = new TGraphErrors(3, nonPromptNpart, bfractionCoarseCent, nonPromptNpartError, nonPromptNpartError);

  TGraphErrors *gBfractionMB = new TGraphErrors(1, promptNpart, bfractionCent, promptNpartError, bfractionCentError);

  TGraphErrors *gBfractionMBSyst = new TGraphErrors(1, promptNpart, bfractionCent, promptSystX, bfractionCentSyst);


  gBfractionCent->RemovePoint(0);
  gBfractionCoarseCent->RemovePoint(0);
  gBfractionCoarseCentP->RemovePoint(0);

  gBfractionCentSyst->RemovePoint(0);
  gBfractionCoarseCentSyst->RemovePoint(0);

  gBfractionCent->SetName("gBfractionCent");
  gBfractionMB->SetName("gBfractionMB");

  gBfractionCoarseCent->SetName("gBfractionCoarseCent");
  gBfractionCoarseCentP->SetName("gBfractionCoarseCentP");


  gBfractionCentSyst->SetName("gBfractionCentSyst");
  gBfractionMBSyst->SetName("gBfractionMBSyst");

  gBfractionCoarseCentSyst->SetName("gBfractionCoarseCentSyst");


  gBfractionCentSyst->SetFillColor(kAzure-9);
  gBfractionMBSyst->SetFillColor(kAzure-9);

  gBfractionCoarseCentSyst->SetFillColor(kAzure-9);

  gBfractionCentSyst->SetFillColor(kRed-9);
  gBfractionMBSyst->SetFillColor(kRed-9);
  gBfractionCoarseCentSyst->SetFillColor(kRed-9);


  if (isPaper) {
    gBfractionCent->SetMarkerColor(kRed+2);
    gBfractionMB->SetMarkerColor(kRed+2);
    gBfractionCoarseCent->SetMarkerColor(kRed+2);
  }
  else {
    gBfractionCent->SetMarkerColor(kRed);
    gBfractionMB->SetMarkerColor(kRed);
    gBfractionCoarseCent->SetMarkerColor(kRed);
  }

  gBfractionCent->SetMarkerStyle(20);
  gBfractionMB->SetMarkerStyle(24);
  gBfractionCoarseCent->SetMarkerStyle(20);

  gBfractionCent->SetMarkerSize(1.2);
  gBfractionMB->SetMarkerSize(1.2);
  gBfractionCoarseCent->SetMarkerSize(1.2);

  gBfractionCoarseCentP->SetMarkerStyle(24);
  gBfractionCoarseCentP->SetMarkerSize(1.2);


  TF1 *f2 = new TF1("f2","1",0,400);
  f2->SetLineWidth(1);
  f2->GetXaxis()->SetTitle("N_{part}");
  f2->GetYaxis()->SetTitle("B-fraction");
  f2->GetYaxis()->SetRangeUser(0.0,0.8);
  f2->GetXaxis()->CenterTitle(kTRUE);

  TCanvas *c2 = new TCanvas("c2","c2");
  f2->Draw();
  gBfractionCoarseCentSyst->Draw("2");
  gBfractionCoarseCent->Draw("P");
  gBfractionCoarseCentP->Draw("P");


  TLegend *leg2 = new TLegend(0.22,0.62,0.90,0.69);
  leg2->SetFillStyle(0);
  leg2->SetFillColor(kWhite);
  leg2->SetBorderSize(0);
  leg2->SetMargin(0.2);
  leg2->SetTextSize(0.04);
  leg2->AddEntry(gBfractionCoarseCent,"B-fraction","P");
  leg2->Draw();

  TLatex *pre2 = new TLatex(125,0.733336,"CMS Preliminary");
  pre2->SetTextFont(42);
  pre2->SetTextSize(0.05);
  pre2->Draw();

  TLatex *l2 = new TLatex(125,0.66664,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  l2->SetTextSize(0.05);
  l2->Draw();

  TLatex *ly2 = new TLatex(20.0,0.090,"0.0 < |y| < 2.4");
  ly2->Draw();
  TLatex *lpt2 = new TLatex(20.0,0.04,"0.0 < p_{T} < 20.0 GeV/c");
  lpt2->Draw();

  gPad->RedrawAxis();
 
  c2->SaveAs("bFraction_cent.pdf");
  c2->SaveAs("bFraction_cent.png");
  return;

  TF1 *f3 = new TF1("f3","220",0,400);
  f3->GetXaxis()->SetTitle("N_{part}");
  f3->GetYaxis()->SetTitle("1/T_{AA} dN/dy (nb)");

  f3->GetYaxis()->SetRangeUser(0.0,1.0);
  f3->GetXaxis()->CenterTitle(kTRUE);


  double ppNpart[] = {2.0};
  double ppNpartError[] = {0.0};
  double ppNpartError2[] = {1.0};
  double ppCDF[] = {2.325};
  //  double ppCDF[] = {0.753};
  double ppCDFError[] = {0.029};
  double ppCDFSyst[] = {0.072};

  TGraphErrors *gUpsCDF = new TGraphErrors(1, ppNpart, ppCDF, ppNpartError, ppCDFError);
  TGraphErrors *gUpsCDFsyst = new TGraphErrors(1, ppNpart, ppCDF, ppNpartError2, ppCDFSyst);

  gUpsCDF->SetName("gUpsCDF");
  gUpsCDFsyst->SetName("gUpsCDFsyst");

  gUpsCDF->SetMarkerStyle(20);
  gUpsCDFsyst->SetFillColor(kGray);

  TCanvas *c3 = new TCanvas("c3","c3");
  // c3->SetRightMargin(rmargin);
  // c3->SetTopMargin(tmargin);

  f3->Draw();
  gUpsCent->Draw("P");
  gUpsMB->Draw("P");
  gUpsCDFsyst->Draw("2");
  gUpsCDF->Draw("P");

  // RAA
  double ppPromptJpsi = 226.0;
  double ppPromptJpsiError = 20;

  double inclJpsiRAA[5];
  double promptJpsiRAA[5];
  double nonPromptJpsiRAA[3];
  double upsRAA[4];

  double inclJpsiRAAError[5];
  double promptJpsiRAAError[5];
  double nonPromptJpsiRAAError[3];
  double upsRAAError[4];

  double inclJpsiRAASyst[5];
  double promptJpsiRAASyst[5];
  double nonPromptJpsiRAASyst[3];
  double upsRAASyst[4];

  for (int i=0; i<5; ++i) {
    inclJpsiRAA[i] = inclJpsiCent[i]/ppPromptJpsi;
    promptJpsiRAA[i] = promptJpsiCent[i]/ppPromptJpsi;

    inclJpsiRAAError[i] = inclJpsiRAA[i]*inclJpsiCentError[i]/inclJpsiCent[i];
    promptJpsiRAAError[i] = promptJpsiRAA[i]*promptJpsiCentError[i]/promptJpsiCent[i];

    inclJpsiRAASyst[i] = inclJpsiRAA[i]*inclJpsiCentSyst[i]/inclJpsiCent[i];
    promptJpsiRAASyst[i] = promptJpsiRAA[i]*promptJpsiCentSyst[i]/promptJpsiCent[i];
  }

  for (int i=0; i<3; ++i) {
    nonPromptJpsiRAA[i] = nonPromptJpsiCent[i]/(bfractionCent[i]*ppPromptJpsi);
    nonPromptJpsiRAAError[i] = nonPromptJpsiRAA[i]*nonPromptJpsiCentError[i]/nonPromptJpsiCent[i];
    nonPromptJpsiRAASyst[i] = nonPromptJpsiRAA[i]*nonPromptJpsiCentSyst[i]/nonPromptJpsiCent[i];
  }

  for (int i=0; i<4; ++i) {
    upsRAA[i] = upsCent[i]/ppCDF[0];
    upsRAAError[i] = upsRAA[i]*upsCentError[i]/upsCent[i];
    upsRAASyst[i] = upsRAA[i]*upsCentSyst[i]/upsCent[i];
  }

  TGraphErrors *gInclJpsiRAA = new TGraphErrors(5, promptNpart, inclJpsiRAA, promptNpartError, inclJpsiRAAError);
  TGraphErrors *gPromptJpsiRAA = new TGraphErrors(5, promptNpart, promptJpsiRAA, promptNpartError, promptJpsiRAAError);
  TGraphErrors *gNonPromptJpsiRAA = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiRAA, nonPromptNpartError, nonPromptJpsiRAAError);
  TGraphErrors *gUpsRAA = new TGraphErrors(4, upsNpart, upsRAA, upsNpartError, upsRAAError);

  TGraphErrors *gInclJpsiRAAMB = new TGraphErrors(1, promptNpart, inclJpsiRAA, promptNpartError, inclJpsiRAAError);
  TGraphErrors *gPromptJpsiRAAMB = new TGraphErrors(1, promptNpart, promptJpsiRAA, promptNpartError, promptJpsiRAAError);
  TGraphErrors *gNonPromptJpsiRAAMB = new TGraphErrors(1, nonPromptNpart, nonPromptJpsiRAA, nonPromptNpartError, nonPromptJpsiRAAError);
  TGraphErrors *gUpsRAAMB = new TGraphErrors(1, upsNpart, upsRAA, upsNpartError, upsRAAError);


  TGraphErrors *gInclJpsiRAASyst = new TGraphErrors(5, promptNpart, inclJpsiRAA, promptSystX, inclJpsiRAASyst);
  TGraphErrors *gPromptJpsiRAASyst = new TGraphErrors(5, promptNpart, promptJpsiRAA, promptSystX, promptJpsiRAASyst);
  TGraphErrors *gNonPromptJpsiRAASyst = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiRAA, nonPromptSystX, nonPromptJpsiRAASyst);
  TGraphErrors *gUpsRAASyst = new TGraphErrors(4, upsNpart, upsRAA, upsSystX, upsRAASyst);

  TGraphErrors *gInclJpsiRAAMBSyst = new TGraphErrors(1, promptNpart, inclJpsiRAA, promptSystX, inclJpsiRAASyst);
  TGraphErrors *gPromptJpsiRAAMBSyst = new TGraphErrors(1, promptNpart, promptJpsiRAA, promptSystX, promptJpsiRAASyst);
  TGraphErrors *gNonPromptJpsiRAAMBSyst = new TGraphErrors(1, nonPromptNpart, nonPromptJpsiRAA, nonPromptSystX, nonPromptJpsiRAASyst);
  TGraphErrors *gUpsRAAMBSyst = new TGraphErrors(1, upsNpart, upsRAA, upsSystX, upsRAASyst);


  gInclJpsiRAA->RemovePoint(0);
  gPromptJpsiRAA->RemovePoint(0);
  gNonPromptJpsiRAA->RemovePoint(0);
  gUpsRAA->RemovePoint(0);

  gInclJpsiRAASyst->RemovePoint(0);
  gPromptJpsiRAASyst->RemovePoint(0);
  gNonPromptJpsiRAASyst->RemovePoint(0);
  gUpsRAASyst->RemovePoint(0);

  gInclJpsiRAA->SetName("gInclJpsiRAA");
  gPromptJpsiRAA->SetName("gPromptJpsiRAA");
  gNonPromptJpsiRAA->SetName("gNonPromptJpsiRAA");

  gInclJpsiRAAMB->SetName("gInclJpsiRAAMB");
  gPromptJpsiRAAMB->SetName("gPromptJpsiRAAMB");
  gNonPromptJpsiRAAMB->SetName("gNonPromptJpsiRAAMB");

  gUpsRAA->SetName("gUpsRAASyst");
  gUpsRAAMB->SetName("gUpsRAAMBSyst");

  gInclJpsiRAASyst->SetName("gInclJpsiRAASyst");
  gPromptJpsiRAASyst->SetName("gPromptJpsiRAASyst");
  gNonPromptJpsiRAASyst->SetName("gNonPromptJpsiRAASyst");

  gInclJpsiRAAMBSyst->SetName("gInclJpsiRAAMBSyst");
  gPromptJpsiRAAMBSyst->SetName("gPromptJpsiRAAMBSyst");
  gNonPromptJpsiRAAMBSyst->SetName("gNonPromptJpsiRAAMBSyst");

  gUpsRAASyst->SetName("gUpsRAASyst");
  gUpsRAAMBSyst->SetName("gUpsRAAMBSyst");


  gInclJpsiRAASyst->SetFillColor(kGray+1);
  gPromptJpsiRAASyst->SetFillColor(kAzure-9);
  gNonPromptJpsiRAASyst->SetFillColor(kRed-10);
  gUpsRAASyst->SetFillColor(kGreen-10);

  gInclJpsiRAAMBSyst->SetFillColor(kGray+1);
  gPromptJpsiRAAMBSyst->SetFillColor(kAzure-9);
  gNonPromptJpsiRAAMBSyst->SetFillColor(kRed-10);
  gUpsRAAMBSyst->SetFillColor(kGreen-10);


  gInclJpsiRAA->SetMarkerColor(kBlack);
  gPromptJpsiRAA->SetMarkerColor(kBlue);
  gNonPromptJpsiRAA->SetMarkerColor(kRed);
  gUpsRAA->SetMarkerColor(kGreen+2);

  gInclJpsiRAAMB->SetMarkerColor(kBlack);
  gPromptJpsiRAAMB->SetMarkerColor(kBlue);
  gNonPromptJpsiRAAMB->SetMarkerColor(kRed);
  gUpsRAAMB->SetMarkerColor(kGreen+2);

  gInclJpsiRAA->SetMarkerStyle(20);
  gPromptJpsiRAA->SetMarkerStyle(21);
  gNonPromptJpsiRAA->SetMarkerStyle(22);
  gUpsRAA->SetMarkerStyle(23);

  gInclJpsiRAAMB->SetMarkerStyle(24);
  gPromptJpsiRAAMB->SetMarkerStyle(25);
  gNonPromptJpsiRAAMB->SetMarkerStyle(26);
  gUpsRAAMB->SetMarkerStyle(27);


  TF1 *f4 = new TF1("f4","1",0,400);
  f4->SetLineWidth(1);
  f4->GetXaxis()->SetTitle("N_{part}");
  f4->GetYaxis()->SetTitle("R_{AA}");
  f4->GetYaxis()->SetRangeUser(0.0,1.0);
  f4->GetXaxis()->CenterTitle(kTRUE);


  TCanvas *c4 = new TCanvas("c4","c4");
  // c4->SetRightMargin(rmargin);
  // c4->SetTopMargin(tmargin);
  c4->SetTickx();
  c4->SetTicky();

  f4->Draw();

  gInclJpsiRAASyst->Draw("2");
  gPromptJpsiRAASyst->Draw("2");
  gNonPromptJpsiRAASyst->Draw("2");
  gUpsRAASyst->Draw("2");


  gInclJpsiRAA->Draw("P");
  gPromptJpsiRAA->Draw("P");
  gNonPromptJpsiRAA->Draw("P");
  gUpsRAA->Draw("P");

  gInclJpsiRAAMBSyst->Draw("2");
  gPromptJpsiRAAMBSyst->Draw("2");
  gNonPromptJpsiRAAMBSyst->Draw("2");
  gUpsRAAMBSyst->Draw("2");

  gInclJpsiRAAMB->Draw("P");
  gPromptJpsiRAAMB->Draw("P");
  gNonPromptJpsiRAAMB->Draw("P");
  gUpsRAAMB->Draw("P");


  double ppg068RAA_mid[] = {0.37, 0.57, 0.66, 0.74};
  double ppg068RAA_midError[] = {0.04, 0.06, 0.07, 0.12};
  double ppg068RAA_midSyst[] = {0.06, 0.08, 0.10, 0.11};
  double ppg068Npart_mid[] = {279.9, 140.0, 60.0, 14.5};
  double ppg068Npart_midError[] = {4.0, 5.0, 4.0, 2.5};
  double ppg068SystX[] = {10.0, 10.0, 10.0, 10.0};

  TGraphErrors *gPPG068RAA_mid = new TGraphErrors(4, ppg068Npart_mid, ppg068RAA_mid, ppg068Npart_midError, ppg068RAA_midError);
  TGraphErrors *gPPG068RAA_midSyst = new TGraphErrors(4, ppg068Npart_mid, ppg068RAA_mid, ppg068SystX, ppg068RAA_midSyst);

  gPPG068RAA_midSyst->SetFillColor(kGray);
  gPPG068RAA_mid->SetMarkerStyle(24);
  gPPG068RAA_mid->SetMarkerColor(kBlack);


  double ppg068RAA_fwd[] = {0.16, 0.27, 0.3, 0.38, 0.6, 0.75};
  double ppg068RAA_fwdError[] = {0.05, 0.035, 0.035, 0.038, 0.032, 0.049};
  double ppg068RAA_fwdSyst[] = {0.035, 0.022, 0.02, 0.023, 0.017, 0.032};
  double ppg068Npart_fwd[] = {325.2, 234.6, 166.6, 114.2, 60.0, 14.5};
  double ppg068Npart_fwdError[] = {3.3, 4.7, 5.4, 4.4, 4.0, 2.5};
  double ppg068SystX_fwd[] = {10.0, 10.0, 10.0, 10.0, 10.0, 10.0};



  TGraphErrors *gPPG068RAA_fwd = new TGraphErrors(6, ppg068Npart_fwd, ppg068RAA_fwd, ppg068Npart_fwdError, ppg068RAA_fwdError);
  TGraphErrors *gPPG068RAA_fwdSyst = new TGraphErrors(6, ppg068Npart_fwd, ppg068RAA_fwd, ppg068SystX, ppg068RAA_fwdSyst);

  gPPG068RAA_fwdSyst->SetFillColor(kOrange-9);
  gPPG068RAA_fwd->SetMarkerStyle(20);
  gPPG068RAA_fwd->SetMarkerColor(kOrange+10);

  gPPG068RAA_midSyst->Draw("2");
  gPPG068RAA_mid->Draw("P");

  gPPG068RAA_fwdSyst->Draw("2");
  gPPG068RAA_fwd->Draw("P");

  return;
}
예제 #19
0
int main(int argc, char* argv[]){

  // Give argument info to user
  std::cout << "Arguments passed to program: " << argc << std::endl;
  for (int i = 0; i < argc; ++i){
    std::cout << i << "\t" << argv[i] << std::endl;
  }
  if (argc != 10){
    std::cerr << "Need 8 args:<iselec> <B/E/Eb> <File1><label1> <File2><labelData2> <File3><label3> <Plot1or2or3>" << std::endl;
    exit(1);
  }

/*
    gStyle->SetLabelColor(1, "XYZ");
    gStyle->SetLabelFont(42, "XYZ");
    gStyle->SetLabelOffset(0.007, "XYZ");
    gStyle->SetLabelSize(0.04, "XYZ");
  // For the Pad:
    gStyle->SetPadBorderMode(0);
    // gStyle->SetPadBorderSize(Width_t size = 1);
    gStyle->SetPadColor(kWhite);
    gStyle->SetPadGridX(false);
    gStyle->SetPadGridY(false);
    gStyle->SetGridColor(0);
    gStyle->SetGridStyle(3);
   gStyle->SetGridWidth(1);

                                      // For the frame:
      gStyle->SetFrameBorderMode(0);
     gStyle->SetFrameBorderSize(10);
     gStyle->SetFrameFillColor(0);    
 
       gROOT->ForceStyle();
*/

    bool elec;
    std::string barrel;
    elec = boost::lexical_cast<bool>(argv[1]);
    barrel = argv[2];
    TFile* file2012A=new TFile(argv[3]);
    const char* labeldata1=argv[4];
    TFile* file2012B=new TFile(argv[5]);
    const char* labeldata2=argv[6];
    TFile* fileMC=new TFile(argv[7]);
    const char* labelMC=argv[8];
    int Plot2or3 = boost::lexical_cast<int>(argv[9]);

    TFile* output;
    if(elec && barrel=="B")
    {
        output=new TFile("ElectronBarrelTriggerPlots.root", "RECREATE");
    }
    if(elec && barrel=="E")
    {
        output=new TFile("ElectronEndcapTriggerPlots.root", "RECREATE");
    }
    if(!elec && barrel=="B")
    {
        output=new TFile("MuonEta08TriggerPlots.root", "RECREATE");
    }
    if(!elec && barrel=="E")
    {
        output=new TFile("MuonEta12TriggerPlots.root", "RECREATE");
    }
    if(!elec && barrel=="Eb")
    {
        output=new TFile("MuonEndcapTriggerPlots.root", "RECREATE");
    }
    
    output->cd();

    TGraphErrors* gr2012A=(TGraphErrors*)file2012A->Get("Graph");
    TGraphErrors* gr2012B = (TGraphErrors*)file2012B->Get("Graph");
    TGraphErrors* grMC = (TGraphErrors*)fileMC->Get("Graph");
    TF1* fit2012A;
    TF1* fit2012B;
    TF1* fitMC;
    
    
    if(barrel=="B")
    {
        fit2012A=(TF1*)file2012A->Get("fitGraph1");
        fit2012B = (TF1*)file2012B->Get("fitGraph1");
        fitMC = (TF1*)fileMC->Get("fitGraph1");
    }
    else if(barrel=="E")
    {
        fit2012A=(TF1*)file2012A->Get("fitGraph2");
        fit2012B = (TF1*)file2012B->Get("fitGraph2");
        fitMC = (TF1*)fileMC->Get("fitGraph2");
    }
    else
    {
        fit2012A=(TF1*)file2012A->Get("fitGraph3");
        fit2012B = (TF1*)file2012B->Get("fitGraph3");
        fitMC = (TF1*)fileMC->Get("fitGraph3");
    }
    
    TCanvas* canvas1 = new TCanvas("canvas1", "canvas1", 200,10, 700, 500);
    TH1F* base1 = new TH1F("base1", "base1" , 100, 0 ,50);
    if(elec)
    {    
        base1->GetXaxis()->SetTitle("Electron p_{T} (GeV)");
    }
    else base1->GetXaxis()->SetTitle("Muon p_{T} (GeV)");
    
    
    base1->GetXaxis()->SetLabelSize(0.045);
    base1->GetXaxis()->SetTitleSize(0.045);
    base1->GetXaxis()->SetTitleOffset(1.1);
    
    base1->GetYaxis()->SetTitle("Efficiency");
    base1->GetYaxis()->SetLabelSize(0.045);
    base1->GetYaxis()->SetTitleSize(0.045);
    base1->GetYaxis()->SetTitleOffset(1.0);
    base1->SetTitle(0);
    base1->SetStats(0);
    base1->Draw();
    gr2012A->SetMarkerColor(1);
    fit2012A->SetLineColor(1);
    if(Plot2or3==1)
    {
        gr2012A->SetMarkerColor(kBlue);
        fit2012A->SetLineColor(kBlue);
    }
    gr2012A->Draw("Psame");
    fit2012A->Draw("same");
    if(Plot2or3!=1)
    {
        gr2012B->SetMarkerColor(kBlue);
        gr2012B->SetMarkerStyle(33);
        fit2012B->SetLineColor(4);
        //fit2012B->SetLineWidth(1);
        gr2012B->Draw("Psame");
        fit2012B->Draw("same");
    }
   if(Plot2or3==3)
   {
        grMC->SetMarkerColor(kRed);
        grMC->SetMarkerStyle(21);
        fitMC->SetLineColor(kRed);
        //fitMC->SetLineWidth(1);
        grMC->Draw("Psame");
        fitMC->Draw("same");
   }
    
    TLegend * legend1 = new TLegend(0.50, 0.35, 0.75, 0.60);
    legend1->AddEntry(gr2012A, labeldata1, "p");
    if(Plot2or3!=1) legend1->AddEntry(gr2012B, labeldata2, "p");
 if(Plot2or3==3)  legend1->AddEntry(grMC, labelMC, "p");
//    legend1->AddEntry(grptdata, "2012 Data", "p");
    legend1->SetFillColor(0);
    legend1->SetTextSize(0.045);
    legend1->SetBorderSize(0);
    legend1->Draw();
    canvas1->Update();

    TLatex *title_latex = new TLatex();
    title_latex->SetNDC();
    title_latex->SetTextSize(0.045);
    title_latex->DrawLatex(0.14, 0.935, "CMS Preliminary 2012, #sqrt{s}=8 TeV, 19.4 fb^{-1}");        
    TLatex *label_latex = new TLatex();
    label_latex->SetNDC();
    label_latex->SetTextSize(0.045);
    if(barrel=="B" && !elec)
    {
        label_latex->DrawLatex(0.14, 0.8, "|#eta|<0.8");
        //label_latex->DrawLatex(0.14, 0.8, "0 < #eta < 0.8");
     //   label_latex->DrawLatex(0.14, 0.8, "-0.8 < #eta < 0");
    }
    if(barrel=="B" && elec)
    {
        label_latex->DrawLatex(0.14, 0.8, "Barrel");
    }
    if(barrel=="E" && !elec)
    {
        label_latex->DrawLatex(0.14, 0.8, "0.8<|#eta|<1.2");
        //label_latex->DrawLatex(0.14, 0.8, "0.8 < #eta < 1.2");
        //label_latex->DrawLatex(0.14, 0.8, "-1.2 < #eta < -0.8");
    }
    if(barrel=="E" && elec)
    {
        label_latex->DrawLatex(0.14, 0.8, "Endcap");
    }
    if(barrel=="Eb")
    {
        label_latex->DrawLatex(0.14, 0.8, "|#eta|>1.2");
        //label_latex->DrawLatex(0.14, 0.8, "#eta > 1.2");
        //label_latex->DrawLatex(0.14, 0.8, "#eta < -1.2");
    }
    
    
    canvas1->Update();

    canvas1->Write();    
    
    output->Close();


    return 0;
}
예제 #20
0
Resolutions() {

	float Ebeam[] = {2.0,3.0,4.0,6.0,8.0,12.0};
	float Ebeam_err[] = {0.,0.,0.,0.,0.,0.};
	float beam_spread[] = {.027,.027,0.023,0.023,0.023,0.023};
	//float beam_spread[] = {0.,0.,0.,0.,0.,0.};

	float Ebeam_no3[] = {2.0,4.0,6.0,8.0,12.0};
	float Ebeam_no3_err[] = {0.,0.,0.,0.,0.};
	float beam_no3_spread[] = {.027,.027,0.023,0.023,0.023};

	float ECal_mean[] = {270.5, 475.9, 586.8, 921.5, 1323., 3022.};
	float ECal_sigma[] = {24.69, 31.54, 35.64, 47.51, 55.71, 133.};

	float PbG_mean[] = {775.3, 1320., 1613., 2556., 3546., 1846.};
	float PbG_sigma[] = {49.63, 71.96, 81., 125.3, 137., 77.99};
	
	float OldPbG_mean[] = {601.5, 1105, 1622, 2074, 2901};
	float OldPbG_sigma[] = {25.07, 38.05, 49.33, 58.2, 77.18};
	float OldPbG_mean_err[] = {.8, .6, .8, .7, 1.1};
	float OldPbG_sigma_err[] = {.83, .53, .74, .6, .93};

	float ECal_res[6], ECal_res_err[6];
	float PbG_res[6], PbG_res_err[6];
	float OldPbG_res[6], OldPbG_res_err[6];
	for (int i=0; i<6; i++) {
		ECal_res[i] = sqrt(ECal_sigma[i]*ECal_sigma[i]/(ECal_mean[i]*ECal_mean[i]) - beam_spread[i]*beam_spread[i]);
		PbG_res[i] = sqrt(PbG_sigma[i]*PbG_sigma[i]/(PbG_mean[i]*PbG_mean[i]) - beam_spread[i]*beam_spread[i]);
		ECal_res_err[i] = 0.;
		PbG_res_err[i] = 0.;
	}
	for (int i=0; i<5; i++) {
		OldPbG_res[i] = sqrt(OldPbG_sigma[i]*OldPbG_sigma[i]/(OldPbG_mean[i]*OldPbG_mean[i]) - beam_no3_spread[i]*beam_no3_spread[i]);
		OldPbG_res_err[i] = 0.;
	}

	TGraphErrors *gECalRes = new TGraphErrors(6, Ebeam, ECal_res, Ebeam_err, ECal_res_err);
	TGraphErrors *gPbGRes = new TGraphErrors(6, Ebeam, PbG_res, Ebeam_err, PbG_res_err);
	TGraphErrors *gOldPbGRes = new TGraphErrors(5, Ebeam_no3, OldPbG_res, Ebeam_no3_err, OldPbG_res_err);
	TF1 *fResECal = new TF1("fResECal", "[1]/sqrt(x) + [0]", 2, 14);
	TF1 *fResPbG = new TF1("fResPbG", "[1]/sqrt(x) + [0]", 2, 14);
	TF1 *fResOldPbG = new TF1("fResOldPbG", "[1]/sqrt(x) + [0]", 2, 14);
	fResECal->SetLineStyle(2);
	fResECal->SetLineColor(kGreen+2);
	fResPbG->SetLineStyle(2);
	fResPbG->SetLineColor(kRed+1);
	fResOldPbG->SetLineStyle(2);
	fResOldPbG->SetLineColor(kMagenta+1);

	gECalRes->Fit(fResECal, "NR");
	gPbGRes->Fit(fResPbG, "NR");
	gOldPbGRes->Fit(fResOldPbG, "NR");

	gECalRes->SetMarkerStyle(20);
	gECalRes->SetMarkerSize(2.0);
	gECalRes->SetMarkerColor(kGreen+2);
	gECalRes->SetLineColor(kGreen+2);
	gPbGRes->SetMarkerStyle(21);
	gPbGRes->SetMarkerSize(2.0);
	gPbGRes->SetMarkerColor(kRed+1);
	gPbGRes->SetLineColor(kRed+1);
	gOldPbGRes->SetMarkerStyle(22);
	gOldPbGRes->SetMarkerSize(2.0);
	gOldPbGRes->SetMarkerColor(kMagenta+1);
	gOldPbGRes->SetLineColor(kMagenta+1);

	TLegend *lres = new TLegend(.45, .56, .93, .83);
	lres->AddEntry(fResECal, Form("ECAL: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResECal->GetParameter(1)*100.0, fResECal->GetParameter(0)*100.0), "L");
	lres->AddEntry(fResPbG, Form("2015 Lead Glass: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResPbG->GetParameter(1)*100.0, fResPbG->GetParameter(0)*100.0), "L");
	lres->AddEntry(fResOldPbG, Form("2014 Lead Glass: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResOldPbG->GetParameter(1)*100.0, fResOldPbG->GetParameter(0)*100.0), "L");
	lres->SetFillStyle(0);
	lres->SetTextSize(.035);
	lres->SetTextFont(42);

	TCanvas *cRes = new TCanvas("cRes", "Resolutions", 900, 700);
	cRes->cd();
	gECalRes->Draw("AP");
	gECalRes->GetXaxis()->SetTitle("Beam Energy (GeV)");
	gECalRes->GetYaxis()->SetTitle("Resolution");
	gPbGRes->Draw("Psame");
	gOldPbGRes->Draw("Psame");
	fResECal->Draw("same");
	fResPbG->Draw("same");
	fResOldPbG->Draw("same");
	gECalRes->GetYaxis()->SetRangeUser(0.0,0.11);
	lres->Draw("same");
	cRes->Update();

}
예제 #21
0
TCanvas* example_plot( int iPeriod, int iPos )
{ 
  //  if( iPos==0 ) relPosX = 0.12;

  int W = 800;
  int H = 600;

  int H_ref = 600; 
  int W_ref = 800; 

  // references for T, B, L, R
  float T = 0.08*H_ref;
  float B = 0.12*H_ref; 
  float L = 0.12*W_ref;
  float R = 0.04*W_ref;

  TString canvName = "FigExample_";
  canvName += W;
  canvName += "-";
  canvName += H;
  canvName += "_";  
  canvName += iPeriod;
  if( writeExtraText ) canvName += "-prelim";
  if( iPos%10==0 ) canvName += "-out";
  else if( iPos%10==1 ) canvName += "-left";
  else if( iPos%10==2 )  canvName += "-center";
  else if( iPos%10==3 )  canvName += "-right";

  TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  canv->SetLeftMargin( L/W );
  canv->SetRightMargin( R/W );
  canv->SetTopMargin( T/H );
  canv->SetBottomMargin( B/H );
  canv->SetTickx(0);
  canv->SetTicky(0);


  int histLineColor = kOrange+7;
  int histFillColor = kOrange-2;
  float markerSize  = 1.0;

  {
    TLatex latex;
				
    int n_ = 2;

    float x1_l = 0.92;
    float y1_l = 0.60;

    float dx_l = 0.30;
    float dy_l = 0.18;
    float x0_l = x1_l-dx_l;
    float y0_l = y1_l-dy_l;

    TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l );
    //    legend->SetFillColor( kGray );
    legend->Draw();
    legend->cd();
		
    float ar_l = dy_l/dx_l;
		
    float x_l[1];
    float ex_l[1];
    float y_l[1];
    float ey_l[1];
		
    //    float gap_ = 0.09/ar_l;
    float gap_ = 1./(n_+1);
		
    float bwx_ = 0.12;
    float bwy_ = gap_/1.5;
		
    x_l[0] = 1.2*bwx_;
    //    y_l[0] = 1-(1-0.10)/ar_l;
    y_l[0] = 1-gap_;
    ex_l[0] = 0;
    ey_l[0] = 0.04/ar_l;
		
    TGraph* gr_l = new TGraphErrors(1, x_l, y_l, ex_l, ey_l );
		
    gStyle->SetEndErrorSize(0);
    gr_l->SetMarkerSize(0.9);
    gr_l->Draw("0P");
		
    latex.SetTextFont(42);
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);    
    latex.SetTextSize(0.25);    
    latex.SetTextAlign(12); 
		
    TLine line_;
    TBox  box_;
    float xx_ = x_l[0];
    float yy_ = y_l[0];
    latex.DrawLatex(xx_+1.*bwx_,yy_,"Data");
		
    yy_ -= gap_;
    box_.SetLineStyle( kSolid );
    box_.SetLineWidth( 1 );
    //		box_.SetLineColor( kBlack );
    box_.SetLineColor( histLineColor );
    box_.SetFillColor( histFillColor );
    box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 );
    box_.SetFillStyle(0);
    box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 );
    latex.DrawLatex(xx_+1.*bwx_,yy_,"Z #rightarrow e^{+}e^{-} (MC)");

    canv->cd();
  }

  {

   TGraphErrors *gre = new TGraphErrors(12);
   gre->SetName("Graph0");
   gre->SetTitle("");
   gre->SetFillColor(1);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#0000ff");
   gre->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(21);
   gre->SetPoint(0,0.1428571,0.943962);
   gre->SetPointError(0,0,0.00470259);
   gre->SetPoint(1,0.1714286,0.940484);
   gre->SetPointError(1,0,0.00447348);
   gre->SetPoint(2,0.2,0.935519);
   gre->SetPointError(2,0,0.00484668);
   gre->SetPoint(3,0.2285714,0.928495);
   gre->SetPointError(3,0,0.00504356);
   gre->SetPoint(4,0.2571429,0.931586);
   gre->SetPointError(4,0,0.00551296);
   gre->SetPoint(5,0.2857143,0.924183);
   gre->SetPointError(5,0,0.00521949);
   gre->SetPoint(6,0.3142857,0.925186);
   gre->SetPointError(6,0,0.00541335);
   gre->SetPoint(7,0.3428572,0.918469);
   gre->SetPointError(7,0,0.00520881);
   gre->SetPoint(8,0.3714286,0.926619);
   gre->SetPointError(8,0,0.00524148);
   gre->SetPoint(9,0.4,0.931496);
   gre->SetPointError(9,0,0.00526956);
   gre->SetPoint(10,0.4285714,0.932581);
   gre->SetPointError(10,0,0.00466349);
   gre->SetPoint(11,0.4571429,0.924199);
   gre->SetPointError(11,0,0.00348535);
   
   TH1F *Graph_Graph1 = new TH1F("Graph_Graph1","",100,0.1114286,0.4885714);
   Graph_Graph1->SetMinimum(0);
   Graph_Graph1->SetMaximum(1);
   Graph_Graph1->SetDirectory(0);
   Graph_Graph1->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1->SetLineColor(ci);
   Graph_Graph1->GetXaxis()->SetTitle("Threshold (pC)");
   Graph_Graph1->GetXaxis()->CenterTitle(true);
   Graph_Graph1->GetXaxis()->SetLabelFont(42);
   Graph_Graph1->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetXaxis()->SetTitleFont(42);
   Graph_Graph1->GetYaxis()->SetTitle("Efficiency");
   Graph_Graph1->GetYaxis()->SetRange(0,1);
   Graph_Graph1->GetYaxis()->CenterTitle(true);
   Graph_Graph1->GetYaxis()->SetLabelFont(42);
   Graph_Graph1->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetYaxis()->SetTitleFont(42);
   Graph_Graph1->GetZaxis()->SetLabelFont(42);
   Graph_Graph1->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1);
   
   gre->Draw("ap");

  }

  TLegend *leg = new TLegend(0.55,0.35,0.70,0.50);
  leg->SetTextSize(0.035);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->SetHeader("GIF++ test beams 08.2015");
  leg->AddEntry(gre, "Low Resistivity Glass RPC", "p");
  leg->Draw();

  // writing the lumi information and the CMS "logo"
  CMS_lumi( canv, iPeriod, iPos );

  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();

  canv->Print(canvName+".pdf",".pdf");
  canv->Print(canvName+".png",".png");

  return canv;
}
예제 #22
0
파일: Norm.C 프로젝트: TJHague/XGT2
/*int main{{{*/
void Check( TString Target_Name){

	/*Define{{{*/
	gROOT->SetStyle("Plain");
	gStyle->SetFillColor(0);
	TString Input_File = ""; 
	Input_File = Form("%s_L_kin5.1_unf.rho",Target_Name.Data()); 
	ifstream infile1(Input_File);
	Input_File = Form("../%s_Yield_L_All.out",Target_Name.Data()); 
	ifstream infile4(Input_File);

	Input_File = Form("%s.rho",Target_Name.Data()); 
	ofstream outfile(Input_File);
	
	const int bin = 60;
	double I1=0.;
	if(Target_Name=="H2"){
		I1=45.0;
	}
	else if(Target_Name=="He3"){
		I1=120.0;
	}
	else if(Target_Name=="He4"){
		I1 = 95.0; 
	}
	else
		cerr<<"***ERROR, Unknow Target!!!"<<endl;

	double *VZ1 = new double[bin];
	double *VZf = new double[bin];
	double *Rho1 = new double[bin];
	double *Rho1_Err = new double[bin];
	double *Rho0 = new double[bin];
	double *Rho0_Err = new double[bin];
	double *Rho0f = new double[bin];
	double *Rho0f_Err = new double[bin];
	double *Rho1f = new double[bin];
	double *Rho1f_Err = new double[bin];
	double *Zero = new double[bin];
	double *BF = new double[bin];
	double *BF_Err = new double[bin];

	double rho1_sum=0., rho0_sum=0.;
    double rho0f_sum=0.,rho1f_sum=0.;
    TString acom; infile4>>acom>>acom>>acom>>acom>>acom;
	/*}}}*/

	double aa=0;
	for(int i=0;i<bin;i++){
		infile1 >> VZ1[i] >> Rho1[i];	Rho1_Err[1]=sqrt(Rho1[i]);
		infile4 >> VZf[i] >> Rho0f[i] >> Rho0f_Err[i] >> BF[i] >> BF_Err[i];	

		Zero[i]=0.0;
		Rho0[i] = Correction_Inverse(Target_Name.Data(), VZ1[i], I1, Rho1[i] ); 
		Rho0_Err[i] = Rho0[i]/Rho1[i]*Rho1_Err[i];

		Rho1f[i] = Correction(Target_Name.Data(), VZf[i], I1, Rho0f[i] ); 
		Rho1f_Err[i] = Rho1f[i]/Rho0f[i]*Rho0f_Err[i];

		if(VZ1[i]>-0.075 && VZ1[i]<0.075){
           rho0_sum+=Rho0[i];
           rho1_sum+=Rho1[i];
		}
		else{
			Rho0[i]=0.0;
			Rho1[i]=0.0;
			Rho0_Err[i]=0.0;
			Rho1_Err[i]=0.0;
		}

		if(VZf[i]>-0.075 && VZf[i]<0.075){
           rho0f_sum+=Rho0f[i];
           rho1f_sum+=Rho1f[i];
		}
		else{
			Rho0f[i]=0.0;
			Rho1f[i]=0.0;
			Rho0f_Err[i]=0.0;
			Rho1f_Err[i]=0.0;
		}
	}
	infile1.close(); 

	cerr<<Form("Rho=%f, Rho1=%f, Rhof=%f, Rho1f=%f", rho0_sum, rho1_sum, rho0f_sum, rho1f_sum)<<endl;

	outfile<<Form("%12s %12s %12s %12s %12s", "VZ","Y0","Y0_Err","BF","BF_Err")<<endl; 
	for(int i=0;i<bin;i++){
		Rho0[i]/=rho0_sum;
		Rho0_Err[i]/=rho0_sum;
		Rho1[i]/=rho1_sum;
		Rho1_Err[i]/=rho1_sum;

		Rho0f[i]/=rho0f_sum;
		Rho0f_Err[i]/=rho0f_sum;
		Rho1f[i]/=rho1f_sum;
		Rho1f_Err[i]/=rho1f_sum;
		
		outfile<<Form("  %12.8f %12.8f %12.8f %12.8f %12.8f",VZf[i],Rho0f[i], Rho0f_Err[i], BF[i],BF_Err[i])<<endl; 
		}	
    outfile.close();

	TCanvas *c1 = new TCanvas("c1","c1",1200,700);
	c1->cd();
	TH2F *h1 = new TH2F("h1","",300,-0.12,0.12,300,-0.01,0.04);
	h1->SetStats(kFALSE);
	h1->SetXTitle("z_{react} (m)");
	h1->GetXaxis()->CenterTitle(1);
	h1->GetXaxis()->SetTitleFont(32);
	h1->GetXaxis()->SetTitleSize(0.06);
	h1->SetYTitle("#rho_{norm}");
	h1->GetYaxis()->CenterTitle(1);
	h1->GetYaxis()->SetTitleFont(32);
	h1->GetYaxis()->SetTitleSize(0.06);
	h1->GetYaxis()->SetTitleOffset(0.8);
	h1->SetLineWidth(1.5);
	h1->Draw();

	TGraphErrors *ex = new TGraphErrors(bin, VZ1, Rho0, Zero, Rho0_Err);
	ex->SetMarkerStyle(20);
	ex->SetMarkerColor(1);
	ex->SetLineColor(1);
	ex->SetLineWidth(1.5);

	TGraphErrors *ex4 = new TGraphErrors(bin, VZf, Rho0f, Zero, Rho0f_Err);
	ex4->SetMarkerStyle(20);
	ex4->SetMarkerColor(6);
	ex4->SetLineColor(6);
	ex4->SetLineWidth(1.5);
	

	TGraphErrors *ex1 = new TGraphErrors(bin, VZ1, Rho1, Zero, Rho1_Err);
	ex1->SetMarkerStyle(21);
	ex1->SetMarkerColor(6);
	ex1->SetLineColor(2);
	ex1->SetLineWidth(1.5);

	TGraphErrors *ex41 = new TGraphErrors(bin, VZf, Rho1f, Zero, Rho1f_Err);
	ex41->SetMarkerStyle(28);
	ex41->SetMarkerColor(4);
	ex41->SetLineColor(2);
	ex41->SetLineWidth(1.5);
	
	TLegend *l1  = new TLegend(0.33,0.2,0.72,0.45,Form("%s Density Profile:",Target_Name.Data()));
	l1->SetTextSize(0.03);
	l1->SetTextFont(32);

	c1->Clear(); h1->Draw();
	ex->Draw("l");
	l1->AddEntry(ex, Form("#rho_{0} calculated from #rho(%d uA) ",(int)(I1)),"l");
	ex4->Draw("p");
	l1->AddEntry(ex4, Form("#rho_{0} from Boiling Fitting"),"p");

	ex1->Draw("l");
	l1->AddEntry(ex1, Form("#rho(%d uA)  from data",(int) (I1)),"l");
	ex41->Draw("p");
	l1->AddEntry(ex41, Form("#rho(%d uA) calculated from Boiling Fitting",(int) (I1)),"p");

	l1->Draw();
//	c1->Print(Form("%s_Check_%d.png",Target_Name.Data(), (int) (I1)));
//	c1->Print(Form("%s_Check_%d.pdf",Target_Name.Data(), (int) (I1)));

	delete VZ1;
	delete VZf;
	delete Rho1;
	delete Rho0;  
	delete Rho1_Err;
	delete Rho0_Err;  
	delete Rho0f;  
	delete Rho1f;  
	delete Rho0f_Err;  
	delete Rho1f_Err;  
	delete Zero;
    delete BF;
    delete BF_Err;	
}
예제 #23
0
파일: TrackFit_SL.C 프로젝트: libov/zeus
void TrackFit_SL()
{
   // make fit box nice
   gStyle->SetOptTitle(0);
   gStyle->SetOptStat(0);
   gStyle->SetOptFit(1111);
   gStyle->SetStatX(0.46);
   gStyle->SetStatY(0.94);
   gStyle->SetStatW(0.17);
 
   TCanvas* c = new TCanvas( "c", "Parabola Fit", 0, 0, 750, 900 );
   //c->Divide(1,2);

   // get and draw data
   c->cd(1);
   TGraphErrors *data = MakeDataPoints();
   data->SetMarkerStyle(21);
   data->SetMarkerColor(2);
   data->SetLineWidth(2);
   data->SetLineColor(2);
   data->Draw("ap");

   // define parabola function
   TF1 *func = new TF1("func", "[0]+[1]*x+[2]*x*x", xmin, xmax );
   
   // do fit
   // R = entire range, + = add to list of functions
   data->Fit("func", "R+"); 

   TFile* _file=new TFile("t1.root","RECREATE");
   data->Write();
   _file->Close();



   //Double_t p0, p1, errp0, errp1, corr;
   //Double_t covMatrix[2][2];
   // get values and errors for p0 and p1
   //gMinuit->GetParameter(0, p0, errp0);
   //gMinuit->GetParameter(1, p1, errp1);
   // get covariance matrix
   //gMinuit->mnemat(&covMatrix[0][0], 2);
   
   // compute correlation between p0 and p1
   //Double_t corr = covMatrix[1][0]/(errp0*errp1);

   // compute error on y; error depends on x
   //TF1 *y_err = new TF1( "y_err", "TMath::Sqrt( [0]*[0]*x*x + [1]*[1] + 2*[2]*x )", xmin, xmax );
   //y_err->SetParameter( 0, errp0 );
   //y_err->SetParameter( 1, errp1 );
   //y_err->SetParameter( 2, covMatrix[1][0] );

   // draw 1sigma error band
   //TF1 *error1 = new TF1("error1", "func + y_err", xmin, xmax );
   //error1->SetLineWidth(1);
   //error1->Draw("same");
   
   // TF1 *error2 = new TF1("error1", "func - y_err", xmin, xmax );
   //error2->SetLineWidth(1);
   //error2->Draw("same");
   

   // ----------------- draw 1sigma error ellipse -------------------
   
   //c->cd(2);
   //TH2F *frame = new TH2F("frame", "error ellipse", 
   //                       1, p0-1.25*errp0, p0+1.25*errp0, 
   //                       1, p1-1.25*errp1, p1+1.25*errp1 );
  //frame->SetXTitle("p0");
  //   frame->SetYTitle("p1");
  //  frame->Draw();

  // draw error lines
  //  TLine *p0_line = new TLine( p0 - errp0, p1, p0 + errp0, p1 );
  // p0_line->SetLineColor(2);
  // p0_line->SetLineWidth(2);
  // p0_line->Draw();
  // TLine *p1_line = new TLine( p0, p1 - errp1, p0, p1 + errp1 );
  // p1_line->SetLineColor(2);
  // p1_line->SetLineWidth(2);
  // p1_line->Draw();
   
   // set 1 sigma contour
// gMinuit->SetErrorDef(1);
   // get contour (100 points)
// TGraph *err_ellipse = (TGraph*)gMinuit->Contour(80);
//  err_ellipse->SetLineWidth(3);
//  err_ellipse->Draw("l");

//  TLatex *text = new TLatex(p0+0.55*errp0, p1+1.02*errp1, Form("corr = %1.3f", corr) );
//  text->AppendPad();
   
}
void QA_Draw_Jet_Summary(const char *jet_family = "AntiKt_Tower",
                         const char *qa_file_name_new =
                             "data/G4sPHENIXCells_2000jets25GeV.root_qa.root",
                         const char *qa_file_name_ref =
                             "data/G4sPHENIXCells_250jets25GeV.root_qa.root")
{
  //! drawing energy range
  const double min_Et = 10;
  const double max_Et = 80;

  SetsPhenixStyle();
  TVirtualFitter::SetDefaultFitter("Minuit2");

  // file IO
  TFile *qa_file_new = new TFile(qa_file_name_new);
  assert(qa_file_new->IsOpen());

  // buffer for results
  vector<float> vec_radius;
  vector<TGraphErrors *> vec_phi_res;
  vector<TGraphErrors *> vec_eta_res;
  vector<TGraphErrors *> vec_e_res;
  vector<TGraphErrors *> vec_et_res;
  vector<TGraphErrors *> vec_reco_eff;
  vector<TGraphErrors *> vec_purity;

  // list and process all jets
  TList *hist_key_list = qa_file_new->GetListOfKeys();
  for (int i = 0; i < hist_key_list->GetSize(); ++i)
  {
    TString key_name = hist_key_list->At(i)->GetName();

    TString s_re_fullname = Form(
        "h_QAG4SimJet_.*_r[0-9]*_%s_r[0-9]*_Matching_Count_Truth_Et",
        jet_family);  // regular expression for search
    TRegexp re_fullname(s_re_fullname, false);
    if (key_name.Index(re_fullname) == kNPOS)
      continue;

    //      cout << " key_name = " << key_name << endl;
    TString jet_pair_name = key_name(0,
                                     key_name.Length() - TString("_Matching_Count_Truth_Et").Length());  // remove suffix

    //      cout << " jet_pair_name = " << jet_pair_name << endl;

    //get jet radius
    TRegexp re_jetradius("_r[0-9]*", false);
    Ssiz_t index_radius = key_name.Index(re_jetradius);             // first radius
    index_radius = key_name.Index(re_jetradius, index_radius + 1);  // second radius
    assert(index_radius != kNPOS);
    float radius = 0;
    sscanf(key_name(index_radius, 100).Data(), "_r%f", &radius);
    //      cout << " index_radius = " << index_radius << endl;
    assert(radius != 0);
    radius /= 10;  // jet radius convention in DST names

    cout << "QA_Draw_Jet_Summary - process jet pair " << jet_pair_name
         << " with radius = " << radius << endl;

    vector<TGraphErrors *> resolution_efficiency_summary(
        QA_Draw_Jet_TruthMatching(jet_pair_name, qa_file_name_new,
                                  qa_file_name_ref));

    //save results
    vec_radius.push_back(radius);
    vec_phi_res.push_back(resolution_efficiency_summary[0]);
    vec_eta_res.push_back(resolution_efficiency_summary[1]);
    vec_e_res.push_back(resolution_efficiency_summary[2]);
    vec_et_res.push_back(resolution_efficiency_summary[3]);
    vec_reco_eff.push_back(resolution_efficiency_summary[4]);
    vec_purity.push_back(resolution_efficiency_summary[5]);

    //      break;
  }

  // plot
  TCanvas *c1 = new TCanvas(
      TString("QA_Draw_Jet_Summary_") + TString(jet_family),
      TString("QA_Draw_Jet_Summary_") + TString(jet_family), 1800, 900);
  c1->Divide(3, 2);
  int idx = 1;
  TPad *p;

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  TH1 *h_frame =
      p->DrawFrame(min_Et, -.1, max_Et, .1,
                   TString(jet_family) + " #phi Reconstruction;E_{T, Truth} (GeV);#phi_{Reco} - #phi_{Truth} (rad)");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  TLine *l = new TLine(min_Et, 0, max_Et, 0);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  TLegend *legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_phi_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame =
      p->DrawFrame(min_Et, -.1, max_Et, .1,
                   TString(jet_family) + " #eta Reconstruction;E_{T, Truth} (GeV);#eta_{Reco} - #eta_{Truth}");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 0, max_Et, 0);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_eta_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame = p->DrawFrame(min_Et, 0, max_Et, 2,
                         TString(jet_family) + " Jet Energy Reconstruction;E_{Truth} (GeV);E_{Reco} / E_{Truth}");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_e_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame =
      p->DrawFrame(min_Et, 0, max_Et, 2,
                   TString(jet_family) + " Jet E_{T} Reconstruction;E_{T, Truth} (GeV);E_{T, Reco} / E_{T, Truth}");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_et_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame = p->DrawFrame(min_Et, 0, max_Et, 1.2,
                         TString(jet_family) + " Reco Efficiency;E_{T, Truth} (GeV);Reco efficiency");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_reco_eff[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame = p->DrawFrame(min_Et, 0, max_Et, 1.2,
                         TString(jet_family) + " Reconstruction Purity;E_{T, Reco} (GeV);Reconstruction Purity");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_purity[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  //  PutInputFileName(c1, .03, qa_file_name_new, qa_file_name_ref);
  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
}
예제 #25
0
void checkIntercalibration(std::vector<float> constant, std::vector<float> const_uncert, const std::string& outputdir, const std::string& runName, const std::string& tag){

  TCanvas* canny = new TCanvas("canny", "",200,200);

  int n=4;
  float vv[4] = { 0.05,1.05,2.05,3.05 };
  std::vector<float> x(&vv[0], &vv[0]+4);
  std::vector<float> xerr (4,0);

  TGraphErrors* graf = new TGraphErrors(n,&(x[0]),&(constant[0]),&(xerr[0]),&(const_uncert[0]));
  graf->SetMarkerStyle(20);
  graf->SetMarkerSize(0.5);
  graf->SetMarkerColor(38);



  float vv2[4] = { -0.05,0.95,1.95,2.95 };
  std::vector<float> x2(&vv2[0], &vv2[0]+4);
  float constantBTF[4] = {1.10023,0.9082,1.02656,0.984356};
  float constantBTF_uncert[4] = {0.0012271,0.00130331,0.00118187,0.00121551};

  TGraphErrors* graf2 = new TGraphErrors(n,&(x2[0]),&(constantBTF[0]),&(xerr[0]),&(constantBTF_uncert[0]));
  graf2->SetMarkerStyle(21);
  graf2->SetMarkerSize(0.5);
  graf2->SetMarkerColor(46);





  TMultiGraph *multi= new TMultiGraph();
  multi->Add(graf);
  multi->Add(graf2);
  multi->SetTitle(" ;Channel Nr.; Correction Factor");
  multi->Draw("AP");



  multi->GetYaxis()->SetRangeUser(0.85,1.15);
  // multi->GetYaxis()->SetRangeUser(0.1,3.5);
  multi->Draw("AP");
  canny->Update();


  TLine* lin = new TLine(-0.2,1.,3.2,1.);
  lin->SetLineColor(kRed);
  lin->Draw();

  TLegend* leg = new TLegend(0.6, 0.9-0.06*2, 0.9, 0.9); 
  leg->AddEntry(graf,"H4","P");
  leg->AddEntry(graf2,"Frascati","P");
  leg->SetFillColor(0);
  leg->Draw("same");

  if(savePlots==1){  canny->SaveAs( Form( "%s/chaInt_corrPlot_%s_%s.pdf", outputdir.c_str(), runName.c_str(), tag.c_str()  ));
    canny->SaveAs( Form( "%s/chaInt_corrPlot_%s_%s.eps", outputdir.c_str(), runName.c_str(), tag.c_str()  ));
}

  delete canny;

}
예제 #26
0
void getmeanrms(TString infile = "histos.root"){
    set_plot_style();
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);

    TH1* array[30];
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* xjgjetone = (TH1*)gROOT->FindObject("unfold5p2");
    array[0]= xjgjetone;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* xjgjettwo = (TH1*)gROOT->FindObject("unfold5p3");
    array[1]= xjgjettwo;

    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* xjgjetthree = (TH1*)gROOT->FindObject("unfold5p4");
    array[2]= xjgjetthree;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfour = (TH1*)gROOT->FindObject("unfold10p2");
    array[3]= xjgjetfour;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfive = (TH1*)gROOT->FindObject("unfold10p3");
    array[4]= xjgjetfive;

    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* xjgjetsix = (TH1*)gROOT->FindObject("unfold10p4");
    array[5]= xjgjetsix;
    
    TFile *_file6 = TFile::Open("unfoldplots.root");
    TH1* xjgjetseven = (TH1*)gROOT->FindObject("unfold15p2");
    array[6]= xjgjetseven;
    
    TFile *_file7 = TFile::Open("unfoldplots.root");
    TH1* xjgjeteight = (TH1*)gROOT->FindObject("unfold15p3");
    array[7]= xjgjeteight;
    
    TFile *_file8 = TFile::Open("unfoldplots.root");
    TH1* xjgjetnine = (TH1*)gROOT->FindObject("unfold15p4");
    array[8]= xjgjetnine;
    
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* xjgjetonea = (TH1*)gROOT->FindObject("unfold20p2");
    array[9]= xjgjetonea;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* xjgjettwoa = (TH1*)gROOT->FindObject("unfold20p3");
    array[10]= xjgjettwoa;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* xjgjetthreea = (TH1*)gROOT->FindObject("unfold20p4");
    array[11]= xjgjetthreea;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfoura = (TH1*)gROOT->FindObject("unfold25p2");
    array[12]= xjgjetfoura;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfivea = (TH1*)gROOT->FindObject("unfold25p3");
    array[13]= xjgjetfivea;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* xjgjetsixa = (TH1*)gROOT->FindObject("unfold25p4");
    array[14]= xjgjetsixa;
    
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* xjgjetone = (TH1*)gROOT->FindObject("unfold30p2");
    array[15]= xjgjetone;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* xjgjettwo = (TH1*)gROOT->FindObject("unfold30p3");
    array[16]= xjgjettwo;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* xjgjetthree = (TH1*)gROOT->FindObject("unfold30p4");
    array[17]= xjgjetthree;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfour = (TH1*)gROOT->FindObject("unfold35p2");
    array[18]= xjgjetfour;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfive = (TH1*)gROOT->FindObject("unfold35p3");
    array[19]= xjgjetfive;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* xjgjetsix = (TH1*)gROOT->FindObject("unfold35p4");
    array[20]= xjgjetsix;
    
    TFile *_file6 = TFile::Open("unfoldplots.root");
    TH1* xjgjetseven = (TH1*)gROOT->FindObject("unfold40p2");
    array[21]= xjgjetseven;
    
    TFile *_file7 = TFile::Open("unfoldplots.root");
    TH1* xjgjeteight = (TH1*)gROOT->FindObject("unfold40p3");
    array[22]= xjgjeteight;
    
    TFile *_file8 = TFile::Open("unfoldplots.root");
    TH1* xjgjetnine = (TH1*)gROOT->FindObject("unfold40p4");
    array[23]= xjgjetnine;
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* xjgjetone = (TH1*)gROOT->FindObject("unfold45p2");
    array[24]= xjgjetone;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* xjgjettwo = (TH1*)gROOT->FindObject("unfold45p3");
    array[25]= xjgjettwo;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* xjgjetthree = (TH1*)gROOT->FindObject("unfold45p4");
    array[26]= xjgjetthree;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfour = (TH1*)gROOT->FindObject("unfold50p2");
    array[27]= xjgjetfour;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* xjgjetfive = (TH1*)gROOT->FindObject("unfold50p3");
    array[28]= xjgjetfive;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* xjgjetsix = (TH1*)gROOT->FindObject("unfold50p4");
    array[29]= xjgjetsix;
    
    TH1* carray[30];
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* cone = (TH1*)gROOT->FindObject("True5p2");
    carray[0]= cone;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* ctwo = (TH1*)gROOT->FindObject("True5p3");
    carray[1]= ctwo;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* cthree = (TH1*)gROOT->FindObject("True5p4");
    carray[2]= cthree;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* cfour = (TH1*)gROOT->FindObject("True10p2");
    carray[3]= cfour;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* cfive = (TH1*)gROOT->FindObject("True10p3");
    carray[4]= cfive;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* csix = (TH1*)gROOT->FindObject("True10p4");
    carray[5]= csix;
    
    TFile *_file6 = TFile::Open("unfoldplots.root");
    TH1* cseven = (TH1*)gROOT->FindObject("True15p2");
    carray[6]= cseven;
    
    TFile *_file7 = TFile::Open("unfoldplots.root");
    TH1* ceight = (TH1*)gROOT->FindObject("True15p3");
    carray[7]= ceight;
    
    TFile *_file8 = TFile::Open("unfoldplots.root");
    TH1* cnine = (TH1*)gROOT->FindObject("True15p4");
    carray[8]= cnine;
    
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* conea = (TH1*)gROOT->FindObject("True20p2");
    carray[9]= conea;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* ctwoa = (TH1*)gROOT->FindObject("True20p3");
    carray[10]= ctwoa;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* cthreea = (TH1*)gROOT->FindObject("True20p4");
    carray[11]= cthreea;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* cfoura = (TH1*)gROOT->FindObject("True25p2");
    carray[12]= cfoura;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* cfivea = (TH1*)gROOT->FindObject("True25p3");
    carray[13]= cfivea;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* csixa = (TH1*)gROOT->FindObject("True25p4");
    carray[14]= csixa;
    
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* cone = (TH1*)gROOT->FindObject("True30p2");
    carray[15]= cone;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* ctwo = (TH1*)gROOT->FindObject("True30p3");
    carray[16]= ctwo;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* cthree = (TH1*)gROOT->FindObject("True30p4");
    carray[17]= cthree;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* cfour = (TH1*)gROOT->FindObject("True35p2");
    carray[18]= cfour;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* cfive = (TH1*)gROOT->FindObject("True35p3");
    carray[19]= cfive;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* csix = (TH1*)gROOT->FindObject("True35p4");
    carray[20]= csix;
    
    TFile *_file6 = TFile::Open("unfoldplots.root");
    TH1* cseven = (TH1*)gROOT->FindObject("True40p2");
    carray[21]= cseven;
    
    TFile *_file7 = TFile::Open("unfoldplots.root");
    TH1* ceight = (TH1*)gROOT->FindObject("True40p3");
    carray[22]= ceight;
    
    TFile *_file8 = TFile::Open("unfoldplots.root");
    TH1* cnine = (TH1*)gROOT->FindObject("True40p4");
    carray[23]= cnine;
    TFile *_file0 = TFile::Open("unfoldplots.root");
    TH1* cone = (TH1*)gROOT->FindObject("True45p2");
    carray[24]= cone;
    
    TFile *_file1 = TFile::Open("unfoldplots.root");
    TH1* ctwo = (TH1*)gROOT->FindObject("True45p3");
    carray[25]= ctwo;
    
    TFile *_file2 = TFile::Open("unfoldplots.root");
    TH1* cthree = (TH1*)gROOT->FindObject("True45p4");
    carray[26]= cthree;
    
    TFile *_file3 = TFile::Open("unfoldplots.root");
    TH1* cfour = (TH1*)gROOT->FindObject("True50p2");
    carray[27]= cfour;
    
    TFile *_file4 = TFile::Open("unfoldplots.root");
    TH1* cfive = (TH1*)gROOT->FindObject("True50p3");
    carray[28]= cfive;
    
    TFile *_file5 = TFile::Open("unfoldplots.root");
    TH1* csix = (TH1*)gROOT->FindObject("True50p4");
    carray[29]= csix;
    
    TCanvas* c3 = new TCanvas("c3","",1000,1000);
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.0);
    gPad->SetTopMargin(0.0);
    gPad->SetBottomMargin(0.0);
    c3->Divide(3,5);
    for(int i=0;i<15;i++){
        c3->cd(i+1);
        carray[i]->SetLineColor(kGreen+3);
        carray[i]->Draw();
        carray[i]->GetXaxis()->SetTitle("X_{J#gamma}");
        //carray[i]->GetXaxis()->SetTitleSize(.1);
        gPad->SetLogy();
        gPad->SetLeftMargin(0.1);
        gPad->SetRightMargin(0.1);
        gPad->SetTopMargin(0.1);
        gPad->SetBottomMargin(0.1);
        if(i==0){
            TLegend* leg = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg,.05);
            leg->SetHeader("P_{T,min}=5 GeV");
            leg->AddEntry("array[0]","R=0.2","");
            //leg->AddEntry("array[0]","combined tracks","");
            leg->SetTextSize(.15);
            leg->Draw();
        }
        else if(i==1){
            TLegend* leg2 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg2,.05);
            leg2->SetHeader("R=0.3");
            leg2->AddEntry(array[0],"unfolded","l");
            leg2->AddEntry(carray[0],"pythia","l");
            leg2->SetTextSize(.15);
            leg2->Draw();
        }
        else if(i==2){
            TLegend* leg3 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg3,.05);
            leg3->SetHeader("R=0.4");
            leg3->SetTextSize(.15);
            leg3->Draw();
        }
        else if(i==3){
            TLegend* leg4 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg4,.05);
            leg4->SetHeader("Ptmin=10 GeV");
            leg4->SetTextSize(.15);
            leg4->Draw();
        }
        else if(i==6){
            TLegend* leg5 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg5,.05);
            leg5->SetHeader("Ptmin=15 GeV");
            leg5->SetTextSize(.15);
            leg5->Draw();
        }
        else if(i==9){
            TLegend* leg5 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg5,.05);
            leg5->SetHeader("Ptmin=20 GeV");
            leg5->SetTextSize(.15);
            leg5->Draw();
        }
        else if(i==12){
            TLegend* leg5 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg5,.05);
            leg5->SetHeader("Ptmin=25 GeV");
            leg5->SetTextSize(.15);
            leg5->Draw();
        }
        //*scale= ((carray[i]->Integral(0,50))/(array[i]->Integral(0,50)));
        //array[i]->Scale(scale);
        array[i]->SetLineColor(kRed);
        array[i]->Draw("same");
        //cout<<scale<<endl;
    }
    
    TCanvas* c4 = new TCanvas("c4","",1000,1000);
    
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.0);
    gPad->SetTopMargin(0.0);
    gPad->SetBottomMargin(0.0);
    c4->Divide(3,5);
    for(int i=15;i<30;i++){
        c4->cd(i-14);
        carray[i]->SetLineColor(kGreen+3);
        carray[i]->Draw();
        carray[i]->GetXaxis()->SetTitle("X_{J#gamma}");
        //carray[i]->GetXaxis()->SetTitleSize(.03);
        gPad->SetLogy();
        gPad->SetLeftMargin(0.1);
        gPad->SetRightMargin(0.1);
        gPad->SetTopMargin(0.1);
        gPad->SetBottomMargin(0.1);
        if(i==15){
            TLegend* leg6 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg6,.05);
            leg6->SetHeader("P_{T,min}=30 GeV");
            leg6->AddEntry("array[15]","R=0.2","");
            //leg6->AddEntry("array[15]","unfolded","");
            leg6->SetTextSize(.15);
            leg6->Draw();
        }
        else if(i==16){
            TLegend* leg2 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg2,.05);
            leg2->SetHeader("R=0.3");
            leg2->AddEntry(array[0],"unfolded","l");
            leg2->AddEntry(carray[0],"pythia","l");
            leg2->SetTextSize(.15);
            leg2->Draw();
        }
        else if(i==17){
            TLegend* leg3 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg3,.05);
            leg3->SetHeader("R=0.4");
            leg3->SetTextSize(.15);
            leg3->Draw();
        }
        else if(i==18){
            TLegend* leg7 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg7,.05);
            leg7->SetHeader("Ptmin=35 GeV");
            leg7->SetTextSize(.15);
            leg7->Draw();
        }
        else if(i==21){
            TLegend* leg8 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg8,.05);
            leg8->SetHeader("Ptmin=40 GeV");
            leg8->SetTextSize(.15);
            leg8->Draw();
        }
        else if(i==24){
            TLegend* leg9 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg9,.05);
            leg9->SetHeader("Ptmin=45 GeV");
            leg9->SetTextSize(.15);
            leg9->Draw();
        }
        else if(i==27){
            TLegend* leg10 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg10,.05);
            leg10->SetHeader("Ptmin=50 GeV");
            leg10->SetTextSize(.15);
            leg10->Draw();
        }
        //scale= ((carray[i]->Integral(0,50))/(array[i]->Integral(0,50)));
        //array[i]->Scale(scale);
        array[i]->SetLineColor(kRed);
        array[i]->Draw("same");
        //cout<<scale<<endl;
    }
  
    
    TCanvas* c4 = new TCanvas("c4","",1000,1000);
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.0);
    gPad->SetTopMargin(0.0);
    gPad->SetBottomMargin(0.0);
    c4->Divide(3,1);
    for(int i=0;i<3;i++){
        c4->cd(i+1);
        carray[i]->SetLineColor(kGreen+3);
        carray[i]->Draw();
        carray[i]->GetXaxis()->SetTitle("X_{J#gamma}");
        //carray[i]->GetXaxis()->SetTitleSize(.1);
        gPad->SetLogy();
        gPad->SetLeftMargin(0.1);
        gPad->SetRightMargin(0.1);
        gPad->SetTopMargin(0.1);
        gPad->SetBottomMargin(0.1);
        if(i==0){
            TLegend* leg = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg,.05);
            leg->SetHeader("P_{T,min}=5 GeV");
            leg->AddEntry("array[0]","R=0.2","");
            //leg->AddEntry("array[0]","combined tracks","");
            leg->SetTextSize(.1);
            leg->Draw();
        }
        else if(i==1){
            TLegend* leg2 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg2,.05);
            leg2->SetHeader("R=0.3");
            leg2->AddEntry(array[0],"unfolded","l");
            leg2->AddEntry(carray[0],"pythia","l");
            leg2->SetTextSize(.1);
            leg2->Draw();
        }
        else if(i==2){
            TLegend* leg3 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg3,.05);
            leg3->SetHeader("R=0.4");
            leg3->SetTextSize(.1);
            leg3->Draw();
        }
        array[i]->SetLineColor(kRed);
        array[i]->Draw("same");
    }
    TCanvas* c5 = new TCanvas("c5","",1000,1000);
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.0);
    gPad->SetTopMargin(0.0);
    gPad->SetBottomMargin(0.0);
    c5->Divide(3,1);
    for(int i=27;i<30;i++){
        c5->cd(i-26);
        carray[i]->SetLineColor(kGreen+3);
        carray[i]->Draw();
        carray[i]->GetXaxis()->SetTitle("X_{J#gamma}");
        //carray[i]->GetXaxis()->SetTitleSize(.1);
        gPad->SetLogy();
        gPad->SetLeftMargin(0.1);
        gPad->SetRightMargin(0.1);
        gPad->SetTopMargin(0.1);
        gPad->SetBottomMargin(0.1);
        if(i==27){
            TLegend* leg = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg,.05);
            leg->SetHeader("P_{T,min}=50 GeV");
            leg->AddEntry("array[0]","R=0.2","");
            //leg->AddEntry("array[0]","combined tracks","");
            leg->SetTextSize(.1);
            leg->Draw();
        }
        else if(i==28){
            TLegend* leg2 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg2,.05);
            leg2->SetHeader("R=0.3");
            leg2->AddEntry(array[0],"unfolded","l");
            leg2->AddEntry(carray[0],"pythia","l");
            leg2->SetTextSize(.1);
            leg2->Draw();
        }
        else if(i==29){
            TLegend* leg3 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg3,.05);
            leg3->SetHeader("R=0.4");
            leg3->SetTextSize(.1);
            leg3->Draw();
        }
        array[i]->SetLineColor(kRed);
        array[i]->Draw("same");
    }
    
    TCanvas* c2 = new TCanvas("c2","",1000,1000);
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.0);
    gPad->SetTopMargin(0.0);
    gPad->SetBottomMargin(0.0);
    c2->Divide(3,5);
    for(int i=15;i<30;i++){
        c2->cd(i-14);
        carray[i]->Draw("colz");
        gPad->SetLogz();
        gPad->SetLeftMargin(0.1);
        gPad->SetRightMargin(0.1);
        gPad->SetTopMargin(0.1);
        gPad->SetBottomMargin(0.1);
        if(i==15){
            TLegend* leg = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg,.05);
            leg->SetHeader("Ptmin=5 GeV");
            leg->AddEntry("array[0]","R=0.2","");
            leg->AddEntry("array[0]","PYTHIA+Background-rho jets","");
            leg->Draw();
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==16){
            TLegend* leg2 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg2,.05);
            leg2->SetHeader("R=0.3");
            leg2->Draw();
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
        }
        else if(i==17){
            TLegend* leg3 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg3,.05);
            leg3->SetHeader("R=0.4");
            leg3->Draw();
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
        }
        else if(i==18){
            TLegend* leg4 = new TLegend(0.6,0.7,0.85,0.85);
            SetLeg(leg4,.05);
            leg4->SetHeader("Ptmin=15 GeV");
            leg4->Draw();
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==19){
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
        }
        else if(i==20){
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
        }
        else if(i==21){
            TLegend* leg5 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg5,.05);
            leg5->SetHeader("Ptmin=25 GeV");
            leg5->Draw();
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==22){
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==23){
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==24){
            TLegend* leg5 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg5,.05);
            leg5->SetHeader("Ptmin=35 GeV");
            leg5->Draw();
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==25){
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==26){
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
            array[i]->GetXaxis()->SetLabelOffset(999);
            array[i]->GetXaxis()->SetLabelSize(0);
        }
        else if(i==27){
            TLegend* leg5 = new TLegend(0.7,0.8,0.85,0.85);
            SetLeg(leg5,.05);
            leg5->SetHeader("Ptmin=45 GeV");
            leg5->Draw();
        }
        else if(i==28){
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
        }
        else if(i==29){
            array[i]->GetYaxis()->SetLabelOffset(999);
            array[i]->GetYaxis()->SetLabelSize(0);
        }
        
    }
    
    TCanvas *c3= new TCanvas("c3","",1000,1000);
    TH1* Projection[30];
    for(int i=0;i<30;i++){
        Projection[i]=array[i]->ProjectionY("Projection[i]",1,-1);
        cout<<Projection[i]->GetRMS(1)<<endl;
        //cout<<Projection[i]->GetMean()<<endl;
    }
    Double_t jpt5[3]={0.469616,0.528041,0.566678};
    Double_t jpt15[3]={0.558344,0.627056,0.641796};
    Double_t jpt25[3]={0.6521,0.710176,0.719287};
    Double_t jpt35[3]={0.701202,0.753099,0.757408};
    Double_t jpt45[3]={0.742131,0.792112,0.806184};
    Double_t spt5[3]={1.09789,1.40334,1.90479};
    Double_t spt15[3]={0.648738,0.805447,1.05616};
    Double_t spt25[3]={0.699613,0.815683,0.985538};
    Double_t spt35[3]={0.735253,0.831829,0.95974};
    Double_t spt45[3]={0.760689,0.841417,0.946005};
    Double_t ejpt5[3]={0.243201,0.287315,0.330208};
    Double_t ejpt15[3]={0.264054,0.302826,0.342976};
    Double_t ejpt25[3]={0.254102,0.277335,0.316553};
    Double_t ejpt35[3]={0.234616,0.249164,0.287426};
    Double_t ejpt45[3]={0.207817,0.211231,0.238832};
    Double_t espt5[3]={0.331098,0.443326,0.52885};
    Double_t espt15[3]={0.228333,0.260963,0.307121};
    Double_t espt25[3]={0.23027,0.235426,0.248455};
    Double_t espt35[3]={0.218582,0.211284,0.215638};
    Double_t espt45[3]={0.202461,0.19085,0.191792};
    Double_t count[3]={0.21,0.31,0.41};
    Double_t count2[3]={0.19,0.29,0.39};
    Double_t ex[3]={0,0,0};
    TGraphErrors *f = new TGraphErrors(3,count,jpt5,ex,ejpt5);
    f->GetYaxis()->SetRangeUser(0,3);
    f->GetXaxis()->SetRangeUser(.15,.42);
    f->SetMarkerStyle(23);
    f->SetMarkerSize(2);
    f->SetMarkerColor(kAzure);
    f->SetLineColor(kAzure);
    f->GetYaxis()->SetTitle("Mean XJG");
    f->GetXaxis()->SetTitle("Jet Radius");
    f->Draw("APsame");
    TGraphErrors *g = new TGraphErrors(3,count2,jpt15,ex,ejpt15);
    //g->GetYaxis()->SetRangeUser(0,2);
    g->SetMarkerStyle(23);
    g->SetMarkerSize(2);
    g->SetMarkerColor(kMagenta);
    g->SetLineColor(kMagenta);
    g->Draw("Psame");
    TGraphErrors *h = new TGraphErrors(3,count,jpt25,ex,ejpt25);
    //h->GetYaxis()->SetRangeUser(0,2);
    h->SetMarkerStyle(23);
    h->SetMarkerSize(2);
    h->SetMarkerColor(kRed);
    h->SetLineColor(kRed);
    h->Draw("P");
    TGraphErrors *w = new TGraphErrors(3,count2,jpt35,ex,ejpt35);
    //g->GetYaxis()->SetRangeUser(0,2);
    w->SetMarkerStyle(23);
    w->SetMarkerSize(2);
    w->SetMarkerColor(kOrange);
    w->SetLineColor(kOrange);
    w->Draw("P");
    TGraphErrors *q = new TGraphErrors(3,count,jpt45,ex,ejpt45);
    //h->GetYaxis()->SetRangeUser(0,2);
    q->SetMarkerStyle(23);
    q->SetMarkerSize(2);
    q->SetMarkerColor(kGreen);
    q->SetLineColor(kGreen);
    q->Draw("P");
    TGraphErrors *j = new TGraphErrors(3,count,spt5,ex,espt5);
    //h->GetYaxis()->SetRangeUser(0,2);
    j->SetMarkerStyle(28);
    j->SetMarkerSize(2);
    j->SetMarkerColor(kAzure);
    j->SetLineColor(kAzure);
    j->Draw("P");
    TGraphErrors *k = new TGraphErrors(3,count2,spt15,ex,espt15);
    //h->GetYaxis()->SetRangeUser(0,2);
    k->SetMarkerStyle(28);
    k->SetMarkerSize(2);
    k->SetMarkerColor(kMagenta);
    k->SetLineColor(kMagenta);
    k->Draw("P");
    TGraphErrors *l = new TGraphErrors(3,count,spt25,ex,espt25);
    //h->GetYaxis()->SetRangeUser(0,2);
    l->SetMarkerStyle(28);
    l->SetMarkerSize(2);
    l->SetMarkerColor(kRed);
    l->SetLineColor(kRed);
    l->Draw("P");
    TGraphErrors *r = new TGraphErrors(3,count2,spt35,ex,espt35);
    //g->GetYaxis()->SetRangeUser(0,2);
    r->SetMarkerStyle(28);
    r->SetMarkerSize(2);
    r->SetMarkerColor(kOrange);
    r->SetLineColor(kOrange);
    r->Draw("P");
    TGraphErrors *y = new TGraphErrors(3,count,spt45,ex,espt45);
    //h->GetYaxis()->SetRangeUser(0,2);
    y->SetMarkerStyle(28);
    y->SetMarkerSize(2);
    y->SetMarkerColor(kGreen);
    y->SetLineColor(kGreen);
    y->Draw("P");
    TLegend* leg6 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg6,.03);
    leg6->SetTextColor(kAzure);
    leg6->AddEntry("f","ptmin=5 GeV","");
    leg6->Draw();
    TLegend* leg7 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg7,.03);
    leg7->SetTextColor(kMagenta);
    leg7->AddEntry("f","ptmin=15 GeV","");
    leg7->Draw();
    TLegend* leg8 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg8,.03);
    leg8->SetTextColor(kRed);
    leg8->AddEntry("f","ptmin=25 GeV","");
    leg8->Draw();
    TLegend* leg10 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg10,.03);
    leg10->SetTextColor(kOrange);
    leg10->AddEntry("f","ptmin=35 GeV","");
    leg10->Draw();
    TLegend* leg11 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg11,.03);
    leg11->SetTextColor(kGreen);
    leg11->AddEntry("f","ptmin=45 GeV","");
    leg11->Draw();
    TLegend* leg9 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg9,.03);
    leg9->AddEntry(f,"PYTHIA","P");
    leg9->AddEntry(y,"PYTHIA-Rho","P");
    leg9->Draw();

    TCanvas *c4= new TCanvas("c4","",1000,1000);
    
    TGraph*f1 = new TGraph(3,count,ejpt5);
    f1->GetYaxis()->SetRangeUser(0,1);
    f1->GetXaxis()->SetRangeUser(.15,.42);
    f1->SetMarkerStyle(23);
    f1->SetMarkerSize(2);
    f1->SetMarkerColor(kAzure);
    f1->SetLineColor(kAzure);
    f1->GetYaxis()->SetTitle("RMS");
    f1->GetXaxis()->SetTitle("Jet Radius");
    f1->Draw("APsame");
    TGraph *g1 = new TGraph(3,count2,ejpt15);
    //g->GetYaxis()->SetRangeUser(0,2);
    g1->SetMarkerStyle(23);
    g1->SetMarkerSize(2);
    g1->SetMarkerColor(kMagenta);
    g1->SetLineColor(kMagenta);
    g1->Draw("P");
    TGraph *h1 = new TGraph(3,count,ejpt25);
    //h->GetYaxis()->SetRangeUser(0,2);
    h1->SetMarkerStyle(23);
    h1->SetMarkerSize(2);
    h1->SetMarkerColor(kRed);
    h1->SetLineColor(kRed);
    h1->Draw("P");
    TGraph *w1 = new TGraph(3,count2,ejpt35);
    //g->GetYaxis()->SetRangeUser(0,2);
    w1->SetMarkerStyle(23);
    w1->SetMarkerSize(2);
    w1->SetMarkerColor(kOrange);
    w1->SetLineColor(kOrange);
    w1->Draw("P");
    TGraph *q1 = new TGraph(3,count,ejpt45);
    //h->GetYaxis()->SetRangeUser(0,2);
    q1->SetMarkerStyle(23);
    q1->SetMarkerSize(2);
    q1->SetMarkerColor(kGreen);
    q1->SetLineColor(kGreen);
    q1->Draw("P");
    TGraph *j1 = new TGraph(3,count,espt5);
    //h->GetYaxis()->SetRangeUser(0,2);
    j1->SetMarkerStyle(28);
    j1->SetMarkerSize(2);
    j1->SetMarkerColor(kAzure);
    j1->SetLineColor(kAzure);
    j1->Draw("P");
    TGraph *k1 = new TGraph(3,count2,espt15);
    //h->GetYaxis()->SetRangeUser(0,2);
    k1->SetMarkerStyle(28);
    k1->SetMarkerSize(2);
    k1->SetMarkerColor(kMagenta);
    k1->SetLineColor(kMagenta);
    k1->Draw("P");
    TGraph *l1 = new TGraph(3,count,espt25);
    //h->GetYaxis()->SetRangeUser(0,2);
    l1->SetMarkerStyle(28);
    l1->SetMarkerSize(2);
    l1->SetMarkerColor(kRed);
    l1->SetLineColor(kRed);
    l1->Draw("P");
    TGraph *r1 = new TGraph(3,count2,espt35);
    //g->GetYaxis()->SetRangeUser(0,2);
    r1->SetMarkerStyle(28);
    r1->SetMarkerSize(2);
    r1->SetMarkerColor(kOrange);
    r1->SetLineColor(kOrange);
    r1->Draw("P");
    TGraph *y1 = new TGraph(3,count,espt45);
    //h->GetYaxis()->SetRangeUser(0,2);
    y1->SetMarkerStyle(28);
    y1->SetMarkerSize(2);
    y1->SetMarkerColor(kGreen);
    y1->SetLineColor(kGreen);
    y1->Draw("P");
    TLegend* leg6 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg6,.03);
    leg6->SetTextColor(kAzure);
    leg6->AddEntry("f","ptmin=5 GeV","");
    leg6->Draw();
    TLegend* leg7 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg7,.03);
    leg7->SetTextColor(kMagenta);
    leg7->AddEntry("f","ptmin=15 GeV","");
    leg7->Draw();
    TLegend* leg8 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg8,.03);
    leg8->SetTextColor(kRed);
    leg8->AddEntry("f","ptmin=25 GeV","");
    leg8->Draw();
    TLegend* leg10 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg10,.03);
    leg10->SetTextColor(kOrange);
    leg10->AddEntry("f","ptmin=35 GeV","");
    leg10->Draw();
    TLegend* leg11 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg11,.03);
    leg11->SetTextColor(kGreen);
    leg11->AddEntry("f","ptmin=45 GeV","");
    leg11->Draw();
    TLegend* leg9 = new TLegend(0.7,0.8,0.85,0.85);
    SetLeg(leg9,.03);
    leg9->AddEntry(f,"PYTHIA","P");
    leg9->AddEntry(y,"PYTHIA-Rho","P");
    leg9->Draw();

}
예제 #27
0
void drawRAA(bool doInclusiveJet=0, bool useUnfolded=1, bool drawTheory=1){

  bool drawPowheg = 0;
  
  float etalo=-2;
  float etahi=2;

  TH1D *dEta80To110 = new TH1D("dEta80To110","",4,-2.465,1.535);
  TH1D *dEta110To150 = new TH1D("dEta110To150","",4,-2.365,1.635);
  TH1D *dEta70To80 = new TH1D("dEta70To80","",4,-2.565,1.435);
  TH1D *dEta150To190 = new TH1D("dEta150To190","",4,-2.265,1.735);

  int nbins = 3;
  double xbins[4] = {0,20,50,100};
  double xbins2[4] = {2,22,52,102};
  double xbins3[4] = {-2,18,48,98};
  double xbins4[4] = {4,24,54,104};
  TH1D *dCent70To80 = new TH1D("dCent70To80","",nbins,xbins3);
  TH1D *dCent80To110 = new TH1D("dCent80To110","",nbins,xbins);
  TH1D *dCent110To150 = new TH1D("dCent110To150","",nbins,xbins2);
  TH1D *dCent150To190 = new TH1D("dCent150To190","",nbins,xbins4);
  
  //for(int ieta=-2; ieta<2; ieta++){
  //  etalo=(float)(ieta+0.5);
  //  etahi=(float)(ieta+1.5);

  int binLo, binHi;
  //for(int icent=0; icent<3; icent++){
  //  if(icent==0){ binLo = 0; binHi=20; }
  //  if(icent==1){ binLo = 20; binHi=50; }
  //  if(icent==2){ binLo = 50; binHi=100; }
  
    TH1D *h = new TH1D();
    TH1D *h2 = new TH1D();
    TH1D *h_den = new TH1D();
    h->Sumw2();
    h2->Sumw2();
    h_den->Sumw2();
    TH1D *he1 = new TH1D();
    TH1D *he2 = new TH1D();
    TH1D *he3 = new TH1D();
    TH1D *he4 = new TH1D();
    he1->Sumw2(); he2->Sumw2(); he3->Sumw2(); he4->Sumw2();

    //grab unfolded histograms from the unfolding output (inclusive)
    TFile *f0, *f2, *f5,*f6,*f7,*f8;
    TFile *fIncl = new TFile("~/bTagTrees/pPb/raa_pPb_numerator-inc_eta-1.0To1.0.root");
    TFile *fInclB = new TFile("~/bTagTrees/pPb/raa_pp_denomForpA-inc_eta-1.0To1.0.root");
    TH1D *hinclTop = (TH1D*)fIncl->Get("hReco0")->Clone("hinclTop");
    TH1D *hinclBot = (TH1D*)fInclB->Get("hGen_cent1")->Clone("hinclBot");
    for(int i=1; i<=hinclTop->GetNbinsX(); i++){
      hinclTop->SetBinError(i,hinclTop->GetBinError(i)/hinclTop->GetBinWidth(i));
      hinclTop->SetBinContent(i,hinclTop->GetBinContent(i)/hinclTop->GetBinWidth(i));
      hinclBot->SetBinError(i,hinclBot->GetBinError(i)/hinclBot->GetBinWidth(i));
      hinclBot->SetBinContent(i,hinclBot->GetBinContent(i)/hinclBot->GetBinWidth(i));
    }
    hinclTop->Scale(1./6.9);
    hinclTop->Divide(hinclBot);
    hinclTop->SetMarkerColor(4);
    //hinclTop->Scale(0.689);

    //grab unfolded histograms from the unfolding output (bjet)
    if(doInclusiveJet) f0 = new TFile(Form("~/bTagTrees/pPb/raa_pPb_numerator-inc_eta%.1fTo%.1f.root",etalo,etahi));
    //else f0 = new TFile(Form("~/bTagTrees/pPb/raa_pPb_numerator-Incljet_FullDataset_ssvhe20_etaCM_v2_bin0_100_eta%.1fTo%.1f.root",etalo,etahi)); //incl jet unfolding
    else if(useUnfolded){
      f0 = new TFile(Form("~/bTagTrees/pPb/raa_pPb_numerator-Bjet_FullDataset_ssvhe20_etaCM_v2_bin0_100_eta%.1fTo%.1f.root",etalo,etahi)); //bjet unfolding
      f5 = new TFile("~/bTagTrees/pPb/raa_pPb_numerator-Bjet_FullDataset_ssvhe20_etaCM_eta-2.0To-1.0.root");
      f6 = new TFile("~/bTagTrees/pPb/raa_pPb_numerator-Bjet_FullDataset_ssvhe20_etaCM_eta-1.0To0.0.root");
      f7 = new TFile("~/bTagTrees/pPb/raa_pPb_numerator-Bjet_FullDataset_ssvhe20_etaCM_eta0.0To1.0.root");
      f8 = new TFile("~/bTagTrees/pPb/raa_pPb_numerator-Bjet_FullDataset_ssvhe20_etaCM_eta1.0To2.0.root");
    }
    else{
      f0 = new TFile(Form("~/bTagTrees/pPb/raa_pPb_numerator-Bjet_NoUnfolding_FullDataset_ssvhe20_etaCM_v2_bin0_100_eta%.1fTo%.1f.root",etalo,etahi));
    }

    if(useUnfolded){
      h = (TH1D*)(f0->Get("hReco0"));
      he1 = (TH1D*)(f5->Get("hReco0"));
      he2 = (TH1D*)(f6->Get("hReco0"));
      he3 = (TH1D*)(f7->Get("hReco0"));
      he4 = (TH1D*)(f8->Get("hReco0"));
    }
    else if(doInclusiveJet) h = (TH1D*)(f0->Get("hIncJetsData"));
    else h = (TH1D*)(f0->Get("hReco0"));

    //h = (TH1D*)he1->Clone("h");
    //he1->Add(he2);
    //he1->Add(he3);
    //he1->Add(he4);
    //h->Scale(1./6.9);

    /* for(int i=1; i<=h->GetNbinsX(); i++){
       h->SetBinError(i, h->GetBinError(i)/h->GetBinWidth(i));
       h->SetBinContent(i, h->GetBinContent(i)/h->GetBinWidth(i));
       }*/
    //h->Scale(1./6.9); //pPb total N coll (L*pp x-sec * A, sigma_pp = 70 mb @ CERN)  
  
    if(doInclusiveJet) f2 = new TFile(Form("~/bTagTrees/pPb/raa_pp_denomForpA-inc_eta%.1fTo%.1f.root",etalo,etahi),"OLD");
    else f2 = new TFile(Form("~/bTagTrees/pPb/raa_pp_denomForpA-Bjet_etaCM_v2_bin0_100_eta%.1fTo%.1f.root",etalo,etahi),"OLD"); //incl jet unfolding
    //else f2 = new TFile(Form("raa_pp_denomForpA-Bjet_etaLab_eta%.1fTo%.1f.root",etalo,etahi),"OLD"); //bjet unfolding
    f2->cd();
    //h_den = (TH1D*)(f2->Get("hRawBMC"));
    if(useUnfolded) h_den = (TH1D*)f2->Get("hGen_cent1");
    else if(doInclusiveJet) h_den = (TH1D*)(f2->Get("hIncJetsMC"));
    else h_den = (TH1D*)(f2->Get("hGen_cent1"));

    TFile *xchk = new TFile("histos/ppMC_ppReco_akPu3PF_QCDjetTrig_etashift_Fix2Sample_MCWeightFinalWithVz_noTrgSelection_Full.root");
    TTree *nt1 = (TTree*)xchk->Get("nt");
    double xbinsXchk[19] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 55, 70, 90, 110, 140, 170, 220, 400, 700, 1000};
    TH1D *hf = new TH1D("hf","",18,xbinsXchk); hf->Sumw2();
    nt1->Project("hf","refpt","weight*(abs(refparton_flavorForB)==5 && jteta<2 && jteta>-2 && jtpt>35 && rawpt>20)");
    for(int i=1; i<=hf->GetNbinsX(); i++){
      hf->SetBinError(i,hf->GetBinError(i)/hf->GetBinWidth(i));
      hf->SetBinContent(i,hf->GetBinContent(i)/hf->GetBinWidth(i));
    }
    hf->SetLineColor(kRed+2);
    //hf->Scale(1E9);
    //hf->Scale(1./70.);
    //hf->Scale(10.);
    //h_den = hf;

    TFile *ff = new TFile("pPb_Unfo_inCM_v31_officialMC_ak3PF_akPu3PF_noGplus_FirstHalfOnly_Converged_usedParameterizedUnfold0_jtpt35_bJets_clo0_chi100_v8_eta_-2.00To2.00_.root");
    TH1D *hfCheck2 = (TH1D*)ff->Get("hGen_cent1");
    TFile *ff2 = new TFile("pPb_Unfo_inCM_v31_officialMC_Reverse_WithResCorr_ak3PF_akPu3PF_noGplus_SecondHalfOnly_Converged_usedParameterizedUnfold0_jtpt35_bJets_clo0_chi100_v8_eta_-2.00To2.00_.root");
    TH1D *hfCheck3 = (TH1D*)ff2->Get("hGen_cent1");
    hfCheck2->Add(hfCheck3);
    //hfCheck2 = (TH1D*)hfCheck2->Rebin(16,hfCheck2->GetName(),xbinsXchk);
    
    //Fix raw B MC histogram to have 14 bins to be compatible with the unfolded nonsense
    /*const int fixNbin = h->GetNbinsX();
    Double_t binBoundaries[15];
    for(int ibin=0; ibin<fixNbin; ibin++){
      binBoundaries[ibin] = h->GetBinLowEdge(ibin+1);
    }
    binBoundaries[fixNbin] = h->GetBinLowEdge(fixNbin)+h->GetBinWidth(fixNbin);
    TH1D *h_den_fix = new TH1D("h_den_fix","",fixNbin,binBoundaries); h_den_fix->Sumw2();
    for(int ibin=0; ibin<fixNbin-h_den->GetNbinsX(); ibin++){
      h_den_fix->SetBinContent(ibin+1,0);
      h_den_fix->SetBinError(ibin+1,0);
    }
    for(int ibin=fixNbin-h_den->GetNbinsX(); ibin<fixNbin; ibin++){
      h_den_fix->SetBinContent(ibin+1,h_den->GetBinContent(ibin-(fixNbin-h_den->GetNbinsX())+1));
      h_den_fix->SetBinError(ibin+1,h_den->GetBinError(ibin-(fixNbin-h_den->GetNbinsX())+1));
      }*/
    //end fix

    //h->Draw();
    h->SetTitle("");
    //h_den->SetMarkerColor(2);
    //h_den->Draw("same");
    //h->Divide(h_den);
    h->SetYTitle("#frac{1}{T_{pA}} #frac{d#sigma}{dp_{T}} (1/GeV/c)");
    h->SetMaximum(1E-6);
    h->SetMinimum(1E-11);
    h->Draw();
    h_den->SetMarkerColor(4);
    h_den->Draw("same");
    hfCheck2->Scale(1./70.);
    hfCheck2->SetLineColor(kGreen+2);
    hf->Draw("same");
    he2->SetMarkerColor(kOrange+2);
    he2->Draw("same");
    //hfCheck2->Draw("same");
    //h_den = hfCheck2;
    //c1->SetLogy();

    for(int j=1; j<=h->GetNbinsX(); j++){
      cout << h->GetBinLowEdge(j) << " ";
    }
    cout << h->GetBinLowEdge(h->GetNbinsX())+h->GetBinWidth(h->GetNbinsX()) << endl;

    for(int j=1; j<=h_den->GetNbinsX(); j++){
      cout << h_den->GetBinLowEdge(j) << " ";
    }
    cout << h_den->GetBinLowEdge(h_den->GetNbinsX())+h_den->GetBinWidth(h_den->GetNbinsX()) << endl;

    TH1F *hpow, *hpow15;
    //if(drawPowheg){
      TFile *fpowheg50 = new TFile("Powheg/CMS-Dijet-Analysis-5tev-kt0-pt50Cut-mstwCL60PDF.root");
      hpow = (TH1F*)fpowheg50->Get("d05-x01-y01")->Clone("hpow"); //inclusive eta, ak3 jets
      TFile *fpowheg15 = new TFile("Powheg/CMS-Dijet-Analysis-5tev-kt0-pt20Cut-mstwCL60PDF.root");
      hpow15 = (TH1F*)fpowheg15->Get("d05-x01-y01")->Clone("hpow15");
      hpow15->Scale(25.4); //pthat20 relative (to pthat50) efficiency
      //hpow15->Scale(405.); //pthat 5 relative efficiency
      //hpow15->Scale(15.95);
      for(int i=1; i<=hpow->GetNbinsX(); i++){
	if(hpow->GetBinLowEdge(i)<100){
	  //cout << "edge: "<< hpow->GetBinLowEdge(i) << endl;
	  //cout << "hpow: "<< hpow->GetBinContent(i) << " hpow15: "<< hpow15->GetBinContent(i) << endl;
	  hpow->SetBinContent(i, hpow15->GetBinContent(i));
	  hpow->SetBinError(i, hpow15->GetBinError(i));
	}
      }
      hpow->SetMarkerStyle(20);
      hpow->SetMarkerColor(kOrange+2);
      hpow->SetLineColor(kOrange+2);
      hpow->Scale(2./10.); //fix eta selection
      hpow->Scale(1./70E-3); //correct for sigma_pp
      hpow->Scale(1.851e-3); //correct pthat50 efficiency (148086/80M)
      //hpow->Scale(4.7e-2);
      hpow->Scale(1e-9); //correct ncoll & translate to mb, not pb
      //hpow->Scale(1./50.);
      //hpow->Scale(0.85/(30.));
      if(drawPowheg) hpow->Draw("same");
      // }

    TLegend *t1 = new TLegend(0.5,0.697,0.879,0.906);
    t1->AddEntry(h,"pPb data b-jet spec.","p");
    t1->AddEntry(h2,"pPb MC b-jet spec.","p");
    t1->AddEntry(h_den,"pp MC b-jet spec.","p");
    if(drawPowheg) t1->AddEntry(hpow,"Powheg Spec.","p");
    t1->SetFillColor(0);
    t1->Draw("same");

    TCanvas *c2 = new TCanvas("c2","",600,600); //800,800
    //formatCanvas(c2);
    TH1D *hcln = (TH1D*)h->Clone("hcln");
    cout << "nbin: "<< hcln->GetNbinsX() << endl;
    //double xbinsrebin[17] = {0,5,10,15,20,25,30,35,40,55,70,90,110,140,170,220,400};
    //TH1D *hcln = new TH1D("hcln","",16,xbinsrebin);
    for(int ibin=1; ibin<=hcln->GetNbinsX(); ibin++){
      cout << "content bin " << ibin << " " << hcln->GetBinContent(ibin) << endl;
      cout << "powheg content bin " << ibin << " " << hpow->GetBinContent(ibin) << endl;
      //hcln->SetBinError(ibin,hcln_tmp->GetBinError(ibin));
      //hcln->SetBinContent(ibin,hcln_tmp->GetBinContent(ibin));
      }
    TH1D *hdencln = (TH1D*)h_den->Clone("hdencln");
    TH1D *hclnpow = (TH1D*)hcln->Clone("hclnpow");
    //cout << "WARNING! Scaling denominator for neutrinoless definition change!" << endl;
    //hdencln->Scale(1./1.243);
    if(!drawPowheg) hcln->Divide(hdencln);
    else{
      for(int ibin=1; ibin<=16; ibin++){
	int powbin=ibin;
	if(!useUnfolded) powbin+=8;
	if(!useUnfolded && ibin>8) continue;
	hcln->SetBinError(powbin,sqrt(pow(h_den->GetBinError(ibin)/h_den->GetBinContent(ibin),2)+pow(hpow->GetBinError(powbin)/hpow->GetBinContent(powbin),2)));
	hcln->SetBinContent(powbin,h_den->GetBinContent(ibin)/hpow->GetBinContent(powbin));
      }
    }
    //hcln->Divide(hcln);
    
    //Apply systematic errors to the inclusive eta plot
    TGraphErrors *systErr[7];
    TGraphErrors *unfoldErr[7];

    //set systematics
    const int nBins = 18;
    double xp[nBins], yp[nBins], xerr[nBins], yerr[nBins];
    //double yerrTot[nBins] = {0,0,0,0,0,0,0,0,0.13729, 0.1306, 0.1235, 0.146166, 0.16266, 0.1437,0.1816,0.23813}; //before recalibration
    double yerrTot[nBins] = {0,0,0,0,0,0,0,0,0,0.131694,0.0976, 0.0957, 0.1139, 0.1209, 0.1773, 0.2162,0,0}; //after recalibration
    double unfoldErrTot[nBins] = {0,0,0,0,0,0,0,0,0,0.05,0.05,0.05,0.05,0.05,0.05,0.06,0,0};
    double unfoldErrTotEta1[nBins] = {0,0,0,0,0,0,0,0,0,0.15,0.08,0.06,0.06,0.08,0.04,0.04,0,0};
    //double pythiaSysErr[nBins+1] = {0,0,0,0,0,0,0,0.136,0.138,0.140,0.142,0.148,0.152,0.157,0.164,0.174,0.182}; //option B
    // double optionBExtra[nBins+1] = {0,0,0,0,0,0,0,0,0,0.10,0.111,0.078,0.119,0.108,0.053,0.122,0.168};
    double pythiaSysErr[1] = {0.22}; //option A
    double pythiaYpoints[1] = {1};
    double pythiaXpoints[1] = {10};
    double pythiaXerr[1] = {10};
    for(int i=0; i<nBins; i++){ yerrTot[i] = sqrt(pow(yerrTot[i],2)+pow(unfoldErrTot[i],2)); }
    int j=0;
    if(!doInclusiveJet){
      for(int i=1; i<=hcln->GetNbinsX(); i++){
	xp[i-1] = hcln->GetBinLowEdge(i)+hcln->GetBinWidth(i)/2.;
	yp[i-1] = hcln->GetBinContent(i);
	xerr[i-1] = hcln->GetBinWidth(i)*0.495;
	yerr[i-1] = yerrTot[i-1];
	//pythiaXpoints[i-1] = xp[i-1];
	//pythiaXerr[i-1] = xerr[i-1];

	if(yerr[i-1]>0.001 && yp[i-1]>-1){ 
	  systErr[j] = new TGraphErrors(1,&xp[i-1],&yp[i-1],&xerr[i-1],&yerrTot[i-1]);
	  unfoldErr[j] = new TGraphErrors(1,&xp[i-1],&yp[i-1],&xerr[i-1],&unfoldErrTot[i-1]);
	  systErr[j]->SetName(Form("RpA_SystErr_bin%d",j));
	  j++;
	}
      }
      //pythiaXerr[16] = 0.;
      //pythiaXpoints[16] = 400.;
      /*for(int jj=0; jj<nBins+1; jj++){
	pythiaSysErr[jj]*=(1+optionBExtra[jj]);
	}*/
      TGraphErrors *pythiaErr = new TGraphErrors(1,pythiaXpoints,pythiaYpoints,pythiaXerr,pythiaSysErr);
    }
    //TGraphErrors *systErr = new TGraphErrors(nBins,xp,yp,xerr,yerr);
    double jesx[1]={2.365};
    double jesy[1]={1};
    double jesxerr[1]={.1};
    double jesyerr[1]={0.035};
    TGraphErrors *JESNorm = new TGraphErrors(1,jesx,jesy,jesxerr,jesyerr);
    JESNorm->SetFillColor(kGreen+3);

    hcln->SetMaximum(2.5);
    hcln->SetMinimum(0);
    if(doInclusiveJet) hcln->SetYTitle("Inclusive Jet R_{pA}");
    else hcln->SetYTitle("Nuclear Modification Factor");
    //else hcln->SetYTitle("b-jet R_{pA}^{PYTHIA}");
    hcln->SetXTitle("b-jet p_{T} [GeV/c]");
    hcln->GetXaxis()->SetRangeUser(0,400);
    hcln->GetXaxis()->CenterTitle(0);
    hcln->GetYaxis()->CenterTitle(0);
    hcln->SetMarkerStyle(20);
    hcln->SetMarkerColor(1);
    hcln->SetMarkerSize(1.2);
    for(int i=1; i<hcln->GetNbinsX(); i++){
      if(hcln->GetBinLowEdge(i) < 55){
	hcln->SetBinContent(i,-1);
	hcln->SetBinError(i,0.0001);
      }
    }
    hcln->Draw();
    hclnpow->SetMarkerColor(kOrange+2);
    hclnpow->SetLineColor(kOrange+2);
    if(drawPowheg) hclnpow->Draw("same");
    TLine *at2 = new TLine(0,1,400,1);
    at2->SetLineStyle(7);
    at2->SetLineWidth(1);
    pythiaErr->SetFillColor(kRed-7);
    //pythiaErr->SetFillStyle(1); //3844
    if(!doInclusiveJet){
      for(int i=0; i<7; i++){
	unfoldErr[i]->SetFillColor(kCyan-7);
	systErr[i]->SetFillColor(kYellow-7);
	systErr[i]->SetMarkerStyle(20);
	systErr[i]->Draw("2,same");
	//unfoldErr[i]->Draw("2,same");
      }
    }
    pythiaErr->Draw("2,same");
    double lumix[1] = {10}; double lumiy[1] = {1}; double lumierrx[1] = {10}; double lumierry[1] = {0.035};
    TGraphErrors *lumiErr = new TGraphErrors(1,lumix,lumiy,lumierrx,lumierry);
    lumiErr->SetFillColor(kGreen+3);
    lumiErr->Draw("2,same");
    at2->Draw("same");
    //JESNorm->Draw("2,same");
    hcln->Draw("same");
    
    //JESNorm->Draw("2,same");
  TLine *phigh1 = new TLine(380,1.22,400,1.22);
  phigh1->SetLineColor(2);
  phigh1->SetLineStyle(4);
  phigh1->SetLineWidth(1);
  //phigh1->Draw("same");
  TLine *phigh2 = new TLine(380,0.78,400,0.78);
  phigh2->SetLineColor(2);
  phigh2->SetLineStyle(4);
  phigh2->SetLineWidth(1);
  //phigh2->Draw("same");
  double zeroTemp[1] = {0};
  TGraphErrors *inclJetSys = new TGraphErrors(1,zeroTemp,zeroTemp,zeroTemp,zeroTemp);
  inclJetSys->SetMarkerColor(2);
  inclJetSys->SetMarkerStyle(21);
  inclJetSys->SetFillColor(8);
  //gROOT->ProcessLine(".x ~/Downloads/UnfoldedakPu3PFIncJetRpAvsPtInterpolatedRefEtaBin7.C");
  //gROOT->ProcessLine(".x ~/Downloads/RAA_drawFinal.C");
  if(drawTheory){
    gROOT->ProcessLine(".x ~/Downloads/drawpPbTheory.C");
  }
  TGraph *raaErr = new TGraph();
  raaErr->SetFillColor(kMagenta+1);
  raaErr->SetMarkerStyle(20);
  raaErr->SetMarkerSize(1.2);

  TLegend *leg1 = new TLegend(0.41,0.729,0.88,0.886);
  leg1->SetFillColor(0);
  //leg1->AddEntry(inclJetSys,"Inclusive-Jet R_{pA}, |#eta_{CM}|<0.5","fp");
  //leg1->AddEntry(raaErr,"b-jet R_{AA}, (0-100%), |#eta|<2","fp");
  leg1->AddEntry(systErr[0],"pPb Data, -2 < #eta_{CM} < 2","fp");
  leg1->AddEntry(grepPbtheory,"Ref. [32]","lp");
  //leg1->AddEntry(pythiaErr,"Reference Unc.","f");
  //leg1->AddEntry(lumiErr,"Luminosity Unc.","f");
  //leg1->AddEntry(systErr[0],"Total Systematic Error","f");
  //leg1->AddEntry(unfoldErr[0],"Unfolding Uncertainty","f");
  leg1->Draw("same");

  TLegend *leg3 = new TLegend(0.2,0.207,0.567,0.328);
  leg3->SetFillColor(0);
  leg3->AddEntry(lumiErr,"pPb Luminosity Unc.","f");
  leg3->AddEntry(pythiaErr,"pPb Reference Unc.","f");
  leg3->Draw("same");

  grepPbtheory->Draw("C,same");

  c2->SetTopMargin(0.0734);
  c2->RedrawAxis();

  TLatex *cmsP = new TLatex(16.7,2.25,"CMS ");
  cmsP->SetTextFont(62);
  cmsP->SetTextSize(0.0558);
  cmsP->Draw("same");
  TLatex *l1 = new TLatex(-0.5,0.18,Form("0-100%%",etalo,etahi));
  //l1->Draw("same");
  TLatex *l4 = new TLatex(236.8,2.56,"35 nb^{-1} (5.02 TeV)");//; PbPb L = 150 #mub^{-1}");
  l4->SetTextFont(43);
  l4->SetTextSize(25);
  l4->Draw("same");
  TLatex *l2 = new TLatex(20.77,0.175,"pPb #sqrt{s_{NN}} = 5.02 TeV #int L dt = 35 nb^{-1}"); //35, 20.7, 14
  l2->SetTextSize(0.035);
  //l2->Draw("same");
  TLatex *l3 = new TLatex(-2,0.22,"PbPb #sqrt{s_{NN}} = 2.76 TeV #int L dt = 150 #mub^{-1}");
  l3->SetTextSize(0.035);
  //l3->Draw("same");
  //TLatex *ltag = new TLatex(65,2.2,"CSV > 0.679");
  TLatex *ltag = new TLatex(65,2.2,"SSVHE > 2.0");
  //ltag->Draw("same");
  TFile *out = new TFile("RpA_BJet_Output.root","RECREATE");
  out->cd();
  hcln->SetName("RpA");//,"b jet RpA");
  hcln->Write();
  h->Write();
  h_den->Write();
  for(int i=0; i<7; i++){
    systErr[i]->Write();
  }
  out->Close();

  // hcln->Fit("pol0","","",45,250);
  //hcln->Fit("pol1","","",45,250);

  cout << "values: { ";
  for(int i=1; i<=hcln->GetNbinsX(); i++){
    cout << hcln->GetBinContent(i) << " ";
  }
  cout << " }" << endl;

  cout << "stat err: { ";
  for(int i=1; i<=hcln->GetNbinsX(); i++){
    cout << hcln->GetBinError(i) << " ";
  }
  cout << " }" << endl;

  cout << "syst err: { ";
  for(int i=1; i<=hcln->GetNbinsX(); i++){
    cout << yerrTot[i-1]+(yerrTot[i-1]*hcln->GetBinContent(i)) << " ";
  }
  cout << " }" << endl;
}
void TagProbeMuonPlotsTrackIso(){
  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetStatFormat("5.3f");
  gStyle->SetFitFormat("5.3f");
  int BoxValue = 11111111; //4680;  
  gStyle->SetOptFit(11);
  gStyle->SetOptDate(0);
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(BoxValue);
  gStyle->SetPadBorderMode(0);
  gStyle->SetCanvasColor(0); //(10);
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetPalette(0);
  TPaveLabel pl;
  TLatex lt;
  lt.SetTextFont(70);
  lt.SetTextAlign(12);
  lt.SetTextSize(0.07);
  lt.SetTextColor(1);
  //------------------------------------------------------------------
  //--------- MC ----------

   float Eff1    = 0.971831;
  float Eff2    = 0.989418;
  float Eff3    = 1;
  float Eff4    = 0.99262;
  float Eff5    = 0.983302;
  float Eff6    = 0.974359;
  float Eff7    = 0.976562;
  float Eff8    = 0.94186;
  float Eff9    = 0.990926;
  float Eff10   = 0.980469;
  float Eff11   = 0.993789;
  float Eff12   = 0.991957;
  float Eff13   = 0.986046;
  //[0.0,0.9]   = 0.981685
  //[0.9,1.2]   = 0.986717
  //[1.2,2.1]   = 0.993622
  //[2.1,2.4]   = 0.978972
  float error1     = 0.0115;
  float error2     = 0.00529101;
  float error3     = 0;
  float error4     = 0.0052185;
  float error5     = 0.00556586;
  float error6     = 0.0181309;
  float error7     = 0.0078125;
  float error8     = 0.0260008;
  float error9     = 0.0040582;
  float error10    = 0.00873464;
  float error11    = 0.00439197;
  float error12    = 0.00464357;
  float error13    = 0.00805605;
  //error[0.0,0.9]    = 0.00334385;
  //error[0.9,1.2]    = 0.0050204;
  //error[1.2,2.1]    = 0.00212615;
  //error[2.1,2.4]    = 0.00700935;
      
  //==============================================
  //  Data
  //==============================================
  float EffD1    = 0.966102;
  float EffD2    = 0.969136;
  float EffD3    = 0.972376;
  float EffD4    = 0.980392;
  float EffD5    = 0.983516;
  float EffD6    = 0.978261;
  float EffD7    = 0.979339;
  float EffD8    = 1;
  float EffD9    = 0.980769;
  float EffD10   = 0.974843;
  float EffD11   = 1;
  float EffD12   = 0.969925;
  float EffD13   = 1;
  
  float errorD1     = 0.0239697;
  float errorD2     = 0.0138029;
  float errorD3     = 0.012354;
  float errorD4     = 0.0113206;
  float errorD5     = 0.00672937;
  float errorD6     = 0.0217391;
  float errorD7     = 0.00923995;
  float errorD8     = 0;
  float errorD9     = 0.00726855;
  float errorD10    = 0.0125786;
  float errorD11    = 0;
  float errorD12    = 0.0150376;
  float errorD13    = 0;
  /*
  [0.0,0.9]   = 98.2 (+/-) 0.4
  [0.9,1.2]   = 97.7 (+/-) 0.8
  [1.2,2.1]   = 97.8 (+/-) 0.6
  [2.1,2.4]   = 98.1 (+/-) 1.4
  error[0.0,0.9]    = 0.00412775
  error[0.9,1.2]    = 0.00847997
  error[1.2,2.1]    = 0.00587387
  error[2.1,2.4]    = 0.0135982
  */

  //================================================================== 
  //==================================================================  
  //================================================================== 
  //==================================================================  
  //================================================================== 
  //==================================================================  
  //================================================================== 
  TCanvas *c1 = new TCanvas("c1","Eff. pt",500,500);
  char textpro1[100],textNDF1[100],textRatio1[100];           
  c1->cd(1);
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  gPad->SetGridx();
  TH1F* MassProbeTTandProbeTF1    = new TH1F("MassProbeTTandProbeTF1","",10,0.0,100.0);
  TH1F* MassProbeTTandProbeTF2    = new TH1F("MassProbeTTandProbeTF2","",10,0.0,100.0);
  TH1F* MassProbeTTandProbe720TF1 = new TH1F("MassProbeTTandProbe720TF1","",10,0.0,100.0);
  TH1F* MassProbeTTandProbe720TF2 = new TH1F("MassProbeTTandProbe720TF2","",10,0.0,100.0);
  TGraphAsymmErrors *MassEffForTagProbe539  = new TGraphAsymmErrors;
  TGraphAsymmErrors *MassEffForTagProbe720  = new TGraphAsymmErrors;
  TMultiGraph *mg1 = new TMultiGraph;
  //========================================================== 
  //                      Data                         
  //==========================================================
  TFile *f1 = new TFile("Analyse_TagAndProbe_CMSSW_8_0_13_ZPRIMEMuMu_13TeV-DataG-V1-JSON-tree.root","READ");
  //---------------------------------------------------
  MassProbeTTandProbeTF1->Add(PtProbeTT);
  MassProbeTTandProbeTF2->Add(PtProbeTP);
  cout<<"====================== T&P1 =============================="<<endl;
  int nbEleTopMass1                             = MassProbeTTandProbeTF1->Integral();
  int nbEleBottomMass1                          = MassProbeTTandProbeTF2->Integral();
  float EffChargedHadMass1                      = (float)nbEleTopMass1/nbEleBottomMass1;
  cout<<"nbEleTopMass1                          = "<<nbEleTopMass1<<endl;
  cout<<"nbEleBottomMass1                       = "<<nbEleBottomMass1<<endl;
  cout<<"EffChargedHadMass1(electron)           = "<<EffChargedHadMass1<<endl;
  float StatErrorMass1                          = sqrt(nbEleBottomMass1 - nbEleTopMass1)/nbEleBottomMass1;
  cout<<"StatErrorMass1(electron)               = "<<StatErrorMass1<<endl;
  //---------------------------------------------------
  MassEffForTagProbe539->BayesDivide(MassProbeTTandProbeTF1,MassProbeTTandProbeTF2);
  MassEffForTagProbe539->SetLineStyle(0);
  MassEffForTagProbe539->SetLineColor(1);
  MassEffForTagProbe539->SetLineWidth(2);
  MassEffForTagProbe539->SetMarkerColor(1); 
  MassEffForTagProbe539->SetMarkerStyle(20);
  MassEffForTagProbe539->SetMarkerSize(0.875);
  //-----------------------------------------------------------------
  //========================================================== 
  //                      MC DY                                                  
  //==========================================================
  TFile *f100 = new TFile("Analyse_TagAndProbe_CMSSW8012_MC_reHLT_DYtoMuMu120to200_13TeV_tree.root","READ");
  //---------------------------------------------------
  MassProbeTTandProbe720TF1->Add(PtProbeTT);
  MassProbeTTandProbe720TF2->Add(PtProbeTP);
  cout<<"====================== T&P1 =============================="<<endl;
  int nbEleTopMass2                             = MassProbeTTandProbe720TF1->Integral();
  int nbEleBottomMass2                          = MassProbeTTandProbe720TF2->Integral();
  float EffChargedHadMass2                      = (float)nbEleTopMass2/nbEleBottomMass2;
  cout<<"nbEleTopMass2                          = "<<nbEleTopMass2<<endl;
  cout<<"nbEleBottomMass2                       = "<<nbEleBottomMass2<<endl;
  cout<<"EffChargedHadMass2(electron)           = "<<EffChargedHadMass2<<endl;
  float StatErrorMass2                          = sqrt(nbEleBottomMass2 - nbEleTopMass2)/nbEleBottomMass2;
  cout<<"StatErrorMass2(electron)               = "<<StatErrorMass2<<endl;
  //---------------------------------------------------
  MassEffForTagProbe720->BayesDivide(MassProbeTTandProbe720TF1,MassProbeTTandProbe720TF2);
  MassEffForTagProbe720->SetLineStyle(0);
  MassEffForTagProbe720->SetLineColor(2);
  MassEffForTagProbe720->SetLineWidth(2);
  MassEffForTagProbe720->SetMarkerColor(2); 
  MassEffForTagProbe720->SetMarkerStyle(24);
  MassEffForTagProbe720->SetMarkerSize(0.875);
  //-----------------------------------------------------------------
  mg1->Add(MassEffForTagProbe539);
  mg1->Add(MassEffForTagProbe720);
  mg1->Draw("AP");
  mg1->SetTitle("title;muon pt [GeV/c]; Eff.(Rel. Tracker iso)");
  mg1->GetXaxis()->SetTitleOffset(1.7);
  mg1->GetYaxis()->SetTitleOffset(1.7);
  mg1->GetXaxis()->SetLabelSize(0.03);
  mg1->GetYaxis()->SetLabelSize(0.03);
  mg1->GetYaxis()->SetRangeUser(0.7,1.05);
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("50.421 pb^{-1} (13 TeV)");
  tText1->SetTextSize(0.035);
  tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS Spring16 Simulation");
  tText2->SetTextSize(0.035);
  tText2->Draw(); 
  //==========================================================
  TPaveText* tText1 = new TPaveText(0.50, 0.25, 0.80, 0.45, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetTextColor(1);
  tText1->SetFillStyle(0);
  Float_t tsize = 0.035;
  tText1->SetTextSize(tsize); 
  TText *t1 = tText1->AddText("Pt > 45 GeV/c"); 
  TText *t2 = tText1->AddText("|#eta|<2.4"); 
  tText1->Draw();
  //========================================================== 
  TLegend *leg = new TLegend(0.20, 0.20, 0.40, 0.35);
  leg->AddEntry(MassEffForTagProbe539,"MC","p");
  leg->AddEntry(MassEffForTagProbe720,"Data","p");
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.035;
  leg->SetTextSize(tsize2); 
  leg->Draw();
  //======================================================================= 
  c1->Print("Eff_TagProbe_ID_13TeV_PtProbe_cmssw720-trackiso.png","png");
  c1->Print("Eff_TagProbe_ID_13TeV_PtProbe_cmssw720-trackiso.pdf","pdf");
  //c1->Print("PlotsDir4/Eff_DeltaPhi_HEEP_ID_MC_CMSSW701_Eta_EBEE.eps","eps");
  //=======================================================================
  
  //==================================================================  
  //================================================================== 
  //==================================================================  
  //================================================================== 
  TCanvas *c4 = new TCanvas("c4","Eff. PVs",500,500);
  char textpro1[100],textNDF1[100],textRatio1[100];           
  c4->cd(1);
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  gPad->SetGridx();
  TH1F* NbPVProbeTTandProbeTF1            = new TH1F("NbPVProbeTTandProbeTF1","",15,0.0,50.0);
  TH1F* NbPVProbeTTandProbeTF2            = new TH1F("NbPVProbeTTandProbeTF2","",15,0.0,50.0);
  TGraphAsymmErrors *TagProbePhi539       = new TGraphAsymmErrors;
  TH1F* NbPVProbeTTandProbe720TF1         = new TH1F("NbPVProbeTTandProbe720TF1","",15,0.0,50.0);
  TH1F* NbPVProbeTTandProbe720TF2         = new TH1F("NbPVProbeTTandProbe720TF2","",15,0.0,50.0);
  TGraphAsymmErrors *TagProbePhi720       = new TGraphAsymmErrors;
  TMultiGraph *mg4 = new TMultiGraph;
  //========================================================== 
  //                     Data                                                  
  //==========================================================
  TFile *f5 = new TFile("Analyse_TagAndProbe_CMSSW_8_0_13_ZPRIMEMuMu_13TeV-DataG-V1-JSON-tree.root","READ");
  //---------------------------------------------------
  NbPVProbeTTandProbeTF1->Add(PVProbeTT);
  NbPVProbeTTandProbeTF2->Add(PVProbeTP);
  cout<<"====================== dBeta =============================="<<endl;
  int nbEleTopPV1                             = NbPVProbeTTandProbeTF1->Integral();
  int nbEleBottomPV1                          = NbPVProbeTTandProbeTF2->Integral();
  float EffChargedHadPV1                      = (float)nbEleTopPV1/nbEleBottomPV1;
  cout<<"nbEleTopPV1                          = "<<nbEleTopPV1<<endl;
  cout<<"nbEleBottomPV1                       = "<<nbEleBottomPV1<<endl;
  cout<<"EffChargedHadPV1(electron)           = "<<EffChargedHadPV1<<endl;
  float StatErrorPV1                          = sqrt(nbEleBottomPV1 - nbEleTopPV1)/nbEleBottomPV1;
  cout<<"StatErrorPV1(electron)               = "<<StatErrorPV1<<endl;
  //---------------------------------------------------
  TagProbePhi539->BayesDivide(NbPVProbeTTandProbeTF1,NbPVProbeTTandProbeTF2);
  TagProbePhi539->SetLineStyle(0);
  TagProbePhi539->SetLineColor(1);
  TagProbePhi539->SetLineWidth(2);
  TagProbePhi539->SetMarkerColor(1); 
  TagProbePhi539->SetMarkerStyle(20);
  TagProbePhi539->SetMarkerSize(0.875);
  //========================================================== 
  //                     MC DY                                                  
  //==========================================================
  TFile *f50 = new TFile("Analyse_TagAndProbe_CMSSW8012_MC_reHLT_DYtoMuMu120to200_13TeV_tree.root","READ");
  //---------------------------------------------------
  NbPVProbeTTandProbe720TF1->Add(PVProbeTT);
  NbPVProbeTTandProbe720TF2->Add(PVProbeTP);
  cout<<"====================== dBeta =============================="<<endl;
  int nbEleTopPV2                             = NbPVProbeTTandProbe720TF1->Integral();
  int nbEleBottomPV2                          = NbPVProbeTTandProbe720TF2->Integral();
  float EffChargedHadPV2                      = (float)nbEleTopPV2/nbEleBottomPV2;
  cout<<"nbEleTopPV2                          = "<<nbEleTopPV2<<endl;
  cout<<"nbEleBottomPV2                       = "<<nbEleBottomPV2<<endl;
  cout<<"EffChargedHadPV2(electron)           = "<<EffChargedHadPV2<<endl;
  float StatErrorPV2                          = sqrt(nbEleBottomPV2 - nbEleTopPV2)/nbEleBottomPV2;
  cout<<"StatErrorPV2(electron)               = "<<StatErrorPV2<<endl;
  //---------------------------------------------------
  TagProbePhi720->BayesDivide(NbPVProbeTTandProbe720TF1,NbPVProbeTTandProbe720TF2);
  TagProbePhi720->SetLineStyle(0);
  TagProbePhi720->SetLineColor(2);
  TagProbePhi720->SetLineWidth(2);
  TagProbePhi720->SetMarkerColor(2); 
  TagProbePhi720->SetMarkerStyle(24);
  TagProbePhi720->SetMarkerSize(0.875);
  //============================================================================
  mg4->Add(TagProbePhi539);
  mg4->Add(TagProbePhi720);
  mg4->Draw("AP");
  mg4->SetTitle("title;Number of vertices; Eff.(Rel. Tracker iso)");
  mg4->GetXaxis()->SetTitleOffset(1.7);
  mg4->GetYaxis()->SetTitleOffset(1.7);
  mg4->GetXaxis()->SetLabelSize(0.03);
  mg4->GetYaxis()->SetLabelSize(0.03);
  mg4->GetXaxis()->SetRangeUser(0.0,37.0);
  mg4->GetYaxis()->SetRangeUser(0.7,1.05);
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("50.421 pb^{-1} (13 TeV)");
  tText1->SetTextSize(0.035);
  tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS Spring16 Simulation");
  tText2->SetTextSize(0.035);
  tText2->Draw(); 
  //========================================================== 
  TPaveText* tText1 = new TPaveText(0.50, 0.25, 0.80, 0.45, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetTextColor(1);
  tText1->SetFillStyle(0);
  Float_t tsize = 0.035;
  tText1->SetTextSize(tsize); 
  TText *t1 = tText1->AddText("Pt > 45 GeV/c"); 
  TText *t2 = tText1->AddText("|#eta|<2.4"); 
  tText1->Draw();
  //========================================================== 
  TLegend *leg = new TLegend(0.20, 0.20, 0.40, 0.35);
  leg->AddEntry(TagProbePhi539,"MC","p");
  leg->AddEntry(TagProbePhi720,"Data","p");
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.035;
  leg->SetTextSize(tsize2); 
  leg->Draw();
  //======================================================================= 
  c4->Print("Eff_TagProbe_ID_13TeV_vtxProbe_cmssw720-trackiso.png","png");
  c4->Print("Eff_TagProbe_ID_13TeV_vtxProbe_cmssw720-trackiso.pdf","pdf");
  //c4->Print("PlotsDir4/Eff_DeltaPhi_HEEP_ID_MC_CMSSW701_Phi_EBEE.eps","eps");
  //=======================================================================

  //================================================================== 
  //==================================================================  
  //================================================================== 
  //==================================================================
  //TCanvas *c5 = new TCanvas("c5","A Simple Graph with error bars",200,10,700,500);
  TCanvas *c5 = new TCanvas("c5","Eff. Eta",500,500);
  c5->SetFillColor(0);
  c5->SetGrid();
  c5->GetFrame()->SetFillColor(21);
  c5->GetFrame()->SetBorderSize(12);
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  gPad->SetGridx();
  const Int_t n = 13;
  Float_t x[n]  = {-2.25,-1.85,-1.4,-1.05,-0.6,-0.25,0.0,0.25,0.6,1.05,1.4,1.85,2.25};
  Float_t y[n]  = {Eff1,
		   Eff2,
		   Eff3,
		   Eff4,
		   Eff5,
		   Eff6,
		   Eff7,
		   Eff8,
		   Eff9,
		   Eff10,
		   Eff11,
		   Eff12,
		   Eff13};
  Float_t ex[n] = {0.15,0.25,0.2,0.15,0.3,0.05,0.2,0.05,0.3,0.15,0.2,0.25,0.15};
  Float_t ey[n] = {error1,error2,error3,error4,error5,error6,error7,error8,error9,error10,error11,error12,error13};
  TGraphErrors *gr = new TGraphErrors(n,x,y,ex,ey);
  gr->SetMarkerColor(1);
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(0.9);
  gr->Draw("AP");
  gr->GetYaxis()->SetNdivisions(10,kTRUE);
  gr->GetYaxis()->SetDecimals();
  //gr->GetYaxis()->SetRangeUser(0.0,0.4);
  //gr->GetXaxis()->SetNdivisions(510,kFALSE);
  gr->GetXaxis()->SetRangeUser(-2.4,2.4);
  gr->GetYaxis()->SetRangeUser(0.70,1.05);
  gr->SetTitle("title;muon #eta; Eff.(Rel. Tracker iso)");
  gr->GetXaxis()->SetTitleOffset(1.7);
  gr->GetYaxis()->SetTitleOffset(1.7);
  gr->GetXaxis()->SetLabelSize(0.03);
  gr->GetYaxis()->SetLabelSize(0.03);
  Float_t x2[n]  = {-2.25,-1.85,-1.4,-1.05,-0.6,-0.25,0.0,0.25,0.6,1.05,1.4,1.85,2.25};
  Float_t y2[n]  = {EffD1,
		   EffD2,
		   EffD3,
		   EffD4,
		   EffD5,
		   EffD6,
		   EffD7,
		   EffD8,
		   EffD9,
		   EffD10,
		   EffD11,
		   EffD12,
		   EffD13};
  Float_t ex2[n] = {0.15,0.25,0.2,0.15,0.3,0.05,0.2,0.05,0.3,0.15,0.2,0.25,0.15};
  Float_t ey2[n] = {errorD1,errorD2,errorD3,errorD4,errorD5,errorD6,errorD7,errorD8,errorD9,errorD10,errorD11,errorD12,errorD13};
  TGraphErrors *gr2 = new TGraphErrors(n,x2,y2,ex2,ey2);
  gr2->SetMarkerColor(2);
  gr2->SetLineColor(2);
  gr2->SetMarkerStyle(24);
  gr2->SetMarkerSize(0.9);
  gr2->Draw("p,sames");
  //-----------------------------------------------------------------
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  double LikelihoodCut1    = 1.2 ;
  TLine *line1 = new TLine( LikelihoodCut1 , 0.7,  LikelihoodCut1 , 1.05);
  line1->SetLineColor(2);
  line1->SetLineWidth(3);
  line1->SetLineStyle(2);
  line1->Draw();
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  double LikelihoodCut2    = -1.2 ;
  TLine *line2 = new TLine( LikelihoodCut2 , 0.7,  LikelihoodCut2 , 1.05);
  line2->SetLineColor(2);
  line2->SetLineWidth(3);
  line2->SetLineStyle(2);
  line2->Draw();
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
   TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("22.2 fb^{-1} (13 TeV)");
  tText1->SetTextSize(0.035);
  tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS Spring16 Simulation");
  tText2->SetTextSize(0.035);
  tText2->Draw(); 
  //========================================================== 
  TPaveText* tText1 = new TPaveText(0.50, 0.25, 0.80, 0.45, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetTextColor(1);
  tText1->SetFillStyle(0);
  Float_t tsize = 0.035;
  tText1->SetTextSize(tsize); 
  TText *t1 = tText1->AddText("Pt > 45 GeV/c"); 
  TText *t2 = tText1->AddText("|#eta|<2.4"); 
  tText1->Draw();
  //==========================================================
  TLegend *leg = new TLegend(0.20, 0.20, 0.40, 0.35);
  leg->AddEntry(gr,"MC","p");
  leg->AddEntry(gr2,"Data","p");
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.03;
  leg->SetTextSize(tsize2); 
  leg->Draw();  
  //======================================================================= 
  c5->Print("Eff_TagProbe_ID_13TeV_EtaProbe_cmssw720-trackiso.png","png");
  c5->Print("Eff_TagProbe_ID_13TeV_EtaProbe_cmssw720-trackiso.pdf","pdf");
  c5->Update();
  //================================================================== 
  

}
예제 #29
0
파일: DY.C 프로젝트: NTrevisani/newWW13TeV
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// DY
//
// channel = SF, MuMu, EE
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void doDY(char jetbin,
	  TString channel,
	  TString ID = "MediumIDTighterIP",
	  TString bunch = "50ns",
	  Bool_t  useDataDriven = true,
	  Int_t   printLevel = 100,
	  Bool_t  drawR = true)
{
  cout<<"nJet = "<<jetbin<<endl;
  cout<<"Channel = "<<channel<<endl;

  Double_t yield;                                                                                                                      
  Double_t statError;
  Double_t systError;                                                                                                                    
  Double_t scaleFactor;
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // Input files
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TString path   = "../rootFiles/" + channel + "/" + ID + "/" + bunch + "/"; 
  TString pathOF = "../rootFiles/OF/" + ID + "/" + bunch + "/"; 

  TFile* inputDYSF   = new TFile(path + "DY.root");
  TFile* inputVVSF   = new TFile(path + "VV.root");
  TFile* inputDataSF = new TFile(path + "Data2015.root");
  TFile* inputDataOF = new TFile(pathOF + "Data2015.root");

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // Input histograms
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TH1F* hNinDYSF  [numberMetCuts];
  TH1F* hNinVVSF  [numberMetCuts];
  TH1F* hNinDataSF[numberMetCuts];
  TH1F* hNinDataOF[numberMetCuts];

  TH1F* hNoutDYSF  [numberMetCuts];
  TH1F* hNoutVVSF  [numberMetCuts];
  TH1F* hNoutDataSF[numberMetCuts];
  TH1F* hNoutDataOF[numberMetCuts];

  for (UInt_t nC=0; nC<numberMetCuts; nC++) {
    hNinDYSF  [nC] = (TH1F*)inputDYSF  ->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));
    cout<<Form("hNinZevents%.i%.c", MetCuts[nC],jetbin)<<endl;
    hNinVVSF  [nC] = (TH1F*)inputVVSF  ->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));
    hNinDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));
    hNinDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));

    hNoutDYSF  [nC] = (TH1F*)inputDYSF  ->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));     
    hNoutVVSF  [nC] = (TH1F*)inputVVSF  ->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));     
    hNoutDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));
    hNoutDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));
  }


  // Histogram at analysis level
  //----------------------------------------
  TH1F* hExpectedDYSF = (TH1F*)inputDYSF->Get(Form("hPtLepton1WWLevel%.c", jetbin));//("hWTopTagging");

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // k estimation
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TFile* inputDYmumu = new TFile("../rootFiles/MuMu/" + ID + "/" + bunch + "/DY.root");
  TFile* inputDYee   = new TFile("../rootFiles/EE/"   + ID + "/" + bunch + "/DY.root");

  TH1F* hNinDYmumu = (TH1F*)inputDYmumu->Get(Form("hNinLooseZevents20%.c", jetbin));
  TH1F* hNinDYee   = (TH1F*)inputDYee  ->Get(Form("hNinLooseZevents20%.c", jetbin));

  Double_t NinDYmumu = hNinDYmumu -> GetBinContent(2);
  Double_t NinDYee   = hNinDYee   -> GetBinContent(2);

  Double_t k    = 0.5 * (sqrt(NinDYmumu / NinDYee) + sqrt(NinDYee / NinDYmumu));
  Double_t errk = errkSF(NinDYmumu, NinDYee);

  if (channel == "MuMu") {
    k    = 0.5 * sqrt(NinDYmumu / NinDYee);
    errk = errkFunction(NinDYmumu, NinDYee);
  }
  else if (channel == "EE") {
    k    = 0.5 * sqrt(NinDYee / NinDYmumu);
    errk = errkFunction(NinDYee, NinDYmumu);
  }


  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // Counters
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Double_t NinDYSF  [numberMetCuts];
  Double_t NinVVSF  [numberMetCuts];
  Double_t NinDataSF[numberMetCuts];
  Double_t NinDataOF[numberMetCuts];

  Double_t NoutDYSF  [numberMetCuts];
  Double_t NoutVVSF  [numberMetCuts];  // Not used for now
  Double_t NoutDataSF[numberMetCuts];
  Double_t NoutDataOF[numberMetCuts];

  for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {
    NinDYSF   [nC] = hNinDYSF   [nC]->GetBinContent(2);
    NinVVSF   [nC] = hNinVVSF   [nC]->GetBinContent(2);
    NinDataSF [nC] = hNinDataSF [nC]->GetBinContent(2);    
    NinDataOF [nC] = hNinDataOF [nC]->GetBinContent(2);

    NoutDYSF  [nC] = hNoutDYSF  [nC]->GetBinContent(2);
    NoutVVSF  [nC] = hNoutVVSF  [nC]->GetBinContent(2);
    NoutDataSF[nC] = hNoutDataSF[nC]->GetBinContent(2);    
    NoutDataOF[nC] = hNoutDataOF[nC]->GetBinContent(2);
  }

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // R estimation
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Double_t R       [numberMetCuts];
  Double_t RData   [numberMetCuts];
  Double_t errR    [numberMetCuts];
  Double_t errRData[numberMetCuts];


  // Loop over the met cuts
  //----------------------------------------------------------------------------
  for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {

    R   [nC] = NoutDYSF[nC] / NinDYSF[nC]; 
    errR[nC] = errRFunction(NoutDYSF[nC], NinDYSF[nC]);

    RData   [nC] = RDataFunction   (NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k);
    errRData[nC] = errRDataFunction(NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k, errk);

    if (printLevel > 2) {
      printf("\n %.0f < mpmet < %.0f GeV\n", MetCuts[nC], MetCuts[nC+1]);
      printf(" -------------------------------------------------\n");
      printf("         N^{MC}_{out,SF}   = %6.1f\n", NoutDYSF[nC]);
      printf("         N^{MC}_{in, SF}   = %6.1f\n", NinDYSF[nC]);
      printf("         N^{data}_{out,SF} = %4.0f\n", NoutDataSF[nC]);
      printf("         N^{data}_{out,OF} = %4.0f\n", NoutDataOF[nC]);
      printf("         N^{data}_{in, SF} = %4.0f\n", NinDataSF[nC]);
      printf("         N^{data}_{in, OF} = %4.0f\n", NinDataOF[nC]);
      printf("         k                 = % 5.3f +- %5.3f\n", k,         errk);
      printf("         R^{MC}            = % 5.3f +- %5.3f\n", R[nC],     errR[nC]);
      printf("         R^{data}          = % 5.3f +- %5.3f\n", RData[nC], errRData[nC]);
    }
  }

  // Estimate the R systematic as the difference between R[2] and R[3]
  //----------------------------------------------------------------------------
  Int_t iMaxR = 0; 
  Int_t iMinR = 0; 

  for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {

    if (R[nC] > 0 && R[nC] > R[iMaxR]) iMaxR = nC;
    if (R[nC] > 0 && R[nC] < R[iMinR]) iMinR = nC;
  }

  Int_t theR = 2;
  Int_t sysR = 3;

  Double_t RelDiffR = (R[theR] > 0) ? fabs(R[theR] - R[sysR]) / R[theR] : -999;


  if (printLevel > 0) {
    printf("\n [%s] R systematic uncertainty\n", channel.Data());
    printf(" -------------------------------------------------\n");
    printf("         min R               = %5.3f\n",     R[iMinR]);
    printf("         max R               = %5.3f\n",     R[iMaxR]);
    printf("         R[%d]               = %5.3f\n",    theR, R[theR]);
    printf("         R[%d]               = %5.3f\n",    sysR, R[sysR]);
    printf("         |R[%d]-R[%d]| / R[%d] = %.1f%s\n", theR, sysR, theR, 1e2*RelDiffR, "%");
    printf("\n");
  }


  // Estimate Nout
  //----------------------------------------------------------------------------
  Double_t NinCountedSFVV   = NinVVSF  [sysR];
  Double_t NinCountedSFData = NinDataSF[sysR];
  Double_t NinCountedOFData = NinDataOF[sysR];

  Double_t NinEstSFFinal    = NinCountedSFData - k*NinCountedOFData;
  Double_t errNinEstSFFinal = errNinEstFunction(NinCountedSFData, NinCountedOFData, k, errk);

  Double_t NestSFFinal    = R[theR] * NinEstSFFinal;
  Double_t errNestSFFinal = errNestFunction(NestSFFinal, R[theR], errR[theR], NinEstSFFinal, errNinEstSFFinal);

  Double_t NinEstSFNoDibosonFinal    = NinEstSFFinal - NinCountedSFVV;
  Double_t errNinEstSFNoDibosonFinal = errNinEstNoDibosonFunction(NinCountedSFData, k, errk, NinCountedOFData, NinCountedSFVV);

  Double_t NestSFNoDibosonFinal    = R[theR] * NinEstSFNoDibosonFinal;
  Double_t errNestSFNoDibosonFinal = errNestFunction(NestSFNoDibosonFinal, R[theR], errR[theR], NinEstSFNoDibosonFinal, errNinEstSFNoDibosonFinal);
  Double_t totalError              = sqrt(errNestSFNoDibosonFinal*errNestSFNoDibosonFinal + (RelDiffR*NestSFNoDibosonFinal)*(RelDiffR*NestSFNoDibosonFinal));


  Double_t SFsf = NestSFNoDibosonFinal / hExpectedDYSF->Integral();


  if (printLevel > 1) {
    printf("\n Analysis results\n");
    printf(" -------------------------------------------------\n");
    printf("         N^{data}_{in,SF} = %4.0f\n", NinCountedSFData);
    printf("         N^{data}_{in,OF} = %4.0f\n", NinCountedOFData);
    printf("         k                = %5.3f +- %5.3f\n", k, errk);
    printf("         R[%d]             = %5.3f +- %5.3f\n", theR, R[theR], errR[theR]);
    printf("         N^{VV}_{in,SF}   = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
	   NinCountedSFVV, sqrt(NinCountedSFVV), 0.1*NinCountedSFVV);
    printf("         N^{est}_{in, SF} = %7.2f +- %6.2f\n", NinEstSFFinal, errNinEstSFFinal);
    printf("         N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
	   NestSFFinal, errNestSFFinal, RelDiffR*NestSFFinal);
    printf(" -------------------------------------------------\n");
    printf(" [no VZ] N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.) = %7.2f +- %6.2f (stat. + syst.)\n",
	   NestSFNoDibosonFinal, errNestSFNoDibosonFinal, RelDiffR*NestSFNoDibosonFinal,
	   NestSFNoDibosonFinal, totalError);
    printf("         N^{MC}_{out,SF}  = %7.2f +- %6.2f\n",
	   hExpectedDYSF->Integral(), sqrt(hExpectedDYSF->Integral()));
    printf("     *** scale factor     = %.3f\n\n", SFsf);
  }


  // Save the result
  //----------------------------------------------------------------------------
  yield       = (useDataDriven) ? NestSFNoDibosonFinal : hExpectedDYSF->Integral();
  statError   = errNestSFNoDibosonFinal;
  systError   = RelDiffR*NestSFNoDibosonFinal;
  scaleFactor = yield / hExpectedDYSF->Integral();


  // For the note
  //----------------------------------------------------------------------------
  if (printLevel > 0) {
    printf("\n [%s] DY values for the note\n", channel.Data());
    printf(" -------------------------------------------------\n");
    printf(" final state   &             R_{MC}  &  N^{control,data}  &     N_{DY}^{data}  &       N_{DY}^{MC}  &  data/MC\n");
    printf(" same flavour  &  %5.3f $\\pm$ %5.3f  &              %4.0f  &  %5.1f $\\pm$ %4.1f  &  %5.1f $\\pm$ %4.1f  &     %4.1f\n\n",
	   R[theR],
	   errR[theR],
	   NinCountedSFData,
	   yield,
	   statError,
	   hExpectedDYSF->Integral(),
	   sqrt(hExpectedDYSF->Integral()),
	   scaleFactor);
    printf("\n [%s] DY relative systematic uncertainties\n", channel.Data());
    printf(" -------------------------------------------------\n");
    printf(" DY normalisation = %.0f (stat.) $\\bigoplus$ %.0f (syst.)\n\n",
	   1e2*statError/yield, 1e2*systError/yield);
  }


  // Check
  //----------------------------------------------------------------------------
  Double_t check = hExpectedDYSF->Integral() - NoutDYSF[sysR];
  if (check != 0) printf(" WARNING: DY yields do not much by %f\n\n", check);


  // Draw histograms
  //----------------------------------------------------------------------------
  if (drawR) {

    Double_t absoluteMin = 999;

    TGraphErrors* gR     = new TGraphErrors(numberMetCuts-1);
    TGraphErrors* gRdata = new TGraphErrors(numberMetCuts-1);

    for (UInt_t i=0; i<numberMetCuts-1; i++) {

      gR->SetPoint     (i, 0.5 * (MetDraw[i+1] + MetDraw[i]),    R[i]);
      gR->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errR[i]);

      gRdata->SetPoint     (i, 0.5 * (MetDraw[i+1] + MetDraw[i]),    RData[i]);
      gRdata->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errRData[i]);

      if (absoluteMin > (R[i]     - errR[i]))     absoluteMin = R[i]     - errR[i];
      if (absoluteMin > (RData[i] - errRData[i])) absoluteMin = RData[i] - errRData[i];
    }
    
    if (absoluteMin > 0) absoluteMin = 0;

    // Cosmetics
    //--------------------------------------------------------------------------
    gR->SetMarkerSize (0.9);
    gR->SetMarkerStyle(kFullCircle);

    gRdata->SetLineColor  (kRed+1);
    gRdata->SetMarkerColor(kRed+1);
    gRdata->SetMarkerSize (0.9);
    gRdata->SetMarkerStyle(kFullCircle);


    // Draw
    //--------------------------------------------------------------------------
    canvas = new TCanvas();

    TMultiGraph *mgR = new TMultiGraph();
    mgR->Add(gRdata);
    mgR->Add(gR);

    mgR->Draw("ap");

    mgR->GetYaxis()->SetTitle("R^{out/in}");
    mgR->GetXaxis()->SetTitle("mpmet (GeV)");

    mgR->SetMinimum(absoluteMin - 0.1);
    mgR->SetMaximum(1.0);


    // Legend
    //--------------------------------------------------------------------------
    TLegend* lmgR = new TLegend(0.62, 0.68, 0.86, 0.88);

    lmgR->AddEntry(gR,    " DY MC", "lp");
    lmgR->AddEntry(gRdata," data",  "lp");

    lmgR->SetFillColor(0);
    lmgR->SetLineColor(kWhite);
    lmgR->SetTextAlign(12);
    lmgR->SetTextFont (42);
    lmgR->SetTextSize (0.04);

    if      (channel == "SF")   lmgR->SetHeader("ee + #mu#mu");
    else if (channel == "EE")   lmgR->SetHeader("ee");
    else if (channel == "MuMu") lmgR->SetHeader("#mu#mu");

    lmgR->Draw();

    // Line at zero
    //--------------------------------------------------------------------------
    TLine* zeroLine = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0);
    zeroLine->SetLineStyle(3);
    zeroLine->SetLineWidth(2);
    zeroLine->Draw("same");
    mgR->Draw("p,same");
  

    // Save
    //--------------------------------------------------------------------------
    lmgR->Draw("same");

    if (jetbin == '3'){
      DrawTLatex(0.725, 0.65, 0.04,  "Inclusive");
      canvas->SaveAs("R_" + channel + "_Inclusive.png");
      canvas->SaveAs("R_" + channel + "_Inclusive.pdf");
    }
    else{                                                   //Inclusive 
      if      (jetbin == '0') DrawTLatex(0.725, 0.65, 0.04,  "0 Jet    ");
      else if (jetbin == '1') DrawTLatex(0.725, 0.65, 0.04,  "1 Jet    ");
      else if (jetbin == '2') DrawTLatex(0.725, 0.65, 0.04,  "2+ Jets  ");
      canvas->SaveAs("R_" + channel + "_" + jetbin + "jet.png");
      canvas->SaveAs("R_" + channel + "_" + jetbin + "jet.pdf");
    }
  }
}
예제 #30
0
void DrawNHIT()
{
  //=========Macro generated from canvas: r1/Energy
  //=========  (Fri Apr  6 17:14:48 2012) by ROOT version5.28/00g
  TCanvas *r1 = new TCanvas("r1", "Nhit",12,24,550,741);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gStyle->SetFrameLineWidth(1);
  r1->Range(0,0,1,1);
  r1->SetFillColor(0);
  r1->SetBorderMode(0);
  r1->SetBorderSize(0);
  r1->SetTickx(1);
  r1->SetTicky(1);
  r1->SetLeftMargin(0.16);
  r1->SetRightMargin(0.01);
  r1->SetTopMargin(0.0256917);
  r1->SetBottomMargin(0.07692308);
  r1->SetFrameBorderMode();
  
  // ------------>Primitives in pad: r1_1
  TPad *r1_1 = new TPad("r1_1", "Energy_1",0.02,0.37,0.95,0.99);
  r1_1->Draw();
  r1_1->cd();
  r1_1->Range(-19,0.01,95,95);
  r1_1->SetFillColor(0);
  r1_1->SetBorderMode(0);
  r1_1->SetBorderSize(2);
  r1_1->SetTickx(1);
  r1_1->SetTicky(1);
  r1_1->SetLeftMargin(0.16);
  r1_1->SetRightMargin(0.01);
  r1_1->SetTopMargin(0.02);
  r1_1->SetBottomMargin(0);
  r1_1->SetFrameBorderMode(0);
  r1_1->SetFrameBorderMode(0);
   
  TH1D *he = new TH1D("he"," ",55,0,55);
  he->SetMinimum(0.01);
  he->SetMaximum(500);
  he->SetStats(0);
  he->GetXaxis()->SetTitle("E_{beam} [GeV]");
  he->GetXaxis()->SetLabelFont(43);
  he->GetXaxis()->SetLabelSize(0);
  he->GetXaxis()->SetTitleFont(43);
  he->GetXaxis()->SetTitleSize(0); 
  he->GetYaxis()->SetTitle("<N_{hit}>");
  he->GetYaxis()->SetLabelFont(43);
  he->GetYaxis()->SetTitleSize(30);
  he->GetYaxis()->SetLabelSize(20);
  he->GetYaxis()->SetTitleFont(43);
  he->GetYaxis()->SetTitleOffset(1.7);
  he->GetZaxis()->SetLabelFont(42);
  he->GetZaxis()->SetTitleSize(0.05);
  he->GetZaxis()->SetTitleFont(42);
  he->Draw("");
   
  std::vector<result> resultData=readTXT(std::string("nhit_augsep2012_electron.txt"));
  TGraphErrors *gre = new TGraphErrors(resultData.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  gre->SetLineColor(1);
  gre->SetFillStyle(1);
  gre->SetFillColor(1);
  gre->SetLineWidth(2);
  gre->SetMarkerColor(1);
  gre->SetMarkerStyle(34);
  gre->SetMarkerSize(1.2);
  for(unsigned int i=0; i<resultData.size(); i++){
    gre->SetPoint(i,resultData.at(i).ebeam,resultData.at(i).nhit);
    gre->SetPointError(i,0,resultData.at(i).nhitError);
  }

  TH1F *Graph_Graph3 = new TH1F("Graph_Graph3","Graph",100,0,87.5);
  Graph_Graph3->SetMinimum(0);
  Graph_Graph3->SetMaximum(1193.483);
  Graph_Graph3->SetDirectory(0);
  Graph_Graph3->SetStats(0);
  Graph_Graph3->GetXaxis()->SetLabelFont(42);
  Graph_Graph3->GetXaxis()->SetTitleSize(0.05);
  Graph_Graph3->GetXaxis()->SetTitleFont(42);
  Graph_Graph3->GetYaxis()->SetLabelFont(42);
  Graph_Graph3->GetYaxis()->SetTitleSize(0.05);
  Graph_Graph3->GetYaxis()->SetTitleFont(42);
  Graph_Graph3->GetZaxis()->SetLabelFont(42);
  Graph_Graph3->GetZaxis()->SetTitleSize(0.05);
  Graph_Graph3->GetZaxis()->SetTitleFont(42);
  gre->SetHistogram(Graph_Graph3);
   
  gre->Draw("p");
   
  std::vector<result> resultFTFP=readTXT(std::string("nhit_ftfp_bert_hp_electron.txt"));
  gre = new TGraphErrors(resultFTFP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  gre->SetFillColor(kRed-3);
  gre->SetMarkerColor(kRed-3);
  gre->SetLineWidth(2);
  gre->SetMarkerStyle(20);
  for(unsigned int i=0; i<resultFTFP.size(); i++){
    gre->SetPoint(i,resultFTFP.at(i).ebeam,resultFTFP.at(i).nhit);
    gre->SetPointError(i,0,resultFTFP.at(i).nhitError);
  }
   
  TH1F *Graph1 = new TH1F("Graph1","Graph",100,0,87.17072);
  Graph1->SetMinimum(2.655724);
  Graph1->SetMaximum(88.56778);
  Graph1->SetDirectory(0);
  Graph1->SetStats(0);
  Graph1->GetXaxis()->SetLabelFont(42);
  Graph1->GetXaxis()->SetTitleSize(0.05);
  Graph1->GetXaxis()->SetTitleFont(42);
  Graph1->GetYaxis()->SetLabelFont(42);
  Graph1->GetYaxis()->SetTitleSize(0.05);
  Graph1->GetYaxis()->SetTitleFont(42);
  Graph1->GetZaxis()->SetLabelFont(42);
  Graph1->GetZaxis()->SetTitleSize(0.05);
  Graph1->GetZaxis()->SetTitleFont(42);
  gre->SetHistogram(Graph1);
   
  gre->Draw("p");

  std::vector<result> resultQGSP=readTXT(std::string("nhit_qgsp_bert_hp_electron.txt"));
  gre = new TGraphErrors(resultQGSP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  gre->SetFillColor(kBlue-6);
  gre->SetMarkerColor(kBlue-6);
  gre->SetLineWidth(2);
  gre->SetMarkerStyle(25);
  for(unsigned int i=0; i<resultQGSP.size(); i++){
    gre->SetPoint(i,resultQGSP.at(i).ebeam,resultQGSP.at(i).nhit);
    gre->SetPointError(i,0,resultQGSP.at(i).nhitError);
  }

  TH1F *Graph_Graph2 = new TH1F("Graph_Graph2","Graph",100,0,87.5);
  Graph_Graph2->SetMinimum(0);
  Graph_Graph2->SetMaximum(1193.483);
  Graph_Graph2->SetDirectory(0);
  Graph_Graph2->SetStats(0);
  Graph_Graph2->GetXaxis()->SetLabelFont(42);
  Graph_Graph2->GetXaxis()->SetTitleSize(0.05);
  Graph_Graph2->GetXaxis()->SetTitleFont(42);
  Graph_Graph2->GetYaxis()->SetLabelFont(42);
  Graph_Graph2->GetYaxis()->SetTitleSize(0.05);
  Graph_Graph2->GetYaxis()->SetTitleFont(42);
  Graph_Graph2->GetZaxis()->SetLabelFont(42);
  Graph_Graph2->GetZaxis()->SetTitleSize(0.05);
  Graph_Graph2->GetZaxis()->SetTitleFont(42);
  gre->SetHistogram(Graph_Graph2);
   
  gre->Draw("p");

  TLegend *leg = new TLegend(0.15,0.7,0.75,0.9,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextFont(62);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
   
  TLegendEntry *entry=leg->AddEntry("Graph_Graph3","SDHCAL DATA (H6 Cern SPS)","p");
  entry->SetLineColor(1);
  entry->SetLineStyle(1);
  entry->SetLineWidth(1);
  entry->SetMarkerColor(1);
  entry->SetMarkerStyle(34);
  entry->SetMarkerSize(1.2);

  entry=leg->AddEntry("Graph1","FTFP_BERT_HP","p");
  entry->SetLineColor(kRed-3);
  entry->SetLineStyle(kRed-3);
  entry->SetLineWidth(kRed-3);
  entry->SetMarkerColor(kRed-3);
  entry->SetMarkerStyle(20);
  entry->SetMarkerSize(1.0);

  entry=leg->AddEntry("Graph_Graph2","QGSP_BERT_HP","p");
  entry->SetLineColor(kBlue-6);
  entry->SetLineStyle(kBlue-6);
  entry->SetLineWidth(kBlue-6);
  entry->SetMarkerColor(kBlue-6);
  entry->SetMarkerStyle(25);
  entry->SetMarkerSize(0.9);

  leg->Draw();

  TText *tex=new TText();
  tex->SetTextSize(0.05);
  tex->SetTextColor(kGray+2);
  //tex->DrawTextNDC(0.5,0.05,"SDHCAL Preliminary");
  tex->DrawTextNDC(0.3,0.05,"CALICE Fe-SDHCAL Preliminary");
  r1_1->Modified();
  r1->cd();
  
  // ------------>Primitives in pad: r1_2
  TPad *r1_2 = new TPad("r1_2", "Energy_2",0.02,0.0,0.95,0.38);
  r1_2->Draw();
  r1_2->cd();
  r1_2->Range(-19,-0.06545455,95,0.048);
  r1_2->SetFillColor(0);
  r1_2->SetBorderMode(0);
  r1_2->SetBorderSize(2);
  r1_2->SetTickx(1);
  r1_2->SetTicky(1);
  r1_2->SetLeftMargin(0.16);
  r1_2->SetRightMargin(0.01);
  r1_2->SetTopMargin(0.0);
  r1_2->SetBottomMargin(0.23);
  r1_2->SetFrameBorderMode(0);
  r1_2->SetFrameBorderMode(0);
   
  TH1D *hd = new TH1D("hd"," ",55,0,55);
  hd->SetMinimum(-0.08);
  hd->SetMaximum(0.08);
  hd->SetStats(0);
  hd->GetXaxis()->SetTitle("E_{beam} [GeV]");
  hd->GetXaxis()->SetLabelFont(43);
  hd->GetXaxis()->SetLabelSize(20);
  hd->GetXaxis()->SetTitleFont(43);
  hd->GetXaxis()->SetTitleSize(30);
  hd->GetXaxis()->SetTitleOffset(2.);
  hd->GetYaxis()->SetTitle("(#DeltaN_{hit})/N_{data}");
  hd->GetYaxis()->SetLabelFont(43);
  hd->GetYaxis()->SetLabelSize(20);
  hd->GetYaxis()->SetTitleSize(30);
  hd->GetYaxis()->SetTitleOffset(1.7);
  hd->GetYaxis()->SetTitleFont(43);
  hd->GetYaxis()->SetNdivisions(505);
  hd->GetZaxis()->SetLabelFont(42);
  hd->GetZaxis()->SetTitleSize(0.05);
  hd->GetZaxis()->SetTitleFont(42);
  hd->Draw("");
   
  float deltaError;
  float delta;
  gre = new TGraphErrors(resultQGSP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  for(unsigned int i=0; i<resultQGSP.size(); i++){
    delta=(resultQGSP.at(i).nhit-resultData.at(i).nhit)/resultData.at(i).nhit;
    deltaError=1/resultData.at(i).nhit*
      sqrt(pow(resultQGSP.at(i).nhitError,2) +
	   pow(resultQGSP.at(i).nhit/resultData.at(i).nhit*resultData.at(i).nhitError,2));
    gre->SetPoint(i,resultQGSP.at(i).ebeam,delta);
    gre->SetPointError(i,0,deltaError);
  }
  gre->SetLineWidth(2);
  gre->SetLineColor(kBlue-6);
  gre->SetMarkerColor(kBlue-6);
  gre->SetMarkerSize(1.0);
  gre->SetMarkerStyle(25);
   
  gre->Draw("p");
   
  gre = new TGraphErrors(resultFTFP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  for(unsigned int i=0; i<resultFTFP.size(); i++){
    delta=(resultFTFP.at(i).nhit-resultData.at(i).nhit)/resultData.at(i).nhit;
    deltaError=1/resultData.at(i).nhit*
      sqrt(pow(resultFTFP.at(i).nhitError,2) +
	   pow(resultFTFP.at(i).nhit/resultData.at(i).nhit*resultData.at(i).nhitError,2));
    gre->SetPoint(i,resultFTFP.at(i).ebeam,delta);
    gre->SetPointError(i,0,deltaError);
  }
  gre->SetLineWidth(2);
  gre->SetLineColor(kRed-3);
  gre->SetMarkerColor(kRed-3);
  gre->SetMarkerSize(1.0);
  gre->SetMarkerStyle(20);
   
  gre->Draw("p");
   
   
  TF1 *lin1 = new TF1("lin1","0",-0.01,95);
  lin1->SetFillColor(19);
  lin1->SetFillStyle(0);
  lin1->SetLineWidth(1);
  lin1->SetLineStyle(1);
  lin1->SetLineColor(1);
  lin1->GetXaxis()->SetLabelFont(42);
  lin1->GetXaxis()->SetTitleSize(0.05);
  lin1->GetXaxis()->SetTitleFont(42);
  lin1->GetYaxis()->SetLabelFont(42);
  lin1->GetYaxis()->SetTitleSize(0.05);
  lin1->GetYaxis()->SetTitleFont(42);
  lin1->Draw("same");
   
  lin1 = new TF1("lin1","0.1",0.01,95);
  lin1->SetFillColor(1);
  lin1->SetFillStyle(0);
  lin1->SetLineWidth(1);
  lin1->SetLineStyle(2);
  lin1->SetLineColor(17);
  lin1->GetXaxis()->SetLabelFont(42);
  lin1->GetXaxis()->SetTitleSize(0.05);
  lin1->GetXaxis()->SetTitleFont(42);
  lin1->GetYaxis()->SetLabelFont(42);
  lin1->GetYaxis()->SetTitleSize(0.05);
  lin1->GetYaxis()->SetTitleFont(42);
  lin1->Draw("same");
   
  lin1 = new TF1("lin1","-0.1",0.01,95);
  lin1->SetFillColor(1);
  lin1->SetFillStyle(0);
  lin1->SetLineWidth(1);
  lin1->SetLineStyle(2);
  lin1->SetLineColor(17);
  lin1->GetXaxis()->SetLabelFont(42);
  lin1->GetXaxis()->SetTitleSize(0.05);
  lin1->GetXaxis()->SetTitleFont(42);
  lin1->GetYaxis()->SetLabelFont(42);
  lin1->GetYaxis()->SetTitleSize(0.05);
  lin1->GetYaxis()->SetTitleFont(42);
  lin1->Draw("same");

  r1_2->Modified();
  r1->cd();
  r1->Modified();
  r1->cd();
  r1->SetSelected(r1);
  r1->SaveAs("../plots/NHITELECTRON.pdf");
}