예제 #1
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();
    
    
    
}
예제 #2
0
void compInclJetFrag()
{
  // Jet Selection: used for jet selecting the jets
  // TCut jetSelCut[2] = {"jetPt>100&&jetPt<300","jetPt>100&&jetPt<300"};
  // TCut jetSelCut[2] = {"jetPtGM>100&&jetPtGM<300","jetPtGM>100&&jetPtGM<300"};
  TCut jetSelCut[2] = {"jetPt>100&&jetPt<300","jetPtGM>100&&jetPtGM<300"};
  // TCut jetSelCut[2] = {"jetPtGM<100","jetPtGM>100&&jetPtGM<300"};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

  // Check
  // TCanvas * cc = new TCanvas("cc","cc",2);
  // hTrkPt[0]->Draw("hist");
  // hTrkJetPt2D[0]->ProjectionY(Form("%s_py",hTrkJetPt2D[0]->GetName()))->Draw("sameE");
  // hJetPt[0]->Scale(1./nJet[0]);
  // hJetPt[0]->Draw("hist");
  // hTrkJetPt2D[0]->ProjectionX(Form("%s_px",hTrkJetPt2D[0]->GetName()))->Draw("sameE");
}
예제 #3
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 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));

}
예제 #5
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");
}
예제 #6
0
void mergeSys() {
    const int kPP = 1;
    const int kHIcentral =  2;
    const int kHIperipheral = 3;
    const int kPA = 4;
    const int nPtBin = 4;  
    const int NCOLL = 3;  
    double ptBin[nPtBin+1] = {40,50,60,80,9999};

    const int nRptBin[4] = {4,4,5,5};
    double ratioPtBin[4][10] = {{30,40,50,70,150},
        {30,40,50,70,150},
        {30,40,50,70,100,150},
        {30,40,50,70,100,150}};
    double ratioPtBin1[4][10] = {{30,40,50,68,105},
        {30,40,50,68,105},
        {30,40,50,68,100,130},
        {30,40,50,68,100,130}};


    TH1D* dNdJetPt_origin[5][5][10]; // [collision] [ptbin] [sys. category]
    TH1D* dNdJetPt[5][5][10];
    TH1D* hOutput[5][5][10]; //Iaa Ratio Sys
    TFile* f; 

    int nFile  = 7;
    //int nFile  = 6;
    for ( int ifile = 1 ; ifile <= nFile ; ifile++ ) { 
        if ( ifile == 1 )       f = new TFile("relativeSys/relativeSys_dueTo_photonEnergyScale.root");
        else if ( ifile == 2 )  f = new TFile("relativeSys/relativeSys_dueTo_noJetResCorr.root");
        else if ( ifile == 3 )  f = new TFile("relativeSys/relativeSys_dueTo_isolation.root");
        else if ( ifile == 4 )  f = new TFile("relativeSys/relativeSys_dueTo_electronContamination.root");
        else if ( ifile == 5 )  f = new TFile("relativeSys/relativeSys_dueTo_photonPurityVaried.root");
        //else if ( ifile == 6 )  f = new TFile("relativeSys/relativeSys_dueTo_smearingNscale.root");
        else if ( ifile == 6 )  f = new TFile("relativeSys/relativeSys_dueTo_jetEnergyScale.root");
        else if ( ifile == 7 )  f = new TFile("relativeSys/relativeSys_dueTo_jetEnergyResolution.root");
      
        for ( int coll = 1 ; coll<=NCOLL ; coll++) { 
            TString collName;
            if ( coll == kPP )  collName = "pp";
            else if ( coll == kPA )  collName = "ppb";
            else if ( coll == kHIcentral )  collName = "pbpb_centralityBin1";
            else if ( coll == kHIperipheral )  collName = "pbpb_centralityBin2";

            for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) { 
                dNdJetPt_origin[coll][ipt][ifile] = (TH1D*)f->Get(Form("dNdJetPt_IaaBin_%s_ptBin%d_uncertainty", collName.Data(), ipt ) );
                dNdJetPt_origin[coll][ipt][ifile] -> SetName(Form("dNdJetPt_IaaBin_%s_ptBin%d_uncertainty_origin", collName.Data(), ipt ) );
                dNdJetPt[coll][ipt][ifile] = (TH1D*)dNdJetPt_origin[coll][ipt][ifile] -> Rebin(nRptBin[ipt-1], Form("dNdJetPt_IaaBin_%s_ptBin%d_uncertainty", collName.Data(), ipt), ratioPtBin[ipt-1] );
            }
        }
    }
    // Divide the uncertainties
    for ( int ifile = 1 ; ifile <= nFile ; ifile++ ) {
        for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {

            hOutput[kHIcentral][ipt][ifile] = (TH1D*)dNdJetPt[kHIcentral][ipt][ifile]->Clone(Form("dNdJetPt_ratio_centralityBin1_ptBin%d_uncertainty", ipt ) );
            hOutput[kHIperipheral][ipt][ifile] = (TH1D*)dNdJetPt[kHIperipheral][ipt][ifile]->Clone(Form("dNdJetPt_ratio_centralityBin2_ptBin%d_uncertainty", ipt ) );
            hOutput[kPP][ipt][ifile] = (TH1D*)dNdJetPt[kPP][ipt][ifile]->Clone(Form("dNdJetPt_pp_ptBin%d_uncertainty", ipt ) );

            // Add unity
            addValueToAllBin(hOutput[kHIcentral][ipt][ifile],    1);
            addValueToAllBin(hOutput[kHIperipheral][ipt][ifile], 1);
            addValueToAllBin(hOutput[kPP][ipt][ifile],           1);

            hOutput[kHIcentral][ipt][ifile]->Divide(hOutput[kPP][ipt][ifile]);
            hOutput[kHIperipheral][ipt][ifile]->Divide(hOutput[kPP][ipt][ifile]);
            addValueToAllBin(hOutput[kHIcentral][ipt][ifile],    -1);
            addValueToAllBin(hOutput[kHIperipheral][ipt][ifile], -1);
        }
    }


/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// dNdJetPt relative uncertainty calculation
    TCanvas* c1 = new TCanvas("c1","",1200,900);
    c1->Divide(nPtBin,NCOLL);
    for ( int coll = 1 ; coll<=NCOLL ; coll++) {   
        for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
            c1->cd( ipt + nPtBin*(coll-1) );
            dNdJetPt[coll][ipt][0] = (TH1D*)dNdJetPt[coll][ipt][1]->Clone(Form("%s_merged",dNdJetPt[coll][ipt][1]->GetName() ) );
            dNdJetPt[coll][ipt][0]->Reset();
            for ( int ifile = 1 ; ifile <= nFile ; ifile++ ) {
                squareHist( dNdJetPt[coll][ipt][ifile] );
                dNdJetPt[coll][ipt][0]->Add(dNdJetPt[coll][ipt][ifile]);
            }
            squareRootHist(dNdJetPt[coll][ipt][0]);
           
            dNdJetPt[coll][ipt][0]->GetYaxis()->SetTitle("Total Rel. Sys. Uncert.");
            dNdJetPt[coll][ipt][0]->SetAxisRange(30,150,"X");
            dNdJetPt[coll][ipt][0]->GetXaxis()->SetRangeUser(30,150);
            dNdJetPt[coll][ipt][0]->SetAxisRange(-1.0,1.0,"Y");
            dNdJetPt[coll][ipt][0]->SetMarkerStyle(20);
            dNdJetPt[coll][ipt][0]->Draw("pl");
            jumSun(30,0,150,0); 

            /////////////////////////////////////////////////////////////////
            // COSMETIC
            TString collName;
            if ( coll == kPP )  collName = "pp";
            else if ( coll == kPA )  collName = "ppb";
            else if ( coll == kHIcentral )  collName = "pbpb 0-30%";
            else if ( coll == kHIperipheral )  collName = "pbpb 30-100%";

            double dx1=0.18;
            if(coll==1){ // photon pT, drawText("text", xp, yp, color, size)
                if ( ipt == nPtBin )
                    drawText(Form("p_{T}^{#gamma} > %dGeV ", (int)ptBin[ipt-1]), 0.07+dx1+0.1,0.9,1,16);
                else if ( ipt == 1)
                    drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.10+dx1,0.9,1,16);
                else
                    drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.10+dx1,0.9,1,16);
            }
            if(ipt==1) drawText(collName, 0.10+dx1, 0.7, 1, 16); //collision name

        }
    }
    c1->SaveAs("pdf/relativeSysDist_dNdJetPt_total.pdf");

/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Ratio(Iaa) relative uncertainty calculation

    TCanvas* c2 = new TCanvas("c2","",1200,600);
    c2->Divide(nPtBin,2);
 
    for ( int coll = 2 ; coll<=NCOLL ; coll++) {
        if   ( ( coll != kHIcentral) && ( coll != kHIperipheral ) )
            continue;
        for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
            c2->cd( ipt + nPtBin*(coll-2) );
            hOutput[coll][ipt][0] = (TH1D*)hOutput[coll][ipt][1]->Clone(Form("%s_merged",hOutput[coll][ipt][1]->GetName() ) );
            hOutput[coll][ipt][0]->Reset();
            for ( int ifile = 1 ; ifile <= nFile ; ifile++ ) {
                squareHist( hOutput[coll][ipt][ifile] );
                hOutput[coll][ipt][0]->Add(hOutput[coll][ipt][ifile]);
            }
            squareRootHist(hOutput[coll][ipt][0]);
           
            hOutput[coll][ipt][0]->GetYaxis()->SetTitle("Total Rel. Sys Uncert.");
            hOutput[coll][ipt][0]->SetAxisRange(30,150,"X");
            hOutput[coll][ipt][0]->GetXaxis()->SetRangeUser(30,150);
            hOutput[coll][ipt][0]->SetAxisRange(-1.0,1.0,"Y");
            hOutput[coll][ipt][0]->SetMarkerStyle(20);
            hOutput[coll][ipt][0]->Draw("pl");
            jumSun(30,0,150,0); 

            /////////////////////////////////////////////////////////////////
            // COSMETIC
            TString collName;
            if ( coll == kHIcentral )  collName = "pbpb/pp 0-30%";
            else if ( coll == kHIperipheral )  collName = "pbpb/pp 30-100%";

            double dx1=0.18;
            if(coll==2){ // photon pT, drawText("text", xp, yp, color, size)
                if ( ipt == nPtBin )
                    drawText(Form("p_{T}^{#gamma} > %dGeV ", (int)ptBin[ipt-1]), 0.07+dx1+0.1,0.9,1,16);
                else if ( ipt == 1)
                    drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.10+dx1,0.9,1,16);
                else
                    drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV ", (int)ptBin[ipt-1], (int)ptBin[ipt]), 0.10+dx1,0.9,1,16);
            }
            if(ipt==1) drawText(collName, 0.10+dx1, 0.7, 1, 16); //collision name
        }
    }
    c2->SaveAs("pdf/relativeSysDist_Iaa_total.pdf");

    TFile * fSysResults = new TFile("relativeSys/relativeSys_merged.root","recreate");
    for ( int coll = 1 ; coll<=NCOLL ; coll++) { 
        for ( int ipt = 1 ; ipt <=nPtBin ; ipt++) {
            dNdJetPt[coll][ipt][0]->Write();
            if( ( coll == kHIcentral) || ( coll == kHIperipheral ) ) hOutput[coll][ipt][0]->Write();
        }
    }
    fSysResults->Close();
}
예제 #7
0
void showerShapeBkg(  sampleType collision = kPPMC)
{
  TH1::SetDefaultSumw2();
  
  TCut bkgPhoCut = "( (abs(genMomId)>22) || (genIso>5) ) && (hovere<0.1)";

  multiTreeUtil* tgj = new multiTreeUtil();
  if ( collision == kPPMC ) {
    tgj->addFile(fnamePPMC_emDijet30to50,   "tgj", bkgPhoCut, wPPMC_emDijet30to50);
    tgj->addFile(fnamePPMC_emDijet50to80,   "tgj", bkgPhoCut, wPPMC_emDijet50to80);
    tgj->addFile(fnamePPMC_emDijet80to120,  "tgj", bkgPhoCut, wPPMC_emDijet80to120);
    tgj->addFile(fnamePPMC_emDijet120to9999,"tgj", bkgPhoCut, wPPMC_emDijet120to9999);
  }
  else { 
    cout << " pA and PbPb MC samples are not ready yet" << endl;
  }


  TH1D* hPtHat = new TH1D("hpthat",";pt hat (GeV);",200,0,200);
  handsomeTH1(hPtHat,1);
  TCanvas* c1 = new TCanvas("c1","",500,500);
  tgj->Draw3(hPtHat,"photonEt",bkgPhoCut,"");
  gPad->SetLogy();

  TCanvas* c2 = new TCanvas("c1","",1100,600);
  makeMultiPanelCanvas(c2,nPtBinPa,2,0.0,0.0,0.2,0.15,0.02);
  c2->cd(1);
  TCut ppIsoCut  = "(ecalIso < 4.2)  &&  (hcalIso < 2.2)  &&  (trackIso < 2)";
  TCut hiIsoCut  = "sumIso < 1";
  TCut ppSbCut   = "(ecalIso < 4.2)  &&  (hcalIso < 2.2)  &&  ( (trackIso>2) && (trackIso<4) )";
  TCut hiSbCut   = "(sumIso > 10) && (sumIso<20)";

  TH1D* sii[5][nPtBinPa+1]; 
  for ( int ipt = 1 ; ipt<=nPtBinPa ; ipt++) {
    for ( int iiso = 1 ; iiso<=4 ; iiso++) {
      sii[iiso][ipt] = new TH1D(Form("sigmaIetaIeta_iso%d_ipt%d",iiso,ipt), ";#sigma_{#eta#eta};Entries", 25,0,0.025);
      handsomeTH1(sii[iiso][ipt],1);
    }
    TCut phoPtCut = Form ( "photonEt>=%f && photonEt<%f", (float)ptBinPa[ipt-1], (float)ptBinPa[ipt]);
    tgj->Draw2(sii[1][ipt], "sigmaIetaIeta",ppIsoCut && phoPtCut, "");
    tgj->Draw2(sii[2][ipt], "sigmaIetaIeta",hiIsoCut && phoPtCut, "");
    tgj->Draw2(sii[3][ipt], "sigmaIetaIeta",ppSbCut && phoPtCut, "");
    tgj->Draw2(sii[4][ipt], "sigmaIetaIeta",hiSbCut && phoPtCut, "");
    scaleInt(sii[1][ipt]);
    scaleInt(sii[2][ipt]);
    scaleInt(sii[3][ipt]);
    scaleInt(sii[4][ipt]);
  }  

  for ( int ipt = 1 ; ipt<=nPtBinPa ; ipt++) {
    c2->cd(ipt);
    TH1D* sii_A = sii[1][ipt];
    TH1D* sii_B = sii[4][ipt];
    handsomeTH1(sii_B,2);
    sii_A->Draw();
    sii_B->Draw("same");
    c2->cd(ipt+nPtBinPa);
    TH1D* hRatio = (TH1D*)sii_A->Clone(Form("hRatio_%s",sii_A->GetName()));
    hRatio->Divide(sii_B);
    hRatio->SetAxisRange(0,4,"Y");
    hRatio->Draw();
    hRatio->Fit("pol1");
    jumSun(0,1,0.025,1);
  }
}
예제 #8
0
void fakerate(int flvOpt = 0, int genOpt = 0){
  TH1::SetDefaultSumw2();

    gStyle->SetOptFit(1011);
    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 = 18;
    //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];

    for(int i=0;i<=nPtBin;i++){
        ptBin[i] = 20.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};
    const int nCentBinPa = 1;
    double centBinPa[nCentBinPa+1] = {0,10000};
    //
    // fake rate
    //
    int nJetmax = 100;
    float refPt[nJetmax], pt[nJetmax], eta[nJetmax], dphi[nJetmax];
    int nJet, refPartonFlv[nJetmax];
    EvtSel evtImb;
    TBranch *b_evt;
    
    multiTreeUtil* yJet = new multiTreeUtil();
    // 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);
   
    //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); 
    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];
    for(int icent=1; icent <= nCentBinPa ; icent++){
        for(int i=0; i < nPtBin ; i++){
            c2 -> cd((icent-1)*4+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", partonCut && Form(" (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && (refPt >= %d && refPt < %d) && (hf4Sum > %f && hf4Sum <= %f) ", (int)ptBin[i], (int)ptBin[i+1], (float)centBinPa[icent-1], (float)centBinPa[icent]),""); 
	    }
	    else if (genOpt == 1)  {
	      yJet -> Draw2(Escale[icent][i], "pt/refPt", partonCut && Form(" (abs(eta) < 1.6) && (dphi > 7*3.141592/8.0) && (pt >= %d && pt < %d) && (hf4Sum > %f && hf4Sum <= %f) ", (int)ptBin[i], (int)ptBin[i+1], (float)centBinPa[icent-1], (float)centBinPa[icent]),"");
	    }
            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.12+dx1,0.84,1,15);//yeonju 130823
            else
                drawText(Form("%dGeV < p_{T}^{GEN Jet} < %dGeV, ", (int)ptBin[i], (int)ptBin[i+1]), 0.12+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();
    //
    // Energy Scale
    //

    TCanvas *c3 = new TCanvas("c3", "Energy Scale vs. jet pt",147,37,930,465);
    c3->Divide(2,1);
    c3->cd(1);
    TH1D* h = new TH1D("h",";JetP_{T}^{GEN} (GeV); Energy Scale ",1000,20,200);
    handsomeTH1(h,1);
    h -> SetAxisRange(0.8, 1.1, "Y");
    h -> Draw();
    jumSun(20,1,200,1);
    jumSun(30,0.8,30,1.1,2);

    TGraphAsymmErrors* g[nCentBinPa+5];
    g[1] = new TGraphAsymmErrors();
    g[2] = new TGraphAsymmErrors();
    g[3] = new TGraphAsymmErrors();
    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 icent=1; icent <= nCentBinPa ; icent++){
        for(int i=0; i < nPtBin ; i++){ 
            g[icent] -> SetPoint(i+1, AvePtBin[i], mean[icent][i]);
            g[icent] -> SetPointError(i+1, 0.001,0.001, var[icent][i], var[icent][i]);
            g[icent] -> SetMarkerStyle(20);
            g[icent] -> SetMarkerSize(1);
            g[icent] -> SetMarkerColor(icent);
            g[icent] -> Draw("same p");
        }
        l3->AddEntry(g[icent], Form("%d GeV < E_{T}^{HF|#eta|>4} < %d GeV", (int)centBinPa[icent-1], (int)centBinPa[icent]), "p"); 
    }
    //    l3 -> Draw();

    //
    // Energy Resolution
    //

    c3->cd(2);
    TH1D* h_resol = new TH1D("h_resol",";JetP_{T} (GeV); Energy Resolution (GeV) ",1000,20,200);
    h_resol -> SetAxisRange(0.0, 0.2, "Y");
    h_resol->GetYaxis()->CenterTitle();
    h_resol -> Draw();
    jumSun(30,0.8,30,1.1,2);

    TGraphAsymmErrors* gResol[nCentBinPa+5];
    gResol[1] = new TGraphAsymmErrors();
    gResol[2] = new TGraphAsymmErrors();
    gResol[3] = new TGraphAsymmErrors();

    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 icent=1; icent <= nCentBinPa ; icent++){
        for(int i=0; i < nPtBin ; i++){ 
//            cout << "resol : " << resol[icent][i] << ", resolVar : " << resolVar[icent][i]<< endl;
            gResol[icent] -> SetPoint(i+1, AvePtBin[i], resol[icent][i]);
            gResol[icent] -> SetPointError(i+1, 0.001,0.001, resolVar[icent][i], resolVar[icent][i]);
            gResol[icent] -> SetMarkerStyle(20);
            gResol[icent] -> SetMarkerSize(1);
            gResol[icent] -> SetMarkerColor(icent);
            gResol[icent] -> Draw("same p");
        }
        l_resol->AddEntry(gResol[icent], Form("%d GeV < E_{T}^{HF|#eta|>4} < %d GeV", (int)centBinPa[icent-1], (int)centBinPa[icent]), "p"); 
    }
    l_resol->Draw();
    //flvOpt = 0, int genOpt
   // c1 -> SaveAs(".gif");
    c2 -> SaveAs(Form("c2_flvOpt%d_genOpt%d.gif",flvOpt,genOpt));
    c3 -> SaveAs(Form("c3_flvOpt%d_genOpt%d.gif",flvOpt,genOpt));
    //    c_fake -> SaveAs(".gif");
    

}
void yeonju_drawPAFigures_0815(int xNorm = 1) { 
  gStyle -> SetOptStat(0); 
    //yeonju
  const int nCentBinPa = 3;
  double centBinPa[nCentBinPa+1] = {0,20,30,100};
  double AvePtBin[nCentBinPa+1] = {10, 25.0, 65.0, 9999};
  const int nPt = 5;
  const int nFile = 10;
  
  double PtBinPa[nPt+1] = {40,50,60,80,120,9999};

/*  const int nCentBinPa = 5;
  double centBinPa[nCentBinPa+1] = {0,20,25,30,40,100};
  double AvePtBin[nCentBinPa+1] = { 10, 22.5, 27.5, 35, 70, 9999};
  */
  TH1D* hxjg[7][1000][20]; // [species][centrality][pt_dependence]
  TH1D* hxjgNorm[7][1000][20];
  TH1D* hdphi[7][1000][20];
  
  valPair meanX[7][1000][20];
  valPair rjg[7][1000][20];
  TGraphAsymmErrors* gr[7][20];
  TGraphAsymmErrors* gx[7][20];
  for (int j=1;j<=nFile;j++){
      for (int i=1;i<=7;i++) {  
          gr[i][j] = new TGraphAsymmErrors();
          gr[i][j]->SetName(Form("gr_%d_%d",i,j));
          gx[i][j] = new TGraphAsymmErrors();
          gx[i][j]->SetName(Form("gx_%d_%d",i,j));
      }
  }
  TFile* fff[7][1000][20];
  double rError[20];
// cout << "ok!"<< endl;
  for ( int icent = 1 ; icent<=nCentBinPa  ; icent++) { 
    int iSpecies =kPADATA ; 
    
    int iglb = icent + iSpecies*50.;
    
    fff[iSpecies][iglb][1] = new TFile("ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr40_to_50_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][2] = new TFile("ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr50_to_60_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][3] = new TFile("ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr60_to_80_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][4] = new TFile("ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr80_to_120_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][5] = new TFile("ffFiles/photonTrackCorr_ppbDATA_output_photonPtThr120_to_9999_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][6] = new TFile("ffFiles/photonTrackCorr_ppbMC_output_photonPtThr40_to_50_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][7] = new TFile("ffFiles/photonTrackCorr_ppbMC_output_photonPtThr50_to_60_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][8] = new TFile("ffFiles/photonTrackCorr_ppbMC_output_photonPtThr60_to_80_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][9] = new TFile("ffFiles/photonTrackCorr_ppbMC_output_photonPtThr80_to_120_jetPtThr30_20130815.root");
    fff[iSpecies][iglb][10] = new TFile("ffFiles/photonTrackCorr_ppbMC_output_photonPtThr120_to_9999_jetPtThr30_20130815.root");
  //          cout << "fffff" << endl;
    for(int j = 1; j <= nFile ; j++){
        hdphi[iSpecies][iglb][j] = (TH1D*)fff[iSpecies][iglb][j]->Get(Form("jetDphi_icent%d_final",icent));
//cout << "hdphi" <<endl;
        hxjg[iSpecies][iglb][j] = (TH1D*)fff[iSpecies][iglb][j]->Get(Form("xjg_icent%d_final",icent));
        hxjgNorm[iSpecies][iglb][j] = (TH1D*)hxjg[iSpecies][iglb][j]->Clone(Form("norm_%s",hxjg[iSpecies][iglb][j]->GetName()) );

//cout << "meanX" <<endl;
        meanX[iSpecies][iglb][j].val = hxjg[iSpecies][iglb][j]->GetMean();
        meanX[iSpecies][iglb][j].err = hxjg[iSpecies][iglb][j]->GetMeanError();
        gx[iSpecies][j]->SetPoint     (icent, AvePtBin[icent-1], meanX[iSpecies][iglb][j].val);
        gx[iSpecies][j]->SetPointError(icent, AvePtBin[icent-1] - centBinPa[icent-1], centBinPa[icent] - AvePtBin[icent-1], meanX[iSpecies][iglb][j].err, meanX[iSpecies][iglb][j].err);

//cout << "rjg" <<endl;
        rjg[iSpecies][iglb][j].val = hxjg[iSpecies][iglb][j]->IntegralAndError(1, hxjg[iSpecies][iglb][j]->GetNbinsX(), rError[j], "width");
        rjg[iSpecies][iglb][j].err = rError[j];
        gr[iSpecies][j]->SetPoint     (icent, AvePtBin[icent-1], rjg[iSpecies][iglb][j].val);
        gr[iSpecies][j]->SetPointError(icent,  AvePtBin[icent-1] - centBinPa[icent-1], centBinPa[icent] - AvePtBin[icent-1], rjg[iSpecies][iglb][j].err, rjg[iSpecies][iglb][j].err);
    }

  }

  cout << "Tcanvas c1 " << endl;
  TCanvas* c1 = new TCanvas("c1","xjg_distribution",900,1750);
  makeMultiPanelCanvas(c1,3,5,0.0,0.0,0.2,0.15,0.02);
  for ( int j = 1 ; j <= nPt ; j++){//pt
      for ( int icent = 1 ; icent<=nCentBinPa  ; icent++) {
          c1->cd(icent+3*(j-1));

          int iSpecies = kPADATA;
          int iglb = icent + iSpecies*50.;
          handsomeTH1(hxjgNorm[iSpecies][iglb][j],icent);
          hxjgNorm[iSpecies][iglb][j]->Scale(0.1);
          if (xNorm==1) scaleInt(hxjgNorm[iSpecies][iglb][j]);
          hxjgNorm[iSpecies][iglb][j]->SetXTitle("x_{J,#gamma}");
          hxjgNorm[iSpecies][iglb][j]->SetYTitle("#frac{dN}{dx} #frac{1}{N}");
          if (xNorm==1)     hxjgNorm[iSpecies][iglb][j]->SetAxisRange(-0.015,0.35,"Y");
          else              hxjgNorm[iSpecies][iglb][j]->SetAxisRange(-0.06,1.5,"Y");
          hxjgNorm[iSpecies][iglb][j]->SetMarkerStyle(19+j);
          hxjgNorm[iSpecies][iglb][j]->Draw();


          float dx1;    
          ((icent==1)||(icent==4))? dx1=0.15 : dx1=0 ;

          if ( icent == nCentBinPa )
              drawText(Form("E_{T}^{HF|#eta|>4} > %dGeV, ", (int)centBinPa[icent-1]), 0.12+dx1+0.25,0.889118,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.889118,1,15);
          
          if ( j == nPt ) 
              drawText(Form("p_{T}^{#gamma} < %dGeV, ", (int)PtBinPa[j-1]), 0.12+dx1+0.25,0.79,1,15);//yeonju 130823
          else
              drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)PtBinPa[j-1], (int)PtBinPa[j]), 0.12+dx1,0.79,1,15);//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();
              onSun(0,0,2,0);
              jumSun(1,0,1,1);
      }
  }

  c1 -> SaveAs("pPbData_xjgDistribution_pt_cent_dep.gif");
//cout<< "c11" << endl;
/*  TCanvas* c11 = new TCanvas("c11","xjgDist_onePanel_pt_cent_dep",500,500);
  for ( int j = 1 ; j <=nPt ; j++){
      for ( int icent = 1 ; icent<=nCentBinPa  ; icent++) {
          int iSpecies = kPADATA;
          int iglb = icent + iSpecies*50.;
          handsomeTH1(hxjgNorm[iSpecies][iglb][j],icent+3*(j-1));

          if ( icent == 1 && j == 1) hxjgNorm[iSpecies][iglb][j]->Draw();
          else     hxjgNorm[iSpecies][iglb][j]->Draw("same");
          onSun(0,0,2,0);
      }
  }

  c11 -> SaveAs("xjgDist_onePanel_by_pt_cent_dep.gif");
*/
  TCanvas* cDphi = new TCanvas("cDphi","",1200,350);
  makeMultiPanelCanvas(cDphi,5,1,0.0,0.0,0.2,0.15,0.02);

  TH1D* meanDphi[7][10];      // [iSpecies][pt]
  for (int j=1 ; j<=nPt  ; j++) {

          int iSpecies = kPADATA;
          meanDphi[iSpecies][j] = new TH1D(Form("meanDphi_iSpecies%d_pt%d",iSpecies,j), ";p_{T}^{#gamma} (GeV); <Dphi_{J#phi}>",nPt,AvePtBin);
  }

  for (int ipt=1 ; ipt<=nPt ; ipt++) {
      for (int icent=1 ; icent<= nCentBinPa ; icent++ ) { 
          int iSpecies = kPADATA;
          int iglb = icent + iSpecies*50.;

          if ( hdphi[iSpecies][iglb][ipt] == NULL ) 
              continue;   // emtpy histogram 

          meanDphi[iSpecies][ipt]->SetBinContent( ipt, hdphi[iSpecies][iglb][ipt]->GetMean() );
          meanDphi[iSpecies][ipt]->SetBinError  ( ipt, hdphi[iSpecies][iglb][ipt]->GetMeanError() );
      }
  }

  for ( int j = 1 ; j<=nPt ; j++){
      int icent=1;
      // for ( int icent = 1 ; icent<=nCentBinPa  ; icent++) {
      cDphi->cd(j-1);
      int iSpecies = kPADATA;
      int iglb = icent + iSpecies*50.;
      handsomeTH1(meanDphi[iSpecies][j]);
      meanDphi[iSpecies][j]->SetXTitle("#Delta#phi_{J,#gamma}");
      meanDphi[iSpecies][j]->Scale(1./meanDphi[iSpecies][j]->Integral("width"));
      meanDphi[iSpecies][j]->SetAxisRange(0.01,30,"Y");
      //    meanDphi[iSpecies][j]->SetMarkerStyle(24);
      //    handsomeTH1(meanDphi[iSpecies][j],icent+3*(j-1));
      meanDphi[iSpecies][j]->Draw();

      gPad->SetLogy();
      float dx1=0;    
 //     ((icent==1)||(icent==4))? dx1=0.15 : dx1=0 ;

      /*   if ( icent == nCentBinPa )
           drawText(Form("E_{T}^{HF|#eta|>4} > %dGeV", (int)centBinPa[icent-1]), 0.12+dx1+0.25,0.889118,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.889118,1,15);
           */   if ( j == nPt ) 
      drawText(Form("p_{T}^{#gamma} < %dGeV, ", (int)PtBinPa[j-1]), 0.12+dx1+0.25,0.79,1,15);//yeonju 130823
      else
          drawText(Form("%dGeV < p_{T}^{#gamma} < %dGeV, ", (int)PtBinPa[j-1], (int)PtBinPa[j]), 0.12+dx1,0.79,1,15);//yeonju 130823

      TLegend *l1 = new TLegend(0.6365615,0.6445304,0.9577623,0.846736,NULL,"brNDC");
      easyLeg(l1,"p+Pb 5.02TeV");
          if ( icent==1 && j==1)   l1->Draw();
     // }
  }
  cDphi -> SaveAs("pPbData_Dphi_distribution_by_pt_dep.pdf");
  
  TCanvas* c2 = new TCanvas("c2","xjg_rjg_vs_pt",800,400);
  c2->Divide(2,1);
  
  TH1D* hr[15];
  TH1D* hx[15];

  for(int j=1; j<=nFile ; j++){
      c2->cd(2);
      hr[j] = new TH1D(Form("hr%d",j),";E_{T}^{HF|#eta|>4} (GeV);r_{J,#gamma}",200,0,100);
      handsomeTH1(hr[j],j+1);
      hr[j]->SetAxisRange(0.01,1.1,"Y");
      //  hr->SetNdivisions(5);
      if (j ==1 ) {hr[j]->Draw();}
      else  { hr[j]->Draw("same");}
      
      if (j < 4) { 
      handsomeTGraph(gr[kPADATA][j],j+1);
          gr[kPADATA][j]->SetMarkerStyle(20);
          gr[kPADATA][j]->SetMarkerSize(1);
          gr[kPADATA][j]->Draw("same p");
      } else {  
      handsomeTGraph(gr[kPADATA][j],j-2);
          gr[kPADATA][j]->SetMarkerStyle(24);
          gr[kPADATA][j]->SetMarkerSize(1.5);
          gr[kPADATA][j]->Draw("same p");
      }

      jumSun(0,1,100,1);

      c2->cd(1);
      hx[j] = (TH1D*)hr[j]->Clone(Form("hx%d",j));
      handsomeTH1(hx[j],j+1);
      hx[j]->SetYTitle("<x_{J,#gamma}>");
      hx[j]->SetAxisRange(0.6,1.05,"Y");
      //  hx->SetNdivisions(5);
      if (j==1) {hx[j]->Draw();}
      else {hx[j]->Draw("same");}
      if (j < 4) { 
      handsomeTGraph(gx[kPADATA][j],j+1);
          gx[kPADATA][j]->SetMarkerStyle(20);
          gx[kPADATA][j]->SetMarkerSize(1);
          gx[kPADATA][j]->Draw("same p");
      } else {  
      handsomeTGraph(gx[kPADATA][j],j-2);
          gx[kPADATA][j]->SetMarkerStyle(24);
          gx[kPADATA][j]->SetMarkerSize(0.2);
          gx[kPADATA][j]->Draw("same p");
      }
      jumSun(0,1,100,1);
  
      TLegend *l1 = new TLegend(0.5226071,0.6300415,0.9597724,0.8332584,NULL,"brNDC");
      easyLeg(l1,"5.02TeV");
      l1->AddEntry(gr[kPADATA][j],"pPb ","p");
      l1->Draw();  }
  

      c2 -> SaveAs("pPbMC_and_Data_comparison_xjg_rjg.gif");
  /* 
  for(int j=1; j<=nPt ; j++){
      c2->cd(2*j);
      hr[j] = new TH1D(Form("hr%d",j),";E_{T}^{HF|#eta|>4} (GeV);r_{J,#gamma}",200,0,100);
      handsomeTH1(hr[j],1);
      hr[j]->SetAxisRange(0.01,1.1,"Y");
      //  hr->SetNdivisions(5);
      hr[j]->Draw();
      handsomeTGraph(gr[kPADATA][j],1);
      gr[kPADATA][j]->SetMarkerStyle(20+j);
      gr[kPADATA][j]->Draw("same p");
      jumSun(0,1,100,1);

      c2->cd(2*j-1);
      hx[j] = (TH1D*)hr[j]->Clone(Form("hx%d",j));
      handsomeTH1(hx[j],1);
      hx[j]->SetYTitle("<x_{J,#gamma}>");
      hx[j]->SetAxisRange(0.6,1.05,"Y");
      //  hx->SetNdivisions(5);
      hx[j]->Draw();
      handsomeTGraph(gx[kPADATA][j],1);
      gx[kPADATA][j]->SetMarkerStyle(20+j);
      gx[kPADATA][j]->Draw("same p");
      jumSun(0,1,100,1);

      TLegend *l1 = new TLegend(0.5226071,0.6300415,0.9597724,0.8332584,NULL,"brNDC");
      easyLeg(l1,"5.02TeV");
      l1->AddEntry(gr[kPADATA][j],"pPb ","p");
      l1->Draw();

      c2 -> SaveAs("x_Jgamma.gif");
  }*/
}
예제 #10
0
void mcClosure(bool  isFW=1, bool isPrompt=1) { 
  
  TString direction;   
  if (isFW) direction="FW";
  else direction     ="BW";
				    
  TH1::SetDefaultSumw2();

  TFile* f1;
  if ( isPrompt)  f1 = new TFile("/home/samba/songkyo/efficiency/PRMC_eff_rootFile/merged_PRMC_eff_Histos.root"); 
  else f1 = new TFile("/home/samba/songkyo/efficiency/NPMC_eff_rootFile/merged_NPMC_eff_Histos.root");
  
  //read-in tree
  TTree *mytree = (TTree*)f1->Get("myTree");
  
  TFile * fEff;
  if ( isPrompt) fEff = new TFile("EffAna_PRMC_boosted.root");
  else           fEff = new TFile("EffAna_NPMC_boosted.root");

  TH1D* hEff[10];
  hEff[0] = (TH1D*)fEff->Get(Form("h1D_EffDimu_pt_bin_%s",direction.Data()));
  hEff[1] = (TH1D*)fEff->Get(Form("h1D_EffDimu_pt_bin_%s_trig",direction.Data()));
  hEff[2] = (TH1D*)fEff->Get(Form("h1D_EffDimu_pt_bin_%s_mupl",direction.Data()));
  hEff[3] = (TH1D*)fEff->Get(Form("h1D_EffDimu_pt_bin_%s_mumi",direction.Data()));
  hEff[4] = (TH1D*)fEff->Get(Form("h1D_EffDimu_pt_bin_%s_jpsi",direction.Data()));
  hEff[5] = (TH1D*)fEff->Get(Form("h1D_EffDimu_pt_bin_%s_mass",direction.Data()));
  cout << "///////////////////////////////////////////////////////////////////////" << endl;
  cout << " Acceptance is calculated by YONGSUN's code not from Hyunchul's code" << endl;
  cout << "///////////////////////////////////////////////////////////////////////" << endl;
  TH1D* hAcc  = (TH1D*)fEff->Get(Form("h1D_Acc_pt_bin_%s",direction.Data()));
  
  
  for ( int i=0 ; i<=5 ;i++) {
    handsomeTH1(hEff[i],i+1);
  }

  /*
  TFile * fAcc;
  if ( isPrompt) fAcc = new TFile("AccAna_20131219_PromptJpsi_boosted_binCode_1.root");
  else fAcc = new TFile("AccAna_20131219_PromptJpsi_boosted_binCode_1.root");
  
  TH1D* hAcc  = (TH1D*)fAcc->Get(Form("h1D_Acc_pt_bin2_%s_20131219",direction.Data()));
  */
  
  TCanvas* c0 = new TCanvas("c0","",1000,500);
  c0->Divide(2,1);
  c0->cd(1);
  hEff[0]->SetXTitle("p_{T} (GeV)");
  hEff[0]->SetYTitle("Efficiency");
  hEff[0]->SetAxisRange(0,1.1,"Y");
  hEff[0]->Draw();
  for (int i=1; i<=4 ;i++) {
    hEff[i]->Draw("same");
  }
  jumSun(6.5,1,30,1);
  
  c0->cd(2);

  handsomeTH1(hAcc,1);
  hAcc->SetXTitle("p_{T} (GeV)");
  hAcc->SetYTitle("Acceptance");
 
  hAcc->SetAxisRange(0,1.1,"Y");
  hAcc->Draw();
  jumSun(6.5,1,30,1);
  

  TCanvas* c1 = new TCanvas("c1","",500,500);
  c1->cd();

  double ptBin[] = {6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 13.0, 16.0, 20.0, 30.0};
  const int nPtBin = sizeof(ptBin)/sizeof(double) - 1;
  TH1D* hptGen = new TH1D("hptGen",";J/psi p_{T} (GeV)",nPtBin,ptBin);
  TH1D* hptReco = (TH1D*)hptGen->Clone("hptReco");

  // Cuts
  TCut genRapCut, recoRapCut; 
  if (isFW) {
    genRapCut = "(Gen_QQ_4mom[0].Rapidity()>-2.4) && (Gen_QQ_4mom[0].Rapidity()<-.47)";
    recoRapCut = "(Reco_QQ_4mom[0].Rapidity()>-2.4) && (Reco_QQ_4mom[0].Rapidity()<-.47) &&  (Reco_QQ_mupl_4mom[0].Rapidity()>-2.4) && (Reco_QQ_mupl_4mom[0].Rapidity()<-.47) && (Reco_QQ_mumi_4mom[0].Rapidity()>-2.4) && (Reco_QQ_mumi_4mom[0].Rapidity()<-.47) && (Reco_QQ_trig&1)==1"; 
  }
  else {
    genRapCut = "Gen_QQ_4mom[0].Rapidity()>-.47 && Gen_QQ_4mom[0].Rapidity()<1.47";
    recoRapCut = "(Reco_QQ_4mom[0].Rapidity()>-.47) && (Reco_QQ_4mom[0].Rapidity()<1.47) && (Reco_QQ_mupl_4mom[0].Rapidity()>-.47 && Reco_QQ_mupl_4mom[0].Rapidity()<1.47) && (Reco_QQ_mumi_4mom[0].Rapidity()>-.47 && Reco_QQ_mumi_4mom[0].Rapidity()<1.47) && (Reco_QQ_trig&1)==1";
  }
  TCut recoMassCut = "Reco_QQ_4mom[0].M()>2.95 && Reco_QQ_4mom[0].M()<3.25";
  TCut recoAccCutPlus  = ""; //" Reco_QQ_mupl_4mom[0].Eta()>-2.4 && Reco_QQ_mupl_4mom[0].Eta()<1.47 &&   (  ( abs(Reco_QQ_mupl_4mom[0].Eta())>2.2 && abs(Reco_QQ_mupl_4mom[0].Eta())<2.4 && Reco_QQ_mupl_4mom[0].Pt()>0.8 )   || ( abs(Reco_QQ_mupl_4mom[0].Eta())>1.3 && abs(Reco_QQ_mupl_4mom[0].Eta())<=2.2 && Reco_QQ_mupl_4mom[0].P()>2.9 )  || ( abs(Reco_QQ_mupl_4mom[0].Eta())<=1.3 && Reco_QQ_mupl_4mom[0].Pt()>3.3 ) )";
  TCut recoAccCutMinus  = ""; //" Reco_QQ_mumi_4mom[0].Eta()>-2.4 && Reco_QQ_mumi_4mom[0].Eta()<1.47 &&   (  ( abs(Reco_QQ_mumi_4mom[0].Eta())>2.2 && abs(Reco_QQ_mumi_4mom[0].Eta())<2.4 && Reco_QQ_mumi_4mom[0].Pt()>0.8 )   || ( abs(Reco_QQ_mumi_4mom[0].Eta())>1.3 && abs(Reco_QQ_mumi_4mom[0].Eta())<=2.2 && Reco_QQ_mumi_4mom[0].P()>2.9 )  || ( abs(Reco_QQ_mumi_4mom[0].Eta())<=1.3 && Reco_QQ_mumi_4mom[0].Pt()>3.3 ) )";
  TCut recoAccCut = recoAccCutPlus && recoAccCutMinus;
  
  Long64_t nEntry = 100000000;
  mytree->Draw(Form("Gen_QQ_4mom[0].Pt()>>%s",hptGen->GetName()), genRapCut, "",nEntry);
  mytree->Draw(Form("Reco_QQ_4mom[0].Pt()>>%s",hptReco->GetName()), recoRapCut && recoMassCut && recoAccCut, "",nEntry);

  TH1D* hptRecoCorr = (TH1D*)hptReco->Clone("hptRecoCorr");
  hptRecoCorr->Divide(hEff[0]);
  hptRecoCorr->Divide(hAcc);
  

  handsomeTH1(hptGen,1);
  hptGen->SetAxisRange(1,1.5e5,"Y");
  
  hptGen->Draw("hist");
  handsomeTH1(hptReco,2);
  hptReco->SetMarkerStyle(24);
  hptReco->Draw("same");
  handsomeTH1(hptRecoCorr,2);
  hptRecoCorr->Draw("same");
  
  TLegend *l = new TLegend(0.4233871,0.5042373,0.8689516,0.7521186,NULL,"brNDC");
  easyLeg(l,"Yield");
  l->AddEntry(hptGen,"Generated J/#psi","l");
  l->AddEntry(hptReco,"Reco yield","p");
  l->AddEntry(hptRecoCorr,"Reco/(Acc*Eff)","p");
  l->Draw();
}
예제 #11
0
void finalPlotsGammaTrack () {
  
  TH1D* hDphiF[5][10];
  TH1D* hXawayF[5][10];
  TH1D* hPtAwayF[5][10];

  TFile* inf = new TFile("photonTrackOutput_photonPt50GeV.root");
  for ( int icent =1 ; icent<=nCent_std ; icent++) {
    hXawayF[icent][kHIDATA] = (TH1D*)inf->Get(Form("hidata_icent%d_hTrkXAway_final",icent));
    handsomeTH1(hXawayF[icent][kHIDATA],color[icent]);
    hXawayF[icent][kHIMC] = (TH1D*)inf->Get(Form("himc_icent%d_hTrkXAway_final",icent));
    handsomeTH1(hXawayF[icent][kHIMC],color[icent]);

    TH1ScaleByWidth(hXawayF[icent][kHIDATA]);
    TH1ScaleByWidth(hXawayF[icent][kHIMC]);

  }
  
  TCanvas* c100 = new TCanvas("c100","",1000,500);
  c100->Divide(2,1);
  c100->cd(2);
  TH1D* htemp100 = (TH1D*)hXawayF[1][kHIDATA]->Clone("htemp100");
  htemp100->Reset();
  handsomeTH1(htemp100,1);
  htemp100->SetAxisRange(0.01,1e2,"Y");
  htemp100->SetYTitle("dN_{track}/dx_{T#gamma}   per #gamma");
  htemp100->DrawCopy();
  gPad->SetLogy();
  for ( int icent =1 ; icent<=nCent_std ; icent++) {
    hXawayF[nCent_std+1-icent][kHIDATA]->Draw("same");
  }  
  TLegend* l1 = new TLegend(0.4979083,0.4978381,0.9999163,0.7767209,NULL,"brNDC");
  easyLeg(l1,"");
  for ( int icent = nCent_std ; icent>=1 ; icent--) {
    int lowCent = centBin_std[icent-1];
    int highCent = centBin_std[icent]-1;
    l1->AddEntry(hXawayF[icent][kHIDATA], Form("%.0f%% - %.0f%%", float((float)lowCent*2.5), float((float)(highCent+1)*2.5)));
  } 

  drawText("CMS Preliminary",0.5,0.83,1);
  drawText("PbPb #int L dt = ~150 #mub^{-1}",0.5,0.75,1);
  
  c100->cd(1);
  htemp100->DrawCopy();
  gPad->SetLogy();
  for ( int icent =1 ; icent<=nCent_std ; icent++) {
    hXawayF[nCent_std+1-icent][kHIMC]->Draw("same");
  }
  drawText("MC",0.5,0.83,1);
  drawText("PYTHIA+HYDJET",0.5,0.75,1);
  l1->Draw();

  int percentBin[5] = {0,10,30,50,100};

  TCanvas* c102 = new TCanvas("c102","",1000,350);
  makeMultiPanelCanvas(c102,4,1,0.0,0.0,0.24,0.15,0.02);
  htemp100->SetYTitle("DATA/MC");
  htemp100->SetAxisRange(0,2,"Y");
  htemp100->SetNdivisions(505);
  for ( int icent =1 ; icent<=nCent_std ; icent++) {
    c102->cd(nCent_std+1-icent);
    htemp100->DrawCopy();
    jumSun(0,1,1,1);
    TH1D* tempRatio =  (TH1D*)hXawayF[icent][kHIDATA]->Clone(Form("tempRatio_icent%d",icent));
    tempRatio->Divide(hXawayF[icent][kHIMC]);
    tempRatio->Draw("same");
    if ( icent ==4 ) {
      drawText("CMS Preliminary",0.4,0.91,1,16);
      drawText("PbPb #int L dt = ~150 #mub^{-1}",0.4,0.82,1,16);
    }
    drawText(Form("%d%% - %d%%",percentBin[icent-1],percentBin[icent]),0.4,0.73,1,16);
  }
  
  
}