コード例 #1
0
void EnvelopeComponent::setLegendText(Text const& legendText)
{	
	EnvelopeLegendComponent* legend = getLegend();
	
	if(legend == 0) return;
	
	legend->setText(legendText);
}
コード例 #2
0
void EnvelopeComponent::setLegendTextToDefault()
{
	EnvelopeLegendComponent* legend = getLegend();
	
	if(legend == 0) return;
	
	legend->setText();	
}
コード例 #3
0
ファイル: BXmistags.C プロジェクト: bjet2015/dibjets
void findfunc()
{

  //dijet case
  // auto fmcppbjt = config.getfile_djt("mcppbfa");
  // auto nt = (TTree *)fmcppbjt->Get("nt");
  // seth(18,40,220);
  // auto hd = geth("hd");
  // auto hn = geth("hn");
  // nt->Project("hd","jtpt2","weight*(pthat>80 && jtpt1>100 && abs(refparton_flavorForB1)==5 && abs(refparton_flavorForB2)!=5 && dphi21>2.1)");
  // nt->Project("hn","jtpt2","weight*(pthat>80 && jtpt1>100 && abs(refparton_flavorForB1)==5 && abs(refparton_flavorForB2)!=5 && dphi21>2.1 && discr_csvV1_2>0.9)");
  // hn->Divide(hn,hd,1,1,"B")
  // hn->Fit(f)
  

  auto fpp = new TF1("fpp","expo",40,200);
  auto f1 = new TF1("fPb1","expo",40,200);
  auto f2 = new TF1("fPb2","expo",40,200);
  auto f3 = new TF1("fPb3","expo",40,200);
  seth(18,40,200);


  auto ntpp = (TTree *)config.getfile_inc("mcppqcd")->Get("nt");

  auto hd = geth("hd");
  auto hn = geth("hn",";p_{T} [GeV];mistag probability");
  ntpp->Project("hd","jtpt","weight*(pthat>50 && refpt>20 && abs(refparton_flavorForB)!=5)");
  ntpp->Project("hn","jtpt","weight*(pthat>50 && refpt>20 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn->Divide(hn,hd,1,1,"B");
  // hn->Scale(1/hn->Integral());
  hn->Fit(fpp);

  auto nt = (TTree *)config.getfile_inc("mcPbqcd")->Get("nt");

  auto hd1 = geth("hd1");
  auto hn1 = geth("hn1",";p_{T} [GeV];mistag probability");
  nt->Project("hd1","jtpt","weight*(pthat>50 && refpt>20 && bin < 20 && abs(refparton_flavorForB)!=5)");
  nt->Project("hn1","jtpt","weight*(pthat>50 && refpt>20 && bin < 20 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn1->Divide(hn1,hd1,1,1,"B");
  // hn1->Scale(1/hn1->Integral());
  hn1->Fit(f1);

  auto hd2 = geth("hd2");
  auto hn2 = geth("hn2",";p_{T} [GeV];mistag probability");
  nt->Project("hd2","jtpt","weight*(pthat>50 && refpt>20 && bin>=20 && bin<60 && abs(refparton_flavorForB)!=5)");
  nt->Project("hn2","jtpt","weight*(pthat>50 && refpt>20 && bin>=20 && bin<60 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn2->Divide(hn2,hd2,1,1,"B");
  // hn2->Scale(1/hn2->Integral());
  hn2->Fit(f2);

  auto hd3 = geth("hd3");
  auto hn3 = geth("hn3",";p_{T} [GeV];mistag probability");
  nt->Project("hd3","jtpt","weight*(pthat>50 && refpt>20 && bin>=60 && abs(refparton_flavorForB)!=5)");
  nt->Project("hn3","jtpt","weight*(pthat>50 && refpt>20 && bin>=60 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn3->Divide(hn3,hd3,1,1,"B");
  // hn3->Scale(1/hn3->Integral());
  hn3->Fit(f3);


  // because of backward imcompatibility with root version on polui

  cout<<"auto fpp = new TF1(\"fpp\",\"expo\","<<fpp->GetXmin()<<","<<fpp->GetXmax()<<");"<<endl;
  cout<<"auto fPb1 = new TF1(\"fPb1\",\"expo\","<<f1->GetXmin()<<","<<f1->GetXmax()<<");"<<endl;
  cout<<"auto fPb2 = new TF1(\"fPb2\",\"expo\","<<f2->GetXmin()<<","<<f2->GetXmax()<<");"<<endl;
  cout<<"auto fPb3 = new TF1(\"fPb3\",\"expo\","<<f3->GetXmin()<<","<<f3->GetXmax()<<");"<<endl;


  cout<<"fpp->SetParameters("<<fpp->GetParameter(0)<<","<<fpp->GetParameter(1)<<");"<<endl;
  cout<<"fPb1->SetParameters("<<f1->GetParameter(0)<<","<<f1->GetParameter(1)<<");"<<endl;
  cout<<"fPb2->SetParameters("<<f2->GetParameter(0)<<","<<f2->GetParameter(1)<<");"<<endl;
  cout<<"fPb3->SetParameters("<<f3->GetParameter(0)<<","<<f3->GetParameter(1)<<");"<<endl;

  // hn->SetMinimum(0);
  // hn1->SetMinimum(0);
  // hn2->SetMinimum(0);
  // hn3->SetMinimum(0);


  auto fout = new TFile("../correctionfiles/BXmistagfunc.root","recreate");
  fout->cd();
  fpp->Write();
  f1->Write();
  f2->Write();
  f3->Write();
  hn->Write();
  hn1->Write();
  hn2->Write();
  hn3->Write();



  auto c = getc();
  f1->SetLineColor(kRed);
  f2->SetLineColor(kGreen);
  f3->SetLineColor(kOrange);
  fpp->SetLineColor(kBlue);

  auto l = getLegend();
  l->AddEntry(fpp,"pp","L");
  l->AddEntry(f1,"bin<20","L");
  l->AddEntry(f2,"20<bin<60","L");
  l->AddEntry(f3,"bin>60","L");

  f1->GetXaxis()->SetTitle("p_{T} [GeV]");
  f1->GetYaxis()->SetTitle("mistag probability");


  f1->Draw();
  f2->Draw("same");
  f3->Draw("same");
  fpp->Draw("same");

  l->Draw();

  SavePlot(c,"func");

  float x = 0.55;
  float y = 0.75;

  auto t= new TLatex();

  auto cpp = getc();
  hn->Draw();
  fpp->Draw("same");
  t->DrawLatexNDC(x,y,"pp");
  SavePlot(cpp,"pp");


  auto c1 = getc();
  hn1->Draw();
  f1->Draw("same");
  t->DrawLatexNDC(x,y,"PbPb 0-10%");
  SavePlot(c1,"bin_0_20");

  auto c2 = getc();
  hn2->Draw();
  f2->Draw("same");
  t->DrawLatexNDC(x,y,"PbPb 10-30%");
  SavePlot(c2,"bin_20_60");

  auto c3 = getc();
  hn3->Draw();
  f3->Draw("same");
  t->DrawLatexNDC(x,y,"PbPb 30-100%");
  SavePlot(c3,"bin_60");


  fout->Close();

}
コード例 #4
0
ファイル: Hootilities.C プロジェクト: hooberman/UserCode
void compareDataMC( vector<TChain*> chmc , vector<char*> labels , TChain* chdata , char* var , 
		    TCut sel , TCut weight , int nbins ,  float xmin , float xmax ,  
		    char* xtitle , bool overlayData , bool residual , bool drawLegend , bool log , char* flavor ){

  TPad* fullpad = new TPad();
  TPad* plotpad = new TPad();
  TPad* respad  = new TPad();

  if( residual ){
    fullpad = new TPad("fullpad","fullpad",0,0,1,1);
    fullpad->Draw();
    fullpad->cd();

    plotpad = new TPad("plotpad","plotpad",0,0,1,0.8);
    plotpad->Draw();
    plotpad->cd();
    if( log ) plotpad->SetLogy();
  }
  else{
    if( log ) gPad->SetLogy();
  }

  TString tvar(var);
  tvar.ReplaceAll("()","");
  tvar.ReplaceAll(".","");
  const char* myvar = tvar;

  cout << "Plotting var " << myvar << " flavor " << flavor << endl;

  int colors[]={6,2,7,4,5,8,9,15,12};
  int sigcolors[]={4,1,7,4,5,8,9,15,12};
  int isigmc = 0;

  assert( chmc.size() == labels.size() );
  const unsigned int nmc = chmc.size();

  THStack* mcstack = new THStack("mcstack","mcstack");
  TH1F*    mctothist = new TH1F();
  TH1F*    smtothist = new TH1F();
  TH1F*    mchist[nmc];
  TH1F*    datahist = new TH1F(Form("%s_datahist_%s",myvar,flavor),Form("%s_datahist_%s",myvar,flavor),nbins,xmin,xmax);

  vector<TH1F*> sighist;

  float trigeff = 1.0;
  //if     ( TString(flavor).Contains("ee")  ) trigeff = 1.00;
  //else if( TString(flavor).Contains("mm")  ) trigeff = 0.90;
  //else if( TString(flavor).Contains("em")  ) trigeff = 0.95;
  //else if( TString(flavor).Contains("all") ) trigeff = 0.95;

  TCut trigweight(Form("%.2f",trigeff));

  for( unsigned int imc = 0 ; imc < nmc ; imc++ ){
  //for( int imc = nmc-1 ; imc > -1 ; imc-- ){

    bool isSignal = TString( labels.at(imc) ).Contains("T2");

    mchist[imc] = new TH1F(Form("%s_mc_%i_%s",myvar,imc,flavor),Form("%s_mc_%i_%s",myvar,imc,flavor),nbins,xmin,xmax);
    mchist[imc]->Sumw2();

    chmc.at(imc)->Draw(Form("TMath::Min(%s,%f)>>%s_mc_%i_%s",var,xmax-0.01,myvar,imc,flavor),sel*weight*trigweight);

    if( isSignal ){
      mchist[imc]->SetFillColor( 0 );
      //mchist[imc]->SetLineStyle(2);
      mchist[imc]->SetLineWidth(2);
      mchist[imc]->SetLineColor( sigcolors[isigmc++] );
      if( TString( labels.at(imc) ).Contains("X5") ){
	mchist[imc]->Scale(5);
	cout << "Scaling signal MC by 5" << endl;
      }
      if( TString( labels.at(imc) ).Contains("X6") ){
	mchist[imc]->Scale(6);
	cout << "Scaling signal MC by 6" << endl;
      }
      if( TString( labels.at(imc) ).Contains("X10") ){
	mchist[imc]->Scale(10);
	cout << "Scaling signal MC by 10" << endl;
      }
    }else{
      mchist[imc]->SetLineWidth(1);
      mchist[imc]->SetFillColor( colors[imc] );
      mchist[imc]->SetLineColor( 1 );
    }

    //mcstack->Add( mchist[imc] );

    if( !isSignal ){
      mcstack->Add( mchist[imc] );

      if( imc == 0 ){
	mctothist = (TH1F*) mchist[imc]->Clone();
	smtothist = (TH1F*) mchist[imc]->Clone();
      }
      else{
	mctothist->Add(mchist[imc]);
	smtothist->Add(mchist[imc]);
      }
    }
    else{
      mctothist->Add(mchist[imc]);
      sighist.push_back( mchist[imc] );
    }

    cout << "MC yield " << labels[imc] << " " << Form("%.2f",mchist[imc]->Integral()) << endl;
  }

  chdata->Draw(Form("TMath::Min(%s,%f)>>%s_datahist_%s",var,xmax-0.01,myvar,flavor),sel);

  if( overlayData ){

    float max = datahist->GetMaximum() + datahist->GetBinError(datahist->GetMaximumBin());
    if( mctothist->GetMaximum() > max ) max = mctothist->GetMaximum();
    if( log ) datahist->SetMaximum( 15 * max );
    else      datahist->SetMaximum( 1.4 * max );

    datahist->GetXaxis()->SetTitle(xtitle);
    datahist->Draw("E1");
    mcstack->Draw("samehist");
    
    for( unsigned int isig = 0 ; isig < sighist.size() ; isig++ ){
      sighist.at(isig)->Add(smtothist);
      sighist.at(isig)->Draw("samehist");
    } 

    datahist->Draw("sameE1");
    datahist->Draw("sameaxis");

    if(!log) datahist->GetYaxis()->SetRangeUser(0.,1.4*max);
    
  }
  else{
    float max = mctothist->GetMaximum();
    if( log ) mctothist->SetMaximum( 15 * max );
    else      mctothist->SetMaximum( 1.4 * max );

    mctothist->SetLineColor(0);
    mctothist->SetFillColor(0);

    mctothist->GetXaxis()->SetTitle(xtitle);
    mctothist->Draw("hist");
    mcstack->Draw("samehist");

    for( unsigned int isig = 0 ; isig < sighist.size() ; isig++ ){
      sighist.at(isig)->Add(smtothist);
      sighist.at(isig)->Draw("samehist");
    } 

    mctothist->Draw("sameaxis");
  }

  if( drawLegend ){
    TLegend* myleg = getLegend( chmc , labels , overlayData );
    myleg->Draw();
  }

  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextSize(0.04);
  text->DrawLatex(0.2,0.88,"CMS Preliminary");
  //text->DrawLatex(0.2,0.83,"0.98 fb^{-1} at #sqrt{s} = 7 TeV");
  text->DrawLatex(0.2,0.83,"#sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 1.0 fb^{-1}");

  if     ( TString(flavor).Contains("e")  )  text->DrawLatex(0.2,0.78,"e-channel");
  else if( TString(flavor).Contains("m")  )  text->DrawLatex(0.2,0.78,"#mu-channel");
  else if( TString(flavor).Contains("all") ) text->DrawLatex(0.2,0.78,"e/#mu-channel");

  if( residual ){
    fullpad->cd();

    respad = new TPad("respad","respad",0,0.8,1,1);
    respad->Draw();
    respad->cd();

    //gPad->SetGridy();

    TH1F* ratio = (TH1F*) datahist->Clone(Form("%s_ratio",datahist->GetName()));
    ratio->Divide(smtothist);

    ratio->GetYaxis()->SetTitleOffset(0.3);
    ratio->GetYaxis()->SetTitleSize(0.2);
    ratio->GetYaxis()->SetNdivisions(5);
    ratio->GetYaxis()->SetLabelSize(0.2);
    ratio->GetYaxis()->SetRangeUser(0.5,1.5);
    ratio->GetYaxis()->SetTitle("data/SM  ");
    ratio->GetXaxis()->SetLabelSize(0);
    ratio->GetXaxis()->SetTitleSize(0);
    ratio->SetMarkerSize(1);
    ratio->Draw();

    TLine line;
    line.SetLineWidth(1);
    line.DrawLine(datahist->GetXaxis()->GetXmin(),1,datahist->GetXaxis()->GetXmax(),1);

  }






}
コード例 #5
0
ファイル: Hootilities.C プロジェクト: hooberman/UserCode
void compareDataMC( vector<TChain*> chmc , vector<char*> labels , TChain* chdata , char* var , 
		    TCut sel , TCut weight , int nbins ,  float xmin , float xmax ,  
		    char* xtitle , bool overlayData , bool residual , bool drawLegend , bool log , char* flavor ){

  TPad* fullpad = new TPad();
  TPad* plotpad = new TPad();
  TPad* respad  = new TPad();

  if( residual ){
    fullpad = new TPad("fullpad","fullpad",0,0,1,1);
    fullpad->Draw();
    fullpad->cd();

    plotpad = new TPad("plotpad","plotpad",0,0,1,0.8);
    plotpad->Draw();
    plotpad->cd();
    if( log ) plotpad->SetLogy();
  }
  else{
    if( log ) gPad->SetLogy();
  }

  TString tvar(var);
  tvar.ReplaceAll("()","");
  tvar.ReplaceAll(".","");
  const char* myvar = tvar;

  cout << "Plotting var " << myvar << " flavor " << flavor << endl;

  //int colors[]={6,2,7,4,5,8,9,15,12};
  int colors[]={kBlue-6,kRed+2,7,5,5,8,9,15,12};

  assert( chmc.size() == labels.size() );
  const unsigned int nmc = chmc.size();

  THStack* mcstack = new THStack("mcstack","mcstack");
  TH1F*    mctothist = new TH1F();
  TH1F*    mchist[nmc];
  TH1F*    datahist = new TH1F(Form("%s_datahist_%s",myvar,flavor),Form("%s_datahist_%s",myvar,flavor),nbins,xmin,xmax);

  float trigeff = 1.0;
  //if     ( TString(flavor).Contains("ee")  ) trigeff = 1.00;
  //else if( TString(flavor).Contains("mm")  ) trigeff = 0.90;
  //else if( TString(flavor).Contains("em")  ) trigeff = 0.95;
  //else if( TString(flavor).Contains("all") ) trigeff = 0.95;
  if     ( TString(flavor).Contains("ee")  ) sel+="leptype==0";
  else if( TString(flavor).Contains("mm")  ) sel+="leptype==1";
  else if( TString(flavor).Contains("em")  ) sel+="leptype==2";
  //else if( TString(flavor).Contains("all") ) 

  TCut trigweight(Form("%.2f",trigeff));

  for( unsigned int imc = 0 ; imc < nmc ; imc++ ){
  //for( int imc = nmc-1 ; imc > -1 ; imc-- ){

    mchist[imc] = new TH1F(Form("%s_mc_%i_%s",myvar,imc,flavor),Form("%s_mc_%i_%s",myvar,imc,flavor),nbins,xmin,xmax);
    mchist[imc]->Sumw2();

    chmc.at(imc)->Draw(Form("TMath::Min(%s,%f)>>%s_mc_%i_%s",var,xmax-0.01,myvar,imc,flavor),sel*weight*trigweight);

    if( TString( labels.at(imc) ).Contains("LM") || TString( labels.at(imc) ).Contains("T2tt") ){
      mchist[imc]->SetFillColor( 0 );
      mchist[imc]->SetLineStyle(2);
    }else{
      mchist[imc]->SetFillColor( colors[imc] );
    }

    // if( strcmp(labels[imc],"ttfake")  == 0 || strcmp(labels[imc],"wjets")  == 0 ){
    //   cout << "Scaling " << labels[imc] << " by 3.8" << endl;
    //   mchist[imc]->Scale(3.8);
    // }

    mcstack->Add( mchist[imc] );

    if( imc == 0 ) mctothist = (TH1F*) mchist[imc]->Clone();
    else           mctothist->Add(mchist[imc]);

    cout << "MC yield " << labels[imc] << " " << Form("%.2f",mchist[imc]->Integral()) << endl;
  }

  chdata->Draw(Form("TMath::Min(%s,%f)>>%s_datahist_%s",var,xmax-0.01,myvar,flavor),sel);

  if( overlayData ){

    float max = datahist->GetMaximum() + datahist->GetBinError(datahist->GetMaximumBin());
    if( mctothist->GetMaximum() > max ) max = mctothist->GetMaximum();
    if( log ) datahist->SetMaximum( 15 * max );
    else      datahist->SetMaximum( 1.4 * max );

    datahist->GetXaxis()->SetTitle(xtitle);
    datahist->Draw("E1");
    mcstack->Draw("samehist");
    datahist->Draw("sameE1");
    datahist->Draw("sameaxis");
    
    if(!log) datahist->GetYaxis()->SetRangeUser(0.,1.4*max);
    
    cout << "data yield " << datahist->Integral() << endl;

  }
  else{
    mctothist->GetXaxis()->SetTitle(xtitle);
    mctothist->Draw();
    mcstack->Draw("same");
    mctothist->Draw("sameaxis");
  }

  if( drawLegend ){
    TLegend* myleg = getLegend( chmc , labels , overlayData );
    myleg->Draw();
  }

  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextSize(0.05);
  text->DrawLatex(0.2,0.88,"CMS Preliminary");
  //text->DrawLatex(0.2,0.83,"0.98 fb^{-1} at #sqrt{s} = 7 TeV");
  text->DrawLatex(0.2,0.83,"#sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 4.3 fb^{-1}");

  if     ( TString(flavor).Contains("ee")  ) text->DrawLatex(0.2,0.78,"Events with ee");
  else if( TString(flavor).Contains("mm")  ) text->DrawLatex(0.2,0.78,"Events with #mu#mu");
  else if( TString(flavor).Contains("em")  ) text->DrawLatex(0.2,0.78,"Events with e#mu");
  else if( TString(flavor).Contains("all") ) text->DrawLatex(0.2,0.78,"Events with ee/#mu#mu/e#mu");

  if( residual ){
    fullpad->cd();

    respad = new TPad("respad","respad",0,0.8,1,1);
    respad->Draw();
    respad->cd();

    gPad->SetGridy();

    TH1F* ratio = (TH1F*) datahist->Clone(Form("%s_ratio",datahist->GetName()));
    ratio->Divide(mctothist);

    ratio->GetYaxis()->SetTitleOffset(0.3);
    ratio->GetYaxis()->SetTitleSize(0.2);
    ratio->GetYaxis()->SetNdivisions(5);
    ratio->GetYaxis()->SetLabelSize(0.2);
    //ratio->GetYaxis()->SetRangeUser(0.5,1.5);
    ratio->GetYaxis()->SetRangeUser(0.,2.);
    ratio->GetYaxis()->SetTitle("data/MC  ");
    ratio->GetXaxis()->SetLabelSize(0);
    ratio->GetXaxis()->SetTitleSize(0);
    ratio->SetMarkerSize(0.7);
    ratio->Draw();

    TLine line;
    line.SetLineWidth(1);
    line.DrawLine(datahist->GetXaxis()->GetXmin(),1,datahist->GetXaxis()->GetXmax(),1);

  }






}
コード例 #6
0
ファイル: tageffcorr.C プロジェクト: bjet2015/dibjets
void findtruthpp()
{
  seth(10,0,1);
  auto hmcppxJTrue = geth("hmcppxJTrue","true;x_{J};Event fractions");
  auto hmcppxJTrueTag = geth("hmcppxJTrueTag","true tagged;x_{J};Event fractions");
  auto hmcppxJTrueTagCorr = geth("hmcppxJTrueTagCorr","true tagged corrected;x_{J};Event fractions");

  TFile *fmcpp = new TFile(config.getFileName_djt("mcppbfa"));
  Fill(fmcpp,[&] (dict &m) {
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;
    // if (m["pthat"]<80) return;
    
    // if (m["bProdCode"]!=1) return;
    float w = m["weight"]*processweight((int)m["bProdCode"]);

    // float w = m["weight"];
    // if (m["bProdCode"]==2) return;

    float corr = tageffcorrectionpp(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB]);
    float wb = w*corr;

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23)
      hmcppxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 && m[discr_csvV1_SB]>0.9) {
      hmcppxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcppxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
    }


  });

  NormalizeAllHists();
  plotputmean = true;
  plotytitle = "Event fractions";
  plotdivide = false;
  // aktstring += "R=0.4 |#eta|<2.0";
  // plotsecondline = Form("p_{T,1}>%d GeV, p_{T,2}>%d GeV", (int)pt1cut, (int)pt2cut);
  // plotthirdline = "#Delta#phi>2/3#pi";
  plottextposy = 0.8;
  plottextposx = 0.2;

  plotmeanposy = 0.43;
  plotymax = 0.2;
  plotymin = 0;
  plotlegendpos = BottomRight;//TopLeft;
  
  aktstring = "pp";
  SetMC({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});
  SetData({hmcppxJTrue});
  Draw({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  hmcppxJTrue->SetMinimum(0);
  hmcppxJTrue->SetMaximum(0.3);
  hmcppxJTrue->SetLineWidth(2);
  hmcppxJTrue->SetMarkerStyle(kNone);
  hmcppxJTrue->SetFillStyle(0);

  hmcppxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcppxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;

  SetB({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  float xjtrue = hmcppxJTrue->GetMean();
  float xjtruetag = hmcppxJTrueTag->GetMean();
  float xjtruetagcorr = hmcppxJTrueTagCorr->GetMean();

  float exjtrue = hmcppxJTrue->GetMeanError();
  float exjtruetag = hmcppxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcppxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcppxJTrue->Draw("hist");
  hmcppxJTrueTag->Draw("E1,same");
  hmcppxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcppxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcppxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcppxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,"closurepp");
}
コード例 #7
0
ファイル: tageffcorr.C プロジェクト: bjet2015/dibjets
void findtruthPbPb(int binMin, int binMax)
{
  TFile *fmc = new TFile(config.getFileName_djt("mcPbbfa"));

  buildNamesuffix = TString::Format("_bin_%d_%d",binMin, binMax);
  //  buildTitlesuffix = TString::Format("%d-%d %%",binMin/2, binMax/2);

  seth(10,0,1);
  auto hmcPbPbxJTrue = geth("hmcPbPbxJTrue","PbPb true;x_{J};Event fractions");
  auto hmcPbPbxJTrueTag = geth("hmcPbPbxJTrueTag","PbPb true tagged;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorr = geth("hmcPbPbxJTrueTagCorr","PbPb true tagged corrected;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrPt = geth("hmcPbPbxJTrueTagCorrPt","PbPb true tagged corrected pt;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrEta = geth("hmcPbPbxJTrueTagCorrEta","PbPb true tagged corrected eta;x_{J};Event fractions");
  auto hmcPbPbxJTrueTagCorrBin = geth("hmcPbPbxJTrueTagCorrBin","PbPb true tagged corrected bin;x_{J};Event fractions");

  seth(12,20,140);//10,40,100);
  auto hpt2true = geth("hpt2true","true;p_{T,2} GeV");
  auto hpt2truetag = geth("hpt2truetag","true tagged;p_{T,2} GeV");
  auto hpt2truetagovertrue = geth("hpt2truetagovertrue","true tagged/true;p_{T,2} GeV");
  auto hpt2truetagcorr = geth("hpt2truetagcorr","true tagged corrected;p_{T,2} GeV");
  auto hpt2truetagcorrovertrue = geth("hpt2truetagcorrovertrue","true tagged corrected/true;p_{T,2} GeV");

  seth(10,100,200);
  auto hpt1true = geth("hpt1true","true;p_{T,1} GeV");
  auto hpt1truetag = geth("hpt1truetag","true tagged;p_{T,1} GeV");
  auto hpt1truetagovertrue = geth("hpt1truetagovertrue","true tagged/true;p_{T,1} GeV");
  auto hpt1truetagcorr = geth("hpt1truetagcorr","true tagged corrected;p_{T,1} GeV");
  auto hpt1truetagcorrovertrue = geth("hpt1truetagcorrovertrue","true tagged corrected/true;p_{T,1} GeV");

  seth(10,0,200);
  auto hbintrue = geth("hbintrue","true;bin");
  auto hbintruetag = geth("hbintruetag","true tagged;bin");
  auto hbintruetagovertrue = geth("hbintruetagovertrue","true tagged/true;bin");
  auto hbintruetagcorr = geth("hbintruetagcorr","true tagged corrected;bin");
  auto hbintruetagcorrovertrue = geth("hbintruetagcorrovertrue","true tagged corrected/true;bin");

  seth(20,-2,2);
  auto heta2true = geth("heta2true","true;#eta_{2}");
  auto heta2truetag = geth("heta2truetag","true tagged;#eta_{2}");
  auto heta2truetagovertrue = geth("heta2truetagovertrue","true tagged/true;#eta_{2}");
  auto heta2truetagcorr = geth("heta2truetagcorr","true tagged corrected;#eta_{2}");
  auto heta2truetagcorrovertrue = geth("heta2truetagcorrovertrue","true tagged corrected/true;#eta_{2}");

  auto heta1true = geth("heta1true","true;#eta_{1}");
  auto heta1truetag = geth("heta1truetag","true tagged;#eta_{1}");
  auto heta1truetagovertrue = geth("heta1truetagovertrue","true tagged/true;#eta_{1}");
  auto heta1truetagcorr = geth("heta1truetagcorr","true tagged corrected;#eta_{1}");
  auto heta1truetagcorrovertrue = geth("heta1truetagcorrovertrue","true tagged corrected/true;#eta_{1}");

  unordered_set<int> eventstodiscard = {1805770,1116573,1084397};//,
                                        // 5755734,1599758,395810,
                                      // 1363321,211625,3195128};
//

  Fill(fmc,[&] (dict &m) {
    if (m["bin"]<binMin || m["bin"]>=binMax) return;
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;

    // if (m["bProdCode"]>1) return;

    if (eventstodiscard.find(m["event"])!=eventstodiscard.end()) return; //kill large-weight GSP event

    float w = m["weight"]*processweight((int)m["bProdCode"]); //because we have only b-dijets


    float corr = tageffcorrectionPbPb(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB],m["bin"]);
    // float corrpt  = getPbPbcorrectionPt(m["jtpt1"],m[jtptSB]);
    // float correta = getPbPbcorrectionEta(m["jteta1"],m[jtetaSB]);
    // float corrbin = getPbPbcorrectionBin(m["bin"]);


    float wb = w*corr;



   if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23) {
      hmcPbPbxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);
      hpt2true->Fill(m[jtptSB],w);
      hpt1true->Fill(m["jtpt1"],w);
      heta2true->Fill(m[jtetaSB],w);
      heta1true->Fill(m["jteta1"],w);
      hbintrue->Fill(m["bin"],w);
   }

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[refptSB]>20 && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 &&  m[discr_csvV1_SB]>0.9) { //

     //corrpt *= m[jtptSB] < 60 ? 1./0.7 : 1;
     //wb *= m[jtptSB] < 60 ? 1./0.7 : 1;

      hmcPbPbxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcPbPbxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
      // hmcPbPbxJTrueTagCorrPt->Fill(m[jtptSB]/m["jtpt1"],w*corrpt);
      // hmcPbPbxJTrueTagCorrEta->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta);
      // hmcPbPbxJTrueTagCorrBin->Fill(m[jtptSB]/m["jtpt1"],w*corrpt*correta*corrbin);


      hpt2truetag->Fill(m[jtptSB],w);
      hpt1truetag->Fill(m["jtpt1"],w);
      heta2truetag->Fill(m[jtetaSB],w);
      heta1truetag->Fill(m["jteta1"],w);
      hbintruetag->Fill(m["bin"],w);

      hpt2truetagcorr->Fill(m[jtptSB],wb);
      hpt1truetagcorr->Fill(m["jtpt1"],wb);
      heta2truetagcorr->Fill(m[jtetaSB],wb);
      heta1truetagcorr->Fill(m["jteta1"],wb);
      hbintruetagcorr->Fill(m["bin"],wb);

    }






  });

  NormalizeAllHists();
//plotymax = 9999;
  aktstring = TString::Format("PbPb %d-%d %%",binMin/2, binMax/2);//TString::Format("PbPb#Delta#phi>2/3#pi %d-%d %%",binMin/2, binMax/2);

  SetMC({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});
  SetData({hmcPbPbxJTrue});
  hmcPbPbxJTrue->SetMinimum(0);
  hmcPbPbxJTrue->SetMaximum(0.3);
  hmcPbPbxJTrue->SetLineWidth(2);
  hmcPbPbxJTrue->SetMarkerStyle(kNone);
  hmcPbPbxJTrue->SetFillStyle(0);

  hmcPbPbxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcPbPbxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;
  Draw({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});

  SetB({hmcPbPbxJTrue,hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorr});

  float xjtrue = hmcPbPbxJTrue->GetMean();
  float xjtruetag = hmcPbPbxJTrueTag->GetMean();
  float xjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMean();

  float exjtrue = hmcPbPbxJTrue->GetMeanError();
  float exjtruetag = hmcPbPbxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcPbPbxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcPbPbxJTrue->Draw("hist");
  hmcPbPbxJTrueTag->Draw("E1,same");
  hmcPbPbxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcPbPbxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcPbPbxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcPbPbxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,Form("closure%d%d",binMin,binMax));


    // //if (binMin==0 && binMax==200) {

    // Draw({hmcPbPbxJTrueTag,hmcPbPbxJTrueTagCorrPt,hmcPbPbxJTrueTagCorrEta,hmcPbPbxJTrueTagCorrBin});
 

    // SetMC({hpt2truetag,hpt1truetag,heta2truetag,heta1truetag,hbintruetag});

    // plotputmean = false;

    // plotymax = 0.2;

    // Draw({hpt2true,hpt2truetag,hpt2truetagcorr});

    // plotymax = 0.3;

    // Draw({hpt1true,hpt1truetag,hpt1truetagcorr});

    // plotymax = 0.2;
    // Draw({heta2true,heta2truetag,heta2truetagcorr});
    // Draw({heta1true,heta1truetag,heta1truetagcorr});

    // plotymax = 1;
    // Draw({hbintrue,hbintruetag,hbintruetagcorr});


plotymin = 0;
plotymax = 0.2;

Draw({hpt2truetag,hpt2true});
Draw({hpt2truetagcorr,hpt2true});
hpt2truetagovertrue->Divide(hpt2truetag,hpt2true,1,1); //"B"
hpt1truetagovertrue->Divide(hpt1truetag,hpt1true,1,1); //"B"
heta2truetagovertrue->Divide(heta2truetag,heta2true,1,1); //"B"
heta1truetagovertrue->Divide(heta1truetag,heta1true,1,1); //"B"
hbintruetagovertrue->Divide(hbintruetag,hbintrue,1,1); //"B"


hpt2truetagcorrovertrue->Divide(hpt2truetagcorr,hpt2true,1,1); //"B"
hpt1truetagcorrovertrue->Divide(hpt1truetagcorr,hpt1true,1,1); //"B"
heta2truetagcorrovertrue->Divide(heta2truetagcorr,heta2true,1,1); //"B"
heta1truetagcorrovertrue->Divide(heta1truetagcorr,heta1true,1,1); //"B"
hbintruetagcorrovertrue->Divide(hbintruetagcorr,hbintrue,1,1); //"B"

 NormalizeAllHists();

Draw({hpt2truetagovertrue,hpt2truetagcorrovertrue});
Draw({hpt1truetagovertrue,hpt1truetagcorrovertrue});
Draw({heta2truetagovertrue,heta2truetagcorrovertrue});
Draw({heta1truetagovertrue,heta1truetagcorrovertrue});
Draw({hbintruetagovertrue,hbintruetagcorrovertrue});



 // }

}