Beispiel #1
0
void drawPaPt(){
  
  TCanvas* c1 = new TCanvas("c1","",500,500);
 
  TFile* f1 = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr40_to_50_jetPtThr30_20130906.root");
  TH1D* hd1 = (TH1D*)f1->Get("jetPt_icent1_final");
  TFile* f2 = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr50_to_60_jetPtThr30_20130906.root");
  TH1D* hd2 = (TH1D*)f2->Get("jetPt_icent1_final");
  TFile* f3 = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr60_to_80_jetPtThr30_20130906.root");
  TH1D* hd3 = (TH1D*)f3->Get("jetPt_icent1_final");
  TFile* f4 = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr80_to_9999_jetPtThr30_20130906.root");
  TH1D* hd4 = (TH1D*)f4->Get("jetPt_icent1_final");

  TFile* f1m = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbMC_output_photonPtThr40_to_50_jetPtThr30_20130906.root");
  TH1D* hm1 = (TH1D*)f1m->Get("jetPt_icent1_final");
  TFile* f2m = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbMC_output_photonPtThr50_to_60_jetPtThr30_20130906.root");
  TH1D* hm2 = (TH1D*)f2m->Get("jetPt_icent1_final");
  TFile* f3m = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbMC_output_photonPtThr60_to_80_jetPtThr30_20130906.root");
  TH1D* hm3 = (TH1D*)f3m->Get("jetPt_icent1_final");
  TFile* f4m = new TFile("/home/jazzitup/analysis/photonJetAnalysis2013/histogramProducer/ffFiles/photonTrackCorr_ppbMC_output_photonPtThr80_to_9999_jetPtThr30_20130906.root");
  TH1D* hm4 = (TH1D*)f4m->Get("jetPt_icent1_final");

  double ptBinPaDraw[5] = { 40.5 ,49.5, 58.5,  76.5,  123. } ;
  TH1D* hd = new TH1D("ptmeanDAta",";p_{T}^{#gamma}; <p_{T}^{Jet}>",4,ptBinPaDraw);
  hd->SetBinContent(1, hd1->GetMean());
  hd->SetBinContent(2, hd2->GetMean());
  hd->SetBinContent(3, hd3->GetMean());
  hd->SetBinContent(4, hd4->GetMean());
  hd->SetBinError(1, hd1->GetMeanError());
  hd->SetBinError(2, hd2->GetMeanError());
  hd->SetBinError(3, hd3->GetMeanError());
  hd->SetBinError(4, hd4->GetMeanError());

  TH1D* hm = new TH1D("ptmeanDAta",";p_{T}^{#gamma}; <p_{T}^{Jet}>",4,ptBinPaDraw);
  hm->SetBinContent(1, hm1->GetMean());
  hm->SetBinContent(2, hm2->GetMean());
  hm->SetBinContent(3, hm3->GetMean());
  hm->SetBinContent(4, hm4->GetMean());
  hm->SetBinError(1, hm1->GetMeanError());
  hm->SetBinError(2, hm2->GetMeanError());
  hm->SetBinError(3, hm3->GetMeanError());
  hm->SetBinError(4, hm4->GetMeanError());



  handsomeTH1(hd,2);
  handsomeTH1(hm,1);
  hm->SetMarkerStyle(24);
  hd->SetAxisRange(30,95,"Y");
  hm->SetAxisRange(30,95,"Y");
  hm->Draw();
  hd->Draw("same");
  TLegend *l1 = new TLegend(0.2399194,0.7288136,0.7862903,0.9322034,NULL,"brNDC");
  easyLeg(l1,"5.02TeV pPb MinBias");
  l1->AddEntry(hd, "DATA","p");
  l1->AddEntry(hm, "MC","p");
  l1->Draw();

  c1->SaveAs("pT_dependence_jetPt_ppb.pdf");
}
Beispiel #2
0
TH2D* GetJetCorrFunc2D_doublegaussian(int itrg, int jass)
{
                    TH2D* hcorr = (TH2D*)GetRawCorrFunc2D_ratio(itrg,jass);
                    TH2D* hcorr_clone = (TH2D*)hcorr->Clone(Form("corr_clone_itrg%d_jass%d",itrg,jass));
                    hcorr_clone->Reset();
		    for(int ietabin=1;ietabin<=hcorr->GetNbinsX();ietabin++)
		    {
                      TH1D* hcorrphi = (TH1D*)hcorr->ProjectionY(Form("corrphi_%d",ietabin),ietabin,ietabin,"e");  
                      float min = hcorrphi->GetMinimum();
                      hcorrphi->SetAxisRange(-1,1,"X");
                      float nearmax = hcorrphi->GetMaximum();
                      hcorrphi->SetAxisRange(PI-1,PI+1,"X");
                      float awaymax = hcorrphi->GetMaximum();

		      TF1* fitfunc = new TF1("fitfunc",doubleGaussian,-PI/2.,3.*PI/2.,5);		    
                      fitfunc->SetParameters(min,nearmax-min,0.3,awaymax-min,0.5);  
                      fitfunc->SetParLimits(0,0,100000);
                      fitfunc->SetParLimits(1,0,100000);
                      fitfunc->SetParLimits(2,0,100000);
                      fitfunc->SetParLimits(3,0,100000);
                      fitfunc->SetParLimits(4,0,100000);		    
		      for(int ifit=0;ifit<3;ifit++) hcorrphi->Fit(Form("fitfunc_%d",ietabin),"RNO");                     
		      float level = fitfunc->GetParameter(0);

		      for(int iphibin=1;iphibin<=hcorr->GetNbinsY();iphibin++) 
                        hcorr_clone->SetBinContent(ietabin,iphibin,hcorr->GetBinContent(ietabin,iphibin)-level);                      
                      delete fitfunc;
		    }

                    float max = hcorr_clone->GetBinContent(hcorr_clone->GetMaximumBin());
                    hcorr_clone->SetAxisRange(ymin,max*1.3,"Z");
                    return hcorr_clone;
}
void drawDum(float min, float max, double drawXLabel){

   TH1D *hdum = new  TH1D("h","",10,120,220);
  hdum->SetMaximum(max);

  hdum->SetStats(0);

  if(drawXLabel) hdum->SetXTitle("(p_{T}^{j1}-p_{T}^{j2})/(p_{T}^{j1}+p_{T}^{j2})");
  hdum->GetXaxis()->SetLabelSize(20);
  hdum->GetXaxis()->SetLabelFont(43);
  hdum->GetXaxis()->SetTitleSize(22);
  hdum->GetXaxis()->SetTitleFont(43);
  hdum->GetXaxis()->SetTitleOffset(1.5);
  hdum->GetXaxis()->CenterTitle();

  hdum->GetXaxis()->SetNdivisions(905,true);

  hdum->SetYTitle("Event Fraction");

  hdum->GetYaxis()->SetLabelSize(20);
  hdum->GetYaxis()->SetLabelFont(43);
  hdum->GetYaxis()->SetTitleSize(20);
  hdum->GetYaxis()->SetTitleFont(43);
  hdum->GetYaxis()->SetTitleOffset(2.5);
  hdum->GetYaxis()->CenterTitle();

  hdum->SetAxisRange(0,0.2,"Y");

  hdum->Draw("");

}
//__________________________________________________________________________
void drawDum(float min, float max, double drawXLabel)
{

  TH1D *hdum = new TH1D("hdum","",20,0,1);
  hdum->SetMaximum(max);

  hdum->SetStats(0);

  if(drawXLabel) hdum->SetXTitle("A_{J} = (E_{T}^{j1}-E_{T}^{j2})/(E_{T}^{j1}+E_{T}^{j2})");
  hdum->GetXaxis()->SetLabelSize(20);
  hdum->GetXaxis()->SetLabelFont(43);
  hdum->GetXaxis()->SetTitleSize(22);
  hdum->GetXaxis()->SetTitleFont(43);
  hdum->GetXaxis()->SetTitleOffset(1.5);
  hdum->GetXaxis()->CenterTitle();

  hdum->GetXaxis()->SetNdivisions(905,true);

  hdum->SetYTitle("Ratio");

  hdum->GetYaxis()->SetLabelSize(20);
  hdum->GetYaxis()->SetLabelFont(43);
  hdum->GetYaxis()->SetTitleSize(20);
  hdum->GetYaxis()->SetTitleFont(43);
  hdum->GetYaxis()->SetTitleOffset(2.5);
  hdum->GetYaxis()->CenterTitle();

  hdum->SetAxisRange(0,0.2,"Y");

  hdum->Draw("");

}
Beispiel #5
0
void loglikdistrib(Int_t ntrials = 10000, Bool_t print = kFALSE)
{
  // compute distribution of log likelihood value
  TH1D * hmc   = gStack[gPadNr][gOrder[gPadNr][0]];
  TH1D * hdata = gStack[gPadNr][gMaxProcess-1];
  Int_t nbins = hmc->GetNbinsX();
  Double_t loglik = loglikelihood(hmc, hdata, 1, nbins);
  TH1D * htest = new TH1D(*hdata);
  TH1D * lldistrib = new TH1D("lldistrib", "log(Likelihood) distribution", 
			      1000, loglik-200, loglik+200);
  setopt(lldistrib);
  for (Int_t n = 0; n < ntrials; n++) {
    // generate poisson around theorie
    for (Int_t i = 1; i <= nbins; i++) {
      htest->SetBinContent(i, gRandom->Poisson(hmc->GetBinContent(i)));
    }
    lldistrib->Fill(loglikelihood(hmc, htest, 1, nbins));
  }
  TCanvas * llcanvas = new TCanvas("llcanvas", "Log(Likelihood) distribution", 
				   40, 40, 800, 600);
  setopt(llcanvas);
  lldistrib->SetFillColor(kYellow);
  lldistrib->Draw();
  lldistrib->GetYaxis()->SetTitle("Anzahl Ereignisse");
  lldistrib->GetXaxis()->SetTitle("-ln L");
  // autozoom
  Int_t lowbin = 1;
  while (lldistrib->GetBinContent(lowbin) == 0)
    lowbin++;
  Int_t highbin = lldistrib->GetNbinsX();
  while (lldistrib->GetBinContent(highbin) == 0)
    highbin--;
  lldistrib->SetAxisRange(lldistrib->GetBinLowEdge(lowbin), 
			  lldistrib->GetBinLowEdge(highbin));
  TH1D * hworse = (TH1D *) lldistrib->Clone();
  for (Int_t nbin = 1; nbin < 501; nbin++) {
    hworse->SetBinContent(nbin, 0);
  }
  hworse->SetFillColor(95);
  hworse->Draw("same");
  Double_t pvalue = lldistrib->Integral(501,1000) / lldistrib->Integral();
  TLatex * tex = new TLatex(0.18, 0.96, Form("-ln L_{obs} = %5.2f", loglik));
  tex->SetNDC();
  tex->SetTextAlign(13);
  tex->Draw();
  tex = new TLatex(0.18, 0.86, Form("CL_{obs} = %.3f", pvalue));
  tex->SetNDC();
  tex->SetTextAlign(13);
  tex->Draw();
  TLine * l = new TLine(loglik, 0, loglik, lldistrib->GetMaximum());
  l->SetLineWidth(3);
  l->SetLineColor(kBlue);
  l->Draw();
  llcanvas->Modified();
  llcanvas->Update();
  if (print)
    llcanvas->Print("lldistrib.pdf");
  cd(gPadNr+1);
}
Beispiel #6
0
TH1D* GetFinalCorrFunc1D(int itrg, int jass)
{
                    TH1D* hbackground_phi = (TH1D*)GetRawBackground1D(itrg,jass);
		    TH1D* hcorrphi = (TH1D*)GetJetCorrFunc1D_ZYAM(itrg,jass);
                    hcorrphi->Multiply(hbackground_phi);
                    float max = hcorrphi->GetBinContent(hcorrphi->GetMaximumBin());
		    hcorrphi->SetAxisRange(ymin,max*1.5,"Y");
                    hcorrphi->SetYTitle("#frac{1}{N^{trg}}#frac{d^{2}N}{d#Delta#phi}");
                    return hcorrphi;
}
Beispiel #7
0
void testCorr3D(Int_t corrLevel=0,
    TString mod="B2InConeGluon",
    TString modref="B2InConeQuark",
    TString app="_jtv3_2_cv4qg",
    TString appref="_jtv3_2_cv4qg",
    Int_t isample=0, // -1 for all samples
    Int_t etaPM=2 // +/- 2 for |eta|<1
    )
{
  Int_t mode=1; // 0 for write, 1 for read
  Int_t cbin=0;
  Float_t ptHatMin=110;

  Corrector3D trkCorr("trkCorrHisAna_djuq",app,mod);
  trkCorr.ptHatMin_.clear();
  trkCorr.ptHatMin_.push_back(ptHatMin);
  trkCorr.sampleMode_ = 0; // 0 for choosing individual sample, 1 for merge samples
  trkCorr.Init();
  Double_t corr[4];
  cout << trkCorr.GetCorr(10,0,110,0,corr) << endl;

  Corrector3D trkCorrRef("trkCorrHisAna_djuq",appref,modref);
  trkCorrRef.ptHatMin_.clear();
  trkCorrRef.ptHatMin_.push_back(ptHatMin);
  trkCorrRef.sampleMode_ = 0; // 0 for choosing individual sample, 1 for merge samples
  trkCorrRef.Init();

  /*
  // Plot 2D Corr.
  gStyle->SetPadRightMargin(0.15);

  TCanvas * c2 = new TCanvas("c2","c2",500,500);
  TH2D *hCorr2D = (TH2D*)trkCorr.InspectCorr(corrLevel,isample,cbin,4,30,0);
  hCorr2D->Draw("colz");
  */

  TCanvas * cEff = new TCanvas("cEff","cEff",500,500);
  TH1D * hCorrPtRef = (TH1D*) trkCorrRef.InspectCorr(corrLevel,isample,cbin,3,15,2,7-etaPM,7+etaPM);
  hCorrPtRef->SetAxisRange(0,120,"X");
  hCorrPtRef->SetMarkerStyle(0);
  hCorrPtRef->SetMarkerColor(kBlack);
  hCorrPtRef->SetLineColor(kBlack);
  hCorrPtRef->Draw("histE");
  TH1D * hCorrPt = (TH1D*) trkCorr.InspectCorr(corrLevel,isample,cbin,3,15,2,7-etaPM,7+etaPM);
  hCorrPt->SetMarkerStyle(0);
  hCorrPt->SetMarkerColor(kRed);
  hCorrPt->SetLineColor(kRed);
  hCorrPt->Draw("hist same E");

  /*
  TCanvas * cEffEta = new TCanvas("cEffEta","cEffEta",500,500);
  TH1D * hCorrEta = (TH1D*)trkCorr.InspectCorr(corrLevel,isample,cbin,4,30,1);
  hCorrEta->Draw("histE");
  */
}
Beispiel #8
0
void ptDependence()
{
   TFile *inf = new TFile("histos/ppMC.root");
   TTree *t = (TTree*) inf->Get("nt");

   const int nBins = 4;
   double ptBin[nBins+1] = {100,120,140,160,200};
//   const int nBins = 1;
//   double ptBin[nBins+1] = {100,400};
   
   TH1D *hProb = new TH1D("hProb","",nBins,ptBin);
   TH1D *hCSV = new TH1D("hCSV","",nBins,ptBin);
   TH1D *hSVTXM = new TH1D("hSVTXM","",nBins,ptBin);
   TProfile *pGen = new TProfile("pGen","",nBins,ptBin);
   
   for (int n=0; n<nBins;n++)
   {
      RooRealVar f1 = bfractionFit("discr_prob",0,3.5,ptBin[n],ptBin[n+1]);
      RooRealVar f2 = bfractionFit("discr_csvSimple",0,1,ptBin[n],ptBin[n+1]);
      RooRealVar f3 = bfractionFit("svtxm",0,6,ptBin[n],ptBin[n+1]);
      hProb->SetBinContent(n+1,f1.getVal());    
      hProb->SetBinError(n+1,f1.getError());    
      hCSV->SetBinContent(n+1,f2.getVal());    
      hCSV->SetBinError(n+1,f2.getError());    
      hSVTXM->SetBinContent(n+1,f3.getVal());    
      hSVTXM->SetBinError(n+1,f3.getError());    
   }
   
   TCanvas *c2 = new TCanvas("c2","",600,600);
   hProb->SetAxisRange(0,0.05,"Y");
   hProb->SetXTitle("Jet p_{T} (GeV/c)");
   hProb->SetYTitle("b-jet fraction");
   hProb->SetTitleOffset(1.5,"Y");
   hProb->Draw();
   hCSV->SetLineColor(2);
   hCSV->SetMarkerColor(2);
   hCSV->SetMarkerStyle(24);
   hCSV->Draw("same");
   hSVTXM->SetLineColor(4);
   hSVTXM->SetMarkerColor(4);
   hSVTXM->SetMarkerStyle(24);
//   hSVTXM->Draw("same");
   t->Draw("abs(refparton_flavorForB)==5:jtpt","","prof same");
   
   TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
   leg->SetBorderSize(0);
   leg->SetFillStyle(0);
   leg->SetFillColor(0);
   leg->AddEntry(hProb,"Jet Probability","pl");
   leg->AddEntry(hCSV,"CSV","pl");
//   leg->AddEntry(hSVTXM,"SV mass","pl");
   leg->Draw();
}
Beispiel #9
0
void zeeAnaDiff(TH1D* hsee, TCut addCut,TH1D* hseeMc) {
  
  TFile *f1=new TFile(fname1.Data());
  TTree *zp = (TTree*)f1->Get("tz");
  zp->AddFriend("yEvt=yongsunHiEvt"       ,fname1.Data());
  zp->AddFriend("ySkim=yongsunSkimTree"   ,fname1.Data());
  zp->AddFriend("yHlt=yongsunHltTree"     ,fname1.Data());
  zp->AddFriend("tgj",                     fname1.Data());
  
  TH1D* hmass = new TH1D("hmass",";inv. mass (GeV);event fraction",34,30,200);
  hmass->Sumw2();

  zp->Draw("invm>>hmass",addCut && "isEle1==1 && isEle2==1");
  TH1D* htemp = (TH1D*)hsee->Clone("htemp");   htemp->Reset();
  zp->Draw("see1>>htemp",addCut && "isEle1==1 && isEle2==1" && "invm>80 && invm<100" );
  hsee->Reset();
  hsee->Add(htemp);
  handsomeTH1(hmass,2);
  scaleInt(hmass);
  
  TH1D* htempMC;
  TFile *f1mc;
  TTree *zpmc ;
  f1mc=new TFile(fname1MC.Data());
  zpmc = (TTree*)f1mc->Get("tz");
  zpmc->AddFriend("yEvt=yongsunHiEvt"       ,fname1MC.Data());
  zpmc->AddFriend("ySkim=yongsunSkimTree"   ,fname1MC.Data());
  zpmc->AddFriend("yHlt=yongsunHltTree"     ,fname1MC.Data());
  zpmc->AddFriend("yPho=yongsunPhotonTree"     ,fname1MC.Data());
  zpmc->AddFriend("tgj",                     fname1MC.Data());
  hseeMc->Sumw2();
  htempMC = (TH1D*)hseeMc->Clone("htempMc");   htempMC->Reset();
  TH1D* hmassMC = new TH1D("hmassMC11",";inv. mass (GeV);event fraction",34,30,200);
  hmassMC->Sumw2();
  zpmc->Draw("invm>>hmassMC11",Form("(%s) *yPho.ncoll",addCut.GetTitle()));
  zpmc->Draw("see1>>htempMc",Form("(%s) *yPho.ncoll", (addCut && "invm>80 && invm<100").GetTitle()) );
  hseeMc->Reset();
  hseeMc->Add(htempMC);
  handsomeTH1(hmassMC,1);
  scaleInt(hmassMC);
  
  
  hmassMC->SetAxisRange(0,0.6,"Y");
  hmassMC->DrawCopy();
  hmass->DrawCopy("same");                                                                                             
  TLegend* leg1 =  new TLegend(0.5580645,0.5381356,0.8923387,0.7648305,NULL,"brNDC");
  easyLeg(leg1,"Z->ee mass");
  leg1->AddEntry(hmass,"DATA","pl");
  leg1->AddEntry(hmassMC,"MC","pl");
  leg1->Draw();
  
}
Beispiel #10
0
TF1* GetFitFunc_ZYAM_AllPhysics(TH1D* h)
{
                    TH1D* hcorrphi = (TH1D*)h->Clone(h->GetName());
                    double histminY = hcorrphi->GetBinContent(10);
                    double histminX = 1.0;

                    hcorrphi->SetAxisRange(-0.01,1.5,"X");
                    TF1* fitfunc = new TF1(Form("fitfunc_%s",h->GetName()),"[0]+[1]*(x-[2])*(x-[2])+[3]*(x-[2])*(x-[2])*(x-[2])",0.5,1.65); //std 0.6 1.55 vs pT ; 0.6 1.8 vs eta
                    fitfunc->SetParameters(histminY,0.0002,histminX,0.0001);
                    fitfunc->SetParLimits(1,0,1000);
                    fitfunc->SetParLimits(2,0.5,1000);
                  //  fitfunc->SetParLimits(3,0,1000);

                    for(int ifit=0;ifit<3;ifit++) hcorrphi->Fit(Form("fitfunc_%s",h->GetName()),"RNO");
                    return fitfunc;
}
Beispiel #11
0
void plotCentrality(){

  
  TFile* f4 = new TFile("histogram_test_MB_2760GeV.root");
  TH1D* cent  = f4->Get("demo/centhist");
  TCanvas* cd = new TCanvas("cd","",600,500);
  cd->SetLeftMargin(0.12);
  cd->SetRightMargin(0.02);
  cd->SetTopMargin(0.02);
  cd->SetBottomMargin(0.12);
  cd->SetTicks(1);
  cent->SetTitle("");
  cent->SetXTitle("Centrality (200 bins)");
  cent->SetYTitle("# of Events");
  cent->GetYaxis()->SetTitleOffset(1.2);
  cent->GetXaxis()->SetTitleOffset(1.2);
  cent->GetXaxis()->CenterTitle(1);
  cent->GetYaxis()->CenterTitle(1);
  cent->GetXaxis()->SetTitleSize(0.046);
  cent->GetYaxis()->SetTitleSize(0.046);
  cent->GetXaxis()->SetTitleFont(62);
  cent->GetYaxis()->SetTitleFont(62);
  cent->SetAxisRange(0,209,"Y");
  cent->SetAxisRange(0,203,"X");
  cent->SetMarkerStyle(20);
  cent->Sumw2();
  cent->SetMarkerSize(1);
  cent->SetMarkerColor(1);
  cent->SetLineColor(1);
  //cent->SetStats(0);
  cent->Draw("Pez");

    TLatex *tex1= new TLatex(55.5,125.060,"Hydjet 2.76TeV MB");
    tex1->SetTextColor(1);
    tex1->SetTextSize(0.05);
    tex1->SetTextFont(42);
    tex1->Draw();

    TLatex *tex2= new TLatex(55.5,99.054,"CMSSW_7_5_0_pre5");
    tex2->SetTextColor(1);
    tex2->SetTextSize(0.05);
    tex2->SetTextFont(42);
    //tex2->Draw();
  cd->SaveAs("centralityDist750x2760GeV.png");

}
Beispiel #12
0
TH1D* GetJetCorrFunc1D_ZYA1(int itrg, int jass)
{
                    TH1D* hcorrphi = (TH1D*)GetRawCorrFunc1D_ratio(itrg,jass);
                    TH1D* hcorrphi_clone = (TH1D*)hcorrphi->Clone(Form("corrphi_clone_itrg%d_jass%d",itrg,jass));
                    hcorrphi->SetAxisRange(0.5,2.0,"X");
                    double histminY = hcorrphi->GetMinimum();
		    TF1* fitfunc = new TF1("fitfunc","[0]+[1]*x",0.8,1.2);		    
                    fitfunc->SetParameters(histminY,0);
                    fitfunc->FixParameter(1,0);
		    for(int ifit=0;ifit<3;ifit++) hcorrphi->Fit("fitfunc","RNO");                     
		    float level = fitfunc->GetParameter(0);
		    for(int ibin=1;ibin<=hcorrphi_clone->GetNbinsX();ibin++) hcorrphi_clone->SetBinContent(ibin,hcorrphi_clone->GetBinContent(ibin)-level);
                    float max = hcorrphi_clone->GetBinContent(hcorrphi_clone->GetMaximumBin());
                    hcorrphi_clone->SetAxisRange(ymin,max*1.3,"Y");
		    hcorrphi_clone->SetAxisRange(-PI/2.,3.*PI/2.,"X");
                    delete fitfunc;
                    return hcorrphi_clone;
}
void photonEnergyValidate   (sampleType collision = kHIMC) {
  TH1::SetDefaultSumw2(); 
  
  TFile* f = new TFile("photonEnergyScaleTable_lowPt_v6.root");
  TF1* curve[2][4];  // [ conversion 0 or 1 ] [ centrality bin 1,2,3] 
  for ( int icent = 1 ; icent<=3 ; icent++) {
    curve[0][icent] = (TF1*)f->Get(Form("fit_hscale_r9gt94_%d",icent));   // Not converted
    curve[1][icent] = (TF1*)f->Get(Form("fit_hscale_r9lt94_%d",icent));  // Converted
    curve[1][icent]->SetLineStyle(7);
  }
  TH1D* htemp = new TH1D("htemp",";p_{T}^{#gamma} (GeV); Residual correction",200,35,200);
  
  TCanvas* c1 = new TCanvas("c1","",500,500);

  handsomeTH1(htemp,0);
  htemp->SetAxisRange(0.97,1.12,"Y");
  htemp->DrawCopy();
  
  for (int icent = 1 ;icent<=3 ; icent++) {
    curve[0][icent]->Draw("same");
    curve[1][icent]->Draw("same");
    //    onSun(35,1,200,1);
  }
  TLegend *l0 =  new TLegend(0.4910859,0.5132576,1,0.7102273,NULL,"brNDC");
  easyLeg(l0,"r9 > 0.94 : Not Conv");
  l0->AddEntry(curve[0][1],"0-10%","l");
  l0->AddEntry(curve[0][2],"10-30%","l");
  l0->AddEntry(curve[0][3],"30-100%","l");
  l0->Draw();
  
  TLegend *l1 = new TLegend(0.4910859,0.7443182,1,0.9318182,NULL,"brNDC");
   easyLeg(l1,"r9 < 0.94 : Conv");
  l1->AddEntry(curve[1][1],"0-10%","l");
  l1->AddEntry(curve[1][2],"10-30%","l");
  l1->AddEntry(curve[1][3],"30-100%","l");
  l1->Draw();
  

       

}
Beispiel #14
0
void trksplit()
{
  TFile* f = new TFile("../cfg/dihadroncorrelation_wsplit_real_cent010_mc.root");
  TFile* f1 = new TFile("../cfg/dihadroncorrelation_wosplit_cent010_mc.root");
 
  TH1D* hpt = (TH1D*)f->Get("corr_ana_HI/ptall_trg");
  TH1D* hpt1 = (TH1D*)f1->Get("corr_ana_HI/ptall_trg");
  hpt->SetMarkerStyle(20);
  hpt1->SetMarkerStyle(20);
  hpt->SetMarkerColor(4);
  hpt->Rebin(4);
  hpt1->Rebin(4);

  TCanvas* c = new TCanvas("c","c",500,450);
  hpt->SetAxisRange(0,5.0,"X");
  hpt->Draw("PE");
  hpt1->Draw("PESAME");

  TH1D* hratio = (TH1D*)hpt->Clone("hratio");
  hratio->Divide(hpt1);

  TCanvas* c1 = new TCanvas("c1","c1",500,450);
  hratio->Draw("PE");
}
Beispiel #15
0
TH2D* GetJetCorrFunc2D_ZYA1(int itrg, int jass)
{
                    TH2D* hcorr = (TH2D*)GetRawCorrFunc2D_ratio(itrg,jass);
                    TH2D* hcorr_clone = (TH2D*)hcorr->Clone(Form("corr_clone_itrg%d_jass%d",itrg,jass));
                    hcorr_clone->Reset();
		    for(int ietabin=1;ietabin<=hcorr->GetNbinsX();ietabin++)
		    {
                      TH1D* hcorrphi = (TH1D*)hcorr->ProjectionY(Form("corrphi_%d",ietabin),ietabin,ietabin,"e");  
                      hcorrphi->SetAxisRange(0.5,2.0,"X");
                      double histminY = hcorrphi->GetMinimum();
		      fitfunc = new TF1("fitfunc","[0]+[1]*x",0.8,1.2);		    
                      fitfunc->SetParameters(histminY,0);
                      fitfunc->FixParameter(1,0);
		      for(int ifit=0;ifit<3;ifit++) hcorrphi->Fit(Form("fitfunc_%d",ietabin),"RNO");                     
		      float level = fitfunc->GetParameter(0);
		      for(int iphibin=1;iphibin<=hcorrphi->GetNbinsY();iphibin++)
                        hcorr_clone->SetBinContent(ietabin,iphibin,hcorr->GetBinContent(ietabin,iphibin)-level);
                      delete fitfunc;
		    }

                    float max = hcorr_clone->GetBinContent(hcorr_clone->GetMaximumBin());
                    hcorr_clone->SetAxisRange(ymin,max*1.3,"Z");
                    return hcorr_clone;
}
TF1* fitDstar5prongs(TTree* nt, Double_t ptmin, Double_t ptmax)
{
  static int count5p=0;
  count5p++;
  
  TCanvas* c = new TCanvas(Form("c_5p_%d",count5p),"",600,600);
  TH1D* h = new TH1D(Form("h_5p_%d",count5p),"",60,0.140,0.160);
  TF1* f = new TF1(Form("f_5p_%d",count5p),"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*((1-[8])*TMath::Gaus(x,[6],[7])/(sqrt(2*3.14159)*[7])+[8]*TMath::Gaus(x,[6],[9])/(sqrt(2*3.14159)*[9]))",minmass3prong,maxmass3prong);
  nt->Project(Form("h_5p_%d",count5p),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f&&Dpt<%f)",weight.Data(),seldata5p.Data(),triggerselection[isData].Data(),ptmin,ptmax));   
    
  f->SetLineColor(4);
  f->SetParameters(0,0,0,0,0,2e2,1.45491e-1,9e-4,0.1,8e-4);
  f->FixParameter(9,15e-4);
  f->FixParameter(6,0.145491);
  f->FixParameter(7,8e-4);
  f->SetParLimits(8,0,1);
  f->SetParLimits(5,0,100000);
  h->Fit(Form("f_5p_%d",count5p),"LL");
  h->Fit(Form("f_5p_%d",count5p),"LL");
  h->Fit(Form("f_5p_%d",count5p),"LL","",minmass3prong,maxmass3prong);
  f->ReleaseParameter(6);
  f->ReleaseParameter(7);
  f->ReleaseParameter(9);
  f->SetParLimits(6,0.144,0.147);
  f->SetParLimits(7,1e-4,9e-4);
  f->SetParLimits(9,1e-4,9e-4);
  h->Fit(Form("f_5p_%d",count5p),"LL","",0.142,0.148);
  h->Fit(Form("f_5p_%d",count5p),"LL","",0.142,0.16);
  h->Fit(Form("f_5p_%d",count5p),"LL","",0.142,0.16);
  h->Fit(Form("f_5p_%d",count5p),"LL","",0.141,0.16);
  h->Fit(Form("f_5p_%d",count5p),"LL","",0.141,0.16);
  h->Fit(Form("f_5p_%d",count5p),"LL","",0.141,0.16);

  TF1* background = new TF1(Form("background_5p_%d",count5p),"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x");
  background->SetParameter(0,f->GetParameter(0));
  background->SetParameter(1,f->GetParameter(1));
  background->SetParameter(2,f->GetParameter(2));
  background->SetParameter(3,f->GetParameter(3));
  background->SetParameter(4,f->GetParameter(4));
  background->SetLineColor(4);
  background->SetRange(minmass3prong,maxmass3prong);
  background->SetLineStyle(2);
  
  TF1* mass = new TF1(Form("fmass_5p_%d",count5p),"[0]*((1-[3])*TMath::Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+[3]*TMath::Gaus(x,[1],[4])/(sqrt(2*3.14159)*[4]))");
  mass->SetParameters(f->GetParameter(5),f->GetParameter(6),f->GetParameter(7),f->GetParameter(8),f->GetParameter(9));
  mass->SetParError(0,f->GetParError(5));
  mass->SetParError(1,f->GetParError(6));
  mass->SetParError(2,f->GetParError(7));
  mass->SetParError(3,f->GetParError(8));
  mass->SetParError(4,f->GetParError(9));
  mass->SetFillColor(kOrange-3);
  mass->SetFillStyle(3002);
  mass->SetLineColor(kOrange-3);
  mass->SetLineWidth(3);
  mass->SetLineStyle(2);
    
  h->SetXTitle("M_{K#pi#pi#pi#pi}-M_{K#pi#pi#pi} (GeV/c^{2})");
  h->SetYTitle("Entries / (1/3 MeV/c^{2})");
  h->SetStats(0);
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");

  background->Draw("same");   
  mass->SetRange(0.142,0.152);	
  mass->Draw("same");
  f->Draw("same");
  
  Double_t yield = mass->Integral(minmass5prong,maxmass5prong)/binwidth5prong;
  Double_t yieldErr = mass->Integral(minmass5prong,maxmass5prong)/binwidth5prong*mass->GetParError(0)/mass->GetParameter(0);

  TLatex* tex;
  TLegend* leg = new TLegend(0.60,0.62,0.85,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry((TObject*)0,"D* D^{0}(K#pi#pi#pi)#pi",NULL);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D*^{+}+D*^{-} Signal","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  tex = new TLatex(0.61,0.58,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();

  tex = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  tex->SetNDC();
  tex->SetTextAlign(12);
  tex->SetTextSize(0.04);
  tex->SetTextFont(42);
  tex->Draw();
  tex = new TLatex(0.65,0.93, "PP #sqrt{s_{NN}} = 5.02 TeV");
  tex->SetNDC();
  tex->SetTextAlign(12);
  tex->SetTextSize(0.04);
  tex->SetTextFont(42);
  tex->Draw();
  tex = new TLatex(0.20,0.79,"|y| < 1.0");
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();
  tex = new TLatex(0.20,0.84,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();

  c->SaveAs(Form("plots/pp/DMass_%s_5prongs-%d.pdf",texData[isData].Data(),count5p));
  
  return mass;
}
TF1* fitDstar3prongs(TTree* nt, TTree* ntMC, Double_t ptmin, Double_t ptmax)
{
  static int count3p=0;
  count3p++;
  
  TCanvas* c = new TCanvas(Form("c_3p_%d",count3p),"",600,600);
  TH1D* h = new TH1D(Form("h_3p_%d",count3p),"",60,0.14,0.16);
  TH1D* hMCSignal = new TH1D(Form("hMCSignal_3p_%d",count3p),"",60,0.14,0.16);
  TH1D* hMCSwapped = new TH1D(Form("hMCSwapped_3p_%d",count3p),"",60,0.14,0.16);

  TF1* f = new TF1(Form("f_3p_%d",count3p),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*([12]*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10])+(1-[12])*Gaus(x,[1],[13])/(sqrt(2*3.14159)*[13])))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]+[4]*x+[5]*x*x+[6]*x*x*x+[11]*x*x*x*x",0.14,0.16);
  f->SetLineColor(kRed);
  nt->Project(Form("h_3p_%d",count3p),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f&&Dpt<%f)",weight.Data(),seldata3p.Data(),triggerselection[isData].Data(),ptmin,ptmax));
  ntMC->Project(Form("hMCSignal_3p_%d",count3p),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f&&Dpt<%f&&(Dgen==23333))",weight.Data(),selmc3p.Data(),triggerselection[isData].Data(),ptmin,ptmax));
  ntMC->Project(Form("hMCSwapped_3p_%d",count3p),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f&&Dpt<%f&&(Dgen==23344))",weight.Data(),selswp3p.Data(),triggerselection[isData].Data(),ptmin,ptmax));

  f->FixParameter(7,1.);
  f->FixParameter(1,0.145491);
  f->FixParameter(2,2.e-3);
  f->FixParameter(10,5.e-4);
  f->FixParameter(13,1.e-4);
  f->FixParameter(3,0.);
  f->FixParameter(4,0.);
  f->FixParameter(5,0.);
  f->FixParameter(6,0.);
  f->FixParameter(11,0.);

  f->SetParLimits(9,0,1);
  f->SetParLimits(12,0,1);
  f->SetParLimits(0,0,1000000);
  hMCSignal->Fit(Form("f_3p_%d",count3p),"LL");
  hMCSignal->Fit(Form("f_3p_%d",count3p),"LL");
  hMCSignal->Fit(Form("f_3p_%d",count3p),"LL","",0.142,0.155);
  f->ReleaseParameter(1);
  f->ReleaseParameter(2);
  f->ReleaseParameter(10);
  f->ReleaseParameter(13);
  f->SetParLimits(1,0.144,0.147);
  if(isData==0||isData==2) f->SetParLimits(2,5.e-4,5.e-3);
  else f->SetParLimits(2,5.e-4,7.e-3);
  f->SetParLimits(10,1.e-4,2.e-3);
  if(isData==0||isData==2) f->SetParLimits(13,5.e-5,3.e-4);
  else if(ptmin>20) f->SetParLimits(13,5.e-5,4.e-4);
  else f->SetParLimits(13,5.e-5,5.e-4);
  hMCSignal->Fit(Form("f_3p_%d",count3p),"LL","",0.143,0.147);
  hMCSignal->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);
  hMCSignal->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);

  f->FixParameter(1,f->GetParameter(1));
  f->FixParameter(2,f->GetParameter(2));
  f->FixParameter(10,f->GetParameter(10));
  f->FixParameter(13,f->GetParameter(13));
  f->FixParameter(9,f->GetParameter(9));
  f->FixParameter(12,f->GetParameter(12));
  f->FixParameter(7,0);
  f->SetParLimits(8,2.e-4,2.e-3);

  hMCSwapped->Fit(Form("f_3p_%d",count3p),"L q","",0.14,0.16);
  hMCSwapped->Fit(Form("f_3p_%d",count3p),"L q","",0.14,0.16);

  f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000)));
  f->FixParameter(8,f->GetParameter(8));
  f->ReleaseParameter(3);
  f->ReleaseParameter(4);
  f->ReleaseParameter(5);
  f->ReleaseParameter(6);
  f->ReleaseParameter(11);
  h->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);
  h->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);
  f->ReleaseParameter(1);
  h->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);
  h->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);
  h->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);
  h->Fit(Form("f_3p_%d",count3p),"LL","",0.14,0.16);

  TF1* background = new TF1(Form("background_3p_%d",count3p),"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x");
  background->SetParameter(0,f->GetParameter(3));
  background->SetParameter(1,f->GetParameter(4));
  background->SetParameter(2,f->GetParameter(5));
  background->SetParameter(3,f->GetParameter(6));
  background->SetParameter(4,f->GetParameter(11));
  background->SetLineColor(4);
  background->SetLineStyle(2);
  
  TF1* mass = new TF1(Form("fmass_3p_%d",count3p),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*([6]*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])+(1-[6])*Gaus(x,[1],[7])/(sqrt(2*3.14159)*[7]))))");
  mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10),f->GetParameter(12),f->GetParameter(13));
  mass->SetParError(0,f->GetParError(0));
  mass->SetParError(1,f->GetParError(1));
  mass->SetParError(2,f->GetParError(2));
  mass->SetParError(3,f->GetParError(7));
  mass->SetParError(4,f->GetParError(9));
  mass->SetParError(5,f->GetParError(10));
  mass->SetParError(6,f->GetParError(12));
  mass->SetParError(7,f->GetParError(13));
  mass->SetFillColor(kOrange-3);
  mass->SetFillStyle(3002);
  mass->SetLineColor(kOrange-3);
  mass->SetLineWidth(3);
  mass->SetLineStyle(2);
  
  h->SetXTitle("M_{K#pi#pi}-M_{K#pi} (GeV/c^{2})");
  h->SetYTitle("Entries / (1/3 MeV/c^{2})");
  h->SetStats(0);
  h->SetAxisRange(1,h->GetMaximum()*1.3,"Y");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");

  background->Draw("same");   
  mass->SetRange(0.142,0.152);	
  mass->Draw("same");
  f->Draw("same");

  Double_t yield = mass->Integral(0.14,0.16)/binwidth3prong;
  Double_t yieldErr = mass->Integral(0.14,0.16)/binwidth3prong*mass->GetParError(0)/mass->GetParameter(0);

  TLatex* tex;
  TLegend* leg = new TLegend(0.60,0.62,0.85,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry((TObject*)0,"D* D^{0}(K#pi)#pi",NULL);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D*^{+}+D*^{-} Signal","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  tex = new TLatex(0.61,0.58,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();

  tex = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  tex->SetNDC();
  tex->SetTextAlign(12);
  tex->SetTextSize(0.04);
  tex->SetTextFont(42);
  tex->Draw();
  tex = new TLatex(0.65,0.93, "PP #sqrt{s_{NN}} = 5.02 TeV");
  tex->SetNDC();
  tex->SetTextAlign(12);
  tex->SetTextSize(0.04);
  tex->SetTextFont(42);
  tex->Draw();
  tex = new TLatex(0.20,0.79,"|y| < 1.0");
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();
  tex = new TLatex(0.20,0.84,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();

  c->SaveAs(Form("plots/pp/DMass_%s_3prongs-%d.pdf",texData[isData].Data(),count3p));
  
  return mass;
}
void photonTemplateProducer(int cutOpt=3, int ppHI = kHI, int isoChoice = kSumIso, int isoCut = -100, bool onlygjEvents=false, float specialSbCut=10, float mcSigShift=0, float sbBkgShift=0) {
  
  CutAndBinCollection cab;
  cab.setCuts(cutOpt);
  int nPtBin = cab.getNPtBin();
  vector<double> ptBinVector = cab.getPtBin();
  double ptBin[100];
  for ( int i = 0 ; i<=nPtBin ;i++) {
    ptBin[i] = ptBinVector[i];
  }
  
  int nCentBin = cab.getNCentBin();
  vector<double> centBinVector = cab.getCentBin();
  double centBin[100];
  for ( int i = 0 ; i<=nCentBin ;i++) {
    centBin[i] = centBinVector[i];
  }
  
  TString pphiLabel = "";
  if ( ppHI == kPP) pphiLabel = "pp";
  
  TCanvas* c1[5];
    
   TH1D* hData[5][5];
   TH1D* hSig[5][5];
   TH1D* hBkg[5][5];
   
   //   TH1D* hDatapp[5];
   //   TH1D* hSigpp[5];
   //   TH1D* hBkgpp[5];
   
   TH1D* hBkgMCsr[5][5];
   TH1D* hBkgMCsb[5][5];
      
   TH1D* rawSpectra[5];
   TH1D* finSpectra[5];
    
   TH2D* hPurity2D = new TH2D("hPurity2D",";pT(GeV);Centrality bin",nPtBin,ptBin,nCentBin,centBin);
   
   int nCent(-1);
   if ( ppHI == kHI ) nCent = nCentBin;
   if ( ppHI == kPP ) nCent = 1;
   
   for ( int icent = 1 ; icent<=nCent ; icent++) {
      rawSpectra[icent] = new TH1D(Form("rawSpec_icent%d_%s",icent,getIsoLabel(isoChoice).Data()),"",nPtBin,ptBin);
   }

   
   for (int ipt = 1; ipt <= nPtBin ; ipt++) { 
      c1[ipt] = new TCanvas(Form("c1_ipt%d",ipt),"",700,700);
      if ( ppHI == kHI )  makeMultiPanelCanvas(c1[ipt],nCent/2,2,0.0,0.0,0.2,0.15,0.02);

      TCut ptCut = Form("corrPt>%.2f && corrPt<%.2f",(float)ptBin[ipt-1],(float)ptBin[ipt]); 
      

      for ( int icent = 1 ; icent<=nCent ; icent++) { 
	 int lowCent =  centBinVector[icent-1];    
	 int highCent = centBinVector[icent]-1;
	 
	 hData[icent][ipt]  = new TH1D(Form("hData_cent%d_pt%d",icent,ipt),";shower shape (#sigma_{#eta#eta});Entries per photon candidate;",25,0,0.025);
	 hSig[icent][ipt]   = (TH1D*)hData[icent][ipt]->Clone(Form("hSig_cent%d_pt%d",icent,ipt));
	 hBkg[icent][ipt]   = (TH1D*)hData[icent][ipt]->Clone(Form("hBkg_cent%d_pt%d",icent,ipt));
	 hBkgMCsr[icent][ipt] = (TH1D*)hData[icent][ipt]->Clone(Form("hBkgMCsr_cent%d_pt%d",icent,ipt));
	 hBkgMCsb[icent][ipt] =(TH1D*)hData[icent][ipt]->Clone(Form("hBkgMCsb_cent%d_pt%d",icent,ipt));
	
	 TString fNamedata = fNameHIdata;
	 if ( ppHI == kPP ) fNamedata = fNamePPdata;
	 
	 getTemplate(ppHI, hSig[icent][ipt],"meaningless",isoChoice,isoCut, kSig,lowCent,highCent,ptCut,onlygjEvents,specialSbCut,mcSigShift);
	 getTemplate(ppHI, hData[icent][ipt],fNamedata ,isoChoice,isoCut, kData,lowCent,highCent,ptCut,onlygjEvents,specialSbCut);
	 if ( ppHI == kHI) {
	   getTemplate(ppHI, hBkg[icent][ipt], fNamedata ,isoChoice,isoCut, kSBB,lowCent,highCent,ptCut,onlygjEvents,specialSbCut,sbBkgShift);
	 }
	 if ( ppHI == kPP)
           getTemplate(ppHI, hBkg[icent][ipt], fNamedata ,isoChoice,isoCut, kSBBpp,lowCent,highCent,ptCut,onlygjEvents,specialSbCut);
	 
      }
            
      
      for ( int icent = 1 ; icent<=nCent ; icent++) {
	int lowerCent = centBinVector[icent-1];
	int upperCent =centBinVector[icent]-1;
	 
	 c1[ipt]->cd(nCent - icent+1);
	 fitResult fitr = doFit ( hSig[icent][ipt], hBkg[icent][ipt], hData[icent][ipt], 0.005,0.025);
	 if ( icent== nCent) drawPatch(0,0,0.05,0.14,0,1001, "ndc");
	 
	 cout << " shift = " << mcSigShift << endl;
	 cout << " purity = " << fitr.purity010 << endl;

	 
	 if ( ptBin[ipt]> 200)
	    drawText(Form(" E_{T}^{#gamma} > %d GeV", (int)ptBin[ipt-1]),0.5680963,0.529118);
	 else
	    drawText(Form("%d - %d GeV", (int)ptBin[ipt-1], (int)ptBin[ipt]),0.5680963,0.529118);
	 
	 if ( ppHI == kHI) {
	   drawText(Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),0.5680963,0.4369118);
	 }
	 else if ( ppHI == kPP) {
	   drawText("7TeV pp",0.5680963,0.4369118);
         }
	 
	 
	 
	 if ( (icent == nCent) || (icent == 2)) 
	   drawText(Form("Purity(#sigma_{#eta#eta} < 0.01) : %.0f%%", (float)fitr.purity010*100),0.5680963,0.3569118,1,15);
	 else 
	   drawText(Form("Purity(#sigma_{#eta#eta} < 0.01) : %.0f%%", (float)fitr.purity010*100),0.4980963,0.3569118,1,15);
	 
	 drawText(Form("#pm %.0f%% (stat)", float( 100. * fitr.purity010 * (float)fitr.nSigErr / (float)fitr.nSig ) ),0.6680963,0.2869118,1,15);
	 
	 
	 hPurity2D->SetBinContent(ipt,icent,fitr.purity010);
	 hPurity2D->SetBinError  (ipt,icent,fitr.purity010* fitr.nSigErr/fitr.nSig);

	 rawSpectra[icent]->SetBinContent( ipt, fitr.nSig);
	 rawSpectra[icent]->SetBinError(   ipt,fitr.nSigErr);

	 TString aa = "";
	 if (isoChoice == kSumIso)  aa = "Sum Iso Method";
	 if (isoChoice == k3dIso)   aa = "3d Cut Method";
	 if (isoChoice == kFisher)  aa = "Fisher Method";
	 
	 if ( (ppHI == kHI)  && ( icent==nCent -1) )
	   drawText(aa.Data(),0.1980963,0.8569118,1,20);
	 else if ( ppHI == kPP) 
	   drawText(aa.Data(),0.1980963,0.8569118,1,20);
	 
	 if ( icent<= 2) drawPatch(0,0,0.05,0.14,0,1001, ndcOpt);
	 //	 drawPatch(0.9,0.05,1.01,0.14,0,1001,ndcOpt);
	 if  ( (ppHI == kPP) && ( mcSigShift != 0 )) 
           drawText(Form("Signal template shifted by %f",mcSigShift),0.1980963,0.7569118,1,15);
	 if  ( (ppHI == kHI) && ( mcSigShift != 0 ) && (icent==3))
	   drawText(Form("Signal template shifted by %f",mcSigShift),0.1980963,0.7569118,1,15);


      }   
      
      TString ppLabel ="";  
      if ( ppHI == kPP) ppLabel = "_pp";
      TString shiftLabel="";
      if ( mcSigShift != 0 )  shiftLabel = Form("_%fSigShifted",(float)mcSigShift);
      c1[ipt]->SaveAs(Form("fittingPurity%s_%s_pt%d%s.pdf",ppLabel.Data(), getIsoLabel(isoChoice).Data(),ipt,shiftLabel.Data()));

   }
   
   // efficiency plots          
   TCanvas* c2  = new TCanvas("c2","",700,700); //100 + nCent_std*300,400);
   if ( ppHI == kHI) makeMultiPanelCanvas(c2,nCent/2,2,0.0,0.0,0.2,0.15,0.02);
   
   TH1D* heff[7][5];
   TH1D* heffGj[5];
   TH1D* heffDphi[5];
   TH1D* effSingleBin = new TH1D("effSingleBin","",1,60,100000);
   TGraphAsymmErrors* geff[7][5];
   TGraphAsymmErrors* gSingleBin = new TGraphAsymmErrors();
   TGraphAsymmErrors* geffGj[5];
   TGraphAsymmErrors* geffDphi[5];
   
   for (int icent = 1; icent <=nCent; icent++) {
     for ( int iid=1 ; iid<=5; iid++) {
       heff[icent][iid] = new TH1D(Form("heff_icent%d_id%d",icent,iid),";photon E_{T} (GeV);Efficiency",nPtBin, ptBin);
       if ( isoChoice == kSumIso2)
	 heff[icent][iid]->SetName(Form("heff_icent%d_id%d_isoCut%d",icent,iid,(int)isoCut));
       if ( isoChoice == kSumIso3)
	 heff[icent][iid]->SetName(Form("heff_icent%d_id%d_sbIsoCut%d",icent,iid,(int)specialSbCut));
       
       geff[icent][iid] = new TGraphAsymmErrors();
       geff[icent][iid]->SetName(Form("geff_%s",heff[icent][iid]->GetName()));
     }
     heffGj[icent]   = new TH1D(Form("heff_icent%d_Gj",  icent),";x_J#gamma;Efficiency",10,0,2);
     heffDphi[icent] = new TH1D(Form("heff_icent%d_Dphi",icent),";#Delta#phi of pair;Efficiency",9,0.3141592,3.141592);
     geffGj[icent] = new TGraphAsymmErrors();
     geffDphi[icent] = new TGraphAsymmErrors();

   }
   
   TCut srIsoCut = getIsoCut(isoChoice,isoCut);
   int nId=4;
   for (int icent = 1; icent <=nCent ; icent++) {
     int lowCent = centBinVector[icent-1];
     int highCent = centBinVector[icent]-1;
     TCut centCut      = Form("yEvt.hiBin >= %d && yEvt.hiBin<= %d",lowCent,highCent);
     if ( ppHI == kPP ) centCut = "";
     getEff("genMatchedPt",heff[icent][1],geff[icent][1],centCut, "swissCrx<0.90 && seedTime<4");
     getEff("genMatchedPt",heff[icent][2],geff[icent][2],centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1");
     getEff("genMatchedPt",heff[icent][3],geff[icent][3],centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1" && srIsoCut);
     getEff("genMatchedPt",heff[icent][4],geff[icent][4],centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1 && sigmaIetaIeta<0.010"&& srIsoCut);
     effSingleBin->Reset();
     getEff("genMatchedPt",effSingleBin, gSingleBin, centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1" && srIsoCut);
     
     
     cout << " here Gj" << endl;
     getEff("yJet.jtpt/photonEt",heffGj[icent],geffGj[icent], centCut && " genIso<5 && abs(genMomId)<=22 && photonEt>60 && abs(yJet.jteta)<2 && yJet.jtpt>30 && acos(cos(photonPhi-yJet.jtphi))>2.749", "hovere<0.1 && sigmaIetaIeta<0.010 && (cc4+cr4+ct4PtCut20)/0.9<1",true);
     getEff("acos(cos(photonPhi-yJet.jtphi))",heffDphi[icent],geffDphi[icent],centCut && " genIso<5 && abs(genMomId)<=22 && photonEt>60 && abs(yJet.jteta)<2 && yJet.jtpt>30", "hovere<0.1 && sigmaIetaIeta<0.010 && (cc4+cr4+ct4PtCut20)/0.9<1",true);
   }
   
   for (int icent = 1; icent <=nCent; icent++) {
     for ( int iid=1 ; iid<=nId ; iid++) {
       handsomeTH1(heff[icent][iid],ycolor[iid]);
       handsomeTGraph(geff[icent][iid],ycolor[iid]);
     }
   }
   

   
   
   
   TH1D* htmp = (TH1D*)heff[1][1]->Clone("htmp");
   htmp->Reset();
   htmp->SetAxisRange(0,1.3,"Y");
   htmp->SetYTitle("Efficiency");
   handsomeTH1(htmp);
   
   for (int icent = 1; icent <=nCent; icent++) {
      int lowerCent = centBinVector[icent-1];
      int upperCent = centBinVector[icent]-1;
      if ( ppHI == kHI) c2->cd(nCent - icent + 1);
      htmp->DrawCopy();
      for ( int iid=1 ; iid<=nId ; iid++) {
         heff[icent][iid]->Draw("p same");
         geff[icent][iid]->Draw("p");
	 
      }
      if ( ( icent == nCent ) ||   ( ppHI == kPP)  )
         {
            TLegend* leg1 =  new TLegend(0.25,0.20,0.95,0.55,NULL,"brNDC");
            easyLeg(leg1,"Photon ID efficiency");
            leg1->AddEntry(heff[icent][1],"spike rejection","lp");
            leg1->AddEntry(heff[icent][2],"+ H/E < 0.1","lp");
	    if (isoChoice == kSumIso)
	      leg1->AddEntry(heff[icent][3],"+ SumIso cut","lp");
	    if (isoChoice == kFisher) 
	      leg1->AddEntry(heff[icent][3],"+ Fisher cut","lp");
	    leg1->AddEntry(heff[icent][4],"+ #sigma_{#eta#eta} <0.010","lp");
            leg1->Draw();
         }
      drawText(Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),0.5680963,0.8369118);
      if ( icent<=2) drawPatch(0,0,0.05,0.14,0,1001,ndcOpt);
      //  drawPatch(0.9,0.05,1.01,0.14,0,1001,ndcOpt);
      
   }
   
   
   c2->SaveAs(Form("photonID_efficiency_%s.pdf",getIsoLabel(isoChoice).Data()));  

   TCanvas* c2b  = new TCanvas("c2b","",1000,500); //100 + nCent_std*300,400);                                             
   c2b->Divide(2,1);
   c2b->cd(1);
   TH1D* htmpG = (TH1D*)heffGj[1]->Clone("htmpG");
   htmpG->Reset();
   htmpG->SetAxisRange(0,1.3,"Y");
   htmpG->SetYTitle("Efficiency");
   handsomeTH1(htmpG);   
      
   TLegend* legCent = new TLegend(0.4657258,0.2245763,1,0.4512712,NULL,"brNDC");
   easyLeg(legCent,"Centrality");
   if (isoChoice == kSumIso)  easyLeg(legCent,"SumIso Method");
   if (isoChoice == kFisher)  easyLeg(legCent,"Fisher Method");
   cout<< " heffGj "<< endl << endl<< endl;
   for (int icent = 1; icent <=nCent; icent++) {
     handsomeTH1(heffGj[icent],ycolor[icent]);
     heffGj[icent]->Fit("pol1");
     heffGj[icent]->GetFunction("pol1")->SetLineColor(ycolor[icent]);
     heffGj[icent]->GetFunction("pol1")->SetLineStyle(7);
   }
   htmpG->DrawCopy();
   for (int icent = 1; icent <=nCent; icent++) {
     heffGj[icent]->Draw("same");
     int lowerCent = centBinVector[icent-1];     int upperCent = centBinVector[icent]-1;
     legCent->AddEntry(heffGj[icent],Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),"pl");
   }
   legCent->Draw();

   c2b->cd(2);
   TH1D* htmpDp = new TH1D("htmpDp",";#Delta#phi of pair;Efficiency",10,0,3.14);
   htmpDp->Reset();
   htmpDp->SetAxisRange(0,1.3,"Y");
   htmpDp->SetYTitle("Efficiency");
   handsomeTH1(htmpDp);
   cout << " heffDphi " << endl << endl << endl ;
   for (int icent = 1; icent <=nCent; icent++) {
     handsomeTH1(heffDphi[icent],ycolor[icent]);
     heffDphi[icent]->Fit("pol1");
     heffDphi[icent]->GetFunction("pol1")->SetLineColor(ycolor[icent]);
     heffDphi[icent]->GetFunction("pol1")->SetLineStyle(7);
   }
   htmpDp->DrawCopy();
   for (int icent = 1; icent <=nCent; icent++) {
     heffDphi[icent]->Draw("same");
   }
   legCent->Draw();
   
   c2b->SaveAs(Form("photonID_efficiency_%s_2.pdf",getIsoLabel(isoChoice).Data()));
   
   
   TCanvas* c3 = new TCanvas("cPurity","",500,500);

   TH1D* hPurity[10];
   for (int icent = 1; icent <=nCent; icent++) {
     hPurity[icent] = (TH1D*)hPurity2D->ProjectionX(Form("purity1D_icent%d",icent),icent,icent);
     hPurity[icent]->Fit("pol1");
     hPurity[icent]->GetFunction("pol1")->SetLineColor(ycolor[icent]);
     hPurity[icent]->GetFunction("pol1")->SetLineStyle(7);
   }
   TH1D* tempPurity = (TH1D*)hPurity[1]->Clone("purityTemp");
   tempPurity->Reset();
   handsomeTH1(tempPurity,1);
   tempPurity->SetXTitle("pT (Gev)");
   tempPurity->SetYTitle("Purity");
   tempPurity->SetAxisRange(0.45,1.2,"Y");

   tempPurity->Draw();
   for (int icent = 1; icent <=nCent; icent++) {
     handsomeTH1(hPurity[icent],ycolor[icent]);
     hPurity[icent]->Draw("same");
   }
   TLegend* legPurity = new TLegend(0.4657258,0.2245763,1,0.4512712,NULL,"brNDC");
   easyLeg(legPurity,"Purity");
   if (isoChoice == kSumIso)  easyLeg(legPurity,"SumIso Method");
   if (isoChoice == kFisher)  easyLeg(legPurity,"Fisher Method");
   for (int icent = 1; icent <=nCent; icent++){
     int lowerCent = centBinVector[icent-1];     int upperCent = centBinVector[icent]-1;
     legPurity->AddEntry(hPurity[icent],Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),"pl");
   }
   legPurity->Draw();
   
   if ( !onlygjEvents) 
     drawText("inclusive photon",0.25,0.2);
   
   c3->SaveAs(Form("purity_%s.pdf",getIsoLabel(isoChoice).Data()));
  
   
   TCanvas* c4 = new TCanvas("efficiencyCorrection","",1000,500);
   c4->Divide(2,1);
   c4->cd(1);
   for (int icent = 1; icent <=nCent; icent++) {
      TH1ScaleByWidth(rawSpectra[icent]);    // divide by width
      finSpectra[icent] = (TH1D*)rawSpectra[icent]->Clone(Form("finSpec_icent%d_%s",icent,getIsoLabel(isoChoice).Data()));
      if ( isoChoice == kSumIso2)
	 finSpectra[icent]->SetName(Form("finSpec_icent%d_%s_isoCut%d",icent,getIsoLabel(isoChoice).Data(),(int)isoCut));
      if ( isoChoice == kSumIso3)
         finSpectra[icent]->SetName(Form("finSpec_icent%d_%s_sbisoCut%d",icent,getIsoLabel(isoChoice).Data(),(int)specialSbCut));
      
      finSpectra[icent]->Divide(heff[icent][3]);
      handsomeTH1(finSpectra[icent],ycolor[icent]);
   }
   // TAA and centrality 
   //

   TFile outf = TFile(cab.getPurityFileName(),"recreate");
   hPurity2D->Write();
   for ( int icent=1 ; icent<=nCent ; icent++) {
      heff[icent][3]->Write();
      heff[icent][4]->Write();
      finSpectra[icent]->Write();
      hPurity[icent]->Write();
      for (int ipt = 1; ipt <= nPtBin ; ipt++) {
	hData[icent][ipt]->Write();
      }
      //      hBkgMCRatioFit[icent][1]->Write();

   }



   outf.Close();
}
Beispiel #19
0
void drawResults(bool drawSinglePanels = false) {
  // const int kPPcentral = 1;
  // const int kPPperipheral =2 ;
  // const int kHIcentral =  3;
  // const int kHIperipheral = 4;
  // const int kPADATA = 5;
  // const int kPAMC = 6;
  //const int nPtBin = 4;
  // double ptBin[nPtBin+1] = {40, 50,60,80,9999};

  TH1D* meanJetPt[8];   // [collision] [Before/After variation]
  TH1D* meanJetPtSys[8];   // [collision] [Before/After variation]

  TH1D* meanXjg[8];   // [collision] [Before/After variation]
  TH1D* meanXjgSys[8];   // [collision] [Before/After variation]

  TH1D* meanRjg[8];
  TH1D* meanRjgSys[8];

  TFile * f = new TFile("../resultHistograms/resultHistograms_ppSmeared10030.root");
  meanJetPt[1]  =(TH1D*)f->Get(Form("meanJetPt_pp"));
  meanXjg[1]    =(TH1D*)f->Get(Form("meanXjg_pp"));
  meanRjg[1]  =(TH1D*)f->Get(Form("meanRjg_pp"));

  f   = new TFile("../resultHistograms/resultHistograms_ppSmeared13099.root");
  meanJetPt[2]  =(TH1D*)f->Get(Form("meanJetPt_pp"));
  meanXjg[2]    =(TH1D*)f->Get(Form("meanXjg_pp"));
  meanRjg[2]  =(TH1D*)f->Get(Form("meanRjg_pp"));

  // pbpb
  f =   new TFile("../resultHistograms/resultHistograms_nominal_vtxCentWeighted.root");

  meanJetPt[7]  =(TH1D*)f->Get(Form("meanJetPt_pp"));
  meanXjg[7]  =(TH1D*)f->Get(Form("meanXjg_pp"));
  meanRjg[7]  =(TH1D*)f->Get(Form("meanRjg_pp"));

  meanJetPt[3]  =(TH1D*)f->Get(Form("meanJetPt_pbpb_centralityBin1"));
  meanXjg[3]  =(TH1D*)f->Get(Form("meanXjg_pbpb_centralityBin1"));
  meanRjg[3]  =(TH1D*)f->Get(Form("meanRjg_pbpb_centralityBin1"));

  meanJetPt[4]  =(TH1D*)f->Get(Form("meanJetPt_pbpb_centralityBin2"));
  meanXjg[4]  =(TH1D*)f->Get(Form("meanXjg_pbpb_centralityBin2"));
  meanRjg[4]  =(TH1D*)f->Get(Form("meanRjg_pbpb_centralityBin2"));

  // pPb
  meanJetPt[5]  =(TH1D*)f->Get(Form("meanJetPt_ppb"));
  meanXjg[5]  =(TH1D*)f->Get(Form("meanXjg_ppb"));
  meanRjg[5]  =(TH1D*)f->Get(Form("meanRjg_ppb"));

  f =   new TFile("../resultHistograms/resultHistograms_MCrecoIso_vtxCentWeighted.root"); //pythia+hijing
  meanJetPt[6]  =(TH1D*)f->Get(Form("meanJetPt_ppb"));
  meanXjg[6]  =(TH1D*)f->Get(Form("meanXjg_ppb"));
  meanRjg[6]  =(TH1D*)f->Get(Form("meanRjg_ppb"));


  TFile* fSys = new TFile("../relativeSys/relativeSys_merged.root");

  meanJetPtSys[1]  =(TH1D*)fSys->Get("meanJetPt_pp_uncertainty_merged");
  meanRjgSys[1]  =(TH1D*)fSys->Get(Form("meanRjg_pp_uncertainty_merged"));
  meanXjgSys[1]  =(TH1D*)fSys->Get(Form("meanXjg_pp_uncertainty_merged"));

  meanJetPtSys[2] = (TH1D*)meanJetPtSys[1]->Clone(Form("%s_2",meanJetPtSys[1]->GetName()));
  meanRjgSys[2] = (TH1D*)meanRjgSys[1]->Clone(Form("%s_2",meanRjgSys[1]->GetName()));
  meanXjgSys[2] = (TH1D*)meanXjgSys[1]->Clone(Form("%s_2",meanXjgSys[1]->GetName()));

  meanJetPtSys[3]  =(TH1D*)fSys->Get("meanJetPt_pbpb_centralityBin1_uncertainty_merged");
  meanXjgSys[3]  =(TH1D*)fSys->Get(Form("meanXjg_pbpb_centralityBin1_uncertainty_merged"));
  meanRjgSys[3]  =(TH1D*)fSys->Get(Form("meanRjg_pbpb_centralityBin1_uncertainty_merged"));

  meanJetPtSys[4]  =(TH1D*)fSys->Get("meanJetPt_pbpb_centralityBin2_uncertainty_merged");
  meanXjgSys[4]  =(TH1D*)fSys->Get(Form("meanXjg_pbpb_centralityBin2_uncertainty_merged"));
  meanRjgSys[4]  =(TH1D*)fSys->Get(Form("meanRjg_pbpb_centralityBin2_uncertainty_merged"));

  meanJetPtSys[5]  =(TH1D*)fSys->Get("meanJetPt_ppb_uncertainty_merged");
  meanXjgSys[5]  =(TH1D*)fSys->Get(Form("meanXjg_ppb_uncertainty_merged"));
  meanRjgSys[5]  =(TH1D*)fSys->Get(Form("meanRjg_ppb_uncertainty_merged"));


  // RJG!!
  TCanvas* c2; 
  //c2->Divide(3,1);
  if( !drawSinglePanels)
  {
    c2 = new TCanvas("c1","",1300,500);
    makeMultiPanelCanvas(c2,3,1,0.0,0.0, 0.15, 0.15, 0.025);
  }
  else
  {
    c2 = new TCanvas("c1","",1450,500);
    c2->Divide(3,1);
    //makeMultiPanelCanvas(c2,3,1,0.2,0.2, 0.15, 0.15, 0.025);
  }
  c2->cd(3);
  handsomeTH1(meanRjg[1],1,1,21);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= newYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)
  TH1D* tempR = new TH1D("tempR",";p_{T}^{#gamma} (GeV);R_{J#gamma}",1000,40,130);
  tempR->Reset();
  handsomeTH1(tempR,0);
  //tempR->SetAxisRange(0,1.2,"Y");
  tempR->SetAxisRange(0,1.0,"Y");
  tempR->SetAxisRange(40.01,109.99,"X");
  tempR->GetYaxis()->SetNdivisions(505);
  tempR->Draw();
  drawSys(meanRjg[1], meanRjgSys[1], kGreen,3001);
  drawSys(meanRjg[3], meanRjgSys[3]);
  handsomeTH1(meanRjg[1],1,1,21);
  meanRjg[1]->DrawCopy("same");
  handsomeTH1(meanRjg[3],2,1,20);
  meanRjg[3]->DrawCopy("same");
  meanRjg[1]->SetFillStyle(3001);
  meanRjg[1]->SetFillColor(kGreen);
  meanRjg[3]->SetFillColor(90);
  meanRjg[3]->SetFillStyle(1001);
  meanRjg[1]->SetLineColor(0);
  meanRjg[3]->SetLineColor(0);
  if ( 1==1 ){
    TLegend *ly = new  TLegend(0.4,0.2,0.75,0.4,NULL,"brNDC");
    //easyLeg(ly,"2.76TeV");
    easyLeg(ly);
    ly->AddEntry(meanRjg[3],"PbPb 0-30%","fp");
    ly->AddEntry(meanRjg[1],"Smeared pp reference","fp");
    ly->Draw();
  }
  if(!drawSinglePanels)
    drawCMSppPbPbDist(0.04,0.9);
  else
    drawCMSppPbPbDist(0.2,0.9);


  c2->cd(2);
  tempR->Draw();
  drawSys(meanRjg[2], meanRjgSys[2], kGreen,3001);
  drawSys(meanRjg[4], meanRjgSys[4]);
  //  meanRjg[2]->SetMarkerStyle(25);
  handsomeTH1(meanRjg[2],1,1,25);
  meanRjg[2]->DrawCopy("same");
  handsomeTH1(meanRjg[4],2,1,24);
  //  meanRjg[4]->SetMarkerStyle(24);
  meanRjg[4]->DrawCopy("same");
  meanRjg[2]->SetFillStyle(3001);
  meanRjg[2]->SetFillColor(kGreen);
  meanRjg[4]->SetFillColor(90);
  meanRjg[4]->SetFillStyle(1001);
  meanRjg[2]->SetLineColor(0);
  meanRjg[4]->SetLineColor(0);
  if ( 1==1 ){
    TLegend *ly = new  TLegend(0.4,0.2,0.75,0.4,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanRjg[4],"PbPb 30-100%","fp");
    ly->AddEntry(meanRjg[2],"Smeared pp reference","fp");
    ly->Draw();
  }
  if(!drawSinglePanels)
    drawCMSppPbPbDist(0.04,0.9);
  else
    drawCMSppPbPbDist(0.2,0.9);

  c2->cd(1);
  tempR->SetAxisRange(40,109.99,"X");
  tempR->DrawCopy();
  tempR->SetAxisRange(40.01,109.99,"X");
  drawSys(meanRjg[5], meanRjgSys[5], newYellow);
  drawSys(meanRjg[7], meanRjgSys[2], kGreen, 3001);
  //  handsomeTH1(meanRjg[5],9,1,34);
  handsomeTH1(meanRjg[5],2,1,34);
  handsomeTH1(meanRjg[6],1,1,25);
  handsomeTH1(meanRjg[7],1,1);
  meanRjg[6]->DrawCopy("same");
  meanRjg[7]->DrawCopy("same");
  meanRjg[5]->DrawCopy("same");
  meanRjg[7]->SetFillStyle(3001);
  meanRjg[7]->SetFillColor(kGreen);
  meanRjg[5]->SetFillColor(90);
  meanRjg[5]->SetFillStyle(1001);
  meanRjg[7]->SetLineColor(0);
  meanRjg[5]->SetLineColor(0);

  if ( 1==1 ) {
    TLegend *ly = new TLegend(0.5,0.2,0.85,0.42,NULL,"brNDC");//0.4,0.2,0.75,0.4
    easyLeg(ly);
    ly->AddEntry(meanRjg[5],"pPb DATA","fp");
    ly->AddEntry(meanRjg[7],"pp DATA (2.76 TeV)","fp");
    ly->AddEntry(meanRjg[6],"PYTHIA+HIJING","p");
    ly->Draw();
  }
  drawCMSpPbDist(0.2,0.9);
  
  c2->SaveAs("pT_dependence_rjg_pp_pbpb.pdf");
  c2->SaveAs("pT_dependence_rjg_pp_pbpb.gif");
  //c2->SaveAs("pT_dependence_rjg_pp_pbpb.png");

  // ppPbPb meanJetPt
  TCanvas* c3 = new TCanvas("c3","",1300,500);
  if(!drawSinglePanels)
    makeMultiPanelCanvas(c3,3,1,0.0,0.0, 0.15, 0.15, 0.025);
  else
    c3->Divide(3,1);
    //makeMultiPanelCanvas(c3,3,1,0.2,0.2, 0.15, 0.15, 0.025);
  c3->cd(1);
  handsomeTH1(meanRjg[1],1);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= newYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)
  //  tempR->Draw();
  TH1D* tempJ = new TH1D("tempJ",";p_{T}^{#gamma}; <p_{T}^{Jet}>",10000,40,130);
  tempJ->Reset();
  handsomeTH1(tempJ,0);
  tempJ->SetAxisRange(40.01,109.99,"Y");
  tempJ->SetAxisRange(40.,109.99,"X");
  tempJ->DrawCopy();
  tempJ->SetAxisRange(40.01,109.99,"X");
  drawSys(meanJetPt[5], meanJetPtSys[5], newYellow);
  drawSys(meanJetPt[7], meanJetPtSys[1], kGreen,3001);
  //  handsomeTH1(meanJetPt[5],9,1,34);
  handsomeTH1(meanJetPt[5],2,1,34);
  handsomeTH1(meanJetPt[6],1,1,25);
  handsomeTH1(meanJetPt[7],1,1);
  meanJetPt[6]->DrawCopy("same");
  meanJetPt[7]->DrawCopy("same");
  meanJetPt[5]->DrawCopy("same");
  if ( 1==1 ) {
    TLegend *ly = new TLegend(0.53,0.18,0.88,0.4,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanJetPt[5],"pPb DATA","p");
    ly->AddEntry(meanJetPt[7],"pp DATA (2.76 TeV)","p");
    ly->AddEntry(meanJetPt[6],"PYTHIA+HIJING","p");
    ly->Draw();
  }
  drawCMSpPbDist(0.2,0.9);

  
  c3->cd(3);
  handsomeTH1(meanJetPt[1],1,1,21);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= newYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)
  tempJ->Draw();
  drawSys(meanJetPt[3], meanJetPtSys[3]);
  drawSys(meanJetPt[1], meanJetPtSys[1], kGreen,3001);
  handsomeTH1(meanJetPt[3],2 );
  meanJetPt[1]->Draw("same");
  meanJetPt[3]->Draw("same");
  if ( 1==1 ){
    TLegend *ly = new  TLegend(0.58,0.18,0.93,0.4,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanJetPt[3],"PbPb 0-30%","p");
    ly->AddEntry(meanJetPt[1],"pp (smeared)","p");
    ly->Draw();
  }
  drawCMSppPbPbDist(0.1,0.9);

  c3->cd(2);
  tempJ->Draw();
  drawSys(meanJetPt[2], meanJetPtSys[2], kGreen,3001);
  drawSys(meanJetPt[4], meanJetPtSys[4]);
  //  meanJetPt[2]->SetMarkerStyle(25);
  meanJetPt[2]->Draw("same");
  handsomeTH1(meanJetPt[4],2 );
  //  meanJetPt[4]->SetMarkerStyle(24);
  meanJetPt[4]->Draw("same");
  if ( 1==1 ){
    TLegend *ly = new  TLegend(0.58,0.18,0.93,0.4,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanJetPt[4],"PbPb 30-100%","p");
    ly->AddEntry(meanJetPt[2],"pp (smeared)","p");
    ly->Draw();
  }
  drawCMSppPbPbDist(0.1,0.9);
  c3->SaveAs("pT_dependence_jetPt_pp_pbpb.pdf");
  c3->SaveAs("pT_dependence_jetPt_pp_pbpb.gif");
  //c3->SaveAs("pT_dependence_jetPt_pp_pbpb.png");


  // mean xjg
  TCanvas* c7; 
  if(!drawSinglePanels)
  {
    c7 = new TCanvas("c7","",1300,500);
    makeMultiPanelCanvas(c7,3,1,0.0,0.0, 0.15, 0.15, 0.025);
  }
  else
  {
    c7 = new TCanvas("c7","",1450,500);
    c7->Divide(3,1);
    //makeMultiPanelCanvas(c7,3,1,0.2,0.2, 0.15, 0.15, 0.025);
  }
  c7->cd(3);
  handsomeTH1(meanXjg[1],1,1,24);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= newYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)
  TH1D* tempX = new TH1D("tempX",";p_{T}^{#gamma} (GeV);<X_{J#gamma}>;",10000,40,130);
  tempX->Reset();
  handsomeTH1(tempX,0);
  tempX->SetAxisRange(0.6,1.1,"Y");
  tempX->SetAxisRange(40.01,109.99,"X");
  tempX->GetYaxis()->SetNdivisions(606);
  tempX->Draw();
  drawSys(meanXjg[3], meanXjgSys[3]);
  drawSys(meanXjg[1], meanXjgSys[1], kGreen,3001);
  //  meanXjg[1]->SetMarkerStyle(21);
  handsomeTH1(meanXjg[1],1,1,21);
  meanXjg[1]->DrawCopy("same");
  handsomeTH1(meanXjg[3],2,1,20);
  meanXjg[3]->DrawCopy("same");
  meanXjg[1]->SetFillStyle(3001);
  meanXjg[1]->SetFillColor(kGreen);
  meanXjg[3]->SetFillColor(90);
  meanXjg[3]->SetFillStyle(1001);
  meanXjg[1]->SetLineColor(0);
  meanXjg[3]->SetLineColor(0);

  Float_t xpos = 0.022;
  if(drawSinglePanels)
    xpos = 0.15;
  if ( 1==1 ){
    TLegend *ly = new TLegend(xpos,0.1861745,0.578901,0.3788434,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanXjg[3],"PbPb 0-30%","fp");
    ly->AddEntry(meanXjg[1],"Smeared pp reference","fp");
    ly->Draw();
  }
  drawCMSppPbPbDist(0.6,0.9);


  c7->cd(2);
  tempX->Draw();
  drawSys(meanXjg[4], meanXjgSys[4]);
  drawSys(meanXjg[2], meanXjgSys[2], kGreen,3001);
  //  meanXjg[2]->SetMarkerStyle(25);
  handsomeTH1(meanXjg[2],1,1,25);
  meanXjg[2]->DrawCopy("same");
  handsomeTH1(meanXjg[4],2,1,24 );
  //  meanXjg[4]->SetMarkerStyle(24);
  meanXjg[4]->DrawCopy("same");
  meanXjg[2]->SetFillStyle(3001);
  meanXjg[2]->SetFillColor(kGreen);
  meanXjg[4]->SetFillColor(90);
  meanXjg[4]->SetFillStyle(1001);
  meanXjg[2]->SetLineColor(0);
  meanXjg[4]->SetLineColor(0);

  if ( 1==1 ){
    TLegend *ly = new TLegend(xpos,0.1861745,0.578901,0.3788434,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanXjg[4],"PbPb 30-100%","fp");
    ly->AddEntry(meanXjg[2],"Smeared pp reference","fp");
    ly->Draw();
  }
  drawCMSppPbPbDist(0.6,0.9);

  c7->cd(1);
  tempX->SetAxisRange(40.0,109.99,"X");
  tempX->DrawCopy();
  tempX->SetAxisRange(40.01,109.99,"X");
  drawSys(meanXjg[5], meanXjgSys[5], newYellow);
  drawSys(meanXjg[7], meanXjgSys[2], kGreen, 3001);
  //  handsomeTH1(meanXjg[5],9,1,34);
  handsomeTH1(meanXjg[5],2,1,34);
  handsomeTH1(meanXjg[6],1,1,25);
  handsomeTH1(meanXjg[7],1,1);
  meanXjg[6]->DrawCopy("same");
  meanXjg[7]->DrawCopy("same");
  meanXjg[5]->DrawCopy("same");
  meanXjg[7]->SetFillStyle(3001);
  meanXjg[7]->SetFillColor(kGreen);
  meanXjg[5]->SetFillColor(90);
  meanXjg[5]->SetFillStyle(1001);
  meanXjg[7]->SetLineColor(0);
  meanXjg[5]->SetLineColor(0);

  if ( 1==1 ) {
    TLegend *ly = new TLegend(0.1722123,0.1861,0.4788343,0.3788,NULL,"brNDC");
    easyLeg(ly);
    ly->AddEntry(meanXjg[5],"pPb DATA","fp");
    ly->AddEntry(meanXjg[7],"pp DATA (2.76 TeV)","fp");    
    ly->AddEntry(meanXjg[6],"PYTHIA+HIJING","p");
    ly->Draw();
  }
  drawCMSpPbDist(0.65,0.90);
  
  c7->SaveAs("pT_dependence_meanXjg_pp_pbpb.pdf");
  c7->SaveAs("pT_dependence_meanXjg_pp_pbpb.gif");
  //c7->SaveAs("pT_dependence_meanXjg_pp_pbpb.png");

  // TCanvas* c10 = new TCanvas("c10","",1200,350);
  // makeMultiPanelCanvas(c10,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  // for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
  //   c10->cd(ipt);

  //   hTempPt->SetAxisRange(20,200,"X");
  //   hTempPt->SetAxisRange(0,2.5,"Y");
  //   hTempPt->SetYTitle("Yield^{JeT} Ratio");
  //   handsomeTH1(hTempPt,0);
  //   hTempPt->DrawCopy();
  //   IaaRatio[4][ipt] = (TH1D*)Iaa[4][ipt]->Clone(Form("%s_ratio",Iaa[4][ipt]->GetName()) );
  //   IaaRatio[4][ipt]->Divide(Iaa[2][ipt]);
  //   IaaRatioSys[4][ipt] = mergeSys( IaaSys[2][ipt], IaaSys[4][ipt]) ;

  //   drawSys(IaaRatio[4][ipt], IaaRatioSys[4][ipt], newYellow);
  //   jumSun(20,1,200,1);
  //   handsomeTH1(IaaRatio[4][ipt],2);
  //   IaaRatio[4][ipt]->SetMarkerStyle(24);
  //   IaaRatio[4][ipt]->Draw("same");
  //   double dx1=0.15;
  //   drawText(Form("p_{T}^{#gamma} > %dGeV ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);//yeonju 130823
  //   drawText(Form("(PbPb)/(pp smeared)  30-100%%"), 0.12+dx1+0.05,0.69,1,15);//yeonju 130823
  // }

  // c10->SaveAs("pT_dependence_iAA_ratio2.pdf");



}
Beispiel #20
0
void TrkClosure(
    int anaMode=0, // 0=pt, 1=eta, 2=dphi, 3=xi
    TString outdir="fig/trkcorrv14_closure"
)
{
    TH1::SetDefaultSumw2();
    gSystem->mkdir(outdir,kTRUE);

    bool doCorr=true;
    float maxEta=2.4;
    float ptmin=0.5,ptmax=200;
    TString mod="Forest2_MergedGeneral";
    TrackingCorrections trkCorr("Forest2STAv14",mod);
    trkCorr.AddSample("trkcorr/IterTrkCorrv14XSec/IterTrkCorrv14XSec_hy18dj80to100_akPu3Calo_100_-1_-1000_genJetMode0.root",80);
    trkCorr.Init();

//   TFile * inf = new TFile("output_hy18dj100_fv27_ntv1_corrv14_akPu3PF_100_-1_-1000_saveTrk1_jmin100_tmin1_genJetMode0.root");
    TFile * inf = new TFile("output_hy18dj80_fv27_ntv1_corrv14_akPu3PF_100_-1_-1000_saveTrk1_jmin100_tmin1_genJetMode0.root");
//    TFile * inf = new TFile("output_sigdj80_fv27_ntv1_akPu3PF_100_-1_-1000_saveTrk1_jmin100_tmin1_genJetMode0_corrhi.root");
//    TFile * inf = new TFile("output_sigdj80_fv27_ntv1_akPu3PF_100_-1_-1000_saveTrk1_jmin100_tmin1_genJetMode0_corrppv14jetfinexsec.root");
//     TFile * inf = new TFile("output_sigdj80_fv27_ntv1_corrv14_akPu3PF_100_-1_-1000_saveTrk1_jmin100_tmin1_genJetMode0.root");
    TTree * t = (TTree*)inf->Get("tgj");

    //////////////////////////////////////////
    // Analysis Setup
    //////////////////////////////////////////
    TString tag=Form("trkClos%d_0to12_jpt100_pthat80",anaMode);
    TCut sel = "cBin<12&&pt1>100";
//     TString tag=Form("trkClos%d_pp_jpt100_pthat80",anaMode);
//     TCut sel = "pt1>100";
    TCut genpSel = "";
    TCut trkSel = "";
//     TCut genpSel = "simAsso==1||simAsso==2";
//     TCut trkSel = "trkAsso==1||trkAsso==2";
    TString trkWt = "trkWt";

    float nEvt = t->GetEntries(sel);
    cout << sel << ": " << nEvt << " events" << endl;

    Compare cmp("cmp","");
    TH1D * hGenp, *hTrk, *hTrkCorr;
    float xmin=1, xmax=119.9;
    bool doLogx=true, doLogy=true;
    TString genVar, trkVar;
    TCut finalGenSel,finalTrkSel;
    if (anaMode==0) {
        TH1D * hPtBin = (TH1D*)trkCorr.ptBin_->Clone("hPtBin");
        hPtBin->Reset();
        hPtBin->SetAxisRange(0.5,179.9,"X");
        hGenp = (TH1D*)trkCorr.ptBin_->Clone("hGenp");
        hTrk = (TH1D*)trkCorr.ptBin_->Clone("hTrk");
        hTrkCorr = (TH1D*)trkCorr.ptBin_->Clone("hTrkCorr");
        cmp.Legend(0.24,0.23,0.7,0.4);
        cmp.leg->AddEntry(hTrk,Form("|#eta| < %.1f",maxEta),"");
        tag += Form("_eta%.0f",maxEta*10);
        genVar="simPt";
        trkVar="trkPt";
        finalGenSel = sel&&genpSel&&Form("abs(simEta)<%.2f",maxEta);
        finalTrkSel = sel&&trkSel&&Form("abs(trkEta)<%.2f",maxEta);
    } else if (anaMode==1) {
        TH1D * hEtaBin = (TH1D*)trkCorr.etaBin_->Clone("hEtaBin");
        hEtaBin->Reset();
        hGenp = (TH1D*)hEtaBin->Clone("hGenp");
        hTrk = (TH1D*)hEtaBin->Clone("hTrk");
        hTrkCorr = (TH1D*)hEtaBin->Clone("hTrkCorr");
        doLogx=false;
        doLogy=false;
        cmp.Legend(0.19,0.76,0.65,0.93);
        cmp.leg->AddEntry(hTrk,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax),"");
        tag += Form("_pt%.0f",ptmin);
        genVar="simEta";
        trkVar="trkEta";
        finalGenSel = sel&&genpSel&&Form("simPt>=%.2f&&simPt<%.2f",ptmin,ptmax);
        finalTrkSel = sel&&trkSel&&Form("trkPt>=%.2f&&trkPt<%.2f",ptmin,ptmax);
    } else if (anaMode==2) {
        TH1D * hBin = new TH1D("hBin",";#Delta#phi(trk,jet1)",25,0,3.14159);
        hGenp = (TH1D*)hBin->Clone("hGenp");
        hTrk = (TH1D*)hBin->Clone("hTrk");
        hTrkCorr = (TH1D*)hBin->Clone("hTrkCorr");
        doLogx=false;
        doLogy=true;
        cmp.Legend(0.19,0.76,0.65,0.93);
        cmp.leg->AddEntry(hTrk,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax),"");
        tag += Form("_pt%.0f",ptmin);
        genVar="acos(cos(simPhi-phi1))";
        trkVar="acos(cos(trkPhi-phi1))";
        finalGenSel = sel&&genpSel&&Form("simPt>=%.2f&&simPt<%.2f",ptmin,ptmax);
        finalTrkSel = sel&&trkSel&&Form("trkPt>=%.2f&&trkPt<%.2f",ptmin,ptmax);
    } else if (anaMode==3) {
        TH1D * hBin = new TH1D("hBin",";#xi=1/ln(z)",12,0,6);
        hGenp = (TH1D*)hBin->Clone("hGenp");
        hTrk = (TH1D*)hBin->Clone("hTrk");
        hTrkCorr = (TH1D*)hBin->Clone("hTrkCorr");
        doLogx=false;
        doLogy=false;
        cmp.Legend(0.19,0.76,0.65,0.93);
        cmp.leg->AddEntry(hTrk,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax),"");
        tag += Form("_pt%.0f",ptmin);
        genVar="log(pt1/simPt)";
        trkVar="log(pt1/trkPt)";
        finalGenSel = sel&&genpSel&&Form("simPt>=%.2f&&simPt<%.2f&&(simAsso==1||simAsso==2)",ptmin,ptmax);
        finalTrkSel = sel&&trkSel&&Form("trkPt>=%.2f&&trkPt<%.2f&&(trkAsso==1||trkAsso==2)",ptmin,ptmax);
    }
    if (anaMode>0) {
        xmin= hGenp->GetBinLowEdge(1);
        xmax= hGenp->GetBinLowEdge(hGenp->GetNbinsX());
    }

    // Legend
    cmp.leg->AddEntry(hTrk,"Raw Trk","p");
    if (doCorr) cmp.leg->AddEntry(hTrkCorr,"Corr. Trk","p");
    cmp.leg->AddEntry(hGenp,"Gen. Particle","l");

    //////////////////////////////////////////
    // Run Analysis
    //////////////////////////////////////////
    cout << genVar << ": " << finalGenSel << endl;
    cout << trkVar << ": " << finalTrkSel << endl;
    if (doCorr) cout << "Corr: " << (finalTrkSel)*trkWt << endl;
    t->Draw(genVar+">>hGenp",finalGenSel,"goff");
    t->Draw(trkVar+">>hTrk",finalTrkSel,"goff");
    if (doCorr) t->Draw(trkVar+">>hTrkCorr",(finalTrkSel)*trkWt);

    hGenp->Scale(1./nEvt);
    hTrk->Scale(1./nEvt);
    hTrkCorr->Scale(1./nEvt);

    //////////////////////////////////////////
    // Draw
    //////////////////////////////////////////
    TCanvas * c2 = new TCanvas("c2","c2",800,400);
    c2->Divide(2,1);
    c2->cd(1);
    hGenp->SetLineColor(2);
    hTrk->SetMarkerStyle(kOpenCircle);
    normHist(hGenp,-1,true);
    normHist(hTrk,-1,true);
    normHist(hTrkCorr,-1,true);
    if (doLogx) gPad->SetLogx();
    if (doLogy) gPad->SetLogy();
    else hGenp->SetAxisRange(0,hGenp->GetMaximum()*1.4,"Y");
    if (anaMode==0) hGenp->SetAxisRange(xmin,xmax,"X");
    hGenp->Draw("hist");
    hTrk->Draw("sameE");
    if (doCorr) hTrkCorr->Draw("sameE");
    cmp.leg->Draw();

    c2->cd(2);
    TH1D * hTrkRat = (TH1D*)hTrk->Clone("hTrkRat");
    hTrkRat->Divide(hGenp);
    TH1D * hTrkCorrRat = (TH1D*)hTrkCorr->Clone("hTrkCorrRat");
    if (doCorr) hTrkCorrRat->Divide(hGenp);
    if (doLogx) gPad->SetLogx();
    if (anaMode==0) hTrkRat->SetAxisRange(xmin,xmax,"X");
    hTrkRat->SetAxisRange(0.,2,"Y");
    TLine * l1 = new TLine(xmin,1,xmax,1);
    l1->SetLineStyle(2);
    hTrkRat->Draw("E");
    l1->Draw();
    if (doCorr) hTrkCorrRat->Draw("sameE");

    c2->Print(Form("%s/%s.gif",outdir.Data(),tag.Data()));
    c2->Print(Form("%s/%s.pdf",outdir.Data(),tag.Data()));
    c2->Print(Form("%s/%s.C",outdir.Data(),tag.Data()));
}
Beispiel #21
0
void HLTEffvJEt(
               TString infname="/d100/velicanu/tmp/hiexp-hirun2011-r181611-reco-v1-collisionEvents_lowerSC_autohlt.root"
               )
{
   TH1::SetDefaultSumw2();
   TFile * inf = new TFile(infname);
   
   TTree * t = (TTree*)inf->Get("hltanalysis/HltTree");
   t->AddFriend("skim=skimanalysis/HltTree");
   t->AddFriend("icPu5JetAnalyzer/t");
   //t->AddFriend("akPu3PFJetAnalyzer/t");
   
   float ptmax=200;
   TProfile * h55 = new TProfile("h55","",50,0,ptmax);
   TProfile * h65 = new TProfile("h65","",50,0,ptmax);
   TProfile * h80 = new TProfile("h80","",50,0,ptmax);
   TProfile * h95 = new TProfile("h95","",50,0,ptmax);
   TProfile * h55_55 = new TProfile("h55_55","",50,0,ptmax);
   TProfile * h65_55 = new TProfile("h65_55","",50,0,ptmax);
   
   TCut sel = "HLT_HIMinBiasHfOrBSC_v1&&skim.pcollisionEventSelection";
   TString tag = "Run181611";
   
   TCanvas * cchk = new TCanvas("cchk","cchk",500,500);
   t->Draw("L1EtTot",sel,"");
   
   t->Draw("HLT_HIJet55_v1:jtpt[0]>>h55",sel,"profgoff");
   t->Draw("HLT_HIJet65_v1:jtpt[0]>>h65",sel,"profgoff");
   t->Draw("HLT_HIJet80_v1:jtpt[0]>>h80",sel,"profgoff");
   t->Draw("HLT_HIJet95_v1:jtpt[0]>>h95",sel,"profgoff");
   t->Draw("HLT_HIDiJet55_v1:jtpt[0]>>h55_55",sel&&"jtpt[1]>57","profgoff");
   t->Draw("HLT_HIJet65_Jet55_v1:jtpt[0]>>h65_55",sel&&"jtpt[1]>57","profgoff");
   
   TCanvas * c2 = new TCanvas("c2","c2",500,500);
   TH1D * hFrame = (TH1D*)h55->Clone("hFrame");
   hFrame->SetAxisRange(0,150,"X");
   hFrame->SetAxisRange(0,1.6,"Y");
   hFrame->GetXaxis()->SetNdivisions(505);
   hFrame->GetXaxis()->CenterTitle();
   hFrame->GetYaxis()->CenterTitle();
   hFrame->SetTitle(";Leading Reco Jet p_{T} (GeV/c);HLT #epsilon");
   
   h65->SetMarkerStyle(kOpenCircle);
   h65->SetMarkerColor(kBlue);
   h80->SetMarkerStyle(kOpenSquare);
   h80->SetMarkerColor(kGreen+2);
   h95->SetMarkerStyle(kOpenTriangleUp);
   h95->SetMarkerColor(kOrange+2);
   h55_55->SetMarkerStyle(kOpenDiamond);
   
   hFrame->Draw();
   h55->Draw("sameE");
   h65->Draw("sameE");
   h80->Draw("sameE");
   h95->Draw("samep");
   h55_55->Draw("sameE");
   
   TLine * l = new TLine(0,1,150,1);
   l->SetLineStyle(2);
   l->Draw();
	
   TLegend *leg = new TLegend(0.4,0.71,0.88,0.93);
   leg->SetFillStyle(0);
   leg->SetBorderSize(0);
   leg->SetTextSize(0.035);
   leg->AddEntry(h55,"MinBias "+tag,"");
   leg->AddEntry(h55,"ICPu5","");
   leg->AddEntry(h55,"HLT_HIJet55_v1","p");
   leg->AddEntry(h65,"HLT_HIJet65_v1","p");
   leg->AddEntry(h80,"HLT_HIJet80_v1","p");
   leg->AddEntry(h95,"HLT_HIJet95_v1","p");
   leg->AddEntry(h55_55,"HLT_HIDiJet55_v1","p");
   leg->Draw();
   
   c2->Print(Form("out/HLTJetEffvJEt_%s.gif",tag.Data()));
}
Beispiel #22
0
void comparePhi(double ajMin=0,double ajMax=1)
{
    char *title="";
    TFile *inf = new TFile("ntv3_data50v2_djcalo_100_50.root");
    TTree *tData = (TTree*) inf->FindObjectAny("ntjt");
    TFile *inf2 = new TFile("ntv3_dj_HyUQ80v3_djcalo_100_50.root");
    TTree *tMC = (TTree*) inf2->FindObjectAny("ntjt");

    const int nBin = 10;
    double delta = 0.0; //shift
    double Bins[nBin+1];
    double BinsMC[nBin+1];
    for (int i=0; i<nBin+1; i++)
    {
        Bins[i]=-PI+2*PI/(double)nBin*i;
        BinsMC[i]=-PI+2*PI/(double)nBin*i+delta;
        cout <<Bins[i]<<endl;
    }



    TCanvas *c = new TCanvas("c","",600,600);

    TH1D *p = new TH1D("p","",nBin,BinsMC);
    TH1D *p2 = new TH1D("p2","",nBin,BinsMC);
    p->Sumw2();
    p2->Sumw2();

    TCut evtCut = Form("Aj>%f&&Aj<%f&&nljet>120&&abs(nljetacorr)<1.6&&aljet>50&&abs(aljetacorr)<1.6&&!maskEvt&&cent<30&&abs(jdphi)>2./3.*3.14159",ajMin,ajMax);

    tMC->Draw("nljphi>>p",evtCut*"weight");
    tData->Draw("nljphi>>p2",evtCut);


    p->SetMarkerStyle(20);
    p2->SetMarkerStyle(25);
    p->Scale(1./p->Integral());
    p2->Scale(1./p2->Integral());
    p->SetAxisRange(0,0.25,"Y");
    p->Draw();
    p2->SetMarkerColor(2);
    p2->SetLineColor(2);
    p2->Draw("same");

    p->SetXTitle("#phi_{Leading Jet}");
    p->SetYTitle("Event fraction");

// ====================
    TLegend *leg = new TLegend(0.45,0.68,0.92,0.9);
    leg->SetFillStyle(0);
    leg->SetBorderSize(0);
    leg->SetTextFont(63);
    leg->SetTextSize(16);
    leg->AddEntry("p",Form("%.2f < A_{J} < %.2f",ajMin,ajMax),"");
    leg->AddEntry("p","PYTHIA + HYDJET","pl");
    leg->AddEntry("p2","Data","pl");
    leg->Draw();

    c->SaveAs(Form("compareJetPhi-%.2f-%.2f.gif",ajMin,ajMax));
    c->SaveAs(Form("compareJetPhi-%.2f-%.2f.eps",ajMin,ajMax));


    TCanvas *c2 = new TCanvas("c2","",600,0,600,600);
    TH1D *hRatio = (TH1D*)p->Clone();
    hRatio->SetName("hRatio");
    hRatio->Divide(p2);
    hRatio->SetAxisRange(0.5,3,"Y");
    hRatio->SetYTitle("MC / Data");
    hRatio->Draw();

    TLine *l = new TLine(Bins[0],1,PI,1);
    l->Draw();

    c2->SaveAs(Form("compareJetPhiRatio-%.2f-%.2f.gif",ajMin,ajMax));
    c2->SaveAs(Form("compareJetPhiRatio-%.2f-%.2f.eps",ajMin,ajMax));

}
void drawSys_merged() {
  //  TH1::SetDefaultSumw2();
    gStyle -> SetOptStat(0);
    const int kPPcentral = 1;
    const int kPPperipheral =2 ;
    const int kHIcentral =  3;
    const int kHIperipheral = 4;
    const int kPADATA = 5;
    const int kPAMC = 6;

  TH1D* dNdJetPt[7][5]; // [collision] [ ptbin]  [Before/After variation]
  TH1D* dNdJetPtSys[7][5]; // [collision] [ ptbin]  [Before/After variation]
  TH1D* dNdJetPtSysIaa[7][5]; // [collision] [ ptbin]  [Before/After variation]
  TH1D* meanJetPt[7];   // [collision] [Before/After variation]
  TH1D* meanJetPtSys[7];   // [collision] [Before/After variation]
  TH1D* meanRjg[7];
  TH1D* meanRjgSys[7];
  
  TH1D* bmeanJetPt[7];   // [collision] [Before/After variation]
  TH1D* bmeanJetPtSys[7];   // [collision] [Before/After variation]
  TH1D* bmeanRjg[7];
  TH1D* bmeanRjgSys[7];
  
  TFile * f = new TFile("../resultHistograms_ppSmeared10030.root");
  bmeanJetPt[1]  =(TH1D*)f->Get(Form("meanJetPt_pp"));
  bmeanRjg[1]  =(TH1D*)f->Get(Form("meanRjg_pp"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPt[1][ipt] = (TH1D*)f->Get(Form("dNdJetPt_pp_ptBin%d", ipt ));
  }  

  f   = new TFile("../resultHistograms_ppSmeared13099.root");
  bmeanJetPt[2]  =(TH1D*)f->Get(Form("meanJetPt_pp"));
  bmeanRjg[2]  =(TH1D*)f->Get(Form("meanRjg_pp"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPt[2][ipt] = (TH1D*)f->Get(Form("dNdJetPt_pp_ptBin%d", ipt ));
  }  
  
  // pbpb
  f =   new TFile("../resultHistograms_jetResCorrection.root");
  bmeanJetPt[3]  =(TH1D*)f->Get(Form("meanJetPt_pbpb_centralityBin1"));
  bmeanRjg[3]  =(TH1D*)f->Get(Form("meanRjg_pbpb_centralityBin1"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPt[3][ipt] = (TH1D*)f->Get(Form("dNdJetPt_pbpb_centralityBin1_ptBin%d", ipt ));
  }
  bmeanJetPt[4]  =(TH1D*)f->Get(Form("meanJetPt_pbpb_centralityBin2"));
  bmeanRjg[4]  =(TH1D*)f->Get(Form("meanRjg_pbpb_centralityBin2"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPt[4][ipt] = (TH1D*)f->Get(Form("dNdJetPt_pbpb_centralityBin2_ptBin%d", ipt ));
  }
  // pPb
  f =   new TFile("../resultHistograms_jetResCorrection.root");
  bmeanJetPt[5]  =(TH1D*)f->Get(Form("meanJetPt_ppb"));
  bmeanRjg[5]  =(TH1D*)f->Get(Form("meanRjg_ppb"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPt[5][ipt] = (TH1D*)f->Get(Form("dNdJetPt_ppb_ptBin%d", ipt ));
  }
  
  f =   new TFile("../resultHistograms_MC_recoIsoPhoton.root");
  bmeanJetPt[6]  =(TH1D*)f->Get(Form("meanJetPt_ppb"));
  bmeanRjg[6]  =(TH1D*)f->Get(Form("meanRjg_ppb"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPt[6][ipt] = (TH1D*)f->Get(Form("dNdJetPt_ppb_ptBin%d", ipt ));
  }  
  
  
  TFile* fSys = new TFile("../merged/relativeSys_merged.root");
  
  bmeanJetPtSys[1]  =(TH1D*)fSys->Get("meanJetPt_pp_uncertainty_merged");
  bmeanRjgSys[1]  =(TH1D*)fSys->Get(Form("meanRjg_pp_uncertainty_merged"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPtSysIaa[1][ipt] = (TH1D*)fSys->Get(Form("dNdJetPt_IaaBin_pp_ptBin%d_uncertainty_merged",  ipt ));
  }
  bmeanJetPtSys[2] = (TH1D*)bmeanJetPtSys[1]->Clone(Form("%s_2",bmeanJetPtSys[1]->GetName()));
  bmeanRjgSys[2] = (TH1D*)bmeanRjgSys[1]->Clone(Form("%s_2",bmeanRjgSys[1]->GetName()));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPtSysIaa[2][ipt] = (TH1D*)dNdJetPtSysIaa[1][ipt]->Clone(Form("%s_2",dNdJetPtSysIaa[1][ipt]->GetName()));
  }
  bmeanJetPtSys[3]  =(TH1D*)fSys->Get("meanJetPt_pbpb_centralityBin1_uncertainty_merged");
  bmeanRjgSys[3]  =(TH1D*)fSys->Get(Form("meanRjg_pbpb_centralityBin1_uncertainty_merged"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPtSysIaa[3][ipt] = (TH1D*)fSys->Get(Form("dNdJetPt_IaaBin_pbpb_centralityBin1_ptBin%d_uncertainty_merged",  ipt ));
  }
  bmeanJetPtSys[4]  =(TH1D*)fSys->Get("meanJetPt_pbpb_centralityBin2_uncertainty_merged");
  bmeanRjgSys[4]  =(TH1D*)fSys->Get(Form("meanRjg_pbpb_centralityBin2_uncertainty_merged"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPtSysIaa[4][ipt] = (TH1D*)fSys->Get(Form("dNdJetPt_IaaBin_pbpb_centralityBin2_ptBin%d_uncertainty_merged",  ipt ));
  }
  bmeanJetPtSys[5]  =(TH1D*)fSys->Get("meanJetPt_ppb_uncertainty_merged");
  bmeanRjgSys[5]  =(TH1D*)fSys->Get(Form("meanRjg_ppb_uncertainty_merged"));
  for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
    dNdJetPtSysIaa[5][ipt] = (TH1D*)fSys->Get(Form("dNdJetPt_IaaBin_ppb_ptBin%d_uncertainty_merged",  ipt ));
  }


  
  // transplant the uncertainty  
  for ( int coll = 1 ; coll<=5 ; coll++) {
    for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
      dNdJetPtSys[coll][ipt] = (TH1D*) dNdJetPt[coll][ipt]->Clone(Form("dNdJetPtSys_coll%d_ipt%d",coll,ipt));
      dNdJetPtSys[coll][ipt]->Reset();
      for ( int ibin = 1 ; ibin<= dNdJetPtSys[coll][ipt]->GetNbinsX() ; ibin++) {
	float xx = dNdJetPtSys[coll][ipt]->GetBinCenter(ibin);
	float yy = dNdJetPtSysIaa[coll][ipt]->GetBinContent ( dNdJetPtSysIaa[coll][ipt]->FindBin(xx) );
	if ( yy>1 ) yy = 1;
	dNdJetPtSys[coll][ipt]->SetBinContent(ibin,yy);

      }
    }
  }

  for(int icoll=1; icoll<=6; icoll++){
      meanJetPt[icoll] = new TH1D(Form("%s_corrected", bmeanJetPt[icoll]->GetName()), "", nPtBin, ptBinPaDraw);
      meanRjg[icoll] = new TH1D(Form("%s_corrected", bmeanRjg[icoll]->GetName()), "", nPtBin, ptBinPaDraw);
      if(icoll<6){
          meanJetPtSys[icoll] = new TH1D(Form("%s_corrected", bmeanJetPtSys[icoll]->GetName()), "", nPtBin, ptBinPaDraw);
          meanRjgSys[icoll] = new TH1D(Form("%s_corrected", bmeanRjgSys[icoll]->GetName()), "", nPtBin, ptBinPaDraw);
      }
  }

  for(int icoll=1; icoll<=6; icoll++){ 
      meanPtHist(bmeanJetPt[icoll], meanJetPt[icoll]);    
      meanPtHist(bmeanRjg[icoll],  meanRjg[icoll]); 
      if(icoll<6){
          meanPtHist(bmeanJetPtSys[icoll],meanJetPtSys[icoll]) ;  
          meanPtHist(bmeanRjgSys[icoll], meanRjgSys[icoll]); 
      }
  } 

  // RJG!!
  TCanvas* c2 = new TCanvas("c1","",1000,500);
  c2->Divide(2,1);
  c2->cd(2);
  handsomeTH1(meanRjg[1],1);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= kYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)
  TH1D* tempR = new TH1D("tempR",";p_{T}^{#gamma};R_{j#gamma}",100,40,130);
  tempR->Reset();  
  handsomeTH1(tempR,0);
  tempR->SetAxisRange(0,1.2,"Y");
  tempR->Draw();
  drawSys(meanRjg[1], meanRjgSys[1], kGreen);
  drawSys(meanRjg[3], meanRjgSys[3]);
  meanRjg[1]->Draw("same");
  handsomeTH1(meanRjg[3],2 );
//  meanRjg[3]->SetMarkerStyle(24);
  meanRjg[3]->Draw("same");
  if ( 1==1 ){ 
    TLegend *ly = new  TLegend(0.4937249,0.262193,0.8493139,0.4740574,NULL,"brNDC");    
    easyLeg(ly,"2.76TeV");
    ly->AddEntry(meanRjg[3],"PbPb 0-30%","p");
    ly->AddEntry(meanRjg[1],"pp (smeared)","p");
    ly->Draw();
  }


  c2->cd(1);
  tempR->Draw();
  handsomeTH1(meanRjg[2],1 );
  drawSys(meanRjg[2], meanRjgSys[2], kGreen);
  drawSys(meanRjg[4], meanRjgSys[4]);
  meanRjg[2]->Draw("same");
  handsomeTH1(meanRjg[4],2 );
  meanRjg[4]->SetMarkerStyle(24);
  meanRjg[4]->Draw("same");
  if ( 1==1 ){ 
    TLegend *ly = new  TLegend(0.4937249,0.262193,0.8493139,0.4740574,NULL,"brNDC");    
    easyLeg(ly,"2.76TeV");
    ly->AddEntry(meanRjg[4],"PbPb 30-100%","p");
    ly->AddEntry(meanRjg[2],"pp (smeared)","p");
    ly->Draw();
  }
  c2->SaveAs("pT_depedence_rjg_pp_pbpb.pdf");

  
  TCanvas* c2pa = new TCanvas("c1pa","",500,500);
  handsomeTH1(meanRjg[1],1);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= kYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)                         
  //  tempR->Draw();
  TH1D* tempJ = new TH1D("tempJ",";p_{T}^{#gamma}; <p_{T}^{Jet}>",100,40,130);
  tempJ->Reset();
  handsomeTH1(tempJ,0);
  tempJ->SetAxisRange(0,100,"Y");
  tempJ->Draw();
  drawSys(meanJetPt[5], meanJetPtSys[5], kYellow);
  handsomeTH1(meanJetPt[5],2);
  handsomeTH1(meanJetPt[6],1);
  meanJetPt[5]->Draw("same");
  meanJetPt[6]->Draw("same");
  if ( 1==1 ) {
    TLegend *ly = new TLegend(0.4484643,0.3088445,0.9140673,0.50102941,NULL,"brNDC");
    easyLeg(ly,"5.02TeV pPb");
    ly->AddEntry(meanJetPt[5],"DATA","p");
    ly->AddEntry(meanJetPt[6],"PYTHIA+HIJING","p");
    ly->Draw();
  }
  c2pa->SaveAs("pT_dependence_rjg_pA_figure1.pdf");

  TCanvas* c3pa = new TCanvas("c3pa","",500,500);
  tempR->Draw();
  drawSys(meanRjg[5], meanRjgSys[5], kYellow);
  handsomeTH1(meanRjg[5],2);
  handsomeTH1(meanRjg[6],1);
  meanRjg[5]->Draw("same");
  meanRjg[6]->Draw("same");
  if ( 1==1 ) {
    TLegend *ly = new TLegend(0.4484643,0.3088445,0.9140673,0.50102941,NULL,"brNDC");
    easyLeg(ly,"5.02TeV pPb");
    ly->AddEntry(meanRjg[5],"DATA","p");
    ly->AddEntry(meanRjg[6],"PYTHIA+HIJING","p");
    ly->Draw();
  }  
  c3pa->SaveAs("pT_dependence_jetPt_pA_figure2.pdf");

  TCanvas* c3 = new TCanvas("c3","",1000,500);
  c3->Divide(2,1);
  c3->cd(2);
  handsomeTH1(meanJetPt[1],1);
  //  drawSys(TH1 *h,TH1 *sys, Int_t theColor= kYellow, Int_t fillStyle = -1, Int_t lineStyle = -1)                                                       
   tempJ->Draw();
  drawSys(meanJetPt[1], meanJetPtSys[1], kGreen);
  drawSys(meanJetPt[3], meanJetPtSys[3]);
  meanJetPt[1]->Draw("same");
  handsomeTH1(meanJetPt[3],2 );
  meanJetPt[3]->Draw("same");
  if ( 1==1 ){
    TLegend *ly = new  TLegend(0.4937249,0.262193,0.8493139,0.4740574,NULL,"brNDC");
    easyLeg(ly,"2.76TeV");
    ly->AddEntry(meanJetPt[3],"PbPb 0-30%","p");
    ly->AddEntry(meanJetPt[1],"pp (smeared)","p");
    ly->Draw();
  }
  
  c3->cd(1);
  tempJ->Draw();
  handsomeTH1(meanJetPt[2],1 );
//  meanJetPt[2]->Draw();
  drawSys(meanJetPt[2], meanJetPtSys[2], kGreen);
  drawSys(meanJetPt[4], meanJetPtSys[4]);
  meanJetPt[2]->Draw("same");
  handsomeTH1(meanJetPt[4],2 );
  meanJetPt[4]->SetMarkerStyle(24);
  meanJetPt[4]->Draw("same");
  if ( 1==1 ){
    TLegend *ly = new  TLegend(0.4937249,0.262193,0.8493139,0.4740574,NULL,"brNDC");
    easyLeg(ly,"2.76TeV");
    ly->AddEntry(meanJetPt[4],"PbPb 30-100%","p");
    ly->AddEntry(meanJetPt[2],"pp (smeared)","p");
    ly->Draw();
  }
  c3->SaveAs("pT_dependence_jetPt_pp_pbpb.pdf");
  
  TH1D* hTempPt = new TH1D("hTemp",";p_{T}^{#gamma} (GeV);",200,10,300);
  TCanvas* c5 = new TCanvas("c5","",1200,700);
  makeMultiPanelCanvas(c5,nPtBin,2,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
    c5->cd(ipt+nPtBin);
    // draw pp                                                                                                                                           
    hTempPt->SetXTitle("p_{T}^{Jet} (GeV)");
    hTempPt->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N}");
    hTempPt->SetAxisRange(10,150,"X");
    //        hTempPt->SetAxisRange(0,0.025,"Y");                                                                                                        
    hTempPt->SetAxisRange(0,0.07,"Y");
    handsomeTH1(hTempPt,0);
    hTempPt->DrawCopy();

    drawSys(dNdJetPt[1][ipt], dNdJetPtSys[1][ipt], kGreen);
    drawSys(dNdJetPt[3][ipt], dNdJetPtSys[3][ipt], kYellow);
    handsomeTH1(dNdJetPt[3][ipt],2);
    dNdJetPt[1][ipt]->Draw("same");
    dNdJetPt[3][ipt]->Draw("same");
    if ( ipt == 1 ) {
      TLegend *ly = new TLegend(0.4484643,0.6988445,0.9140673,0.9102941,NULL,"brNDC");
      easyLeg(ly,"2.76TeV");
      ly->AddEntry(meanJetPt[1],"PbPb 0-30%","p");
      ly->AddEntry(meanJetPt[3],"pp (smeared)","p");
      ly->Draw();
    }
 

    c5->cd(ipt);
    hTempPt->DrawCopy();

    drawSys(dNdJetPt[2][ipt], dNdJetPtSys[2][ipt], kGreen);
    drawSys(dNdJetPt[4][ipt], dNdJetPtSys[4][ipt], kYellow);
    handsomeTH1(dNdJetPt[4][ipt],2);
    dNdJetPt[4][ipt]->SetMarkerStyle(24);
    dNdJetPt[2][ipt]->Draw("same");
    dNdJetPt[4][ipt]->Draw("same");
    if ( ipt==1 ){
      TLegend *ly = new TLegend(0.4484643,0.5088445,0.9140673,0.75102941,NULL,"brNDC");
      easyLeg(ly,"2.76TeV");
      ly->AddEntry(meanJetPt[4],"PbPb 30-100%","p");
      ly->AddEntry(meanJetPt[2],"pp (smeared)","p");
      ly->Draw();
    }

    double dx1=0.15;
    if ( ipt == nPtBin )
      drawText(Form("p_{T}^{#gamma} > %dGeV, ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);//yeonju 130823                                           
    else
      drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.12+dx1,0.85,1,15);//yeonju 130823                       

    
  }
  c5->SaveAs("pT_dependence_jetPt_pp_pbpb_distribution.pdf");

  TCanvas* c5pa = new TCanvas("c5pa","",1200,350);
  makeMultiPanelCanvas(c5pa,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
    c5pa->cd(ipt);
    // draw pp                                                                                                                                           
    hTempPt->SetXTitle("p_{T}^{Jet} (GeV)");
    hTempPt->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N}");
    hTempPt->SetAxisRange(10,150,"X");
    //        hTempPt->SetAxisRange(0,0.025,"Y");                                                                                                        
    hTempPt->SetAxisRange(0,0.07,"Y");
    handsomeTH1(hTempPt,0);
    hTempPt->DrawCopy();

    drawSys(dNdJetPt[5][ipt], dNdJetPtSys[5][ipt], kYellow);
    handsomeTH1(dNdJetPt[5][ipt],2);
    dNdJetPt[6][ipt]->Draw("same");
    dNdJetPt[5][ipt]->Draw("same");
    if ( ipt == 1 ) {
      TLegend *ly = new TLegend(0.4855983,0.5529059,0.9512013,0.7645899,NULL,"brNDC");
      easyLeg(ly,"5.02TeV pPb");
      ly->AddEntry(meanJetPt[5],"Data","p");
      ly->AddEntry(meanJetPt[6],"PYTHIA+HIJING","p");
      ly->Draw();
    }
    double dx1=0.15;
    if ( ipt == nPtBin )
      drawText(Form("p_{T}^{#gamma} > %dGeV, ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);//yeonju 130823                                           
    else
      drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.12+dx1,0.85,1,15);//yeonju 130823                       
    
    
  }
  c5pa->SaveAs("pT_dependence_jetPt_pA_distribution.pdf");
  
  
  
}
Beispiel #24
0
//TF1* fit(Float_t varval, Float_t ibin, Int_t isMC, float NPpar[])
TF1* fit(Float_t varval, Float_t ibin, Int_t isMC, TString npfit)
{
  TString tMC;
  if(isMC==1) tMC="MC";
  else tMC="Data";
  TCanvas* c = new TCanvas(Form("c_%s_%.0f",tMC.Data(),ibin),"",600,600);
  TFile* infile = new TFile(Form("%s_%s_%s_%s_%.0f.root",infname.Data(),collisionsystem.Data(),varname.Data(),tMC.Data(),ibin));
  TH1D* h = (TH1D*)infile->Get("h");                    h->SetName(Form("h_%s_%.0f",tMC.Data(),ibin));
  TH1D* hMCSignal = (TH1D*)infile->Get("hMCSignal");    hMCSignal->SetName(Form("hMCSignal_%s_%.0f",tMC.Data(),ibin));

  //TString iNP=Form("TMath::Erf((x-%f)/%f)+1", NPpar[0], NPpar[1]);
  TString iNP = npfit;
  TF1* f = new TF1(Form("f_%s_%.0f",tMC.Data(),ibin),"[0]*([7]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]+[4]*x+[5]*("+iNP+")");

  f->SetParLimits(3,0,1e5);
  f->SetParLimits(4,-1000,0);
  f->SetParLimits(2,0.01,0.05);
  f->SetParLimits(8,0.01,0.05);
  f->SetParLimits(7,0,1);
  f->SetParLimits(5,0,1000);
  if(isMC) {
    f->SetParLimits(3,0,1e2);
    f->SetParLimits(4,-100,0);
  }

  f->SetParameter(0,setparam0);
  f->SetParameter(1,setparam1);
  f->SetParameter(2,setparam2);
  f->SetParameter(8,setparam3);
  f->FixParameter(1,fixparam1);
  f->FixParameter(5,0);
  h->GetEntries();

  hMCSignal->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  hMCSignal->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L m","",minhisto,maxhisto);

  f->FixParameter(1,f->GetParameter(1));
  f->FixParameter(2,f->GetParameter(2));
  f->FixParameter(7,f->GetParameter(7));
  f->FixParameter(8,f->GetParameter(8));
  f->ReleaseParameter(5);
  
  h->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"q","",minhisto,maxhisto);
  h->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  h->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%s_%.0f",tMC.Data(),ibin),"L m","",minhisto,maxhisto);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);

  TF1 *background = new TF1(Form("background_%s_%.0f",tMC.Data(),ibin),"[0]+[1]*x");
  background->SetParameter(0,f->GetParameter(3));
  background->SetParameter(1,f->GetParameter(4));
  background->SetLineColor(4);
  background->SetRange(minhisto,maxhisto);
  background->SetLineStyle(2);
  
  TF1 *Bkpi = new TF1(Form("fBkpi_%s_%.0f",tMC.Data(),ibin),"[0]*("+iNP+")");
  Bkpi->SetParameter(0,f->GetParameter(5));
  Bkpi->SetLineColor(kGreen+1);
  Bkpi->SetRange(minhisto,maxhisto);
  Bkpi->SetLineStyle(1);
  Bkpi->SetFillStyle(3004);
  Bkpi->SetFillColor(kGreen+1);

  TF1 *mass = new TF1(Form("fmass_%s_%.0f",tMC.Data(),ibin),"[0]*([3]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[3])*Gaus(x,[1],[4])/(sqrt(2*3.14159)*[4]))");
  mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(8));
  mass->SetParError(0,f->GetParError(0));
  mass->SetParError(1,f->GetParError(1));
  mass->SetParError(2,f->GetParError(2));
  mass->SetParError(7,f->GetParError(7));
  mass->SetParError(8,f->GetParError(8));
  mass->SetLineColor(2);

  h->SetXTitle("m_{#mu#muK} (GeV/c^{2})");
  h->SetYTitle("Entries / (5 MeV/c^{2})");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");
  Bkpi->Draw("same");
  background->Draw("same");   
  mass->SetRange(minhisto,maxhisto);
  mass->Draw("same");
  mass->SetLineStyle(2);
  mass->SetFillStyle(3004);
  mass->SetFillColor(2);
  f->Draw("same");

  Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
  Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
  
  std::cout<<"YIELD="<<yield<<std::endl;
  TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"B^{+} Signal","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  texCms->SetNDC();
  texCms->SetTextAlign(12);
  texCms->SetTextSize(0.04);
  texCms->SetTextFont(42);
  texCms->Draw();

  TLatex* texCol;
  if(collisionsystem=="pp"||collisionsystem=="PP") texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","pp"));
  else texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","PbPb"));
  texCol->SetNDC();
  texCol->SetTextAlign(32);
  texCol->SetTextSize(0.04);
  texCol->SetTextFont(42);
  texCol->Draw();

  TLatex* tex;

  if(ibin>0)
    {
      if(isLarger==1) tex = new TLatex(0.22,0.78,Form("%s > %.3f",vartex.Data(),varval));
      else tex = new TLatex(0.22,0.78,Form("%s < %.3f",vartex.Data(),varval));
    }
  else tex = new TLatex(0.22,0.78,Form("%s",_nominalcut.Data()));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->SetLineWidth(2);
  tex->Draw();

  tex = new TLatex(0.22,0.83,"|y| < 2.4");
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->SetLineWidth(2);
  tex->Draw();

  tex = new TLatex(0.22,0.73,Form("N_{B} = %.0f #pm %.0f",yield,yieldErr));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->SetLineWidth(2);
  tex->Draw();

  c->SaveAs(Form("plotFits/DMass_%s_%s_%s_%.0f.pdf",collisionsystem.Data(),varname.Data(),tMC.Data(),ibin));
  return mass;
}
void plotLeadingJet(int cbin,
		    TString infname,
		    TString pythia,
		    TString mix,
		    bool useWeight,
		    bool drawXLabel,
		    bool drawLeg)
{

  TString cut="et1>120 && et2>50 && dphi>2.5";
  TString cutpp="et1>120 && et2>50 && dphi>2.5";
  TString cstring = "";
  if(cbin==0) {
    cstring = "0-10%";
    cut+=" && bin>=0 && bin<4";
    cut+=" && ((et1-et2)/(et1+et2) > 0.3)";
  } else if (cbin==1) {
     cstring = "10-30%";
     cut+=" && bin>=4 && bin<12";
     cut+=" && ((et1-et2)/(et1+et2) > 0.3)";
  } else {
     cstring = "30-100%";
     cut+=" && bin>=12 && bin<40";
     cut+=" && ((et1-et2)/(et1+et2) > 0.3)";
  }
  
  // open the data file
  TFile *inf = new TFile(infname.Data());
  TTree *nt =(TTree*)inf->FindObjectAny("nt");

  // open the pythia (MC) file
  TFile *infPythia = new TFile(pythia.Data());
  TTree *ntPythia = (TTree*) infPythia->FindObjectAny("nt");

  // open the datamix file
  TFile *infMix = new TFile(mix.Data());
  TTree *ntMix =(TTree*)infMix->FindObjectAny("nt");


  // projection histogram
  TH1D *h = new TH1D("h","",10,60,135);
  TH1D *hPythia = new TH1D("hPythia","",10,60,135);
  TH1D *hDataMix = new TH1D("hDataMix","",10,60,135);
  nt->Draw("et2>>h",Form("(%s)",cut.Data())); 
   
  if (useWeight) {
    // use the weight value caluculated by Matt's analysis macro
    ntMix->Draw("et2>>hDataMix",Form("(%s)*weight",cut.Data())); 
  } else {
    // ignore centrality reweighting
    ntMix->Draw("et2>>hDataMix",Form("(%s)",cut.Data()));  
  }
    ntPythia->Draw("et2>>hPythia",Form("(%s)",cutpp.Data())); 
  // calculate the statistical error and normalize
  h->Sumw2();
  h->Scale(1./h->GetEntries());
  h->SetMarkerStyle(20);

  hPythia->Scale(1./hPythia->Integral(0,20));
  hPythia->SetLineColor(kBlue);
  hPythia->SetFillColor(kAzure-8);
  hPythia->SetFillStyle(3005);
   
  hPythia->SetStats(0);
  hPythia->Draw("hist");
  if(drawXLabel) hPythia->SetXTitle("Subleading Jet E_{T} (GeV)");

  hPythia->GetXaxis()->SetLabelSize(20);
  hPythia->GetXaxis()->SetLabelFont(43);
  hPythia->GetXaxis()->SetTitleSize(22);
  hPythia->GetXaxis()->SetTitleFont(43);
  hPythia->GetXaxis()->SetTitleOffset(1.5);
  hPythia->GetXaxis()->CenterTitle();

  hPythia->GetXaxis()->SetNdivisions(904,true);

  hPythia->SetYTitle("Event Fraction");

  hPythia->GetYaxis()->SetLabelSize(20);
  hPythia->GetYaxis()->SetLabelFont(43);
  hPythia->GetYaxis()->SetTitleSize(20);
  hPythia->GetYaxis()->SetTitleFont(43);
  hPythia->GetYaxis()->SetTitleOffset(2.5);
  hPythia->GetYaxis()->CenterTitle();

  hPythia->SetAxisRange(2E-3,3,"Y");
  hDataMix->SetAxisRange(2E-3,3,"Y");
  h->SetAxisRange(2E-3,3,"Y");


  h->Draw("same");

  hDataMix->Scale(1./hDataMix->Integral(0,20));
  hDataMix->SetLineColor(kRed);
  hDataMix->SetFillColor(kRed-9);
  hDataMix->SetFillStyle(3004);
  hDataMix->Draw("same");

  if(drawLeg){
     TLegend *t3=new TLegend(0.25,0.74,0.79,0.90);
    t3->AddEntry(h,"Pb+Pb  #sqrt{s}_{_{NN}}=2.76 TeV","pl");
    t3->AddEntry(hPythia,"PYTHIA","lf");
    t3->AddEntry(hDataMix,"embedded PYTHIA","lf");
    t3->SetFillColor(0);
    t3->SetBorderSize(0);
    t3->SetFillStyle(0);
    t3->SetTextFont(63);
    t3->SetTextSize(15);
    t3->Draw();
  }
  
}
Beispiel #26
0
TH1D * drawQual(TFile * inf, TCanvas * c, Int_t ic, Float_t ymin, Float_t ymax, Int_t doLog)
{
  c->Divide(3,1);
  c->cd(1);
  if (doLog==1) gPad->SetLogy();
  TH1D * hQual_precut_mc = (TH1D*)inf->FindObjectAny(Form("hTrkQual%dPreCut_mc80",ic));
  TH1D * hQual_precut_data = (TH1D*)inf->FindObjectAny(Form("hTrkQual%dPreCut_dataj35",ic));
  TH1D * hQual_mc = (TH1D*)inf->FindObjectAny(Form("hTrkQual%dPostCut_mc80",ic));
  TH1D * hQual_data = (TH1D*)inf->FindObjectAny(Form("hTrkQual%dPostCut_dataj35",ic));
  if (!hQual_precut_mc) cout << Form("hTrkQual%dPreCut_mc80 not found",ic) << endl;
  if (!hQual_precut_data) cout << Form("hTrkQual%dPreCut_dataj35 not found",ic) << endl;
  hQual_precut_mc->Scale(1./hQual_precut_mc->GetEntries());
  hQual_precut_data->Scale(1./hQual_precut_data->GetEntries());
  hQual_mc->Scale(1./hQual_precut_mc->GetEntries());
  hQual_data->Scale(1./hQual_precut_data->GetEntries());

  hQual_precut_mc->SetAxisRange(ymin,ymax,"Y");
  hQual_precut_mc->SetLineColor(2);
  hQual_precut_mc->SetLineStyle(2);
  hQual_mc->SetMarkerStyle(kOpenCircle);
  hQual_mc->SetMarkerColor(2);
  hQual_mc->SetLineColor(2);
  hQual_precut_data->SetLineStyle(2);
  hQual_precut_mc->Draw("hist");
  hQual_precut_data->Draw("same hist");
  hQual_mc->Draw("same E");
  hQual_data->Draw("same E");

  c->cd(2);
  gPad->SetLogy();
  TH1D * hPPt_precut_mc = inf->FindObjectAny(Form("hPPt_cut%d_mc80",ic-1));
  TH1D * hPPt_precut_data = inf->FindObjectAny(Form("hPPt_cut%d_dataj35",ic-1));
  TH1D * hPPt_mc = inf->FindObjectAny(Form("hPPt_cut%d_mc80",ic));
  TH1D * hPPt_data = inf->FindObjectAny(Form("hPPt_cut%d_dataj35",ic));

  hPPt_precut_mc->SetAxisRange(5e-5,2,"Y");
  hPPt_precut_mc->SetMarkerColor(2);
  hPPt_precut_mc->SetLineColor(2);
  hPPt_precut_mc->SetLineStyle(2);
  hPPt_precut_data->SetLineStyle(2);
  hPPt_mc->SetMarkerStyle(kOpenCircle);
  hPPt_mc->SetLineColor(2);
  hPPt_mc->SetMarkerColor(2);
  hPPt_precut_mc->Draw("hist");
  hPPt_precut_data->Draw("samehist");
  hPPt_mc->Draw("sameE");
  hPPt_data->Draw("sameE");

  c->cd(3);
  TH1D * hRatMc = hPPt_mc->Clone(Form("%s_rat",hPPt_mc->GetName()));
  hRatMc->Divide(hPPt_precut_mc);
  TH1D * hRatData = hPPt_data->Clone(Form("%s_rat",hPPt_data->GetName()));
  hRatData->Divide(hPPt_precut_data);
  hRatMc->SetAxisRange(0,1.1,"Y");
  hRatMc->SetMarkerStyle(kOpenCircle);
  hRatMc->SetMarkerColor(2);
  hRatMc->SetLineColor(2);
	hRatMc->SetLineStyle(1);
  hRatData->SetLineStyle(1);
	hRatMc->SetYTitle("(After Cut)/(Before Cut)");
  hRatMc->Draw("E");
  hRatData->Draw("sameE");

  return hPPt_data;
}
TF1* fitDstar(TTree* nt, TTree* ntMC, Float_t ptmin, Bool_t plotgenmatch)
{
  TCanvas* c = new TCanvas(Form("c_5p_%.0f",ptmin),"",600,600);
  TH1D* h = new TH1D(Form("h_5p_%.0f",ptmin),"",BINNUM,BINMIN,BINMAX);
  TH1D* hMCSignal = new TH1D(Form("hMCSignal_5p_%.0f",ptmin),"",BINNUM,BINMIN,BINMAX);
  TH1D* hMCSignalplot = new TH1D(Form("hMCSignalplot_5p_%.0f",ptmin),"",BINNUM,BINMIN,BINMAX);
  TH1D* hMCSwapped = new TH1D(Form("hMCSwapped_5p_%.0f",ptmin),"",BINNUM,BINMIN,BINMAX);
  TH1D* hMCSwappedplot = new TH1D(Form("hMCSwappedplot_5p_%.0f",ptmin),"",BINNUM,BINMIN,BINMAX);

  TF1* f = new TF1(Form("f_5p_%.0f",ptmin),"[0]*([4]*([6]*([12]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[12])*Gaus(x,[1],[11])/(sqrt(2*3.14159)*[11]))+(1-[6])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5]))+(1-[4])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3]))+[10]*((1-exp((0.13957-x)/[7]))*pow(x/0.13957,[8])+[9]*(x/0.13957-1))",BINMIN,BINMAX);
  nt->Project(Form("h_5p_%.0f",ptmin),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightdata[isData].Data(),seldata5p[isData].Data(),triggerselectiondata[isData].Data(),ptmin));
  ntMC->Project(Form("hMCSignal_5p_%.0f",ptmin),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightmc[isData].Data(),selmc5p[isData].Data(),triggerselectionmc[isData].Data(),ptmin));
  ntMC->Project(Form("hMCSwapped_5p_%.0f",ptmin),"Dmass-DtktkResmass",Form("%s*(%s&&%s&&Dpt>%f)",weightmc[isData].Data(),selswp5p[isData].Data(),triggerselectionmc[isData].Data(),ptmin));
  for(int ibin=0;ibin<BINNUM;ibin++) hMCSignalplot->SetBinContent(ibin+1,hMCSignal->GetBinContent(ibin+1));
  for(int ibin=0;ibin<BINNUM;ibin++) hMCSwappedplot->SetBinContent(ibin+1,hMCSwapped->GetBinContent(ibin+1));
  f->FixParameter(4,1.);
  f->FixParameter(1,0.145491);
  f->FixParameter(10,0);

  f->SetParLimits(0,0,1.e+5);
  f->SetParLimits(6,0,1.);
  f->SetParLimits(12,0,1.);
  f->SetParLimits(2,3.e-4,1.e-3);
  f->SetParameter(2,5.e-4);
  f->SetParLimits(11,1.6e-4,3.e-4);//1.5e-4 keyong
  f->SetParameter(11,2.e-4);
  f->SetParLimits(5,1.e-3,1.6e-3);
  f->SetParameter(5,1.e-3);
  hMCSignal->Fit(Form("f_5p_%.0f",ptmin),"LL","",BINMIN,BINMAX);
  hMCSignal->Fit(Form("f_5p_%.0f",ptmin),"LL","",BINMIN,BINMAX);
  f->ReleaseParameter(1);
  f->SetParLimits(1,minmass,maxmass);
  hMCSignal->Fit(Form("f_5p_%.0f",ptmin),"LL","",minmass,maxmass);
  hMCSignal->Fit(Form("f_5p_%.0f",ptmin),"LL","",minmass,maxmass);

  f->FixParameter(1,f->GetParameter(1));
  f->FixParameter(2,f->GetParameter(2));
  f->FixParameter(5,f->GetParameter(5));
  f->FixParameter(11,f->GetParameter(11));
  f->FixParameter(6,f->GetParameter(6));
  f->FixParameter(12,f->GetParameter(12));
  f->FixParameter(4,0);
  f->SetParLimits(3,2.e-4,2.e-3);
  f->SetParameter(3,1.e-3);

  hMCSwapped->Fit(Form("f_5p_%.0f",ptmin),"L q","",BINMIN,BINMAX);
  hMCSwapped->Fit(Form("f_5p_%.0f",ptmin),"L q","",BINMIN,BINMAX);
  hMCSwapped->Fit(Form("f_5p_%.0f",ptmin),"L q","",minmass,maxmass);
  hMCSwapped->Fit(Form("f_5p_%.0f",ptmin),"L q","",minmass,maxmass);

  f->FixParameter(4,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000)));
  f->FixParameter(3,f->GetParameter(3));

  f->SetParLimits(7,5.e-4,1.e-2);
  f->SetParameter(7,1.6e-3);
  f->SetParLimits(8,0.,15.);
  f->SetParameter(8,0.35);
  f->SetParLimits(9,-2.e+1,2.e+1);
  f->SetParameter(9,13.);

  f->ReleaseParameter(10);
  f->SetParLimits(10,0,1.e+6);

  h->Fit(Form("f_5p_%.0f",ptmin),"LL","",BINMIN,BINMAX);
  h->Fit(Form("f_5p_%.0f",ptmin),"LL","",BINMIN,BINMAX);

  f->ReleaseParameter(1);
  f->SetParLimits(1,minmass,maxmass);
  f->SetParameter(1,f->GetParameter(1));
  h->Fit(Form("f_5p_%.0f",ptmin),"LL","",BINMIN,BINMAX);
  h->Fit(Form("f_5p_%.0f",ptmin),"LL","",BINMIN,BINMAX);

  TF1* background = new TF1(Form("background_5p_%.0f",ptmin),"[3]*((1-exp((0.13957-x)/[0]))*pow(x/0.13957,[1])+[2]*(x/0.13957-1))");
  background->SetParameters(f->GetParameter(7),f->GetParameter(8),f->GetParameter(9),f->GetParameter(10));
  background->SetRange(BINMIN,BINMAX);
  background->SetLineColor(4);
  background->SetLineWidth(3);
  background->SetLineStyle(2);

  TF1* mass = new TF1(Form("fmass_5p_%.0f",ptmin),"[0]*[3]*([5]*([7]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[7])*Gaus(x,[1],[6])/(sqrt(2*3.14159)*[6]))+(1-[5])*Gaus(x,[1],[4])/(sqrt(2*3.14159)*[4]))");
  mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(4),f->GetParameter(5),f->GetParameter(6),f->GetParameter(11),f->GetParameter(12));
  mass->SetParError(0,f->GetParError(0));
  mass->SetParError(1,f->GetParError(1));
  mass->SetParError(2,f->GetParError(2));
  mass->SetParError(3,f->GetParError(4));
  mass->SetParError(4,f->GetParError(5));
  mass->SetParError(5,f->GetParError(6));
  mass->SetRange(BINMIN,BINMAX);
  mass->SetFillColor(kOrange-3);
  mass->SetFillStyle(3002);
  mass->SetLineColor(kOrange-3);
  mass->SetLineWidth(3);
  mass->SetLineStyle(2);

  TF1* massSwap = new TF1(Form("fmassSwap_5p_%.0f",ptmin),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])");
  massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(4),f->GetParameter(3));
  massSwap->SetRange(BINMIN,BINMAX);
  massSwap->SetFillColor(kGreen+4);
  massSwap->SetFillStyle(3005);
  massSwap->SetLineColor(kGreen+4);
  massSwap->SetLineWidth(3);
  massSwap->SetLineStyle(1);

  h->SetXTitle("M_{K#pi#pi#pi#pi}-M_{K#pi#pi#pi} (GeV/c^{2})");
  h->SetYTitle("Entries / (0.4 MeV/c^{2})");
  h->SetStats(0);
  h->SetAxisRange(0,h->GetMaximum()*1.3,"Y");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);

  h->Draw("e");
  mass->Draw("same");
  massSwap->Draw("same");
  background->Draw("same");
  f->Draw("same");

  if(plotgenmatch&&(isData==MC_MB||isData==MC))
    {
      hMCSignalplot->SetMarkerSize(0.8);
      hMCSignalplot->SetMarkerColor(kMagenta+2);
      hMCSignalplot->Draw("psame");
      hMCSwappedplot->SetMarkerSize(0.8);
      hMCSwappedplot->SetMarkerColor(kGray+2);
      hMCSwappedplot->Draw("psame");
    }

  Float_t yield = mass->Integral(BINMIN,BINMAX)/BINWID;
  Float_t yieldErr = mass->Integral(BINMIN,BINMAX)/BINWID*mass->GetParError(0)/mass->GetParameter(0);
  cout<<mass->GetParameter(0)<<" "<<mass->Integral(BINMIN,BINMAX)<<endl;

  TLatex* tex;
  TLegend* leg = new TLegend(0.60,0.57,0.85,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry((TObject*)0,"D* D^{0}(K#pi#pi#pi)#pi",NULL);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D*^{+}+D*^{-} Signal","f");
  leg->AddEntry(massSwap,"K-#pi swapped","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  tex = new TLatex(0.61,0.52,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();

  tex = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  tex->SetNDC();
  tex->SetTextAlign(12);
  tex->SetTextSize(0.04);
  tex->SetTextFont(42);
  tex->Draw();
  tex = new TLatex(0.65,0.93, "PP #sqrt{s_{NN}} = 5.02 TeV");
  tex->SetNDC();
  tex->SetTextAlign(12);
  tex->SetTextSize(0.04);
  tex->SetTextFont(42);
  tex->Draw();
  tex = new TLatex(0.20,0.79,"|y| < 1.0");
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();
  tex = new TLatex(0.20,0.84,Form("p_{T} > %.1f GeV/c",ptmin));
  tex->SetNDC();
  tex->SetTextFont(42);
  tex->SetTextSize(0.04);
  tex->Draw();

  c->SaveAs(Form("plots/pp/fitDstar5p/DMass_%s_%.0f.pdf",texData[isData].Data(),ptmin));

  return mass;
}
Beispiel #28
0
void fitDstar(char *infname = "/data/wangj/MC2015/Dntuple/PbPb/ntD_Pythia8_5020GeV_DstarD0kpipipi_755patch3_GEN_SIM_PU_20151120_Dstar5p_tkPt2_20151126_Evt_All.root") {

    TFile *inf = new TFile(infname);
    //TTree *ntmix=(TTree*)inf->Get("ntDD0kpipipipi");
    TTree *ntmix=(TTree*)inf->Get("ntDD0kpipi");
    TH1D *h = new TH1D("h","",100,0.139,0.159);
    TCut cutTrk = "";//"trk1PixelHit>=2&&trk1StripHit>=10&&trk1Chi2ndf<5&&trk2PixelHit>=2&&trk2StripHit>=10&&trk2Chi2ndf<5";

    TCanvas *c = new TCanvas("c","",750,750);
    ntmix->Draw("Dmass-DtktkResmass>>h","abs(DtktkResmass-1.86486)<0.015&&Dpt>10&&(DsvpvDistance/DsvpvDisErr)>0.&&Dchi2cl>0.05&&Dalpha<1."&&cutTrk,"",10000000);
    //ntmix->Draw("Dmass-DtktkResmass>>h","abs(DtktkResmass-1.86486)<0.015&&Dpt>10&&Dtrk1Pt>0.5&&DRestrk1Pt>0.5&&DRestrk2Pt>0.5&&DRestrk3Pt>0.5&&DRestrk4Pt>0.5&&Dchi2cl>0.1&&Dalpha<0.2&&(DsvpvDistance/DsvpvDisErr)>.0"&&cutTrk,"",10000000);
    h->Sumw2();
    //   TF1 *f = new TF1("f","(1-exp(-(x-[8])/[0]))*(((x)/[8])**[1]+[2]*(((x)/[8])-1))*[3]+[4]*(TMath::Voigt(x-[5],[6],[7]))");
    TF1* f = new TF1("f","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*((1-[8])*TMath::Gaus(x,[6],[7])/(sqrt(2*3.14159)*[7])+[8]*TMath::Gaus(x,[6],[9])/(sqrt(2*3.14159)*[9]))",minmass3prong,maxmass3prong);
//   TF1 *f = new TF1("f","(1-exp(-(x-0.13957018)/[0]))*(((x)/0.13957018)**[1]+[2]*(((x)/0.13957018)-1))*[3]+[4]*(TMath::Gaus(x,[5],[6]))");
    //TF1 *f = new TF1("f","(1-exp(-(x-1.86486-0.13957018)/[0]))*(((x-1.86486)/0.13957018)**[1]+[2]*(((x-1.86486)/0.13957018)-1))*[3]+[4]*TMath::Gaus(x,[5],[6])");
    f->SetLineColor(4);
//   f->SetParameters(-2.3825e6,-7.99713e-1,-1.42957,-5.50069e10,5.33573,1.45491e-1,2.78677e-6,1.43145e-3,0.13957018);
//   f->SetParameters(-7.3e5,-2.2e1,5.24e-1,-7.18e9,2e2,1.45491e-1,9e-4,0.1,8e-4);
    f->SetParameters(0,0,0,0,0,2e2,1.45491e-1,9e-4,0.1,8e-4);
    f->FixParameter(9,15e-4);
    f->FixParameter(6,0.145491);
    f->FixParameter(7,8e-4);
    f->SetParLimits(8,0,1);
    h->Fit("f","LL");
    h->Fit("f","LL");
    h->Fit("f","LL","",0.142,0.147);
    f->ReleaseParameter(6);
    f->ReleaseParameter(7);
    f->ReleaseParameter(9);
    f->SetParLimits(7,1e-4,9e-4);
    f->SetParLimits(9,1e-4,9e-4);
    h->Fit("f","LL","",0.142,0.148);
    h->Fit("f","LL","",0.142,0.16);
    h->Fit("f","LL","",0.142,0.16);
    h->Fit("f","LL","",0.141,0.16);
    h->Fit("f","LL","",0.141,0.16);
    h->Fit("f","LL","",0.141,0.16);

    h->SetXTitle("M_{K#pi#pi#pi#pi}-M_{K#pi#pi#pi} (GeV/c^{2})");
    h->SetYTitle("Entries");
    h->SetStats(0);
    h->SetAxisRange(1,h->GetMaximum()*1.3,"Y");
    TF1 *f2 = (TF1*)f->Clone("f2");
    f2->SetParameter(5,0);
    f2->SetRange(0.141,0.16);
    TF1 *f3 = (TF1*)f->Clone("f3");
    f3->SetParameter(0,0);
    f3->SetParameter(1,0);
    f3->SetParameter(2,0);
    f3->SetParameter(3,0);
    f3->SetParameter(4,0);

    f->SetLineColor(4);
    f2->SetLineColor(4);
    f2->SetLineStyle(2);
    f3->SetLineStyle(2);
    f2->Draw("same");
    f3->SetLineColor(2);
    f3->SetFillStyle(3004);
    f3->SetFillColor(2);
    f3->Draw("same");

    c->SaveAs("canvasDstar.pdf");
}
void balanceMetVsAj(TString infname = "dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0_120_50.root",
                    TCut myCut = "cent<30", char *title = "",bool drawLegend = false,
                    bool drawSys = true
		    )
{
   // ===========================================================
   // Get Input
   // ===========================================================
   TFile *inf = new TFile(infname);
   TTree *t = (TTree*)inf->Get("ntjt");


   t->SetAlias("metxMergedAll","(metOutOfConex0+metOutOfConex1+metOutOfConex2+metOutOfConex3+metOutOfConex4+metOutOfConex5)");
   t->SetAlias("metxMerged0","(metOutOfConex0)");
   t->SetAlias("metxMerged1","(metOutOfConex1)");
   t->SetAlias("metxMerged2","(metOutOfConex2)");
   t->SetAlias("metxMerged3","(metOutOfConex3)");
   t->SetAlias("metxMerged4","(metOutOfConex4+metOutOfConex5)");

   // ===========================================================
   // Analysis Setup
   // ===========================================================
   const int nBin = 5;
   double bins[nBin+1] = {0.5,1.0,1.5,4,8,1000};
   int colors[5] = {kBlue-10,kYellow-7, kOrange-2,kGreen-5,kRed-3};
   
   const int nBinAj = 4;
   double ajBins[nBinAj+1] = {0.0001,0.11,0.22,0.33,0.49999};
   // Selection cut
   TCut evtCut = "nljet>120&&abs(nljetacorr)<2&&aljet>50&&abs(aljetacorr)<2&&jdphi>2./3*TMath::Pi()&&!maskEvt";
//   TCut evtCut = "nljet>120&&abs(nljetacorr)<2&&aljet>50&&abs(aljetacorr)<2&&jdphi>3&&!maskEvt";

   cout << "Sel evt: " << t->GetEntries(evtCut&&myCut) << endl;

   // ===========================================================
   // Find Average Weights
   // ===========================================================
   TH1D *hw[nBinAj];
   float meanWt[nBinAj];
   for ( int iaj = 0 ; iaj< nBinAj ; iaj++) {
      hw[iaj] = new TH1D(Form("hw_aj%d",iaj),"",1000,0,100);
      TCut ajCut = Form("Aj>%f && Aj<%f", ajBins[iaj],ajBins[iaj+1]);
      t->Draw(Form("weight>>hw_aj%d",iaj), evtCut&&myCut&&ajCut);
      meanWt[iaj] = hw[iaj]->GetMean();
      cout << " <Weight>: " << meanWt[iaj] << endl;
   }

   // ===========================================================
   // Draw Weighted Averages
   // ===========================================================
   TH1D *ppos[nBin];
   TH1D *pneg[nBin];
   TH1D *pe[nBin];
   for (int i=0;i<nBin;i++)
   {
      TH1D *h1 = new TH1D(Form("h1%d",i),"",nBinAj,ajBins);
      TH1D *h2 = new TH1D(Form("h2%d",i),"",nBinAj,ajBins);
      TH1D *he[nBinAj];
      
      // =================================
      // Get Weighted Mean for each Aj bin
      // =================================
      h1->Sumw2();
      h2->Sumw2();
      t->Draw(Form("Aj>>h1%d",i), "weight"*(evtCut&&myCut));
      t->Draw(Form("Aj>>h2%d",i), Form("((-weight*metxMerged%d))",i)*(evtCut&&myCut));
      
      pe[i]=(TH1D*)h2->Clone();
      pe[i]->SetName(Form("p%d",i));     
      pe[i]->Divide(h1);
      ppos[i] = new TH1D(Form("ppos%d",i),"",nBinAj,ajBins);
      ppos[i]->SetLineColor(1);     
      ppos[i]->SetMarkerColor(colors[i]);
      ppos[i]->SetFillColor(colors[i]);
      ppos[i]->SetFillStyle(1001);
      pneg[i] = new TH1D(Form("pneg%d",i),"",nBinAj,ajBins);
      pneg[i]->SetLineColor(1);     
      pneg[i]->SetMarkerColor(colors[i]);
      pneg[i]->SetFillColor(colors[i]);
      pneg[i]->SetFillStyle(1001);

      // =================================
      // Caculated Stat Error of the Mean
      // =================================
      cout << "Stat Error for pt bin " << i << ": ";
      for ( int iaj = 0 ; iaj< nBinAj ; iaj++) {
         he[iaj] = new TH1D(Form("he%d_aj%d",i,iaj),"",100,-200,200);
         TCut ajCut = Form("Aj>%f && Aj<%f", ajBins[iaj],ajBins[iaj+1]);
         t->Draw(Form("((metxMerged%d))>>he%d_aj%d",i,i,iaj), "weight" * evtCut&&myCut&&ajCut);
         float theError = he[iaj]->GetRMS()/ (sqrt(he[iaj]->GetEntries()));
	 cout << theError << " ";
	 pe[i]->SetBinError(iaj+1, theError);
      }
      cout << endl;
   }

   // Stack
   for (int i=nBin-1;i>=0;i--)
   {
      for(int iaj = 0 ; iaj< nBinAj ; iaj++) {
         double posVal=0, negVal=0;
         double posValErr=0, negValErr=0;
         if (i!=nBin-1) {
            posVal = ppos[i+1]->GetBinContent(iaj+1);
            posValErr = ppos[i+1]->GetBinError(iaj+1);
            negVal = pneg[i+1]->GetBinContent(iaj+1);
            negValErr = pneg[i+1]->GetBinError(iaj+1);
         }
         if (pe[i]->GetBinContent(iaj+1)<0) {
            negVal+=pe[i]->GetBinContent(iaj+1);
            negValErr=pe[i]->GetBinError(iaj+1);
            posValErr=0;
         } else if (pe[i]->GetBinContent(iaj+1)>0) {
            posVal+=pe[i]->GetBinContent(iaj+1);
            posValErr=pe[i]->GetBinError(iaj+1);
            negValErr=0;
         } 
         ppos[i]->SetBinContent(iaj+1,posVal);
         ppos[i]->SetBinError(iaj+1,posValErr);
         pneg[i]->SetBinContent(iaj+1,negVal);
         pneg[i]->SetBinError(iaj+1,negValErr);
      }
   }
   
   TH1D *pall;
   TH1D *pallE;
   TH1D *h1 = new TH1D(Form("hAll1"),"",nBinAj,ajBins);
   TH1D *h2 = new TH1D(Form("hAll2"),"",nBinAj,ajBins);

   h1->Sumw2();
   h2->Sumw2();
   t->Draw(Form("Aj>>hAll1"), "weight"*(evtCut&&myCut));
   t->Draw(Form("Aj>>hAll2"), Form("((-weight*metxMergedAll))")*(evtCut&&myCut));
   pall=(TH1D*)h2->Clone();
   pall->SetName("pall");
   pall->Divide(h1);

   // replace the sys error from pallE to pall 
   TH1D *he[nBinAj];
   cout << "Stat Error for All pt: ";
   for ( int iaj = 0 ; iaj< nBinAj ; iaj++) {
      he[iaj] = new TH1D(Form("heAll_aj%d",iaj),"",100,-200,200);
      TCut ajCut = Form("Aj>%f && Aj<%f", ajBins[iaj],ajBins[iaj+1]);
      t->Draw(Form("((metxMergedAll))>>heAll_aj%d",iaj), "weight" * evtCut&&myCut&&ajCut);
      float theError = he[iaj]->GetRMS()/ (sqrt(he[iaj]->GetEntries()));
      cout << theError << " ";
      pall->SetBinError(iaj+1,  theError);
   }
   cout << endl;

   pall->SetXTitle("A_{J}");
   pall->SetYTitle("<#slash{p}_{T}^{#parallel}> (GeV/c)");
   pall->GetXaxis()->CenterTitle();
   pall->GetYaxis()->CenterTitle();
   pall->GetXaxis()->SetLabelSize(22);
   pall->GetXaxis()->SetLabelFont(43);
   pall->GetXaxis()->SetTitleSize(24);
   pall->GetXaxis()->SetTitleFont(43);
   pall->GetYaxis()->SetLabelSize(22);
   pall->GetYaxis()->SetLabelFont(43);
   pall->GetYaxis()->SetTitleSize(24);
   pall->GetYaxis()->SetTitleFont(43);
   pall->GetXaxis()->SetTitleOffset(1.8);
   pall->GetYaxis()->SetTitleOffset(2.4);
   pall->SetNdivisions(505);
   pall->SetAxisRange(-59.9,59.9,"Y");
   pall->SetMarkerSize(1);
   pall->Draw("E");
   float addSys = 0;
   if ( drawSys==1)   addSys=0; // No sys error at this moment

   // ====================
   // Finally Draw
   // ====================
   for (int i=0;i<nBin;++i) {
      ppos[i]->SetLineWidth(1);
      ppos[i]->Draw("hist same");
      pneg[i]->SetLineWidth(1);
      pneg[i]->Draw("hist same");
   }
   
   // ====================
   // Draw Statistical Error bars
   // ====================
   for (int i=0;i<nBin;++i) {
      if ( i==0 )       drawErrorShift(ppos[i],-0.016, addSys);
      if ( i==1 || i==4)       drawErrorShift(ppos[i],-0.008,addSys);
      if ( i==2 )       drawErrorShift(ppos[i],0.008,addSys);
      if ( i==3 )       drawErrorShift(ppos[i],0.016,addSys);
      if ( i==0 )       drawErrorShift(pneg[i],-0.016, addSys);
      if ( i==1 || i==4)       drawErrorShift(pneg[i],-0.008,addSys);
      if ( i==2 )       drawErrorShift(pneg[i],0.008,addSys);
      if ( i==3 )       drawErrorShift(pneg[i],0.016,addSys);
   }
   pall->Draw("E same");
   
   // ====================
   // Draw Systematic Errors
   // ====================
   if (drawSys == 1) {
      for(int i = 0; i < nBinAj; ++i){
        double x = pall->GetBinCenter(i+1);
        double y = pall->GetBinContent(i+1);
        // Quote the difference between GEN and RECO in >8 Bin (20%) before adjusting eff as systematics
        double err = fabs(pe[nBin-1]->GetBinContent(i+1)*0.2);
        DrawTick(y,err,err,x,1,0.02,1);
      }
   }

   // ====================
   // Draw Legend
   // ====================
   TLegend *leg = new TLegend(0.10,0.68,0.70,0.96);
   leg->SetFillStyle(0);
   leg->SetBorderSize(0);
   leg->SetTextFont(63);
   leg->SetTextSize(16);
   leg->AddEntry(pall,Form("> %.1f GeV/c",bins[0]),"pl");
   for (int i=0;i<nBin;++i) {
      if (i!=nBin-1){
         leg->AddEntry(ppos[i],Form("%.1f - %.1f GeV/c",bins[i],bins[i+1]),"f");
      } else {
         leg->AddEntry(ppos[i],Form("> %.1f GeV/c",bins[i]),"f");
      }
   }

   if (drawLegend) leg->Draw();

   TLine * l0 = new TLine(0,0,0.5,0);
   l0->SetLineStyle(2);
   l0->Draw();


   TLine * l1 = new TLine(0.0001,-10,0.0001,10);
   l1->Draw();

   TText *titleText = new TText(0.3,30,title);
   titleText->Draw();
}
Beispiel #30
0
void compInclJetFrag()
{
  // Jet Selection: used for jet selecting the jets
  // TCut jetSelCut[2] = {"jetPt>100&&jetPt<300","jetPt>100&&jetPt<300"};
  // TCut jetSelCut[2] = {"jetPtGM>100&&jetPtGM<300","jetPtGM>100&&jetPtGM<300"};
  TCut jetSelCut[2] = {"jetPt>100&&jetPt<300","jetPtGM>100&&jetPtGM<300"};
  // TCut jetSelCut[2] = {"jetPtGM<100","jetPtGM>100&&jetPtGM<300"};

  // Jet Alias: used for plotting the selected jets.
  // TString jetAlias[2] = {"jetPt","jetPt"};
  // TString jetAlias[2] = {"jetPtGM","jetPtGM"};
  TString jetAlias[2] = {"jetPt","jetPtGM"};

  multiTreeUtil vmt[2];
  // measurement in MC
  // smeared pp
  // vmt[0].addFile("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root","tdj", jetSelCut[0] && "pthat>=80&&pthat<120", 9.913e-5*1.e9); // no centrality cut
  // vmt[0].addFile("../ntout/jskim_dj120_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root","tdj", jetSelCut[0] && "pthat>=120&&pthat<9999", 1.128e-5*1.e9); // no centrality cut
  // unsmeared pp
  // vmt[0].addFile("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm0bin0_ak3PF_gj0.root","tdj", jetSelCut[0] && "pthat>=80&&pthat<120", 9.913e-5*1.e9); // no centrality cut
  // vmt[0].addFile("../ntout/jskim_dj120_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm0bin0_ak3PF_gj0.root","tdj", jetSelCut[0] && "pthat>=120&&pthat<9999", 1.128e-5*1.e9); // no centrality cut
  // pbpb
  TCut centCut = "cBin>=0&&cBin<4";
  vmt[0].addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[0] && centCut && "pthat>=80&&pthat<100",9.913e-5*1.e9);
  // vmt[0].addFile("../ntout/jskim_hydj120_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[0] && centCut && "pthat>=120&&pthat<9999",1.128e-5*1.e9);
  vmt[0].addFile("../ntout/jskim_hydj100_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[0] && centCut && "pthat>=100&&pthat<9999",3.069e-5*1.e9);
  // vmt[0].addFile("../ntout/jskim_hydj120_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[0] && centCut && "pthat>=120&&pthat<9999",1.128e-5*1.e9);

  // reference
  // unsmeared pp
  // vmt[1].addFile("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm0bin0_ak3PF_gj0.root","tdj", jetSelCut[1] && "pthat>=80&&pthat<120", 9.913e-5*1.e9); // no centrality cut
  // vmt[1].addFile("../ntout/jskim_dj120_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm0bin0_ak3PF_gj0.root","tdj", jetSelCut[1] && "pthat>=120&&pthat<9999", 1.128e-5*1.e9); // no centrality cut
  // smeared pp
  // vmt[1].addFile("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root","tdj", jetSelCut[1] && "pthat>=80&&pthat<120", 9.913e-5*1.e9); // no centrality cut
  // vmt[1].addFile("../ntout/jskim_dj120_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root","tdj", jetSelCut[1] && "pthat>=120&&pthat<9999", 1.128e-5*1.e9); // no centrality cut
  // pbpb
  vmt[1].addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[1] && centCut && "pthat>=80&&pthat<100",9.913e-5*1.e9);
  vmt[1].addFile("../ntout/jskim_hydj100_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[1] && centCut && "pthat>=100&&pthat<9999",3.069e-5*1.e9);

  for (int i=0; i<2; ++i) {
    vmt[i].NormalizeScales(2,"","hEvtCentNoSkim");
  }

  for (int i=0; i<2; ++i) {
    vmt[i].AddFriend("yTrk=yongsunTrack");
    vmt[i].AddFriend("genPar");
    vmt[i].SetAlias("finalJetPt",jetAlias[i]);
    cout << "(input " << i << ") finalJetPt = " << vmt[i].trees_[0]->GetAlias("finalJetPt") << endl;
  }

  TFile * ouf = new TFile("hists.root","recreate");

  // Draw jet
  TCut jetCut="abs(jetEta)<2&&abs(jetEta)>0.3";
  TH1D * hJetPt[2];
  for (int i=0; i<2; ++i) {
    hJetPt[i] = new TH1D(Form("hJetPt_%d",i),";Jet p_{T} (GeV/c);",20,0,400);
    vmt[i].Draw(hJetPt[i],"finalJetPt",jetCut,"1");
  }

  // Check Normalization
  TCanvas * c0 = new TCanvas("c0","c0",400,650,600,300);
  c0->Divide(2,1);
  c0->cd(1);
  gPad->SetLogy();
  cleverRange(hJetPt[0],hJetPt[1],5);
  hJetPt[0]->DrawCopy("E");
  hJetPt[1]->DrawCopy("same hist");
  c0->cd(2);
  TH1D * hJetPtUnNormRat = (TH1D*)hJetPt[0]->Clone(Form("%s_unnormrat",hJetPt[0]->GetName()));
  hJetPtUnNormRat->Divide(hJetPt[1]);
  hJetPtUnNormRat->SetAxisRange(0,2,"Y");
  hJetPtUnNormRat->Draw("E");
  jumSun(0,1,400,1);

  // Normalization
  float nJet[2] = {0,0};
  for (int i=0; i<2; ++i) {
    nJet[i] = hJetPt[i]->Integral();
    cout << "(input " << i << ") nJet = " << nJet[i] << endl;
  }

  // Draw Trk
  // TCut trkCut="yTrk.jetMatch==1 && yTrk.jetDr<0.30 && yTrk.pt>1.00 && yTrk.pt<300.00";
  // TString trkWeight="(yTrk.trkWeight)";
  // TString trkWeight="(yTrk.trkWeight*(yTrk.trkWeight<3.5)+1.47*(yTrk.trkWeight>=3.5))";
  TCut trkCut="abs(genPar.chg)>0 && genPar.jetMatch==1 && genPar.jetDr<0.30 && genPar.pt>1.00 && genPar.pt<300.00";
  trkCut=trkCut&&"genPar.sube==0";
  TString trkWeight="1";
  TH1D * hTrkPt[2], * hXi[2];
  for (int i=0; i<2; ++i) {
    hTrkPt[i] = new TH1D(Form("hTrkPt_%d",i),";Track p_{T} (GeV/c);",20,1,101);
    // vmt[i].Draw(hTrkPt[i],"yTrk.pt",jetCut&&trkCut,trkWeight);
    vmt[i].Draw(hTrkPt[i],"genPar.pt",jetCut&&trkCut,trkWeight);
    hXi[i] = new TH1D(Form("hXi_%d",i),";#xi = ln(1/z);",16,-1,7);
    vmt[i].Draw(hXi[i],"log(finalJetPt/genPar.pt)",jetCut&&trkCut,trkWeight);
  }

  // Draw Jet and Trk
  TH2D * hTrkJetPt2D[2], * hXiJetPt2D[2];
  for (int i=0; i<2; ++i) {
    hTrkJetPt2D[i] = new TH2D(Form("hTrkJetPt2D_%d",i),";Track p_{T} (GeV/c);Jet p_{T} (GeV/c);",20,1,101,20,0,400);
    // vmt[i].Draw2D(hTrkJetPt2D[i],"yTrk.pt:finalJetPt",jetCut&&trkCut,trkWeight);
    vmt[i].Draw2D(hTrkJetPt2D[i],"finalJetPt:genPar.pt",jetCut&&trkCut,trkWeight);
    hXiJetPt2D[i] = new TH2D(Form("hXiJetPt2D_%d",i),";#xi = ln(1/z);Jet p_{T} (GeV/c);",16,-1,7,20,0,400);
    vmt[i].Draw2D(hXiJetPt2D[i],"finalJetPt:log(finalJetPt/genPar.pt)",jetCut&&trkCut,trkWeight);
  }

  // Normalize
  for (int i=0; i<2; ++i) {
    hJetPt[i]->Scale(1./nJet[i]);
    hTrkPt[i]->Scale(1./nJet[i]);
    hXi[i]->Scale(1./nJet[i]);
    hTrkJetPt2D[i]->Scale(1./nJet[i]);
    hXiJetPt2D[i]->Scale(1./nJet[i]);
  }

  // Draw
  TCanvas * c2 = new TCanvas("c2","c2",1000,650,600,300);
  c2->Divide(2,1);
  c2->cd(1);
  gPad->SetLogy();
  hJetPt[0]->Draw("E");
  hJetPt[1]->Draw("same hist");
  c2->cd(2);
  TH1D * hJetPtRat = (TH1D*)hJetPt[0]->Clone(Form("%s_rat",hJetPt[0]->GetName()));
  hJetPtRat->Divide(hJetPt[1]);
  hJetPtRat->SetAxisRange(0,2,"Y");
  hJetPtRat->Draw("E");
  jumSun(0,1,400,1);

  TCanvas * c3 = new TCanvas("c3","c3",100,0,600,300);
  c3->Divide(2,1);
  c3->cd(1);
  gPad->SetLogy();
  gPad->SetLogx();
  hTrkPt[0]->Draw("E");
  hTrkPt[1]->Draw("same hist");
  c3->cd(2);
  gPad->SetLogx();
  TH1D * hTrkPtRat = (TH1D*)hTrkPt[0]->Clone(Form("%s_rat",hTrkPt[0]->GetName()));
  hTrkPtRat->Divide(hTrkPt[1]);
  hTrkPtRat->SetAxisRange(0,2,"Y");
  hTrkPtRat->Draw("E");
  jumSun(1,1,100,1);

  TCanvas * c4 = new TCanvas("c4","c4",700,0,900,300);
  c4->Divide(3,1);
  c4->cd(1);
  gPad->SetRightMargin(0.15);
  gPad->SetLogx();
  gPad->SetLogz();
  hTrkJetPt2D[0]->SetAxisRange(5e-3,1e1,"Z");
  hTrkJetPt2D[0]->Draw("colz");
  c4->cd(2);
  gPad->SetRightMargin(0.15);
  gPad->SetLogx();
  gPad->SetLogz();
  hTrkJetPt2D[1]->Draw("colz");
  hTrkJetPt2D[1]->SetAxisRange(5e-3,1e1,"Z");
  c4->cd(3);
  gPad->SetRightMargin(0.15);
  gPad->SetLogx();
  TH1D * hTrkJetPt2DRat = (TH1D*)hTrkJetPt2D[0]->Clone(Form("%s_rat",hTrkJetPt2D[0]->GetName()));
  hTrkJetPt2DRat->Divide(hTrkJetPt2D[1]);
  hTrkJetPt2DRat->SetAxisRange(0.4,2,"Z");
  hTrkJetPt2DRat->Draw("colz");


  TCanvas * c5 = new TCanvas("c5","c5",100,325,600,300);
  c5->Divide(2,1);
  c5->cd(1);
  gPad->SetLogy();
  hXi[0]->Draw("E");
  hXi[1]->Draw("same hist");
  c5->cd(2);
  TH1D * hXiRat = (TH1D*)hXi[0]->Clone(Form("%s_rat",hXi[0]->GetName()));
  hXiRat->Divide(hXi[1]);
  hXiRat->SetAxisRange(0,2,"Y");
  hXiRat->Draw("E");
  jumSun(0,1,6,1);

  TCanvas * c6 = new TCanvas("c6","c6",700,325,900,300);
  c6->Divide(3,1);
  c6->cd(1);
  gPad->SetRightMargin(0.15);
  gPad->SetLogz();
  hXiJetPt2D[0]->SetAxisRange(2e-6,5,"Z");
  hXiJetPt2D[0]->Draw("colz");
  c6->cd(2);
  gPad->SetRightMargin(0.15);
  gPad->SetLogz();
  hXiJetPt2D[1]->Draw("colz");
  hXiJetPt2D[1]->SetAxisRange(2e-6,5,"Z");
  c6->cd(3);
  gPad->SetRightMargin(0.15);
  TH1D * hXiJetPt2DRat = (TH1D*)hXiJetPt2D[0]->Clone(Form("%s_rat",hXiJetPt2D[0]->GetName()));
  hXiJetPt2DRat->Divide(hXiJetPt2D[1]);
  hXiJetPt2DRat->SetAxisRange(0.4,2,"Z");
  hXiJetPt2DRat->Draw("colz");

  // Check
  // TCanvas * cc = new TCanvas("cc","cc",2);
  // hTrkPt[0]->Draw("hist");
  // hTrkJetPt2D[0]->ProjectionY(Form("%s_py",hTrkJetPt2D[0]->GetName()))->Draw("sameE");
  // hJetPt[0]->Scale(1./nJet[0]);
  // hJetPt[0]->Draw("hist");
  // hTrkJetPt2D[0]->ProjectionX(Form("%s_px",hTrkJetPt2D[0]->GetName()))->Draw("sameE");
}