void ReadAllHistograms(const NameMap& dictionary, OutputMap& values)
 {
     for(const auto& entry : dictionary) {
         const std::string& hist_name = entry.second.at(version);
         if(!hist_name.size()) continue;
         const auto hist = GetHist(hist_name);
         values[entry.first] = hist;
         all_hists.push_back(hist);
     }
 }
Example #2
0
void FitHist(Double_t * d, char * path)
{

TH1D* hist = GetHist(path);
if (hist == NULL )
	{
		d[0]=-1;
	    d[1]=-1;
		d[2]=-1;
		return;
	}
TF1 *func = new TF1 ("fit",DoubleErrf,hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax(),3);
func->SetParameters(0.,0.1,hist->GetEntries());
func->SetParNames ("Mean_value","Sigma","N");
hist->Fit("fit","Q");
//Double_t d[2];
d[0]=func->GetParameter(0);
d[1]=func->GetParameter(1);
d[2]=func->GetParameter(2);
//return d;
//cout<<endl<<"for "<<path<<endl<<"mean = "<<func->GetParameter(0)<<endl<<"sigma = "<<func->GetParameter(1)<<endl;
}
Example #3
0
void NaT(TTree *sel, TTree *asel,TTree *qcd,TTree *aqcd, TTree *ewk, TCut flow,TString point, TString type){
  TCut hi = flow && mu_pt_hi;
  TCut lo = flow && mu_pt_lo;

  if (type == "Data"){


 TH1D* s_at = GetHist("Data","AlphaT_Lep",flow,"(100,0.,1.)",sel);
 TH1D* as_at = GetHist("Data","AlphaT_Lep",flow,"(100,0.,1.)",asel);
  }
  else if (type != "Data"){



  
    TH1D* s_qcd = GetHist("S_QCD","AlphaT_Lep",flow,"(100,0.,1.)",qcd);
    //    TH1D* s_qcd_lo = GetHist("S_QCDlo","AlphaT_Lep",lo,"(100,0.,1.)",qcd);


    // s_qcd_lo->Scale(1.94);
    //s_qcd->Add(s_qcd_lo);


 


 TH1D* s_W= GetHist("S_W","AlphaT_Lep",flow,"(100,0.,1.)",stW);
 TH1D* s_tt = GetHist("S_tt","AlphaT_Lep",flow,"(100,0.,1.)",stTT);
TH1D* s_Z = GetHist("S_tt","AlphaT_Lep",flow,"(100,0.,1.)",stZ);

s_W->Scale(1.29557302);
s_tt->Scale(1.65789474);
 s_Z->Scale(3048./2400.);
 TH1D *s_ewk = (TH1D*)s_W->Clone();
 s_ewk->Add(s_Z);
 s_ewk->Add(s_tt);

 TH1D *s_at = (TH1D*)s_ewk->Clone();
 s_at->Add(s_qcd);

 TH1D* as_qcd = GetHist("AS_QCD","AlphaT_Lep",hi,"(100,0.,1.)",aqcd);
    TH1D* as_qcd_lo = GetHist("AS_QCDlo","AlphaT_Lep",lo,"(100,0.,1.)",aqcd);
    //cout << "qcdhi  " <<  as_qcd->Integral(56,as_qcd->GetNbinsX()) << " and below " << (as_qcd->Integral(0,55)) << endl;
    //cout << "qcdlo  " <<  as_qcd_lo->Integral(56,as_qcd->GetNbinsX()) << " and below " << (as_qcd_lo->Integral(0,55)) << endl;
 as_qcd_lo->Scale(1.94);
 //cout << "qcdlo after scaling " <<  as_qcd_lo->Integral(56,as_qcd->GetNbinsX()) << " and below " << (as_qcd_lo->Integral(0,55)) << endl;
 as_qcd->Add(as_qcd_lo);
 // cout << "qcd after adding  " <<  as_qcd->Integral(56,as_qcd->GetNbinsX()) << " and below " << (as_qcd->Integral(0,55)) << endl;
 TH1D* as_W= GetHist("AS_W","AlphaT_Lep",flow,"(100,0.,1.)",astW);
 TH1D* as_tt = GetHist("AS_tt","AlphaT_Lep",flow,"(100,0.,1.)",astTT);
TH1D* as_Z = GetHist("AS_tt","AlphaT_Lep",flow,"(100,0.,1.)",astZ);
as_W->Scale(1.29557302);
 as_tt->Scale(1.65789474);
 as_Z->Scale(3048./2400.);

 TH1D *as_ewk   = (TH1D*)as_W->Clone();
 as_ewk->Add(as_Z);
 as_ewk->Add(as_tt);

 TH1D *as_at= (TH1D*)as_ewk->Clone();
 as_at->Add(as_qcd);


  }


 /* cout << "Bin 0.47 = " << s_at->GetXaxis()->FindBin(0.47) << endl; */
 /* cout << "Bin center is = " << s_at->GetBinCenter(s_at->GetXaxis()->FindBin(0.47) ) << endl; */
 /* cout << "Next bin is = " << s_at->GetBinCenter(s_at->GetXaxis()->FindBin(0.56) ) << endl; */

  Double_t Ctrl_ratio = (as_at->Integral(hibinat,as_at->GetNbinsX()))/(as_at->Integral(0,lobinat));
  Double_t Ctrl_ratio_error=error(as_at->Integral(hibinat,as_at->GetNbinsX()),as_at->Integral(0,lobinat));
  Double_t Sig_below = s_at->Integral(0,lobinat);
  Double_t Sig_below_error = sqrt(s_at->Integral(0,lobinat));

 Double_t combinationA = ((Ctrl_ratio_error/Ctrl_ratio)*(Ctrl_ratio_error/Ctrl_ratio));
 Double_t combinationB = ((Sig_below_error/Sig_below)*(Sig_below_error/Sig_below));

 //cout << "after the scaling " << as_at->Integral(56,as_at->GetNbinsX()) << " and below " << (as_at->Integral(0,55)) << endl;
 


  Double_t Sig_above = Ctrl_ratio * Sig_below;

 Double_t  Sig_above_error = sqrt((Sig_above*Sig_above)*(combinationA + combinationB));
  Double_t Actual_Sig_above = s_at->Integral(hibinat,s_at->GetNbinsX());
  if (type != "Data"){
  Double_t Actual_sQCD_above = s_qcd->Integral(hibinat,s_qcd->GetNbinsX());
  Double_t Actual_sEWK_above =  s_ewk->Integral(hibinat,s_ewk->GetNbinsX());}

  //cout << endl;
  //cout.width(122); cout.fill('-'); cout << "\n";

  //cout << " The point at which this calculation is done is: " << point << endl;/
  //cout << endl;
 
  //   cout << " The ratio in the CTRL region is " << Ctrl_ratio << " +/- " << Ctrl_ratio_error << " and the number of events below aT 0.49 in SIG region is " << Sig_below << endl;
  //  cout << endl;
  //  cout << "Hence the number of predicted events in the SIG region with aT > 0.49 is " << Sig_above << " +/- "<< Sig_above_error << "  while the actual SM is " << Actual_Sig_above << " +/- " << sqrt(Actual_Sig_above) << endl;
  // cout << "BUT the actual QCD above in signal region is : " << Actual_sQCD_above << " +/= " << sqrt(Actual_sQCD_above) << " whereas EWK is : " << Actual_sEWK_above << "+/-" << sqrt(Actual_sEWK_above) << endl;

  // cout.width(122); cout.fill('-'); cout << "\n";
  // cout << endl;
  if (type =="Data"){
    cout.precision(4);
    cout << point + " the Upper bound on QCD predicted from "+lumi+" data is: " << Sig_above << " +/- " << Sig_above_error << endl;
 cout.precision(4);
    cout << point + " the  Actual events in "+lumi+" data is " << Actual_Sig_above << " +/- " << sqrt(Actual_Sig_above) << endl;
  cout << endl;
  }
  else{
    cout.precision(4);
    cout.width(11); cout << point; cout.width(2); cout << "|";
  cout.width(11); cout << Sig_above; cout.width(5); cout << "  +/-"; cout.width(10); cout << Sig_above_error; cout.width(2); cout << " |";
 cout.precision(4);
  cout.width(11); cout << Actual_Sig_above; cout.width(5); cout << "  +/-"; cout.width(10); cout << sqrt(Actual_Sig_above); cout.width(2); cout << " |";
 cout.precision(4);
  cout.width(10); cout << Actual_sQCD_above; cout.width(5); cout << "   +/-"; cout.width(7); cout << sqrt(Actual_sQCD_above); cout.width(2); cout << " |";
 cout.precision(4);
  cout.width(10); cout << Actual_sEWK_above; cout.width(5); cout << "  +/-"; cout.width(9); cout << sqrt(Actual_sEWK_above); cout.width(2); cout << "\n";
 cout.precision(4);


}
  //  cout.width (10); cout << Actual_Sig_above << " +/- " << sqrt(Actual_Sig_above) << "   | ";
  //cout.width (12); cout << Actual_sQCD_above << " +/- " << sqrt(Actual_sQCD_aove) << "     | ";
  // cout.width (9); cout << Actual_sEWK_above << " +/- " << sqrt(Actual_sEWK_above) << "\n";
  }
Example #4
0
void Plot(TString var,TCut cut,TString bins,Double_t xmax,TString cutpoint){
  setstyle(); 
 TH1::SetDefaultSumw2(true);
TCanvas *c2 = new TCanvas("canvas"+var+cutpoint,"canname"+var+cutpoint,800,800);
  TPad *mainPad = new TPad("","",0.01,0.25,0.99,0.99);
   mainPad->SetNumber(1);
   mainPad->Draw();
    TPad *ratioPad = new TPad("","",0.01,0.01,0.99,0.25);
   ratioPad->SetNumber(2);
   ratioPad->Draw();
c2->cd(1);
//   if (cutpoint == "noHT"){ TCut cut = numpj; TCut cutData = numpjData;}
//  else if (cutpoint == "HT200"){ TCut cut = HT200; TCut cutData = HT200Data; }//
//  else if (cutpoint == "anoHT"){ TCut cut = anumpj; TCut cutData = anumpjData;}
//  else if (cutpoint == "aHT200"){ TCut cut = aHT200; TCut cutData = aHT200Data; }
// else if (cutpoint == "HT300"){ TCut cut = HT300;  TCut cutData = HT300Data;}
// else if (cutpoint == "HT350"){ TCut cut = HT350; TCut cutData = HT350Data; }
//  else if (cutpoint == "aT"){ TCut cut = aT;  TCut cutData = aTData;}
//  else if (cutpoint == "early"){TCut cut = earlyaT; TCut cutData = earlyaTData;}

//else{cout << "ERRORRRR: BRaaaaaaaaaaaaaaaaaains" << endl; }
  TCut cutData = trig && hbhe && cut;
  TH1D* lm0 = GetHist("LM0",kRed,var,cut,bins,tLM0,cutpoint);
  ///  cout << "lm0" << endl;
  TH1D* lm1 = GetHist("LM1",kRed,var,cut,bins,tLM1,cutpoint);
  //  cout << "lm1" << endl;
  TH1D* qcd = GetHist("QCD_AllPtBins_7TeV_Pythia",kOrange+4,var,cut && mu_pt_hi,bins,tQCD,cutpoint);
  // cout << "qcd" << endl;
  TH1D* data = GetHist("Data",1,var,cutData,bins,tData,cutpoint);
  // cout << "data" << endl;
  TH1D* W = GetHist("Wjets_vols",kBlue,var,cut,bins,tW,cutpoint);
  //cout << "W" << endl;
  TH1D* tt = GetHist("ttbarTauola",kGreen,var,cut,bins,tTT,cutpoint);
  // cout << "tt" << endl;
  TH1D* Z = GetHist("ZJets_madgraph",kYellow,var,cut,bins,tZ,cutpoint);
  // cout << "Z" << endl;


  //TH1D* qcd_lo = GetHist("QCD_AllPtBins_7TeV_Pythia",kOrange+4,var,cut && mu_pt_lo,bins,tQCD,cutpoint);
 

  //   qcd_lo->Scale(1.94);
  // qcd->Add(qcd_lo);
 // TH1D* SM = GetHist("SM",kGray+2,var,cut,binstLM0,cutpoint);
 lm1->SetLineStyle(2);
 W->Scale(1.29557302);
 tt->Scale(1.65789474);
 Z->Scale(3048./2400.);

 TH1::SetDefaultSumw2(true);

 TH1D *SM   = (TH1D*)qcd->Clone();
 SM->Add(Z);
 SM->Add(tt);
 SM->Add(W);
 //SM->SetLineColor(kGray+2);
 // SM->SetFillStyle(3001);
 // SM->SetFillColor(kGray+2);
 // SM->SetMarkerSize(0.);
 //for(int bnum = 1; bnum <9; bnum++){
 //  if(data->GetBinContent(bnum)>0){
 // cout << "Bin Number " << bnum << " has qcd " << qcd->GetBinContent(bnum) << " and data " << data->GetBinContent(bnum) <<  " and SM " << SM->GetBinContent(bnum) <<  " and scale factor to QCD " << data->GetBinContent(bnum)/qcd->GetBinContent(bnum) << " and scale factor to SM " << data->GetBinContent(bnum)/SM->GetBinContent(bnum) << endl; 
 // }
 //  }
 c2->cd(1)->SetLogy();
 //  data->Draw("PE0");
 SM->Draw("E");
   THStack bkg("bkg","test stacked histograms");
   bkg.Add(Z);
   bkg.Add(tt);
   bkg.Add(W);
   bkg.Add(qcd);

   bkg.Draw("HIST0SAME");
   //  data->Draw("PE0SAME");
   
   
   //qcd->Draw("HIST0same");
   /*  
      W->Draw("HIST0same");
         Z->Draw("HIST0same");
       tt->Draw("HIST0same");
   */
    lm0->Draw("HIST0same"); lm0->SetLineColor(1); lm0->SetFillColor(0);
    lm1->Draw("HIST0same"); lm1->SetLineColor(1); lm1->SetFillColor(0); lm1->SetLineStyle(2);
	//  data->Draw("EPSAME");  
  if(xmax == 1337){
      double ymax=SM->GetMaximum()*12.6;}
  else{
    double ymax=SM->GetMaximum()*10.6;}
	SM->GetYaxis()->SetRangeUser(0.05,ymax);
	if (var=="AlphaT_Lep") { data->GetXaxis()->SetRangeUser(0.,xmax);}
	SM->GetXaxis()->SetTitle(var);
	SM->SetTitle();
  TLegend *leg = new TLegend(0.73803,0.591026,0.88137,0.880819);
  // leg->SetShadowColor(0);
  //leg->SetBorderSize(0);
  //leg->SetFillStyle(4100);
  leg->SetTextSize(0.04);
  leg->SetFillColor(0);
  leg->SetLineColor(0);
  
  // leg->AddEntry(data,"DATA","PL");
   leg->AddEntry(qcd,"QCD","FL");
  leg->AddEntry(W,"W","FL");
  leg->AddEntry(Z,"Z","FL");
  leg->AddEntry(tt,"TTbar","FL");
  leg->AddEntry(lm0,"LM0","FL");
  leg->AddEntry(lm1,"LM1","FL");
  
  //leg->AddEntry(SM,"SM BKGD","FL");
  leg->Draw("same");
  
   TLatex  *prelim = new TLatex(0.1152,0.81981,"CMS preliminary 2010");



  TLatex *lumi = new TLatex(0.1015,.9403,"#scale[0.8]{#int L dt = " +luminum+ "pb^{-1}, #sqrt{s} = 7 TeV}");
    prelim->SetNDC();
    lumi->SetNDC();
    //   prelim->Draw("same");
   lumi->Draw("same");

   TH1D *RatioBottom = (TH1D*)SM->Clone("Ratiob");
   TH1D *RatioTop = (TH1D*)data->Clone("Ratiot");
   RatioTop->GetYaxis()->SetTitle("data / sim");
 RatioTop->GetXaxis()->SetTitle();
      RatioTop->Divide(RatioBottom);

      c2->cd(2);
      gPad->SetGridx(); gPad->SetGridy();
   RatioTop->SetTitleSize(0.1, "XYZ");
    RatioTop->SetTitleOffset(0.55, "X");
    RatioTop->SetTitleOffset(0.3, "Y");
    RatioTop->SetLabelSize(0.06,"XY");
    RatioTop->GetYaxis()->SetRangeUser(-2.,4.0);
    RatioTop->Draw();
    RatioTop->GetYaxis()->SetLabelSize(0.05);
    TBox *unity = new TBox(RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetFirst()), 0.89,RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetLast()), 1.11);
    unity->SetLineWidth(2);
unity->SetLineColor(2);
    unity->SetFillColor(2);
    unity->SetFillStyle(3002);
    unity->Draw();

    c2->Update();
    if(cutpoint == "early"){
      c2->SaveAs(plots+erlee+"Muon_ND"+selec+var+"_"+cutpoint+".png");
    }
    else if (xmax == 90003){
      c2->SaveAs(plots+"Muon_ND"+selec+"_zooomed_"+var+"_"+cutpoint+".png");}
    else{
      c2->SaveAs(plots+"Muon_ND"+ptsec++selec+var+"_"+cutpoint+".png");}



 
       c2->Close();
}
Example #5
0
void pileup1(double dzmin, double dzmax)
{
  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h1 = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep"); 
  TH2D* h21 = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssec");
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");

  TH1D* htrk_max1 = h1->ProjectionX();
  h1->GetZaxis()->SetRange(h1->GetZaxis()->FindBin(dzmin),h1->GetZaxis()->FindBin(dzmax));
  h1->GetYaxis()->SetRange(h1->GetYaxis()->FindBin(2),h1->GetYaxis()->FindBin(50));
  TH2D* h2D1 = (TH2D*)h1->Project3DProfile("yx100");
  h2D1->Rebin2D(5,1);
  TProfile* hprof1_x = (TProfile*)h2D1->ProfileX("hprof1_x",-1,-1,"s");
  TH1D* h1D1 = (TH1D*)h2D1->ProjectionY("h1D1",13,15,"e");
/*
  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_PPRereco_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_PPRereco_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep");
  TH2D* h2 = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_PPRereco_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssec");
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_PPRereco_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");
*/

  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HydjetReco_Minbias_2760GeV/merged/HydjetReco_Minbias_2760GeV_PeripheralNew_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HydjetReco_Minbias_2760GeV/merged/HydjetReco_Minbias_2760GeV_PeripheralNew_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep");
  TH2D* h2 = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HydjetReco_Minbias_2760GeV/merged/HydjetReco_Minbias_2760GeV_PeripheralNew_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssec");
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HydjetReco_Minbias_2760GeV/merged/HydjetReco_Minbias_2760GeV_PeripheralNew_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");

/*
  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HijingReco_Minbias_2760GeV/merged/HijingReco_Minbias_2760GeV_53x_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HijingReco_Minbias_2760GeV/merged/HijingReco_Minbias_2760GeV_53x_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep");
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HijingReco_Minbias_2760GeV/merged/HijingReco_Minbias_2760GeV_53x_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");
*/
/*
  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep"); 
  TH2D* h2 = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssec");
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_MBNEW_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");
*/
/*
  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptSkim_INCLMULT220_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptSkim_INCLMULT220_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep"); 
  TH2D* h2 = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptSkim_INCLMULT220_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssec"); 
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptSkim_INCLMULT220_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");
*/
/*
  TH1D* hdz = (TH1D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptRecoNew_INCLMULT220PURej2sigmaMode1_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","xyzvtxsepmin");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptRecoNew_INCLMULT220PURej2sigmaMode1_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep"); 
  TH2D* h2 = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptRecoNew_INCLMULT220PURej2sigmaMode1_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssec"); 
  TH2D* hNvtxVsMult = (TH2D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptRecoNew_INCLMULT220PURej2sigmaMode1_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","nvtxvsnmult");
*/
  TH1D* htrk_max = h->ProjectionX();
  h->GetZaxis()->SetRange(h->GetZaxis()->FindBin(dzmin),h->GetZaxis()->FindBin(dzmax));
  h->GetYaxis()->SetRange(h->GetYaxis()->FindBin(2),h->GetYaxis()->FindBin(241));
//  h->Rebin3D(10,1);
  TH2D* h2D = (TH2D*)h->Project3DProfile("yx");
  h2D->Rebin2D(5,1);
  TProfile* hprof_x = (TProfile*)h2D->ProfileX("hprof_x",-1,-1,"s");
//  TH1D* h1D = (TH1D*)h2D->ProjectionY("h1D",h2D->GetXaxis()->FindBin(200),h2D->GetXaxis()->FindBin(220),"e");
  TH1D* h1D = (TH1D*)h2->ProjectionY("h1D",h2->GetXaxis()->FindBin(200),h2->GetXaxis()->FindBin(220),"e");
   
  double xx[1000];
  double yy[1000];
  for(int i=1;i<=hprof_x->GetNbinsX();i++)
  {
    yy[i-1] = hprof_x->GetBinContent(i)+2*hprof_x->GetBinError(i);
    xx[i-1] = hprof_x->GetBinCenter(i);
  }

  TGraph* xx_yy = new TGraph(hprof_x->GetNbinsX(),xx,yy);

  int ibin = hprof_x->GetXaxis()->FindBin(200);
/*
  TF1* func = new TF1("func","[0]+[1]*x",0,500);
  double par1 = (hprof_x->GetBinContent(ibin)+hprof_x->GetBinError(ibin)-hprof_x->GetBinContent(1)-hprof_x->GetBinError(1))/(hprof_x->GetBinCenter(ibin)-hprof_x->GetBinCenter(1));
  double par0 = hprof_x->GetBinContent(ibin)+hprof_x->GetBinError(ibin)-par1*hprof_x->GetBinCenter(ibin);
  func->SetParameters(par0,par1);
*/
//  TF1* func = new TF1("func","[0]+[1]*(x-[2])*(x-[2])",0,500);
//  func->SetParameters(30,-0.1,150);
  TF1* func = new TF1("func","[0]*x**[1]",0,500);
  func->SetParameters(0.1,0.5);
  func->SetParLimits(0,0,10000);
  func->SetParLimits(1,0,10000);
//  func->FixParameter(0,5); small dz
  func->FixParameter(0,2);
  xx_yy->Fit("func","NO","",10,400);

  TCanvas* cc6 = new TCanvas("cc6","cc6",550,500);
  TH2D* htmp = new TH2D("htmp",";N_{trk}^{primary};N_{trk}^{secondary}",500,0,500,50,0,50);
  htmp->Draw("");
  xx_yy->Draw("Psame");
  func->SetLineColor(2);
  func->Draw("Lsame");
  TLatex* latex = new TLatex();
  latex->SetNDC();
  latex->SetTextSize(latex->GetTextSize()*0.75);
  latex->DrawLatex(0.23,0.87,"PbPb HYDJET, 1<|dz|<2 cm");
//  SaveCanvas(cc6,"pPb/corr","NpriVsNsecProfile_2Sigma_hydjet_dz1020_ForAN");

  TCanvas* cc4 = new TCanvas("cc4","cc4",550,500);
  cc4->SetLogz();
  hNvtxVsMult->Rebin2D(10,1);
//  hNvtxVsMult->Scale(1.0/hNvtxVsMult->GetBinContent(0,0));
  hNvtxVsMult->SetAxisRange(1,5.9,"Y");
  hNvtxVsMult->SetAxisRange(0,280,"X");
  hNvtxVsMult->SetTitle(";N_{trk}^{offline};# of vertices");
  TProfile* hNvtxVsMult_prof = (TProfile*)hNvtxVsMult->ProfileX("hNvtxVsMult_prof",-1,-1,"s");
  hNvtxVsMult->Draw("colz");
//  hNvtxVsMult_prof->Draw("PEsame");
//  SaveCanvas(cc4,"pPb/corr","NvtxVsMult_PbPb2011_ForAN");

  TCanvas* cc5 = new TCanvas("cc5","cc5",550,500);
  TH1D* hNvtxVsMult_1D = hNvtxVsMult->ProjectionY("hNvtxVsMult_1D",23,23,"e");
  hNvtxVsMult_1D->Draw("PE");

//  TCanvas* cc3 = new TCanvas("cc3","cc3",550,500);
//  htrk_max->SetAxisRange(-1.5,1.5,"X");
//  htrk_max->Draw("PE");

  TCanvas* cc1 = new TCanvas("cc1","cc1",550,500);
  hdz->SetAxisRange(-1.5,1.5,"X");
  hdz->Draw("PE");
//  SaveCanvas(cc1,"pPb/corr","dz_pPbPURej3");

  TCanvas* c = new TCanvas("c","",580,500);
  c->SetLogz();
  c->SetRightMargin(0.14);

  h2D->SetTitle(";N_{trk}^{primary};N_{trk}^{secondary}");
  h2D->GetXaxis()->CenterTitle();
  h2D->GetYaxis()->CenterTitle();
  h2D->Draw("colz");
/*
  h2->SetAxisRange(2,241,"Y");
  h2->SetTitle(";N_{trk}^{primary};N_{trk}^{secondary}");
  h2->GetXaxis()->CenterTitle();
  h2->GetYaxis()->CenterTitle();
  h2->Draw("colz");
*/
  //hprof_x->Draw("PESAME");
//  func->Draw("Lsame");
  TLatex* latex = new TLatex();
  latex->SetNDC();
  latex->SetTextSize(latex->GetTextSize()*0.75);
//  latex->DrawLatex(0.23,0.87,"PbPb data 2011");
//  latex->DrawLatex(0.23,0.87,"PbPb HYDJET, 1<|dz|<2 cm");
  latex->DrawLatex(0.23,0.87,"HLT_PAPixelTracks_Multiplicity220");
  latex->DrawLatex(0.23,0.8,"1<|dz|<2 cm, pileup rejected");
//  latex->DrawLatex(0.23,0.87,"pPb pilot");
//  SaveCanvas(c,"pPb/corr","NpriVsNsec_NoPURej_pPbTrigger220_ForAN");
//  SaveCanvas(c,"pPb/corr","NpriVsNsec_NoPURej_PbPb2011_ForAN");
//  SaveCanvas(c,"pPb/corr","NpriVsNsec_NoPURej_hydjet_ForAN_dz1020");
//  SaveCanvas(c,"pPb/corr","NpriVsNsec_PURej_pPbTrigger220_dz1020_ForAN");

  TCanvas* cc = new TCanvas("cc","",550,500);
  cc->SetLogy();
  h1D->SetTitle("");
  h1D->SetXTitle("N_{trk}^{secondary}");
  h1D->GetXaxis()->CenterTitle();
  h1D->Scale(1.0/h1D->Integral());
  htrk_max1->Scale(1.0/htrk_max1->Integral());
  htrk_max1->SetMarkerStyle(24);
  h1D->SetAxisRange(0,50,"X");
  h1D->Draw("PE");
  htrk_max1->Draw("PESAME");
  TLine* l_2sigma = new TLine(h1D->GetMean()+h1D->GetRMS()*2,0,h1D->GetMean()+h1D->GetRMS()*2,0.04);
  l_2sigma->SetLineWidth(3);
  l_2sigma->SetLineColor(2);
  l_2sigma->Draw("Lsame");
  TLatex* latex = new TLatex();
  latex->SetTextColor(2);
  latex->SetTextSize(latex->GetTextSize()*0.75);
  latex->DrawLatex(h1D->GetMean()+h1D->GetRMS()*2*0.7,0.053,"Mean+2#timesRMS");

  TLine* l_1sigma = new TLine(h1D->GetMean()+h1D->GetRMS()*1,0,h1D->GetMean()+h1D->GetRMS()*1,0.1);
  l_1sigma->SetLineWidth(3);
  l_1sigma->SetLineStyle(9);
  l_1sigma->SetLineColor(4);
  l_1sigma->Draw("Lsame");
  TLatex* latex = new TLatex();
  latex->SetTextColor(4);
  latex->SetTextSize(latex->GetTextSize()*0.75);
  latex->DrawLatex(h1D->GetMean()+h1D->GetRMS()*0.4,0.123,"Mean+1#timesRMS");

  TLatex* latex = new TLatex();
  latex->SetTextColor(1);
  latex->SetNDC();
  latex->SetTextSize(latex->GetTextSize()*0.75);
  latex->DrawLatex(0.65,0.85,"200<N_{trk}^{primary}<220");
  SaveCanvas(cc,"pPb/corr","NsecDist_PUestimate");

  TLegend* legend = new TLegend(0.4,0.58,0.9,0.68);
  legend->SetFillColor(0);
  legend->SetFillStyle(0);
  legend->AddEntry(h1D,"N_{trk}^{secondary} from PbPb Hydjet","P");
  legend->AddEntry(htrk_max1,"N_{trk}^{primary} from pPb pilot","P");
  legend->Draw();

  TH1D* hhh = new TH1D("hhh",";N_{trk}^{primary};Residual pileup (%)",25,0,500);
  for(int i=1;i<=hhh->GetNbinsX();i++)
  {
    TH1D* h1Dtmp = (TH1D*)h2->ProjectionY("h1Dtmp",h2->GetXaxis()->FindBin((i-1)*20),h2->GetXaxis()->FindBin(i*20),"e");
    double frac = htrk_max1->Integral(1,htrk_max1->FindBin(h1Dtmp->GetMean()+h1Dtmp->GetRMS()*2))*3.0;
    hhh->SetBinContent(i,frac);
  }
  TCanvas* cc4 = new TCanvas("cc4","",550,500);
  hhh->GetXaxis()->CenterTitle();
  hhh->GetYaxis()->CenterTitle();
  hhh->GetYaxis()->SetTitleOffset(hhh->GetYaxis()->GetTitleOffset()*1.3);
  hhh->Draw("hist");
  TLatex* latex = new TLatex();
  latex->SetTextColor(1);
  latex->SetNDC();
  latex->SetTextSize(latex->GetTextSize()*0.75);
  latex->DrawLatex(0.25,0.85,"Mean+2#timesRMS cut");
  SaveCanvas(cc4,"pPb/corr","ResidualPUvsNtrkpri");
}
Example #6
0
void pileup()
{
//  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_PPRereco_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep");
  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HydjetReco_Minbias_2760GeV/merged/HydjetReco_Minbias_2760GeV_PeripheralNew_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep");
//  TH3D* h = (TH3D*)GetHist("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/PAData_Minbias_5TeV/merged/PAData_Minbias_5TeV_HM_PromptReco_INCLMULTAllPURej3Vtx_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root","multmaxvssecvszvtxsep");

  TF1* func[40];
  TGraph* xx_yy[40];
  double par0_arr[40];
  double par1_arr[40];
  double par2_arr[40];
  double dz_arr[40];
//  double binwidth=0.2;
  double binedges[16]={0.0,0.2,0.3,0.4,0.5,0.6,0.8,1.0,1.4,1.8,2.4,3.0,4.2,5.0,7.0,10.0};

  TCanvas* c16 = new TCanvas("c16","c16",800,600);
  c16->Divide(4,4);

  for(int i=0;i<15;i++)
  {
//    h->GetZaxis()->SetRange(h->GetZaxis()->FindBin(binwidth*i),h->GetZaxis()->FindBin(binwidth*i+binwidth));
    h->GetZaxis()->SetRange(h->GetZaxis()->FindBin(binedges[i]),h->GetZaxis()->FindBin(binedges[i+1]));
    h->GetYaxis()->SetRange(h->GetYaxis()->FindBin(2),h->GetYaxis()->FindBin(50));
    TH2D* h2D = (TH2D*)h->Project3DProfile(Form("yx%d",i));
    h2D->Rebin2D(10,1);
    TProfile* hprof_x = (TProfile*)h2D->ProfileX("hprof_x",-1,-1,"s");
    double xx[500];
    double yy[500];
    for(int ibin=1;ibin<=hprof_x->GetNbinsX();ibin++)
    {
      yy[ibin-1] = hprof_x->GetBinContent(ibin)+2*hprof_x->GetBinError(ibin);
      xx[ibin-1] = hprof_x->GetBinCenter(ibin);
    }
  
// Hydjet
//    TF1* func = new TF1("func","[0]+[1]*(x-[2])*(x-[2])",0,500);
//    func->SetParameters(20,-0.1,150);
  func[i] = new TF1(Form("func_%d",i),"[0]*x**[1]",0,500);
  func[i]->SetParameters(1,0.5);
  func[i]->SetParLimits(0,0,10000);
  func[i]->SetParLimits(1,0,10000);
  if(i==0) func[i]->FixParameter(0,8); //pPb
//  else if(i>11) func[i]->FixParameter(0,20); //pPb
  else func[i]->FixParameter(0,2.); //pPb

//  func->FixParameter(0,5); //PbPb

//    TF1* func = new TF1("func","[0]+[1]*x",40,500);
//    double par1 = (hprof_x->GetBinContent(6)+hprof_x->GetBinError(6)-hprof_x->GetBinContent(1)-hprof_x->GetBinError(1))/(hprof_x->GetBinCenter(6)-hprof_x->GetBinCenter(1));
//    double par0 = hprof_x->GetBinContent(6)+hprof_x->GetBinError(6)-par1*hprof_x->GetBinCenter(6);
//    func->SetParameters(par0,par1);

    xx_yy[i] = new TGraph(hprof_x->GetNbinsX(),xx,yy);
    xx_yy[i]->Fit(Form("func_%d",i),"NO","",0,300);

    c16->cd(i+1);
    xx_yy[i]->Draw("AP"); 
    func[i]->SetLineColor(kRed);
    func[i]->Draw("Lsame");   

    par2_arr[i] = func[i]->GetParameter(2);    
    par1_arr[i] = func[i]->GetParameter(1);
    par0_arr[i] = func[i]->GetParameter(0);
    dz_arr[i] = (binedges[i]+binedges[i+1])/2;
  }

  TGraph* gr_par0 = new TGraph(15,dz_arr,par0_arr);
  TGraph* gr_par1 = new TGraph(15,dz_arr,par1_arr);
  TGraph* gr_par2 = new TGraph(15,dz_arr,par2_arr);

  TCanvas* cc = new TCanvas("cc","",950,400);  
  cc->Divide(3,1);
  cc->cd(1);
  gr_par0->Draw("AP");
  TF1* func_par0 = new TF1("func_par0","[2]*exp(-x**2/[0])*x**[3]+[1]",0.0,10.0);
  func_par0->SetParameters(0.2,0,5,-1);
  func_par0->FixParameter(2,0);
  gr_par0->Fit("func_par0","NO","",0.3,4.0);
  func_par0->Draw("Lsame");
  cc->cd(2);
  gr_par1->Draw("AP");
//  TF1* func_par1 = new TF1("func_par1","[2]*exp(-x**2/[0])*x**[3]+[1]",0.,10.0);
//  func_par1->SetParameters(0.2,0,-0.0005,0);
//  TF1* func_par1 = new TF1("func_par1","[2]*exp(-x/[0])*x**[3]+[1]",0.,10.0);
  TF1* func_par1 = new TF1("func_par1","[1]*exp(-x**[2]/[0])*x**[3]",0.,10.0);
  func_par1->SetParameters(0.1,0.6,2,1);
//  func_par1->FixParameter(2,1);
//  func_par1->FixParameter(3,1);

  gr_par1->Fit("func_par1","NO","",0.3,4.0);
  func_par1->Draw("Lsame");
  cc->cd(3);
  gr_par2->Draw("AP"); 
  TF1* func_par2 = new TF1("func_par2","[2]*exp(-x**2/[0])*x**[3]+[1]",0.,10.0);
  func_par2->SetParameters(1.2,170,120,1);
  gr_par2->Fit("func_par2","NO","",0.2,2.0);
  func_par2->Draw("Lsame");

cout<<Form("par0=%.2f*exp(-x**2/%.2f)*(x**%.2f)+%.2f",func_par0->GetParameter(2),func_par0->GetParameter(0),func_par0->GetParameter(3),func_par0->GetParameter(1))<<endl;
cout<<Form("par1=%.6f*exp(-x/%.6f)*(x**%.6f)+%.2f",func_par1->GetParameter(2),func_par1->GetParameter(0),func_par1->GetParameter(3),func_par1->GetParameter(1))<<endl;
cout<<Form("par2=%.2f*exp(-x**2/%.2f)*(x**%.2f)+%.2f",func_par2->GetParameter(2),func_par2->GetParameter(0),func_par2->GetParameter(3),func_par2->GetParameter(1))<<endl;

//  TF2* func2D = new TF2("func2D","[2]*exp(-x**2/[0])*x**[3]+[1]+([6]*exp(-x**2/[7])*x**[3]+[5])*y",0,1.0,0,500);
//  TF2* func2D = new TF2("func2D","[2]*exp(-x**2/[0])*x**[3]+[1]+([6]*exp(-x/[4])*x**[7]+[5])*(y-[10]*exp(-x**2/[8])*x**[11]-[9])*(y-[10]*exp(-x**2/[8])*x**[11]-[9])",0,5.0,0,500);
//  TF2* func2D = new TF2("func2D","([2]*exp(-x**2/[0])*x**[3]+[1])*y**[4]",0,10.0,0,500);
  TF2* func2D = new TF2("func2D","[0]*y**([2]*exp(-x**[3]/[1])*x**[4])",0,10.0,0,500);
  func2D->SetParameter(0,func_par0->GetParameter(1));
  func2D->SetParameter(1,func_par1->GetParameter(0));
  func2D->SetParameter(2,func_par1->GetParameter(1));
  func2D->SetParameter(3,func_par1->GetParameter(2));
  func2D->SetParameter(4,func_par1->GetParameter(3));
/*
  func2D->SetParameter(0,func_par0->GetParameter(0));
  func2D->SetParameter(1,func_par0->GetParameter(1));
  func2D->SetParameter(2,func_par0->GetParameter(2));
  func2D->SetParameter(3,func_par0->GetParameter(3));
  func2D->SetParameter(4,func_par1->GetParameter(0));
  func2D->SetParameter(5,func_par1->GetParameter(1));
  func2D->SetParameter(6,func_par1->GetParameter(2));
  func2D->SetParameter(7,func_par1->GetParameter(3));
  func2D->SetParameter(8,func_par2->GetParameter(0));
  func2D->SetParameter(9,func_par2->GetParameter(1));
  func2D->SetParameter(10,func_par2->GetParameter(2));
  func2D->SetParameter(11,func_par2->GetParameter(3));
*/
/*
cout<<Form("%.6f, %.6f, %.6f, %.6f,",func_par0->GetParameter(0),func_par0->GetParameter(1),func_par0->GetParameter(2),func_par0->GetParameter(3))<<endl;
cout<<Form("%.6f, %.6f, %.6f, %.6f,",func_par1->GetParameter(0),func_par1->GetParameter(1),func_par1->GetParameter(2),func_par1->GetParameter(3))<<endl;
cout<<Form("%.6f, %.6f, %.6f, %.6f,",func_par2->GetParameter(0),func_par2->GetParameter(1),func_par2->GetParameter(2),func_par2->GetParameter(3))<<endl;
*/
cout<<Form("%.6f, %.6f, %.6f, %.6f, %.6f,",func2D->GetParameter(0),func2D->GetParameter(1),func2D->GetParameter(2),func2D->GetParameter(3),func2D->GetParameter(4))<<endl;
cout<<Form("%.6f, %.6f",func[0]->GetParameter(0),func[0]->GetParameter(1))<<endl;

  TH2D* h_pileup = new TH2D("distfunc",";d (cm);N_{trk}^{primary};N_{trk}^{secondary}",500,0,50.0,50,0,500);

  for(int i=1;i<=h_pileup->GetNbinsX();i++) 
    for(int j=1;j<=h_pileup->GetNbinsY();j++)
    {

//      if(h_pileup->GetYaxis()->GetBinCenter(j)<func2D->Eval(h_pileup->GetXaxis()->GetBinCenter(i),h_pileup->GetYaxis()->GetBinCenter(j))) h_pileup->SetBinContent(i,j,h_pileup->GetYaxis()->GetBinCenter(j));
//      else if(h_pileup->GetXaxis()->GetBinCenter(i)<0.2) h_pileup->SetBinContent(i,j,func2D->Eval(0.2,h_pileup->GetYaxis()->GetBinCenter(j)));
//      else h_pileup->SetBinContent(i,j,func2D->Eval(h_pileup->GetXaxis()->GetBinCenter(i),h_pileup->GetYaxis()->GetBinCenter(j)));
      if(h_pileup->GetXaxis()->GetBinCenter(i)<0.2) h_pileup->SetBinContent(i,j,func[0]->Eval(h_pileup->GetYaxis()->GetBinCenter(j)));
      else h_pileup->SetBinContent(i,j,func2D->Eval(h_pileup->GetXaxis()->GetBinCenter(i),h_pileup->GetYaxis()->GetBinCenter(j)));
    }

/*
  for(int i=1;i<=h_pileup->GetNbinsX();i++) 
    for(int j=1;j<=h_pileup->GetNbinsY();j++)
    {
      for(int k=0;k<15;k++) 
      {
        if(h_pileup->GetXaxis()->GetBinCenter(i)>binedges[k] && h_pileup->GetXaxis()->GetBinCenter(i)<binedges[k+1]) h_pileup->SetBinContent(i,j,func[k]->Eval(h_pileup->GetYaxis()->GetBinCenter(j)));
      }
    }
*/

  TCanvas* c2D = new TCanvas("c2D","",550,500);
  c2D->SetPhi(-60);
  c2D->SetTheta(50);
  h_pileup->SetAxisRange(0,3.0,"X");
  h_pileup->GetXaxis()->CenterTitle();
  h_pileup->GetYaxis()->CenterTitle();
  h_pileup->GetZaxis()->CenterTitle();
  h_pileup->Draw("surf1"); 
  SaveCanvas(c2D,"pPb/corr","pileup_distfunc_hydjet");
return;
  TFile* fout = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/pileup_distfunc_pPb_1sigma_mode1.root","recreate");
  h_pileup->Write();
  fout->Close();
}
Example #7
0
void Fourier()
{
/*
  TString dataname = "HIData_Minbias_2760GeV";
  TString datatag = "PPRereco_INCLEFF1v4";
*/
  TString dataname = "PAData_Minbias_5TeV";
  TString datatag = "HM_Express_INCLEFF1v5";
//  TString datatag = "MB_INCLEFF1v4";

  int nmin=220;
  int nmax=260;
  const int ntrgptbins=11;
  const int nassptbins=11;

  TH1D ***hdata = compare_flow_pp_phi_multipad_pt<TH1D**>(dataname.Data(),datatag.Data(),nmin,nmax,-1,-1,2.0,4.0,ntrgptbins,nassptbins,-2.4,2.4,-2.4,2.4);
  TH1D* hdata_zyam[ntrgptbins][nassptbins];
  TF1* fitfunc_vn[ntrgptbins][nassptbins];

  for(int itrg = 0; itrg<ntrgptbins; itrg++)
  {
    for(int jass = 0; jass<nassptbins; jass++)
    {
      fitfunc_vn[itrg][jass] = FitVnFunc(hdata[itrg][jass]);
    }
  }

  int bin_ref=1;
  double V2_ref = fitfunc_vn[bin_ref][bin_ref]->GetParameter(2);
  double V3_ref = fitfunc_vn[bin_ref][bin_ref]->GetParameter(3);
  double V2_ref_err = fitfunc_vn[bin_ref][bin_ref]->GetParError(2);
  double V3_ref_err = fitfunc_vn[bin_ref][bin_ref]->GetParError(3);

  double v2[ntrgptbins];
  double v3[ntrgptbins];
  double v2_err[ntrgptbins];
  double v3_err[ntrgptbins];
  double pttrg[ntrgptbins] = {0.0};
  double pttrg_err[ntrgptbins] = {0.0};

  TH1D* hpt[ntrgptbins];
  for(int itrg = 0; itrg<ntrgptbins; itrg++)
  {
    TString filename = Form("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/%s/merged/%s_%s_nmin%d_nmax%d_etatrg%.1f-%.1f_etaass%.1f-%.1f_centmin%d_centmax%d.root",dataname.Data(),dataname.Data(),datatag.Data(),nmin,nmax,-1,-1,-2.4,2.4,-2.4,2.4);    
    hpt[itrg] = (TH1D*)GetHist(filename,Form("ptcorr_signal_trg_%d",itrg));
    pttrg[itrg] = hpt[itrg]->GetMean();
  }

  for(int itrg = 0; itrg<ntrgptbins; itrg++)
  {
    v2[itrg] = fitfunc_vn[itrg][bin_ref]->GetParameter(2)/sqrt(fabs(V2_ref));
    v3[itrg] = fitfunc_vn[itrg][bin_ref]->GetParameter(3)/sqrt(fabs(V3_ref));
    v2_err[itrg] = fitfunc_vn[itrg][bin_ref]->GetParError(2)/fitfunc_vn[itrg][bin_ref]->GetParameter(2)*v2[itrg];
    v3_err[itrg] = fitfunc_vn[itrg][bin_ref]->GetParError(3)/fitfunc_vn[itrg][bin_ref]->GetParameter(3)*v3[itrg];
  }

  ofstream fcout(Form("data/%s_%s_nmin%d_nmax%d_centmin%d_centmax%d_ptass%d.txt",dataname.Data(),datatag.Data(),nmin,nmax,-1,-1,bin_ref));
  fcout << "pT    v_2    v_2 err." << endl;
  for(int itrg = 0; itrg<ntrgptbins; itrg++) fcout << pttrg[itrg] << " "<< v2[itrg] << " " << v2_err[itrg] <<endl;
  fcout<<endl<<endl;
  fcout << "pT    v_3    v_3 err." << endl;
  for(int itrg = 0; itrg<ntrgptbins; itrg++) fcout << pttrg[itrg] << " "<< v3[itrg] << " " << v3_err[itrg] <<endl;
  fcout<<endl<<endl;

  TGraphErrors* g_v2 = new TGraphErrors(ntrgptbins,pttrg,v2,pttrg_err,v2_err);
  TGraphErrors* g_v3 = new TGraphErrors(ntrgptbins,pttrg,v3,pttrg_err,v3_err);
  g_v3->SetMarkerStyle(24);

  TCanvas* cv = new TCanvas("cv","cv",600,550);
  TH2D* hdummy = new TH2D("dummy",";p_{T} (GeV/c);v_{2}",100,0,12.0,100,0,0.25);
  hdummy->Draw();
  g_v2->Draw("PESAME");
  g_v3->Draw("PESAME");
}
Example #8
0
void control(TString var,TString bin, TCut cuts, TCut cutsA, TString cutpoint,bool log,Double_t ymax){
setstyle();
 TH1::SetDefaultSumw2(true);
TCanvas *c2 = new TCanvas("canvas"+var+cutpoint,"canname"+var+cutpoint,700,800);

  TPad *mainPad = new TPad("","",0.01,0.25,0.99,0.99);
   mainPad->SetNumber(1);
   mainPad->Draw();
    TPad *ratioPad = new TPad("","",0.01,0.01,0.99,0.25);
   ratioPad->SetNumber(2);
   ratioPad->Draw();
 c2->cd(1);

 TCut lo = cuts && mu_pt_lo;
 TCut hi = cuts && mu_pt_hi;

 // TH1D *Ctrl_lo = GetHist("AS",kBlack,var,lo,bin,astQCD,cutpoint);
 // TH1D *Sig_lo = GetHist("S",kRed,var,lo,bin,stQCD,cutpoint);
  TH1D *Ctrl_hi = GetHist("AS",kBlack,var,cuts,bin,astQCD,cutpoint);
  TH1D *Sig_hi = GetHist("S",kRed,var,cuts,bin,stQCD,cutpoint);
  //  Ctrl_lo->Scale(1.94);
  //  Sig_lo->Scale(1.94);
  TH1D *Ctrl = Ctrl_hi->Clone();
  TH1D *Sig = Sig_hi->Clone();
  //  Ctrl->Add(Ctrl_hi);
  // Sig->Add(Sig_hi);

  Sig->Scale(intlumi);
  // TH1D *Ctrl = GetHist("AS",kBlack,var,cuts,bin,astQCD,cutpoint);
  if(Ctrl->Integral()!=0){
  Ctrl->Scale(Sig->Integral()/Ctrl->Integral());
  }
  
  if(log){ c2->cd(1)->SetLogy();}
  
 TLegend *leg = new TLegend(0.564,0.719,0.775,0.875);
 leg->SetTextSize(0.054);
  leg->SetFillColor(0);
  leg->SetLineColor(0);
  //  leg->AddEntry(Ctrl,"Anti-Selected","LF");
  leg->AddEntry(Sig,"Selected","LF");
    leg->AddEntry(Ctrl,"Anti-Selected","LF");

  Ctrl->Draw("EHIST9");
  Sig->Draw("E9same");

  Sig->SetMarkerStyle(20); Sig->SetMarkerColor(kRed);
  leg->Draw("same");
  Ctrl->SetTitle();
  Ctrl->GetXaxis()->SetTitle(var);
  if(log){
  Ctrl->GetYaxis()->SetRangeUser(0.001,ymax);
  }
  else{
    ymax=(Ctrl->GetMaximum()*1.6);
     Ctrl->GetYaxis()->SetRangeUser(0.,ymax);
  }
   TH1D *RatioBottom = (TH1D*)Ctrl->Clone("Ratiob");
   TH1D *RatioTop = (TH1D*)Sig->Clone("Ratiot");

  RatioTop->GetYaxis()->SetTitle("Selected / Anti-Selected");
 RatioTop->GetXaxis()->SetTitle();
 RatioTop->SetTitle();
      RatioTop->Divide(RatioBottom);

      c2->cd(2);
  gPad->SetGridx(); gPad->SetGridy();
   RatioTop->SetTitleSize(0.1, "XYZ");
    RatioTop->SetTitleOffset(0.55, "X");
    RatioTop->SetTitleOffset(0.3, "Y");
    RatioTop->SetLabelSize(0.06,"XY");
    RatioTop->GetYaxis()->SetRangeUser(-2.,5.0);
    RatioTop->SetLineColor(kBlack);
    RatioTop->Draw();
  TBox *unity = new TBox(RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetFirst()), 0.79,RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetLast()), 1.21);
			   unity->SetLineWidth(2);
unity->SetLineColor(2);
    unity->SetFillColor(2);
			   unity->SetFillStyle(3002);
			   unity->Draw();
  c2->Update();
  c2->SaveAs(plots+"SAS_Muon_10to25"+var+"_"+cutpoint+".png");
  // c2->Close();
}