Esempio n. 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");
}
Esempio n. 2
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();
  
}
Esempio n. 3
0
void drawPaEta( bool saveFigures=false) {
  TFile * fData = new TFile("../histogramProducer/ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr40_to_9999_jetPtThr30_20130829.root");
  TH1D* hD1 = (TH1D*)fData->Get("etaJg_icent1_final");
  TH1D* hD2 = (TH1D*)fData->Get("etaJg_icent2_final");
  TH1D* hD3 = (TH1D*)fData->Get("etaJg_icent3_final");

  TFile * fMC = new TFile("../histogramProducer/ffFiles/photonTrackCorr_ppbMC_output_photonPtThr40_to_9999_jetPtThr30_20130829.root");
  TH1D* hM1 = (TH1D*)fMC->Get("etaJg_icent1_final");
  TH1D* hM2 = (TH1D*)fMC->Get("etaJg_icent2_final");
  TH1D* hM3 = (TH1D*)fMC->Get("etaJg_icent3_final");

  TCanvas* c1 = new TCanvas("c1","",500,500);
  handsomeTH1(hD1,1);
  handsomeTH1(hD2,4);
  handsomeTH1(hD3,2);
  hD1->Rebin(10);
  hD2->Rebin(10);
  hD3->Rebin(10);

  hD1->Draw();
  hD2->Draw("same");
  hD3->Draw("same");

  TCanvas* c2 = new TCanvas("c2","",400,400);
  TH1D* hmData = new TH1D("hmData",";HF energy;",nCentBinPa,centBinPa);
  hmData->SetBinContent(1, hD1->GetMean());
  hmData->SetBinContent(2, hD2->GetMean());
  hmData->SetBinContent(3, hD3->GetMean());
  hmData->SetBinError(1, hD1->GetMeanError());
  hmData->SetBinError(2, hD2->GetMeanError());
  hmData->SetBinError(3, hD3->GetMeanError());
  TH1D* hmMc = new TH1D("hmMc",";HF energy;",nCentBinPa,centBinPa);
  hmMc->SetBinContent(1, hM1->GetMean());
  hmMc->SetBinContent(2, hM2->GetMean());
  hmMc->SetBinContent(3, hM3->GetMean());
  hmMc->SetBinError(1, hM1->GetMeanError());
  hmMc->SetBinError(2, hM2->GetMeanError());
  hmMc->SetBinError(3, hM3->GetMeanError());
  handsomeTH1(hmData,2);
  handsomeTH1(hmMc,1);
  hmMc->SetMarkerStyle(24);
  hmMc->Draw();
  hmData->Draw("same");
  

}
Esempio n. 4
0
void niceTH1(TH1F* uglyTH1, float max , float min, float ndivX, float ndivY)
{
  handsomeTH1(uglyTH1);
  uglyTH1->SetMaximum(max);
  uglyTH1->SetMinimum(min);
  uglyTH1->GetXaxis()->SetNdivisions(ndivX);
  uglyTH1->GetYaxis()->SetNdivisions(ndivY);
  return;
}
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();
  

       

}
Esempio n. 6
0
TH1F* templ(char* prx="")
{
   
   
   TCanvas* c0 = new TCanvas("c0","",800,400);
   c0->Divide(2,1);
   c0->Draw();
   c0->cd(1);
   TFile *f1=new TFile("../rootFiles/compPhoton_scan_0-105-120-150-200.root","r");
   char* _ntupleName_ = "_directory/photons_";
   TNtuple *nt1 = (TNtuple*)f1->Get(_ntupleName_);
   
   //TCut etaCut = "abs(eta)<1.45";
   //char* label  = "Barrel";
   
   int nBin = 100;
   float xMin = -1;
   float xMax = 20;
   TH1F* theHist = new TH1F("_theHist_",";Track Iso(GeV);Entries",nBin,xMin,xMax);
   
   
   nt1->Draw("_theVariable_>>_theHist_",etCut&&etaCut);
   
   theHist->Sumw2();
   handsomeTH1(theHist);
   theHist->Draw();
   
   TLegend* leg = new TLegend(0.56,0.85, 0.95, 0.90,NULL,"brNDC");
   easyLeg(leg,"the legend");
   //   leg->AddEntry(theHist,"compl. cone","l");
   leg->Draw();
   
   c0->SaveAs(Form("plots/thePlot_%s.gif",prx));
   
   
}
Esempio n. 7
0
void drawTrkCorrPtvCent(
                           TString outdir="fig/trkcorrv14"
)
{
   TH1::SetDefaultSumw2();
   gSystem->mkdir(outdir,kTRUE);
   float xmin=1,xmax=179.9;
   TString title="Iterative Tracking";

   /////////////////////////////////////////////////////////////////////////////////////
   // Load Histograms
   /////////////////////////////////////////////////////////////////////////////////////
   HiForest * c = new HiForest("/net/hidsk0001/d00/scratch/yjlee/merge/v27/pthat170/Dijet170_HydjetDrum_v27_mergedV1.root");
   c->doTrackCorrections = true;
   c->InitTree();
   
   TrackingCorrections * trkCorr = c->trackCorrections[0];
      
   cout << endl << "========= plot =========" << endl;
   Int_t etaPM=2; // 7 +2,-3 for |eta|<1.2, 7 =5,-6 for full eta
   Float_t jetPtMin=0;
   Int_t jetBegBin = trkCorr->jetBin_->FindBin(jetPtMin);
   Int_t jetEndBin = trkCorr->numJEtBins_;
   cout << Form("jet pt %.0f bin: ",jetPtMin) << jetBegBin << " to " << jetEndBin << endl;
   cout << "========================" << endl;
   bool doTestCorr = true;
   
   string infpath=trkCorr->sample_[0]->GetName();
   TString src=infpath.substr(infpath.find_last_of('/')+1);
   src.ReplaceAll(".root","");
   TString tag = src+"_"+trkCorr->trkCorrModule_+Form("_vs_Pt_jet%.0f_ieta%d_wts%d",jetPtMin,etaPM,trkCorr->weightSamples_);

   /////////////////////////////////////////////////////////////////////////////////////
   // Inspect Projection
   /////////////////////////////////////////////////////////////////////////////////////
   // Get Eff/fake histograms
   int numCentBin=trkCorr->numCentBins_;
   TH1D * vhCorrPtRef[2][5], *vhCorrPt[2][5];
   Int_t colors[10] = {kBlack,kRed,kYellow+2,kGreen+2,kBlue};
   Int_t styles[2] = {kFullCircle,kOpenCircle};
   for (Int_t lv=0; lv<2; ++lv) {
     for (Int_t c=0; c<numCentBin; ++c) {
       vhCorrPt[lv][c] = (TH1D*) trkCorr->InspectCorr(lv,c,c,jetBegBin,jetEndBin,2,7-etaPM-1,7+etaPM);
       vhCorrPt[lv][c]->SetMarkerStyle(styles[lv]);
       handsomeTH1(vhCorrPt[lv][c],colors[c]);
       vhCorrPt[lv][c]->SetAxisRange(xmin,xmax,"X");
     }
   }
   
   // Draw Histograms
   TCanvas * cEff = new TCanvas("cEff","cEff",500,500);
   cEff->SetLogx();
   vhCorrPt[0][0]->SetAxisRange(0,1,"Y");
   vhCorrPt[0][0]->SetTitle(";Track p_{T} (GeV/c);A #times #epsilon");
   vhCorrPt[0][0]->SetTitleOffset(1.2);
   vhCorrPt[0][0]->SetTitleSize(0.055);
   vhCorrPt[0][0]->Draw("E");
   vhCorrPt[1][0]->Draw("sameE");
   for (Int_t lv=0; lv<2; ++lv) {
     for (Int_t c=numCentBin-1; c>=0; --c) {
       vhCorrPt[lv][c]->Draw("sameE");
     }
   }
   TLegend *leg0 = new TLegend(0.16,0.786,0.46,0.92);
   leg0->SetFillStyle(0);
   leg0->SetBorderSize(0);
   leg0->SetTextSize(0.04);
   leg0->AddEntry(vhCorrPt[0][0],"PYTHIA+HYDJET","");
   if (jetPtMin >= 40) leg0->AddEntry(vhCorrPt[0][0],Form("Jet p_{T} #geq %.0f GeV/c",jetPtMin),"");
   leg0->AddEntry(vhCorrPt[0][0],Form("Track %.1f < #eta < %.1f",trkCorr->etaBin_->GetBinLowEdge(7-etaPM-1), trkCorr->etaBin_->GetBinLowEdge(7+etaPM+1)),"");
   leg0->Draw();
   TLine * l = new TLine(xmin,1,xmax,1);
   l->SetLineStyle(2);
   l->Draw();
	
   TLegend *leg = new TLegend(0.34,0.25,0.56,0.55);
   leg->SetFillStyle(0);
   leg->SetBorderSize(0);
   leg->SetTextSize(0.035);
   leg->AddEntry(vhCorrPt[0][0],title,"");
// 	leg->AddEntry(vhCorrPt[0][0],"0-5%","p");
// 	leg->AddEntry(vhCorrPt[0][1],"5-10%","p");
// 	leg->AddEntry(vhCorrPt[0][2],"10-20%","p");
// 	leg->AddEntry(vhCorrPt[0][3],"30-50%","p");
// 	leg->AddEntry(vhCorrPt[0][4],"50-90%","p");
	leg->AddEntry(vhCorrPt[0][0],"0-30%","p");
	leg->AddEntry(vhCorrPt[0][1],"30-100%","p");
   leg->Draw();
   
	drawText("CMS Simulation",0.64,0.89);
	drawText("Fake Rate",0.69,0.26);
   
   cEff->Print(outdir+"/"+tag+".gif");
   cEff->Print(outdir+"/"+tag+".pdf");

   /////////////////////////////////////////////////////////////////////////////////////
   // Inspect Events
   /////////////////////////////////////////////////////////////////////////////////////
	TCanvas * cPtHat = new TCanvas("cPtHat","cPtHat",1000,500);
	cPtHat->Divide(2,1);
	cPtHat->cd(1);
	gPad->SetLogy();
	trkCorr->vhPtHat[0][0]->SetMarkerStyle(kOpenCircle);
	trkCorr->vhPtHat[0][0]->SetMarkerColor(kRed);
	trkCorr->vhPtHat[1][0]->SetTitle(";#hat{p}_{T} (GeV/c);a.u.");
	normHist(trkCorr->vhPtHat[0][0],1,false);//,trkCorr->vhPtHat[0][0]->Integral()/trkCorr->vhPtHat[0][0]->Integral(24,200));
	normHist(trkCorr->vhPtHat[1][0],1,false);//,trkCorr->vhPtHat[1][0]->Integral()/trkCorr->vhPtHat[1][0]->Integral(24,200));
	trkCorr->vhPtHat[1][0]->SetAxisRange(0,500,"X");
	trkCorr->vhPtHat[1][0]->SetAxisRange(1e-7,1,"Y");
	trkCorr->vhPtHat[1][0]->Draw("E");
// 	trkCorr->vhPtHat[0][0]->Draw("Esame");
//    TLegend *legev0 = new TLegend(0.53,0.76,0.75,0.90);
//    legev0->SetFillStyle(0);
//    legev0->SetBorderSize(0);
//    legev0->SetTextSize(0.035);
//    legev0->AddEntry(trkCorr->vhPtHat[0][0],"Raw","p");
//    legev0->AddEntry(trkCorr->vhPtHat[1][0],"Weighted","p");
//    legev0->Draw();
	cPtHat->cd(2);
	gPad->SetLogx();
	gPad->SetLogy();
	normHist(trkCorr->hDen1DInsp,1,true);
	normHist(trkCorr->hNum1DInsp,1,true);
	trkCorr->hDen1DInsp->SetMarkerStyle(kOpenCircle);
	trkCorr->hDen1DInsp->SetTitle(";Track p_{T} (GeV/c);a.u.");
	trkCorr->hDen1DInsp->SetAxisRange(1.001,299.9,"X");
	trkCorr->hDen1DInsp->SetAxisRange(1e-13,1e1,"Y");
	trkCorr->hDen1DInsp->Draw("hist");
	trkCorr->hNum1DInsp->Draw("Esame");
	cPtHat->Print(outdir+"/"+tag+"_weighting.gif");
	cPtHat->Print(outdir+"/"+tag+"_weighting.pdf");

   /////////////////////////////////////////////////////////////////////////////////////
   // Inspect Each Bin
   /////////////////////////////////////////////////////////////////////////////////////
      TCanvas * cEff2D = new TCanvas("cEff2D","cEff2D",800,800);
	gPad->SetLogy();
   Double_t pt=8,eta=0,jet=101.  ;
   Int_t cBin = 0;
   cEff2D->Divide(2,2);
   cEff2D->cd(1);
   gPad->SetLogy();
   TH2D * hCorr2D = (TH2D*)trkCorr->InspectCorr(0,cBin,cBin,trkCorr->jetBin_->FindBin(jet),trkCorr->jetBin_->FindBin(jet));
   gPad->SetRightMargin(0.15);
   hCorr2D->SetAxisRange(0.5,119.9,"Y");
   hCorr2D->SetAxisRange(0,1,"Z");
   hCorr2D->Draw("colz");
   cEff2D->cd(2);
   gPad->SetLogy();
   TH2D * hCorr2DFak= (TH2D*)trkCorr->InspectCorr(1,cBin,cBin,trkCorr->jetBin_->FindBin(jet),trkCorr->jetBin_->FindBin(jet));
   gPad->SetRightMargin(0.15);
   hCorr2DFak->SetAxisRange(0.5,119.9,"Y");
   hCorr2DFak->SetAxisRange(0,1,"Z");
   hCorr2DFak->Draw("colz");
   cEff2D->cd(3);
   gPad->SetLogy();
   hCorr2D = (TH2D*)trkCorr->InspectCorr(0,cBin,cBin,trkCorr->jetBin_->FindBin(200.),trkCorr->jetBin_->FindBin(jet));
   gPad->SetRightMargin(0.15);
   hCorr2D->SetAxisRange(1,119.9,"Y");
   hCorr2D->SetAxisRange(0,1,"Z");
   hCorr2D->Draw("colz");
   cEff2D->cd(4);
   gPad->SetLogy();
   hCorr2DFak= (TH2D*)trkCorr->InspectCorr(1,cBin,cBin,trkCorr->jetBin_->FindBin(200.),trkCorr->jetBin_->FindBin(jet));
   gPad->SetRightMargin(0.15);
   hCorr2DFak->SetAxisRange(1,119.9,"Y");
   hCorr2DFak->SetAxisRange(0,1,"Z");
   hCorr2DFak->Draw("colz");
   cEff2D->Print(outdir+"/"+tag+"_2D.gif");
   
   /////////////////////////////////////////////////////////////////////////////////////
   // Test corr
   /////////////////////////////////////////////////////////////////////////////////////
   if (doTestCorr) {
      cout << "trk weight: " << trkCorr->GetCorr(pt,eta,jet,cBin) << endl;
      Double_t corr[4];
      for (Int_t i=1; i<=trkCorr->ptBin_->GetNbinsX(); ++i) {
         trkCorr->GetCorr(trkCorr->ptBin_->GetBinCenter(i),eta,jet,cBin,corr);
         cout << "trk pt: " << trkCorr->ptBin_->GetBinLowEdge(i) << " trk eff: " << corr[0] << " trk fak: " << corr[1] << endl;
      }
   }   
}
Esempio n. 8
0
void drawIaa( bool saveFigures=true) {

    const int nPtBin = 4;
    int ptBin[nPtBin+1] = {40, 50,60,80,9999};
    double ptBinPaDraw[nPtBin+1] = { 40.5 ,49.5, 58.5,  76.5,  123. } ;
    // double AvePtBin[nPtBin+1] = { 45, 54.1479, 67.4204, 99.6956, 9999};
    
    const int nCentBinHI = 2;
    const int centBinHI[nCentBinHI +1] = {-1, 10030, 13099}; 

    TH1D* hJetPt[7][10][6]; // [Collision][centrality][pt]
    TH1D* hIaa[10][6]; // [centrality][pt]
    
    for (int icent=1 ; icent<= 10 ; icent++) {
      for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
	
	hIaa[icent][ipt] = NULL;
	for (int icoll=0 ; icoll<6  ; icoll++) {
	  hJetPt[icoll][icent][ipt] = NULL;
	}
	
      }
    }
    
    TFile* histFile[7][6];  // [Collision][pt]                                                                                          
    for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
      for (int icoll=0 ; icoll<6 ; icoll++) {
	TString sampleName = getSampleName( icoll ) ;

	char* fname =  Form("ffFiles/jetEnergyResL2L3_smeared/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131018.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/centralValue/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/centralOct16th/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131016.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/jetEnergyResCorrectedOct16th/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131016.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/jetEnergyScaledMinus2percentOct17/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131017.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/ak5Cone/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131017.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//char* fname =  Form("ffFiles/jetEnergyResCorrected/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//char* fname =  Form("ffFiles/jetEnergyScaledPlus2percent/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/jetEnergyScaledMinus2percent/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/noElectronRejection/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//char* fname =  Form("ffFiles/leadingJetAnalysis/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/jetEnergySmearedBy10percent/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);
	//	char* fname =  Form("ffFiles/photonEnergyScaled/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20131011_photonEnergyScaledBy-0.015.root",sampleName.Data(), (int)ptBin[ipt-1], 9999);


	histFile[icoll][ipt] = new TFile(fname) ;
	cout << " Reading file : " << fname << endl;
	if ( histFile[icoll][ipt]->IsZombie()  == false ) {
	  cout << " Success." << endl;
	  if ( (icoll == kPPDATA) || (icoll == kPPMC) )   {  //  PP
	    int icent = 7 ; 
	    hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", icent)) ;
	    cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
	    //	    hJetPt[icoll][7][ipt]->Rebin(10);
	    // hJetPt[icoll][7][ipt]->Scale(1./10);
	    
	  }
	  if ( ( icoll == kHIDATA) ||  (icoll == kHIMC) ) { // PbPb
	    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
	      hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) );
	      cout << " Getting histogram : " << Form("jetPt_icent%d_final", centBinHI[icent] ) << endl;
	      //	      hJetPt[icoll][icent][ipt]->Rebin(10);
	      //hJetPt[icoll][icent][ipt]->Scale(1/10.);
	    }
	  }
	}
	else  
	  cout << " no such file " << endl;
      }
    }

    // Calculation of IAA
    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
      for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
	hIaa[icent][ipt] = (TH1D*)hJetPt[kHIDATA][icent][ipt]->Clone(Form("iaa_%s",hJetPt[kHIDATA][icent][ipt]->GetName()));
	hIaa[icent][ipt]->Divide(hJetPt[kPPDATA][7][ipt]);
      }
    }
    
    
    TH1D* hTempPt = new TH1D("hTemp",";p_{T}^{#gamma} (GeV);",200,10,300);
    
    TCanvas* c2 = new TCanvas("c2","",1000,450);
    makeMultiPanelCanvas(c2,nPtBin,2,0.0,0.0,0.2,0.15,0.02);
    for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {

        c2->cd(ipt);

        // draw pp
        hTempPt->SetXTitle("p_{T}^{Jet} (GeV)");
        hTempPt->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N^{#gamma}}");
        hTempPt->SetAxisRange(30,200,"X");
	//        hTempPt->SetAxisRange(0,0.025,"Y");
	hTempPt->SetAxisRange(0.00007,0.11,"Y");
        handsomeTH1(hTempPt,0);
        hTempPt->DrawCopy();
	gPad->SetLogy();
	

        handsomeTH1(hJetPt[kPPDATA][7][ipt], 1);
        hJetPt[kPPDATA][7][ipt]->SetMarkerStyle(24);
	hJetPt[kPPDATA][7][ipt]->Draw("same");

        // draw pbpb 
        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(hJetPt[kHIDATA][icent][ipt],kRed);
	    if ( icent == 2 ) hJetPt[kHIDATA][icent][ipt]->SetMarkerStyle(24);
	    hJetPt[kHIDATA][icent][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);
	/*
	  if ( ipt == nPtBin ) 
	  drawText(Form("p_{T}^{#gamma} > %dGeV, ", (int)ptBin[ipt-1]), 0.12+dx1+0.25,0.85,1,15);
	  else
	  drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.12+dx1,0.85,1,15);
	*/
	
        onSun(30,0,200,0);

        c2->cd(ipt + nPtBin);
	hTempPt->SetAxisRange(0,2.5,"Y");
	hTempPt->SetYTitle("Ratio of Yield PbPb/pp");
	handsomeTH1(hTempPt,0);
        hTempPt->DrawCopy();
                                                                                                               
        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
	  handsomeTH1(hIaa[icent][ipt],kRed);
	  if ( icent == 2 )         hIaa[icent][ipt]->SetMarkerStyle(24);
	  // if ( icent == 1 )   
	    hIaa[icent][ipt]->Draw("same");
	  jumSun(30,1,200,1);
        }
	
	
	
	
    }
    

    c2->cd(1);
    
    TLegend *l2 = new TLegend(0.5933981,0.3877892,0.9981436,0.7857262,NULL,"brNDC");
    easyLeg(l2,"2.76TeV");
    l2->AddEntry(hJetPt[kPPDATA][7][1],"pp", "p");
    l2->AddEntry(hJetPt[kHIDATA][2][1],"PbPb 30-100%", "p");
    l2->AddEntry(hJetPt[kHIDATA][1][1],"PbPb 0-30%", "p");
    l2->Draw();
    if (saveFigures)   c2->SaveAs("figures/pT_dependence_IAA_figure1.pdf");
    if (saveFigures)   c2->SaveAs("figures/pT_dependence_IAA_figure1.gif");


    TFile * fResults =  new TFile("resultHistograms.root","update");

    for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
      hJetPt[kPPDATA][7][ipt]->SetName(Form("dNdJetPt_forIaa_pp_ptBin%dAndHigher",ipt));
      hJetPt[kPPDATA][7][ipt]->Write();

      for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
        hJetPt[kHIDATA][icent][ipt]->SetName(Form("dNdJetPt_forIaa_pbpb_centralityBin%d_ptBin%dAndHigher",icent,ipt));
	hJetPt[kHIDATA][icent][ipt]->Write();
	
        hIaa[icent][ipt]->SetName(Form("Ryaa_centralityBin%d_ptBin%dAndHigher",icent,ipt));
	hIaa[icent][ipt]->Write();
      }

    }
    fResults->Close();
    
    
    
}
Esempio n. 9
0
void systErrCal(){
    gStyle -> SetOptStat(0);
    const int nPt = 4;
    const int nPurity = 3; // 
    double purity[nPurity] = {0.9, 1., 1.1} ;// purity*0.9 and so on.. 
    double AvePtBin[nPt+1] = {45.0, 55.0, 70.0, 100.0};
    double ptBin[nPt+1] = {40,50,60,80,9999};
    double ptBinPaDraw[nPt+1] = { 40.5 ,49.5, 58.5,  76.5,  123. } ;

    const int nCentBinHI = 2;
    const int centBinHI[nCentBinHI +1] = {-1, 10030, 13099}; 

    TH1D* hxjg10[7][10][6]; // [species][centrality][pt_dependence]
    TH1D* hxjg09[7][10][6]; // [species][centrality][pt_dependence]
    TH1D* hxjg11[7][10][6]; // [species][centrality][pt_dependence]
    TH1D* hJetPt10[7][10][6];
    TH1D* hJetPt09[7][10][6];
    TH1D* hJetPt11[7][10][6];
    TH1D* meanXjg[7][10][nPurity+1];      // [Collision][centrality][purity]
    TH1D* meanJetPt[7][10][nPurity+1];      // [Collision][centrality]
    TH1D* rjg[7][5][nPurity+1];     //  [Collision][centrality]

    for (int icoll=0 ; icoll<6  ; icoll++) {
        for (int icent=1 ; icent<= 10 ; icent++) {
            for(int ipu=0 ; ipu<nPurity ; ipu++) {
                meanXjg[icoll][icent][ipu] = new TH1D( Form("meanXjg_icoll%d_icent%d_ipu%d",icoll,icent,ipu), ";p_{T}^{#gamma} (GeV); <X_{J#gamma}>",nPt,ptBinPaDraw);
                meanJetPt[icoll][icent][ipu] = new TH1D( Form("meanJetPt_icoll%d_icent%d_ipu%d",icoll,icent,ipu), ";p_{T}^{#gamma} (GeV); <p_{T}^{Jet}>",nPt,ptBinPaDraw);
                rjg[icoll][icent][ipu]= new TH1D( Form("rjg_icoll%d_icent%d_ipu%d",icoll,icent,ipu), ";p_{T}^{#gamma} (GeV); R_{J#gamma}",nPt,ptBinPaDraw);
                for (int ipt=1 ; ipt<=nPt ; ipt++) {
                    hxjg10[icoll][icent][ipt] = NULL;
                    hxjg09[icoll][icent][ipt] = NULL;
                    hxjg11[icoll][icent][ipt] = NULL;
                    hJetPt10[icoll][icent][ipt] = NULL;
                    hJetPt09[icoll][icent][ipt] = NULL;
                    hJetPt11[icoll][icent][ipt] = NULL;
                }
            }
        }
    }
//    cout << "dlfja " << endl;
    
    TFile* histFile[7][6][nPurity+1];  // [Collision][pt]                                                                                      

    for (int ipt=1 ; ipt<=nPt ; ipt++) {
        for (int icoll=0 ; icoll<6 ; icoll++) {
            for (int ipu=0 ; ipu < nPurity ; ipu++) {
                TString sampleName = getSampleName( icoll ) ;
                char* fname = "";
                if (ipu==1) {fname =  Form("./ffFiles/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20130909_purity09.root",sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt]);
                } else if (ipu==0) {fname =  Form("./ffFiles/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20130909.root",sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt]);
                } else {fname =  Form("./ffFiles/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20130909_purity1.1.root",sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt]);
                }
                histFile[icoll][ipt][ipu] = new TFile(fname) ;
    //               cout << " Reading file : " << fname << endl;

                if ( histFile[icoll][ipt][ipu]->IsZombie()  == false ) {
      //                 cout << " Success." << endl;
                    if ( (icoll == kPPDATA) || (icoll == kPPMC) )   {  //  PP
                        int icent = 7 ; 
                        if (ipu==0) { hxjg10[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("xjg_icent%d_final", icent)) ;
                                        hJetPt10[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("jetPt_icent%d_final", icent)) ;
                        } else if (ipu==1) {hxjg09[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("xjg_icent%d_final", icent)) ;
                                        hJetPt09[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("jetPt_icent%d_final", icent)) ;
                        } else { hxjg11[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("xjg_icent%d_final", icent)) ;
                                        hJetPt11[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("jetPt_icent%d_final", icent)) ;
                        }
  //                      cout << " Getting histogram : " << Form("xjg_icent%d_final", icent) << endl;
  //                      cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
                    }
                
                    if ( ( icoll == kHIDATA) ||  (icoll == kHIMC) ) { // PbPb
                        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
                            if (ipu==0) { hxjg10[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("xjg_icent%d_final", centBinHI[icent] )) ;
                                            hJetPt10[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("jetPt_icent%d_final", centBinHI[icent] ) );
                            } else if (ipu==1) { hxjg09[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("xjg_icent%d_final", centBinHI[icent] )) ;
                                            hJetPt09[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("jetPt_icent%d_final", centBinHI[icent] ) );
                            } else { hxjg11[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("xjg_icent%d_final", centBinHI[icent] )) ;
                                    hJetPt11[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt][ipu]->Get(Form("jetPt_icent%d_final", centBinHI[icent] ) );
                            }
                            //  cout << " Getting histogram : " << Form("jetPt_icent%d_final", centBinHI[icent] ) << endl;
                            //  cout << " Getting histogram : " << Form("xjg_icent%d_final", centBinHI[icent] ) << endl;
                        histFile[icoll][ipt][ipu] -> Close();
                        }
                    }
                }
                else  
                    cout << " no such file " << endl;
            }
        }
    }

    for (int ipt=1 ; ipt<=nPt ; ipt++) {
        for (int icoll=0 ; icoll<6 ; icoll++) {
            for (int icent=1 ; icent<= 10 ; icent++ ) { 
                for (int ipu=0 ; ipu< nPurity ; ipu++ ) { 
                    if ( (hxjg10[icoll][icent][ipt] == NULL) && (hxjg09[icoll][icent][ipt] == NULL) && (hxjg11[icoll][icent][ipt] == NULL) ) 
                        continue;   // emtpy histogram 
                    double rVal, rErr;

                    if (ipu==0) rVal = hxjg10[icoll][icent][ipt]->IntegralAndError(1, hxjg10[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
                    else if (ipu==1) rVal = hxjg09[icoll][icent][ipt]->IntegralAndError(1, hxjg09[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
                    else rVal = hxjg11[icoll][icent][ipt]->IntegralAndError(1, hxjg11[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
                    rjg[icoll][icent][ipu]->SetBinContent( ipt, rVal );
                    rjg[icoll][icent][ipu]->SetBinError  ( ipt, rErr );
                    cout << "ipt : " << ipt << " icoll : " << icoll << " icent : " << icent << " ipu : " << ipu << " rVal : " << rVal << endl;            
                    if (ipu==0){
                        meanXjg[icoll][icent][ipu]->SetBinContent( ipt, hxjg10[icoll][icent][ipt]->GetMean() );
                        meanXjg[icoll][icent][ipu]->SetBinError  ( ipt, hxjg10[icoll][icent][ipt]->GetMeanError() );
                        meanJetPt[icoll][icent][ipu]->SetBinContent( ipt, hJetPt10[icoll][icent][ipt]->GetMean() );
                        meanJetPt[icoll][icent][ipu]->SetBinError  ( ipt, hJetPt10[icoll][icent][ipt]->GetMeanError() );
                    }else if (ipu==1){
                        meanXjg[icoll][icent][ipu]->SetBinContent( ipt, hxjg09[icoll][icent][ipt]->GetMean() );
                        meanXjg[icoll][icent][ipu]->SetBinError  ( ipt, hxjg09[icoll][icent][ipt]->GetMeanError() );
                        meanJetPt[icoll][icent][ipu]->SetBinContent( ipt, hJetPt09[icoll][icent][ipt]->GetMean() );
                        meanJetPt[icoll][icent][ipu]->SetBinError  ( ipt, hJetPt09[icoll][icent][ipt]->GetMeanError() );
                    } else {
                        meanXjg[icoll][icent][ipu]->SetBinContent( ipt, hxjg11[icoll][icent][ipt]->GetMean() );
                        meanXjg[icoll][icent][ipu]->SetBinError  ( ipt, hxjg11[icoll][icent][ipt]->GetMeanError() );
                        meanJetPt[icoll][icent][ipu]->SetBinContent( ipt, hJetPt11[icoll][icent][ipt]->GetMean() );
                        meanJetPt[icoll][icent][ipu]->SetBinError  ( ipt, hJetPt11[icoll][icent][ipt]->GetMeanError() );
                    } 
                }
            }
        }
    }
    
    TLegend *ly = new TLegend(0.4913112,0.6561548,0.9997611,0.9431145,NULL,"brNDC");
    easyLeg(ly,"2.76TeV");
    ly->AddEntry(meanJetPt[kPPDATA][7][1],"pp ","p");
    ly->AddEntry(meanJetPt[kHIDATA][2][1],"PbPb 0-30%","p");

    TLegend *l1 = new TLegend(0.4913112,0.6561548,0.9997611,0.9431145,NULL,"brNDC");
    easyLeg(l1,"2.76TeV");
    l1->AddEntry(meanJetPt[kPPDATA][7][1],"pp ","p");
    l1->AddEntry(meanJetPt[kHIDATA][1][1],"PbPb 30-100%","p");
    l1->AddEntry(meanJetPt[kHIDATA][2][1],"PbPb 0-30%","p");


    TCanvas* cJetpt = new TCanvas("c21","",500,500);
    for(int ipu=0; ipu<nPurity; ipu++){
        handsomeTH1(meanJetPt[kPPDATA][7][ipu]);
        if (ipu==0){
            meanJetPt[kPPDATA][7][ipu]->SetYTitle("<p_{T}^{Jet}>  (>30GeV)");
            //  meanJetPt[kPPDATA][7][ipu]->SetAxisRange(-2,2,"X");
            meanJetPt[kPPDATA][7][ipu]->SetAxisRange(30,95,"Y");
            meanJetPt[kPPDATA][7][ipu]->Draw();
        } else { 
            meanJetPt[kPPDATA][7][ipu]->Draw("same");
        }

    //    meanJetPt[kPPDATA][7][ipu]->SetMarkerStyle(24);
        meanJetPt[kPPDATA][7][ipu]->SetMarkerColor(kTeal+ipu);
        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(meanJetPt[kHIDATA][icent][ipu]);
            if ( icent == 2 ) meanJetPt[kHIDATA][icent][ipu]->SetMarkerStyle(24);
            //if ( icent != 2 ) meanJetPt[kHIDATA][icent]->Draw("same");
            meanJetPt[kHIDATA][icent][ipu]->Draw("same");
        }
    }

    l1 ->Draw();

    TCanvas* cXjg = new TCanvas("c31","",500,500);
    for(int ipu=0; ipu<nPurity; ipu++){
        handsomeTH1(meanXjg[kPPDATA][7][ipu]);
        if (ipu==0){
            meanXjg[kPPDATA][7][ipu]->SetYTitle("<x_{J#gamma}>  (>30GeV)");
            meanXjg[kPPDATA][7][ipu]->SetMarkerStyle(24);
            //  meanXjg[kPPDATA][7]->SetAxisRange(-2,2,"X");
            meanXjg[kPPDATA][7][ipu]->SetAxisRange(0.6,1.2,"Y");
            meanXjg[kPPDATA][7][ipu]->Draw();
        } else {
            meanXjg[kPPDATA][7][ipu]->Draw("same");
        }

        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(meanXjg[kHIDATA][icent][ipu]);
            if ( icent == 2 ) meanXjg[kHIDATA][icent][ipu]->SetMarkerStyle(24);
            //if ( icent != 2 ) meanXjg[kHIDATA][icent]->Draw("same");
            meanXjg[kHIDATA][icent][ipu]->Draw("same");
        }
    }
    l1->Draw();

    TCanvas* cRjg = new TCanvas("c_rjg","",500,500);

    for(int ipu=0; ipu<nPurity; ipu++){
        handsomeTH1(rjg[kPPDATA][7][ipu]);
        if (ipu==0){
            rjg[kPPDATA][7][ipu]->SetYTitle("r_{J#gamma}");
            rjg[kPPDATA][7][ipu]->SetMarkerStyle(24);
            //  rjg[kPPDATA][7]->SetAxisRange(-2,2,"X");
            rjg[kPPDATA][7][ipu]->SetAxisRange(0.0,1.1,"Y");
            rjg[kPPDATA][7][ipu]->Draw();
        } else {
            rjg[kPPDATA][7][ipu]->Draw("same");
        }

        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(rjg[kHIDATA][icent][ipu],kRed);
            if ( icent == 2 ) rjg[kHIDATA][icent][ipu]->SetMarkerStyle(24);
            //       if ( icent != 2 ) rjg[kHIDATA][icent]->Draw("same");
            rjg[kHIDATA][icent][ipu]->Draw("same");
        }
    }
    ly->Draw();

}
Esempio n. 10
0
void drawTrkCorrJetPtvGenJet(Int_t corrLevel=0,
    //TString mod="hitrkEffAnalyzer",
    //TString modref="hitrkEffAnalyzer",
    TString mod="hitrkEffAnalyzer_akpu3pf_j2",
    TString modref="hitrkEffAnalyzer_akpu3pf_j1",
    //TString mod="hiHighPtTrkEffAnalyzer_akpu3pf_j2",
    //TString modref="hiHighPtTrkEffAnalyzer_akpu3pf_j1",
    //TString mod="B2InConeJ2",
    //TString modref="B2InConeJ1",
    //TString app="_mattgmv1",
    TString appref="_tev6",
    TString app="_tev6",
    //TString appref="_tev7hpt",
    TString appgenjet="_tev7genjet",
    //TString app="_ppv1",
    //TString appref="_ppv1",
    //TString app="_pphptv1",
    //TString appref="_pphptv1",
    //TString app = "_LargeSet1_1k_rereco",
    //TString appref = "_LargeSet1_1k",
    //TString app="_jtv5_cv6",
    //TString appref="_jtv5_cv6",
    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 centBeg=0, centEnd=2; // HI: 0-30%
  //Int_t centBeg=0, centEnd=4; // pp: all cent

  Corrector3D trkCorr("trkCorrHisAna_djuq",app,mod);
  trkCorr.ptHatMin_.clear();
  trkCorr.ptHatMin_.push_back(50);
  trkCorr.ptHatMin_.push_back(80);
  trkCorr.ptHatMin_.push_back(110);
  trkCorr.ptHatMin_.push_back(170);
  trkCorr.sampleMode_ = 1; // 0 for choosing individual sample, 1 for merge samples
  trkCorr.Init();

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

  Corrector3D trkCorrGenJet("trkCorrHisAna_djuq",appgenjet,mod);
  trkCorrGenJet.ptHatMin_.clear();
  trkCorrGenJet.ptHatMin_.push_back(80);
  trkCorrGenJet.sampleMode_ = 1; // 0 for choosing individual sample, 1 for merge samples
  trkCorrGenJet.Init();

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

  cout << endl << "========= plot =========" << endl;
  Float_t ptMin=4;
  Int_t ptBegBin = trkCorr.ptBin_->FindBin(ptMin);
  Int_t ptEndBin = trkCorr.ptBin_->FindBin(200);
  cout << "pt beg bin: " << ptBegBin << " end bin: " << ptEndBin << endl;
  cout << "========================" << endl;

  TCanvas * cEff = new TCanvas("cEff","cEff",500,500);
  // eff
  TH1D * hCorrPtRefJet100 = (TH1D*) trkCorrRef.InspectCorr(0,isample,centBeg,centEnd,ptBegBin,ptEndBin,3,7-etaPM,7+etaPM);
  handsomeTH1(hCorrPtRefJet100);
  hCorrPtRefJet100->SetAxisRange(41,499.9,"X");
  hCorrPtRefJet100->SetAxisRange(0,1,"Y");
  hCorrPtRefJet100->SetTitle(";Jet p_{T} (GeV/c); Eff., Fake Rate");
  hCorrPtRefJet100->SetMarkerStyle(kOpenCircle);
  hCorrPtRefJet100->Draw("E");
  TH1D * hCorrPtJet40 = (TH1D*) trkCorr.InspectCorr(0,isample,centBeg,centEnd,ptBegBin,ptEndBin,3,7-etaPM,7+etaPM);
  hCorrPtJet40->Draw("same E");
  // genjet
  TH1D * hCorrRefPtGenJet100 = (TH1D*) trkCorrRefGenJet.InspectCorr(0,isample,centBeg,centEnd,ptBegBin,ptEndBin,3,7-etaPM,7+etaPM);
  hCorrRefPtGenJet100->SetMarkerColor(kRed);
  hCorrRefPtGenJet100->SetMarkerStyle(kOpenCircle);
  hCorrRefPtGenJet100->Draw("same E");
  TH1D * hCorrPtGenJet40 = (TH1D*) trkCorrGenJet.InspectCorr(0,isample,centBeg,centEnd,ptBegBin,ptEndBin,3,7-etaPM,7+etaPM);
  hCorrPtGenJet40->SetMarkerColor(kRed);
  hCorrPtGenJet40->Draw("same E");

  // fake
  TH1D * hCorr1PtRefJet100 = (TH1D*) trkCorrRef.InspectCorr(1,isample,centBeg,centEnd,ptBegBin,ptEndBin,3,7-etaPM,7+etaPM);
  hCorr1PtRefJet100->SetMarkerStyle(kOpenCircle);
  hCorr1PtRefJet100->Draw("sameE");
  TH1D * hCorr1PtJet40 = (TH1D*) trkCorr.InspectCorr(1,isample,centBeg,centEnd,ptBegBin,ptEndBin,3,7-etaPM,7+etaPM);
  hCorr1PtJet40->Draw("sameE");

  TLegend *leg = new TLegend(0.21,0.25,0.51,0.55);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
  leg->AddEntry(hCorrPtRefJet100,"PYTHIA HYDJET","");
  leg->AddEntry(hCorrPtRefJet100,"#hat{p}_{T} > 80 GeV/c","");
  leg->AddEntry(hCorrPtRefJet100,"0-30%, |#eta^{Trk}|<1, p_{T}^{Trk} > 4 GeV/c","");
  leg->AddEntry(hCorrPtRefJet100,Form("Leading RecJet"),"p");
  leg->AddEntry(hCorrPtJet40,Form("Subleading RecJet"),"p");
  leg->AddEntry(hCorrRefPtGenJet100,Form("Leading GenJet"),"p");
  leg->AddEntry(hCorrPtGenJet40,Form("Subleading GenJet"),"p");
  leg->Draw();

  cEff->Print("TrkCorr_vs_JetPt_Central"+app+"_vsGenJet.gif");
  cEff->Print("TrkCorr_vs_JetPt_Central"+app+"_vsGenJet.pdf");
}
Esempio n. 11
0
void hfCentrality(char* fname = "r151878.root",  char* trg="anaPixelHitJet50U")
{
   
   TFile *f1=new TFile(Form("/d101/kimy/macro/pixelTrees/rootFiles/%s",fname),"r");
   TTree *trPixMB = (TTree*)f1->Get("anaPixelHitMB/PixelTree");
   TTree *trPixJet = (TTree*)f1->Get("anaPixelHitJet50U/PixelTree");
   
   //   const int nscEtBin = 10;
   //   double scetBin[nscEtBin+1] = { 15.1,18,21,24,28,32,36,40,48,55,70};
   
   TH1D* hhfMB  = new TH1D(Form("hhfMB",trg),";Sum HF Energy (TeV);Fraction of minimum bias events",70,0,160);
   TH1D* hhfMB1  = (TH1D*)hhfMB->Clone("hhfMB1");
   TH1D* hhfMB2  = (TH1D*)hhfMB->Clone("hhfMB2");
   TH1D* hhfMB3  = (TH1D*)hhfMB->Clone("hhfMB3");
   TH1D* hhfJET  = (TH1D*)hhfMB->Clone("hhfJET");

   TCanvas* c1 = new TCanvas(Form("c1_%s",trg),"",400,400);

   trPixMB->Draw("hf/1000.>>hhfMB");
   trPixMB->Draw("hf/1000.>>hhfMB1","cBin<=4");
   trPixMB->Draw("hf/1000.>>hhfMB2","cBin>=4 && cBin<=12");
   trPixMB->Draw("hf/1000.>>hhfMB3","cBin>=12 && cBin<=35");
   
   trPixJet->Draw("hf/1000.>>hhfJET");

   
   handsomeTH1(hhfMB1,1);
   handsomeTH1(hhfMB2,2);
   handsomeTH1(hhfMB3,4);
   hhfMB1->SetFillColor(1);
   hhfMB2->SetFillColor(2);
   hhfMB3->SetFillColor(4);

   
   hhfMB->Scale(1./hhfMB->GetEntries());
   hhfMB->SetAxisRange(1e-5,1,"Y");
   hhfJET->Scale(1./hhfJET->GetEntries());
   hhfJET->SetAxisRange(1e-5,1,"Y");

   hhfMB->SetLineWidth(2);
   handsomeTH1(hhfMB);
   hhfMB->DrawCopy();
   
   //   TLine* t1 = new TLine(.511,1e-5,.511,hhfMB->GetBinContent(hhfMB->FindBin(0.511)));
   TLine* t1 = new TLine(0,1e-5,.511,hhfMB->GetBinContent(hhfMB->FindBin(0.511)));
   TLine* t2 = new TLine(35.397,1e-5,35.397,hhfMB->GetBinContent(hhfMB->FindBin(35.397)));
   TLine* t3 = new TLine(79.370,1e-5,79.370,hhfMB->GetBinContent(hhfMB->FindBin(79.370)));
   t1->SetLineWidth(1);
   t2->SetLineWidth(1);
   t3->SetLineWidth(1);
   t1->SetLineStyle(7);
   t2->SetLineStyle(7);
   t3->SetLineStyle(7);
   t1->Draw();
   t2->Draw();
   t3->Draw();
   
   //  hhfMB3->DrawCopy();
   //  hhfMB2->DrawCopy("same");
   //  hhfMB1->DrawCopy("same");
   gPad->SetLogy();

   TLegend* leg0 = new TLegend(0.2813131,0.7115054,0.9,0.8439785,NULL,"brNDC");
   TLegend* leg0b =new TLegend(0.3813131,0.7115054,1,0.8439785,NULL,"brNDC");
   TLegend* leg1 = new TLegend(0.1767677,0.3826344,0.4467677,0.5875591,NULL,"brNDC");
   TLegend* leg2 = new TLegend(0.3611111,0.3876344,0.6111111,0.5865591,NULL,"brNDC");
   TLegend* leg3 = new TLegend(0.5606061,0.3876344,0.8106061,0.5865591,NULL,"brNDC");

   easyLeg(leg0b,"Centrality, HLT_HIJet50U");

   easyLeg(leg1,"30%-100%");
   easyLeg(leg2,"10%-30% ");
   easyLeg(leg3," 0%-10% ");

   //   TCanvas* c2 = new TCanvas(Form("c2_%s",trg),"",400,400);
   
   float triggerRatio = 0.29 / 49.;
   
   hhfJET->SetLineWidth(2);
   hhfJET->SetLineColor(2);
   hhfJET->SetFillColor(2);
   hhfJET->SetFillStyle(3544);
   hhfJET->Scale(triggerRatio);
   hhfJET->DrawCopy("same");
   
   easyLeg(leg0,"Centrality");
   leg0->AddEntry(hhfMB,"HLT_MinBiasHForBSC_Core","l");
   leg0->AddEntry(hhfJET,"HLT_HiJet50U","l");
   leg0->Draw();
   //   leg1->Draw();
   //   leg2->Draw();
   //   leg3->Draw();
     
   TLatex *bint = new TLatex(0.1867677,0.4876344,"30%-100%");
   bint->SetTextFont(63);
   bint->SetTextSize(13);
   bint->SetNDC();
   bint->Draw();

   bint = new TLatex(0.4011111,0.4876344,"10%-30% ");
   bint->SetTextFont(63);
   bint->SetTextSize(13);
   bint->SetNDC();
   bint->Draw();

   bint = new TLatex(0.6006061,0.4876344," 0%-10% ");
   bint->SetTextFont(63);
   bint->SetTextSize(13);
   bint->SetNDC();
   bint->Draw();

 
   TLatex *cms = new TLatex(0.6013,0.89,"CMS Preliminary");
   cms->SetTextFont(63);
   cms->SetTextSize(16);
   cms->SetNDC();
   cms->Draw();
   c1->SaveAs("hf_centrality_distribution_mb_jet50_20101126_v1.eps");
   c1->SaveAs("hf_centrality_distribution_mb_jet50_20101126_v1.gif");
   c1->SaveAs("hf_centrality_distribution_mb_jet50_20101126_v1.C");

   // TCanvas* c2 = new TCanvas(Form("c2_%s",trg),"",400,400);
   //  hhfJET->Divide(hhfMB);
   //  hhfJET->Draw();
   //   c2->SaveAs("ratio.gif");
   
   //  TLine* t1j = new TLine(.511,1e-5,.511,hhfJET->GetBinContent(hhfJET->FindBin(0.511)));
   //  TLine* t2j = new TLine(35.397,1e-5,35.397,hhfJET->GetBinContent(hhfJET->FindBin(35.397)));
   //  TLine* t3j = new TLine(79.370,1e-5,79.370,hhfJET->GetBinContent(hhfJET->FindBin(79.370)));
   //  t1j->SetLineWidth(2);
   // t2j->SetLineWidth(2);
   //  t3j->SetLineWidth(2);
   //  t1j->Draw();
   //  t2j->Draw();
   // t3j->Draw();
   

   
   //   TLegend* leg0 = new TLegend(0.46,0.80, 0.99, 0.95,NULL,"brNDC");
   //  easyLeg(leg0,"offline cleaned Superlclusters");
   //   leg0->AddEntry(hetSc,"HLT_HIPhoton15");
   //  leg0->AddEntry(hetScClean,"HLT_HICleanPhoton15");
   // leg0->Draw();
   
}
Esempio n. 12
0
void fitResolandScale(int collision = 2, int flvOpt = 0, int genOpt = 0){
    /*  const int kHIcentral = 0; // 0-30%
        const int kHIperipheral = 1;//30-100%
        const int kPP = 2;
        const int kPA = 3;
        const int kHI010 = 4; //0-10%
        const int kHI1030 = 5; //10-30%
        const int kHI3050 = 6;//30-50%
        const int kHI50100 = 7;//50-100%

*/
   // const int collision = 3;
    TLegend *l1 = new TLegend(0.4365615,0.6445304,0.9577623,0.846736,NULL,"brNDC");

    TCut centCut = "";
    if ( (collision ==0) )   {   
        centCut = "cBin > 0 && cBin< 12";
        easyLeg(l1,"Pb+Pb 0-30%");
    }
    else if (  (collision ==1) ){  // if it's pp 
        centCut = "cBin >=12";
        easyLeg(l1,"Pb+Pb 30-100%");
    }
    else if (collision == 2 || collision == 3){ // pPb
        centCut = "";
        if (collision == 2) easyLeg(l1,"p+p");
        else easyLeg(l1, "p+Pb");
    }
    else if (  (collision ==4) ){  //HI
        centCut = "cBin > 0 && cBin < 4";
        easyLeg(l1,"Pb+Pb 0-10%");
    } else if (  (collision ==5) ){  //HI
        centCut = "cBin >= 4 && cBin < 12";
        easyLeg(l1,"Pb+Pb 10-30%");
    } else if (  (collision ==6) ){  //HI
        centCut = "cBin >= 12 && cBin < 20";
        easyLeg(l1,"Pb+Pb 30-50%");
    } else if (  (collision ==7) ){  //HI
        centCut = "cBin >= 20";
        easyLeg(l1,"Pb+Pb 50-100%");
    }    

    //        
    TH1::SetDefaultSumw2();

    // gStyle->SetOptFit(0);
    gStyle -> SetOptStat(0);
    //  gStyle -> SetTitleYOffset(2.35);
    gStyle -> SetTitleYSize(0.04);


    TCut partonCut = "";
    if (flvOpt ==0 ) partonCut = "";
    else if (flvOpt == 1 ) partonCut = "refPartonFlv == 21";
    else if (flvOpt == 2 ) partonCut = "abs(refPartonFlv) < 21";
    else partonCut = "refPartonFlv < -200";


    const int nPtBin = 12;
    //const int nPtBin = 17;
    //double ptBin[nPtBin+1] = {30.0, 40.0, 50.0, 80.0, 9999.0}; 
    //double AvePtBin[nPtBin+1] = { 35.0, 45.0, 65.0, 100.0};
    double ptBin[nPtBin+1];
    double AvePtBin[nPtBin];

    ptBin[0] = 30.0;
    ptBin[1] = 40.0;
    ptBin[2] = 50.0;
    ptBin[3] = 60.0;
    ptBin[4] = 70.0;
    ptBin[5] = 80.0;
    ptBin[6] = 90.0;
    ptBin[7] = 100.0;
    ptBin[8] = 120.0;
    ptBin[9] = 140.0;
    ptBin[10] = 160.0;
    ptBin[11] = 180.0;
    ptBin[12] = 200.0;

    /*
       for(int i=0;i<=nPtBin;i++){
       ptBin[i] = 30.0+i*10.0;
       }
       */  
    for(int i=0;i<nPtBin;i++){
        AvePtBin[i] = (ptBin[i+1]+ptBin[i])/2.0;
    }

    //    const int nCentBinPa = 3;
    //   double centBinPa[nCentBinPa+1] = {0,20,30,100};
    //
    // fake rate
    //
    int nJetmax = 100;
    float refPt[nJetmax], pt[nJetmax], eta[nJetmax], dphi[nJetmax];
    int nJet, cBin, refPartonFlv[nJetmax];
    EvtSel evtImb;
    TBranch *b_evt;

    multiTreeUtil* yJet = new multiTreeUtil();
    //:PbPb
    if(collision ==1 || collision == 0  || collision == 4 || collision == 5 || collision == 6|| collision == 7){
        yJet -> addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_qcdAllPhoton30to50_genPhotonPtCut40_allCent.root", "yJet", "",32796./32796);
        yJet -> addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_qcdAllPhoton50to80_genPhotonPtCut40_allCent.root", "yJet", "",21470./53876);
        yJet -> addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_qcdAllPhoton80to9999_genPhotonPtCut40_allCent.root", "yJet", "",6462./58781);  
    } else if (collision ==3){
        // pA
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_PA2013_pyquen_allQCDPhoton30to50_forestv85.root", "yJet","", 56669./50385);
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_PA2013_pyquen_allQCDPhoton50to80_forestv85.root", "yJet","", 41906./114136);
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_PA2013_pyquen_allQCDPhoton80to120_forestv85.root", "yJet","",12044./103562);
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_PA2013_pyquen_allQCDPhoton120to9999_forestv85.root", "yJet","", 4481./151511);
    } else if (collision ==2){
        //pp 
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_merged_allQCDPhoton30to50_genPhotonPtCut30_CMSSW538HIp2.root", "yJet", "",29329. / 29329.);
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_merged_allQCDPhoton50to80_genPhotonPtCut30_CMSSW538HIp2.root", "yJet", "",8098. / 87988.);
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_merged_allQCDPhoton80to120_genPhotonPtCut30_CMSSW538HIp2.root", "yJet", "",1680. / 96756.);
        yJet->addFile("/home/jazzitup/forestFiles/yskimmedFiles/yskim_merged_allQCDPhoton120to9999_genPhotonPtCut30_CMSSW538HIp2.root", "yJet", "", 438.   / 90972.);
    }

    yJet -> AddFriend("tgj");
    yJet->AddFriend("yPhotonTree");


    TCanvas* c4 = new TCanvas("c4","",400,800);
    c4->Divide(1,2);
    c4->cd(1);
    TH1D* hpt1 = new TH1D("hpt1",";p_{T}^{RECO};Entries",20,0,200);
    TH1D* hpt0 = (TH1D*)hpt1->Clone("hpt2");
    TH1D* hpt2 = (TH1D*)hpt1->Clone("hpt2");
    TH1D* hpt3 = (TH1D*)hpt1->Clone("hpt3");

    yJet -> Draw2(hpt0, "refPt", Form(" photonEt>40 && genPhotonEt> 30 && abs(genMomId)<=22 && (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) "),"");
    yJet -> Draw2(hpt1, "refPt", Form("  photonEt>40 &&  genPhotonEt> 30 && abs(genMomId)<=22 && (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && refPartonFlv == 21"),"");
    yJet -> Draw2(hpt2, "refPt", Form(" photonEt>40 &&  genPhotonEt> 30 && abs(genMomId)<=22 && (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && abs(refPartonFlv)<21 "),"");
    yJet -> Draw2(hpt3, "refPt", Form(" photonEt>40 &&  genPhotonEt> 30 && abs(genMomId)<=22 && (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && refPartonFlv < -200"),"");

    handsomeTH1(hpt0,1);
    handsomeTH1(hpt1,1);
    handsomeTH1(hpt2,2);
    handsomeTH1(hpt3,4);

    hpt0->GetYaxis()->SetTitleOffset(1.8);

    hpt0->DrawCopy("hist");
    hpt1->DrawCopy("same");
    hpt2->DrawCopy("same");
    hpt3->DrawCopy("same");
    jumSun(30,0,30,7400,2);

    c4->cd(2);
    hpt1->Divide(hpt0);
    hpt2->Divide(hpt0);
    hpt3->Divide(hpt0);
    hpt1->SetAxisRange(0,1,"Y");
    hpt1->SetYTitle("Ratio");
    hpt1->DrawCopy();
    hpt2->DrawCopy("same");
    hpt3->DrawCopy("same");
    jumSun(30,0,30,1,2);

    //    return;


    // pt spectrum
    //    TCanvas* c1=  new TCanvas("c1", "", 500,500);
    //   TH1D* hptHat = new TH1D("hptHat",";pt hat;Entries",200,0,200);
    //   yJet->Draw3( hptHat, "yPhotonTree.ptHat"," photonEt>40 && genPhotonEt> 30 && abs(genMomId)<=22","");
    //yJet->Draw3( hptHat, "yPhotonTree.pt","","");
    //    return;


    // Energy Scale
    TCanvas* c2 = new TCanvas("c2", "pt/refPt distribution", 1200, 900); 
    TCanvas* ccc = new TCanvas("ccc", "pt/refpt 30-40GeV", 400, 400); 
    makeMultiPanelCanvas(c2,5,4,0.0,0.0,0.2,0.15,0.02);


    TH1D* Escale[nCentBinPa+5][nPtBin];
    double mean[nCentBinPa+5][nPtBin], var[nCentBinPa+5][nPtBin], resol[nCentBinPa+5][nPtBin], resolVar[nCentBinPa+5][nPtBin];
    int icent =1;
    // for(int icent=1; icent <= nCentBinPa ; icent++){
    for(int i=0; i < nPtBin ; i++){
        //  c2 -> cd((icent-1)*4+i+1);
        c2 -> cd(i+1);
        Escale[icent][i] = new TH1D(Form("Escale%d_%d",icent, i) , " ;  p_{T}^{RECO}/p_{T}^{GEN}", 50, 0, 2);

        if ( genOpt == 0 )  {
            yJet -> Draw2(Escale[icent][i], "pt/refPt", centCut && partonCut && Form(" (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && (refPt >= %d && refPt < %d)", (int)ptBin[i], (int)ptBin[i+1]),""); 
        }
        else if (genOpt == 1)  {
            yJet -> Draw2(Escale[icent][i], "pt/refPt", centCut && partonCut && Form(" (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && (pt >= %d && pt < %d) ", (int)ptBin[i], (int)ptBin[i+1]),"");
        }
        //         Escale[icent][i] -> Draw(); 
        TF1* ff = cleverGaus(Escale[icent][i]);
        gPad->SetLogy();
        mean[icent][i] = ff->GetParameter(1);
        var[icent][i] = ff->GetParError(1);
        resol[icent][i] = ff->GetParameter(2);
        resolVar[icent][i] = ff->GetParError(2);

        float dx1;    
        // ((icent==1)||(icent==4))? dx1=0.15 : dx1=0 ;
        dx1=0;
        //            if ( icent == nCentBinPa )
        //  drawText(Form("E_{T}^{HF|#eta|>4} > %dGeV, ", (int)centBinPa[icent-1]), 0.12+dx1,0.929118,1,15);//yeonju 130805
        //else
        //    drawText(Form("%dGeV < E_{T}^{HF|#eta|>4} < %dGeV, ", (int)centBinPa[icent-1], (int)centBinPa[icent]), 0.12+dx1,0.929118,1,15);

        if ( i+1 == nPtBin ) 
            drawText(Form("p_{T}^{GEN Jet} > %dGeV, ", (int)ptBin[i]), 0.17+dx1,0.84,1,15);//yeonju 130823
        else
            drawText(Form("%dGeV < p_{T}^{GEN Jet} < %dGeV, ", (int)ptBin[i], (int)ptBin[i+1]), 0.17+dx1,0.84,1,12);//yeonju 130823

        //            TLegend *l1 = new TLegend(0.6365615,0.6445304,0.9577623,0.846736,NULL,"brNDC");
        //            easyLeg(l1,"p+Pb 5.02TeV");
        //    l1->AddEntry(hxjgNorm[kPADATA][icent + kPADATA*50][j],"pPb ","p");
        //                  if ( icent==1 && j==1)   l1->Draw();
    }
    // }
    c2 -> Update();

    ccc -> Divide(2,1);
    ccc -> cd(1);
    Escale[1][0]->Draw();
    ccc -> cd(2);
    Escale[1][1]->Draw();



    //
    // Energy Scale
    //

    TCanvas *c3 = new TCanvas("c3", "Energy Scale vs. jet pt",147,37,930,465);
    c3->Divide(2,1);
    c3->cd(1);
    
    double bin[nPtBin+1];
    
    for(int ibin=0; ibin<nPtBin+1; ibin++){
        bin[ibin]=ptBin[ibin];
    }
    
    TH1D* hscale = new TH1D("hscale", ";JetP_{T}^{GEN} (GeV); Energy Scale ", nPtBin, bin);
    l1 -> Draw();
    handsomeTH1(hscale,1);
    hscale -> SetAxisRange(0.9, 1.15, "Y");
    hscale -> Draw();
    jumSun(30,1,200,1);
    
    TLegend *l3=new TLegend(0,0,0.4490239,0.08695652,NULL,"brNDC");
    l3->SetTextFont(42);
    l3->SetTextSize(0.04);
    l3->SetFillColor(0);
    l3->SetLineColor(0);

    for(int i=0; i < nPtBin ; i++){ 
        hscale -> SetBinContent(i+1, mean[icent][i]);
        hscale -> SetBinError(i+1, var[icent][i]);
        hscale -> SetMarkerStyle(20);
        hscale -> SetMarkerSize(1);
        hscale -> Draw("same p");
    }

    TF1 *fs = new TF1("fs", myFunc, 30, 200, 3);
    fs -> SetParameters(0.9,0.8,0.001);
    fs -> SetParNames("scale_C", "scale_S", "scale_N");

    double params[3];

    hscale -> Fit("fs", "RLL");
    fs->GetParameters(params);
    cout << " scale C : " << params[0] << ", S : " << params[1] << ", N : : " << params[2] << endl;
    // cout << " N : " << param[0] << endl;

    fs->Draw("same");


    //
    // Energy Resolution
    //
    c3->cd(2);

    TH1D* hresol = new TH1D("hresol", ";JetP_{T} (GeV); Energy Resolution ", nPtBin, bin);
    handsomeTH1(hresol,1);
    hresol -> SetAxisRange(0.0, 0.3, "Y");
    hresol->GetYaxis()->CenterTitle();
    hresol -> Draw();

    jumSun(30,0.0,30,0.3,2);

    TLegend *l_resol=new TLegend(0.40,0.20,0.85,0.42);
    l_resol->SetTextFont(42);
    l_resol->SetTextSize(0.04);
    l_resol->SetFillColor(0);
    l_resol->SetLineColor(0);

    for(int i=0; i < nPtBin ; i++){ 
        hresol -> SetBinContent(i+1, resol[icent][i]);
        hresol -> SetBinError(i+1, resolVar[icent][i]);
        hresol -> SetMarkerStyle(20);
        hresol -> SetMarkerSize(1);
        hresol -> Draw("same p");
    }
    
    TF1 *f;
  //  if(collision==2){ 
        f = new TF1("f", myFunc3, 30, 200, 3);
        f -> SetParameters(0.03, 0.8, 0.01);
        f -> SetParNames("C", "S", "N");

    //   } else { 
 //       f = new TF1("f", myFunc3, 30, 200, 3);
   //     f -> SetParameters(0.041, 0.956,0.001);
  //      f -> SetParNames("N");
  //  }

    double param[3];

    hresol -> Fit("f", "RLL");
    f->GetParameters(param);
 //   cout << " resol_N : " << param[0]<< endl;
//  if(collision==2) cout << " resol C : " << param[0] << ", S : " << param[1] << ", N : : " << param[2] << endl;
    cout << " resol C : " << param[0] << ", S : " << param[1] << ", N : : " << param[2] << endl;
 //  else cout << " N : " << param[0] << endl;

    f->Draw("same");
    l1 -> Draw();
    //  l_resol->Draw();
    //flvOpt = 0, int genOpt
    // c1 -> SaveAs(".gif");
    //c2 -> SaveAs(Form("./graph/CSnotFix_scale_distribution_collision%d.pdf",collision));
    //c3 -> SaveAs(Form("./graph/CSnotFix_scale_resolution_fit_collision%d.pdf",collision));
    //    c_fake -> SaveAs(".gif");
}
Esempio n. 13
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");



}
Esempio n. 14
0
void drawDijetPtHat() 
  
{
  TH1::SetDefaultSumw2();
 
  vector<int> ptHat_;
  vector<float> cs_;
  //  ptHat_.push_back(30);   cs_.push_back(1.079e-02);
  //  ptHat_.push_back(50);   cs_.push_back(1.021e-03);
  ptHat_.push_back(80);   cs_.push_back(9.913e-05);
  ptHat_.push_back(120);  cs_.push_back(1.128e-05);
  ptHat_.push_back(170);  cs_.push_back(1.470e-06);
  ptHat_.push_back(200);  cs_.push_back(5.310e-07);
  ptHat_.push_back(250);  cs_.push_back(1.192e-07);
  ptHat_.push_back(300);  cs_.push_back(3.176e-08);

  multiTreeUtil* tdj= new multiTreeUtil();
  /*  tdj->addFile("jskim_Dijet80_merged_nMix10_July-v1.root","tdj","pthat<120",1);
  tdj->addFile("jskim_Dijet120_merged_nMix10_July-v1.root","tdj","pthat<170",1);
  tdj->addFile("jskim_Dijet170_merged_nMix10_July-v1.root","tdj","pthat<200",1);
  tdj->addFile("jskim_Dijet200_merged_nMix10_July-v1.root","tdj","pthat<250",1);
  tdj->addFile("jskim_Dijet250_merged_nMix10_July-v1.root","tdj","pthat<300",1);
  tdj->addFile("jskim_Dijet300_merged_nMix10_July-v1.root","tdj","",1);
  
  */
    tdj->addFile("jskim_Dijet80_merged_nMix10_July-v1.root","tdj","pthat<120",(9.913e-05 )/78549);
    tdj->addFile("jskim_Dijet120_merged_nMix10_July-v1.root","tdj","pthat<170",( 1.128e-05)/34838);
    tdj->addFile("jskim_Dijet170_merged_nMix10_July-v1.root","tdj","pthat<200",( 1.470e-06)/6108);
    tdj->addFile("jskim_Dijet200_merged_nMix10_July-v1.root","tdj","pthat<250",(5.310e-07 )/35838);
    tdj->addFile("jskim_Dijet250_merged_nMix10_July-v1.root","tdj","pthat<300",( 1.192e-07)/29132);
    tdj->addFile("jskim_Dijet300_merged_nMix10_July-v1.root","tdj","",(3.176e-08)/43015);
  
  
  TH1D* htemp[10];
  int color[10];
  color[0]=1;
  color[1]=2;
  color[2]=4;
  color[3]=5;
  color[4]=6;
  color[5]=9;
  color[6]=1;
 
  TCanvas* c1= new TCanvas("c1","",1000,800);
  c1->Divide(1,2);
    c1->cd(1);
  TH1D* hptljet = new TH1D("hptljet",";leading jet pT (GeV);",48,120,600);
  tdj->Draw2(hptljet,"lJetPt","","");
  TLegend* l1 = new TLegend(0.6723432,0.670013,0.9206198,0.9506693,NULL,"brNDC");
  easyLeg(l1,"");

  for (int i=0;i<=5;i++) {
    htemp[i] = new TH1D(Form("htemp_%d",i),"",10,0,10);
    handsomeTH1(htemp[i], color[i]);
    l1->AddEntry(htemp[i],Form("pt-hat : %dGeV",ptHat_[i]),"l");
  }
  l1->Draw();
  drawText("Leading jet", 0.5,0.9);
  
  c1->cd(2);
  TH1D* hptsljet = new TH1D("hptsljet",";Subleading jet pT (GeV);",55,50,600);
  tdj->Draw2(hptsljet,"slJetPt","","");
  drawText("Subleading jet", 0.5,0.9);



}
Esempio n. 15
0
void updateHIN11010(int etPho = 60, int etJet = 30, bool scaleByR=true, bool drawMC=true, int prodDate=20131021) {
  bool mcOnly=false;

  int percentBin[5] = {0,10,30,50,100};
  TH1D* hxgj[5][10];   //[data kind] [ centrality] 
  TH1D* hxgjpp[20];
  TFile *fSum1 = new TFile(Form("histOutputFiles60GeVInclusive/HisOutput_Photonv7_v29_akPu3PF_InclPtRatio_gamma%djet%ddphiSig2749_Isol0_Norm1.root",etPho,etJet));
  for ( int icent=0; icent<=3 ; icent++) { 
    hxgj[khimc][icent] =  (TH1D*)fSum1->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khimc,icent));
    hxgj[khidata][icent] =  (TH1D*)fSum1->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khidata,icent));
  }
  hxgjpp[kppdata] = (TH1D*)fSum1->Get("dataSrc2_reco1_cent0SubtractedExtrapExtrapNorm");

  TFile *fSum2 = new TFile(Form("histOutputFiles60GeVInclusive/HisOutput_Photonv7_v29_akPu3PF_InclPtRatio_gamma%djet%ddphiSig2749_Isol0_Norm2.root",etPho,etJet));
  TGraphAsymmErrors* mxhimc = (TGraphAsymmErrors*)fSum2->Get("dataSrc0_reco1_x_Summary_0");
  TGraphAsymmErrors* mxhidata = (TGraphAsymmErrors*)fSum2->Get("dataSrc1_reco1_x_Summary_0");
  //  TGraphAsymmErrors* mxppdata = (TGraphAsymmErrors*)fSum2->Get("dataSrc2_reco1_x_Summary_0");
  TGraphAsymmErrors* mxppdata;
  TGraphAsymmErrors* mxppmc = (TGraphAsymmErrors*)fSum2->Get("dataSrc10_reco1_x_Summary_0");

  TGraphAsymmErrors* rxhimc = (TGraphAsymmErrors*)fSum2->Get("dataSrc0_reco1_R_Summary_0");
  TGraphAsymmErrors* rxhidata = (TGraphAsymmErrors*)fSum2->Get("dataSrc1_reco1_R_Summary_0");
  TGraphAsymmErrors* rxppdata = (TGraphAsymmErrors*)fSum2->Get("dataSrc2_reco1_R_Summary_0");
  TGraphAsymmErrors* rxppmc = (TGraphAsymmErrors*)fSum2->Get("dataSrc10_reco1_R_Summary_0");

  TFile *fSum3 = new TFile(Form("histOutputFiles60GeVInclusive/HisOutput_Photonv7_v29_akPu3PF_InclDeltaPhi_gamma%djet%ddphiSig628_subJ1SS1_Isol0_Norm1.root",etPho,etJet));

  TFile *fSum4 = new TFile("histOutputFiles60GeVInclusive/HisSummary_Photonv7_v29_akPu3PF_InclDeltaPhi_gamma60jet30dphiSig628_subJ1SS1_Isol0_Norm1.root");
  TGraphAsymmErrors* dphihimc = (TGraphAsymmErrors*)fSum4->Get("dataSrc0_reco1_dphi_Summary");
  TGraphAsymmErrors* dphihidata = (TGraphAsymmErrors*)fSum4->Get("dataSrc1_reco1_dphi_Summary");
  TGraphAsymmErrors* dphippdata = (TGraphAsymmErrors*)fSum4->Get("dataSrc2_reco1_dphi_Summary");
  TGraphAsymmErrors* dphippmc = (TGraphAsymmErrors*)fSum4->Get("dataSrc10_reco1_dphi_Summary");

  // new dphihidata points
  //


  double sysDphi[4] = {0.032,0.03,0.045,0.077};
  //0.109940, 0.046998, 0.034206,0.142664};
  double sysDphipp[1] = {sysDphi[3]};
  
  double sysR[4] = {0.045,0.039,0.041,0.037};
  //0.017232,0.012847,0.011691,0.012724};
  double sysRpp[1] = {sysR[3]};
  
  double sysMx[4] = { 0.053,0.048,0.051,0.032};
  double sysMxpp[1] = {0.009};
  double corrSysMx =  0.028;

  TH1D* hdphi[5][5];   //[data kind] [ centrality]                                                                                     
  TH1D* hdphipp[20];
  for ( int icent=0; icent<=3 ; icent++) {
    hdphi[khimc][icent] =  (TH1D*)fSum3->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khimc,icent));
    hdphi[khidata][icent] =  (TH1D*)fSum3->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khidata,icent));
  }
  hdphipp[kppdata] = (TH1D*)fSum3->Get("dataSrc2_reco1_cent0SubtractedExtrapExtrapNorm");
  
  // 2013 pp data!!!!!!
  TFile* pp13 = new TFile(Form("ffFilesPP60GeVInclusive/photonTrackCorr_ppDATA_output_photonPtThr60_to_9999_jetPtThr30_%d.root", prodDate));
  // TFile* pp13 = new TFile("ffFilesPP60GeVInclusive/oldSmearing.root");

  hdphi[kppdata13][1] =  (TH1D*)pp13->Get("jetDphi_icent10010_final");
  hxgj[kppdata13][1] = (TH1D*)pp13->Get("xjg_icent10010_final");
  hdphi[kppdata13][2] =  (TH1D*)pp13->Get("jetDphi_icent11030_final");
  hxgj[kppdata13][2] = (TH1D*)pp13->Get("xjg_icent11030_final");
  hdphi[kppdata13][3] =  (TH1D*)pp13->Get("jetDphi_icent13050_final");
  hxgj[kppdata13][3] = (TH1D*)pp13->Get("xjg_icent13050_final");
  hdphi[kppdata13][4] =  (TH1D*)pp13->Get("jetDphi_icent15099_final");
  hxgj[kppdata13][4] = (TH1D*)pp13->Get("xjg_icent15099_final");
  hdphi[kppdata13][5] =  (TH1D*)pp13->Get("jetDphi_icent7_final");
  hxgj[kppdata13][5] = (TH1D*)pp13->Get("xjg_icent7_final");
  

  for ( int icent  = 1 ; icent<=5 ; icent++) {
    hdphi[kppdata13][icent]->Scale(1./hdphi[kppdata13][icent]->Integral());
    for ( int i = 1 ; i<=5 ; i++) {
      hdphi[kppdata13][icent]->SetBinContent(i,-1e4);
    }
    //    hxgj[kppdata13][icent]->Rebin(10);  // Now the bins are already rebined from photonTrackCorr_ppDATA_output_photonPtThr60_to_9999_jetPtThr30_20131021.root
    hxgj[kppdata13][icent]->Scale(1./hxgj[kppdata13][icent]->Integral("width"));
  }
  
  TH1D* hPtPP2013[10];  
  hPtPP2013[1] = (TH1D*)pp13->Get("jetPt_icent10010_final");
  hPtPP2013[2] = (TH1D*)pp13->Get("jetPt_icent11030_final");
  hPtPP2013[3] = (TH1D*)pp13->Get("jetPt_icent13050_final");
  hPtPP2013[4] = (TH1D*)pp13->Get("jetPt_icent15099_final");
  hPtPP2013[5] = (TH1D*)pp13->Get("jetPt_icent7_final");
  
  TH1D* hRpp2013[10]; 
  hRpp2013[1] = new TH1D("hrpp2013_icent1","",1, 359.1-10, 359.1+10);
  hRpp2013[2] = new TH1D("hrpp2013_icent2","",1, 235.6-10, 235.6+10);
  hRpp2013[3] = new TH1D("hrpp2013_icent3","",1, 116.4-10, 116.4+10);
  hRpp2013[4] = new TH1D("hrpp2013_icent4","",1, 43.6-10,  43.6 +10);
  hRpp2013[5] = new TH1D("hrpp2013_icent5","",1, -8,  18 );

  for ( int icent=1 ;  icent<=5; icent++) { 
    double temprPP13err;
    double temprPP13 = hPtPP2013[icent]->IntegralAndError(1,hPtPP2013[icent]->GetNbinsX(),temprPP13err,"width");
    hRpp2013[icent]->SetBinContent(1,temprPP13);
    hRpp2013[icent]->SetBinError(1,temprPP13err);
    handsomeTH1(hRpp2013[icent],1);
    hRpp2013[icent]->SetMarkerStyle(21);
  }
  
  TH1D* hMXpp2013[10];
  hMXpp2013[1] = new TH1D("hmxpp2013_icent1","",1, 359.1-10, 359.1+10);
  hMXpp2013[2] = new TH1D("hmxpp2013_icent2","",1, 235.6-10, 235.6+10);
  hMXpp2013[3] = new TH1D("hmxpp2013_icent3","",1, 116.4-10, 116.4+10);
  hMXpp2013[4] = new TH1D("hmxpp2013_icent4","",1, 43.6-10,  43.6 +10);
  hMXpp2013[5] = new TH1D("hmxpp2013_icent5","",1, -8, 18);
  for ( int icent=1 ;  icent<=5; icent++) {
    hMXpp2013[icent]->SetBinContent(1,hxgj[kppdata13][icent]->GetMean());
    hMXpp2013[icent]->SetBinError(1,hxgj[kppdata13][icent]->GetMeanError());
    handsomeTH1(hMXpp2013[icent],1);
    hMXpp2013[icent]->SetMarkerStyle(21);
  }


  TFile* fPPsys = new TFile("ffFilesPP60GeVInclusive/relativeSys_merged_pp60GeV.root");

  TH1D* hdphiWidth  = (TH1D*)fPPsys->Get("dphiWidth_uncertainty_merged");
  
  TH1D* hDphiPPUnc = new TH1D("hdphippunc","",1,0,1);
  hDphiPPUnc->SetBinContent(1, hdphiWidth->GetBinContent(1) );

  TH1D* ppSysX[4];
  ppSysX[0] = (TH1D*)fPPsys->Get("dNdXjg_uncertainty_merged");
  ppSysX[1] = (TH1D*)ppSysX[0]->Clone("ppSysx1");
  ppSysX[2] = (TH1D*)ppSysX[0]->Clone("ppSysx2");
  ppSysX[3] = (TH1D*)ppSysX[0]->Clone("ppSysx3");

  TH1D* meanXpp13Sys = (TH1D*)fPPsys->Get("meanXjg_uncertainty_merged");

  float ppSysMx60 = meanXpp13Sys->GetBinContent(1);    // UPDATED on Oct 22nd
  TH1D* ppSysMx = new TH1D("ppSysMx","",1,0,1);
  ppSysMx->SetBinContent(1,ppSysMx60);

  TH1D* meanRpp13Sys = (TH1D*)fPPsys->Get("meanRjg_uncertainty_merged");
  float ppSysR60 = meanRpp13Sys->GetBinContent(1); // UPDATED on Oct 22nd
  TH1D* ppSysR = new TH1D("ppSysR","",1,0,1);
  ppSysR->SetBinContent(1,ppSysR60);

  
  
  // xjg distributions
  TCanvas *c1 = new TCanvas("c1","",1100,330);
  makeMultiPanelCanvas(c1,4,1,0.0,0.0,0.24,0.15,0.075);
  c1->cd(0);
  drawCMSppPbPb(0.1,0.95);
  //c1->Divide(4,1,0.0,0.0);
  for ( int icent=0; icent<=3 ; icent++) {
    c1->cd( 4 - icent);
    //hxgj[khimc][icent]->SetAxisRange(-.2,2.5,"Y");
    hxgj[khimc][icent]->SetAxisRange(0,2.5,"Y");
    hxgj[khimc][icent]->SetNdivisions(505);
    //    hxgj[khimc][icent]->SetTitle(";x_{J#gamma} = p^{Jet}_{T}/p^{#gamma}_{T}; #frac{1}{N_{J#gamma}} #frac{dN_{J#gamma}}{dx_{J#gamma}}");
    hxgj[khimc][icent]->SetTitle(";x_{J#gamma}; #frac{1}{N_{J#gamma}} #frac{dN_{J#gamma}}{dx_{J#gamma}}");
    handsomeTH1(hxgj[khimc][icent]);
    fixedFontHist(hxgj[khimc][icent],1,1.35);
    mcStyle2(hxgj[khimc][icent]);
    handsomeTH1(hxgj[khidata][icent],2);
    
    hxgj[khimc][icent]->GetYaxis()->SetTitleOffset(1.5);
    TH1D * htemp41 = (TH1D*)hxgj[khimc][icent]->Clone(Form("htemp41_%d",icent));
    for ( int i=0 ; i<=20 ; i++) {
      htemp41->SetBinContent(i,0);
      htemp41->SetBinError(i,0);
    }
    if (scaleByR) {
      htemp41->SetAxisRange(0,2,"Y");
      htemp41->SetYTitle("#frac{1}{N_{#gamma}} #frac{dN_{J#gamma}}{dx_{J#gamma}}");
    }
    htemp41->DrawCopy("hist");

    if (scaleByR)    {
      hxgj[kppdata13][icent+1]->Scale(hRpp2013[icent+1]->GetBinContent(1));
      std::cout <<"  Scaled by pp R :" << hRpp2013[icent+1]->GetBinContent(1) << std::endl;
      
      double x,y;
      rxhidata->GetPoint(icent, x,y);
      hxgj[khidata][icent]->Scale(y);
      std::cout << " scaled by PbPb R: " << y << std::endl;

      rxhimc->GetPoint(icent, x,y);
      hxgj[khimc][icent]->Scale(y);
      std::cout << " scaled by PbPb R: " << y << std::endl;
    }
    if(drawMC) hxgj[khimc][icent]->DrawCopy("hist same");

    if ( !mcOnly )    drawXSys(icent,hxgj[khidata][icent]);
    //   if ( icent==3){ }
    
    handsomeTH1(hxgj[kppdata13][icent+1]);
    hxgj[kppdata13][icent+1]->SetMarkerStyle(21);

    drawSys(hxgj[kppdata13][icent+1],ppSysX[icent],kGreen,3001);

    hxgj[kppdata13][icent+1]->Draw("same ");
    
    if ( !mcOnly )   hxgj[khidata][icent]->Draw("same");
    //onSun(0,0,2,0);
 
    // if ( icent == 2) {
    //   TLegend *leg0  = new TLegend(0.2796373,0.7545885,0.9742202,0.9937661,NULL,"brNDC");
    //     easyLeg(leg0,"");
    //   //      if ( !mcOnly )       leg0->AddEntry(hxgj[khidata][icent],"PbPb Data","p");
    //   leg0->AddEntry(hxgj[khimc][icent],"PYTHIA + HYDJET","f");
    //   leg0->AddEntry(hxgjpp[kppdata],"","");

    //   leg0->Draw();
    // }
    
    if ( icent == 3) {
      TLegend *leg0 = new TLegend(0.2916647,0.7045885,0.9862476,0.9869226,NULL,"brNDC");
      easyLeg(leg0);
      leg0->AddEntry(hxgj[khidata][icent],"PbPb Data","p");
      if ( !mcOnly )       leg0->AddEntry(hxgj[kppdata13][icent+1],"Smeared pp reference","p");
      //    leg0->AddEntry(hxgj[khidata][icent],"","");
      if(drawMC) leg0->AddEntry(hxgj[khimc][icent],"PbPb PYTHIA + HYDJET","f");
      leg0->Draw();
      //drawText("#sqrt{s_{NN}}=2.76 TeV ",0.65,0.74,0,15);
    }
        
    if ( icent == 2) {
      drawText(Form("p^{#gamma}_{T} > %d GeV/c     |#eta^{#gamma}| < 1.44",etPho),0.2,0.85,0,15);
      drawText(Form("p^{Jet}_{T} > %d GeV/c    |#eta^{Jet}| < 1.6",etJet),0.2,0.77,0,15);
      drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.2,0.69,0,15);
    }
    if ( icent == 0 ) {
      //      drawText("CMS",0.8,0.9,1);
      //      drawText("pp       #int L dt = 231 nb^{-1}",0.4,0.68,1,15);
    }
    
    if ( icent == 3) 
      drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.72,0.5,0,15);
    else 
      drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.67,0.5,0,15);
    
    /*    if ( icent == 3)
      drawText("(a)",0.275,0.8,1);
    if ( icent == 2)
      drawText("(b)",0.05,0.8,1);  
    if ( icent == 1)
      drawText("(c)",0.05,0.8,1);   
    if ( icent == 0)
      drawText("(d)",0.05,0.8,1);
    */
    gPad->RedrawAxis();
  }

  c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.pdf");
  //c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.png");
  //c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.gif");
  //c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.C");

  
  
  // TCanvas *c1all = new TCanvas("c1all","",500,500);

  // for ( int icent=0;icent<4;icent++){
  //   hxgj[khimc][icent]->SetFillStyle(0);
  //   hxgj[khimc][icent]->SetMarkerSize(1.5);
  // }
  // hxgj[khimc][0]->SetMarkerStyle(22);
  // hxgj[khimc][1]->SetMarkerStyle(26);
  // hxgj[khimc][2]->SetMarkerStyle(23);
  // hxgj[khimc][3]->SetMarkerStyle(32);
  // hxgj[khimc][0]->DrawCopy("");
  // hxgj[khimc][1]->DrawCopy(" same");
  // hxgj[khimc][2]->DrawCopy(" same");
  // hxgj[khimc][3]->DrawCopy(" same");
  // jumSun(0,0,2,0);

  // drawText("PYTHIA+HYDJET",0.2,0.80,0,25);
  // TLegend *legc1all = new TLegend(0.6149194,0.6716102,0.9435484,0.9555085,NULL,"brNDC");
  // easyLeg(legc1all,"");
  // legc1all->AddEntry(hxgj[khimc][3],"50-100%","p");
  // legc1all->AddEntry(hxgj[khimc][2],"30-50%","p");
  // legc1all->AddEntry(hxgj[khimc][1],"10-30%","p");
  // legc1all->AddEntry(hxgj[khimc][0],"0-10%","p");
  // legc1all->Draw();
  
  // dphi distributions
  TCanvas *c1ppDphi = new TCanvas("c1ppDphi","",500,500);
  TString fitFunc = "(TMath::Pi()/20.0)*exp(-(TMath::Pi()-x)/[0])/([0]*(1-exp(-TMath::Pi()/[0])))";
  float fitxmin=3.1415926*2./3;
  TF1 *fdphiPP[10];
  TH1D* hDphiPP2013[10];
  hDphiPP2013[1] = new TH1D("hDphiPP2013_icent1","",1, 359.1-10, 359.1+10);
  hDphiPP2013[2] = new TH1D("hDphiPP2013_icent2","",1, 235.6-10, 235.6+10);
  hDphiPP2013[3] = new TH1D("hDphiPP2013_icent3","",1, 116.4-10, 116.4+10);
  hDphiPP2013[4] = new TH1D("hDphiPP2013_icent4","",1, 43.6-10,  43.6 +10);
  hDphiPP2013[5] = new TH1D("hDphiPP2013_icent5","",1, -8, 18);
  
  for ( int icent=1; icent<=5 ; icent++) {
    fdphiPP[icent] = new TF1(Form("fdphiPP_icent%d",icent),fitFunc.Data(),2.0*TMath::Pi()/3.0,TMath::Pi());
    fdphiPP[icent]->SetParName(0,"width");
    fdphiPP[icent]->SetParameter("width",0.3);
    hdphi[kppdata13][icent]->Fit(Form("fdphiPP_icent%d",icent),"0","",fitxmin,3.1415926);
    fdphiPP[icent]->SetLineWidth(1);
    fdphiPP[icent]->SetLineStyle(2);
    fdphiPP[icent]->SetLineColor(1);
    hdphi[kppdata13][icent]->SetAxisRange(1.00001e-3,1,"Y");
    hdphi[kppdata13][icent]->SetStats(0);
    hdphi[kppdata13][icent]->Draw("");
    hdphi[kppdata13][icent]->SetAxisRange(1.00001e-3,1,"Y");
    hdphi[kppdata13][icent]->SetStats(0);
    fdphiPP[icent]->SetLineWidth(2);
    fdphiPP[icent]->SetLineStyle(7); 
    fdphiPP[icent]->DrawCopy("same");
    gPad->SetLogy();
  
    float dphiWidth13 = fdphiPP[icent]->GetParameter(0) ; 
    float dphiWidth13err = fdphiPP[icent]->GetParError(0);
    hDphiPP2013[icent]->SetBinContent(1,dphiWidth13);
    hDphiPP2013[icent]->SetBinError(  1,dphiWidth13err);
    handsomeTH1(hDphiPP2013[icent],1);
    hDphiPP2013[icent]->SetMarkerStyle(21);
  }

  TCanvas *c1dphi = new TCanvas("c1dphi","",1100,330);
  makeMultiPanelCanvas(c1dphi,4,1,0.0,0.0,0.24,0.18,0.075);
  c1dphi->cd(0);
  drawCMSppPbPb(0.1,0.95);

  for ( int icent=0; icent<=3 ; icent++) {
    c1dphi->cd( 4 - icent);
    hdphi[khimc][icent]->SetAxisRange(1.e-3,1,"Y");
    //   hdphi[khimc][icent]->SetNdivisions(505);
    hdphi[khimc][icent]->GetXaxis()->SetNdivisions(3,5,0,kFALSE);
    
    hdphi[khimc][icent]->SetTitle(";#Delta#phi_{J#gamma};Pair Fraction");

    handsomeTH1(hdphi[khimc][icent]);
    fixedFontHist(hdphi[khimc][icent],1,1.35);
    mcStyle2(hdphi[khimc][icent]);
    handsomeTH1(hdphi[khidata][icent],2);

    TF1 *fdphi = new TF1("fdphi",fitFunc.Data(),2.0*TMath::Pi()/3.0,TMath::Pi());
    fdphi->SetParName(0,"width");
    fdphi->SetParameter("width",0.3);
    
    hdphi[khimc][icent]->Fit("fdphi","0llm","",fitxmin,3.1415926);

    fdphi->SetLineWidth(1);
    fdphi->SetLineStyle(2);
    fdphi->SetLineColor(kBlue); 
    // float dphiWidth = fdphi->GetParameter("width");
    // float dphiWidthErr = fdphi->GetParError(0);
    // std::cout << " dphiWidth,dphiWidthErr = " << dphiWidth <<"   "<< dphiWidthErr << std::endl;
    hdphi[khimc][icent]->SetAxisRange(1.00001e-3,1,"Y");
    hdphi[khimc][icent]->SetStats(0);
    TH1D* hdphitemp = (TH1D*)hdphi[khimc][icent]->Clone(Form("hdphitemp55_%d",icent));
    if(!drawMC)
    {
      for ( int i=0;i<=30;i++) { 
	hdphitemp->SetBinContent(i,0);
	hdphitemp->SetBinError(i,0);
      }
    }
    hdphitemp->Draw("hist");
    hdphi[khidata][icent]->SetAxisRange(1.00001e-3,1,"Y");
    if (!mcOnly) hdphi[khidata][icent]->Draw("same ");
    hdphi[khidata][icent]->SetStats(0);
    fdphi->SetLineWidth(2);
    fdphi->SetLineStyle(7);
    if ( mcOnly )    fdphi->DrawCopy("same");


    gPad->SetLogy();
    handsomeTH1(hdphi[kppdata13][icent+1]);
    
    hdphi[kppdata13][icent+1]->SetMarkerStyle(21);
    hdphi[kppdata13][icent+1]->Draw("same");

    
    if ( icent == 3) {
      TLegend *leg0  = new TLegend(0.32,0.7,0.9,0.89,NULL,"brNDC");
      easyLeg(leg0);
      if ( !mcOnly )   leg0->AddEntry(hdphi[kppdata13][icent+1],"Smeared pp reference","p");
      if ( !mcOnly )      leg0->AddEntry(hdphi[khidata][icent],"PbPb Data","p");
      if(drawMC) leg0->AddEntry(hdphi[khimc][icent],"PYTHIA + HYDJET","f");
      leg0->Draw();
    }

    if (( !mcOnly ) && ( icent == 2)) {
      //drawText("#sqrt{s_{NN}}=2.76 TeV ",0.4,0.88,0,15);
      //drawText("#int L dt = 150 #mub^{-1}",0.4,0.75,0,15);
    }

    if ( icent == 1) {
      drawText(Form("p^{#gamma}_{T} > %d GeV/c     |#eta^{#gamma}| < 1.44",etPho),0.15,0.8,0,15);
      drawText(Form("p^{Jet}_{T} > %d GeV/c    |#eta^{Jet}| < 1.6",etJet),0.15,0.7,0,15);
    }

    if ( icent == 0 ) {
      //      drawText("CMS",0.8,0.9,1);
      //      drawText("pp       #int L dt = 231 nb^{-1}",0.4,0.68,1,15);                                                                     
    }


    if ( icent == 3)
      drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.313,0.6,0,15);
    else
      drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.1,0.6,0,15);

    if ( icent == 3)
      drawText("(a)",0.275,0.8,1);
    if ( icent == 2)
      drawText("(b)",0.05,0.8,1);
    if ( icent == 1)
      drawText("(c)",0.05,0.8,1);
    if ( icent == 0)
      drawText("(d)",0.05,0.8,1);
    
    double bottomY = 0.0009;
    double pi = TMath::Pi();

    drawPatch(-0.5,bottomY/100,pi+0.5,bottomY);

    bottomY = 0.0005;
    drawText("0",0.05,bottomY,0,18,false);
    drawText("#frac{1}{3}#pi",pi/3-0.05,bottomY,0,18,0);
    drawText("#frac{2}{3}#pi",2*pi/3-0.05,bottomY,0,18,0);
    if ( icent==0) 
      drawText("#pi",pi-0.1,bottomY,0,18,0);
    drawText("#Delta#phi_{J#gamma}",pi/2.-0.1,bottomY-0.0002,0,18,0);
    
  }
  


  gPad->RedrawAxis();
  c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.pdf");
  //c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.png");
  //c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.gif");
  //c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.C");
  
  ////////////////////////////// summary plots
  TCanvas *c2 = new TCanvas("c2","",350,350);
  TH1D* hTemp2 = new TH1D("htemp2",";N_{part};<x_{J#gamma}>",100,-20,400);
  hTemp2->SetNdivisions(505);
  handsomeTH1(hTemp2,1);
  handsomeTGraph(mxhidata,2);
  mxhidata->SetMarkerStyle(20);
  handsomeTGraph(mxhimc,1);
  mxhimc->SetMarkerStyle(24);
  //  handsomeTGraph(mxppdata,1);
  //  mxppdata->SetMarkerStyle(21);
  handsomeTGraph(mxppmc,1);
  mxppmc->SetMarkerStyle(25);
  
    
  hTemp2->SetAxisRange(0.6,1.1,"Y");
  hTemp2->DrawCopy();
  //  TH1D* hMXpp2013_2 = new TH1D("hmxpp2013_2","",1,-10,370);
  //  hMXpp2013_2->SetBinContent(1,hMXpp2013->GetBinContent(1));
  //  if ( !mcOnly )   drawSys(hMXpp2013_2,sysMxpp,kGreen,3001);
  if ( !mcOnly )   drawSys(mxhidata,sysMx,10);
  
  // mxppmc->Draw("p");
  //  if ( !mcOnly )   mxppdata->Draw("p");
  if ( !mcOnly )  {
    hMXpp2013[5]->SetMarkerStyle(20);
    for ( int icent = 1 ; icent<=5 ; icent++) {
      drawSys(hMXpp2013[icent],ppSysMx,kGreen,3001);
      hMXpp2013[icent]->DrawCopy("p same");
    }
  }
  if(drawMC) mxhimc->Draw("p same");
  if ( !mcOnly )  mxhidata->Draw("p same");

  hMXpp2013[5]->SetFillStyle(3001);
  hMXpp2013[5]->SetFillColor(kGreen);
  hMXpp2013[5]->SetLineColor(0);
  hDphiPP2013[2]->SetFillStyle(3001);
  hDphiPP2013[2]->SetFillColor(kGreen);
  hDphiPP2013[2]->SetLineColor(0);
  TH1D *dummyHist = new TH1D("dummyHist","",10,0,1);
  dummyHist->SetFillStyle(1001);
  dummyHist->SetMarkerColor(kRed);
  dummyHist->SetFillColor(90);
  dummyHist->SetLineColor(0);
  
  //// sys bar by energy scale
  /*
  TBox *b1 = new TBox(400-20,0.85 - corrSysMx ,400,  0.85 + corrSysMx);
  b1->SetFillColor(1);
  b1->SetFillStyle(1001);
  if ( !mcOnly )   b1->Draw();
  TBox *b2 = new TBox(400-20+3,0.85 - corrSysMx+ 0.002 ,400-3,  0.85 + corrSysMx- 0.002);
  b2->SetFillColor(0);
  b2->SetFillStyle(1001);
  if ( !mcOnly )   b2->Draw();
  */
  //  drawText("Common uncertainty due to jet ",0.35,0.25,0,15);
  //  drawText("energy scale & photon purity",0.35,0.2,0,15);
  //  drawText("#sqrt{s_{NN}}=2.76 TeV ",0.5,0.85,0,15);
  //  drawText("#int L dt = 150 #mub^{-1}",0.5,0.72,0,15);
  //  drawText("(a)",0.22,0.87,1);
  drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.7,0.75,0);
  drawCMSppPbPb(0.1,0.95,12);
  //  drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.5,0.38,0);
  // drawText("CMS",0.78,0.88,1);

  TLegend *leg4 =  new TLegend(0.1630303,0.6054839,0.7590909,0.8931183,NULL,"brNDC");
  easyLeg(leg4,"");
  //  if ( !mcOnly )  leg4->AddEntry(mxppdata,"pp Data 231nb^{-1}","p");
  if ( !mcOnly ) leg4->AddEntry(dummyHist,"PbPb Data","fp");
  if ( !mcOnly )  leg4->AddEntry(hMXpp2013[5],"pp Data","fp");
  if ( !mcOnly )  leg4->AddEntry(hDphiPP2013[2],"Smeared pp reference","fp");
  if(drawMC) leg4->AddEntry(mxhimc,"PYTHIA + HYDJET","p");
  //  leg4->AddEntry(mxppmc,"PYTHIA","p");




  //  leg4->AddEntry(hSysTemp,"Sys. Uncertainty","f");                                                                                         
  leg4->Draw();


  gPad->RedrawAxis();
  
  c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.pdf");
  //c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.png");
  //c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.gif");
  //c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.C");
  
  ////////////////////////////// rx 
  TCanvas *c3 = new TCanvas("c3","",350,350);

  TH1D* hTemp3 = new TH1D("htemp2",";N_{part};R_{J#gamma}",100,-20,400);
  hTemp3->SetNdivisions(505);
  handsomeTH1(hTemp3,1);
  handsomeTGraph(rxhidata,2);
  rxhidata->SetMarkerStyle(20);
  handsomeTGraph(rxhimc,1);
  rxhimc->SetMarkerStyle(24);
  handsomeTGraph(rxppdata,1);
  rxppdata->SetMarkerStyle(21);
  handsomeTGraph(rxppmc,1);
  rxppmc->SetMarkerStyle(25);

  hTemp3->SetAxisRange(0.41,1.,"Y");
  hTemp3->Draw();


  // Ratio
  // DivideTG(rxppdata,rxppmc);
  // DivideTG(rxhidata,rxhimc);
  //////////////////////////////////////////////
  //  TH1D* hdphi2013_2 = new TH1D("hdphi2013_2","",1,-10,370);
  //  hdphi2013_2->SetBinContent(1,hRpp2013->GetBinContent(1));
  //  if ( !mcOnly )   drawSys(hdphi2013_2,sysRpp,kGreen,3001);
  if ( !mcOnly )   drawSys(rxhidata,sysR,10);
  //  if ( !mcOnly )   drawSys(rxppdata,sysRpp,10);
  // jumSun(-10,1,400,1);
  if(drawMC) rxhimc->Draw("p");
  //  rxppmc->Draw("p");
  //  if ( !mcOnly )   rxppdata->Draw("p");
  if ( !mcOnly )   {
    hRpp2013[5]->SetMarkerStyle(20);
    for ( int icent =1 ; icent<=5 ; icent++) { 
      drawSys(hRpp2013[icent],ppSysR,kGreen,3001);
      hRpp2013[icent]->Draw("same");
    }
  }
  if ( !mcOnly )   rxhidata->Draw("p same");
  //  drawText(Form("p^{#gamma}_{T} > %d GeV/c",etPho),0.6,0.75,0,15);
  //  drawText(Form("p^{Jet}_{T} > %d GeV/c",etJet),0.6,0.67,0,15);
  //  drawText("CMS",0.78,0.88,1);
  //  drawText("(b)",0.22,0.87,1);
  drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.7,0.75,0);
  drawCMSppPbPb(0.1,0.95,12);

  leg4->Draw();
  gPad->RedrawAxis();

  c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.pdf");
  //c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.png");
  //c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.gif");
  //c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.C");
  
  TCanvas *c4 = new TCanvas("c4","",350,350);

  TH1D* hTemp4 = new TH1D("htemp2",";N_{part};#sigma(#Delta#phi_{J#gamma})",100,-20,400);
  hTemp4->SetNdivisions(505);
  handsomeTH1(hTemp4,1);
  handsomeTGraph(dphihidata,2);
  dphihidata->SetMarkerStyle(20);
  handsomeTGraph(dphihimc,1);
  dphihimc->SetMarkerStyle(24);
  handsomeTGraph(dphippdata,1);
  dphippdata->SetMarkerStyle(21);
  handsomeTGraph(dphippmc,1);
  dphippmc->SetMarkerStyle(25);

  hTemp4->SetAxisRange(0,.5,"Y");
  hTemp4->Draw();
  
                                                                                 
  // TH1D* h2013_3 = new TH1D("hdphi2013_3","",1,-10,370);
  //  h2013_3->SetBinContent(1,hDphiPP2013->GetBinContent(1));

  //  if ( !mcOnly )  drawSys(h2013_3,sysDphipp,kGreen,3001);
  if ( !mcOnly )  drawSys(dphihidata,sysDphi,10);
  if(drawMC) dphihimc->Draw("p same");
  // dphippmc->Draw("p");
  //  if ( !mcOnly )  dphippdata->Draw("p");
  for ( int icent=1 ; icent<=5 ; icent++){
    drawSys(hDphiPP2013[icent], hDphiPPUnc, kGreen,3001);
  }
  
  TH1D* hDphiPP2013Temp = new TH1D("hDphiPP2013Temp","",1,380,400);
  hDphiPP2013Temp->SetBinContent(1,0.27);
  hDphiPP2013[5]->SetMarkerStyle(20);
  for ( int icent=1 ; icent<=5 ; icent++){ 
    hDphiPP2013[icent]->Draw("same");
  }
  if ( !mcOnly )  dphihidata->Draw("p");

  // TLegend *legDphi =  new TLegend(0.32,0.18,0.93,0.7,NULL,"brNDC");
  // easyLeg(legDphi,"");
  // legDphi->SetTextSize(17);
  // //  drawText("|#Delta#phi_{J#gamma}| > #frac{2}{3}#pi",0.5,0.38,0);
  // //  drawText("Fit : #frac{e^{#frac{|#Delta#phi_{J#gamma}|-#pi}{#sigma}}}{#sigma(1-e^{-#pi/#sigma})}",0.5,0.23,0);
  // legDphi->Draw();
  // //  drawText("(a)",0.22,0.87,1);
  // //  drawText("CMS",0.78,0.88,1);


  TH1D* hSysTemp = new TH1D("hSystemp","",1,0,1);
  hSysTemp->SetFillColor(newYellow);
  hSysTemp->SetLineColor(newYellow);

  leg4->Draw();

  drawText(Form("p^{#gamma}_{T} > %d GeV/c     |#eta^{#gamma}| < 1.44",etPho),0.25,0.3,0,15);
  drawText(Form("p^{Jet}_{T} > %d GeV/c    |#eta^{Jet}| < 1.6",etJet),0.25,0.2,0,15);
  drawCMSppPbPb(0.1,0.95,12);

  gPad->RedrawAxis();
  c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.pdf");
  //c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.png");
  //c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.gif");
  //c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.C");

   // // print numbers
   // std::cout << " Summary of Points for PbPb " << std::endl;
   // PrintGraphAndSys(dphihidata,sysDphi);
   // PrintGraphAndSys(mxhidata,sysMx);
   // PrintGraphAndSys(rxhidata,sysR);

   // std::cout << " Summary of Points for PYTHIA + HYDJET " << std::endl;
   // PrintGraph(dphihimc);
   // PrintGraph(mxhimc);
   // PrintGraph(rxhimc);

   //   std::cout << " Summary of Points for pp " << std::endl;
   //  PrintGraphAndSys(dphippdata[5],sysDphipp);
   //  PrintGraphAndSys(mxppdata[5],sysMxpp);
   // PrintGraphAndSys(rxppdata[5],sysRpp);


   
   /*
   TCanvas *c5 = new TCanvas("c5","",500,500);
   hxgj[khidata][0]->SetAxisRange(-.2,2.5,"Y");
   hxgj[khidata][0]->SetNdivisions(505);
   fixedFontHist(hxgj[khidata][0],1,1.35);
   handsomeTH1(hxgj[khidata][0],2);
   hxgj[khidata][0]->GetYaxis()->SetTitleOffset(1.5);
   hxgj[khidata][0]->DrawCopy("");
   handsomeTH1(hxgj[kppdata13][5],4);
   hxgj[kppdata13][5]->Draw("same hist");
   onSun(0,0,2,0);
   */
}
void drawPtDependencePPSmeared(int centBin = 10030, TString dirName="nominal", int prodDate=20131021, int jetPtCut=30) {
  TH1::SetDefaultSumw2();

  const int nPtBin = 4;
  double ptBin[nPtBin+1] = {40, 50,60,80,9999}; 
  double ptBinPaDraw[nPtBin+1] = { 40.5 ,49.5, 58.5,  76.5,  123. } ;
  // double AvePtBin[nPtBin+1] = { 45, 54.1479, 67.4204, 99.6956, 9999};
    
  const int nCentBinHI = 2;
  const int centBinHI[nCentBinHI +1] = {-1, 10030, 13099}; 

  TH1D* hxjg[7][10][6]; // [Collision][centrality][pt]
  TH1D* hJetPt[7][10][6]; // [Collision][centrality][pt]
  TH1D* hJetPtIaaBin[7][10][6]; // [Collision][centrality][pt]
  TH1D* hDphi[7][10][6]; // [Collision][centrality][pt]
  TH1D* hEta[7][10][6]; // [Collision][centrality][pt]
  TH1D* meanXjg[7][10];      // [Collision][centrality]
  TH1D* meanJetPt[7][10];      // [Collisi on][centrality]

  TH1D* rjg[7][10];     //  [Collision][centrality]
  for (int icoll=0 ; icoll<6  ; icoll++) {
    for (int icent=1 ; icent<= 10 ; icent++) {
      meanXjg[icoll][icent] = new TH1D( Form("meanXjg_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); <X_{J#gamma}>",nPtBin,ptBinPaDraw);
      meanJetPt[icoll][icent] = new TH1D( Form("meanJetPt_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); <p_{T}^{Jet}>",nPtBin,ptBinPaDraw);
      rjg[icoll][icent] = new TH1D( Form("rjg_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); R_{J#gamma}",nPtBin,ptBinPaDraw);

      for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
	hxjg[icoll][icent][ipt] = NULL;
	hJetPt[icoll][icent][ipt] = NULL;
	hJetPtIaaBin[icoll][icent][ipt] = NULL;
	hDphi[icoll][icent][ipt] = NULL;
	hEta[icoll][icent][ipt] = NULL;
      }

    }
  }

  TFile* histFile[7][6];  // [Collision][pt]                                                                                          
  for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
    for (int icoll=0 ; icoll<6 ; icoll++) {
      TString sampleName = getSampleName( icoll ) ;
      char* fname =  Form("ffFiles/%s/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr%d_%d.root",dirName.Data(), sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt], (int)jetPtCut, prodDate);

      histFile[icoll][ipt] = new TFile(fname) ;
      cout << " Reading file : " << fname << endl;

      if ( histFile[icoll][ipt]->IsZombie()  == false ) {
	cout << " Success." << endl;
	if ( (icoll == kPPDATA) || (icoll == kPPMC) )   {  //  PP
	  int icent = 7 ; 
	  hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", centBin));
	  cout << " Getting histogram : " << Form("xjg_icent%d_final", icent) << endl;
	  hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", centBin));
	  cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
	  hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", centBin));
	  cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", icent) << endl;
	  hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", centBin));
	  cout << " Getting histogram : " << Form("jetDphi_icent%d_final", icent) << endl;
	  hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", centBin)) ;
	  cout << " Getting histogram : " << Form("etaJg_icent%d_final", centBin) << endl;

	}

	if ( ( icoll == kHIDATA) ||  (icoll == kHIMC) ) { // PbPb
	  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
	    hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", centBinHI[icent] )) ;
	    cout << " Getting histogram : " << Form("xjg_icent%d_final", centBinHI[icent] ) << endl;
	    hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", centBinHI[icent] ) );
	    cout << " Getting histogram : " << Form("jetPt_icent%d_final", centBinHI[icent] ) << endl;
	    hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) );
	    cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) << endl;
	    hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", centBinHI[icent] ) ) ;
	    cout << " Getting histogram : " << Form("jetDphi_icent%d_final", icent)<< endl;
	    hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", centBinHI[icent] ) ) ;
	    cout << " Getting histogram : " << Form("etaJg_icent%d_final", icent)<< endl;
	  }
	}
      }
      else  
	cout << " no such file " << endl;
    }
  }

  for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
    for (int icoll=0 ; icoll<6 ; icoll++) {
      for (int icent=1 ; icent<= 10 ; icent++ ) { 
	if ( hxjg[icoll][icent][ipt] == NULL ) 
	  continue;   // emtpy histogram 
	double rVal, rErr;

	rVal = hxjg[icoll][icent][ipt]->IntegralAndError(1, hxjg[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
	printf("icoll: %d icent: %d ipt: %d rval: %lf\n",icoll, icent, ipt, rVal);
	rjg[icoll][icent]->SetBinContent( ipt, rVal );
	rjg[icoll][icent]->SetBinError  ( ipt, rErr );

	meanXjg[icoll][icent]->SetBinContent( ipt, hxjg[icoll][icent][ipt]->GetMean() );
	meanXjg[icoll][icent]->SetBinError  ( ipt, hxjg[icoll][icent][ipt]->GetMeanError() );

	meanJetPt[icoll][icent]->SetBinContent( ipt, hJetPt[icoll][icent][ipt]->GetMean() );
	meanJetPt[icoll][icent]->SetBinError  ( ipt, hJetPt[icoll][icent][ipt]->GetMeanError() );


      }
    }
  }

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

    c1->cd(ipt);

    // draw pp
    handsomeTH1(hDphi[kPPDATA][7][ipt], 1);
    hDphi[kPPDATA][7][ipt]->SetXTitle("#Delta#phi_{J#gamma}");
    hDphi[kPPDATA][7][ipt]->SetYTitle("Normalized entries");
    hDphi[kPPDATA][7][ipt]->SetMarkerStyle(24);
    hDphi[kPPDATA][7][ipt]->Scale(1./hDphi[kPPDATA][7][ipt]->Integral("width"));       
    hDphi[kPPDATA][7][ipt]->SetAxisRange(0,3.141592,"X");
    hDphi[kPPDATA][7][ipt]->SetAxisRange(0.01,30,"Y");
    hDphi[kPPDATA][7][ipt]->Draw();
    // draw pbpb 
    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
      handsomeTH1(hDphi[kHIDATA][icent][ipt],kRed);
      if ( icent == 2 ) hDphi[kHIDATA][icent][ipt]->SetMarkerStyle(24);
      hDphi[kHIDATA][icent][ipt]->Scale(1./hDphi[kHIDATA][icent][ipt]->Integral("width"));
      hDphi[kHIDATA][icent][ipt]->Draw("same");

    }

    gPad->SetLogy();
    //    onSun(30,0,200,0);
  }
  c1->cd(1);
  TLegend *ly = new TLegend(0.4913112,0.6561548,0.9997611,0.9431145,NULL,"brNDC");
  easyLeg(ly,"2.76TeV");
  ly->AddEntry(hDphi[kPPDATA][7][1],"pp ","p");
  ly->AddEntry(hDphi[kHIDATA][2][1],"PbPb 0-30%","p");

  TLegend *l1 = new TLegend(0.1995968,0.7097458,0.7076613,0.9237288,NULL,"brNDC");
  easyLeg(l1,"2.76TeV");
  l1->AddEntry(hDphi[kPPDATA][7][1],"pp ","p");
  l1->AddEntry(hDphi[kHIDATA][2][1],"PbPb 30-100%","p");
  l1->AddEntry(hDphi[kHIDATA][1][1],"PbPb 0-30%","p");
  l1->Draw();

  // c1->SaveAs("figures/pT_dependence_dphi_pp_pbpb_figure1.pdf");
  // c1->SaveAs("figures/pT_dependence_dphi_pp_pbpb_figure1.gif");





  TH1D* hTempPt = new TH1D("hTemp",";p_{T}^{#gamma} (GeV);",200,10,300);

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

    c2->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.08,"Y");
    handsomeTH1(hTempPt,0);
    hTempPt->DrawCopy();
	
    //    hJetPt[kPPDATA][7][ipt]->Scale(1./rjg[kPPDATA][7]->GetBinContent(ipt)); // rjg normalization                      
		

    handsomeTH1(hJetPt[kPPDATA][7][ipt], 1);
    hJetPt[kPPDATA][7][ipt]->SetMarkerStyle(24);
    hJetPt[kPPDATA][7][ipt]->Draw("same");

    // draw pbpb 
    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
      handsomeTH1(hJetPt[kHIDATA][icent][ipt],kRed);
      //      hJetPt[kHIDATA][icent][ipt]->Scale(1./rjg[kHIDATA][icent]->GetBinContent(ipt));  // rjg normalization
      //      hJetPt[kHIDATA][icent][ipt]->Rebin(10);
      //     hJetPt[kHIDATA][icent][ipt]->Scale(1/10.);
      if ( icent == 2 ) hJetPt[kHIDATA][icent][ipt]->SetMarkerStyle(24);
      if ( icent == 2 ) hJetPt[kHIDATA][icent][ipt]->Draw("same");
      if ( icent == 1 ) hJetPt[kHIDATA][icent][ipt]->Draw("same");
    }
       
    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

    onSun(30,0,200,0);
  }
  c2->cd(1);
  l1->Draw();  

  c2->SaveAs("figures/pT_dependence_jetPt_pp_pbpb_figure1.pdf");
  c2->SaveAs("figures/pT_dependence_jetPt_pp_pbpb_figure1.gif");

  TLegend *l2 = new TLegend(0.2116935,0.7012712,0.6149194,0.904661,NULL,"brNDC");
  easyLeg(l2,"2.76TeV");
  l2->AddEntry(hDphi[kPPDATA][7][1],"pp ","p");
  l2->AddEntry(hDphi[kHIDATA][1][1],"PbPb 30-100%","p");
  l2->AddEntry(hDphi[kHIDATA][2][1],"PbPb 0-30%","p");

  TCanvas* c21 = new TCanvas("c21","",500,500);
  handsomeTH1(meanJetPt[kPPDATA][7], 1);
  meanJetPt[kPPDATA][7]->SetYTitle("<p_{T}^{Jet}>  (>30GeV)");
  meanJetPt[kPPDATA][7]->SetMarkerStyle(24);
  //  meanJetPt[kPPDATA][7]->SetAxisRange(-2,2,"X");
  meanJetPt[kPPDATA][7]->SetAxisRange(40,90,"Y");
  meanJetPt[kPPDATA][7]->Draw();

  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
    handsomeTH1(meanJetPt[kHIDATA][icent],kRed);
    if ( icent == 2 ) meanJetPt[kHIDATA][icent]->SetMarkerStyle(24);
    //if ( icent == 2 ) meanJetPt[kHIDATA][icent]->Draw("same");
    meanJetPt[kHIDATA][icent]->Draw("same");
  }
  l1 ->Draw();
  c21->SaveAs("figures/pT_dependence_jetPt_pp_pbpb_figure2.pdf");
  c21->SaveAs("figures/pT_dependence_jetPt_pp_pbpb_figure2.gif");

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

    c3->cd(ipt);

    // draw pp
    handsomeTH1(hxjg[kPPDATA][7][ipt], 1);
    hxjg[kPPDATA][7][ipt]->SetXTitle("x_{J#gamma}");
    hxjg[kPPDATA][7][ipt]->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N}");
    hxjg[kPPDATA][7][ipt]->SetMarkerStyle(24);

    //    hxjg[kPPDATA][7][ipt]->Scale(1./rjg[kPPDATA][7]->GetBinContent(ipt)); // rjg normalization 

    //    hxjg[kPPDATA][7][ipt]->Rebin(10);
    //    hxjg[kPPDATA][7][ipt]->Scale(1./10);
    hxjg[kPPDATA][7][ipt]->SetAxisRange(0,2.5,"X");
    hxjg[kPPDATA][7][ipt]->SetAxisRange(0,3,"Y");
    hxjg[kPPDATA][7][ipt]->Draw();

    // draw pbpb
    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
      handsomeTH1(hxjg[kHIDATA][icent][ipt],kRed);
      //      hxjg[kHIDATA][icent][ipt]->Scale(1./rjg[kHIDATA][icent]->GetBinContent(ipt)); // rjg normalization    
      //      hxjg[kHIDATA][icent][ipt]->Rebin(10);
      //   hxjg[kHIDATA][icent][ipt]->Scale(1./10);
      if ( icent == 2 ) hxjg[kHIDATA][icent][ipt]->SetMarkerStyle(24);
      if ( icent == 2 ) hxjg[kHIDATA][icent][ipt]->Draw("same");
      if ( icent == 1 ) hxjg[kHIDATA][icent][ipt]->Draw("same");

    }
    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

 
    onSun(30,0,200,0);
  }
  c3->cd(1);
  l1->Draw();  

  c3->SaveAs("figures/pT_dependence_xjg_pp_pbpb_figure1.pdf");
  c3->SaveAs("figures/pT_dependence_xjg_pp_pbpb_figure1.gif");

  TCanvas* c31 = new TCanvas("c31","",500,500);
  handsomeTH1(meanXjg[kPPDATA][7], 1);
  meanXjg[kPPDATA][7]->SetYTitle("<x_{J#gamma}>  (>30GeV)");
  meanXjg[kPPDATA][7]->SetMarkerStyle(24);
  //  meanXjg[kPPDATA][7]->SetAxisRange(-2,2,"X");
  meanXjg[kPPDATA][7]->SetAxisRange(0.6,1.2,"Y");
  meanXjg[kPPDATA][7]->Draw();

  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
    handsomeTH1(meanXjg[kHIDATA][icent],kRed);
    if ( icent == 2 ) meanXjg[kHIDATA][icent]->SetMarkerStyle(24);
    //if ( icent != 2 ) meanXjg[kHIDATA][icent]->Draw("same");
    meanXjg[kHIDATA][icent]->Draw("same");
  }
  l1->Draw();
     c31->SaveAs("figures/pT_dependence_xjg_pp_pbpb_figure1.pdf");
     c31->SaveAs("figures/pT_dependence_xjg_pp_pbpb_figure1.gif");
    

  TCanvas* c_rjg = new TCanvas("c_rjg","",500,500);
  handsomeTH1(rjg[kPPDATA][7], 1);
  rjg[kPPDATA][7]->SetYTitle("r_{J#gamma}");
  rjg[kPPDATA][7]->SetMarkerStyle(24);
  //  rjg[kPPDATA][7]->SetAxisRange(-2,2,"X");
  rjg[kPPDATA][7]->SetAxisRange(0.0,1.1,"Y");
  rjg[kPPDATA][7]->Draw();

  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
    handsomeTH1(rjg[kHIDATA][icent],kRed);
    if ( icent == 2 ) rjg[kHIDATA][icent]->SetMarkerStyle(24);
    //        if ( icent != 2 ) rjg[kHIDATA][icent]->Draw("same");
    rjg[kHIDATA][icent]->Draw("same");
  }
  l1->Draw();
  c_rjg->SaveAs("figures/pT_dependence_rjg_pp_pbpb_figure1.pdf");
  c_rjg->SaveAs("figures/pT_dependence_rjg_pp_pbpb_figure1.gif");
  
  
  
  // Save the final root histogram files
  TFile * fResults =  new TFile(Form("resultHistograms_ppSmeared%d.root",centBin),"update");
  
  
  // pp 
    
  meanJetPt[kPPDATA][7]->SetName(Form("meanJetPt_pp"));
  meanJetPt[kPPDATA][7]->Write();

  meanXjg[kPPDATA][7]->SetName(Form("meanXjg_pp"));
  meanXjg[kPPDATA][7]->Write();
    
  rjg[kPPDATA][7]->SetName(Form("meanRjg_pp"));
  rjg[kPPDATA][7]->Write();
    
  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
    hJetPt[kPPDATA][7][ipt]->SetName(Form("dNdJetPt_pp_ptBin%d",ipt));
    hJetPt[kPPDATA][7][ipt]->Write();
    hJetPtIaaBin[kPPDATA][7][ipt]->SetName(Form("dNdJetPt_IaaBin_pp_ptBin%d",ipt));
    hJetPtIaaBin[kPPDATA][7][ipt]->Write();
      
    hxjg[kPPDATA][7][ipt]->SetName(Form("dNdXjg_pp_ptBin%d",ipt));
    hxjg[kPPDATA][7][ipt]->Write();

    hDphi[kPPDATA][7][ipt]->SetName(Form("dNdphi_pp_ptBin%d",ipt));
    hDphi[kPPDATA][7][ipt]->Write();
      
      
  }
    

  // PbPb 
    
  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
    for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
      hJetPt[kHIDATA][icent][ipt]->SetName(Form("dNdJetPt_pbpb_centralityBin%d_ptBin%d",icent,ipt));
      hJetPt[kHIDATA][icent][ipt]->Write();	
      hJetPtIaaBin[kHIDATA][icent][ipt]->SetName(Form("dNdJetPt_IaaBin_pbpb_centralityBin%d_ptBin%d",icent,ipt));
      hJetPtIaaBin[kHIDATA][icent][ipt]->Write();	
  
      hxjg[kHIDATA][icent][ipt]->SetName(Form("dNdXjg_pbpb_centralityBin%d_ptBin%d",icent,ipt));
      hxjg[kHIDATA][icent][ipt]->Write();

      hDphi[kHIDATA][icent][ipt]->SetName(Form("dNdphi_pbpb_centralityBin%d_ptBin%d",icent,ipt));
      hDphi[kHIDATA][icent][ipt]->Write();
	
    }
      
    meanJetPt[kHIDATA][icent]->SetName(Form("meanJetPt_pbpb_centralityBin%d",icent));
    meanJetPt[kHIDATA][icent]->Write();
    meanXjg[kHIDATA][icent]->SetName(Form("meanXjg_pbpb_centralityBin%d",icent));
    meanXjg[kHIDATA][icent]->Write();
      
    rjg[kHIDATA][icent]->SetName(Form("meanRjg_pbpb_centralityBin%d",icent));
    rjg[kHIDATA][icent]->Write();
  }
    
  fResults->Close();
    
    
}
void drawPtDependenceOfDpt(bool drawPbPb=1, int xNorm = 1) {
  gStyle -> SetOptStat(0);  
  const int nPtBin = 5;
  double ptBin[nPtBin+1] = {40, 50,60,80,120,9999}; 
  double AvePtBin[nPtBin+1] = { 45, 54.1479, 67.4204, 99.6956, 150, 9999};
  
  TH1D* hxjg[7][1000]; // [species][centrality] 
  TH1D* hxjgNorm[7][1000];
  TH1D* hdpt[7][1000];
  TH1D* hdptNorm[7][1000];
  TH1D* hdphi[7][1000];
  
  valPair meanX[7][1000];
  valPair meanDpt[7][1000];
  valPair rjg[7][1000];
  TGraphAsymmErrors* gr[7];
  TGraphAsymmErrors* gx[7];
  TGraphAsymmErrors* gdpt[7];
  for (int i=0;i<7;i++) {  
    gr[i] = new TGraphAsymmErrors();
    gr[i]->SetName(Form("gr_%d",i));
    gx[i] = new TGraphAsymmErrors();
    gx[i]->SetName(Form("gx_%d",i));
    gdpt[i] = new TGraphAsymmErrors();
    gdpt[i]->SetName(Form("gdpt_%d",i));
  }
  TFile* fff[7][1000];
  
  for ( int ipt = 0 ; ipt<nPtBin  ; ipt++) { 
    for ( int iSpecies=0 ; iSpecies<=5 ; iSpecies++){ 
      if (  (iSpecies!=kPPDATA)&&(iSpecies!=kHIDATA) ) 
	continue;
      
      int iglb = ipt + iSpecies*50.;
      int icent = -1;
      
      if ( iSpecies == kPPDATA) { 
        icent = 7;
	fff[iSpecies][iglb] = new TFile(Form("photonTrackCorr_ppDATA_output_photonPtThr%d_to_%d_jetPtThr30_20130816.root",(int)ptBin[ipt],(int)ptBin[ipt+1]));
      }
      if ( iSpecies == kHIDATA) { 
	icent = 10030;
	//	icent = 13099;
	fff[iSpecies][iglb] = new TFile(Form("photonTrackCorr_pbpbDATA_output_photonPtThr%d_to_%d_jetPtThr30_20130816.root",(int)ptBin[ipt],(int)ptBin[ipt+1]));
      }
  cout << "hdphi" << endl;     
      hdphi[iSpecies][iglb] = (TH1D*)fff[iSpecies][iglb]->Get(Form("jetDphi_icent%d_final",icent));
      
      hxjg[iSpecies][iglb] = (TH1D*)fff[iSpecies][iglb]->Get(Form("xjg_icent%d_final",icent));
      hxjgNorm[iSpecies][iglb] = (TH1D*)hxjg[iSpecies][iglb]->Clone(Form("norm_%s",hxjg[iSpecies][iglb]->GetName()) );
      meanX[iSpecies][iglb].val = hxjg[iSpecies][iglb]->GetMean();
      meanX[iSpecies][iglb].err = hxjg[iSpecies][iglb]->GetMeanError();
      gx[iSpecies]->SetPoint     (ipt+1, AvePtBin[ipt], meanX[iSpecies][iglb].val);
      gx[iSpecies]->SetPointError(ipt+1, 0.001,0.001, meanX[iSpecies][iglb].err, meanX[iSpecies][iglb].err);

      hdpt[iSpecies][iglb] = (TH1D*)fff[iSpecies][iglb]->Get(Form("dpt_icent%d_final",icent));
      hdptNorm[iSpecies][iglb] = (TH1D*)hdpt[iSpecies][iglb]->Clone(Form("norm_%s",hdpt[iSpecies][iglb]->GetName()) );
      meanDpt[iSpecies][iglb].val = hdpt[iSpecies][iglb]->GetMean();
      meanDpt[iSpecies][iglb].err = hdpt[iSpecies][iglb]->GetMeanError();
      gdpt[iSpecies]->SetPoint     (ipt+1, AvePtBin[ipt], meanDpt[iSpecies][iglb].val);
      gdpt[iSpecies]->SetPointError(ipt+1, 0.001,0.001, meanDpt[iSpecies][iglb].err, meanDpt[iSpecies][iglb].err);

cout << "rError" << endl;      
      double rError;
      rjg[iSpecies][iglb].val = hxjg[iSpecies][iglb]->IntegralAndError(1, hxjg[iSpecies][iglb]->GetNbinsX(), rError, "width");
      rjg[iSpecies][iglb].err = rError;
      gr[iSpecies]->SetPoint     (ipt+1, AvePtBin[ipt], rjg[iSpecies][iglb].val);
      gr[iSpecies]->SetPointError(ipt+1, 0.001,0.001, rjg[iSpecies][iglb].err, rjg[iSpecies][iglb].err);

      
    }
  }
  
  cout << "finish!"<< endl; 
  //
  //for PbPb 30-100 % !!
  //
  for ( int ipt = 0 ; ipt<nPtBin  ; ipt++) { 
      cout << "in the for loop  " << endl;
      int iSpecies=6;
      int iglb = ipt + iSpecies*50.;
      int icent = 13099;
      fff[iSpecies][iglb] = new TFile(Form("photonTrackCorr_pbpbDATA_output_photonPtThr%d_to_%d_jetPtThr30_20130816.root",(int)ptBin[ipt],(int)ptBin[ipt+1]));
      hdphi[iSpecies][iglb] = (TH1D*)fff[iSpecies][iglb]->Get(Form("jetDphi_icent%d_final",icent));

      hxjg[iSpecies][iglb] = (TH1D*)fff[iSpecies][iglb]->Get(Form("xjg_icent%d_final",icent));
      hxjgNorm[iSpecies][iglb] = (TH1D*)hxjg[iSpecies][iglb]->Clone(Form("norm_%s",hxjg[iSpecies][iglb]->GetName()) );
      meanX[iSpecies][iglb].val = hxjg[iSpecies][iglb]->GetMean();
      meanX[iSpecies][iglb].err = hxjg[iSpecies][iglb]->GetMeanError();
      gx[iSpecies]->SetPoint     (ipt+1, AvePtBin[ipt], meanX[iSpecies][iglb].val);
      gx[iSpecies]->SetPointError(ipt+1, 0.001,0.001, meanX[iSpecies][iglb].err, meanX[iSpecies][iglb].err);

      hdpt[iSpecies][iglb] = (TH1D*)fff[iSpecies][iglb]->Get(Form("dpt_icent%d_final",icent));
      hdptNorm[iSpecies][iglb] = (TH1D*)hdpt[iSpecies][iglb]->Clone(Form("norm_%s",hdpt[iSpecies][iglb]->GetName()) );
      meanDpt[iSpecies][iglb].val = hdpt[iSpecies][iglb]->GetMean();
      meanDpt[iSpecies][iglb].err = hdpt[iSpecies][iglb]->GetMeanError();
      gdpt[iSpecies]->SetPoint     (ipt+1, AvePtBin[ipt], meanDpt[iSpecies][iglb].val);
      gdpt[iSpecies]->SetPointError(ipt+1, 0.001,0.001, meanDpt[iSpecies][iglb].err, meanDpt[iSpecies][iglb].err);

      double rError;
      rjg[iSpecies][iglb].val = hxjg[iSpecies][iglb]->IntegralAndError(1, hxjg[iSpecies][iglb]->GetNbinsX(), rError, "width");
      rjg[iSpecies][iglb].err = rError;
      gr[iSpecies]->SetPoint     (ipt+1, AvePtBin[ipt], rjg[iSpecies][iglb].val);
      gr[iSpecies]->SetPointError(ipt+1, 0.001,0.001, rjg[iSpecies][iglb].err, rjg[iSpecies][iglb].err);
  }

            
 

  TCanvas* c1 = new TCanvas("c1","",900,350);
  makeMultiPanelCanvas(c1,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 0 ; ipt<nPtBin  ; ipt++) {
    
    
    c1->cd(ipt+1);
    
    int iSpecies = kPPDATA;
    int iglb = ipt + iSpecies*50.;
    handsomeTH1(hdptNorm[iSpecies][iglb],1);
    if (xNorm==1) scaleInt(hdptNorm[iSpecies][iglb]);
    hdptNorm[iSpecies][iglb]->SetXTitle("x_{J,#gamma}");
    hdptNorm[iSpecies][iglb]->SetYTitle("#frac{dN}{dx} #frac{1}{N}");
    hdptNorm[iSpecies][iglb]->SetAxisRange(-100,100,"X");
    if (xNorm==1)     hdptNorm[iSpecies][iglb]->SetAxisRange(-.03,.6,"Y");
    else              hdptNorm[iSpecies][iglb]->SetAxisRange(-.03,.6,"Y");
    hdptNorm[iSpecies][iglb]->SetMarkerStyle(24);
    hdptNorm[iSpecies][iglb]->Draw();

    iSpecies = kHIDATA;
    iglb = ipt + iSpecies*50.;
    if (xNorm==1)  scaleInt(hdptNorm[iSpecies][iglb]);
    handsomeTH1(hdptNorm[iSpecies][iglb],2);
    if (drawPbPb) hdptNorm[iSpecies][iglb]->Draw("same");
    
    //for PbPb 30-100 % !! 
    iSpecies = 6;
    iglb = ipt + iSpecies*50.;
    if (xNorm==1)  scaleInt(hdptNorm[iSpecies][iglb]);
    handsomeTH1(hdptNorm[iSpecies][iglb],2);
    hdptNorm[iSpecies][iglb] -> SetMarkerStyle(24);

    if (drawPbPb) hdptNorm[iSpecies][iglb]->Draw("same");
    //    onSun(0,0,2,0);

    //    onSun(meanX[iSpecies][iglb].val - meanX[iSpecies][iglb].err, 0, meanX[iSpecies][iglb].val+meanX[iSpecies][iglb].err,0,ycolor[ipt+1],2);

    float dx1;    
    (ipt==0)? dx1=0.15 : dx1=0 ;
    
    if ( ipt == nPtBin-1 ) 
      drawText(Form("p_{T}^{#gamma} > %dGeV,   p_{T}^{jet}>30GeV", (int)ptBin[ipt]), 0.12+dx1+0.25,0.889118,1,15);
    else 
      drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV,   p_{T}^{jet}>30GeV", (int)ptBin[ipt], (int)ptBin[ipt+1]), 0.12+dx1,0.889118,1,15);

      
    TLegend *l1 = new TLegend(0.6365615,0.6445304,0.9577623,0.846736,NULL,"brNDC");
    easyLeg(l1,"2.76TeV");
    l1->AddEntry(hdptNorm[kPPDATA][ipt + kPPDATA*50],"pp ","p");
    if (drawPbPb)    l1->AddEntry(hdptNorm[kHIDATA][iglb],"PbPb 0-30%","p");
    if (drawPbPb)    l1->AddEntry(hdptNorm[6][iglb],"PbPb 30-100%","p");
    if ( ipt==0 )   l1->Draw();

  }
  //  c1->SaveAs(Form("gifs/dpt_ptDependence_drawPbPb%d_norm%d.pdf",drawPbPb,xNorm));

  TCanvas* cDphi = new TCanvas("cDphi","",900,350);
  makeMultiPanelCanvas(cDphi,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
  for ( int ipt = 0 ; ipt<nPtBin  ; ipt++) {
    cDphi->cd(ipt+1);
    
    int iSpecies = kPPDATA;
    int iglb = ipt + iSpecies*50.;
    handsomeTH1(hdphi[iSpecies][iglb],1);
    hdphi[iSpecies][iglb]->SetYTitle("x_{J,#gamma}");
    hdphi[iSpecies][iglb]->SetXTitle("#Delta#phi_{J,#gamma}");
    hdphi[iSpecies][iglb]->Scale(1./hdphi[iSpecies][iglb]->Integral("width"));
    hdphi[iSpecies][iglb]->SetAxisRange(0.01,30,"Y");
    hdphi[iSpecies][iglb]->SetMarkerStyle(24);
    hdphi[iSpecies][iglb]->Draw();

    iSpecies = kHIDATA;
    iglb = ipt + iSpecies*50.;
    hdphi[iSpecies][iglb]->Scale(1./hdphi[iSpecies][iglb]->Integral("width"));
    handsomeTH1(hdphi[iSpecies][iglb],2);
    if (drawPbPb)     hdphi[iSpecies][iglb]->Draw("same");
    
    // for PbPb 30-100% !!!
    iSpecies = 6;
    iglb = ipt + iSpecies*50.;
    hdphi[iSpecies][iglb]->Scale(1./hdphi[iSpecies][iglb]->Integral("width"));
    handsomeTH1(hdphi[iSpecies][iglb],2);
    hdphi[iSpecies][iglb] -> SetMarkerStyle(24);
    if (drawPbPb)     hdphi[iSpecies][iglb]->Draw("same");
    
    gPad->SetLogy();
    float dx1;    
    (ipt==0)? dx1=0.15 : dx1=0 ;
    
    if ( ipt == nPtBin-1 ) 
      drawText(Form("%dGeV<p_{T}^{#gamma},   p_{T}^{jet}>30GeV", (int)ptBin[ipt]), 0.15+dx1+0.25,0.889118,1,15);
    else 
      drawText(Form("%dGeV<p_{T}^{#gamma}<%dGeV,   p_{T}^{jet}>30GeV", (int)ptBin[ipt], (int)ptBin[ipt+1]), 0.15+dx1,0.889118,1,15);
    
      
    TLegend *l1 = new TLegend(0.6365615,0.6445304,0.9577623,0.846736,NULL,"brNDC");
    easyLeg(l1,"2.76TeV");
    l1->AddEntry(hdphi[kPPDATA][ipt + kPPDATA*50],"pp ","p");
    if (drawPbPb)    l1->AddEntry(hdphi[kHIDATA][iglb],"PbPb 0-30%","p");
    if (drawPbPb)    l1->AddEntry(hdphi[6][iglb],"PbPb 30-100%","p");
    if ( ipt==0 )   l1->Draw();

  }

  
  //  cDphi->SaveAs(Form("gifs/dphi_ptDependence_drawPbPb%d_norm%d.pdf",drawPbPb,xNorm));
  
  TCanvas* c2 = new TCanvas("c2","",800,400);
  c2->Divide(2,1);
  c2->cd(2);
  TH1D* hr = new TH1D("hr",";p_{T}^{#gamma};r_{J,#gamma}",200,20,180);
  handsomeTH1(hr,0);
  hr->SetAxisRange(0.0,1.3,"Y");
  //  hr->SetNdivisions(5);
  hr->Draw();
  handsomeTGraph(gr[kPPDATA],1);
  handsomeTGraph(gr[kHIDATA],2);
  handsomeTGraph(gr[6],2);
  gr[kPPDATA]->SetMarkerStyle(24);
  gr[kPPDATA]->Draw("same p");
  gr[6]->SetMarkerStyle(24);
  if (drawPbPb)   gr[kHIDATA]->Draw("same p");
  if (drawPbPb)   gr[6]->Draw("same p");
  jumSun(20,1,180,1);


  
  c2->cd(1);
  TH1D* hx = (TH1D*)hr->Clone("hx");
  handsomeTH1(hx,0);
  hx->SetYTitle("<#Deltap_{T}^{J,#gamma}>");
  hx->SetAxisRange(-60,10,"Y");
  //  hx->SetNdivisions(5);
  hx->Draw();
  handsomeTGraph(gdpt[kPPDATA],1);
  handsomeTGraph(gdpt[kHIDATA],2);
  handsomeTGraph(gdpt[6],2);
  gdpt[kPPDATA]->SetMarkerStyle(24);
  gdpt[6]->SetMarkerStyle(24);
  gdpt[kPPDATA]->Draw("same p");
  if (drawPbPb)   gdpt[kHIDATA]->Draw("same p");
  if (drawPbPb)   gdpt[6]->Draw("same p");
  jumSun(20,1,180,1);
 
  gStyle -> SetEndErrorSize(0);
  
  TLegend *l1=   new TLegend(0.5226071,0.6300415,0.9597724,0.8332584,NULL,"brNDC");
  easyLeg(l1,"2.76TeV");
  l1->AddEntry(gr[kPPDATA],"pp ","p");
  if (drawPbPb)     l1->AddEntry(gr[kHIDATA],"PbPb 0-30%","p");
  if (drawPbPb)     l1->AddEntry(gr[6],"PbPb 30-100%","p");
  l1->Draw();

  //  c2->SaveAs(Form("gifs/summaryPlot_ptDependence_drawPbPb%d_norm%d.pdf",drawPbPb,xNorm));

}
Esempio n. 18
0
void drawSpecRat_pp(
    TString infname="histff_tv11ppdatajet_ak3pf_an0509trk5.root",
    TString mcfname="histff_tv11_dj80mattpfgmv1_ak3pf_j2t2_an0509trk5.root",
    TString inrefname = "../specRef/toFrank/output_interpolation.root"
    )
{
  cout << infname << endl;
  cout << mcfname << endl;
  cout << inrefname << endl;
  TFile * inf = new TFile(infname);
  TFile * mcf = new TFile(mcfname);
  TFile * inref = new TFile(inrefname);
  TString outdir = "out/20110509";
  TString outname = infname+"_vs_interpolation";
  outname.ReplaceAll(".root","");

  Bool_t doRebin=true;
  TFile * outf = new TFile(outdir+"/final"+outname+".root","RECREATE");

  // Histograms
  //TH1D * hSpec_ref = (TH1D*)inf->FindObjectAny("hGenSpecCorr0");
  //TH1D * hSpec_ref = (TH1D*)inref->Get("corrTypeOne/hdndpt_full");
  TH1D * hSpec_gen = (TH1D*)mcf->FindObjectAny(Form("hGenSpecCorr0"));
  TH1D * hSpec_ana = (TH1D*)inf->FindObjectAny(Form("hRecSpecCorr2"));
  // pp interpolation
  float xsection_nn = 64.0;  // https://twiki.cern.ch/twiki/bin/view/Main/LHCGlauberBaseline                             
  TH1D * hdndpt1_pre = (TH1D*) inref->Get("h2760combined");
  hdndpt1_pre->Scale(2.); // as the interpolated spectra is h+ + h-
  hdndpt1_pre->Scale(1./xsection_nn);
  TH1D * hSpec_ref = (TH1D*) hSpec_ana->Clone("hSpec_ref");
  recastPPRefHist(hSpec_ref,hdndpt1_pre,false);


  // normalization
  Int_t begbin_ref, endbin_ref, begbin_ana, endbin_ana;
  begbin_ref = hSpec_ref->FindBin(40.01);
  endbin_ref = hSpec_ref->FindBin(200);
  begbin_ana = hSpec_ana->FindBin(40.01);
  endbin_ana = hSpec_ana->FindBin(200);
  cout << "Integral range. ref: " << begbin_ref << "," << endbin_ref << " ana: " << begbin_ana << "," << endbin_ana << endl;
  Float_t area_ref = integrateHistArea(hSpec_ref,begbin_ref,endbin_ref);
  Float_t area_ana = integrateHistArea(hSpec_ana,begbin_ana,endbin_ana);
  Float_t area_rat = area_ana/area_ref;
  cout << "Ref area: " << area_ref << " Ana area: " << area_ana << " ratio ana/ref: " << area_rat << endl;
  Float_t scale_ana = 1.479e-03;
  //Float_t scale_ana = 2.363e-03;
  //Float_t scale_ref = area_rat;
  Float_t scale_ref = 1658.15;
  //scale_ref = 1658.15*137438./198;
  //scale_ref = 1658.15*137438./198/0.47;
  hSpec_ana->Scale(scale_ana);
  hSpec_gen->Scale(scale_ana);
  hSpec_ref->Scale(scale_ref);
  cout << "final scale_ref: " << scale_ref << endl;

  // rebin
  if (doRebin) {
    hSpec_ana->Rebin(2);
    hSpec_ana->Scale(0.5);
    hSpec_gen->Rebin(2);
    hSpec_gen->Scale(0.5);
    hSpec_ref->Rebin(2);
    hSpec_ref->Scale(0.5);
  }

  // fit
  TString fitFor3 = "[0]*pow((x+[1]),[2])*exp([3]*x+[4])";
  cout << "Fit3: " << fitFor3 << endl;
  TF1 * fitF3 = new TF1("fitF3",fitFor3.Data(),1,200);
  fitF3->SetParameters(1,1,-5,0.0,1);
  fitF3->SetParLimits(2,-7.0,-2.0);
  fitF3->SetParLimits(3,-1,.0);
  fitF3->SetParLimits(4,0.0,5.0);
  //hSpec_ref->Fit("fitF3","0","",10,200);

  // ratio
  //TH1D * hSpec_refrat = (TH1D*)hSpec_ref->Clone("hSpec_refrat");
  //hSpec_refrat->Divide(fitF3);
  TH1D * hSpec_anarat = (TH1D*)hSpec_ana->Clone("hSpec_anarat");
  //hSpec_anarat->Divide(fitF3);
  hSpec_anarat->Divide(hSpec_ref);
  TH1D * hSpec_anagenrat = (TH1D*)hSpec_ana->Clone("hSpec_anagenrat");
  hSpec_anagenrat->Divide(hSpec_gen);

  // draw
  TCanvas * c2 = new TCanvas("c2","c2",500,900);
  c2->Divide(1,2);
  c2->cd(1);
  gPad->SetLogy();
  hSpec_ref->SetMarkerStyle(kOpenSquare);
  hSpec_ana->SetAxisRange(0,100,"X");
  hSpec_ana->SetAxisRange(1e-7,1e3,"Y");
  hSpec_ana->SetTitle(";Trk p_{T} (GeV/c); #frac{1}{N_{MB}} #frac{dN}{dp_{T}}");
  handsomeTH1(hSpec_ana);
  hSpec_gen->SetLineColor(kRed);
  hSpec_ana->Draw("E");
  hSpec_gen->Draw("samehist");
  hSpec_ref->Draw("Esame");
  //fitF3->Draw("same");
  c2->cd(2);
  hSpec_anarat->SetAxisRange(0,100,"X");
  hSpec_anarat->SetAxisRange(0,3,"Y");
  hSpec_anarat->SetTitle(";Trk p_{T} (GeV/c); Data/Reference");
  handsomeTH1(hSpec_anarat);
  hSpec_anagenrat->SetMarkerColor(kRed);
  hSpec_anagenrat->SetLineColor(kRed);
  hSpec_anarat->Draw("E");
  //hSpec_anarat->Fit("pol0","","",20,120);
  //hSpec_refrat->SetMarkerStyle(kOpenSquare);
  //hSpec_refrat->Draw("Esame");
  hSpec_anagenrat->Draw("same");

  TLine * l = new TLine(0,1,100,1);
  l->SetLineStyle(2);
  l->Draw();

  c2->cd(1);
  TLegend *leg = new TLegend(0.52,0.65,0.91,0.91);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
  leg->AddEntry(hSpec_ref,"pp data","");
  leg->AddEntry(hSpec_ref,"Trk |#eta|<1","");
  leg->AddEntry(hSpec_ref,"Interpolation","l");
  leg->AddEntry(hSpec_gen,"Pythia Gen. Charged","l");
  leg->AddEntry(hSpec_ana,"Jet Analysis","p");
  leg->Draw();

  c2->cd(2);
  TLegend *leg = new TLegend(0.29,0.74,0.68,0.90);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
  leg->AddEntry(hSpec_anarat,"Jet Analysis/Interpolation","p");
  leg->AddEntry(hSpec_anagenrat,"Jet Analysis/Pythia Gen. Ch.","p");
  leg->Draw();

  c2->Print(outdir+"/Spectra_comp_"+outname+".gif");
}
Esempio n. 19
0
void drawTrackingClosure()
{
  TCut centCut = "cBin>=0&&cBin<4";
  TCut jetSelCut[2] = {"jetPt>100&&jetPt<300&&jetUnSmPt<100","jetPt>100&&jetPt<300&&jetUnSmPt<100"};
  // TCut jetSelCut[2] = {"jetUnSmPt>100&&jetUnSmPt<300","jetUnSmPt>100&&jetUnSmPt<300"};
  TString jetAlias[2] = {"jetPt","jetPt"};
  // TString jetAlias[2] = {"jetUnSmPt","jetUnSmPt"};

  multiTreeUtil vmt[2];

  // Mar 04
  // hi
  vmt[0].addFile("../ntout/jskim_hydj80_akPu3PF_Mar04job0_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_hydj100_akPu3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[0] && centCut && "pthat>=100&&pthat<170",3.069e-5*1.e9);
  vmt[0].addFile("../ntout/jskim_hydj170_akPu3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[0] && centCut && "pthat>=170&&pthat<9999",1.470e-6*1.e9);
  vmt[1].addFile("../ntout/jskim_hydj80_akPu3PF_Mar04job0_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_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[1] && centCut && "pthat>=100&&pthat<170",3.069e-5*1.e9);
  vmt[1].addFile("../ntout/jskim_hydj170_akPu3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut[1] && centCut && "pthat>=170&&pthat<9999",1.470e-6*1.e9);
  // pp
  // vmt[0].addFile("../ntout/jskim_dj80_ak3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root", "tdj", jetSelCut[0] && "pthat>=80&&pthat<120",9.913e-5*1.e9);
  // vmt[0].addFile("../ntout/jskim_dj120_ak3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root", "tdj", jetSelCut[0] && "pthat>=120&&pthat<170",1.128e-5*1.e9);
  // vmt[0].addFile("../ntout/jskim_dj170_ak3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root", "tdj", jetSelCut[0] && "pthat>=170&&pthat<9999",1.470e-6*1.e9);
  // vmt[1].addFile("../ntout/jskim_dj80_ak3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root", "tdj", jetSelCut[1] && "pthat>=80&&pthat<120",9.913e-5*1.e9);
  // vmt[1].addFile("../ntout/jskim_dj120_ak3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root", "tdj", jetSelCut[1] && "pthat>=120&&pthat<170",1.128e-5*1.e9);
  // vmt[1].addFile("../ntout/jskim_dj170_ak3PF_Mar04job0_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin1_ak3PF_gj0.root", "tdj", jetSelCut[1] && "pthat>=170&&pthat<9999",1.470e-6*1.e9);

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

  TString annotation="#DeltaR<0.3";
  TString tag="hiMar04job0trkcorr14d_dr3_limcorr_unsmptlt100";
  // TString tag="ppMar04job0trkcorr14d_dr3_limcorr_sm2bin1";

  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";
  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",805,0,800,400);
  c0->Divide(2,1);
  c0->cd(1);
  gPad->SetLogy();
  cleverRange(hJetPt[0],hJetPt[1],5);
  handsomeTH1(hJetPt[0],kBlack);
  handsomeTH1(hJetPt[1],kRed);
  hJetPt[0]->SetYTitle("# of Jets");
  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
  float xminpt=1, xmaxpt=119;
  TString trkVar[2]={"yTrk.pt","genPar.pt"};
  TString xiVar[2]={"log(finalJetPt/yTrk.pt)","log(finalJetPt/genPar.pt)"};
  // TCut trkCut[2]={
  //   "yTrk.jetMatch==1 && yTrk.jetDr<0.30 && yTrk.pt>1.00 && yTrk.pt<300.00 && yTrk.trkWeight<10",
  //   "abs(genPar.chg)>0 && genPar.jetMatch==1 && genPar.jetDr<0.30 && genPar.pt>1.00 && genPar.pt<300.00"
  // };
  // Signal Cone
  TCut trkCut[2]={"yTrk.jetMatch==1&&yTrk.jetDr<0.30","abs(genPar.chg)>0 && genPar.jetMatch==1 && genPar.jetDr<0.30"};
  // Bkg Cone
  // TCut trkCut[2]={"yTrk.jetMatch==-1&&yTrk.jetDr<0.30","abs(genPar.chg)>0 && genPar.jetMatch==-1 && genPar.jetDr<0.30"};
  // trkCut[1]=trkCut[1]&&"genPar.sube==0";
  // TString trkWeight[2]={"(yTrk.trkWeight)","1"};
  // TString trkWeight[2]={"((yTrk.trkWeight)*(1-yTrk.jetDr/0.3*0.08*(yTrk.jetDr<0.3)))","1"};
  TString trkWeight[2]={"(yTrk.trkWeight*(yTrk.trkWeight<10)+1.47*(yTrk.trkWeight>=10))","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);",nPtBin,ptBin);
    vmt[i].Draw(hTrkPt[i],trkVar[i],jetCut&&trkCut[i],trkWeight[i]);
    hXi[i] = new TH1D(Form("hXi_%d",i),";#xi = ln(1/z);",16,-1,7);
    vmt[i].Draw(hXi[i],xiVar[i],jetCut&&trkCut[i],trkWeight[i]);
  }

  // Normalize
  for (int i=0; i<2; ++i) {
    hJetPt[i]->Scale(1./nJet[i]);
    hJetPt[i]->SetYTitle("Jet Fraction");
    normHist(hTrkPt[i],0,true,1./nJet[i]);
    normHist(hXi[i],0,true,1./nJet[i]);
  }

  /////////////////////////////////////
  // Draw Jet
  /////////////////////////////////////
  TCanvas * c2 = new TCanvas("c2","c2",805,425,800,400);
  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);

  /////////////////////////////////////
  // Draw Track Pt
  /////////////////////////////////////
  TCanvas * c3 = new TCanvas("c3","c3",10,0,800,400);
  c3->Divide(2,1);
  c3->cd(1);
  gPad->SetLogy();
  gPad->SetLogx();
  handsomeTH1(hTrkPt[0],kBlack);
  handsomeTH1(hTrkPt[1],kRed);
  hTrkPt[0]->SetTitle(";p_{T}^{ Track} (GeV/c);1/N_{ jet} dN_{ Track} /dp_{T}");
  hTrkPt[0]->Draw("E");
  hTrkPt[1]->Draw("same hist");

  TLegend * l1 = new TLegend(0.35,0.19,0.78,0.40,NULL,"brNDC");
  easyLeg(l1,"",20);
  l1->AddEntry(hTrkPt[0],annotation,"");
  l1->AddEntry(hTrkPt[0],"Rec. Tracks","p");
  l1->AddEntry(hTrkPt[1],"Gen. Partls","l");
  l1->Draw();

  c3->cd(2);
  gPad->SetLogx();
  TH1D * hTrkPtRat = (TH1D*)hTrkPt[0]->Clone(Form("%s_rat",hTrkPt[0]->GetName()));
  hTrkPtRat->Divide(hTrkPt[1]);
  hTrkPtRat->SetAxisRange(xminpt,xmaxpt,"X");
  hTrkPtRat->SetAxisRange(0.5,1.5,"Y");
  hTrkPtRat->SetYTitle("Ratio");
  hTrkPtRat->Draw("E");
  jumSun(xminpt,1,xmaxpt,1,kRed);
  c3->Print(Form("closure/trackingClosure_pt_%s.gif",tag.Data()));
  c3->Print(Form("closure/trackingClosure_pt_%s.pdf",tag.Data()));

  /////////////////////////////////////
  // Draw Xi
  /////////////////////////////////////
  TCanvas * c5 = new TCanvas("c5","c5",10,425,800,400);
  c5->Divide(2,1);
  c5->cd(1);
  gPad->SetLogy();
  handsomeTH1(hXi[0],kBlack);
  handsomeTH1(hXi[1],kRed);
  hXi[0]->SetTitle(";#xi = ln(1/z);1/N_{ jet} dN_{ track} /d#xi");
  hXi[0]->Draw("E");
  hXi[1]->Draw("same hist");
  l1->Draw();
  c5->cd(2);
  TH1D * hXiRat = (TH1D*)hXi[0]->Clone(Form("%s_rat",hXi[0]->GetName()));
  hXiRat->Divide(hXi[1]);
  hXiRat->SetAxisRange(0.5,1.5,"Y");
  hXiRat->SetYTitle("Ratio");
  hXiRat->Draw("E");
  jumSun(0,1,6,1,kRed);
  c5->Print(Form("closure/trackingClosure_xi_%s.gif",tag.Data()));
  c5->Print(Form("closure/trackingClosure_xi_%s.pdf",tag.Data()));
}
void drawDphi() { 
  
  TH1D* hdphi[5][5]; // [species][centrality] 
  TH1D* hxjg[5][5]; // [species][centrality] 
  TH1D* hxjgNorm[5][5];
  TFile* fff[5];
  
  fff[kHIDATA] = new TFile("ffFiles/photonTrackCorr_pbpbDATA_output_photonPtThr60_jetPtThr30_20130210_genLevel0.root");
  for ( int iSpecies =0 ; iSpecies<=5 ; iSpecies++) {
    if (iSpecies != kHIDATA)       continue;
    for ( int icent = 1 ; icent<=4 ; icent++) {
      hdphi[iSpecies][icent] = (TH1D*)fff[iSpecies]->Get(Form("jetDphi_icent%d_final",icent));
      hxjg[iSpecies][icent] = (TH1D*)fff[iSpecies]->Get(Form("jetXjg_icent%d_final",icent));
      hxjgNorm[iSpecies][icent] = (TH1D*)hxjg[iSpecies][icent]->Clone(Form("norm_%s",hxjg[iSpecies][icent]->GetName()));
      scaleInt(hxjgNorm[iSpecies][icent]);    
    }}
  
  fff[kHIMC]   = new TFile("ffFiles/photonTrackCorr_pbpbMC_output_photonPtThr60_jetPtThr30_20130210_genLevel0.root"); 
  for ( int iSpecies =0 ; iSpecies<=5 ; iSpecies++) {
    if (iSpecies != kHIMC)         continue;
    for ( int icent = 1 ; icent<=4 ; icent++) {
      hdphi[iSpecies][icent] = (TH1D*)fff[iSpecies]->Get(Form("jetDphi_icent%d_final",icent));
      hxjg[iSpecies][icent] = (TH1D*)fff[iSpecies]->Get(Form("jetXjg_icent%d_final",icent));
      hxjgNorm[iSpecies][icent] = (TH1D*)hxjg[iSpecies][icent]->Clone(Form("norm_%s",hxjg[iSpecies][icent]->GetName()));
      scaleInt(hxjgNorm[iSpecies][icent]);
    }}
  
  
  
  TCanvas* c1 = new TCanvas("c1","",1400,450);
  makeMultiPanelCanvas(c1,4,1,0.0,0.0,0.2,0.15,0.02);
  for ( int icent = 1 ; icent<=4 ; icent++) {
    c1->cd(5-icent);
    handsomeTH1(hdphi[kHIMC][icent],1);
    handsomeTH1(hdphi[kHIDATA][icent],2);
    hdphi[kHIMC][icent]->Scale(1./hdphi[kHIMC][icent]->Integral("width"));
    hdphi[kHIDATA][icent]->Scale(1./hdphi[kHIDATA][icent]->Integral("width"));
    hdphi[kHIMC][icent]->SetAxisRange(3.141592/3.,3.141592,"X");
    hdphi[kHIMC][icent]->SetAxisRange(0.01,5,"Y");
    hdphi[kHIMC][icent]->DrawCopy("hist");
    //  hdphi[kHIDATA][icent]->Draw("same");
    //    gPad->SetLogy();
    
    TF1 *fdphi = new TF1("fdphi","exp(-(TMath::Pi()-x)/[0]) / ([0]*(1-exp(-TMath::Pi()/[0]))) ",2.0*TMath::Pi()/3.0,TMath::Pi());
    fdphi->SetParName(0,"width");
    fdphi->SetParameter("width",0.22);
        
    float fitxmin=3.1415926*2./3;
    //    float fitxmin=2.5;
    hdphi[kHIMC][icent]->Fit("fdphi","0llm","",fitxmin,3.1415926);
    fdphi->SetLineWidth(1);
    fdphi->SetLineStyle(2);
    fdphi->SetLineColor(kBlue);
    float dphiWidth = fdphi->GetParameter("width");
    float dphiWidthErr = fdphi->GetParError(0);
    cout << " dphiWidth,dphiWidthErr = " << dphiWidth <<"   "<< dphiWidthErr << endl;
    fdphi->DrawCopy("same");
  }
  c1->SaveAs("pdfFiles/dPhi_MC_only.pdf");


  TCanvas* c2 = new TCanvas("c2","",1400,450);
  makeMultiPanelCanvas(c2,4,1,0.0,0.0,0.2,0.15,0.02);
  for ( int icent = 1 ; icent<=4 ; icent++) {
    c2->cd(5-icent);
    handsomeTH1(hxjgNorm[kHIMC][icent],1);
    handsomeTH1(hxjgNorm[kHIDATA][icent],2);
    hxjgNorm[kHIMC][icent]->SetAxisRange(-0.01,0.35,"Y");
    hxjgNorm[kHIMC][icent]->DrawCopy("");
    //    hxjgNorm[kHIDATA][5-icent]->Draw("same");
    int lowCent = centBin1[icent-1];    int highCent = centBin1[icent]-1;
    drawText(Form("%.0f%% - %.0f%%", float((float)lowCent*2.5), float((float)(highCent+1)*2.5)), 0.67,0.7,1);
  }
  TLegend *l12 = new TLegend(0.304355,0.755085,.8,0.9552542,NULL,"brNDC");
  easyLeg(l12,"p_{T}^{Jet}/p_{T}^{#gamma}");
  l12->AddEntry(hxjgNorm[kHIMC][1],"PYTHIA+HYDJET","pl");
  c2->cd(1);   l12->Draw();

  c2->SaveAs("pdfFiles/xgj_MC_only.pdf");

  TCanvas* c2MCover = new TCanvas("c2MCover","",500,500);
  bool drawn=false;
  for ( int icent = 1 ; icent<=4 ; icent++) {
    c2MCover->cd(icent);
    handsomeTH1(hxjgNorm[kHIMC][icent],ycolor[icent]);
    hxjgNorm[kHIMC][5-icent]->SetAxisRange(-0.01,0.38,"Y");
    if (drawn)  
      hxjgNorm[kHIMC][5-icent]->Draw("same");
    else       hxjgNorm[kHIMC][5-icent]->Draw("");
    
    
    drawn = true;
  }
  TLegend *l11 = new TLegend(0.1794355,0.7055085,1,0.9152542,NULL,"brNDC");
  easyLeg(l11,"p_{T}^{Jet}/p_{T}^{#gamma} of PYTHIA embedded in"); 
  l11->AddEntry(hxjgNorm[kHIMC][4],"HYDJET 50-100%","p");
  l11->AddEntry(hxjgNorm[kHIMC][3],"HYDJET 30-50%","p");
  l11->AddEntry(hxjgNorm[kHIMC][2],"HYDJET 10-30%","p");
  l11->AddEntry(hxjgNorm[kHIMC][1],"HYDJET 0 -10%","p");
  l11->Draw();
  c2MCover->SaveAs("pdfFiles/xgj_MC_OnePannel.pdf");


  
  TCanvas* c3 = new TCanvas("c3","",500,500);
  TH1D* npartTempHist = new TH1D("meanR",";N_{part}; R",100,0,400);
  
  double npart4[8] = { 43.6661-10, 43.6661+10, 116.36-10, 116.36+10, 235.769-10, 235.769+10, 359.22-10,359.22+10};
  double npart4_2[4] = { 43.6661, 116.36, 235.769, 359.22};
  TGraphAsymmErrors* gR[5];

  for ( int iSpec = 0 ; iSpec<5 ; iSpec++) {
    
    if ( (iSpec != kHIDATA) && (iSpec != kHIMC) )       continue;
    gR[iSpec] = new TGraphAsymmErrors();
    gR[iSpec]->SetName(Form("gR_%d",iSpec));
    for ( int icent =4 ; icent>=1 ; icent--) {
      double theRerror;
      double theR = hxjg[iSpec][icent]->IntegralAndError(1, hxjg[iSpec][5-icent]->GetNbinsX(), theRerror, "width");
      gR[iSpec]->SetPoint(icent, npart4_2[4 - icent], theR );
      gR[iSpec]->SetPointError(icent, 0.001,0.001, theRerror, theRerror);    
    }
  }
  handsomeTH1(npartTempHist,1);
  npartTempHist->SetAxisRange(0.3,1.0,"Y");
  npartTempHist->DrawCopy();
  gR[kHIDATA]->SetMarkerColor(2);
  gR[kHIDATA]->SetLineColor(2);
  gR[kHIMC]->Draw("same p");
  //  gR[kHIDATA]->Draw("same p");

  c3->SaveAs("pdfFiles/r_MC_only.pdf");

  TCanvas* c3a = new TCanvas("c3a","",500,500);
  npartTempHist->DrawCopy();
  gR[kHIMC]->Draw("same p");
  gR[kHIDATA]->Draw("same p");
  TLegend *l13 = new TLegend(0.1794355,0.7055085,1,0.9152542,NULL,"brNDC");
  easyLeg(l13,"R_{J,#gamma}");
  l13->AddEntry(gR[kHIDATA],"PbPb data","pl");
  l13->AddEntry(gR[kHIMC],"PYTHIA+HYDJET","pl");
  l13->Draw();
  c3a->SaveAs("pdfFiles/r_MC_Data.pdf");


  TCanvas* c4 = new TCanvas("c4","",500,500);
  
  TGraphAsymmErrors* gX[5];

  for ( int iSpec = 0 ; iSpec<5 ; iSpec++) {
    
    if ( (iSpec != kHIDATA) && (iSpec != kHIMC) )       continue;
    gX[iSpec] = new TGraphAsymmErrors();
    gX[iSpec]->SetName(Form("gX_%d",iSpec));
    for ( int icent =4 ; icent>=1 ; icent--) {
      double theX      = hxjg[iSpec][icent]->GetMean();
      double theXerror = hxjg[iSpec][icent]->GetMeanError();
      gX[iSpec]->SetPoint(icent, npart4_2[4 - icent], theX );
      gX[iSpec]->SetPointError(icent, 0.001,0.001, theXerror, theXerror);    
    }
  }
  handsomeTH1(npartTempHist,1);
  npartTempHist->SetYTitle("<X_{J,#gamma}>");
  npartTempHist->SetAxisRange(0.6,1.1,"Y");
  npartTempHist->DrawCopy();
  gX[kHIDATA]->SetMarkerColor(2);
  gX[kHIDATA]->SetLineColor(2);
  gX[kHIMC]->Draw("same p");
  //  gX[kHIDATA]->Draw("same p");

  c4->SaveAs("pdfFiles/meanX_MC_only.pdf");


 TCanvas* c4a = new TCanvas("c4a","",500,500);
  
 npartTempHist->DrawCopy();
 gX[kHIMC]->Draw("same p");
 gX[kHIDATA]->Draw("same p");
 TLegend *l14 = new TLegend(0.1794355,0.7055085,1,0.9152542,NULL,"brNDC");
 easyLeg(l14,"<X_{J,#gamma}>");
 l14->AddEntry(gX[kHIDATA],"PbPb data","pl");
 l14->AddEntry(gX[kHIMC],"PYTHIA+HYDJET","pl");
 l14->Draw();
 c4a->SaveAs("pdfFiles/meanX_MC_Data.pdf");




    
}
void gammaTrkSingle(     GjSpectra* gSpec,  multiTreeUtil* tObj[3],   corrFunctionTrk* corr, 
			 float purity,       sampleType collision, 	     TString var,     
			 TCut cut, 		TString theWeight,	 TCut phoCandCut,   TCut phoDecayCut,
			 TH1D* hTemplate,  TString outfName)
{
  TH1::SetDefaultSumw2();
  
  TCanvas* c1 = new TCanvas(Form("canvas_%s",hTemplate->GetName()),"",800,650);
  makeMultiPanelCanvas(c1,2,2,0.0,0.0,0.2,0.15,0.02);
  c1->cd(1);
  corr->init(gSpec, collision, purity, hTemplate);
  cout << "Filling raw jets" << endl;
  tObj[kTrkRaw]->Draw2(corr->Func[kPhoCand][kTrkRaw],  var,  phoCandCut  && cut, theWeight);
  if ( tObj[kTrkBkg]!=0)   {
  cout << "Filling mixed jets" << endl;
    tObj[kTrkBkg]->Draw2(corr->Func[kPhoCand][kTrkBkg],  var,  phoCandCut  && cut, theWeight);
  }
  
  if ( (collision==kHIDATA) || (collision==kPPDATA) || (collision==kPADATA) ) {
    cout << "Filling decay photon-jet correlation" << endl;
    tObj[kTrkRaw]->Draw2(corr->Func[kPhoDecay][kTrkRaw], var, phoDecayCut && cut,  theWeight);
    if (tObj[kTrkBkg]!=0)   {
      cout << "Filling decay photon- mixed jet correlation" << endl;
      tObj[kTrkBkg]->Draw2(corr->Func[kPhoDecay][kTrkBkg], var, phoDecayCut && cut,  theWeight);
    }
  }
  TH1ScaleByWidth( corr->Func[kPhoCand][kTrkRaw]); 
  TH1ScaleByWidth( corr->Func[kPhoCand][kTrkBkg]);
  TH1ScaleByWidth( corr->Func[kPhoDecay][kTrkRaw]);
  TH1ScaleByWidth( corr->Func[kPhoDecay][kTrkBkg]);
  
  corr->calCorr();
  c1->cd(1); 
  handsomeTH1(corr->Func[kPhoCand][kTrkRaw],1);
  handsomeTH1(corr->Func[kPhoCand][kTrkBkg],1);
  handsomeTH1(corr->Func[kPhoCand][kTrkSig],2);
  corr->Func[kPhoCand][kTrkRaw]->Draw();
  corr->Func[kPhoCand][kTrkBkg]->Draw("same hist");
  corr->Func[kPhoCand][kTrkSig]->Draw("same");
  gPad->SetLogy();

  c1->cd(2); 
  handsomeTH1(corr->Func[kPhoDecay][kTrkRaw],1);
  handsomeTH1(corr->Func[kPhoDecay][kTrkBkg],1);
  handsomeTH1(corr->Func[kPhoDecay][kTrkSig],4);
  corr->Func[kPhoDecay][kTrkRaw]->Draw();
  corr->Func[kPhoDecay][kTrkBkg]->Draw("same hist");
  corr->Func[kPhoDecay][kTrkSig]->Draw("same");
  gPad->SetLogy();
  
  c1->cd(3);
  corr->Func[kPhoCand][kTrkSig]->Draw();
  corr->Func[kPhoDecay][kTrkSig]->Draw("same");

  c1->cd(4);
  handsomeTH1(corr->Func[kPhoSig][kTrkSig],1);
  corr->Func[kPhoSig][kTrkSig]->Draw();
  c1->SaveAs(Form("gifs/%s_%s.gif",outfName.Data(),c1->GetName()) );
  
  TFile outf = TFile(Form("ffFiles/%s",outfName.Data()),"update");
  corr->Func[kPhoCand][kTrkRaw]->Write();
  corr->Func[kPhoCand][kTrkBkg]->Write();
  corr->Func[kPhoCand][kTrkSig]->Write();
  corr->Func[kPhoDecay][kTrkRaw]->Write();
  corr->Func[kPhoDecay][kTrkBkg]->Write();
  corr->Func[kPhoDecay][kTrkSig]->Write();
  corr->Func[kPhoSig][kTrkRaw]->Write();
  corr->Func[kPhoSig][kTrkBkg]->Write();
  corr->Func[kPhoSig][kTrkSig]->Write();
  
  outf.Close();  
}
void cross_section_weight( bool isPP=1) 
{
  
  // Variables that will hold the tree information
  int             nPar;
  Float_t         et[500];   //[nPar]
  Float_t         eta[500];   //[nPar]
  Float_t         phi[500];   //[nPar]
  Int_t           id[500];   //[nPar]
  Int_t           momId[500];   //[nPar]
  Int_t           status[500];   //[nPar]
  Float_t         ptHat;
  TBranch        *b_nPar;   //!
  TBranch        *b_et;   //!
  TBranch        *b_eta;   //!
  TBranch        *b_phi;   //!
  TBranch        *b_id;   //!
  TBranch        *b_momId;   //!
  TBranch        *b_status;   //!
  TBranch        *b_ptHat;   //!  ///////////////////////

  TFile *f1[10];
  TTree* t1[10];
  TTree* genp[10];
  double n1[10];
  double n2[10][10];

  TH1::SetDefaultSumw2();
  TH1D* hPhoPt[10];  
  TH1D* hPtHat[10];  

  cout << endl << " Entries : " << endl;
  for ( int i=1 ; i <=3; i++) {
    
    if ( isPP ) { 
      if (i==1)  f1[i] = new TFile("/home/goyeonju/recent2013/jetAnalysis/files/forest/pp/pp2760_pythia_allQCDPhoton30_CMSSW538HIp2.root");
      else if (i==2) f1[i]=new TFile("/home/goyeonju/recent2013/jetAnalysis/files/forest/pp/pp2760_pythia_allQCDPhoton50_CMSSW538HIp2.root");
      else if ( i==3 )  f1[i] = new TFile("/home/goyeonju/recent2013/jetAnalysis/files/forest/pp/pp2760_pythia_allQCDPhoton80_CMSSW538HIp2.root");
    }
    else {
      if ( i==1 )  f1[i] = new TFile("/home/jazzitup/forestFiles/pbpb/pbpb/PbPb_pythiaHYDJET_forest_AllQCDPhotons30.root");
      else if ( i==2 )  f1[i] = new TFile("/home/jazzitup/forestFiles/pbpb/pbpb/PbPb_pythiaHYDJET_forest_AllQCDPhotons50.root");
      else if ( i==3 )  f1[i] = new TFile("/home/jazzitup/forestFiles/pbpb/pbpb/PbPb_pythiaHYDJET_forest_AllQCDPhotons80.root");
    }


    hPtHat[i] = new TH1D(Form("ptHat_%d",i),";pt Hat;",400,0,400);
    hPhoPt[i] = new TH1D(Form("h_%d",i),";photon pT;",400,0,400);


    t1[i] = (TTree*)f1[i]->Get("multiPhotonAnalyzer/photon");
    t1[i]->SetBranchAddress("ptHat", &ptHat, &b_ptHat);
    //    n1[i] = t1[i]->GetEntries();
    genp[i] = (TTree*)f1[i]->Get("genpana/photon");
    genp[i]->SetBranchAddress("nPar", &nPar, &b_nPar);
    genp[i]->SetBranchAddress("et", et, &b_et);
    genp[i]->SetBranchAddress("eta", eta, &b_eta);
    genp[i]->SetBranchAddress("phi", phi, &b_phi);
    genp[i]->SetBranchAddress("id", id, &b_id);
    genp[i]->SetBranchAddress("momId", momId, &b_momId);
    genp[i]->SetBranchAddress("status", status, &b_status);
    
    n1[i]=0;
    for ( int j=1 ; j<=3; j++) { 
      n2[i][j] = 0;
    }
    // Loop! 
    for (Long64_t jentry=0; jentry< genp[i]->GetEntries() ; jentry++) {
      genp[i]->GetEntry(jentry);
      t1[i]->GetEntry(jentry);
      
      // find the leading gen photon 
      float maxEt = 0;
      for ( int jpar = 0 ; jpar< nPar ; jpar++) {
	if (  (et[jpar]>maxEt) && (fabs(eta[jpar])<1.44) && (fabs(momId[jpar])<=22) && (status[jpar]==1) && ( id[jpar]==22))
	  maxEt = et[jpar] ;   // "abs(eta)<3 && abs(momId)<=22 && status==1 && id==22"
      }
      if ( maxEt <35 ) 
	continue;
      
      hPtHat[i]->Fill (ptHat);
      hPhoPt[i]->Fill ( maxEt);

      if ( ptHat <50 ) 
	n2[i][1]++; 
      else if ( ptHat <80 )
	n2[i][2]++;
      else
	n2[i][3]++;
      
      n1[i]++;
      
   }
    
    for ( int j=1 ; j<=3; j++) {
      int pt1(0), pt2(0);
      if ( j==1 )  pt1 = 30;   if ( j==2 ) pt1 = 50 ; if ( j==3) pt1=80;
      if ( j==1 )  pt2 = 50;   if ( j==2 ) pt2 = 80 ; if ( j==3) pt2=10000;
      cout << Form("file of %dth,   pt hat : %d - %d : %d", i,  pt1, pt2, (int)n2[i][j]) << endl;
    }
    
  }
  cout << " ===============================" << endl;
  
  double n3[10];
  for ( int j=1 ; j<=3; j++) {
    n3[j] = n2[1][j] + n2[2][j] + n2[3][j];
    int pt1(0), pt2(0);
    if ( j==1 ) pt1 = 30 ;     if ( j==2) pt1 =50 ;     if ( j==3) pt1 =80    ;
    if ( j==1 ) pt2 = 50 ;     if ( j==2) pt2 =80 ;     if ( j==3) pt2 =10000 ;
    cout << Form("Sum :  pt hat : %d - %d : %d",  pt1, pt2, (int)(n3[j]) ) << endl;
  }
  cout << "Before rearrangement : "<< endl;
  for ( int j=1 ; j<=3; j++) {
    float pt1;
    if ( j==1 ) pt1 = 30 ;     if ( j==2) pt1 =50 ;     if ( j==3) pt1 =80    ;
    cout << "  " << pt1 << "GeV : "<< n1[j] << endl;
  }
  
  for ( int i=1 ; i <=3; i++) {	
    hPtHat[i]->Scale(1./n1[i]);
    handsomeTH1(hPtHat[i],i);
    hPhoPt[i]->Scale(1./n1[i]);
    handsomeTH1(hPhoPt[i],i);
  }




  TCanvas *c1 = new TCanvas("c1","",1000,1000);
  c1->Divide(2,2);
  c1->cd(1);
  for ( int i=1 ; i <=3; i++) {
    if ( i==1){
      hPtHat[i]->SetAxisRange(0.00001,0.5,"Y");
      hPtHat[i]->DrawCopy();
    }
    else hPtHat[i]->DrawCopy("same");
  }
  gPad->SetLogy();

  c1->cd(3);
  for ( int i=1 ; i <=3; i++) {
    if ( i==1){
      hPhoPt[i]->SetAxisRange(0.00001,0.5,"Y");
      hPhoPt[i]->DrawCopy();
    }
    else hPhoPt[i]->DrawCopy("same");
  }
  gPad->SetLogy();
  
  double w[10];  
  w[1] = 1;
  w[2] = hPhoPt[1]->Integral(80,400) / hPhoPt[2]->Integral(80,400) ; 
  w[3] = w[2] *  hPhoPt[2]-> Integral(140,400) / hPhoPt[3]->Integral(140,400) ; 
  
  cout << " Differential Cross-section : " << endl;
  cout << " 30GeV-50 : " << n2[1][1] <<endl;
  cout << " 50GeV-80 : " << n2[1][2] <<endl;
  cout << " 80GeV-   : " << n2[1][3] <<endl;
  cout << " ===============================" << endl;
  cout << " ========== Weights : ==========" << endl;
  cout << " 30 - 50GeV : " << n2[1][1] << "/" << n3[1] << "." << endl;
  cout << " 50 - 80GeV : " << n2[1][2] << "/" << n3[2] << "." << endl;
  cout << " 80GeV : " << n2[1][3] << "/" << n3[3] << "." << endl;
  //  cout << " 120 - 170GeV : " << w[4]-w[5] << "/" << n3[4] << "." << endl;
  //  cout << " 170GeV : " << w[5] << "/" << n3[5] << "." << endl;

  
  c1->cd(2);
  for ( int i=1 ; i <=3; i++) {
    hPtHat[i]->Scale(w[i]);
    if ( i==1){
      hPtHat[i]->SetAxisRange(0.00001,0.5,"Y");
      hPtHat[i]->DrawCopy();
    }
    else hPtHat[i]->DrawCopy("same");
  }
  gPad->SetLogy();

  c1->cd(4);
  for ( int i=1 ; i <=3; i++) {
    hPhoPt[i]->Scale(w[i]);
    if ( i==1){
      hPhoPt[i]->SetAxisRange(0.00001,0.5,"Y");
      hPhoPt[i]->DrawCopy();
    }
    else hPhoPt[i]->DrawCopy("same");
  }
  gPad->SetLogy();

  

}
fitResult getPurity(TString fname, sampleType collision, TCut evtSeltCut, TCut sbEvtCut, TString canvasName, float photonPtThr, float photonPtThrUp) {
  double purity(0);
  
  multiTreeUtil* tgj = new multiTreeUtil();
  multiTreeUtil* tgjMC = new multiTreeUtil();
  cout <<" 1 " << endl;
  tgj->addFile(fname,  "tgj",  "",  1);
  cout <<" 2 " << endl;
  tgj->AddFriend("yJet");
  if   (collision==kPPDATA) { 
    tgjMC->addFile(fnamePPMC_AllQcdPho30to50,    "tgj", "", wPPMC_AllQcdPho30to50 ); 
    tgjMC->addFile(fnamePPMC_AllQcdPho50to80,    "tgj", "", wPPMC_AllQcdPho50to80 ); 
    tgjMC->addFile(fnamePPMC_AllQcdPho80to120,   "tgj", "", wPPMC_AllQcdPho80to120); 
    tgjMC->addFile(fnamePPMC_AllQcdPho120to9999, "tgj", "", wPPMC_AllQcdPho120to9999); 
  }
  else if (collision==kPADATA)     {
    tgjMC->addFile(fnamePAMC_AllQcdPho30to50,     "tgj","", wPAMC_AllQcdPho30to50);
    tgjMC->addFile(fnamePAMC_AllQcdPho50to80,     "tgj","", wPAMC_AllQcdPho50to80);
    tgjMC->addFile(fnamePAMC_AllQcdPho80to120,    "tgj","", wPAMC_AllQcdPho80to120);
    tgjMC->addFile(fnamePAMC_AllQcdPho120to9999,  "tgj","", wPAMC_AllQcdPho120to9999);
  }
  else if (collision==kHIDATA)  {
    tgjMC->addFile(fnameHIMC_AllQcdPho30to50,     "tgj", "",wHIMC_AllQcdPho30to50);
    tgjMC->addFile(fnameHIMC_AllQcdPho50to80,     "tgj", "",wHIMC_AllQcdPho50to80);
    tgjMC->addFile(fnameHIMC_AllQcdPho80to9999,   "tgj", "",wHIMC_AllQcdPho80to9999);
  }   
  else { 
    cout << " Error: getPurity.  check the type of the collision!  " << endl;
    fitResult fitr0;
    return fitr0;
  }
  
  TH1D* hCand = new TH1D("cand","",25,0,0.025);
  TH1D* hBkg = (TH1D*)hCand->Clone("bkg");  TH1D* hSig = (TH1D*)hCand->Clone("sig");
  
  tgj->Draw2(   hCand, "sigmaIetaIeta", evtSeltCut , "");
  tgj->Draw2(   hBkg, "sigmaIetaIeta", sbEvtCut , "");
  tgjMC->Draw2( hSig, "sigmaIetaIeta", evtSeltCut && "genIso<5 && abs(genMomId)<=22", "");
  handsomeTH1(hCand,1);
  handsomeTH1(hSig,2);
  handsomeTH1(hBkg,4);
  

  TCanvas* cPurity = new TCanvas("cpurity","",500,500);
  fitResult  fitr = doFit ( hSig, hBkg, hCand, 0.005, 0.025);
  drawText(Form("Purity : %.2f", (float)fitr.purity010), 0.5680963,0.429118);
  drawText(Form("p_{T}^{#gamma}: %d-%d GeV", (int)photonPtThr, (int)photonPtThrUp), 0.568,0.529118);
  cPurity->SaveAs( Form("%s.pdf",canvasName.Data() ) );
  gPad->SetLogy();
  cPurity->SaveAs( Form("%s_logScale.pdf",canvasName.Data() ) );
   
  TCanvas* c1 = new TCanvas("c1","",100,100);
  
  
  delete tgj;
  delete tgjMC;
  delete hSig;
  delete hBkg;
  delete hCand;
  
  return fitr;
  
  
}
Esempio n. 24
0
void drawPtDependencePA(TString dirName, int prodDate, int jetPtCut, TString fNameSuffix, TString outNameSuffix){
  bool saveFigures=true;

  const int nPtBin = 4;
  double ptBin[nPtBin+1] = {40, 50,60,80,9999};
  double ptBinPaDraw[nPtBin+1] = { 40.5 ,49.5, 58.5,  76.5,  123. } ;
  // double AvePtBin[nPtBin+1] = { 45, 54.1479, 67.4204, 99.6956, 9999};

  const int nCentBinHI = 2;
  const int centBinHI[nCentBinHI +1] = {-1, 10030, 13099};

  TH1D* hxjg[7][10][6]; // [Collision][centrality][pt]
  TH1D* hJetPt[7][10][6]; // [Collision][centrality][pt]
  TH1D* hJetPtIaaBin[7][10][6]; // [Collision][centrality][pt]
  TH1D* hDphi[7][10][6]; // [Collision][centrality][pt]
  TH1D* meanXjg[7][10];      // [Collision][centrality]
  TH1D* meanJetPt[7][10];      // [Collisi on][centrality]

  TH1D* rjg[7][5];     //  [Collision][centrality]
  for (int icoll=0 ; icoll<6  ; icoll++) {
      for (int icent=1 ; icent<= 10 ; icent++) {
          meanXjg[icoll][icent] = new TH1D( Form("meanXjg_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); <X_{J#gamma}>",nPtBin,ptBinPaDraw);
          meanJetPt[icoll][icent] = new TH1D( Form("meanJetPt_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); <p_{T}^{Jet}>",nPtBin,ptBinPaDraw);
          rjg[icoll][icent] = new TH1D( Form("rjg_icoll%d_icent%d",icoll,icent), ";p_{T}^{#gamma} (GeV); R_{J#gamma}",nPtBin,ptBinPaDraw);

          for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
              hxjg[icoll][icent][ipt] = NULL;
              hJetPt[icoll][icent][ipt] = NULL;
              hJetPtIaaBin[icoll][icent][ipt] = NULL;
              hDphi[icoll][icent][ipt] = NULL;
          }

      }
  }

  TFile* histFile[7][6];  // [Collision][pt]
  for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
      for (int icoll=0 ; icoll<6 ; icoll++) {
          TString sampleName = getSampleName( icoll ) ;
          char* fname;
          if (fNameSuffix.EqualTo(""))  {  // if no explicit suffix for the input file name is specified
              fname =  Form("ffFiles/%s/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr%d_%d.root",dirName.Data(), sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt], (int)jetPtCut, prodDate);
          }
          else {
              fname =  Form("ffFiles/%s/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr%d_%d_%s.root",dirName.Data(), sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt], (int)jetPtCut, prodDate, fNameSuffix.Data());
          }

          histFile[icoll][ipt] = new TFile(fname) ;
          cout << " Reading file : " << fname << endl;

          if ( histFile[icoll][ipt]->IsZombie()  == false ) {
              cout << " Success." << endl;
              if ( (icoll == kPPDATA) || (icoll == kPPMC) )   {  //  PP
                  int icent = 7 ;
                  hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("xjg_icent%d_final", icent) << endl;
                  hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
                  hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", icent) << endl;
                  hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetDphi_icent%d_final", icent) << endl;
                  //hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", icent)) ;
                  //cout << " Getting histogram : " << Form("etaJg_icent%d_final", icent) << endl;

              }

              if ( (icoll == kPADATA) || (icoll == kPAMC) )   {  //  PA
                  int icent = 1 ;
                  hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("xjg_icent%d_final", icent) << endl;
                  hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetPt_icent%d_final", icent) << endl;
                  hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", icent ) ) ;
                  cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", icent ) << endl;

                  hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", icent)) ;
                  cout << " Getting histogram : " << Form("jetDphi_icent%d_final", icent) << endl;
                  //hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", icent)) ;
                  //cout << " Getting histogram : " << Form("etaJg_icent%d_final", icent) << endl;

              }

              if ( ( icoll == kHIDATA) ||  (icoll == kHIMC) ) { // PbPb
                  for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
                      hxjg[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("xjg_icent%d_final", centBinHI[icent] )) ;
                      cout << " Getting histogram : " << Form("xjg_icent%d_final", centBinHI[icent] ) << endl;
                      hJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPt_icent%d_final", centBinHI[icent] ) );
                      cout << " Getting histogram : " << Form("jetPt_icent%d_final", centBinHI[icent] ) << endl;
                      hJetPtIaaBin[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) );
                      cout << " Getting histogram : " << Form("jetPtForIaa_icent%d_final", centBinHI[icent] ) << endl;
                      hDphi[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("jetDphi_icent%d_final", centBinHI[icent] ) ) ;
                      cout << " Getting histogram : " << Form("jetDphi_icent%d_final", centBinHI[icent])<< endl;
                      //hEta[icoll][icent][ipt]  = (TH1D*)histFile[icoll][ipt]->Get(Form("etaJg_icent%d_final", centBinHI[icent] ) ) ;
                      //cout << " Getting histogram : " << Form("etaJg_icent%d_final", centBinHI[icent])<< endl;
                  }
              }
          }
          else
              cout << " no such file " << endl;
      }
  }

  for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
      for (int icoll=0 ; icoll<6 ; icoll++) {
          for (int icent=1 ; icent<= 10 ; icent++ ) {

              if ( hxjg[icoll][icent][ipt] == NULL )  continue;   // emtpy histogram

              double rVal, rErr;
              rVal = hxjg[icoll][icent][ipt]->IntegralAndError(1, hxjg[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
              rjg[icoll][icent]->SetBinContent( ipt, rVal );
              rjg[icoll][icent]->SetBinError  ( ipt, rErr );

              meanXjg[icoll][icent]->SetBinContent( ipt, hxjg[icoll][icent][ipt]->GetMean() );
              meanXjg[icoll][icent]->SetBinError  ( ipt, hxjg[icoll][icent][ipt]->GetMeanError() );

              meanJetPt[icoll][icent]->SetBinContent( ipt, hJetPt[icoll][icent][ipt]->GetMean() );
              meanJetPt[icoll][icent]->SetBinError  ( ipt, hJetPt[icoll][icent][ipt]->GetMeanError() );
          }
      }
  }

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

      c1->cd(ipt);

      handsomeTH1(hDphi[kPAMC][1][ipt], 1);
      hDphi[kPAMC][1][ipt]->SetXTitle("#Delta#phi_{J#gamma}");
      hDphi[kPAMC][1][ipt]->SetYTitle("Normalized entries");
      hDphi[kPAMC][1][ipt]->SetMarkerStyle(24);
      hDphi[kPAMC][1][ipt]->Scale(1./hDphi[kPAMC][1][ipt]->Integral("width"));
      hDphi[kPAMC][1][ipt]->SetAxisRange(0,3.141592,"X");
      hDphi[kPAMC][1][ipt]->SetAxisRange(0.01,30,"Y");
      hDphi[kPAMC][1][ipt]->Draw();

      handsomeTH1(hDphi[kPADATA][1][ipt], kRed);
      hDphi[kPADATA][1][ipt]->Scale(1./hDphi[kPADATA][1][ipt]->Integral("width"));
      hDphi[kPADATA][1][ipt]->Draw("same");

      gPad->SetLogy();

      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

  }
  c1->cd(1);

  TLegend *l1 = new TLegend(0.2199474,0.5971384,0.7283974,0.8119819,NULL,"brNDC");
  easyLeg(l1,"5.02TeV");
  l1->AddEntry(hDphi[kPAMC][1][1],"pA pythia+HIJING ","p");
  l1->AddEntry(hDphi[kPADATA][1][1],"pA Data","p");
  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c1->SaveAs("figures/pT_dependence_dphi_pA_figure1.pdf");
          c1->SaveAs("figures/pT_dependence_dphi_pA_figure1.gif");
      }
      else {
          c1->SaveAs(Form("figures/pT_dependence_dphi_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c1->SaveAs(Form("figures/pT_dependence_dphi_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }


  TH1D* hTempPt = new TH1D("hTemp",";p_{T}^{#gamma} (GeV);",200,10,300);

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

      c2->cd(ipt);

      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.08,"Y");
      handsomeTH1(hTempPt,0);
      hTempPt->DrawCopy();

      //	hJetPt[kPAMC][1][ipt]->Scale(1./rjg[kPAMC][1]->GetBinContent(ipt)); // rjg normalization

      handsomeTH1(hJetPt[kPAMC][1][ipt], 1);
      hJetPt[kPAMC][1][ipt]->SetMarkerStyle(24);
      hJetPt[kPAMC][1][ipt]->Draw("same");

      handsomeTH1(hJetPt[kPADATA][1][ipt],kRed);
      //	hJetPt[kPADATA][1][ipt]->Scale(1./rjg[kPADATA][1]->GetBinContent(ipt));

      hJetPt[kPADATA][1][ipt]->Draw("same");


      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

      onSun(30,0,200,0);
  }
  c2->cd(1);
  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c2->SaveAs("figures/pT_dependence_jetPt_pA_figure1.pdf");
          c2->SaveAs("figures/pT_dependence_jetPt_pA_figure1.gif");
      }
      else {
          c2->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c2->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }

  TLegend *l2 = new TLegend(0.2116935,0.7012712,0.6149194,0.904661,NULL,"brNDC");
  easyLeg(l2,"5.02TeV");

  l2->AddEntry(hDphi[kPAMC][1][1],"pPb pythia+HIJING","p");
  l2->AddEntry(hDphi[kPADATA][1][1],"pPb Data","p");


  TCanvas* c21 = new TCanvas("c21","",500,500);
  handsomeTH1(meanJetPt[kPAMC][1], 1);
  meanJetPt[kPAMC][1]->SetYTitle("<p_{T}^{Jet}>  (>30GeV)");
  meanJetPt[kPAMC][1]->SetMarkerStyle(24);
  //  meanJetPt[kPAMC][1]->SetAxisRange(-2,2,"X");
  meanJetPt[kPAMC][1]->SetAxisRange(40,115,"Y");
  meanJetPt[kPAMC][1]->Draw();

  handsomeTH1(meanJetPt[kPADATA][1],kRed);
  meanJetPt[kPADATA][1]->Draw("same");

  l1 ->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c21->SaveAs("figures/pT_dependence_jetPt_pA_figure2.pdf");
          c21->SaveAs("figures/pT_dependence_jetPt_pA_figure2.gif");
      }
      else {
          c21->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure2_%s.pdf", outNameSuffix.Data()));
          c21->SaveAs(Form("figures/pT_dependence_jetPt_pA_figure2_%s.gif", outNameSuffix.Data()));
      }
  }


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

      c3->cd(ipt);

      handsomeTH1(hxjg[kPAMC][1][ipt], 1);
      hxjg[kPAMC][1][ipt]->SetXTitle("x_{J#gamma}");
      hxjg[kPAMC][1][ipt]->SetYTitle("#frac{dN}{dp_{T}} #frac{1}{N}");
      hxjg[kPAMC][1][ipt]->SetMarkerStyle(24);

      //	hxjg[kPAMC][1][ipt]->Scale(1./rjg[kPAMC][1]->GetBinContent(ipt)); // rjg normalization


      hxjg[kPAMC][1][ipt]->SetAxisRange(0,2,"X");
      hxjg[kPAMC][1][ipt]->Draw();

      handsomeTH1(hxjg[kPADATA][1][ipt],kRed);
      //	hxjg[kPADATA][1][ipt]->Scale(1./rjg[kPADATA][1]->GetBinContent(ipt)); // rjg normalization


      hxjg[kPADATA][1][ipt]->Draw("same");

      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


      onSun(30,0,200,0);
  }
  c3->cd(1);
  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c3->SaveAs("figures/pT_dependence_xjg_pA_figure1.pdf");
          c3->SaveAs("figures/pT_dependence_xjg_pA_figure1.gif");
      }
      else {
          c3->SaveAs(Form("figures/pT_dependence_xjg_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c3->SaveAs(Form("figures/pT_dependence_xjg_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }

  TCanvas* c31 = new TCanvas("c31","",500,500);
  handsomeTH1(meanXjg[kPAMC][1], 1);
  meanXjg[kPAMC][1]->SetYTitle("<x_{J#gamma}>  (>30GeV)");
  meanXjg[kPAMC][1]->SetMarkerStyle(24);
  //  meanXjg[kPAMC][1]->SetAxisRange(-2,2,"X");
  meanXjg[kPAMC][1]->SetAxisRange(0.6,1.2,"Y");
  meanXjg[kPAMC][1]->Draw();

  handsomeTH1(meanXjg[kPADATA][1],kRed);
  meanXjg[kPADATA][1]->Draw("same");

  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c31->SaveAs("figures/pT_dependence_xjg_pA_figure2.pdf");
          c31->SaveAs("figures/pT_dependence_xjg_pA_figure2.gif");
      }
      else {
          c31->SaveAs(Form("figures/pT_dependence_xjg_pA_figure2_%s.pdf", outNameSuffix.Data()));
          c31->SaveAs(Form("figures/pT_dependence_xjg_pA_figure2_%s.gif", outNameSuffix.Data()));
      }
  }

  TCanvas* c_rjg = new TCanvas("c_rjg","",500,500);
  handsomeTH1(rjg[kPAMC][1], 1);
  rjg[kPAMC][1]->SetYTitle("R_{J#gamma}");
  rjg[kPAMC][1]->SetMarkerStyle(24);
  //  rjg[kPAMC][1]->SetAxisRange(-2,2,"X");
  rjg[kPAMC][1]->SetAxisRange(0.0,1.1,"Y");
  rjg[kPAMC][1]->Draw();

  handsomeTH1(rjg[kPADATA][1],kRed);
  rjg[kPADATA][1]->Draw("same");


  l1->Draw();

  if (saveFigures) {
      if(outNameSuffix.EqualTo("")){
          c_rjg->SaveAs("figures/pT_dependence_rjg_pA_figure1.pdf");
          c_rjg->SaveAs("figures/pT_dependence_rjg_pA_figure1.gif");
      }
      else {
          c_rjg->SaveAs(Form("figures/pT_dependence_rjg_pA_figure1_%s.pdf", outNameSuffix.Data()));
          c_rjg->SaveAs(Form("figures/pT_dependence_rjg_pA_figure1_%s.gif", outNameSuffix.Data()));
      }
  }

  // Save the final root histogram files
  TFile* fResults;
  if(outNameSuffix.EqualTo("")){
      fResults =  new TFile("resultHistograms.root", "update");
  }
  else   {
      fResults =  new TFile(Form("resultHistograms_%s.root", outNameSuffix.Data()), "update");
  }
  //    TFile * fResults =  new TFile("resultHistograms_ppb_photonEnergy_ScaledBy0.015.root","update");

  meanJetPt[kPADATA][1]->SetName(Form("meanJetPt_ppb"));
  meanJetPt[kPADATA][1]->Write();

  meanXjg[kPADATA][1]->SetName(Form("meanXjg_ppb"));
  meanXjg[kPADATA][1]->Write();

  rjg[kPADATA][1]->SetName(Form("meanRjg_ppb"));
  rjg[kPADATA][1]->Write();

  for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {
      hJetPt[kPADATA][1][ipt]->SetName(Form("dNdJetPt_ppb_ptBin%d",ipt));
      hJetPt[kPADATA][1][ipt]->Write();

      hJetPtIaaBin[kPADATA][1][ipt]->SetName(Form("dNdJetPt_IaaBin_ppb_ptBin%d",ipt));
      hJetPtIaaBin[kPADATA][1][ipt]->Write();

      hxjg[kPADATA][1][ipt]->SetName(Form("dNdXjg_ppb_ptBin%d",ipt));
      hxjg[kPADATA][1][ipt]->Write();

      hDphi[kPADATA][1][ipt]->SetName(Form("dNdphi_ppb_ptBin%d",ipt));
      hDphi[kPADATA][1][ipt]->Write();
  }

  fResults->Close();
}
Esempio n. 25
0
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");
  
  
  
}
Esempio n. 26
0
void drawPhotonSpec(){
  


  TH1::SetDefaultSumw2();
  
  TFile* f1 = new TFile("/mnt/hadoop/cms/store/user/luck/2014-photon-forests/pPb_DATA_photon30trig_localJEC_v1.root");
  TTree* photon = (TTree*)f1->Get("multiPhotonAnalyzer/photon");
  TTree* hlt    = (TTree*)f1->Get("hltanalysis/HltTree");
  hlt->SetName("hlt");
  photon->AddFriend(hlt);
  
  TH1D* h1 = new TH1D("h1",";p_{T} of photon;Entries (Arb. Norm.)",200,0,200);
  // TCut ccut = "abs(eta)<1.44 && hlt.HLT_PAPhoton20_NoCaloIdVL_v1 && hadronicOverEm<0.1";
  TCut ccut = "abs(eta)<1.44 && hadronicOverEm<0.1";
  photon->Draw("pt>>h1",ccut);
  TH1D* h2 = (TH1D*)h1->Clone("h2");
  photon->Draw("pt>>h2",ccut && "!isEle");

  TCut isocut = "sigmaIetaIeta<0.011 && ecalRecHitSumEtConeDR04<4.2 && hcalTowerSumEtConeDR04< 2.2 && trkSumPtHollowConeDR04 <2";

  TH1D* h3 = (TH1D*)h1->Clone("h3");
  photon->Draw("pt>>h3",ccut && isocut);
  
  TH1D* h4 = (TH1D*)h1->Clone("h4");
  photon->Draw("pt>>h4",ccut && isocut && "!isEle");

  
  handsomeTH1(h1,1);
  handsomeTH1(h2,2);
  handsomeTH1(h3,1);
  handsomeTH1(h4,2);
  

  TCanvas* c1 = new TCanvas("c1","",1000,500);
  c1->Divide(2,1);
  c1->cd(1);
  //h1->SetAxisRange(0.5, 80000,"Y");
  h1->Draw("hist" );
  h2->Draw("same hist");

  TLegend *l1 = new TLegend(0.6365615,0.6445304,0.9577623,0.846736,NULL,"brNDC");
  easyLeg(l1,"5.02TeV pA Data");
  l1->SetTextFont(43);
  l1->SetTextSize(16);
  l1->Draw();
  TLegend *l2 = new TLegend(0.6365615,0.4445304,0.9577623,0.646736,NULL,"brNDC");
  easyLeg(l2,"Barrel photons H/E<0.1");
  l2->SetTextFont(43);
  l2->SetTextSize(16);
  l2->AddEntry(h1, "All");
  l2->AddEntry(h2, "Electrons excluded");
  l2->Draw();

  
  c1->cd(2);
  //h3->SetAxisRange(0.5, 2500,"Y");
  h3->Draw("hist");
  h4->Draw("same hist");
  TLegend *l3 = new TLegend(0.6365615,0.4445304,0.9577623,0.646736,NULL,"brNDC");
  easyLeg(l3,"Isolated photons");
  l3->SetTextFont(43);
  l3->SetTextSize(16);
  l3->AddEntry(h3, "All");
  l3->AddEntry(h4, "Electrons excluded");
  l3->Draw();

  
}
Esempio n. 27
0
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();
}
void drawInclJetFragSingle( TH1D* htrkPt[3][5],
			  int dataset,
			  int icent,
			  int irj,
			  int fragMode,
			  float trackPtMin,
			  float trackPtMax,
			  int doClosure,
			  bool usingPara,
        int rewtJet
        ) {
  /////////////////////////////////////////////////////////////////
  // This function is given the booked histograms
  // and does the real work of filling the histograms
  // for each dataset and each analysis setup
  /////////////////////////////////////////////////////////////////
  TString datasetName;
  if (dataset == kHIDATA)       datasetName = "hidata";
  else if (dataset == kHIMC)    datasetName = "himc";
  else if (dataset == kPPDATA)  datasetName = "ppdata";
  else if (dataset == kPPMC)  datasetName = "ppmc";
  TString attPara = ( (usingPara == true) ? "Para" : "" ) ;
  
  TString suffix = Form("%s_icent%d_irj%d_fragMode%d_closure%d_jtrewt%d_%s",datasetName.Data(),icent,irj,fragMode,doClosure,rewtJet,tag.Data());
  
  TString clsText = "evtMixing";
  TString clsText_ = "event mixing method";
  if ( doClosure >= 100 ) {
    clsText = "etaRefl";
    clsText_ = "#eta reflection method";
  }

  ///////////////////////////////////////////////////////
  // Book histograms for Intermediate checks
  ///////////////////////////////////////////////////////
  TH1D* hjetPt = new TH1D(Form("hjetPt_%s",suffix.Data()),";Jet p_{T} (GeV/c);Entries;",50,0,500);

  ///////////////////////////////////////////////////////
  // Setup cuts
  ///////////////////////////////////////////////////////
  float finalEtaCut = 2.0;
  // float finalEtaCut = 1.2;
  float finalJetPtMin = 100;
  float finalJetPtMax = 300;
  TCut jetSelCut = Form("finalJetPt>=%.0f&&finalJetPt<%.0f",finalJetPtMin,finalJetPtMax);
  // TCut jetSelCut = Form("finalJetPt>=%.0f&&finalJetPt<%.0f&&jetPtGM>100",finalJetPtMin,finalJetPtMax);
  // TCut jetSelCut = Form("jetPtGM>=%.0f&&jetPtGM<%.0f",finalJetPtMin,finalJetPtMax);
  // jetSelCut=jetSelCut&&"abs(vz)<4";
  
  TCut centCut = "1==1";
  if ( (icent >= 1) && (icent<=4) )
    centCut = Form("cBin>=%d && cBin<%d", (int)centBin1[icent-1], (int)centBin1[icent]);

  ////////////////////////////////////////////////////////  
  // Jet Selection
  ////////////////////////////////////////////////////////  
  // inclusive /////////
  TString jet1Cut = Form("abs(jetEta)<%.2f",finalEtaCut);
  // if (doClosure>=100&&doClosure!=101) {
  if (doClosure>=100) {
    jet1Cut = Form("%s && abs(jetEta)>0.3",jet1Cut.Data());
  }

  ////////////////////////////////////////////////////////  
  // Weights
  ////////////////////////////////////////////////////////  
  float jetDrCut = 0.3;
  TString jetRewt= "1";
  if ( rewtJet==1 ) {
    jetRewt = Form("rewtPt");
    // jetRewt = Form("(1+0.5*(rewtPt-1))");
  }
  
  ///////////////////////////////////////////////////////
  // Input trees
  ///////////////////////////////////////////////////////
  multiTreeUtil* dj  = new multiTreeUtil();
  if ( dataset == kHIDATA) {
    // dj->addFile("../ntout/jskim_hltjet80-pt90-v20_akPu3PF_Jan16_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root",
    dj->addFile("../ntout/jskim_hltjet80-pt90-v20_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0_addedReweight.root","tdj", jetSelCut && centCut,1);
    // dj->addFile("../ntout/jskim_hltjet80-pt90-v20_akPu3PF_Jan26_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm3bin0_akPu3PF_gj0.root","tdj", jetSelCut && centCut,1);
  } else if ( dataset == kHIMC) {
    // pythia+hydjet
    // dj->addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root","tdj", jetSelCut && centCut && "pthat>=80&&pthat<9999", 9.913e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj50_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root","tdj", jetSelCut && centCut && "pthat>=50&&pthat<80", 1.021e-3*1.e9);
    // dj->addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=80&&pthat<100",9.913e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj100_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=100&&pthat<120",3.069e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj120_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=120&&pthat<9999",1.128e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=80&&pthat<100",9.913e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj100_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=100&&pthat<9999",3.069e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root","tdj", jetSelCut && centCut && "pthat>=80&&pthat<100", 9.913e-5*1.e9);
    // dj->addFile("../ntout/jskim_hydj80_akPu3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root","tdj", jetSelCut && centCut && "pthat>=80&&pthat<9999", 3.069e-5*1.e9);
    // pyquen+hydjet
    dj->addFile("../ntout/jskim_hydj80quenwide_akPu3PF_Jan26_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=80&&pthat<100",9.913e-5*1.e9);
    dj->addFile("../ntout/jskim_hydj100quenwide_akPu3PF_Jan26_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm1bin0_akPu3PF_gj0.root", "tdj", jetSelCut && centCut && "pthat>=100&&pthat<9999",3.069e-5*1.e9);
  } else if ( dataset == kPPDATA) {
    // dj->addFile(Form("../ntout/jskim_pp-full_ak3PF_Dec5newsmgt60steps_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0.root",icent),
    // dj->addFile(Form("../ntout/jskim_pp-full_ak3PF_Jan16_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0_addedReweight.root",icent),
    // dj->addFile(Form("../ntout/jskim_pp-full_ak3PF_Jan16_4bin_sm18_seed2_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0.root",icent),
    dj->addFile(Form("../ntout/jskim_pp-full_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0_addedReweight.root",icent),
    // dj->addFile(Form("../ntout/jskim_pp-full_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0_addedFitRewt.root",icent),
    "tdj", jetSelCut, 1); // no centrality cut
  } else if ( dataset == kPPMC) {
    // dj->addFile(Form("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm0bin0_ak3PF_gj0.root"),"tdj", jetSelCut && "pthat>=80&&pthat<9999", 9.913e-5*1.e9); // no centrality cut
    // dj->addFile(Form("../ntout/jskim_dj50_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm0bin0_ak3PF_gj0.root"),"tdj", jetSelCut && "pthat>=50&&pthat<80", 1.021e-3*1.e9); // no centrality cut
    dj->addFile(Form("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0.root",icent),"tdj", jetSelCut && "pthat>=80&&pthat<120", 9.913e-5*1.e9); // no centrality cut
    dj->addFile(Form("../ntout/jskim_dj120_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0.root",icent),"tdj", jetSelCut && "pthat>=120&&pthat<9999", 1.128e-5*1.e9); // no centrality cut
    // dj->addFile(Form("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0.root",icent),"tdj", jetSelCut, 1); // no centrality cut
    // dj->addFile(Form("../ntout/jskim_dj80_ak3PF_Jan17_4bin_sm18_jetPt_60_jetEtaCut_2.00_noPbin_sm2bin%d_ak3PF_gj0_addedReweight.root",icent),"tdj", jetSelCut, 1); // no centrality cut
  }
  // pthat scaling normalization
  if ( dataset == kHIMC || dataset == kPPMC) dj->NormalizeScales(2,"","hEvtCentNoSkim");
  
  // Friend Trees
  dj->AddFriend("yTrk=yongsunTrack");
//   dj->AddFriend("mTrk");
  if ( (doClosure > 0) && ( doClosure != 100 ) && doClosure!=200 && doClosure!=210 && doClosure!=240 && doClosure!=250) {
    dj->AddFriend("genPar");
//     dj->AddFriend("mGenPar");
  }
  dj->SetAlias("finalJetPt","jetPt");
  // dj->SetAlias("finalJetPt","(jetPt*(0.935+0.065*cBin/40.))"); // systematic check for uncertainty in jes
  cout << "finalJetPt = " << dj->trees_[0]->GetAlias("finalJetPt") << endl;
  
  cout << " ================================================= " << endl;
  cout << " working on dataset, icent, irj = " << datasetName << ", "<<icent<<", "<<irj<<endl;
  cout << " doClosure: " << doClosure << " rewtJet: " << rewtJet << endl;
  cout << " ================================================= " << endl;

  ////////////////////////////////////////////////////////  
  // Draw From Tree
  ////////////////////////////////////////////////////////  
  dj->Draw(hjetPt, "finalJetPt" ,jet1Cut.Data() ,jetRewt);
  
  double NoE1 = hjetPt->Integral();
  
  ////////////////////////////////////////////////////////  
  // Track Selection
  ////////////////////////////////////////////////////////  
  TString trkCutJet1 = Form("yTrk.jetMatch==1 && yTrk.jetDr<%.2f && yTrk.pt>%.2f && yTrk.pt<%.2f", jetDrCut,trackPtMin,trackPtMax);
  TString bkgTrkCutJet1;
  if (doClosure==0) {
    bkgTrkCutJet1 = Form("mTrk.jetMatch==1 && mTrk.jetDr<%.2f && mTrk.pt>%.2f && mTrk.pt<%.2f", jetDrCut,trackPtMin,trackPtMax);
  } else if (doClosure==100) {
    bkgTrkCutJet1 = Form("yTrk.jetMatch==-1 && yTrk.jetDr<%.2f && yTrk.pt>%.2f && yTrk.pt<%.2f", jetDrCut,trackPtMin,trackPtMax);
  } else if (doClosure==1 || doClosure==101) {
    trkCutJet1    = Form("(abs(genPar.chg)>0) && (genPar.jetMatch==1) && (genPar.jetDr<%.2f) && (genPar.pt>%.2f && genPar.pt<%.2f)", jetDrCut,trackPtMin,trackPtMax);
    bkgTrkCutJet1 = Form("(genPar.sube!=0) && (abs(genPar.chg)>0) && (genPar.jetMatch==1) && (genPar.jetDr<%.2f) && (genPar.pt>%.2f && genPar.pt<%.2f)", jetDrCut,trackPtMin,trackPtMax);
  } else if (doClosure==102) {
    trkCutJet1    = Form("(abs(genPar.chg)>0) && (genPar.jetMatch==1) && (genPar.jetDr<%.2f) && (genPar.pt>%.2f && genPar.pt<%.2f)", jetDrCut,trackPtMin,trackPtMax);
    bkgTrkCutJet1 = Form("(abs(genPar.chg)>0) && (genPar.jetMatch==-1) && (genPar.jetDr<%.2f) && (genPar.pt>%.2f && genPar.pt<%.2f)", jetDrCut,trackPtMin,trackPtMax);
  } else if (doClosure ==2) {
    trkCutJet1    = Form("(abs(genPar.chg)>0) && (genPar.jetMatch==1) && (genPar.jetDr<%.2f) && (genPar.pt>%.2f && genPar.pt<%.2f)", jetDrCut,trackPtMin,trackPtMax);
    bkgTrkCutJet1 = Form("(abs(mGenPar.chg)>0) && (mGenPar.jetMatch==1) && (mGenPar.jetDr<%.2f) && (mGenPar.pt>%.2f && mGenPar.pt<%.2f)", jetDrCut,trackPtMin,trackPtMax);
  }

  ////////////////////////////////////////////////////////  
  // Track Weights
  ////////////////////////////////////////////////////////  
  TString trackWeight[3];
  TString matchedTrackWeight[3];
  TString genpWeight[3];
  // initialize
  for (int j=0; j<3; ++j) {
    // trackWeight[j] = jetRewt;
    // matchedTrackWeight[j] = jetRewt;
    trackWeight[j] = jetRewt+"*(yTrk.trkWeight*(yTrk.trkWeight<3.5)+1.47*(yTrk.trkWeight>=3.5))";
    matchedTrackWeight[j] = jetRewt+"*(mTrk.trkWeight*(mTrk.trkWeight<3.5)+1.47*(mTrk.trkWeight>=3.5))";
    genpWeight[j] = jetRewt;
    if (weightMode==1) {
      trackWeight[j]+="*yTrk.pt*";
      matchedTrackWeight[j]+="*mTrk.pt";
      genpWeight[j] += "*genPar.pt";
    } else if (weightMode==2) {
      trackWeight[j]+="*yTrk.pt/finalJetPt";
      matchedTrackWeight[j]+="*mTrk.pt/finalJetPt";
      genpWeight[j] += "*genPar.pt/finalJetPt";
    }
  }

  for (int j=0; j<1; ++j) {
    if ( fragMode   == 1 ) {
      if (doClosure == 0) {
        dj->Draw(htrkPt[j][kRAW],"yTrk.pt",    Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), trackWeight[j] );
        dj->Draw(htrkPt[j][kBKG],"mTrk.pt",    Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), matchedTrackWeight[j]);
      }
      else if ( doClosure == 100 ) {
        dj->Draw(htrkPt[j][kRAW],"yTrk.pt",    Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), trackWeight[j]);
        dj->Draw(htrkPt[j][kBKG], "yTrk.pt",   Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), trackWeight[j]);
      } 
      else if ( doClosure == 1 || doClosure == 101 || doClosure == 102) {
        dj->Draw(htrkPt[j][kRAW], "genPar.pt", Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), genpWeight[j]);
        dj->Draw(htrkPt[j][kBKG], "genPar.pt", Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), genpWeight[j]);
      }
//       else if ( doClosure == 2 ) {
//         dj->Draw(htrkPt[j][kRAW], "genPar.pt", Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), genpWeight[j]);
//         dj->Draw(htrkPt[j][kBKG], "mGenPar.pt",Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), genpWeight[j]);
//       }
    } else if ( fragMode   == 2 ) {
      if (doClosure == 0) {
        dj->Draw(htrkPt[j][kRAW],"-log(yTrk.pt * cos(yTrk.jetDr)  *(cosh(yTrk.eta)/cosh(jetEta)) /finalJetPt )",
          Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), trackWeight[j]);
        dj->Draw(htrkPt[j][kBKG],"-log(mTrk.pt * cos(mTrk.jetDr) * (cosh(mTrk.eta)/cosh(jetEta)) /finalJetPt )",
          Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), matchedTrackWeight[j]);
      }
      else if ( doClosure == 100 ) {
        dj->Draw(htrkPt[j][kRAW],"-log(yTrk.pt * cos(yTrk.jetDr) *(cosh(yTrk.eta)/cosh(jetEta)) /finalJetPt)",
          Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), trackWeight[j]);
        dj->Draw(htrkPt[j][kBKG], "-log(yTrk.pt * cos(yTrk.jetDr) * (cosh(yTrk.eta)/cosh(jetEta)) /finalJetPt)",
          Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), trackWeight[j]);
      }
      else if ( doClosure == 1|| doClosure == 101 || doClosure == 102) {
        dj->Draw(htrkPt[j][kRAW], "-log( genPar.pt * cos(genPar.jetDr)  *(cosh(genPar.eta)/cosh(jetEta)) /finalJetPt)", Form("%s && %s",
          jet1Cut.Data(), trkCutJet1.Data()), genpWeight[j]);
        dj->Draw(htrkPt[j][kBKG], "-log( genPar.pt * cos(genPar.jetDr)  *(cosh(genPar.eta)/cosh(jetEta))  /finalJetPt)", Form("%s && %s",
          jet1Cut.Data(), bkgTrkCutJet1.Data()), genpWeight[j]);
      }
//       else if ( doClosure == 2 ) {
//         dj->Draw(htrkPt[j][kRAW], "-log( genPar.pt * cos(genPar.jetDr)  *(cosh(genPar.eta)/cosh(jetEta)) /finalJetPt)", Form("%s && %s",
//           jet1Cut.Data(), trkCutJet1.Data()), genpWeight[j]);
//         dj->Draw(htrkPt[j][kBKG], "-log(mGenPar.pt * cos(mGenPar.jetDr)  *(cosh(mGenPar.eta)/cosh(jetEta)) /finalJetPt)", Form("%s && %s",
//           jet1Cut.Data(), bkgTrkCutJet1.Data()), genpWeight[j]);
//       }
    }
    // Rockets!
//     else if ( fragMode   == 10 ) {
//       if (doClosure <= 0) {
//         dj->Draw(htrkPt[j][kRAW],"yTrk.jetDr",    Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), trackWeight[j]);
//         dj->Draw(htrkPt[j][kBKG],"mTrk.jetDr",    Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), matchedTrackWeight[j]);
//       }
//       else if ( doClosure == 100 ) {
//         dj->Draw(htrkPt[j][kRAW],"yTrk.jetDr",    Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), trackWeight[j]);
//         dj->Draw(htrkPt[j][kBKG], "yTrk.jetDr",   Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), trackWeight[j]);
//       } 
//       else if ( doClosure == 1 || doClosure == 101 || doClosure == 102) {
//         dj->Draw(htrkPt[j][kRAW], "genPar.jetDr", Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), genpWeight[j]);
//         dj->Draw(htrkPt[j][kBKG], "genPar.jetDr", Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), genpWeight[j]);
//       }
//       else if ( doClosure == 2 ) {
//         dj->Draw(htrkPt[j][kRAW], "genPar.jetDr", Form("%s && %s", jet1Cut.Data(), trkCutJet1.Data()), genpWeight[j]);
//         dj->Draw(htrkPt[j][kBKG], "mGenPar.jetDr",Form("%s && %s", jet1Cut.Data(), bkgTrkCutJet1.Data()), genpWeight[j]);
//       }  
//     }

    // Normalize Histograms
    if (fragMode<10) {
       TH1ScaleByWidth(htrkPt[j][kRAW]);
       TH1ScaleByWidth(htrkPt[j][kBKG]);
    }
    // Signal
    htrkPt[j][kRAW]->Scale(1./NoE1);
    // Background
    if ( (doClosure == 1)  || (doClosure>99) ) {
      htrkPt[j][kBKG]->Scale(1./(NoE1));
    }
    else {
      htrkPt[j][kBKG]->Scale(1./(NoE1*nMixing1));
    }
    htrkPt[j][kSIG]->Add(htrkPt[j][kRAW]);
    htrkPt[j][kSIG]->Add(htrkPt[j][kBKG],-1);
    handsomeTH1(htrkPt[j][kRAW],1,1,24);
    handsomeTH1(htrkPt[j][kBKG],1);
    handsomeTH1(htrkPt[j][kSIG],1,1,20);
  }

  // Inspect
  TCanvas* c1 = new TCanvas(Form("c1_icent%d_irj%d",icent,irj),"",900,450);
  int iJetInsp=0;
  c1->Divide(2,1);
  c1->cd(1);
  if (fragMode<10) {
    gPad->SetLogy();
    htrkPt[iJetInsp][kRAW]->SetAxisRange(1e-5,10000,"Y");
  } else {
    gPad->SetLogy();
    if (weightMode==0) htrkPt[iJetInsp][kRAW]->SetAxisRange(1e-4,100,"Y");
    if (weightMode==1) htrkPt[iJetInsp][kRAW]->SetAxisRange(1e-4,1e5,"Y");
    if (weightMode==2) htrkPt[iJetInsp][kRAW]->SetAxisRange(1e-4,10,"Y");
  }
  htrkPt[iJetInsp][kRAW]->Draw();
  htrkPt[iJetInsp][kBKG]->Draw("same hist");
  htrkPt[iJetInsp][kSIG]->Draw("same");
  TLegend* l1 = new TLegend(0.3678213,0.7702352,0.9162483,0.9296714,NULL,"brNDC");
  easyLeg(l1,clsText_.Data()) ;
  l1->AddEntry(htrkPt[iJetInsp][kRAW],"All tracks in jet cone","p");
  l1->AddEntry(htrkPt[iJetInsp][kBKG], "tracks from underlying events","l");
  l1->AddEntry(htrkPt[iJetInsp][kSIG], "After subtraction","p");
  l1->Draw();
  drawText("jet p_{T} > 100GeV/c,  |#eta|<2", 0.26,0.3,1,17);
  drawText(Form("%d jets",(int)hjetPt->GetEntries()), 0.26,0.23,1,17);
  if ( fragMode   == 1 )      gPad->SetLogx();
  
  if       ( dataset == kHIDATA) 
    drawText("PbPb DATA", 0.2,0.8,1,15);
  else  if ( dataset == kHIMC)
    drawText("MC", 0.2,0.8,1);
  else if ( dataset == kPPDATA)
    drawText("pp DATA", 0.2,0.8,1,15);
  else if ( dataset == kPPMC)
    drawText("pp MC", 0.2,0.8,1,15);
  
  if ( (icent>=1) && (icent<=4) ) {
    int lowCent = centBin1[icent-1];
    int highCent = centBin1[icent]-1;
    drawText(Form("%.0f%% - %.0f%%", float((float)lowCent*2.5), float((float)(highCent+1)*2.5)), 0.2,0.73,1);
  }
  if ( (irj>=1) && (irj<=4) ) {
    drawText("0-30%", 0.2,0.73,1);
    drawText(Form("%.2f < pt_{2}/pt_{1} < %.2f             %.0f < p_{T}^{track} < %.0f", float(rjBin1[irj-1]), float(rjBin1[irj]),trackPtMin,trackPtMax), 0.2,0.66,1);    
  }
  if (fragMode==10) {
    drawText(Form("%.0f < p_{T}^{track} < %.0f GeV/c", trackPtMin,trackPtMax), 0.5,0.66,1);
  }
  c1->cd(2);
  cleverRange(hjetPt,10,1e-1);
  handsomeTH1(hjetPt,1);
  hjetPt->Draw();
  gPad->SetLogy();
  drawText("Jet p_{T}", 0.55,0.63,1);
  
  TString outnameTag=Form("trackPtCut%.0f_FinalJetPt%.0fto%.0feta%.2f_Jan17mcquenwide80and100_hi",ptranges[0],finalJetPtMin,finalJetPtMax,finalEtaCut);

  if ( fragMode==2) {
    c1->SaveAs(Form("plotsOfInclJetFF/inclJetFF_xi_doClosure%d_icent%d_irj%d_%s_%s%s_%s.pdf",doClosure,icent,irj,datasetName.Data(),clsText.Data(),tag.Data(),outnameTag.Data()));
  }
  else if ( fragMode==1) {
    c1->SaveAs(Form("plotsOfInclJetFF/inclJetFF_pt_doClosure%d_icent%d_irj%d_%s_%s%s_%s.pdf",doClosure,icent,irj,datasetName.Data(),clsText.Data(),tag.Data(),outnameTag.Data()));
  }
  else if ( fragMode==10) {
    c1->SaveAs(Form("plotsOfInclJetFF/inclJetFF_dr_pt%.0fto%.0f_doClosure%d_wtMode%d_icent%d_irj%d_%s_%s%s_%s.pdf",trackPtMin,trackPtMax,doClosure,weightMode,icent,irj,datasetName.Data(),clsText.Data(),tag.Data(),outnameTag.Data()));
  }

  // All Done, write output  
  TFile outf = TFile(Form("inclJetFF_output_%s.root",outnameTag.Data()),"update");
  hjetPt->Write();
  htrkPt[0][kRAW]->Write();
  htrkPt[0][kSIG]->Write();
  htrkPt[0][kBKG]->Write();
  outf.Close();

  // clean up
  delete dj;
}
Esempio n. 29
0
void drawSpecClosure(
    // HI
    TString infname="histff_tv12hydjuq80repass_j4_j2t2_et90_0601Closure_c0to12_a0to100.root"
    // pp
    //TString infname="histff_tv11_dj80mattpfgmv1_ak3pf_j2t2_an0509trk5.root"
    )
{
  TFile * inf = new TFile(infname);
  TString outdir = "out/20110601";
  gSystem->mkdir(outdir,true);
  TString outname = infname;
  outname.ReplaceAll(".root","");

  Bool_t doRebin = false;

  // Histograms
  TH1D * hSpec_ref = (TH1D*)inf->FindObjectAny("hGenSpecCorr0");
	cout << hSpec_ref << " " << hSpec_ref->GetName() << " " << hSpec_ref->GetEntries() << endl;
  TH1D * hSpec_corr[3], *hSpec_rat[3];
  for (Int_t lv=0; lv<3; ++lv) {
    hSpec_corr[lv] = (TH1D*)inf->FindObjectAny(Form("hRecSpecCorr%d",lv));
		cout << hSpec_corr[lv] << " " << hSpec_corr[lv]->GetName() << " " << hSpec_corr[lv]->GetEntries() << endl;
  }
  // styles
  hSpec_ref->SetLineColor(kRed);
  hSpec_corr[0]->SetMarkerStyle(kOpenSquare);

  // rebin
  if (doRebin) {
    for (Int_t lv=0; lv<3; ++lv) {
      hSpec_corr[lv]->Rebin(2);
      hSpec_corr[lv]->Scale(0.5);
    }
    hSpec_ref->Rebin(2);
    hSpec_ref->Scale(0.5);
  }

  // ratio
  for (Int_t lv=0; lv<3; ++lv) {
    hSpec_rat[lv] = (TH1D*)hSpec_corr[lv]->Clone(Form("%s_rat",hSpec_corr[lv]->GetName()));
    hSpec_rat[lv]->Divide(hSpec_ref);
  }

  // draw
  TCanvas * c2 = new TCanvas("c2","c2",500,900);
	TH1D * hFrame = (TH1D*)hSpec_ref->Clone("hFrame");
	hFrame->Reset();
  hFrame->SetTitle(";Trk p_{T};dN/dp_{T}");
  hFrame->SetAxisRange(10,100,"X");
  hFrame->SetAxisRange(2e-5,5e1,"Y");	
  handsomeTH1(hFrame);
  c2->Divide(1,2);
  c2->cd(1);
  gPad->SetLogy();
	hFrame->Draw("p");
  hSpec_ref->Draw("same hist");
  hSpec_corr[0]->Draw("sameE");
  hSpec_corr[2]->Draw("sameE");
  c2->cd(2);
  hSpec_rat[0]->SetTitle(";Trk p_{T};ratio");
  hSpec_rat[0]->SetAxisRange(10,100,"X");
  hSpec_rat[0]->SetAxisRange(0,2,"Y");
  handsomeTH1(hSpec_rat[0]);
  hSpec_rat[0]->Draw("E");
  hSpec_rat[2]->Draw("sameE");
  TLine * l = new TLine(10,1,120,1);
  l->SetLineStyle(2);
  l->Draw();

  c2->cd(1);
  TLegend *leg = new TLegend(0.52,0.65,0.91,0.91);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
  leg->AddEntry(hSpec_ref,"PYTHIA+HYDJET 0-30%","");
  leg->AddEntry(hSpec_ref,"hiGoodTight","");
  leg->AddEntry(hSpec_ref,"Trk |#eta|<1","");
  leg->AddEntry(hSpec_ref,"Gen. Charged","l");
  leg->AddEntry(hSpec_corr[0],"Raw Reco","p");
  leg->AddEntry(hSpec_corr[2],"Corrected Reco","p");
  leg->Draw();

  c2->Print(outdir+"/Spectra_closure_"+outname+".gif");
}
Esempio n. 30
0
void drawQual(TFile * inf, TCanvas * can, Int_t ic, Float_t ymin, Float_t ymax, Int_t doLog, Float_t xmin=0, Float_t xmax=0)
{
	cout << "ic: " << ic << " ymin: " << ymin << " ymax " << ymax << " xmin " << xmin	<< " xmax " << xmax << endl;
	TH3F * hQual3D_precut_mc = (TH3F*)inf->FindObjectAny(Form("hTrkQual%dPreCut3D_mc80_c0to36",ic));
	TH3F * hQual3D_precut_data = (TH3F*)inf->FindObjectAny(Form("hTrkQual%dPreCut3D_dataj35_c0to36",ic));
	cout << hQual3D_precut_mc->GetName() << ": " << hQual3D_precut_mc << endl;
	cout << hQual3D_precut_data->GetName() << ": " << hQual3D_precut_data << endl;
	TH1D * hPtBin = (TH1D*)hQual3D_precut_data->Project3D("y");
	TH1D * hQual_precut_mc[10][8], * hQual_precut_data[10][8];
	Int_t colors[10] = {kBlack, kGray+2, kBlue+2,kCyan+2,kGreen+2,kYellow+2,kOrange+2,kRed};
	
	Int_t rebinFactor=2;
	for (Int_t p=0; p<=9; ++p){
		for (Int_t c=0; c<=7; ++c) {
			Int_t ptBin=p;
			Int_t cBin=c;
			hQual3D_precut_mc->GetYaxis()->SetRange(ptBin,ptBin);
			//hQual3D_precut_mc->GetZaxis()->SetRange(cBin,cBin+5);
			hQual3D_precut_data->GetYaxis()->SetRange(ptBin,ptBin);
			//hQual3D_precut_data->GetZaxis()->SetRange(cBin,cBin+5);

			hQual_precut_mc[p][c] = (TH1D*)hQual3D_precut_mc->Project3D("x");
			hQual_precut_mc[p][c]->SetName(Form("%s_p%d_c%d",hQual3D_precut_mc->GetName(),ptBin,cBin));
			hQual_precut_data[p][c] = (TH1D*)hQual3D_precut_data->Project3D("x");
			hQual_precut_data[p][c]->SetName(Form("%s_p%d_c%d",hQual3D_precut_data->GetName(),ptBin,cBin));
			//cout << Form("Project data %d: %.1f-%.1f GeV/c: ",ptBin, hPtBin->GetBinLowEdge(ptBin),hPtBin->GetBinLowEdge(ptBin+1)) << hQual_precut_data[p][c]->GetEntries() << endl;
			//rebin
			hQual_precut_data[p][c]->Rebin(rebinFactor);
			hQual_precut_mc[p][c]->Rebin(rebinFactor);
			// styles
			hQual_precut_mc[p][c]->SetMarkerColor(kRed-9);
			hQual_precut_mc[p][c]->SetLineColor(kRed-9);
			hQual_precut_mc[p][c]->SetMarkerStyle(kOpenSquare);
			hQual_precut_mc[p][c]->SetFillStyle(3001);
			hQual_precut_mc[p][c]->SetFillColor(kRed-9);
			hQual_precut_data[p][c]->SetMarkerColor(colors[c]);
			hQual_precut_mc[p][c]->Scale(1./hQual_precut_mc[p][c]->GetEntries()/rebinFactor);
			hQual_precut_data[p][c]->Scale(1./hQual_precut_data[p][c]->GetEntries()/rebinFactor);
			// set title
			fixedFontHist(hQual_precut_mc[p][c]);
			fixedFontHist(hQual_precut_data[p][c]);
			hQual_precut_mc[p][c]->SetYTitle("unit normalization");
			hQual_precut_data[p][c]->SetYTitle("unit normalization");
			// set axis
			if(xmin!=xmax) {
				hQual_precut_mc[p][c]->SetAxisRange(xmin,xmax,"X");
				hQual_precut_data[p][c]->SetAxisRange(xmin,xmax,"X");
			}
			hQual_precut_mc[p][c]->SetAxisRange(ymin,ymax,"Y");
			hQual_precut_data[p][c]->SetAxisRange(ymin,ymax,"Y");
		}
	}
	
	//can->Divide(5,1);
	Int_t centBin=0;
	Int_t ipad=1;
	for (Int_t p=3; p<=7; ++p) {
		can->cd(ipad);
		if (doLog==1) gPad->SetLogy();
		Int_t ptBin=p;
		cout << "ptBin: " << ptBin << endl;
		handsomeTH1(hQual_precut_data[ptBin][centBin]);
		hQual_precut_data[ptBin][centBin]->Draw("E");
		hQual_precut_mc[ptBin][centBin]->Draw("histsame");
		hQual_precut_data[ptBin][centBin]->Draw("Esame");
		cout << Form("%.1f-%.1f GeV/c: ",hPtBin->GetBinLowEdge(ptBin),hPtBin->GetBinLowEdge(ptBin+1)) << hQual_precut_data[ptBin][centBin]->GetEntries() << endl;
		++ipad;
	}
	can->cd(1);
  //TLegend *legdata = new TLegend(0.19,0.71,0.49,0.90);
  TLegend *legdata = new TLegend(0.26,0.72,0.56,0.92);
  legdata->SetFillStyle(0);
  legdata->SetBorderSize(0);
  legdata->SetTextSize(0.035);
	legdata->AddEntry(hQual_precut_data[0][0],"0-90%","");
  legdata->AddEntry(hQual_precut_data[0][0],"Data Jet35U","p");
  legdata->AddEntry(hQual_precut_mc[0][0],"MC, #hat{p}_{T} 80 GeV/c","p");
	legdata->Draw();
	
	ipad=1;
	for (Int_t p=3; p<=7; ++p) {
		can->cd(ipad);
		Int_t ptBin=p;
		cout << "ptBin leg: " << ptBin << endl;
		Float_t px=0.4,py=0.88;
		if (ipad==1) px=0.63;
		drawText(Form("%.1f - %.1f GeV/c",hPtBin->GetBinLowEdge(ptBin),hPtBin->GetBinLowEdge(ptBin+1)),px,py);
		++ipad;
	}
}