void drawPbPb_pp_subEnergy( 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* hGenJetPt[7][10][6]; // [Collision][centrality][pt]
    TH1D* hIaa[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* meanGenJetPt[7][10];      // [Collisi on][centrality]

    TH1D* rjg[7][5];     //  [Collision][centrality]
    TH1D* rGenjg[7][5];     //  [Collision][centrality]
    for (int icoll=0 ; icoll<4  ; icoll++) {   // only pp and PbPb
        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);
            meanGenJetPt[icoll][icent] = new TH1D( Form("meanGenJetPt_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);
            rGenjg[icoll][icent] = new TH1D( Form("rGenjg_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;
                hGenJetPt[icoll][icent][ipt] = NULL;
                hIaa[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<4 ; icoll++) {
            TString sampleName = getSampleName( icoll ) ;
            char* fname =  Form("ffFilesEnergySub/photonTrackCorr_%s_output_photonPtThr%d_to_%d_jetPtThr30_20130917.root",sampleName.Data(), (int)ptBin[ipt-1], (int)ptBin[ipt]);
            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;
                    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%2 == 1)  {  // if it is MC
                        hGenJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("genJetPt_icent%d_final", icent)) ;
                        cout << " Getting histogram : " << Form("genJetPt_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;
                        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;
                        if ( icoll%2 == 1)  {  // if it is MC
                            hGenJetPt[icoll][icent][ipt] = (TH1D*)histFile[icoll][ipt]->Get(Form("genJetPt_icent%d_final",centBinHI[icent]));
                            cout << " Getting histogram : " << Form("genJetPt_icent%d_final", centBinHI[icent] ) << endl;
                        }
                    }
                }
            }
            else
                cout << " no such file " << endl;
        }
    }

    for (int ipt=1 ; ipt<=nPtBin ; ipt++) {
        for (int icoll=0 ; icoll<4 ; 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() );

                if ( icoll%2 == 1)  {  // if it is MC
                    meanGenJetPt[icoll][icent]->SetBinContent( ipt, hGenJetPt[icoll][icent][ipt]->GetMean() );
                    meanGenJetPt[icoll][icent]->SetBinError  ( ipt, hGenJetPt[icoll][icent][ipt]->GetMeanError() );
                    rVal = hGenJetPt[icoll][icent][ipt]->IntegralAndError(1, hGenJetPt[icoll][icent][ipt]->GetNbinsX(), rErr, "width");
                    rGenjg[icoll][icent]->SetBinContent( ipt, rVal );
                    rGenjg[icoll][icent]->SetBinError  ( ipt, rErr );

                }

            }
        }
    }

    TH1D* hTempPt = new TH1D("hTemp",";p_{T}^{Jet} (GeV);#frac{dN}{dp_{T}} #frac{1}{N}",200,10,150);
    hTempPt->SetAxisRange(30,150,"X");
    hTempPt->SetAxisRange(0,0.05,"Y");
    hTempPt->GetYaxis()->SetTitleOffset(1.35);
    handsomeTH1(hTempPt,0);

    TCanvas* c2 = new TCanvas("c2_jetPt","",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->DrawCopy();
        hJetPt[kPPMC][7][ipt]->Scale(1./rjg[kPPMC][7]->GetBinContent(ipt)); // rjg normalization
        handsomeTH1(hJetPt[kPPMC][7][ipt], 1);
        hJetPt[kPPMC][7][ipt]->SetMarkerStyle(24);
        hJetPt[kPPMC][7][ipt]->Draw("same hist");
        // draw pbpb
        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(hJetPt[kHIMC][icent][ipt],kRed);
            hJetPt[kHIMC][icent][ipt]->Scale(1./rjg[kHIMC][icent]->GetBinContent(ipt));  // rjg normalization
            if ( icent == 2 ) hJetPt[kHIMC][icent][ipt]->SetMarkerStyle(24);

            if ( icent == 2 ) hJetPt[kHIMC][icent][ipt]->Draw("same hist");
            if ( icent == 1 ) hJetPt[kHIMC][icent][ipt]->Draw("same");

        }

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

        if ( ipt == nPtBin )  {
            TLegend *l0 = new TLegend(0.1542202,0.4928762,0.9769094,0.7803873,NULL,"brNDC");
            easyLeg(l0,"MC  2.76TeV");
            l0->AddEntry(hJetPt[kPPMC][7][ipt],"PYTHIA   pp ","l");
            l0->AddEntry(hJetPt[kHIMC][2][ipt],"PYTHIA+HYDJET 30-100%","l");
            l0->AddEntry(hJetPt[kHIMC][1][ipt],"PYTHIA+HYDJET 0-30%","p");
            l0->Draw();
        }

        onSun(30,0,200,0);
    }


    TCanvas* c3 = new TCanvas("c3_GenjetPt","",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
        hTempPt->DrawCopy();
        hGenJetPt[kPPMC][7][ipt]->Scale(1./rGenjg[kPPMC][7]->GetBinContent(ipt)); // rjg normalization
        handsomeTH1(hGenJetPt[kPPMC][7][ipt], 1);
        hGenJetPt[kPPMC][7][ipt]->SetMarkerStyle(24);
        hGenJetPt[kPPMC][7][ipt]->Draw("same hist");
        // draw pbpb
        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(hGenJetPt[kHIMC][icent][ipt],kRed);
            hGenJetPt[kHIMC][icent][ipt]->Scale(1./rGenjg[kHIMC][icent]->GetBinContent(ipt));  // rjg normalization
            if ( icent == 2 ) hGenJetPt[kHIMC][icent][ipt]->SetMarkerStyle(24);

            if ( icent == 2 ) hGenJetPt[kHIMC][icent][ipt]->Draw("same hist");
            if ( icent == 1 ) hGenJetPt[kHIMC][icent][ipt]->Draw("same");

        }

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

        if ( ipt == nPtBin )  {
            TLegend *l0 = new TLegend(0.1542202,0.4928762,0.9769094,0.7803873,NULL,"brNDC");
            easyLeg(l0,"Gen Jet Used");
            l0->AddEntry(hGenJetPt[kPPMC][7][ipt],"PYTHIA   pp ","l");
            l0->AddEntry(hGenJetPt[kHIMC][2][ipt],"PYTHIA+HYDJET 30-100%","l");
            l0->AddEntry(hGenJetPt[kHIMC][1][ipt],"PYTHIA+HYDJET 0-30%","p");
            l0->Draw();
        }

        onSun(30,0,200,0);
    }



    TCanvas* c101 = new TCanvas("c101_xjg","",1200,350);
    makeMultiPanelCanvas(c101,nPtBin,1,0.0,0.0,0.2,0.15,0.02);
    TH1D* hTempXjg = new TH1D("htempxjg",";x_{J#gamma};#frac{dN}{dp_{T}} #frac{1}{N}",200,0,2);
    hTempXjg->SetAxisRange(0,2,"X");
    hTempXjg->SetAxisRange(0,3,"Y");
    hTempXjg->GetYaxis()->SetTitleOffset(1.35);
    handsomeTH1(hTempXjg,0);

    for ( int ipt = 1 ; ipt<=nPtBin  ; ipt++) {

        c101->cd(ipt);

        // draw pp
        hTempXjg->DrawCopy();
        hxjg[kPPMC][7][ipt]->Scale(1./rjg[kPPMC][7]->GetBinContent(ipt)); // rjg normalization
        handsomeTH1(hxjg[kPPMC][7][ipt], 1);
        hxjg[kPPMC][7][ipt]->SetMarkerStyle(24);
        hxjg[kPPMC][7][ipt]->Draw("same hist");
        // draw pbpb
        for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
            handsomeTH1(hxjg[kHIMC][icent][ipt],kRed);
            hxjg[kHIMC][icent][ipt]->Scale(1./rjg[kHIMC][icent]->GetBinContent(ipt));  // rjg normalization
            if ( icent == 2 ) hxjg[kHIMC][icent][ipt]->SetMarkerStyle(24);

            if ( icent == 2 ) hxjg[kHIMC][icent][ipt]->Draw("same hist");
            if ( icent == 1 ) hxjg[kHIMC][icent][ipt]->Draw("same");

        }


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

        if ( ipt == nPtBin )  {
            TLegend *l0 = new TLegend(-0.0007607977,0.6729655,0.8215427,0.9383604,NULL,"brNDC");
            easyLeg(l0,"MC  2.76TeV");
            l0->AddEntry(hxjg[kPPMC][7][ipt],"PYTHIA   pp ","l");
            l0->AddEntry(hxjg[kHIMC][2][ipt],"PYTHIA+HYDJET 30-100%","l");
            l0->AddEntry(hxjg[kHIMC][1][ipt],"PYTHIA+HYDJET 0-30%","p");
            l0->Draw();
        }

        onSun(30,0,200,0);
    }


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

    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
        handsomeTH1(meanXjg[kHIMC][icent],kRed);
        if ( icent == 2 ) meanXjg[kHIMC][icent]->SetMarkerStyle(24);
        meanXjg[kHIMC][icent]->Draw("same");
    }

    if (1 == 1) {
        TLegend *l1mc = new TLegend(0.3387097,0.6864407,0.8729839,0.9004237,NULL,"brNDC");
        easyLeg(l1mc,"MC  2.76TeV");
        l1mc->AddEntry(meanXjg[kPPMC][7],"PYTHIA   pp ","l");
        l1mc->AddEntry(meanXjg[kHIMC][2],"PYTHIA+HYDJET 30-100%","l");
        l1mc->AddEntry(meanXjg[kHIMC][1],"PYTHIA+HYDJET 0-30%","p");
        l1mc->Draw();
    }

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

    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
        handsomeTH1(meanJetPt[kHIMC][icent],kRed);
        if ( icent == 2 ) meanJetPt[kHIMC][icent]->SetMarkerStyle(24);
        meanJetPt[kHIMC][icent]->Draw("same");
    }

    if (1 == 1) {
        TLegend *l1mc = new TLegend(0.3810484,0.1864407,0.891129,0.4004237,NULL,"brNDC");
        easyLeg(l1mc,"MC  2.76TeV");
        l1mc->AddEntry(meanJetPt[kPPMC][7],"PYTHIA   pp ","p");
        l1mc->AddEntry(meanJetPt[kHIMC][2],"PYTHIA+HYDJET 30-100%","p");
        l1mc->AddEntry(meanJetPt[kHIMC][1],"PYTHIA+HYDJET 0-30%","p");
        l1mc->Draw();
    }

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

    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
        handsomeTH1(meanGenJetPt[kHIMC][icent],kRed);
        if ( icent == 2 ) meanGenJetPt[kHIMC][icent]->SetMarkerStyle(24);
        meanGenJetPt[kHIMC][icent]->Draw("same");
    }

    if (1 == 1) {
        TLegend *l1mc = new TLegend(0.3810484,0.1864407,0.891129,0.4004237,NULL,"brNDC");
        easyLeg(l1mc,"Gen Jet Used");
        l1mc->AddEntry(meanGenJetPt[kPPMC][7],"PYTHIA   pp ","p");
        l1mc->AddEntry(meanGenJetPt[kHIMC][2],"PYTHIA+HYDJET 30-100%","p");
        l1mc->AddEntry(meanGenJetPt[kHIMC][1],"PYTHIA+HYDJET 0-30%","p");
        l1mc->Draw();
    }

    TCanvas* c34 = new TCanvas("c34","",500,500);
    handsomeTH1(rjg[kPPMC][7], 1);
    rjg[kPPMC][7]->SetYTitle("r_{j#gamma}  (>30GeV)");
    rjg[kPPMC][7]->SetMarkerStyle(24);
    //  rjg[kPPMC][7]->SetAxisRange(-2,2,"X");
    rjg[kPPMC][7]->SetAxisRange(.2,1,"Y");
    rjg[kPPMC][7]->Draw();

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

    if (1 == 1) {
        TLegend *l1mc = new TLegend(0.3810484,0.1864407,0.891129,0.4004237,NULL,"brNDC");
        easyLeg(l1mc,"MC  2.76TeV");
        l1mc->AddEntry(rjg[kPPMC][7],"PYTHIA   pp ","p");
        l1mc->AddEntry(rjg[kHIMC][2],"PYTHIA+HYDJET 30-100%","p");
        l1mc->AddEntry(rjg[kHIMC][1],"PYTHIA+HYDJET 0-30%","p");
        l1mc->Draw();
    }

    TCanvas* c34_genJet = new TCanvas("c34_genJet","",500,500);
    handsomeTH1(rGenjg[kPPMC][7], 1);
    rGenjg[kPPMC][7]->SetYTitle("r_{j#gamma}  (>30GeV)");
    rGenjg[kPPMC][7]->SetMarkerStyle(24);
    //  rGenjg[kPPMC][7]->SetAxisRange(-2,2,"X");
    rGenjg[kPPMC][7]->SetAxisRange(.2,1,"Y");
    rGenjg[kPPMC][7]->Draw();

    for ( int icent = 1; icent <= nCentBinHI ; icent++ ) {
        handsomeTH1(rGenjg[kHIMC][icent],kRed);
        if ( icent == 2 ) rGenjg[kHIMC][icent]->SetMarkerStyle(24);
        rGenjg[kHIMC][icent]->Draw("same");
    }

    if (1 == 1) {
        TLegend *l1mc = new TLegend(0.3810484,0.1864407,0.891129,0.4004237,NULL,"brNDC");
        easyLeg(l1mc,"Gen Jet Used");
        l1mc->AddEntry(rGenjg[kPPMC][7],"PYTHIA   pp ","p");
        l1mc->AddEntry(rGenjg[kHIMC][2],"PYTHIA+HYDJET 30-100%","p");
        l1mc->AddEntry(rGenjg[kHIMC][1],"PYTHIA+HYDJET 0-30%","p");
        l1mc->Draw();
    }


}
예제 #2
0
void CompareDifftheta(){

const int npt24=9;
const double pt[npt24]={0.4,0.7,1.2,1.7,2.2,2.7,3.4,4.4,5.4};
const double v24[5][npt24]={
{0.02809,0.04599,0.06869,0.08440,0.09715,0.09357,0.07924,0.04701,0.01620},
{0.02682,0.04447,0.06771,0.08586,0.09932,0.09782,0.08714,0.06139,0.05068},
{0.02582,0.04324,0.06644,0.08396,0.09725,0.1032,0.09603,0.07668,0.0605},
{0.02507,0.04214,0.06471,0.08294,0.09241,0.09917,0.09663,0.08479,0.06271},
};
const double v24err[5][npt24]={
{0.0007,0.00057,0.00085,0.0014,0.0022,0.0034,0.0041,0.0072,0.011},
{0.00058,0.00043,0.00063,0.00099,0.0016,0.0025,0.0031,0.0054,0.0086},
{0.00053,0.00038,0.00056,0.00088,0.0014,0.0022,0.0027,0.0049,0.0076},
{0.00079,0.00057,0.00084,0.0013,0.002,0.0032,0.004,0.0075,0.012},
};

//TString dirname = "PFcandpt03to6tracknormcpt03to6";TString name = "PFcandi03to6";
//TString dirname = "PFcandpt01to10tracknormcpt03to6";
//TString dirname = "tracknormcpt03to6"; TString name = "trackpt03to6";
TString dirname = "tracknormcpt03to3tracknormcpt03to6"; TString name = "trackpt03to3";

c1 = new TCanvas("c1"," ",1200,700);
makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03);
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    gStyle->SetErrorX(0);
    TH1D *hFrame = new TH1D("","",80,-1,7);
    hFrame->SetTitle("v_{2} vs momentum");
    hFrame->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    hFrame->GetYaxis()->SetTitle("v_{2}");	
    hFrame->GetXaxis()->SetTitleSize(0.04);
    hFrame->GetYaxis()->SetTitleSize(0.04);
    hFrame->GetXaxis()->SetRangeUser(-0.3,6.3);
    hFrame->SetMaximum(0.2);

for(int i=0;i<ntotbin;i++){
	c1->cd(i+1);
	if(i!=ntotbin-1)
	TGraphErrors *gr24=new TGraphErrors(npt24,pt,v24[i],0,v24err[i]);
	TGraphErrors *grProd_theta8=plotTG(i,0,10,dirname,20,2);
	TGraphErrors *grProd_theta15=plotTG(i,0,15,dirname,27,2);
	TGraphErrors *grProd=plotTG(i,0,5,dirname,24,4);
	gr24->SetMarkerSize(1.3);
	gr24->SetMarkerColor(1);
	gr24->SetMarkerStyle(20);
	hFrame->Draw();
	gr24->Draw("Psame");
	grProd_theta8->Draw("Psame");
	grProd_theta15->Draw("Psame");
	grProd->Draw("Psame");
	TLegend *tl = new TLegend(0.4,0.5,0.7,0.70);
	tl->SetFillColor(0);
	tl->SetBorderSize(0);
	tl->SetTextSize(0.05);
	tl->AddEntry(gr24,"v2 4-particle cum","lp");
	tl->AddEntry(grProd_theta8,"LYZ n_{#theta} = 10","lp");
	tl->AddEntry(grProd_theta15,"LYZ n_{#theta} = 15","lp");
	tl->AddEntry(grProd,"LYZ n_{#theta} = 5","lp");
	if(i==0 || i==3) 
		TLatex *tlx2 = new TLatex(0.3,0.8,Form("%d<Ntrkoffline<%d",trkpointmin[i],trkpointmax[i]));
	else
		TLatex *tlx2 = new TLatex(0.1,0.8,Form("%d<Ntrkoffline<%d",trkpointmin[i],trkpointmax[i]));
	tlx2->SetNDC();
	tlx2->Draw("same");
	}
	c1->cd(ntotbin+1);
	TLatex *tlx0 = new TLatex(0.12,0.3,Form("%s",dirname.Data()));
        TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0));
	tlx0->SetNDC();
	tlx1->SetNDC();
	tlx0->SetTextSize(0.045);
	tlx1->SetTextSize(0.045);
	tlx2->SetTextSize(0.045);
	hFrame->Draw();
	tlx0->Draw("same");
	tlx1->Draw("same");
	tl->Draw("same");
	c1->Print(Form("v2vspt_difftheta_%s.png",name.Data()));

}
예제 #3
0
void MptAjPlotInConeOutCone(
)
{
   TH1::SetDefaultSumw2();

//    TString inputFile_mc="fig/06.21HIN_loop/HisMc_icPu5_trkHPCorr_120_50_2094_eta24.root";
//    TString inputFile_data="fig/06.21HIN_loop/HisData_icPu5_trkHPCorr_120_50_2094_eta24.root";
//    TString inputFile_mc="fig/06.25_simtrkloop_olderforest/HisMc_icPu5_trkHPCorr_120_50_2094_eta24_prec1.root";
//    TString inputFile_data="fig/06.25_simtrkloop_olderforest/HisData_icPu5_trkHPCorr_120_50_2094_eta24_prec1.root";
//    TString inputFile_mc="fig/06.25HIN_loop/HisMc_icPu5_trkHPCorr_120_50_2094_eta24.root";
//    TString inputFile_data="fig/06.25HIN_loop/HisData_icPu5_trkHPCorr_120_50_2094_eta24.root";
//    TString inputFile_mc="fig/06.26_genploop/HisMc_icPu5_trkHPCorr_120_50_2094_eta24_prec0.root";
//    TString inputFile_data="fig/06.26_genploop/HisData_icPu5_trkHPCorr_120_50_2094_eta24_prec4.root";
//    TString inputFile_mc="fig/06.26_genploop/HisMc_icPu5_trkHPCorr_120_50_2749_eta24_prec0.root";
//    TString inputFile_data="fig/06.26_genploop/HisData_icPu5_trkHPCorr_120_50_2749_eta24_prec4.root";
   TString inputFile_mc="fig/06.26_tree/HisMc_icPu5_trkHPCorr_120_50_2749_eta24_prec4.root";
   TString inputFile_data="fig/06.26_tree/HisData_icPu5_trkHPCorr_120_50_2749_eta24_prec4.root";

   string path=inputFile_data.Data();
   TString outdir = path.substr(0, path.find_last_of('/'));
   cout << "Output: " << outdir << endl;
   gSystem->mkdir(outdir,kTRUE);

   float coneSize = 0.8;
   TString tag = Form("CorrRes%d-data-mcRec",doResCorr);

   Float_t leftMargin=0.28,bottomMargin=0.18;
   TCanvas *c1 = new TCanvas("c1","",1000,1000);
   makeMultiPanelCanvas(c1,2,2,0.0,0.0,leftMargin,bottomMargin,0.02);
//    TCanvas *c1 = new TCanvas("c1","",1000,500);
//    makeMultiPanelCanvas(c1,2,1,0.0,0.0,leftMargin,bottomMargin,0.02);

   c1->cd(1);
   balanceMetVsAj(inputFile_mc,"0to12","InCone",false,false);
   drawText("PYTHIA+HYDJET 0-30%",0.33,0.82);
   drawText("In-Cone",0.85,0.9);
   drawText(Form("#DeltaR<%.1f",coneSize),0.85,0.9-0.06);
//    drawText("(a)",0.31,0.91);
   gPad->RedrawAxis();
   
   c1->cd(2);
   balanceMetVsAj(inputFile_mc,"0to12","OutCone",true,false);
   drawText("Out-of-Cone",0.7,0.9);
   drawText(Form("#DeltaR#geq%.1f",coneSize),0.7,0.9-0.06);
   drawText("(b)",0.04,0.91);
   float ptx(0.08),pty1(0.22);
   drawText("p_{T,1}  > 120GeV/c",ptx,pty1);
   drawText("p_{T,2}  > 50GeV/c",ptx,pty1-0.07);
   drawText("#Delta#phi_{1,2}>  #frac{7}{8}#pi",ptx,pty1-0.14);
//    drawText("#Delta#phi_{1,2}>  #frac{5}{6}#pi",ptx,pty1-0.14);
   drawText("|#eta_{1,2}| < 1.6",ptx+0.20,pty1-0.14);
   gPad->RedrawAxis();
   
   c1->cd(3);
   balanceMetVsAj(inputFile_data,"0to12","InCone",false,false);
//    float ptx(0.33),pty1(0.35);
//    drawText("p_{T,1}  > 120GeV/c",ptx,pty1);
//    drawText("p_{T,2}  > 50GeV/c",ptx,pty1-0.07);
//    drawText("#Delta#phi_{1,2}>  #frac{2}{3}#pi",ptx,pty1-0.14);
   drawText("CMS 0-30%",0.33,0.90);
   drawText("Pb+Pb  #sqrt{s}_{_{NN}}=2.76 TeV",0.33,0.84);
   drawText("#intL dt = 150 #mub^{-1}",0.33,0.78);
   drawText("In-Cone",0.85,0.93);
   drawText(Form("#DeltaR<%.1f",coneSize),0.85,0.93-0.06);
//    drawText("(c)",0.31,0.95);
   gPad->RedrawAxis();
   
   c1->cd(4);
   balanceMetVsAj(inputFile_data,"0to12","OutCone",false,false);
   drawText("Out-of-Cone",0.7,0.93);
   drawText(Form("#DeltaR#geq%.1f",coneSize),0.7,0.93-0.06);
//    drawText("(d)",0.04,0.95);
   gPad->RedrawAxis();
   
   c1->SaveAs(Form("%s/Mpt_InConeOutCone%.0f_%s.pdf",outdir.Data(),coneSize*10,tag.Data()));
   c1->SaveAs(Form("%s/Mpt_InConeOutCone%.0f_%s.gif",outdir.Data(),coneSize*10,tag.Data()));
}
예제 #4
0
void plotcorr_4p_pt_compMC(){
//TString dire = "north";
TString dire = "south";
TString coll = "pAu";
//TString corr = "cntbbc150M";
TString corr = "cntbbcmbtrig2B";
//TString corr = "cntbbc";
c1 = new TCanvas("c1"," ",800,460);
makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03);
c2 = new TCanvas("c2"," ",800,460);
makeMultiPanelCanvas(c2,3,2,0,0,0.25,0.2,0.03);
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetStripDecimals(0);
  gStyle->SetErrorX(0);
  float const PI = acos(-1.0);
  const int npt = 10;
  const int ncent = 10;
  const int ncentd = 8;
 // TFile *f=TFile::Open(Form("../../MCgen/PHHijing/Nonflow/mergedAnav2%s%s.root",coll.Data(),corr.Data()));
  TFile *f=TFile::Open(Form("../../MCgen/PHHijing/Nonflow/mergedAna%s%s.root",coll.Data(),corr.Data()));
  TFile *fdata=TFile::Open(Form("merged_AnapAumbcentral_PC3Sigma2.root"));
  //TFile *f=TFile::Open(Form("mergedAna%s%s.root",coll.Data(),corr.Data()));
  ofstream fout;
  if(!corr.Contains("bbc"))
  fout.open(Form("Yjet%s_pt.dat",coll.Data()));
TH1F* kforebbcw[npt][ncent];
TH1F* hforebbcw[npt][ncent];
TH1F* kbackbbcw2[npt][ncent];
TH1F* kforebbcw_centIn[npt];
TH1F* hforebbcw_centIn[npt];
TH1F* kbackbbcw2_centIn[npt];
TH1F* kforebbcwd[npt][ncent];
TH1F* hforebbcwd[npt][ncent];
TH1F* kbackbbcw2d[npt][ncent];
TH1F* kforebbcw_centInd[npt];
TH1F* hforebbcw_centInd[npt];
TH1F* kbackbbcw2_centInd[npt];
double ptbin[npt+1] = {0.2,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0};
//double centbin[ncent+1] = {0,1,5,10,20,30,40,60,84}; //fvtx or cent
double centbin[ncent+1] = {100.00,97.51,92.65,85.92,78.00,69.62,53.55,33.84,15.74,5.89,0.00};
//double centbin[ncent+1] = {100.00,0.00};
//double bbccentbin[ncent+1] = {200.0,39.3,27.0,21.4,15.6,9.5,5.8,2.9,0.0}; //fvtx mb cent
//double centbin[ncent] = {108,83.3333,75,56.6667,48.6667,40,29.6667,21.6667,0}; //fvtx or
// double centbin[ncent] = {110,85.3333,77.3333,59.3333,51.6667,43,32.6667,25.3333,0};   //fvtx south
double bbccentbin[ncent+1] = {0,1,2,3,4,5,7,10,14,18,40};
//double bbccentbin[ncent+1] = {0,40};
//double bbccentbin[ncent+1] = {0,1,2,3,5,7,9,12,16,21,100}; //dAu
//double bbccentbin[ncent+1] = {0,2,4,6,8,11,16,20,26,30,100}; //HeAu
 //        
//  double centbin[ncent] = {152.333,118.333,102.333,69.6667,57.3333,45,31,21,0};   //fvtx and
/*double centmin = 1.0; double centmax = 3.0;//has to be boundary
for(int ipt=0; ipt<ncent; ipt++){
if(centmin >= centbin[ipt] && centmin < centbin[ipt+1]){int xcentmin = ipt; continue;}
if(centmax >= centbin[ipt] && centmax < centbin[ipt+1]){int xcentmax = ipt; continue;}
}*/
for(int icent_a=0;icent_a<1;icent_a++){
    if(coll.Contains("Au")){
int xcentmin = icent_a*1+9;
int xcentmind = icent_a*1;
int xcentmax = icent_a*1+10;
int xcentmaxd = icent_a*1+2;
    }
    else{
int xcentmin = icent_a*1;
int xcentmax = (icent_a+1)*10;
int xcentmaxd = (icent_a+1)*6;
    }
double centmin = centbin[xcentmin];
double centmax = centbin[xcentmax];

for(int ipt=0; ipt<npt; ipt++){
for(int icent=0; icent<ncent; icent++){
kforebbcw[ipt][icent] = (TH1F*)f->Get(Form("kfore%sbbc_%d_%d",dire.Data(),icent,ipt));
hforebbcw[ipt][icent] = (TH1F*)f->Get(Form("hfore%sbbc_%d_%d",dire.Data(),icent,ipt));
kbackbbcw2[ipt][icent] = (TH1F*)f->Get(Form("kback%sbbc2_%d_%d",dire.Data(),icent,ipt));
    if(!coll.Contains("Au")){
htemp = (TH1F*)f->Get(Form("kforenorthbbc_%d_%d",icent,ipt));
kforebbcw[ipt][icent]->Add(htemp);
htemp = (TH1F*)f->Get(Form("hforenorthbbc_%d_%d",icent,ipt));
hforebbcw[ipt][icent]->Add(htemp);
htemp = (TH1F*)f->Get(Form("kbacknorthbbc2_%d_%d",icent,ipt));
kbackbbcw2[ipt][icent]->Add(htemp);
    }
}
for(int icent=0; icent<ncentd; icent++){
kforebbcwd[ipt][icent] = (TH1F*)fdata->Get(Form("kfore%sbbcw_%d_%d",dire.Data(),icent,ipt));
hforebbcwd[ipt][icent] = (TH1F*)fdata->Get(Form("hfore%sbbcw_%d_%d",dire.Data(),icent,ipt));
kbackbbcw2d[ipt][icent] = (TH1F*)fdata->Get(Form("kback%sbbcw2_%d_%d",dire.Data(),icent,ipt));
    if(!coll.Contains("Au")){
htemp = (TH1F*)fdata->Get(Form("kforenorthbbcw_%d_%d",icent,ipt));
kforebbcwd[ipt][icent]->Add(htemp);
htemp = (TH1F*)fdata->Get(Form("hforenorthbbcw_%d_%d",icent,ipt));
hforebbcwd[ipt][icent]->Add(htemp);
htemp = (TH1F*)fdata->Get(Form("kbacknorthbbcw2_%d_%d",icent,ipt));
kbackbbcw2d[ipt][icent]->Add(htemp);
    }
}
kforebbcw_centIn[ipt] = (TH1F*)kforebbcw[ipt][xcentmin]->Clone();
hforebbcw_centIn[ipt] = (TH1F*)hforebbcw[ipt][xcentmin]->Clone();
kbackbbcw2_centIn[ipt] = (TH1F*)kbackbbcw2[ipt][xcentmin]->Clone();
kforebbcw_centInd[ipt] = (TH1F*)kforebbcw[ipt][xcentmin]->Clone();
hforebbcw_centInd[ipt] = (TH1F*)hforebbcw[ipt][xcentmin]->Clone();
kbackbbcw2_centInd[ipt] = (TH1F*)kbackbbcw2[ipt][xcentmin]->Clone();
for(int icent=xcentmin+1; icent<xcentmax; icent++){
kforebbcw_centIn[ipt]->Add(kforebbcw[ipt][icent]);
hforebbcw_centIn[ipt]->Add(hforebbcw[ipt][icent]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2[ipt][icent]);
}
for(int icent=xcentmind+1; icent<xcentmaxd; icent++){
kforebbcw_centInd[ipt]->Add(kforebbcwd[ipt][icent]);
hforebbcw_centInd[ipt]->Add(hforebbcwd[ipt][icent]);
kbackbbcw2_centInd[ipt]->Add(kbackbbcw2d[ipt][icent]);
}
kforebbcw_centIn[ipt]->Rebin(2);
hforebbcw_centIn[ipt]->Rebin(2);
kbackbbcw2_centIn[ipt]->Rebin(2);
kforebbcw_centInd[ipt]->Rebin(2);
hforebbcw_centInd[ipt]->Rebin(2);
kbackbbcw2_centInd[ipt]->Rebin(2);
}

TH1F* hpp[npt];
TH1F* hbackpp[npt];
TH1F* hppd[npt];
TH1F* hppratio[npt];
TH1F* hbackppd[npt];
  
int iptstart = 0;
for(int ipt=iptstart; ipt<6; ipt++){
	
if(ipt==iptstart){
for(int ipt_add=0;ipt_add<iptstart;ipt_add++){
kforebbcw_centIn[ipt]->Add(kforebbcw_centIn[ipt_add]);
hforebbcw_centIn[ipt]->Add(hforebbcw_centIn[ipt_add]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2_centIn[ipt_add]);
kforebbcw_centInd[ipt]->Add(kforebbcw_centInd[ipt_add]);
hforebbcw_centInd[ipt]->Add(hforebbcw_centInd[ipt_add]);
kbackbbcw2_centInd[ipt]->Add(kbackbbcw2_centInd[ipt_add]);
}
ptbin[ipt] = ptbin[0];
}

/*
	if(ipt==6){
for(int ipt_add=6;ipt_add<ncent;ipt_add++){
kforebbcw_centIn[ipt]->Add(kforebbcw_centIn[ipt_add]);
hforebbcw_centIn[ipt]->Add(hforebbcw_centIn[ipt_add]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2_centIn[ipt_add]);
}
centbin[ipt] = 800;
}
*/
  hpp[ipt] = (TH1F*)kforebbcw_centIn[ipt]->Clone();
  hbackpp[ipt] = (TH1F*)kbackbbcw2_centIn[ipt]->Clone();
  hppd[ipt] = (TH1F*)kforebbcw_centInd[ipt]->Clone();
  hppratio[ipt] = (TH1F*)kforebbcw_centInd[ipt]->Clone();
  hbackppd[ipt] = (TH1F*)kbackbbcw2_centInd[ipt]->Clone();
  float nbackpp = hbackpp[ipt]->Integral()/2.0/PI;
  float nforepp = hpp[ipt]->Integral()/2.0/PI;
  float nbackppd = hbackppd[ipt]->Integral()/2.0/PI;
  float nforeppd = hppd[ipt]->Integral()/2.0/PI;
  //float ntrig0 = centforedis_0->Integral(11,30);
   for(int i=0; i<20; i++){
     float pp_cont = 1.0*hpp[ipt]->GetBinContent(i+1);
     float pp_contd = 1.0*hppd[ipt]->GetBinContent(i+1);
     //float pp0_err = 1.0*hpp[ipt]->GetBinError(i+1);
     float weight2 = sqrt(1.0*hforebbcw_centIn[ipt]->GetBinContent(i+1));
     float weight2d = sqrt(1.0*hforebbcw_centInd[ipt]->GetBinContent(i+1));

     float backpp_cont = 1.0*hbackpp[ipt]->GetBinContent(i+1);
     float backpp_contd = 1.0*hbackppd[ipt]->GetBinContent(i+1);
    
     float con = pp_cont/backpp_cont*nbackpp/nforepp;
     float err = weight2/backpp_cont*nbackpp/nforepp;
     float cond = pp_contd/backpp_contd*nbackppd/nforeppd;
     float errd = weight2d/backpp_contd*nbackppd/nforeppd;

     hpp[ipt]->SetBinContent(i+1, con);
     hpp[ipt]->SetBinError(i+1, err);
     hppd[ipt]->SetBinContent(i+1, cond);
     hppd[ipt]->SetBinError(i+1, errd);
     hppratio[ipt]->SetBinContent(i+1,con/cond);
     hppratio[ipt]->SetBinError(i+1,con/cond*sqrt((err/con)**2+(errd/cond)**2));
   }

  c1->cd(ipt-iptstart+1);
  gPad->SetTicks(1,1);
if(corr.Contains("bbc")){
    if(coll.Contains("Au")){
  float ymax = 1.1-0.0;//hpp[ipt]->GetMaximum()*1.1;
  float ymin = 0.9+0.0;//hpp[ipt]->GetMinimum()*0.9;
    }
    else{
  float ymax = 1.39-0.0;//hpp[ipt]->GetMaximum()*1.1;
  float ymin = 0.61+0.0;//hpp[ipt]->GetMinimum()*0.9;
    }
}
else{
  float ymax = 7.0-0.0;//hpp[ipt]->GetMaximum()*1.1;
  float ymin = 0.0+0.0;//hpp[ipt]->GetMinimum()*0.9;
}
  hpp[ipt]->SetMinimum(ymin);
  hpp[ipt]->SetMaximum(ymax);

  hpp[ipt]->SetMarkerStyle(20);
  hpp[ipt]->SetMarkerSize(1.3);
  hppd[ipt]->SetMarkerStyle(24);
  hppd[ipt]->SetMarkerSize(1.3);
  
  hpp[ipt]->SetMarkerColor(4);
  hppd[ipt]->SetMarkerColor(2);
  hpp[ipt]->GetYaxis()->SetLabelSize(0.08);
  hpp[ipt]->GetXaxis()->SetLabelSize(0.08);
  hpp[ipt]->GetYaxis()->SetNdivisions(505);
  //hpp[ipt]->GetYaxis()->SetTitleSize(0.6);
  //hpp[ipt]->GetXaxis()->SetTitleSize(0.0);
  hpp[ipt]->Draw("PE");
  hppd[ipt]->Draw("PEsame");
  c2->cd(ipt-iptstart+1);
  hppratio[ipt]->SetMinimum(0.9);
  hppratio[ipt]->SetMaximum(1.1);
  hppratio[ipt]->SetMarkerStyle(20);
  hppratio[ipt]->SetMarkerSize(1.3);
  hppratio[ipt]->Draw("PE");
TLegend *leg1 = new TLegend(0.44442,0.22,0.82,0.32);
  leg1->SetFillColor(10);
  leg1->SetLineStyle(4000);
  leg1->SetLineColor(10);
  leg1->SetLineWidth(0.);
  leg1->SetTextSize(0.08);
  leg1->SetBorderSize(0);
  leg1->AddEntry(hppratio[ipt],"MC/data","P");
  if(ipt-iptstart==0) leg1->Draw();

  c1->cd(ipt-iptstart+1);
  if(corr.Contains("bbc")){
  TF1 *fun0 = new TF1("fun0","[0]*(1+2*[1]*cos(x)+2*[2]*cos(2*x)+2*[3]*cos(3*x)+2*[4]*cos(4*x))", -0.5*PI, 1.5*PI);

  fun0->SetLineColor(1);
 // hpp[ipt]->Fit("fun0","R");


  TF1 *fun1 = new TF1("fun1","[0]*(1+2*[1]*cos(x))",   -0.5*PI, 1.5*PI);
  TF1 *fun2 = new TF1("fun2","[0]*(1+2*[1]*cos(2*x))", -0.5*PI, 1.5*PI);
  TF1 *fun3 = new TF1("fun3","[0]*(1+2*[1]*cos(3*x))", -0.5*PI, 1.5*PI);
  TF1 *fun4 = new TF1("fun4","[0]*(1+2*[1]*cos(4*x))", -0.5*PI, 1.5*PI);

//  TF1 *fun0 = new TF1("fun0","pol2",0.1,2);
//  hpp[ipt]->Fit("fun0","R");
TLegend *leg1 = new TLegend(0.22,0.22,0.82,0.32);
  leg1->SetFillColor(10);
  leg1->SetLineStyle(4000);
  leg1->SetLineColor(10);
  leg1->SetLineWidth(0.);
  leg1->SetTextSize(0.08);
  leg1->SetBorderSize(0);
  leg1->AddEntry(fun0,"1+#Sigma2c_{n}cos(n#Delta#phi)","L");
//  leg1->AddEntry(fun0,"pol2","L");
  //if(ipt-iptstart==1)leg1->Draw();

  TLegend *leg2 = new TLegend(0.12,0.60,0.32,0.82);
  leg2->SetFillColor(10);
  leg2->SetLineStyle(4000);
  leg2->SetLineColor(10);
  leg2->SetLineWidth(0.);
  leg2->SetTextSize(0.080);
  leg2->SetBorderSize(0);
  leg2->AddEntry(fun1,"1+2c_{1}cos(#Delta#phi)","L");
  leg2->AddEntry(fun2,"1+2c_{2}cos(2#Delta#phi)","L");
  leg2->AddEntry(fun3,"1+2c_{3}cos(3#Delta#phi)","L");
  leg2->AddEntry(fun4,"1+2c_{4}cos(4#Delta#phi)","L");
  //if(ipt-iptstart==1)leg2->Draw();
  

  fun1->SetParameters(fun0->GetParameter(0), fun0->GetParameter(1));
  fun2->SetParameters(fun0->GetParameter(0), fun0->GetParameter(2));
  fun3->SetParameters(fun0->GetParameter(0), fun0->GetParameter(3));
  fun4->SetParameters(fun0->GetParameter(0), fun0->GetParameter(4));

  fun1->SetLineColor(3);
  fun2->SetLineColor(2);
  fun3->SetLineColor(6);
  fun4->SetLineColor(9);

  fun1->SetLineStyle(2);
  fun2->SetLineStyle(3);
  fun3->SetLineStyle(4);
  fun4->SetLineStyle(5);
/*
  fun1->Draw("same");
  fun2->Draw("same");
  fun3->Draw("same");
  fun4->Draw("same");
  */
  }
else{
  TLegend *leg3 = new TLegend(0.12,0.60,0.32,0.82);
  leg3->SetFillColor(10);
  leg3->SetLineStyle(4000);
  leg3->SetLineColor(10);
  leg3->SetLineWidth(0.);
  leg3->SetTextSize(0.080);
  leg3->SetBorderSize(0);
  leg3->AddEntry(hpp[ipt],"before zyam", "p");
  //TF1 *fun0 = new TF1("fun0","[0]*x*x+[1]*x+[2]",0.1,2);
  TF1 *fun0 = new TF1("fun0","gaus(0)+gaus(3)",-1.2,PI/2);
  fun0->SetParameters(3,0,1,0.2,0,4);
  hpp[ipt]->Fit("fun0","R");
  hpp[ipt]->DrawCopy();
  TF1 *fun1 = new TF1("fun1","gaus(0)",-1.2,PI/2);
  fun1->SetParameters(fun0->GetParameter(0),fun0->GetParameter(1),fun0->GetParameter(2));
/*  double a=fun0->GetParameter(0);
  double b=fun0->GetParameter(1);
  double c=fun0->GetParameter(2);
  if(-b/2./a<2.)
    double zyam = fun0->Eval(-b/2./a);
  else
    double zyam = fun0->Eval(2.);
    */
  double zyam = fun0->Eval(PI/2);
  hpp_cp = (TH1D*)hpp[ipt]->Clone(Form("hpp_cp_%d",ipt));
   for(int i=0; i<21; i++){
  hpp_cp->SetBinContent(i,hpp[ipt]->GetBinContent(i)-zyam);
   }
   hpp_cp->SetMarkerColor(2);
   hpp_cp->Draw("same");
   //fout<<hpp[ipt]->Integral(hpp[ipt]->FindBin(-1.2),hpp[ipt]->FindBin(PI/2))<<"\t";
   fout<<0.95*fabs(fun1->GetParameter(0)*fun1->GetParameter(2)*sqrt(2*PI))<<endl;
  leg3->AddEntry(hpp_cp,"after zyam", "p");
  if(ipt-iptstart==1)leg3->Draw();
}
  hpp[ipt]->GetXaxis()->SetTitle("#Delta#phi");
  hpp[ipt]->GetXaxis()->SetTitleSize(0.08);
  hpp[ipt]->GetXaxis()->SetLabelSize(0.08);
  hpp[ipt]->GetXaxis()->CenterTitle();
  hpp[ipt]->GetXaxis()->SetTitleOffset(1.1);
  hpp[ipt]->GetYaxis()->SetTitle("C(d#phi)");
  hpp[ipt]->GetYaxis()->SetTitleSize(0.08);
  hpp[ipt]->GetYaxis()->CenterTitle();
  hpp[ipt]->GetYaxis()->SetTitleOffset(1.3);
  hpp[ipt]->GetYaxis()->SetLabelSize(0.08);
  hpp[ipt]->GetYaxis()->SetTitle("C(#Delta#phi)");
  hppratio[ipt]->GetXaxis()->SetTitle("#Delta#phi");
  hppratio[ipt]->GetXaxis()->SetTitleSize(0.08);
  hppratio[ipt]->GetXaxis()->SetLabelSize(0.08);
  hppratio[ipt]->GetXaxis()->CenterTitle();
  hppratio[ipt]->GetXaxis()->SetTitleOffset(1.1);
  hppratio[ipt]->GetYaxis()->SetTitle("C(d#phi)");
  hppratio[ipt]->GetYaxis()->SetTitleSize(0.08);
  hppratio[ipt]->GetYaxis()->CenterTitle();
  hppratio[ipt]->GetYaxis()->SetTitleOffset(1.3);
  hppratio[ipt]->GetYaxis()->SetLabelSize(0.08);
  hppratio[ipt]->GetYaxis()->SetTitle("C(#Delta#phi)");
  TLegend *leg3 = new TLegend(0.12,0.60,0.32,0.82);
  leg3->SetBorderSize(0);
  leg3->SetFillColor(0);
  leg3->SetTextSize(0.06);
  leg3->AddEntry(hpp[ipt],Form("%s HIJING 200GeV ",coll.Data()));
  leg3->AddEntry(hppd[ipt],Form("%s data 200GeV ",coll.Data()));
  if(ipt-iptstart==1)
  leg3->Draw();
 // TLatex *t=new TLatex(-1.0,0.88*(ymax-ymin)+ymin, Form("%d)",ipt+1));
 // t->SetTextSize(0.08);
 // t->Draw();

  TMarker *m0 = new TMarker(-0.3, 0.91*(ymax-ymin)+ymin, 20);

  if(ipt-iptstart==0){
  TMarker *m0 = new TMarker(-1.1, 0.91*(ymax-ymin)+ymin, 20);
  TLatex *t=new TLatex(-1.1,0.88*(ymax-ymin)+ymin, Form("%s HIJING 200GeV ",coll.Data()));
  t->SetTextSize(0.08);
 // t->Draw();
  }
 // else{
 // TLatex *t=new TLatex(-0.9,0.88*(ymax-ymin)+ymin, Form("%.f <Nch<= %.f",bbccentbin[ipt],bbccentbin[ipt+1]));
 // }
  if(ipt-iptstart==5){
    TLatex *t=new TLatex(-1.1,5.24*(ymax-ymin)+ymin, Form("with weight = particle Energy"));
    t->SetTextSize(0.07);
  //  t->Draw();
  }
  m0->SetMarkerSize(1.3);
  m0->SetMarkerColor(4);
  //m0->Draw();
  
  TLatex *t=new TLatex(-0.4,0.08*(ymax-ymin)+ymin, Form("%.1f < pt < %.1f GeV/c",ptbin[ipt],ptbin[ipt+1]));
  t->SetTextSize(0.08);
  t->Draw();

  //TLatex *t=new TLatex(-1.2,0.78*(ymax-ymin)+ymin, Form("%.1f< cent <%.1f%%",centmax,centmin));
  TLatex *t=new TLatex(-1.2,0.78*(ymax-ymin)+ymin, Form("%.1f< cent <%.f%%",centmax,5.));
  t->SetTextSize(0.08);
  if(ipt-iptstart==2)t->Draw();

  TLatex *t=new TLatex(-1.0,0.66*(ymax-ymin)+ymin, "|#eta_{trig}|<0.35");
  t->SetTextSize(0.08);
  if(ipt-iptstart==0)t->Draw();

if(dire=="north")
  TLatex *t=new TLatex(-1.2,0.24*(ymax-ymin)+ymin, "3.0<#eta_{asso}<4.0");
else
if(corr.Contains("bbc"))
  TLatex *t=new TLatex(-1.2,0.24*(ymax-ymin)+ymin, "-4.0<#eta_{asso}<-3.0");
  else
  TLatex *t=new TLatex(-1.2,0.24*(ymax-ymin)+ymin, "|#eta_{asso}|<0.35");
  t->SetTextSize(0.08);
  t->SetTextColor(2);
  if(ipt-iptstart==0)t->Draw();

}
  c1->Print(Form("fig/%s%sridge_%s_%.1f_%.1f_dataMC.gif",coll.Data(),corr.Data(),dire.Data(),centmin,centmax));
  c1->Print(Form("fig/%s%sridge_%s_%.1f_%.1f_dataMC.pdf",coll.Data(),corr.Data(),dire.Data(),centmin,centmax));
  c2->Print(Form("fig/%s%sridge_%s_%.1f_%.1f_dataMCratio.png",coll.Data(),corr.Data(),dire.Data(),centmin,centmax));
  c2->Print(Form("fig/%s%sridge_%s_%.1f_%.1f_dataMCratio.pdf",coll.Data(),corr.Data(),dire.Data(),centmin,centmax));
}

/*  
  cout<<"*************** v2 ***********"<<endl;
  float v2_0 = funvn0->GetParameter(1)/(zym_pp0 + funvn0->GetParameter(0));
  float v2_1 = funvn1->GetParameter(1)/(zym_pp1 + funvn1->GetParameter(0));
  float v2_2 = funvn2->GetParameter(1)/(zym_pp2 + funvn2->GetParameter(0));
  float v2_3 = funvn3->GetParameter(1)/(zym_pp3 + funvn3->GetParameter(0));
  

  cout<<v2_0<<" "<<v2_1<<" "<<v2_2<<" "<<v2_3<<endl;
 
  
  cout<<funvn0->GetParameter(0)*funvn0->GetParameter(1)<<" "
      <<funvn1->GetParameter(0)*funvn1->GetParameter(1)<<" "
      <<funvn2->GetParameter(0)*funvn2->GetParameter(1)<<" "
      <<funvn3->GetParameter(0)*funvn3->GetParameter(1)<<endl;
  

  cout<<"*************** v2 ***********"<<endl;
  cout<<funvn0->GetParameter(2)<<" "<<funvn1->GetParameter(2)<<" "<<funvn2->GetParameter(2)<<" "<<funvn3->GetParameter(2)<<endl;

  cout<<"*************** v3 ***********"<<endl;
  cout<<funvn0->GetParameter(3)<<" "<<funvn1->GetParameter(3)<<" "<<funvn2->GetParameter(3)<<" "<<funvn3->GetParameter(3)<<endl;
*/
}
예제 #5
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));

}
예제 #8
0
void P3overlayDataMCetabin(){
gStyle->SetOptStat(kFALSE);
gStyle->SetErrorX(0);
int ietac=0;
TString coll="PbP";
TString listsvarALL[6]={"Max","Sum","Mult","Maxpt","Sumpt","other"};
double binbound_JetID[100];
c1 = new TCanvas("c1"," ",1000,400);
makeMultiPanelCanvas(c1,3,1,0,0,0.18,0.16,0.03);

for(int ieta=0;ieta<Neta;ieta++){
if(ieta==0 || ieta==7 || ieta==6){
if(ieta==0) ietac=1;
if(ieta==6) ietac=3;
if(ieta==7) ietac=2;
//cout<<ieta<<endl;
for(int j=0;j<6;j++){
if(j!=5) continue;
TString svar=listsvarALL[j];
if(svar=="Max"){
int listsvar[]={0,2,4};
double ymin=1e-7,ymax=10;
double margin=8;
}

else if(svar=="Maxpt"){
int listsvar[]={6,8,10};
double ymin=1e-7,ymax=10;
double margin=3e-2;
}
else if(svar=="Sum"){
int listsvar[]={1,3,5};
double ymin=1e-7,ymax=10;
double margin=8;
}

else if(svar=="Sumpt"){
int listsvar[]={7,9,11};
double ymin=1e-7,ymax=10;
double margin=3e-2;
}

else if(svar=="Mult"){
int listsvar[]={15,16,17};
double ymin=1e-7;ymax=10;
double margin=1;
}

else if(svar=="other"){
int listsvar[]={0,12,6,14};
double ymin=1e-7,ymax=10;
double margin=3e-2;
}
else exit();

int N=sizeof(listsvar)/sizeof(int);

//for(int k=0;k<N;k++)
int ilist=listsvar[0];
TString JetIDName=JetIDNameList[ilist];
TString JetID, Unit;
if(ilist== 0)   JetID = "Max p_{T}^{charged}";
else if(ilist== 1)      JetID = "#Sigma p_{T}^{charged}";
else if(ilist== 2)      JetID = "Max p_{T}^{neutral}";
else if(ilist== 3) JetID = "#Sigma p_{T}^{neutral}";
else if(ilist== 4) JetID = "Max p_{T}^{photon}";
else if(ilist== 5) JetID = "#Sigma p_{T}^{photon}";
else if(ilist== 6)      JetID = "Max p_{T}^{charged}/p_{T}^{jet}";
else if(ilist== 7)      JetID = "#Sigma p_{T}^{charged}/p_{T}^{jet}";
else if(ilist== 8)      JetID = "Max p_{T}^{neutral}/p_{T}^{jet}";
else if(ilist== 9)      JetID = "#Sigma p_{T}^{neutral}/p_{T}^{jet}";
else if(ilist== 10)     JetID = "Max p_{T}^{photon}/p_{T}^{jet}";
else if(ilist== 11)     JetID = "#Sigma p_{T}^{photon}/p_{T}^{jet}";
else if(ilist== 12)     JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photon} +#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{jet}";
else if(ilist== 13)     JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photon} +#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{raw}";
else if(ilist== 14)     JetID = "Max p_{T}^{neutral}/Max(#Sigma p_{T}^{charged}, #Sigma p_{T}^{neutral})";
else if(ilist== 15)     JetID = "charged Multiplicity";
else if(ilist== 16)     JetID = "neutral Multiplicity";
else if(ilist== 17)     JetID = "photon Multiplicity";
else{   exit();}
if(JetIDName.Contains("pt") || JetIDName=="neuMaxr"){
if(ilist==12 || ilist==13){
double binbound_JetID[]={0,0.84,0.86,0.88,0.9,0.92,0.94,0.96,0.98,1.0,1.02,1.04,1.06,1.1,1.15,1.2,1.3,1.4,1.6,1.8,2.}; int Nbin_JetID=20;}
else if(ilist==6){
double binbound_JetID[]={0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,1.}; int Nbin_JetID=19;}
else{
double binbound_JetID[]={0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.}; int Nbin_JetID=20;}
Unit="";
}
else if(JetIDName.Contains("N")){
if(ilist==17){
double binbound_JetID[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,30}; int Nbin_JetID=17;}
else if(ilist==16){
double binbound_JetID[]={0,1,2,3,4,5,6,7,8,10}; int Nbin_JetID=9;}
else if(ilist==15){
double binbound_JetID[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,24,30,40}; int Nbin_JetID=22;}
Unit="";
}
else{
//double binbound_JetID[]={0,15,30,45,60,75,90,105,120,135,150,165,180,195,210,225,240,255,270,285,300};
double binbound_JetID[]={0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200};
int Nbin_JetID=20;
Unit="(GeV/c)";
}

if(coll=="PPb"){
TString histoname=Form("jetpt%sEtaBin%s",JetIDName.Data(),etabinnameswap[ieta].Data());
TH2F* hdata2F=(TH2F*)fDataPPbJetID->Get(histoname);
TH2F* hPPb2F=(TH2F*)fMCPPbJetID->Get(histoname);
}
if(coll=="PbP"){
TString histoname=Form("jetpt%sEtaBin%s",JetIDName.Data(),etabinname[ieta].Data());
TH2F* hdata2F=(TH2F*)fDataPbPJetIDOld->Get(histoname);
TH2F* hPPb2F=(TH2F*)fMCPbPJetID->Get(histoname);
}

TH1D* hdata = (TH1D*)hdata2F->ProjectionY("hdata",hdata2F->GetXaxis()->FindBin(xrange_pt[0]),hdata2F->GetXaxis()->FindBin(xrange_pt[1]));
TH1D* hPPb = (TH1D*)hPPb2F->ProjectionY("hPPb",hPPb2F->GetXaxis()->FindBin(xrange_pt[0]),hPPb2F->GetXaxis()->FindBin(xrange_pt[1]));

rehdata=(TH1D*)hdata->Clone("rehdata");
rehPPb=(TH1D*)hPPb->Clone("rehPPb");
rehdata=(TH1D*)hdata->Rebin(Nbin_JetID,"rehdata",binbound_JetID);
rehPPb=(TH1D*)hPPb->Rebin(Nbin_JetID,"rehPPb",binbound_JetID);
normalizeByBinWidth(rehdata);
normalizeByBinWidth(rehPPb);
rehdata->Scale(1./rehdata->Integral(rehdata->FindBin(binbound_JetID[0]),rehdata->FindBin(binbound_JetID[Nbin_JetID])));
rehPPb->Scale(1./rehPPb->Integral(rehPPb->FindBin(binbound_JetID[0]),rehPPb->FindBin(binbound_JetID[Nbin_JetID])));
rehdata->SetMarkerStyle(20);
rehdata->SetMarkerColor(1);
rehdata->SetLineColor(1);
rehdata->SetMarkerSize(1.2);
rehPPb->SetMarkerStyle(0);
rehPPb->SetFillStyle(3004);
rehPPb->SetFillColor(2);
rehPPb->SetLineColor(2);
c1->cd(ietac)->SetLogy();
TH1F* hFrame=new TH1F("","",100000,0,1000);
hFrame->GetYaxis()->SetRangeUser(ymin,ymax);
fixedFontHist(hFrame,1.2,1.5);
hFrame->GetXaxis()->SetTitleSize(0.05);
hFrame->GetXaxis()->SetLabelSize(0.05);
hFrame->GetYaxis()->SetTitleSize(0.05);
hFrame->GetYaxis()->SetLabelSize(0.05);
//if(k==0)	
hFrame->GetYaxis()->SetTitle("Event Fraction");
//else hFrame->GetYaxis()->SetTitle(""); 
hFrame->SetTitle("");
if(svar=="other")
hFrame->GetXaxis()->SetTitleSize(0.04);
hFrame->GetXaxis()->SetTitle(Form("%s %s",JetID.Data(),Unit.Data()));
hFrame->GetXaxis()->SetLimits(binbound_JetID[0]-margin,binbound_JetID[Nbin_JetID]+margin);
hFrame->DrawCopy();
//if(ilist==12 || ilist==13) 
//rehdata->GetXaxis()->SetRangeUser(0.8,1.2);
rehdata->Draw("E1same");
rehPPb->Draw("HIST E1same");
TLegend *leg1=new TLegend(0.08,0.85,0.25,0.95);
leg1->SetBorderSize(0);
leg1->SetFillColor(0);
leg1->SetTextSize(0.048);
if(coll=="PPb"){
leg1->AddEntry(rehdata,"Pb going positive Data","lpf");
leg1->AddEntry(rehPPb,"PYTHIA+HIJING","lpf");
}
else if(coll=="PbP"){
leg1->AddEntry(rehdata,"Proton going positive Data","lpf");
leg1->AddEntry(rehPPb,"HIJING+PYTHIA","lpf");
}
TLatex *T=new TLatex();
T->SetNDC();
T->SetTextAlign(12);
T->SetTextColor(1);
T->SetTextFont(42);

T->SetTextSize(0.048);
if(ietac==1)
T->DrawLatex(0.25,0.88,Form("%.f < p_{T}^{jet} < %.f (GeV/c)",xrange_pt[0],xrange_pt[1]));
if(ietac==3)
leg1->Draw("same");
T->SetTextSize(0.055);
T->DrawLatex(0.65,0.80,etastring[ieta]);
//if(k==1)
//T->DrawLatex(0.25,0.92,Form("|#eta_{CM}| < 1"));
//if(k==2)
//leg1->Draw("same");
/*c1->cd(2);
TH1D* ratio=(TH1D*)rehdata->Clone("ratio");
ratio->Divide(rehPPb);
ratio->SetMarkerStyle(20);
ratio->SetMarkerSize(1.2);
ratio->SetMarkerColor(1);
ratio->SetMinimum(0);
ratio->SetMaximum(1.9);
ratio->SetTitle("");
ratio->GetYaxis()->SetTitle("Data/MC");
ratio->Draw("E1");
TLine *l =new TLine(binbound_JetID[0],1,binbound_JetID[Nbin_JetID],1);
l->SetLineStyle(2);
l->SetLineColor(1);
l->Draw("same");
*/
}
}
}
c1->Print(Form("pic/%soverlay_%s_DataMC_etabin.png",coll.Data(),JetIDName.Data()));
c1->Print(Form("pic/%soverlay_%s_DataMC_etabin.pdf",coll.Data(),JetIDName.Data()));
}
예제 #9
0
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();  
}
예제 #10
0
파일: CompareOldNew.C 프로젝트: XuQiao/HI
void CompareOldNew(){
gStyle->SetOptStat(kFALSE);
gStyle->SetOptFit(kTRUE);
gStyle->SetErrorX(0);
static const int nColor = 8;
static const int colorCode[nColor] = {
    2, 4, 6, 7, 8, 9, 46,1
};
static const int markerCode[nColor] = {
    33, 34, 29, 24, 30, 28,27,20
};

const int N=8;
const TString etabinname[N]={"12_22","7_12","3_7","-3_3","-7_-3","-12_-7","-22_-12",""};
const double etabin[N]={1.0,0.5,0.4,0.6,0.4,0.5,1,2};
const TString etastring[N]={"-2.2<#eta_{CM}<-1.2","-1.2<#eta_{CM}<-0.7","-0.7<#eta_{CM}<-0.3","-0.3<#eta_{CM}<0.3","0.3<#eta_{CM}<0.7","0.7<#eta_{CM}<1.2","1.2<#eta_{CM}<2.2","-1.0<#eta_{CM}<1.0"};
TH2F* hPPb[N];	 TProfile* hProPPb[N]; 
TH2F* hold[N];	 TProfile* hProold[N]; 
c1 = new TCanvas("c1","c1",600,600);
//c2 = new TCanvas("c2","c2",600,600);
//c2->cd(1)->SetLogx();
makeMultiPanelCanvas(c1,1,1,-0.12,0,0.14,0.12,0.03);
//makeMultiPanelCanvas(c2,1,1,-0.12,0,0.14,0.12,0.03);
TLegend *leg1=new TLegend(0.65,0.7,0.8,0.9);
TLegend *leg2=new TLegend(0.65,0.7,0.8,0.9);
leg1->SetTextSize(0.035);
leg2->SetTextSize(0.04);
TH1F* hFrame=new TH1F("","",1000,0,1000);
hFrame->GetXaxis()->SetLimits(21.9,599.9);
hFrame->SetTitle("");
hFrame->GetYaxis()->SetRangeUser(0.98,1.1);
fixedFontHist(hFrame,1.2,1.6);
TLatex *T2=new TLatex(0.20,0.88,"CMS simulation");
T2->SetNDC();
T2->SetTextAlign(12);
T2->SetTextSize(0.04);
T2->SetTextColor(1);
T2->SetTextFont(42);
TLine *l=new TLine(30.1,1,599.9,1);
l->SetLineStyle(2);
l->SetLineColor(1);
for(int i=0;i<N;i++){
if(i==N-1){
hPPb[i]=(TH2F*)fPPb->Get("rawptJES_0-100%");
hold[i]=(TH2F*)fPPbOld->Get("rawptJES_0-100%");
}
else{
hPPb[i]=(TH2F*)fPPb->Get(Form("rawptJESEtaBin%s_Cen0-100%%",etabinname[i].Data()));
hold[i]=(TH2F*)fPPbOld->Get(Form("rawptJESEtaBin%s_Cen0-100%%",etabinname[i].Data()));
}
hPPb[i]->SetName(Form("hPPb_%d",i));
hold[i]->SetName(Form("hold_%d",i));

hProPPb[i]=(TProfile*)hPPb[i]->ProfileX();
hProold[i]=(TProfile*)hold[i]->ProfileX();
hProPPb[i]=(TProfile*)hProPPb[i]->Rebin(Nbin_pt,hProPPb[i]->GetName(),binbound_pt);
hProold[i]=(TProfile*)hProold[i]->Rebin(Nbin_pt,hProold[i]->GetName(),binbound_pt);
}

c1->cd(1);
hFrame->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
hFrame->GetYaxis()->SetTitle("p_{T}^{jet}/p_{T}^{raw}");
hFrame->DrawCopy();
for(int i=0;i<N;i++){
if(i==2){
TLatex *T1=new TLatex(0.25,0.83,etastring[i]);
T1->SetNDC();
T1->SetTextAlign(12);
T1->SetTextSize(0.04);
T1->SetTextColor(1);
T1->SetTextFont(42);

hProPPb[i]->SetMarkerStyle(markerCode[i]);
hProold[i]->SetMarkerStyle(markerCode[(i<6)?(6-i):3]);
hProPPb[i]->SetMarkerColor(colorCode[i]);
hProold[i]->SetMarkerColor(colorCode[i]);
hProPPb[i]->SetLineColor(colorCode[i]);
hProold[i]->SetLineColor(colorCode[i]);
hProPPb[i]->SetMarkerSize(1.4);
hProold[i]->SetMarkerSize(1.4);
leg1->AddEntry(hProPPb[i],Form("New %s",etastring[i].Data()),"lp");
leg1->AddEntry(hProold[i],Form("Old %s",etastring[i].Data()),"lp");
hProPPb[i]->DrawCopy("same");
hProold[i]->DrawCopy("same");
}
}
T2->Draw("same");
leg1->SetBorderSize(0);
leg1->SetFillColor(0);
leg1->Draw("same");
c1->Print(Form("OldNewrawptJES_etabin.pdf"));

}
예제 #11
0
파일: checkEricNtrk.C 프로젝트: XuQiao/HI
void checkEricNtrk(){
const int N=50;
double x[N]; double y[N];	double y_[N];	double ratio[N];
//gEff->BayesDivide(h_tr,h_DS);
cout<<"trackMult"<<'\t'<<"Eric"<<'\t'<<"Qiao"<<'\t'<<"ratio Qiao/Eric"<<endl;
TrackCorrector2D corr("/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/Corrections/trackCorrections_HIN12017v5_XSecWeighted.root");
Corrector corr_Qiao("/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/CentrDep/official/output/noweight/pPbHijing_DS_EffCorr.root");
for(int i=0;i<N;i++){
x[i]=i;
y[i]=1./corr.getEventWeight(i);
y_[i]=1./corr_Qiao.getEventWeightNtrk(i);
ratio[i]=(double)y_[i]/y[i];
cout<<i<<"th: "<<'\t'<<y[i]<<'\t'<<y_[i]<<'\t'<<ratio[i]<<endl;
}
TGraph *gEff=new TGraph(N,x,y_);	gEff->SetName("gEff");
TGraph *gEff_Eric=new TGraph(N,x,y);	gEff_Eric->SetName("gEff_Eric");
TGraph *gRatio=new TGraph(N,x,ratio);	gRatio->SetName("gRatio");
c1 = new TCanvas("c1"," ",600,800);
makeMultiPanelCanvas(c1,1,2,0,0,0.08,0.08,0.03);
c1->cd(1);
gEff->SetMarkerStyle(20);
gEff->SetMarkerColor(1);
gEff->SetMarkerSize(1.2);
gEff_Eric->SetMarkerStyle(24);
gEff_Eric->SetMarkerColor(2);
gEff_Eric->SetMarkerSize(1.2);
gRatio->SetMarkerStyle(20);
gRatio->SetMarkerColor(1);
gRatio->SetMarkerSize(1.2);
gEff->GetYaxis()->SetTitle("Efficiency");
gEff->GetXaxis()->SetTitleOffset(1.5);
gEff->GetYaxis()->SetTitleOffset(1.5);
gEff->SetTitle("");
gEff->GetYaxis()->SetRangeUser(-0.05,1.1);
gRatio->SetTitle("");
gRatio->GetXaxis()->SetTitleOffset(1.5);
gRatio->GetYaxis()->SetTitleOffset(1.5);
gRatio->GetYaxis()->SetRangeUser(0.9,1.1);
gRatio->GetXaxis()->SetTitle("Track Mult");
gRatio->GetXaxis()->CenterTitle();
gRatio->GetXaxis()->SetTitleSize(18);
gRatio->GetXaxis()->SetTitleFont(44);
gRatio->GetYaxis()->SetTitle("Qiao/Eric");
gRatio->GetYaxis()->CenterTitle();
gRatio->GetYaxis()->SetTitleSize(18);
gRatio->GetYaxis()->SetTitleFont(44);
gEff->GetYaxis()->CenterTitle();
gEff->GetYaxis()->SetTitleSize(18);
gEff->GetYaxis()->SetTitleFont(44);
gEff->Draw("AP");
TLine *l = new TLine(0,1,100,1);
l->SetLineStyle(2);
l->Draw("same");
gEff_Eric->Draw("Psame");

TLegend *leg=new TLegend(0.55,0.2,0.75,0.4);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetTextSize(0.05);
leg->AddEntry(gEff,"Qiao","lp");
leg->AddEntry(gEff_Eric,"Eric","lp");
leg->Draw("same");
c1->cd(2);
gRatio->Draw("AP");
l->Draw("same");
c1->Print("compTrkEff.png");

}
예제 #12
0
void DivideHFbin_NoGplus(){
gStyle->SetOptStat(kFALSE);
gStyle->SetErrorX(0);
double goal;
bool IsMC=kFALSE;
if(IsMC){
TString dir="/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/GlobalEvent/CentrDep/RecoHI";
TString inputfile="pPbHijing_EffCorr_VRw.root";}
else{
TString dir="/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/output/GlobalEvent/CentrDep/";
TString inputfile="HFCorrNoGplusCombinedJetTrigak3PFJetAllHist.root";}
ofstream fstr;
//fstr<<setprecision(2)<<fixed<<endl;
TFile *f=TFile::Open(Form("%s/%s",dir.Data(),inputfile.Data()));
fstr<<dir<<"/"<<inputfile<<endl;

if(IsMC){
TString Var[6]={"HFp4","HFp","HFm4","HFm","HF4","Mult"};
TString corr[9]={"ES","DS","NtrkEric","Ntrk","Ntrkbak","HFp4","HFp4bak","reHFp4","reHFp4bak"};
TH1F* hHF[6][9];        TH1F* hHF_tr[6];
}
else{
TString Var[4]={"HF4","HFPlus","HFPlus4","Ntrk"};
TString corr[7]={"Wt","_QiaoNtrkWt","_QiaoNtrkbakWt","_QiaoHFPlus4bakWt","_QiaoHFPlus4Wt","_QiaoReHFPlus4Wt","_QiaoReHFPlus4bakWt"};
TH1F* hHF[4][7];        TH1F* hHF_tr[4];
}

if(IsMC)
fstr.open(Form("NoGplus_HFbin_Hijing.txt"));
else
fstr.open(Form("NoGplus_HFbin_Data.txt"));

const int N=5;
double cent[N]={0.1,0.2,0.3,0.6,0.9};
double HFcentrbin[N];
double HFbin[]={0,0.23,0.47,0.67,0.87,1.05,1.24,1.43,1.62,1.82,2.03,2.24,2.47,2.7,2.95,3.21,3.48,3.77,4.07,4.38,4.72,5.06,5.41,5.79,6.17,6.57,6.98,7.41,7.85,8.3,8.76,9.24,9.74,10.25,10.79,11.33,11.91,12.51,13.14,13.81,14.51,15.27,16.09,17,17.99,19.14,20.48,22.14,24.35,27.93,90.29};
int nHFbin=sizeof(HFbin)/sizeof(double)-1;
TLine *l[N];
//for(int k=0;k<nVar;k++){
int k=2;
//for(int j=0;j<=ncorr;j++){
int j=6;
if(IsMC){
if(j==0)
hHF[k][j]=(TH1F*)f->Get(Form("demo/h%s%s",Var[k].Data(),corr[j].Data()));
else if(j==1)
hHF[k][j]=(TH1F*)fDS->Get(Form("h%s%s",Var[k].Data(),corr[j].Data()));
else
hHF[k][j]=(TH1F*)f->Get(Form("demo/h%s%s",corr[j].Data(),Var[k].Data()));
hHF_tr[k]=(TH1F*)f->Get(Form("demo/h%s%s",Var[k].Data(),corr[0].Data()));
}
else{
if(j==2){
if(k==1)
corr[j]="_QiaoNtrkbalWt";
else
corr[j]="_QiaoNtrkbakWt";
}
hHF[k][j]=(TH1F*)f->Get(Form("pfjet_%s%s",Var[k].Data(),corr[j].Data()));
hHF_tr[k]=(TH1F*)f->Get(Form("pfjet_%s",Var[k].Data()));
}
fstr<<hHF[k][j]->GetName()<<" Integral="<<hHF_tr[k]->Integral()/hHF[k][j]->Integral()<<endl;
for(int icent=0;icent<N;icent++){
//fstr<<"start from 90-100%:"<<endl;
for(int ibin=1;ibin<hHF[k][j]->GetNbinsX();ibin++){
goal=cent[icent]*hHF[k][j]->Integral();
if(hHF[k][j]->Integral(ibin,hHF[k][j]->GetNbinsX())<=goal){
HFcentrbin[icent]=hHF[k][j]->GetXaxis()->GetBinLowEdge(ibin);
fstr<<icent<<"th: "<<hHF[k][j]->GetXaxis()->GetBinLowEdge(ibin)<<'\t'<<cent[icent]<<endl;
break;
}
}
l[icent]=new TLine(HFcentrbin[icent],0,HFcentrbin[icent],6e-2);
l[icent]->SetLineStyle(2);
l[icent]->SetLineColor(4);
l[icent]->SetLineWidth(2);
}
//}
//}
hHF[k][j]=(TH1F*)hHF[k][j]->Rebin(nHFbin,hHF[k][j]->GetName(),HFbin);
normalizeByBinWidth(hHF[k][j]);
hHF[k][j]->Scale((double)1.0/hHF[k][j]->Integral());
c1 = new TCanvas("c1","",600,600);
makeMultiPanelCanvas(c1,1,1,0,0,0.05,0.05,0.03);
c1->cd()->SetLogy();
c1->cd()->SetLogx();
TH1F* hFrame=new TH1F("","",1000,0,100);
fixedFontHist(hFrame,1.3,1.2);
hFrame->GetXaxis()->SetTitle("HF #Sigma E_{T} #eta>4");
hFrame->GetXaxis()->SetRangeUser(1e-1,30);
hFrame->GetYaxis()->SetTitle("Event Fraction");
hFrame->GetYaxis()->SetRangeUser(1e-3,1e-1);
hFrame->Draw();
TLatex *T1=new TLatex(0.25,0.85,"CMS preliminary pPb #sqrt{s} = 5.02TeV");
T1->SetNDC();
T1->SetTextAlign(12);
T1->SetTextSize(0.04);
T1->SetTextColor(1);
T1->SetTextFont(42);

TLatex T2;
T2.SetNDC();
T2.SetTextAngle(90);
T2.SetTextSize(0.03);
T2.SetTextColor(1);
T2.SetTextFont(42);
T2.DrawLatex(0.27,0.30,"90-100%");
T2.DrawLatex(0.54,0.30,"60-90%");
T2.DrawLatex(0.71,0.30,"30-60%");
T2.DrawLatex(0.79,0.30,"20-30%");
T2.DrawLatex(0.83,0.30,"10-20%");
T2.DrawLatex(0.88,0.30,"0-10%");


hHF[k][j]->SetMarkerStyle(20);
hHF[k][j]->SetMarkerColor(1);
hHF[k][j]->SetLineColor(1);
hHF[k][j]->SetMarkerSize(1);
hHF[k][j]->Draw("same");
T1->Draw("same");
for(int icent=0;icent<N;icent++){
l[icent]->Draw("same");
}
c1->Print("HFbin.png");
}
예제 #13
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");
}
예제 #14
0
파일: overlayJetIDcut.C 프로젝트: XuQiao/HI
void overlayJetIDcut(){
gStyle->SetOptStat(kFALSE);
c1 = new TCanvas("c1","",600,600);
makeMultiPanelCanvas(c1,1,1,-0.12,0,0.13,0.1,0.03);
TH1F* hFrame=new TH1F("","",1000,0,1000);
c1->cd(1)->SetGridx();
hFrame->SetLineColor(0);
hFrame->GetXaxis()->SetLimits(28,599.9);
hFrame->GetXaxis()->SetTitle("p_{T}^{jet} (GeV/c)");
hFrame->GetYaxis()->SetTitle("Cut Efficiency");
hFrame->GetYaxis()->SetRangeUser(0.92,1.02);
fixedFontHist(hFrame,1.2,1.8);
hFrame->DrawCopy();
TGraphAsymmErrors *g6Data = makeJetIDcut(6,1);
g6Data->SetMarkerStyle(20);
g6Data->SetMarkerColor(1);
g6Data->SetLineColor(1);
g6Data->Draw("Psame");
TGraphAsymmErrors *g6MC = makeJetIDcut(6,0);
g6MC->SetMarkerStyle(24);
g6MC->SetMarkerColor(1);
g6MC->SetLineColor(1);
TGraphAsymmErrors *g12Data = makeJetIDcut(12,1);
g12Data->SetMarkerStyle(20);
g12Data->SetMarkerColor(1);
g12Data->SetLineColor(1);
g12Data->Draw("Psame");
TGraphAsymmErrors *g12MC = makeJetIDcut(12,0);
g12MC->SetMarkerStyle(24);
g12MC->SetMarkerColor(1);
g12MC->SetLineColor(1);
g12MC->Draw("Psame");
TGraphAsymmErrors *g14Data = makeJetIDcut(14,1);
g14Data->SetMarkerStyle(21);
g14Data->SetMarkerColor(4);
g14Data->SetLineColor(4);
g14Data->Draw("Psame");
TGraphAsymmErrors *g14MC = makeJetIDcut(14,0);
g14MC->SetMarkerStyle(25);
g14MC->SetMarkerColor(4);
g14MC->SetLineColor(4);
g14MC->Draw("Psame");
g6MC->Draw("Psame");
TLegend *leg1=new TLegend(0.52,0.15,0.8,0.45);
leg1->SetBorderSize(0);
leg1->SetFillColor(0);
leg1->SetTextSize(0.04);
leg1->AddEntry(g6Data,"cut 1 Data","lp");
leg1->AddEntry(g6MC,"cut 1 PYTHIA+HIJING","lp");
leg1->AddEntry(g14Data,"cut 2 Data","lp");
leg1->AddEntry(g14MC,"cut 2 PYTHIA+HIJING","lp");
//leg1->AddEntry(g12Data,"cut 3 Data","lp");
//leg1->AddEntry(g12MC,"cut 3 PYTHIA+HIJING","lp");
leg1->Draw("same");
T->SetTextSize(0.04);
T->DrawLatex(0.30,0.20,etastring[ieta]);
TLine *l =new TLine(25,1,600,1);
l->SetLineStyle(2);
l->SetLineColor(1);
l->Draw("same");

c1->Print(Form("pic/overlay_JetIDcut.png"));
c1->Print(Form("pic/overlay_JetIDcut.pdf"));
}
예제 #15
0
void RAA_dataDrivenUnfoldingErrorCheck_new(int radius = 3, bool isATLASCut = true)
{

  TStopwatch timer; 
  timer.Start();
  
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  
  bool printDebug = true;
  bool dofakeremove = false;
  bool do10GeVBins = true;

  char * scale = (char*)"NeqScale";
  // 944Scale
  // NeqScale
  // NeqScalePerCent
  
  int unfoldingCut = 20;
  char * outLocation = (char*) "July20/";
  if(isATLASCut) outLocation = (char*)"July20/ATLASCut/";
  
  // get the data and mc histograms from the output of the read macro. 
  
  TDatime date;//this is just here to get them to run optimized. 

  // Pawan's files:
  //TFile * fPbPb_in = TFile::Open(Form("Pawan_TTree_PbPb_Data_MC_subid0_spectra_JetID_CutA_finebins_%s_R0p%d.root", etaWidth, radius));
  //TFile * fPbPb_in = TFile::Open(Form("Pawan_TTree_PbPb_Data_MC_subid0_spectra_JetID_CutA_muMaxOverSumcandMaxLT0p975_finebins_%s_R0p%d.root", etaWidth, radius));
  //TFile * fPbPb_in = TFile::Open(Form("Pawan_TTree_PbPb_Data_MC_subid0_spectra_JetID_CutA_trkMaxOverpfptGT0p02_finebins_%s_R0p%d.root", etaWidth, radius));
  //TFile * fPbPb_in = TFile::Open(Form("Pawan_TTree_PbPb_Data_noPrescl_MC_subid0_spectra_JetID_CutA_finebins_%s_R0p%d.root", etaWidth, radius));
  //TFile * fPbPb_in = TFile::Open(Form("Pawan_TTree_PbPb_Data_noPrescl_MC_subid0_spectra_JetID_CutA_7GeVTrackCut_finebinscut_%s_R0p%d.root", etaWidth, radius));
  // get the files to perform MC closure from the fixed ntuples
  TFile * fPbPb_in, *fMinBias, *fPbPb_MC_in, * fTrig;
  
  if(isATLASCut) fPbPb_in    = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_Data_histograms_FromForest_trkMax7OrNeMax8GeVCut_akPu%d_20_eta_20.root",radius),"r");
  if(!isATLASCut) fPbPb_in    = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_Data_histograms_FromForest_akPu%d_20_eta_20.root",radius),"r");
  if(isATLASCut) fMinBias    = TFile::Open(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_MB_Data_histograms_FromForest_trkMax7OrNeMax8GeVCut_fix_pt15GeVCut_akPu%d_20_eta_20.root",radius));
  if(!isATLASCut) fMinBias    = TFile::Open(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_MB_Data_histograms_FromForest_fix_pt15GeVCut_akPu%d_20_eta_20.root",radius));
  //TFile * fPbPb_MC_in = TFile::Open(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_MC_histograms_FromForest_pthat50andabove_akPu%d_20_eta_20.root",radius));
  if(isATLASCut) fPbPb_MC_in = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_MC_histograms_FromForest_trkMax7OrNeMax8GeVCut_akPu%d_20_eta_20.root",radius),"r");
  if(!isATLASCut) fPbPb_MC_in = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_MC_histograms_FromForest_akPu%d_20_eta_20.root",radius),"r");
  TFile * fPP_in      = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/pp_Data_histograms_FromForest_ak%d_20_eta_20.root",radius),"r");
  TFile * fPP_MC_in   = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/pp_MC_histograms_FromForest_ak%d_20_eta_20.root",radius),"r");
  if(isATLASCut) fTrig       = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_Data_nofkSub_trkMax7OrNeMax8GeVCut_new_MC_turnonCurves_R%d_20_eta_20_20150715.root",radius),"r");
  if(!isATLASCut) fTrig       = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/PbPb_Data_nofkSub_new_MC_turnonCurves_R%d_20_eta_20_20150715.root",radius),"r");
  TFile * fTrig_pp = new TFile(Form("/afs/cern.ch/work/r/rkunnawa/WORK/RAA/Jun29/pp_MC_turnonCurves_R%d_20_eta_20_20150702.root", radius),"r");
  // TFile * fPPMCTrig = new TFile(Form("PP_Data_MC_turnonCurves_R%d_20_eta_20_20150618.root",radius),"r");

  TH1F * hMC_turnon[nbins_cent+1], * hData_turnon[nbins_cent+1];
  cout<<"after input file declaration"<<endl;
  
  
  // histogram declarations with the following initial appendage: d - Data, m - MC, u- Unfolded
  // for the MC closure test, ive kept separate 

  TH1F *dPbPb_TrgComb[nbins_cent+1], *dPbPb_TrgCombInput[nbins_cent+1], *dPbPb_Comb[nbins_cent+1], *dPbPb_Trg80[nbins_cent+1], *dPbPb_Trg65[nbins_cent+1], *dPbPb_Trg55[nbins_cent+1], *dPbPb_1[nbins_cent+1], *dPbPb_2[nbins_cent+1], *dPbPb_3[nbins_cent+1], *dPbPb_80[nbins_cent+1], *dPbPb_65[nbins_cent+1], *dPbPb_55[nbins_cent+1];
  
  TH1F *mPbPb_GenInput[nbins_cent+1], *mPbPb_RecoInput[nbins_cent+1];
  TH1F *mPbPb_Gen[nbins_cent+1], *mPbPb_Reco[nbins_cent+1];
  TH2F *mPbPb_Matrix[nbins_cent+1], * mPbPb_MatrixInput[nbins_cent+1], *mPbPb_Response[nbins_cent+1], *mPbPb_ResponseNorm[nbins_cent+1];
  TH1F *mPbPb_mcclosure_data[nbins_cent+1];
  TH2F *mPbPb_mcclosure_Matrix[nbins_cent+1],*mPbPb_mcclosure_Response[nbins_cent+1], *mPbPb_mcclosure_ResponseNorm[nbins_cent+1];
  TH1F *mPbPb_mcclosure_gen[nbins_cent+1];
  const int Iterations = 20; //for unfolding systematics. 
  const int BayesIter = 4;
  TH1F *uPbPb_Bayes[nbins_cent+1], *uPbPb_BinByBin[nbins_cent+1], *uPbPb_SVD[nbins_cent+1]; 
  TH1F *uPbPb_BayesianIter[nbins_cent+1][Iterations];
  TH1F *dPbPb_MinBias[nbins_cent];
  TH1F *hMinBias[nbins_cent];
  
  TH1F *dPP_1, *dPP_2, *dPP_3, *dPP_Comb, * dPP_CombInput;
  TH1F *mPP_Gen, *mPP_Reco, *mPP_GenInput, *mPP_RecoInput;
  TH2F *mPP_Matrix, *mPP_MatrixInput, *mPP_Response,*mPP_ResponseNorm;
  TH1F *mPP_mcclosure_data;
  TH2F *mPP_mcclosure_Matrix, *mPP_mcclosure_Response,*mPP_mcclosure_ResponseNorm;
  TH1F *mPP_mcclosure_Gen;
  TH1F *uPP_Bayes, *uPP_BinByBin, *uPP_SVD;
  TH1F *uPP_BayesianIter[Iterations];

  TH1F * hData_FaketoSub_fullbin[nbins_cent+1];
  
  // would be better to read in the histograms and rebin them. come to think of it, it would be better to have them already rebinned (and properly scaled - to the level of differential cross section in what ever barns (inverse micro barns) but keep it consistent) from the read macro. 

  if(radius == 2) unfoldingCut = unfoldingCut_R2;
  if(radius == 3) unfoldingCut = unfoldingCut_R3;
  if(radius == 4) unfoldingCut = unfoldingCut_R4;
  
  // TH1F * htest = new TH1F("htest","",nbins, ptbins_long);
  // Int_t unfoldingCutBin = htest->FindBin(unfoldingCut);
  
  //Float_t cutarray[6]={50,50,40,35,35,35};
  float cutarray[nbins_cent] = {0.0,0.0,0.0,0.0,0.0,0.0};
  
  if(radius == 2){
    cutarray[0] = 50;
    cutarray[1] = 40;
    cutarray[2] = 40;
    cutarray[3] = 40;
    cutarray[4] = 30;
    cutarray[5] = 30;
  }
  if(radius == 3){
    cutarray[0] = 55;
    cutarray[1] = 50;
    cutarray[2] = 50;
    cutarray[3] = 40;
    cutarray[4] = 35;
    cutarray[5] = 40;
  }
    
  if(radius == 4){
    cutarray[0] = 70;
    cutarray[1] = 60;
    cutarray[2] = 60;
    cutarray[3] = 45;
    cutarray[4] = 40;
    cutarray[5] = 30;
  }
    
  TH1F * hDataBeforeSub[nbins_cent], * hDataAfterSub[nbins_cent];
  
  // get PbPb data
  for(int i = 0;i<nbins_cent;++i){
    if(printDebug) cout<<"cent_"<<i<<endl;

    hData_turnon[i] = (TH1F*)fTrig->Get(Form("hHist_Data_Turnon_cent%d",i));
    
    hData_turnon[i] = (TH1F*)hData_turnon[i]->Rebin(nbins_short, Form("hData_turnon_cent%d",i), boundaries_short);
    //hData_turnon[i] = (TH1F*)hData_turnon[i]->Rebin(10);

    divideBinWidth(hData_turnon[i]);

     //  hMinBias[i]     = (TH1F*)fMinBias->Get(Form("hpbpb_noTrg_R%d_%s_cent%d",radius,etaWidth,i)); //MinBias Histo
    hMinBias[i]     = (TH1F*)fMinBias->Get(Form("hpbpb_HLTMBwoLJSbJ_R%d_%s_cent%d",radius,etaWidth,i)); //MinBias Histo
    hMinBias[i]->Print("base");

    dPbPb_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLTComb_%s_R%d_%s_cent%d",scale, radius,etaWidth,i));
    //dPbPb_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT80_R%d_%s_cent%d",radius,etaWidth,i));
    //dPbPb_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT65_R%d_%s_cent%d",radius,etaWidth,i));
    //dPbPb_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT55_R%d_%s_cent%d",radius,etaWidth,i));
    // dPbPb_TrgComb[i]->Scale(1./(1+0.898+0.494)/1e16);
    // //dPbPb_TrgComb[i]->Scale(4*145.156*1e6);
    dPbPb_TrgComb[i]->Print("base");

    hDataBeforeSub[i] = (TH1F*)dPbPb_TrgComb[i]->Clone(Form("hData_Before_Sub_cent%d",i));
    
    //dPbPb_TrgComb[i] = (TH1F*)fPbPb_DataCorr_in->Get(Form("Data_TrigEffCorrected_FakeSub_cent%d",i));
    //dPbPb_TrgComb[i]->Print("base");
    
    // dPbPb_JEC_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_JEC_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
    // // //dPbPb_TrgComb[i]->Scale(4*145.156*1e6);
    // dPbPb_JEC_TrgComb[i]->Print("base");
    // dPbPb_Smear_TrgComb[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_Smear_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));
    // // //dPbPb_TrgComb[i]->Scale(4*145.156*1e6);
    // dPbPb_Smear_TrgComb[i]->Print("base");
    // dPbPb_Trg80[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT80_R%d_%s_cent%d",radius,etaWidth,i));
    // //dPbPb_Trg80[i]->Scale(4*145.156*1e6);
    // dPbPb_Trg80[i]->Print("base");
    // dPbPb_Trg65[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT65_R%d_%s_cent%d",radius,etaWidth,i));
    // //dPbPb_Trg65[i]->Scale(4*145.156*1e6);
    // dPbPb_Trg65[i]->Print("base");
    // dPbPb_Trg55[i] = (TH1F*)fPbPb_in->Get(Form("hpbpb_HLT55_R%d_%s_cent%d",radius,etaWidth,i));
    // //dPbPb_Trg55[i]->Scale(4*145.156*1e6);
    // dPbPb_Trg55[i]->Print("base");

    // if(dotrigcor){
      
    //   doTrigCorr(dPbPb_TrgComb[i], hData_turnon[i]);
    //   doTrigCorr(dPbPb_JEC_TrgComb[i], hData_turnon[i]);
    //   doTrigCorr(dPbPb_Smear_TrgComb[i], hData_turnon[i]);

    // }
    
    //Lets do the subtraction here _Sevil 

      // Float_t bincon=cutarray[i]; 
      // Int_t bincut= hMinBias[i]->FindBin(bincon); 
      
      // for(int k = bincut;k<=hMinBias[i]->GetNbinsX();k++) { 
      // 	hMinBias[i]->SetBinContent(k,0); 
      // 	hMinBias[i]->SetBinError(k,0);
      // } 

      // for(int k = 1;k<=15;k++) { 
      // 	hMinBias[i]->SetBinContent(k,0); 
      // 	hMinBias[i]->SetBinError(k,0);
      // }
      
      Float_t   bin_no = dPbPb_TrgComb[i]->FindBin(15);
      Float_t bin_end=dPbPb_TrgComb[i]->FindBin(25);
      
      Float_t   bin_nomb = hMinBias[i]->FindBin(15);
      Float_t bin_endmb=hMinBias[i]->FindBin(25);
      
      float scalerangeweight=dPbPb_TrgComb[i]->Integral(bin_no,bin_end)/hMinBias[i]->Integral(bin_nomb,bin_endmb);

      // for(int j = 0; j<hMinBias[i]->GetNbinsX(); ++j)
      // 	hMinBias[i]->SetBinError(j+1, (Float_t)hMinBias[i]->GetBinError(j+1)/scalerangeweight);
      
      hMinBias[i]->Scale(scalerangeweight);
      if(dofakeremove) dPbPb_TrgComb[i]->Add(hMinBias[i], -1);

      hDataAfterSub[i] = (TH1F*)dPbPb_TrgComb[i]->Clone(Form("hData_After_Sub_cent%d",i));
      
      // dPbPb_JEC_TrgComb[i]->Add(hMinBias[i], -1);
      // dPbPb_Smear_TrgComb[i]->Add(hMinBias[i], -1);

      // for(int j = 1; j<dPbPb_TrgComb[i]->GetNbinsX(); ++j){

      // 	if(dPbPb_TrgComb[i]->GetBinContent(j) <= 0 ||dPbPb_JEC_TrgComb[i]->GetBinContent(j) <= 0||dPbPb_Smear_TrgComb[i]->GetBinContent(j) <= 0){
      // 	  dPbPb_TrgComb[i]->SetBinContent(j, 0);
      // 	  dPbPb_JEC_TrgComb[i]->SetBinContent(j, 0);
      // 	  dPbPb_Smear_TrgComb[i]->SetBinContent(j, 0);
      // 	  dPbPb_TrgComb[i]->SetBinError(j, 0);
      // 	  dPbPb_JEC_TrgComb[i]->SetBinError(j, 0);
      // 	  dPbPb_Smear_TrgComb[i]->SetBinError(j, 0);
      // 	}
      // }
      
    

    // // lets truncate the histograms here:
    // cout<<" going to truncate Data histogram here cent "<<i<<endl;
    // dPbPb_TrgCombInput[i]->Print("base");

    // dPbPb_TrgComb[i] = new TH1F(Form("PbPb_data_minbiasSub_cent%d",i),"",365, 30, 395);
    // Truncate1D(dPbPb_TrgCombInput[i], dPbPb_TrgComb[i]);    
    
    // // dPbPb_TrgComb[i] = (TH1F*)Truncate1D(dPbPb_TrgComb[i], 340, unfoldingCutBin, 395);
    // // dPbPb_TrgComb[i]->Print("base");
    
    //dPbPb_TrgComb[i] = (TH1F*)dPbPb_TrgComb[i]->Rebin(nbins, Form("PbPb_data_minbiasSub_cent%d",i), ptbins_long);
    dPbPb_TrgComb[i] = (TH1F*)dPbPb_TrgComb[i]->Rebin(10);
    dPbPb_TrgComb[i]->SetName(Form("PbPb_data_minbiasSub_cent%d",i));
    divideBinWidth(dPbPb_TrgComb[i]);
    
    hMinBias[i] = (TH1F*)hMinBias[i]->Rebin(10);
    hDataAfterSub[i] = (TH1F*)hDataAfterSub[i]->Rebin(10);
    hDataBeforeSub[i] = (TH1F*)hDataBeforeSub[i]->Rebin(10);

    divideBinWidth(hMinBias[i]);
    divideBinWidth(hDataAfterSub[i]);
    divideBinWidth(hDataBeforeSub[i]);
    
    dPbPb_TrgComb[i]->Scale(1./(166 * 1e9));
    
    // dPbPb_TrgComb[i]->Print("base");
    
  }

  if(printDebug)cout<<"loaded the data histograms PbPb"<<endl;
  // get PbPb MC
  for(int i = 0;i<nbins_cent;i++){
    
    // mPbPb_GenInput[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_anaBin_JetComb_gen_R%d_%s_cent%d",radius,etaWidth,i));
    // mPbPb_GenInput[i]->Print("base");
    // mPbPb_RecoInput[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_anaBin_JetComb_reco_R%d_%s_cent%d",radius,etaWidth,i));
    // mPbPb_RecoInput[i]->Print("base");
    // mPbPb_MatrixInput[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_anaBin_matrix_HLT_R%d_%s_cent%d",radius,etaWidth,i));
    // mPbPb_MatrixInput[i]->Print("base");

    mPbPb_Gen[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_gen_R%d_%s_cent%d",radius,etaWidth,i));
    //mPbPb_Gen[i]->Rebin(nbins, Form("mPbPb_Gen_cent%d",i), ptbins_long);
    mPbPb_Gen[i]->Rebin(10);
    divideBinWidth(mPbPb_Gen[i]);
    mPbPb_Gen[i]->Print("base");
    mPbPb_Reco[i] = (TH1F*)fPbPb_MC_in->Get(Form("hpbpb_JetComb_reco_R%d_%s_cent%d",radius,etaWidth,i));
    //mPbPb_Reco[i]->Rebin(nbins, Form("mPbPb_Reco_cent%d",i), ptbins_long);
    mPbPb_Reco[i]->Rebin(10);
    divideBinWidth(mPbPb_Reco[i]);
    mPbPb_Reco[i]->Print("base");
    mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_matrix_HLT_R%d_%s_cent%d",radius,etaWidth,i));
    //mPbPb_Matrix[i] = (TH2F*)fPbPb_MC_in->Get(Form("hpbpb_anaBin_matrix_HLT_R%d_%s_cent%d",radius,etaWidth,i));
    mPbPb_Matrix[i]->Rebin2D(10, 10);
    mPbPb_Matrix[i]->Print("base");
    
    // if(etaWidth == "10_eta_10"){
    //   if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);

    //   if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(30);

    //   if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(30);
    // }

    // if(etaWidth == "10_eta_18"){
    //   if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);

    //   if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(60);
    //   if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(40);
    //   if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(30);

    //   if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(70);
    //   if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(60);
    //   if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(30);
    // }

    // if(etaWidth == "20_eta_20"){
    //   if(i == 0 && radius==2) unfoldingCutBin = htest->FindBin(70);
    //   if(i == 1 && radius==2) unfoldingCutBin = htest->FindBin(60);
    //   if(i == 2 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 3 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 4 && radius==2) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==2) unfoldingCutBin = htest->FindBin(30);

    //   if(i == 0 && radius==3) unfoldingCutBin = htest->FindBin(70);
    //   if(i == 1 && radius==3) unfoldingCutBin = htest->FindBin(60);
    //   if(i == 2 && radius==3) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 3 && radius==3) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 4 && radius==3) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==3) unfoldingCutBin = htest->FindBin(30);

    //   if(i == 0 && radius==4) unfoldingCutBin = htest->FindBin(80);
    //   if(i == 1 && radius==4) unfoldingCutBin = htest->FindBin(60);
    //   if(i == 2 && radius==4) unfoldingCutBin = htest->FindBin(50);
    //   if(i == 3 && radius==4) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 4 && radius==4) unfoldingCutBin = htest->FindBin(30);
    //   if(i == 5 && radius==4) unfoldingCutBin = htest->FindBin(30);
    // }

    int bincut = mPbPb_Gen[i]->FindBin(50);
    for(int k = 1;k<=bincut;k++){

    //   mPbPb_Gen[i]->SetBinContent(k,0);
    //   mPbPb_Reco[i]->SetBinContent(k,0);
    //   mPbPb_Gen[i]->SetBinError(k,0);
    //   mPbPb_Reco[i]->SetBinError(k,0);
    //   // set bin content matrix l,k works 
      for(int l = 1;l<=mPbPb_Gen[i]->GetNbinsX();l++){
	mPbPb_Matrix[i]->SetBinContent(l,k,0);
	mPbPb_Matrix[i]->SetBinError(l,k,0);
      }
      
    }

    SetUnfoldBins1D(dPbPb_TrgComb[i], 50, 350);
    
    // cout<<"going to truncate the MC histograms here."<<endl;
    
    // // mPbPb_Reco[i]->Print("base");
    // // mPbPb_Reco[i] = (TH1F*)Truncate1D_anaBin(mPbPb_Reco[i], nbins, ptbins_long);
    // // mPbPb_Reco[i]->Print("base");

    // mPbPb_GenInput[i]->Print("base");
    // mPbPb_Gen[i] = new TH1F(Form("mPbPb_Gen_spectra_cent%d",i),"",nbins, ptbins_long);
    // Truncate1D(mPbPb_GenInput[i], mPbPb_Gen[i]);
    // mPbPb_Gen[i]->Print("base");
    
    // mPbPb_RecoInput[i]->Print("base");
    // mPbPb_Reco[i] = new TH1F(Form("mPbPb_REco_spectra_cent%d",i),"",nbins, ptbins_long);
    // Truncate1D(mPbPb_RecoInput[i], mPbPb_Reco[i]);
    // mPbPb_Reco[i]->Print("base");
    
    // mPbPb_MatrixInput[i]->Print("base");
    // mPbPb_Matrix[i] = new TH2F(Form("mPbPb_Response_Matrix_cent%d",i),"",nbins_truncated, ptbins_long_truncated, nbins_truncated, ptbins_long_truncated);
    // Truncate2D(mPbPb_MatrixInput[i], mPbPb_Matrix[i]);
    // mPbPb_Matrix[i]->Print("base");
 
  }
  
  if(printDebug) cout<<"loaded the data and mc PbPb histograms from the files"<<endl;

  // get PP data
  if(printDebug) cout<<"Getting PP data and MC"<<endl;

  //fPP_in->ls();

  // dPP_1 = (TH1F*)fPP_in->Get(Form("hpp_HLT80_R%d_%s",radius,etaWidth)); 
  // dPP_1->Print("base");
  // dPP_2 = (TH1F*)fPP_in->Get(Form("hpp_HLT60_R%d_%s",radius,etaWidth));
  // dPP_2->Print("base");
  // dPP_3 = (TH1F*)fPP_in->Get(Form("hpp_HLT40_R%d_%s",radius,etaWidth));
  // dPP_3->Print("base");
  dPP_Comb = (TH1F*)fPP_in->Get(Form("hpp_HLTComb_R%d_%s",radius,etaWidth));
  //dPP_Comb = (TH1F*)dPP_1->Clone(Form("hpp_TrgComb_R%d_n20_eta_p20",radius,etaWidth));   
  //dPP_CombInput->Print("base");
  dPP_Comb->Scale(1./(5.3 * 1e9));
  
  // dPP_Comb = new TH1F("PP_MeasuredSpectra","",365, 30, 395);
  // Truncate1D(dPP_CombInput, dPP_Comb);

  //dPP_Comb = (TH1F*)dPP_Comb->Rebin(nbins, "PP_MeasuredSpectra", ptbins_long);
  dPP_Comb = (TH1F*)dPP_Comb->Rebin(10);
  dPP_Comb->SetName("PP_MeasuredSpectra");
  divideBinWidth(dPP_Comb);
  dPP_Comb->Print("base");
  
  // get PP MC
  // mPP_GenInput = (TH1F*)fPP_MC_in->Get(Form("hpp_anaBin_JetComb_gen_R%d_%s",radius,etaWidth));
  // mPP_GenInput->Print("base");
  // mPP_Gen = new TH1F("mPP_Gen_spectra","",nbins, ptbins_long);
  // Truncate1D(mPP_GenInput, mPP_Gen);
  // mPP_Gen->Print("base");
  
  // mPP_RecoInput = (TH1F*)fPP_MC_in->Get(Form("hpp_anaBin_JetComb_reco_R%d_%s",radius,etaWidth));
  // mPP_RecoInput->Print("base");
  // mPP_Reco = new TH1F("mPP_Reco_spectra","",nbins, ptbins_long);
  // Truncate1D(mPP_RecoInput, mPP_Reco);
  // mPP_Reco->Print("base");
  
  // mPP_MatrixInput = (TH2F*)fPP_MC_in->Get(Form("hpp_anaBin_matrix_HLT_R%d_%s",radius,etaWidth));
  // mPP_MatrixInput->Print("base");
  // mPP_Matrix = new TH2F("mPP_response_Matrix","",nbins_truncated, ptbins_long_truncated, nbins_truncated, ptbins_long_truncated);
  // Truncate2D(mPP_MatrixInput, mPP_Matrix);
  // mPP_Matrix->Print("base");

  // get PP MC
  // change from fPP_MC_in to fPP_in to run finebinscut
  //mPP_Gen = (TH1F*)fPP_MC_in->Get(Form("hpp_anaBin_JetComb_gen_R%d_20_eta_20",radius));
  mPP_Gen = (TH1F*)fPP_MC_in->Get(Form("hpp_JetComb_gen_R%d_20_eta_20",radius));
  //mPP_Gen->Rebin(nbins, "mPP_Gen", ptbins_long);
  mPP_Gen->Rebin(10);
  divideBinWidth(mPP_Gen);
  mPP_Gen->Print("base");

  //mPP_Reco = (TH1F*)fPP_MC_in->Get(Form("hpp_anaBin_JetComb_reco_R%d_20_eta_20",radius));
  mPP_Reco = (TH1F*)fPP_MC_in->Get(Form("hpp_JetComb_reco_R%d_20_eta_20",radius));
  //mPP_Gen->Rebin(nbins, "mPP_Gen", ptbins_long);
  mPP_Reco->Rebin(10);
  divideBinWidth(mPP_Reco);
  mPP_Reco->Print("base");

  //mPP_Matrix = (TH2F*)fPP_MC_in->Get(Form("hpp_anaBin_matrix_HLT_R%d_20_eta_20",radius));
  mPP_Matrix = (TH2F*)fPP_MC_in->Get(Form("hpp_matrix_HLT_R%d_20_eta_20",radius));
  mPP_Matrix->Rebin2D(10, 10);
  mPP_Matrix->Print("base");

  if(printDebug) cout<<"Filling the PbPb response Matrix"<<endl;

  // response matrix and unfolding for PbPb 
  // going to try it the way kurt has its. 

  for(int i = 0;i<nbins_cent;i++){
    if(printDebug) cout<<"centrality bin iteration = "<<i<<endl;
    TF1 *f = new TF1("f","[0]*pow(x+[2],[1])");
    f->SetParameters(1e10,-8.8,40);
    // TH1F *hGenSpectraCorr = (TH1F*)mPbPb_Matrix[i]->ProjectionX()->Clone(Form("hGenSpectraCorr_cent%d",i));
    // hGenSpectraCorr->Fit("f"," ");
    // hGenSpectraCorr->Fit("f","","");
    // hGenSpectraCorr->Fit("f","LL");
    // TH1F *fHist = functionHist(f,hGenSpectraCorr,Form("fHist_cent%d",i));// function that you get from the fitting 
    // hGenSpectraCorr->Divide(fHist);
    for (int y=1;y<=mPbPb_Matrix[i]->GetNbinsY();y++) {
      double sum=0;
      for (int x=1;x<=mPbPb_Matrix[i]->GetNbinsX();x++) {
	if (mPbPb_Matrix[i]->GetBinContent(x,y)<=1*mPbPb_Matrix[i]->GetBinError(x,y)) {
	  //in the above line mine had 0*getbinerror while Kurt's had 1*. 
	  mPbPb_Matrix[i]->SetBinContent(x,y,0);
	  mPbPb_Matrix[i]->SetBinError(x,y,0);
	}
	sum+=mPbPb_Matrix[i]->GetBinContent(x,y);
      }
      
      for (int x=1;x<=mPbPb_Matrix[i]->GetNbinsX();x++) {	   
	double ratio = 1;
	// if (hGenSpectraCorr->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorr->GetBinContent(x);
	mPbPb_Matrix[i]->SetBinContent(x,y,mPbPb_Matrix[i]->GetBinContent(x,y)*ratio);
	mPbPb_Matrix[i]->SetBinError(x,y,mPbPb_Matrix[i]->GetBinError(x,y)*ratio);
      }
    }
    //mPbPb_Matrix[i]->Smooth(0);
    // Ok major differences here between my code and Kurt in b-jet Tools under Unfold - lines 469 and above.  
    
    mPbPb_Response[i] = (TH2F*)mPbPb_Matrix[i]->Clone(Form("mPbPb_Response_cent%d",i));
    TH1F *hProj = (TH1F*)mPbPb_Response[i]->ProjectionY()->Clone(Form("hProj_cent%d",i));

    for (int y=1;y<=mPbPb_Response[i]->GetNbinsY();y++) {
      double sum=0;
      for (int x=1;x<=mPbPb_Response[i]->GetNbinsX();x++) {
	if (mPbPb_Response[i]->GetBinContent(x,y)<=1*mPbPb_Response[i]->GetBinError(x,y)) {
	  // in the above if loop, kurt has 1*error and my old had 0*error
	  mPbPb_Response[i]->SetBinContent(x,y,0);
	  mPbPb_Response[i]->SetBinError(x,y,0);
	}
	sum+=mPbPb_Response[i]->GetBinContent(x,y);
      }
      
      for (int x=1;x<=mPbPb_Response[i]->GetNbinsX();x++) {  	
	if (sum==0) continue;
	double ratio = 1;
	//if(dPbPb_TrgComb[i]->GetBinContent(y)==0) ratio = 1e-100/sum;
	// else ratio = dPbPb_TrgComb[i]->GetBinContent(y)/sum
	ratio = 1./sum;
	if (hProj->GetBinContent(y)==0) ratio = 1e-100/sum;
	else ratio = hProj->GetBinContent(y)/sum;
	mPbPb_Response[i]->SetBinContent(x,y,mPbPb_Response[i]->GetBinContent(x,y)*ratio);
	mPbPb_Response[i]->SetBinError(x,y,mPbPb_Response[i]->GetBinError(x,y)*ratio);
      }
    }
    
    mPbPb_ResponseNorm[i] = (TH2F*)mPbPb_Matrix[i]->Clone(Form("mPbPb_ResponseNorm_cent%d",i));
    for (int x=1;x<=mPbPb_ResponseNorm[i]->GetNbinsX();x++) {
      double sum=0;
      for (int y=1;y<=mPbPb_ResponseNorm[i]->GetNbinsY();y++) {
	if (mPbPb_ResponseNorm[i]->GetBinContent(x,y)<=1*mPbPb_ResponseNorm[i]->GetBinError(x,y)) {
	  mPbPb_ResponseNorm[i]->SetBinContent(x,y,0);
	  mPbPb_ResponseNorm[i]->SetBinError(x,y,0);
	}
	sum+=mPbPb_ResponseNorm[i]->GetBinContent(x,y);
      }
      
      for (int y=1;y<=mPbPb_ResponseNorm[i]->GetNbinsY();y++) {  	
	if (sum==0) continue;
	double ratio = 1./sum;
	mPbPb_ResponseNorm[i]->SetBinContent(x,y,mPbPb_ResponseNorm[i]->GetBinContent(x,y)*ratio);
	mPbPb_ResponseNorm[i]->SetBinError(x,y,mPbPb_ResponseNorm[i]->GetBinError(x,y)*ratio);
      }
      
    }
    
    
  }

  
  if(printDebug) cout<<"Filling PP response Matrix"<<endl;

  // response matrix for pp.  
  // Kurt doesnt have this whole hGenSpectraCorr thing in his macro. need to check why the difference exists between out codes
  
  TF1 *fpp = new TF1("fpp","[0]*pow(x+[2],[1])");
  fpp->SetParameters(1e10,-8.8,40);
  // if(printDebug) cout<<"before getting the gen spectra corr matrix"<<endl;
  // TH1F *hGenSpectraCorrPP = (TH1F*)mPP_Matrix->ProjectionX()->Clone("hGenSpectraCorrPP");
  // if(printDebug) cout<<"after gettign the gen spectra corr matrix"<<endl;
  // hGenSpectraCorrPP->Fit("f"," ");
  // hGenSpectraCorrPP->Fit("f","","");
  // hGenSpectraCorrPP->Fit("f","LL");
  // TH1F *fHistPP = functionHist(fpp,hGenSpectraCorrPP,"fHistPP");// that the function that you get from the fitting 
  // hGenSpectraCorrPP->Divide(fHistPP);
  
  for (int y=1;y<=mPP_Matrix->GetNbinsY();y++) {
    double sum=0;
    for (int x=1;x<=mPP_Matrix->GetNbinsX();x++) {
      if (mPP_Matrix->GetBinContent(x,y)<=1*mPP_Matrix->GetBinError(x,y)) {
	mPP_Matrix->SetBinContent(x,y,0);
	mPP_Matrix->SetBinError(x,y,0);
      }
      sum+=mPP_Matrix->GetBinContent(x,y);
    }
    
    for (int x=1;x<=mPP_Matrix->GetNbinsX();x++) {	   
      double ratio = 1;
      // if (hGenSpectraCorrPP->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorrPP->GetBinContent(x);
      mPP_Matrix->SetBinContent(x,y,mPP_Matrix->GetBinContent(x,y)*ratio);
      mPP_Matrix->SetBinError(x,y,mPP_Matrix->GetBinError(x,y)*ratio);
    }
  }
  // mPbPb_Matrix[i]->Smooth(0);
  
  // Ok major differences here between my code and Kurt in b-jet Tools under Unfold - lines 469 and above.  

  if(printDebug) cout<<"getting the response matrix"<<endl;

  mPP_Response = (TH2F*)mPP_Matrix->Clone("mPP_Response");
  TH1F *hProjPP = (TH1F*)mPP_Response->ProjectionY()->Clone("hProjPP");
  
  
  for (int y=1;y<=mPP_Response->GetNbinsY();y++) {
    double sum=0;
    for (int x=1;x<=mPP_Response->GetNbinsX();x++) {
      if (mPP_Response->GetBinContent(x,y)<=1*mPP_Response->GetBinError(x,y)) {
	// in the above if statement, kurt has 1*error and my old has 0*error
	mPP_Response->SetBinContent(x,y,0);
	mPP_Response->SetBinError(x,y,0);
      }
      sum+=mPP_Response->GetBinContent(x,y);
    }
    
    for (int x=1;x<=mPP_Response->GetNbinsX();x++) {  	
      if (sum==0) continue;
      double ratio = 1;
      //if(dPbPb_TrgComb[i]->GetBinContent(y)==0) ratio = 1e-100/sum;
      // else ratio = dPbPb_TrgComb[i]->GetBinContent(y)/sum
      ratio = 1./sum;
      if (hProjPP->GetBinContent(y)==0) ratio = 1e-100/sum;
      else ratio = hProjPP->GetBinContent(y)/sum;
      mPP_Response->SetBinContent(x,y,mPP_Response->GetBinContent(x,y)*ratio);
      mPP_Response->SetBinError(x,y,mPP_Response->GetBinError(x,y)*ratio);
    }
  }
  if(printDebug) cout<<"getting the normalized response matrix"<<endl;
  mPP_ResponseNorm = (TH2F*)mPP_Matrix->Clone("mPP_ResponseNorm");
  for (int x=1;x<=mPP_ResponseNorm->GetNbinsX();x++) {
    double sum=0;
    for (int y=1;y<=mPP_ResponseNorm->GetNbinsY();y++) {
      if (mPP_ResponseNorm->GetBinContent(x,y)<=1*mPP_ResponseNorm->GetBinError(x,y)) {
	mPP_ResponseNorm->SetBinContent(x,y,0);
	mPP_ResponseNorm->SetBinError(x,y,0);
      }
      sum+=mPP_ResponseNorm->GetBinContent(x,y);
    }
    
    for (int y=1;y<=mPP_ResponseNorm->GetNbinsY();y++) {  	
      if (sum==0) continue;
      double ratio = 1./sum;
      mPP_ResponseNorm->SetBinContent(x,y,mPP_ResponseNorm->GetBinContent(x,y)*ratio);
      mPP_ResponseNorm->SetBinError(x,y,mPP_ResponseNorm->GetBinError(x,y)*ratio);
    }
    
    
  }
  
  // scale the spectra to the respective units

  // for(int i = 0;i<nbins_cent;++i){
  //   dPbPb_TrgComb[i] = (TH1F*)dPbPb_TrgComb[i]->Rebin(nbins,Form("PbPb_measured_spectra_combined_cent%d",i),ptbins_long);
  //   divideBinWidth(dPbPb_TrgComb[i]);
  // }

  // dPP_Comb = (TH1F*)dPP_Comb->Rebin(nbins,"pp_measured_spectra_combined",ptbins_long);
  // divideBinWidth(dPP_Comb);
  // dPP_Comb->Scale(1./ dPP_Comb->GetBinContent(nbins));
  
  // Now that we have all the response matrix for the 6 centralities in PbPb and one pp spectra lets start doing the steps:
  // we have 39 pt bins, so we need 1000 gaussian functions for each pt bin.
  
  Int_t unfoldingTrials = 1000;
  Double_t meanMeasPbPb[nbins][nbins_cent], sigmaMeasPbPb[nbins][nbins_cent];
  Double_t meanMeasPP[nbins], sigmaMeasPP[nbins];
  Double_t meanUnfoldPbPb[nbins][nbins_cent][unfoldingTrials], sigmaUnfoldPbPb[nbins][nbins_cent][unfoldingTrials];
  Double_t meanUnfoldPP[nbins][unfoldingTrials], sigmaUnfoldPP[nbins][unfoldingTrials]; 
  
  TRandom3 *random = new TRandom3(0);

  TH1F * hPbPb_beforeUnfold_Gaussian_pt150[nbins_cent];
  TH1F * hPP_beforeUnfold_Gaussian_pt150; 
  hPP_beforeUnfold_Gaussian_pt150 = new TH1F("hPP_beforeUnfold_Gaussian_pt150","",1000, 0.1 * dPP_Comb->GetBinContent(dPP_Comb->FindBin(150)) , 1.9 * dPP_Comb->GetBinContent(dPP_Comb->FindBin(150)));
  
  for(int i = 0; i<nbins_cent; ++i)
    hPbPb_beforeUnfold_Gaussian_pt150[i] = new TH1F(Form("hPbPb_beforeUnfold_Gaussian_pt150_cent%d",i),"Before Unfolding pt bin at 150 value spectra",1000, 0.1 * dPbPb_TrgComb[i]->GetBinContent(dPbPb_TrgComb[i]->FindBin(150)), 1.9 * dPbPb_TrgComb[i]->GetBinContent(dPbPb_TrgComb[i]->FindBin(150)));
  

  for(int u = 0;u<unfoldingTrials;++u){
    cout<<"unfolding trial no = "<<u+1<<endl;
  
    for(int j = 0;j<nbins;++j){
      for(int i = 0;i<nbins_cent;++i){
      
	meanMeasPbPb[j][i] = dPbPb_TrgComb[i]->GetBinContent(j+1);
	sigmaMeasPbPb[j][i] = dPbPb_TrgComb[i]->GetBinError(j+1);

      }// centrality loop

      meanMeasPP[j] = dPP_Comb->GetBinContent(j+1);
      sigmaMeasPP[j] = dPP_Comb->GetBinError(j+1);
      
    }// nbins loop

    // now proceed to unfolding for each trial.

    for(int i = 0;i<nbins_cent;++i){

      TH1F * hPreUnfoldingSpectra = new TH1F("hPreUnfoldingSpectra","",nbins,0, 1000);
      TH1F * hAfterUnfoldingSpectra;

      for(int j = 0;j<nbins;++j){
	
	hPreUnfoldingSpectra->SetBinContent(j+1, random->Gaus(meanMeasPbPb[j][i], sigmaMeasPbPb[j][i]));
	hPreUnfoldingSpectra->SetBinError(j+1, sigmaMeasPbPb[j][i]/sqrt(unfoldingTrials));
	if(j+1 == dPbPb_TrgComb[i]->FindBin(150)) hPbPb_beforeUnfold_Gaussian_pt150[i]->Fill(random->Gaus(meanMeasPbPb[j][i], sigmaMeasPbPb[j][i]));
	
      }// nbins loop

      TH1F* hMCGen          = (TH1F*)mPbPb_Response[i]->ProjectionX();
      removeZero(hMCGen);
      bayesianUnfold myUnfoldingMulti(mPbPb_Matrix[i], hMCGen, 0);
      myUnfoldingMulti.unfold(hPreUnfoldingSpectra, BayesIter);

      hAfterUnfoldingSpectra = (TH1F*) myUnfoldingMulti.hPrior->Clone("hAfterUnfoldingSpectra");

      for(int j = 0;j<nbins;++j){

	meanUnfoldPbPb[j][i][u] = hAfterUnfoldingSpectra->GetBinContent(j+1);
	sigmaUnfoldPbPb[j][i][u] = hAfterUnfoldingSpectra->GetBinError(j+1);

      }// nbins loop
      
      delete hPreUnfoldingSpectra;
      delete hAfterUnfoldingSpectra;
      delete hMCGen; 
      
    }// centrality loop

    cout<<"pp "<<endl;

    // now do it for the pp:
    TH1F * hPreUnfoldingSpectraPP = new TH1F("hPreUnfoldingSpectraPP","",nbins,0, 1000);
    TH1F * hAfterUnfoldingSpectraPP;
    
    for(int j = 0;j<nbins;++j){
	
      hPreUnfoldingSpectraPP->SetBinContent(j+1, random->Gaus(meanMeasPP[j], sigmaMeasPP[j]));
      hPreUnfoldingSpectraPP->SetBinError(j+1, sigmaMeasPP[j]/sqrt(unfoldingTrials));
      if(j+1 == dPP_Comb->FindBin(150)) hPP_beforeUnfold_Gaussian_pt150->Fill(random->Gaus(meanMeasPP[j], sigmaMeasPP[j]));
      
    }// nbins loop
    TH1F* hMCGenPP          = (TH1F*)mPP_Response->ProjectionX();
    removeZero(hMCGenPP);
    bayesianUnfold myUnfoldingMultiPP(mPP_Matrix, hMCGenPP, 0);
    myUnfoldingMultiPP.unfold(hPreUnfoldingSpectraPP, BayesIter);

    hAfterUnfoldingSpectraPP = (TH1F*) myUnfoldingMultiPP.hPrior->Clone("hAfterUnfoldingSpectraPP");

    for(int j = 0;j<nbins;++j){

      meanUnfoldPP[j][u] = hAfterUnfoldingSpectraPP->GetBinContent(j+1);
      sigmaUnfoldPP[j][u] = hAfterUnfoldingSpectraPP->GetBinError(j+1);

    }// nbins loop

    delete hPreUnfoldingSpectraPP;
    delete hAfterUnfoldingSpectraPP;
    delete hMCGenPP; 
    
  }// unfolding trials loop


  // Now that we have all the necesary values we need, lets proceed to fill a histogram with the mean values for each ptbin and get the corrected values.
  TH1F * hAfterUnfoldingptBinDistribution[nbins];
  TH1F * hCorrUnfoldingPbPb[nbins_cent];

  // we need to store one gaussian histogram in the root file which we can plot 
  TH1F * hPbPb_Gaussian_pt150[nbins_cent];
  TH1F * hPP_Gaussian_pt150;


  for(int i = 0;i<nbins_cent;++i){

    hCorrUnfoldingPbPb[i] = new TH1F(Form("PbPb_BayesianUnfolded_cent%d",i),"Spectra after correction", nbins,0, 1000);
    hPbPb_Gaussian_pt150[i] = new TH1F(Form("PbPb_Gaussian_pt150_cent%d",i),"gaussian distribution of values at pt bin at 150",1000, 0.1 * dPbPb_TrgComb[i]->GetBinContent(dPbPb_TrgComb[i]->FindBin(150)), 1.9 * dPbPb_TrgComb[i]->GetBinContent(dPbPb_TrgComb[i]->FindBin(150)));

    for(int j = 0;j<nbins;++j){
      
      hAfterUnfoldingptBinDistribution[j] = new TH1F(Form("hAfterUnfoldingptBinDistribution_ptBin%d",j),"",100,	0, 1);
      for(int u = 0;u<unfoldingTrials;++u){

	hAfterUnfoldingptBinDistribution[j]->Fill(meanUnfoldPbPb[j][i][u]);
	if(j+1 == dPbPb_TrgComb[i]->FindBin(150)) hPbPb_Gaussian_pt150[i]->Fill(meanUnfoldPbPb[j][i][u]);

      }// unfolding trials loop

      hCorrUnfoldingPbPb[i]->SetBinContent(j+1, hAfterUnfoldingptBinDistribution[j]->GetMean());
      hCorrUnfoldingPbPb[i]->SetBinError(j+1, hAfterUnfoldingptBinDistribution[j]->GetRMS());

      delete hAfterUnfoldingptBinDistribution[j];
      
    }// nbins loop

  }// centrality loop

  // similar for the pp:
  TH1F * hAfterUnfoldingptBinDistributionPP[nbins];
  TH1F * hCorrUnfoldingPP;
  
  hCorrUnfoldingPP = new TH1F("PP_BayesianUnfolded","Spectra after unfolding error correction",nbins,0, 1000);
  hPP_Gaussian_pt150 = new TH1F("PP_Gaussian_pt100","gaussian distribution of values at pt bin at 150",1000, 0.1 * dPP_Comb->GetBinContent(dPP_Comb->FindBin(150)) , 1.9 * dPP_Comb->GetBinContent(dPP_Comb->FindBin(150)));
  
  for(int j = 0;j<nbins;++j){
    
    hAfterUnfoldingptBinDistributionPP[j] = new TH1F(Form("hAfterUnfoldingptBinDistributionPP_ptBin%d",j),"",100, 0, 1);
    for(int u = 0;u<unfoldingTrials;++u){
      
      hAfterUnfoldingptBinDistributionPP[j]->Fill(meanUnfoldPP[j][u]);
      if(j+1 == dPP_Comb->FindBin(150)) hPP_Gaussian_pt150->Fill(meanUnfoldPP[j][u]);
      
    }// unfolding trials loop
    
    hCorrUnfoldingPP->SetBinContent(j+1, hAfterUnfoldingptBinDistributionPP[j]->GetMean());
    hCorrUnfoldingPP->SetBinError(j+1, hAfterUnfoldingptBinDistributionPP[j]->GetRMS());
    
    delete hAfterUnfoldingptBinDistributionPP[j];
    
  }// nbins loop
    
  TFile f(Form("July20/HiForest_%disATLASCut_%ddo10GeVBins_data_driven_correction_ak%d.root" , isATLASCut, do10GeVBins, radius),"RECREATE");
  f.cd();

  for(int i = 0;i<nbins_cent;i++) {

    //hCorrUnfoldingPbPb[i] = (TH1F*)hCorrUnfoldingPbPb[i]->Rebin(nbins_coarse, Form("PbPb_BayesianUnfolded_cent%d",i), ptbins_long_coarse);
    //divideBinWidth(hCorrUnfoldingPbPb[i]);
    //dPbPb_TrgComb[i] = (TH1F*)dPbPb_TrgComb[i]->Rebin(nbins_coarse, Form("PbPb_measured_cent%d",i), ptbins_long_coarse);
    //divideBinWidth(dPbPb_TrgComb[i]);

    hMinBias[i]->Write();
    hDataBeforeSub[i]->Write();
    hDataAfterSub[i]->Write();
    
    hCorrUnfoldingPbPb[i]->Scale(166 * 1e9);
    hCorrUnfoldingPbPb[i]->Write();
    hCorrUnfoldingPbPb[i]->Print("base");

    dPbPb_TrgComb[i]->Scale(166 * 1e9);
    dPbPb_TrgComb[i]->SetName(Form("PbPb_data_minbiasSub_cent%d",i));
    //dPbPb_TrgComb[i]->Scale(145.156 * 1e9);
    dPbPb_TrgComb[i]->Write();
    dPbPb_TrgComb[i]->Print("base");

    hPbPb_beforeUnfold_Gaussian_pt150[i]->Write();
    hPbPb_beforeUnfold_Gaussian_pt150[i]->Print("base");
    
    hPbPb_Gaussian_pt150[i]->Write();
    hPbPb_Gaussian_pt150[i]->Print("base");

    mPbPb_Matrix[i]->Write();
    
  }

  //hCorrUnfoldingPP = (TH1F*)hCorrUnfoldingPP->Rebin(nbins_coarse, "PP_BayesianUnfolded", ptbins_long_coarse);
  //divideBinWidth(hCorrUnfoldingPP);
  //dPP_Comb = (TH1F*)dPP_Comb->Rebin(nbins_coarse, "PP_measured", ptbins_long_coarse);  
  //divideBinWidth(dPP_Comb);
  
  hCorrUnfoldingPP->Scale(5.3 * 1e9);
  hCorrUnfoldingPP->Write();
  hCorrUnfoldingPP->Print("base");

  dPP_Comb->Scale(5.3 * 1e9);
  dPP_Comb->Write();
  dPP_Comb->Print("base");

  hPP_beforeUnfold_Gaussian_pt150->Write();
  hPP_beforeUnfold_Gaussian_pt150->Print("base");
  
  hPP_Gaussian_pt150->Write();
  hPP_Gaussian_pt150->Print("base");
  mPP_Matrix->Write();

  f.Write();
  f.Close();

  // make the data driven Error correction histograms and plots here:
  
  TH1F * hError_Meas[nbins_cent+1], * hError_Fixed[nbins_cent+1];
  for(int i = 0; i<nbins_cent+1; ++i){
    cout<<"centrality "<<i<<endl;
    if(i < nbins_cent){
      hError_Meas[i]  = new TH1F(Form("hError_Meas_cent%d",i),"",nbins, 0, 1000);
      hError_Fixed[i] = new TH1F(Form("hError_Fixed_cent%d",i),"",nbins, 0, 1000);
    }
    if(i == nbins_cent){
      hError_Meas[i]  = new TH1F(Form("hError_PP_Meas_cent%d",i),"",nbins, 0, 1000);
      hError_Fixed[i] = new TH1F(Form("hError_PP_Fixed_cent%d",i),"",nbins, 0, 1000);
    }

    for(int j = 1; j<=nbins; ++j){
      //cout<<"ptbins "<<j<<endl;
      if(i < nbins_cent){
	if(dPbPb_TrgComb[i]->GetBinContent(j)!=0) hError_Meas[i]->SetBinContent(j, (float)dPbPb_TrgComb[i]->GetBinError(j)/dPbPb_TrgComb[i]->GetBinContent(j));
        //hError_Meas[i]->SetBinContent(j, (float)dPbPb_TrgComb[i]->GetBinError(j));
	if(hCorrUnfoldingPbPb[i]->GetBinContent(j)!=0)hError_Fixed[i]->SetBinContent(j, (float)hCorrUnfoldingPbPb[i]->GetBinError(j)/hCorrUnfoldingPbPb[i]->GetBinContent(j));
	cout<<j<<" "<<hError_Fixed[i]->GetBinContent(j)<<endl;
	//hError_Fixed[i]->SetBinContent(j, (float)hCorrUnfoldingPbPb[i]->GetBinError(j));
      }
      if(i == nbins_cent){
	hError_Meas[i]->SetBinContent(j, (float)dPP_Comb->GetBinError(j)/dPP_Comb->GetBinContent(j));
	//hError_Meas[i]->SetBinContent(j, (float)dPP_Comb->GetBinError(j));
	hError_Fixed[i]->SetBinContent(j, (float)hCorrUnfoldingPP->GetBinError(j)/hCorrUnfoldingPP->GetBinContent(j));
	//hError_Fixed[i]->SetBinContent(j, (float)hCorrUnfoldingPP->GetBinError(j));
      }
    }
    
    hError_Meas[i]->SetAxisRange(50, 299, "X");
    //hError_Meas[i]->Print("base");
    //hError_Fixed[i]->Print("base");
    //hError_Meas[i]->SetAxisRange(1e-12, 1, "Y");
  }
  //cout<<" passed the loop"<<endl;

  TCanvas * cSpectra = new TCanvas("cSpectra","",1200,1000);
  makeMultiPanelCanvas(cSpectra,3,2,0.0,0.0,0.2,0.15,0.07);  
  for(int i = 0; i<nbins_cent; ++i){
    //cout<<i<<endl;
    cSpectra->cd(nbins_cent-i);
    cSpectra->cd(nbins_cent-i)->SetLogy();
    dPbPb_TrgComb[i]->SetMarkerStyle(24);
    dPbPb_TrgComb[i]->SetMarkerColor(kBlack);
    makeHistTitle(dPbPb_TrgComb[i]," ","jet pT","dN/dpT");
    dPbPb_TrgComb[i]->SetAxisRange(50, 299, "X");
    dPbPb_TrgComb[i]->Draw("p");

    hCorrUnfoldingPbPb[i]->SetMarkerStyle(33);
    hCorrUnfoldingPbPb[i]->SetMarkerColor(kRed);
    hCorrUnfoldingPbPb[i]->Draw("psame");

  }
  TLegend * Spec = myLegend(0.55,0.55,0.75,0.75);
  cSpectra->cd(1);
  putCMSPrel();
  Spec->AddEntry(dPbPb_TrgComb[0],"Measured","pl");
  Spec->AddEntry(hCorrUnfoldingPbPb[0],"Data Driven Correction","pl");
  Spec->SetTextSize(0.04);
  Spec->Draw();
  
  cSpectra->SaveAs(Form("%sUnfoldingSpectra_fromDataDrivenMacro_PbPb_%s_R%d_%d_hiForest_%dGeVCut.pdf",outLocation,etaWidth,radius,date.GetDate(),unfoldingCut),"RECREATE");

  
  TCanvas * cErrorFix = new TCanvas("cErrorFix","",1200,1000);
  makeMultiPanelCanvas(cErrorFix,3,2,0.0,0.0,0.2,0.15,0.07);  
  for(int i = 0; i<nbins_cent; ++i){
    //cout<<i<<endl;
    cErrorFix->cd(nbins_cent-i);
    cErrorFix->cd(nbins_cent-i)->SetLogy();
    makeHistTitle(hError_Meas[i]," ","jet pT","Error/Content");
    hError_Meas[i]->SetMarkerStyle(24);
    hError_Meas[i]->SetMarkerColor(kBlack);
    hError_Meas[i]->Draw("p");

    hError_Fixed[i]->SetMarkerStyle(33);
    hError_Fixed[i]->SetMarkerColor(kRed);
    hError_Fixed[i]->Draw("psame");

  }
  TLegend * err = myLegend(0.55,0.55,0.75,0.75);
  cErrorFix->cd(1);
  putCMSPrel();
  err->AddEntry(hError_Meas[0],"Measured","pl");
  err->AddEntry(hError_Fixed[0],"Data Driven Correction","pl");
  err->SetTextSize(0.04);
  err->Draw();
  
  cErrorFix->SaveAs(Form("%sUnfoldingErrorFix_fromDataDrivenMacro_PbPb_%s_R%d_%d_hiForest_%dGeVCut.pdf",outLocation,etaWidth,radius,date.GetDate(),unfoldingCut),"RECREATE");

  TCanvas * cErrorFixPP = new TCanvas("cErrorFixPP","",800,600);
  cErrorFixPP->SetLogy();
  hError_Meas[nbins_cent]->SetMarkerStyle(24);
  hError_Meas[nbins_cent]->SetMarkerColor(kBlack);
  hError_Meas[nbins_cent]->Draw("p");
  
  hError_Fixed[nbins_cent]->SetMarkerStyle(33);
  hError_Fixed[nbins_cent]->SetMarkerColor(kRed);
  hError_Fixed[nbins_cent]->Draw("psame");
  TLegend * errPP = myLegend(0.55,0.55,0.75,0.75);
  putCMSPrel();
  errPP->AddEntry(hError_Meas[nbins_cent],"Measured","pl");
  errPP->AddEntry(hError_Fixed[nbins_cent],"Data Driven Correction","pl");
  errPP->SetTextSize(0.04);
  errPP->Draw();
  
  cErrorFixPP->SaveAs(Form("%sUnfoldingErrorFix_fromDataDrivenMacro_PP_%s_R%d_%d_hiForest_%dGeVCut.pdf",outLocation,etaWidth,radius,date.GetDate(),unfoldingCut),"RECREATE");
  
  timer.Stop();
  if(printDebug) cout<<"CPU time (mins) = "<<(Float_t)timer.CpuTime()/60<<endl;
  if(printDebug) cout<<"Real tile (mins) = "<<(Float_t)timer.RealTime()/60<<endl;


}
예제 #16
0
void CompareRawSpectrapPbPbp(int ieta)
{
  bool SavePlots=kTRUE;
  
  double EtaMin[8] = {-2.0, -1.5, -1.0, -0.5, 0.5, 1.0, 1.5, -1.0 };
  double EtaMax[8] = {-1.5, -1.0, -0.5,  0.5, 1.0, 1.5, 2.0,  1.0 };

  double RevEtaMin[8];
  double RevEtaMax[8];

  for(int j=0; j<8; j++)
  {
    RevEtaMin[j]=-EtaMax[j];
    RevEtaMax[j]=-EtaMin[j];
  }

//  int ieta=6; //0 to 7
 
  double StartPoint=50.;
  double EndPoint;

  if(TMath::Abs(EtaMin[ieta])==TMath::Abs(EtaMax[ieta]))  EndPoint = 430.;
  else if(ieta>0 && ieta<4 )         EndPoint = 300;
  else EndPoint = 250; 
  
 // TFile *f1 = new TFile(Form("/home/xuq/Documents/HI/RpA/output/UnfoldedOutputs/PPb_UnfoPriorGen_akPu3PFKurtForestEtaWeightNoIDCut_jtpt20_EtaBin%.f_%.f_Inc_v13.root",RevEtaMin[ieta]*10,RevEtaMax[ieta]*10));//PPb no residual unfolding
  TFile *f1 = new TFile(Form("/home/xuq/Documents/HI/RpA/output/UnfoldedOutputs/PPb_UnfoPriorGen_akPu3PFKurtMCNoIDCut_MC_jtpt20_EtaBin%.f_%.f_Inc_v8.root",RevEtaMin[ieta]*10,RevEtaMax[ieta]*10));//PPb no residual unfolding
  TFile *f2 = new TFile(Form("/home/xuq/Documents/HI/RpA/output/UnfoldedOutputs/PbP_UnfoPriorGen_akPu3PFKurtMCNoIDCut_MC_jtpt20_EtaBin%.f_%.f_Inc_v8.root",EtaMin[ieta]*10,EtaMax[ieta]*10));//PPb no residual unfolding

  
 TH1F *h1eta = (TH1F*)f1->Get(Form("hGen0"));
 TH1F *h2eta = (TH1F*)f2->Get(Form("hGen0"));



  double Lumi1 = 20.7*10E6;
  double Lumi2 = 14.0*10E6;
 
  TCanvas *c1 = new TCanvas("c1","c1",0,0,650,650);
  makeMultiPanelCanvas(c1,1,2,0.0,0.0,0.12,0.01,0.06);
  
  gStyle->SetOptStat(0);
  
  c1->cd(1)->SetLogy();
  
  TLegend *t1=new TLegend(0.35,0.75,0.8,0.93);
  t1->SetFillColor(0);
  t1->SetBorderSize(0);
  t1->SetFillStyle(0);
  t1->SetTextFont(63);
  t1->SetTextSize(17);

  TH1F *hDum =new TH1F("hdum","",50,StartPoint,EndPoint);
  hDum->SetMaximum(5.00E-3);
  hDum->SetMinimum(5.00E-10);
  hDum->GetYaxis()->SetTitle("d#sigma/dp_{T}");
  hDum->GetYaxis()->SetTitleSize(0.055);
  hDum->GetYaxis()->SetLabelSize(0.045);
  hDum->GetYaxis()->CenterTitle();
  
  hDum->DrawCopy();
//  h1eta->Scale(1./Lumi1);
//  h2eta->Scale(1./Lumi2);

  h1eta->GetXaxis()->SetRangeUser(StartPoint+5,EndPoint);
  h1eta->SetMarkerStyle(24);
  h1eta->SetMarkerColor(kBlue);
  h1eta->SetLineColor(kBlue);
  h1eta->SetMarkerSize(1.2);
 
  h2eta->GetXaxis()->SetRangeUser(StartPoint+5,EndPoint);
  h2eta->SetMarkerStyle(20);
  h2eta->SetMarkerColor(kRed);
  h2eta->SetLineColor(kRed);
  h2eta->SetMarkerSize(1.2);

  h1eta->DrawCopy("same");
  h2eta->DrawCopy("same");
  
  t1->AddEntry(h1eta,Form("PPb (%2.1f<#eta_{CM}<%2.1f)",EtaMin[ieta],EtaMax[ieta]),"P");
  t1->AddEntry(h2eta,Form("PbP (%2.1f<#eta_{CM}<%2.1f)",EtaMin[ieta],EtaMax[ieta]),"P");
 
  t1->Draw("same");
  c1->Update();


//-----------------------------------ratio-----------------------------------
  c1->cd(2);
  TH1F *ratio1=h1eta->Clone(h1eta->GetName());
  ratio1->Divide(h2eta);
  ratio1->SetMarkerSize(1.2);
  ratio1->SetMarkerStyle(21);
  ratio1->SetMarkerColor(kBlue);
  TH1F *hDum2 = new TH1F("hDum2","",50,StartPoint,EndPoint);
  hDum2->SetMaximum(1.45);
  hDum2->SetMinimum(0.65);
  hDum2->GetXaxis()->SetTitle("p_{T}[GeV/c]");
  hDum2->GetXaxis()->SetTitleSize(0.055);
  hDum2->GetXaxis()->SetLabelSize(0.045);
  hDum2->GetXaxis()->CenterTitle();

  hDum2->GetYaxis()->SetTitle("pPb/Pbp" );
  hDum2->GetYaxis()->SetTitleSize(0.055);
  hDum2->GetYaxis()->SetLabelSize(0.045);
  hDum2->GetYaxis()->CenterTitle();

  hDum2->DrawCopy();
  ratio1->DrawCopy("same");

  c1->Update();  

  TLine* l1 = new TLine(StartPoint,1.,EndPoint,1.);
  l1->SetLineWidth(1);
  l1->SetLineStyle(3);
  l1->SetLineColor(kBlack);
  l1->Draw();


  
  if(SavePlots) {
    c1->SaveAs(Form("ComparegenptSpectrapPb_PbpEta%.f_%.f.pdf",EtaMin[ieta]*10,EtaMax[ieta]*10));
   }


}
예제 #17
0
//__________________________________________________________________________
void Plot_JpsiV2_a1_newError()
{
  gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+");
  gStyle->SetOptFit(0);
 
  // options
  bool bDoDebug   = false;
  bool bSavePlots = true; 

  const int ncentbins    = 4;
  int    cts[ncentbins+1]  = {0, 10, 20, 30, 60};
  int centrality_start   = 0;
  int centrality_end     = 4; 
  int nPads = centrality_end - centrality_start; 
 
  const int nsignals           = 3;
  const char* signals[nsignals]      = {"NSig","NPr","Pr"};
  const char* legend[nsignals]       = {"Inclusive J/#psi","Non-prompt J/#psi","Prompt J/#psi",};
  int signal_start = 0;
  int signal_end   = 3; 
  
  const int nrapbins     = 2;
  double raps[nrapbins]  = {0.0, 2.4};
 
  const int nptbins      = 2; 
  double pts[nptbins]    = {6.5, 40.0};
  int pt_start = 0;
  int pt_end   = 1; 
 
  // phi bins
  const int nphibins = 4;
  float dPhiLimits[nphibins+1] = {0.0, TMath::PiOver2()/4, 2*TMath::PiOver2()/4, 3*TMath::PiOver2()/4, 4*TMath::PiOver2()/4};
  double dPhiBinCenters[nphibins];
  double dPhiBinCentersErr[nphibins];
 
  for(int ibin=0; ibin<nphibins; ibin++)
    {
      dPhiBinCenters[ibin]	= dPhiLimits[ibin]+dPhiBinWidth/2;
      dPhiBinCentersErr[ibin]   = 0.0;
      cout<<"bin limits"<< dPhiLimits[ibin] << "\t"<< dPhiLimits[ibin+1]<<"\t"<<dPhiBinCenters[ibin]<<endl;
    }
 

 // inclusive
   
  double gYieldP_0010_nsig[nphibins] = {0.6791,
					 0.6419,
					 0.6078,
					 0.6177}; // yield of etHFp for 0 - 10 %
  double gYieldP_1020_nsig[nphibins] = {0.6788,
					0.6745,
					0.6424,
					0.5508}; // yield of etHFp for 10 - 20 %
  double gYieldP_2030_nsig[nphibins] = {0.7705,
					0.5811,
					0.6172,
					0.5776}; // yield of etHFp for 20 - 30 %
  double gYieldP_3060_nsig[nphibins] = {0.6405,
					0.6994,
					0.5997,
					0.6069}; // yield of etHFp for 30 - 60 %
  
  double gYieldM_0010_nsig[nphibins] = {0.6796,
					 0.6196,
					 0.6358,
					 0.6115}; // yield of etHFm for 0 - 10 %
  double gYieldM_1020_nsig[nphibins] = {0.7550,
					0.6097,
					0.5786,
					0.6032}; // yield of etHFm for 10 - 20 %
  double gYieldM_2030_nsig[nphibins] = {0.7167,
					0.6719,
					0.5886,
					0.5693}; // yield of etHFm for 20 - 30 %
  double gYieldM_3060_nsig[nphibins] = {0.7554,
					0.6385,
					0.5759,
					0.5767}; // yield of etHFm for 30 - 60 %


  double gYieldP_0010_nsig_err[nphibins] = {0.0409,
					     0.0404,
					     0.0389,
					     0.0382}; // error of etHFp for 0 - 10 %
  double gYieldP_1020_nsig_err[nphibins] = {0.0436,
					    0.0427,
					    0.0413,
					    0.0386}; // error of etHFp for 10 - 20 %
  double gYieldP_2030_nsig_err[nphibins] = {0.0523,
					    0.0461,
					    0.0467,
					    0.0449}; // error of etHFp for 20 - 30 %
  double gYieldP_3060_nsig_err[nphibins] = {0.0396,
					    0.0409,
					    0.0378,
					    0.0379}; // error of etHFp for 30 - 60 %
  
  double gYieldM_0010_nsig_err[nphibins] = {0.0419,
					     0.0405,
					     0.0403,
					     0.0399}; // error of etHFm for 0 - 10 %
  double gYieldM_1020_nsig_err[nphibins] = {0.0469,
					    0.0425,
					    0.0414,
					    0.0419}; // error of etHFm for 10 - 20 %
  double gYieldM_2030_nsig_err[nphibins] = {0.0504,
					    0.0485,
					    0.0454,
					    0.0448}; // error of etHFm for 20 - 30 %
  double gYieldM_3060_nsig_err[nphibins] = {0.0423,
					    0.0389,
					    0.0369,
					    0.0371}; // error of etHFm for 30 - 60 %

   // prompt
  double gYieldP_0010_pr[nphibins] = {0.6533,
				       0.6450,
				       0.6174,
				       0.6307}; // yield of etHFp for 0 - 10 %
  double gYieldP_1020_pr[nphibins] = {0.6567,
				       0.6927,
				       0.6500,
				       0.5471}; // yield of etHFp for 10 - 20 %
  double gYieldP_2030_pr[nphibins] = {0.8234,
				       0.5767,
				       0.5598,
				       0.5866}; // yield of etHFp for 20 - 30 %
  double gYieldP_3060_pr[nphibins] = {0.6453,
				       0.7071,
				       0.6158,
				       0.5782}; // yield of etHFp for 30 - 60 %
  
  double gYieldM_0010_pr[nphibins] = {0.6538,
				       0.6226,
				       0.6458,
				       0.6244}; // yield of etHFm for 0 - 10 %
  double gYieldM_1020_pr[nphibins] = {0.7319,
				       0.6275,
				       0.5867,
				       0.6004}; // yield of etHFm for 10 - 20 %
  double gYieldM_2030_pr[nphibins] = {0.7665,
				       0.6673,
				       0.5342,
				       0.5785}; // yield of etHFm for 20 - 30 %
  double gYieldM_3060_pr[nphibins] = {0.7607,
				       0.6453,
				       0.5912,
				       0.5492}; // yield of etHFm for 30 - 60 %

  double gYieldP_0010_pr_err[nphibins] = {0.0555,
					  0.0472,
					  0.0510,
					  0.0450}; // error of etHFp for 0 - 10 %
  double gYieldP_1020_pr_err[nphibins] = {0.0525,
					  0.0511,
					  0.0516,
					  0.0513}; // error of etHFp for 10 - 20 %

  double gYieldP_2030_pr_err[nphibins] = {0.0613,
					  0.0568,
					  0.0490,
					  0.0615}; // error of etHFp for 20 - 30 %

  double gYieldP_3060_pr_err[nphibins] = {0.0476,
					  0.0476,
					  0.0431,
					  0.0439}; // error of etHFp for 30 - 60 %
  
  double gYieldM_0010_pr_err[nphibins] = {0.0465,
					  0.0492,
					  0.0482,
					  0.0463}; // error of etHFm for 0 - 10 %

  double gYieldM_1020_pr_err[nphibins] = {0.0625,
					  0.0491,
					  0.0517,
					  0.0515}; // error of etHFm for 10 - 20 %
  double gYieldM_2030_pr_err[nphibins] = {0.0617,
					  0.0561,
					  0.0488,
					  0.0516}; // error of etHFm for 20 - 30 %

  double gYieldM_3060_pr_err[nphibins] = {0.0504,
					  0.0443,
					  0.0465,
					  0.0419}; // error of etHFm for 30 - 60 %

  // non-prompt
  double gYieldP_0010_npr[nphibins] = {0.7498,
				       0.6333,
				       0.5816,
				       0.5818}; // yield of etHFp for 0 - 10 %
  double gYieldP_1020_npr[nphibins] = {0.7468,
				       0.6187,
				       0.6188,
				       0.5621}; // yield of etHFp for 10 - 20 %
  double gYieldP_2030_npr[nphibins] = {0.5920,
				       0.5960,
				       0.8109,
				       0.5476}; // yield of etHFp for 20 - 30 %
  double gYieldP_3060_npr[nphibins] = {0.6239,
				       0.6727,
				       0.5437,
				       0.7062}; // yield of etHFp for 30 - 60 %
  
  double gYieldM_0010_npr[nphibins] = {0.7504,
				       0.6114,
				       0.6085,
				       0.5761}; // yield of etHFm for 0 - 10 %
  double gYieldM_1020_npr[nphibins] = {0.8253,
				       0.5557,
				       0.5538,
				       0.6116}; // yield of etHFm for 10 - 20 %
  double gYieldM_2030_npr[nphibins] = {0.5493,
				       0.6875,
				       0.7714,
				       0.5383}; // yield of etHFm for 20 - 30 %
  double gYieldM_3060_npr[nphibins] = {0.7367,
				       0.6150,
				       0.5228,
				       0.6719}; // yield of etHFm for 30 - 60 %
  //------
  double gYieldP_0010_npr_err[nphibins] = {0.0839,
					   0.0726,
					   0.0722,
					   0.0676}; // error of etHFp for 0 - 10 %
  double gYieldP_1020_npr_err[nphibins] = {0.0873,
					   0.0797,
					   0.0819,
					   0.0832}; // error of etHFp for 10 - 20 %
  double gYieldP_2030_npr_err[nphibins] = {0.0908,
					   0.0926,
					   0.1024,
					   0.0964}; // error of etHFp for 20 - 30 %
  double gYieldP_3060_npr_err[nphibins] = {0.0776,
					   0.0845,
					   0.0717,
					   0.0832}; // error of etHFp for 30 - 60 %
  //-----
  double gYieldM_0010_npr_err[nphibins] = {0.0771,
					   0.0724,
					   0.0719,
					   0.0678}; // error of etHFm for 0 - 10 %
  double gYieldM_1020_npr_err[nphibins] = {0.0993,
					   0.0730,
					   0.0768,
					   0.0875}; // error of etHFm for 10 - 20 %
  double gYieldM_2030_npr_err[nphibins] = {0.0862,
					   0.1007,
					   0.0991,
					   0.0899}; // error of etHFm for 20 - 30 %
  double gYieldM_3060_npr_err[nphibins] = {0.0880,
					   0.0779,
					   0.0717,
					   0.0793}; // error of etHFm for 30 - 60 %

  const int nhf = 2;
  TGraphErrors *g[nsignals][ncentbins][nhf];
  double pr[nsignals][ncentbins][nhf], ep[nsignals][ncentbins][nhf], chi[nsignals][ncentbins][nhf], ndf[nsignals][ncentbins][nhf];
     
  double vpts1 = pts[pt_start];
  double vpts2 = pts[pt_end];
  
  double gYieldPlus[ncentbins];
  double gYieldMinus[ncentbins];
  double gYieldPlus_err[ncentbins];
  double gYieldMinus_err[ncentbins];

  for(int iSignal = signal_start; iSignal<signal_end; iSignal++)
      {
	const char* chosenSignal = signals[iSignal];
	for(int mcent = centrality_start; mcent < centrality_end; mcent++)
	  {
	   
	    TGraphErrors *pgTempP;
	    TGraphErrors *pgTempM;
	    switch (mcent) {
	    case 0:
	      if (iSignal == 0) 
		{
		  assignArray(gYieldP_0010_nsig,gYieldPlus);
		  assignArray(gYieldM_0010_nsig,gYieldMinus);

		  assignArray(gYieldP_0010_nsig_err,gYieldPlus_err);
		  assignArray(gYieldM_0010_nsig_err,gYieldMinus_err);
		  
		}
	      else 
		if (iSignal == 1)  
		  {
		    assignArray(gYieldP_0010_npr,gYieldPlus);
		    assignArray(gYieldM_0010_npr,gYieldMinus);
		 
		    assignArray(gYieldP_0010_npr_err,gYieldPlus_err);
		    assignArray(gYieldM_0010_npr_err,gYieldMinus_err);
		  }
		else 
		  {
		    assignArray(gYieldP_0010_pr,gYieldPlus);
		    assignArray(gYieldM_0010_pr,gYieldMinus);
		  
		    assignArray(gYieldP_0010_pr_err,gYieldPlus_err);
		    assignArray(gYieldM_0010_pr_err,gYieldMinus_err);
		  }
	      break;
	   
	    case 1:
	      if (iSignal == 0) 
		{
		  assignArray(gYieldP_1020_nsig,gYieldPlus);
		  assignArray(gYieldM_1020_nsig,gYieldMinus);
	
		  assignArray(gYieldP_1020_nsig_err,gYieldPlus_err);
		  assignArray(gYieldM_1020_nsig_err,gYieldMinus_err);
		}
	      else 
		if (iSignal == 1)  
		  {
		    assignArray(gYieldP_1020_npr,gYieldPlus);
		    assignArray(gYieldM_1020_npr,gYieldMinus);
		  
		    assignArray(gYieldP_1020_npr_err,gYieldPlus_err);
		    assignArray(gYieldM_1020_npr_err,gYieldMinus_err);
		  }
		else 
		  {
		    assignArray(gYieldP_1020_pr,gYieldPlus);
		    assignArray(gYieldM_1020_pr,gYieldMinus);
		  
		    assignArray(gYieldP_1020_pr_err,gYieldPlus_err);
		    assignArray(gYieldM_1020_pr_err,gYieldMinus_err);
		  }
	      break;
	    case 2:
	      if (iSignal == 0) 
		{
		  assignArray(gYieldP_2030_nsig,gYieldPlus);
		  assignArray(gYieldM_2030_nsig,gYieldMinus);
		
		  assignArray(gYieldP_2030_nsig_err,gYieldPlus_err);
		  assignArray(gYieldM_2030_nsig_err,gYieldMinus_err);
		}
	      else 
		if (iSignal == 1)  
		  {
		    assignArray(gYieldP_2030_npr,gYieldPlus);
		    assignArray(gYieldM_2030_npr,gYieldMinus);
		  
		    assignArray(gYieldP_2030_npr_err,gYieldPlus_err);
		    assignArray(gYieldM_2030_npr_err,gYieldMinus_err);
		  }
		else 
		  {
		    assignArray(gYieldP_2030_pr,gYieldPlus);
		    assignArray(gYieldM_2030_pr,gYieldMinus);
		 
		    assignArray(gYieldP_2030_pr_err,gYieldPlus_err);
		    assignArray(gYieldM_2030_pr_err,gYieldMinus_err);
		  }
	      break;
	      
	    case 3:
	      if (iSignal == 0) 
		{
		  assignArray(gYieldP_3060_nsig,gYieldPlus);
		  assignArray(gYieldM_3060_nsig,gYieldMinus);
		
		  assignArray(gYieldP_3060_nsig_err,gYieldPlus_err);
		  assignArray(gYieldM_3060_nsig_err,gYieldMinus_err);
		}
	      else 
		if (iSignal == 1)  
		  {
		    assignArray(gYieldP_3060_npr,gYieldPlus);
		    assignArray(gYieldM_3060_npr,gYieldMinus);
		  
		    assignArray(gYieldP_3060_npr_err,gYieldPlus_err);
		    assignArray(gYieldM_3060_npr_err,gYieldMinus_err);
		  }
		else 
		  {
		    assignArray(gYieldP_3060_pr,gYieldPlus);
		    assignArray(gYieldM_3060_pr,gYieldMinus);
		  
		    assignArray(gYieldP_3060_pr_err,gYieldPlus_err);
		    assignArray(gYieldM_3060_pr_err,gYieldMinus_err);
		  }
	      break;
	    default:
	      cout<< "Wrong centrality, please pick something else!"<<endl;
	    }//mcent switch

	    pgTempP = new TGraphErrors(nphibins, dPhiBinCenters, gYieldPlus, dPhiBinCentersErr, gYieldPlus_err);
	    pgTempM = new TGraphErrors(nphibins, dPhiBinCenters, gYieldMinus, dPhiBinCentersErr, gYieldMinus_err);
	    g[iSignal][mcent][0] = pgTempP;
	    g[iSignal][mcent][1] = pgTempM;
	    double cp[4] = {0.0, 0.0, 0.0, 0.0};
	    double cm[4] = {0.0, 0.0, 0.0, 0.0};
	    GetV2(g[iSignal][mcent][0], cp);
	    GetV2(g[iSignal][mcent][1], cm);
	    
	    pr[iSignal][mcent][0]  = cp[0];
	    ep[iSignal][mcent][0]  = cp[1];
	    chi[iSignal][mcent][0] = cp[2];
	    ndf[iSignal][mcent][0] = cp[3];

	    pr[iSignal][mcent][1]  = cm[0];
	    ep[iSignal][mcent][1]  = cm[1];
	    chi[iSignal][mcent][1] = cm[2];
	    ndf[iSignal][mcent][1] = cm[3];

	  }//centrality loop
	
	// #### Drawing: 
	TLatex *lt1 = new TLatex();
	lt1->SetNDC();
	lt1->SetTextSize(0.05);
	
	// frawing: 
	TCanvas *pc1 = new TCanvas("pc1",Form("pcV2_intPt"),0,0,1200,350);
	TH1F    *pp  = new TH1F("pp", Form(";| #phi_{J/#psi} - #Psi_{EP} | (rad);#frac{1}{N_{total J/#psi}} #frac{dN}{d#phi} (rad^{-1})"),4,0,TMath::PiOver2());
	
	pp->GetXaxis()->SetLabelSize(20);
	pp->GetXaxis()->SetLabelFont(43);
	pp->GetXaxis()->SetTitleSize(18);
	pp->GetXaxis()->SetTitleFont(43);
	pp->GetXaxis()->SetTitleOffset(1.2);
	pp->GetXaxis()->CenterTitle();
	
	pp->GetYaxis()->SetLabelSize(20);
	pp->GetYaxis()->SetLabelFont(43);
	pp->GetYaxis()->SetTitleSize(19);
	pp->GetYaxis()->SetTitleFont(43);
	pp->GetYaxis()->SetTitleOffset(1.43);
	pp->GetYaxis()->CenterTitle();
		
	makeMultiPanelCanvas(pc1,nPads,1,0.0,0.0,0.2,0.15,0.02);
	int ind = 0;
	for(int mcent = centrality_start; mcent < centrality_end; mcent++)
	  {
	    if(!g[iSignal][mcent][0]|| !g[iSignal][mcent][1]) 
	      {
		cout<<"No graph! continued !!!!"<<endl;
		continue;
	      }
	    int vcts1 = cts[mcent]; 
	    int vcts2 = cts[mcent+1];
	    cout<<"Centrlality bin: "<<vcts1<<"-"<<vcts2<<endl;
	    pc1->cd(ind+1);
	    pp->SetMaximum(1.2);
	    pp->SetMinimum(0.2);		    
	    pp->Draw();

	    TGraphErrors *pgP = (TGraphErrors *) g[iSignal][mcent][0];
	    TGraphErrors *pgM = (TGraphErrors *) g[iSignal][mcent][1];

	    pgP->SetMarkerStyle(20);
	    pgM->SetMarkerStyle(24);
	    pgP->Draw("pz");
	    pgM->Draw("pz");
	    
	    if(ind==0 )
	      {
		 // drapwing v2 value and chi2
		 lt1->SetTextSize(0.045);
		 lt1->DrawLatex(0.24,0.23,Form("v_{2}^{etHFp} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][0], ep[iSignal][mcent][0], chi[iSignal][mcent][0], ndf[iSignal][mcent][0]));
		 lt1->DrawLatex(0.24,0.18,Form("v_{2}^{etHFm} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][1], ep[iSignal][mcent][1], chi[iSignal][mcent][1], ndf[iSignal][mcent][1]));
		 lt1->SetTextSize(0.055);
		 lt1->DrawLatex(0.24,0.3,Form("Cent. %d - %d %%",vcts1, vcts2)); // centrality 
	       }
	     else
	       {
		 lt1->SetTextSize(0.05);
		 lt1->DrawLatex(0.05,0.23,Form("v_{2}^{etHFp} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][0], ep[iSignal][mcent][0], chi[iSignal][mcent][0], ndf[iSignal][mcent][0]));
		 lt1->DrawLatex(0.05,0.18,Form("v_{2}^{etHFm} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][1], ep[iSignal][mcent][1], chi[iSignal][mcent][1], ndf[iSignal][mcent][1]));

		 lt1->SetTextSize(0.06);
		 if(ind == 1) lt1->DrawLatex(0.05,0.3,Form("Cent. %d - %d %%",vcts1, vcts2));
		 if(ind > 1) lt1->DrawLatex(0.05,0.3,Form("Cent. %d - %d %%",vcts1, vcts2));
		 
		 if(ind == 3)
		   {
		     lt1->SetTextSize(0.06);
		     lt1->DrawLatex(0.45,0.8,Form("|y| < %.1f",raps[1]));       // rapidity
		     lt1->DrawLatex(0.45,0.73,Form("%.1f < p_{T} < %.0f GeV/c", vpts1, vpts2)); // pt
		   }
		 if(ind==1)
		   {
		     TLegend *legCent = new TLegend(0.7,0.8,0.95,0.95);
		     legCent->SetFillColor(0);
		     legCent->SetBorderSize(0);
		     legCent->SetTextSize(0.07);
		     legCent->AddEntry(pgP,"etHFp","P");
		     legCent->AddEntry(pgM,"etHFm","P");
		     legCent->Draw("same");
		   }
	       }
	     ind++;
	  }//mcent
	//_______ stuff to write
	pc1->cd(1);
	TLatex *tex1 = new TLatex(0.23,0.93,"CMS Preliminary");
	tex1->SetNDC();
	tex1->SetTextAlign(13);
	tex1->SetTextFont(43);
	tex1->SetTextSize(23);
	tex1->SetLineWidth(1);
	tex1->Draw();
	
	TLatex *tex2 = new TLatex(0.23,0.84,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
	tex2->SetNDC();
	tex2->SetTextAlign(13);
	tex2->SetTextFont(43);
	tex2->SetTextSize(18);
	tex2->SetLineWidth(2);
	tex2->Draw();
	
	pc1->cd(1);
	TLatex *tex3 = new TLatex(0.23,0.75,"L_{int} = 150 #mub^{-1}");
	tex3->SetNDC();
	tex3->SetTextAlign(13);
	tex3->SetTextFont(43);
	tex3->SetTextSize(18);
	tex3->SetLineWidth(2);
	tex3->Draw();
	
	pc1->cd(4);
	lt1->SetTextSize(0.06);
	lt1->DrawLatex(0.05,0.89,Form("%s",legend[iSignal]));  // what signal is
	
	//_______
	if(bSavePlots)
	  {
	    pc1->SaveAs(Form("%s_Jpsi_a1_newErr_Nominal.png",chosenSignal));
 	    pc1->SaveAs(Form("%s_Jpsi_a1_newErr_Nominal.pdf",chosenSignal));
	  }
	  
	//	pc1->Clear();
    
	
	cout<<""<<endl;
	cout<<"%%%%% Category etHFp: "<<signals[iSignal]<<" %%%%%"<<endl;
	cout<<"|  Cent.  |  0 - 10 %  |  10 - 20 %  |  20 - 30 %  |  30 - 60 %  |"<<endl;
	cout<<"|  v2  |"<<"  "<<pr[iSignal][0][0]<<"  |  "<<pr[iSignal][1][0]<<"  |  "<<pr[iSignal][2][0]<<"  |  "<<pr[iSignal][3][0]<<"  |"<<endl;
	cout<<"|  err  |"<<"  "<<ep[iSignal][0][0]<<"  |  "<<ep[iSignal][1][0]<<"  |  "<<ep[iSignal][2][0]<<"  |  "<<ep[iSignal][3][0]<<"  |"<<endl;

	cout<<"%%%%% Category etHFm: "<<signals[iSignal]<<" %%%%%"<<endl;
	cout<<"|  Cent.  |  0 - 10 %  |  10 - 20 %  |  20 - 30 %  |  30 - 60 %  |"<<endl;
	cout<<"|  v2  |"<<"  "<<pr[iSignal][0][1]<<"  |  "<<pr[iSignal][1][1]<<"  |  "<<pr[iSignal][2][1]<<"  |  "<<pr[iSignal][3][1]<<"  |"<<endl;
	cout<<"|  err  |"<<"  "<<ep[iSignal][0][1]<<"  |  "<<ep[iSignal][1][1]<<"  |  "<<ep[iSignal][2][1]<<"  |  "<<ep[iSignal][3][1]<<"  |"<<endl;

	
      }// chose signal


}
예제 #18
0
파일: DrawVzcut.C 프로젝트: XuQiao/HI
void DrawVzcut(){
gStyle->SetOptStat(kFALSE);
gStyle->SetErrorX(0);
const int NColor=7;
static const int Color[NColor]={
   1, 2, 4, 46,6, 7,8
};
static const int Style[NColor] = {
    20, 34, 33, 25,27, 28//,24
};

const double pPbLumi = 20.7 ;

const int Ntrig = 5;const int NVz=4;
TString TrigName[Ntrig]={"Jet20","Jet40","Jet60","Jet80","Jet100"};
TFile *f[Ntrig];

int Vzname[NVz]={2,3,4,7};	
TString Vzstring[NVz]={"HLT","Beam","pprim","EvtSel"};
TH1F* hVz[Ntrig][NVz];	TH1F* hRatio1[NVz];
int trig0=4;
TH1F* hFrame=new TH1F("","",1000,-50,50);
hFrame->GetXaxis()->SetRangeUser(-30,30);
hFrame->GetYaxis()->SetTitle("Number of Events");
fixedFontHist(hFrame,1.4,1.6);
TLegend *leg=new TLegend(0.60,0.75,0.8,0.95);
TLegend *leg_=new TLegend(0.60,0.75,0.8,0.95);
//TLine *l=new TLine(-30,1,30,1);
TLine *l=new TLine(-15,1,15,1);
l->SetLineStyle(2);
l->SetLineColor(1);

TLine *l1=new TLine(-15,1.01e-6,-15,2e-1);
TLine *l3=new TLine(-15,0,-15,2);
TLine *l2=new TLine(15,1.01e-6,15,2e-1);
TLine *l4=new TLine(15,0,15,2);
l1->SetLineStyle(2);
l2->SetLineStyle(2);
l3->SetLineStyle(2);
l4->SetLineStyle(2);
l1->SetLineColor(2);
l2->SetLineColor(2);
l3->SetLineColor(2);
l4->SetLineColor(2);
l1->SetLineWidth(4);
l2->SetLineWidth(4);
l3->SetLineWidth(4);
l4->SetLineWidth(4);

leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetTextFont(42);
leg->SetTextSize(0.035);
/*if(k0==0){
leg->SetHeader("Before Event Selection");
leg_->SetHeader("Before Event Selection");
}
lse{
leg->SetHeader("After Event Selection");
leg_->SetHeader("After Event Selection");
}*/
//leg->SetTextAlign(32);
leg_->SetBorderSize(0);
leg_->SetFillColor(0);
leg_->SetTextFont(42);
leg_->SetTextSize(0.035);
for(int itrig=4;itrig<5;itrig++){
for(int iVz=0;iVz<NVz;iVz++){
f[itrig]=TFile::Open(Form("/scratch/xuq7/RpA/GlobalEvent/EventSel/%sEvSel.root",TrigName[itrig].Data()));
hVz[itrig][iVz]=(TH1F*)f[itrig]->Get(Form("hVz_cut%d",Vzname[iVz]));
hVz[itrig][iVz]->Rebin(10);
//normalizeByBinWidth(hVz[trig0][iVz]);
//hVz[trig0][iVz]->Scale((double)1.0/hVz[trig0][iVz]->Integral());
}
}
c1 = new TCanvas("c1"," ",600,600);
c2 = new TCanvas("c2"," ",600,600);
makeMultiPanelCanvas(c1,1,1,-0.05,0,0.12,0.12,0.03);
makeMultiPanelCanvas(c2,1,1,-0.05,0,0.12,0.12,0.03);

c1->cd(1)->SetLogy();
hFrame->GetXaxis()->SetTitle("Vz (cm)");
hFrame->GetYaxis()->SetRangeUser(1,1e8);
hFrame->DrawCopy();
for(iVz=0;iVz<NVz;iVz++){
hVz[trig0][iVz]->SetMarkerColor(Color[iVz]);
hVz[trig0][iVz]->SetLineColor(Color[iVz]);
hVz[trig0][iVz]->SetMarkerStyle(Style[iVz]);
hVz[trig0][iVz]->SetMarkerSize(1.2);
leg->AddEntry(hVz[trig0][iVz],Vzstring[iVz],"lp");
hVz[trig0][iVz]->Draw("same");
}
leg->Draw("same");
drawCMS(0.2,0.9,pPbLumi);
c1->Print("Vzcut.pdf");
//l1->Draw("same");
//l2->Draw("same");
c2->cd(1);

hFrame->GetXaxis()->SetTitle("Vz (cm)");
//hFrame->GetYaxis()->SetRangeUser(0.9,1.25);
hFrame->GetYaxis()->SetRangeUser(0.7,1.2);
hFrame->GetYaxis()->SetTitle("Ratio");
hFrame->DrawCopy();
int Selbase=0;
for(iVz=0;iVz<NVz;iVz++){
if(iVz!=Selbase){
hRatio1[iVz]=(TH1F*)hVz[trig0][iVz]->Clone(Form("hRatio1_%d",iVz));
hRatio1[iVz]->SetMarkerColor(Color[iVz]);
hRatio1[iVz]->SetLineColor(Color[iVz]);
hRatio1[iVz]->SetMarkerStyle(Style[iVz]);
hRatio1[iVz]->SetMarkerSize(1.2);
leg_->AddEntry(hRatio1[iVz],Form("%s/%s",Vzstring[iVz].Data(),Vzstring[Selbase].Data()),"lp");
hRatio1[iVz]->Divide(hVz[trig0][Selbase]);
hRatio1[iVz]->Draw("same");
}
}
//l3->Draw("same");
//l4->Draw("same");
leg_->Draw("same");
l->Draw("same");
drawCMS(0.2,0.9,pPbLumi);
c2->Print("Vzcut_ratio.pdf");

/*
int i0=5, k1=0, k2=1;
c2 = new TCanvas("c2"," ",600,800);
makeMultiPanelCanvas(c2,1,2,-0.05,0,0.12,0.12,0.03);
c2->cd(1)->SetLogy();
//hFrame->GetYaxis()->SetRangeUser(1e-5,2e-1);
hFrame->GetYaxis()->SetRangeUser(0.5,1e7);
hFrame->GetXaxis()->SetTitle("");
hFrame->GetYaxis()->SetTitle("Number of Event");
hVz[i0][k1]->SetMarkerColor(1);
hVz[i0][k1]->SetLineColor(1);
hVz[i0][k1]->SetMarkerStyle(20);
hVz[i0][k1]->SetMarkerSize(1.2);
hVz[i0][k2]->SetMarkerColor(2);
hVz[i0][k2]->SetLineColor(2);
hVz[i0][k2]->SetMarkerStyle(24);
hVz[i0][k2]->SetMarkerSize(1.2);
leg->Clear();
leg->SetHeader(TrigName[i0]);
leg->AddEntry(hVz[i0][k1],"Before ES","lp");
leg->AddEntry(hVz[i0][k2],"After ES","lp");
hFrame->DrawCopy();
hVz[i0][k1]->Draw("same");
hVz[i0][k2]->Draw("same");
leg->Draw("same");
c2->cd(2);
hFrame->GetYaxis()->SetRangeUser(0,1.99);
hFrame->GetXaxis()->SetTitle("Vz (cm)");
hFrame->GetYaxis()->SetRangeUser(0.1,1.89);
hFrame->GetYaxis()->SetTitle(Form("After/Before"));
hFrame->DrawCopy();
TH1F* hRatio2=(TH1F*)hVz[i0][k2]->Clone("hRatio2");
hRatio2->Divide(hVz[i0][k1]);
hRatio2->SetMarkerColor(1);
hRatio2->SetLineColor(1);
hRatio2->SetMarkerStyle(20);
hRatio2->Draw("same");
l->Draw("same");
c2->Print(Form("%sEvSel.png",TrigName[i0].Data()));
*/
}
예제 #19
0
파일: plotr0vstheta.C 프로젝트: XuQiao/HI
void plotr0vstheta(){
	TFile *f;
        int isSum=1;
        const int ntotbin=5;
        const int trkpointmin[ntotbin] = {120,150,185,220,260};
        const int trkpointmax[ntotbin] = {150,185,220,260,300};
        int trkbin=1;
	int xbin=0;
        c1 = new TCanvas("c1"," ",1200,700);
        makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03);
        gStyle->SetOptFit(1);
        gStyle->SetOptStat(0);
        gStyle->SetOptTitle(0);
        gStyle->SetErrorX(0);
        TH1D *hFrame = new TH1D("","",100,0,2);
        hFrame->SetTitle("");
        hFrame->GetXaxis()->SetTitle("#theta");
        hFrame->GetYaxis()->SetTitle("r_{0}");
        hFrame->GetYaxis()->SetTitleOffset(1.1);
        hFrame->GetXaxis()->SetTitleSize(0.04);
        hFrame->GetYaxis()->SetTitleSize(0.04);
        hFrame->GetXaxis()->SetRangeUser(0,1.5);
        hFrame->SetMinimum(0.05);
        hFrame->SetMaximum(0.50);
        for(int trkbin=0;trkbin<ntotbin; trkbin++){
	if(isSum==0){
	    f = TFile::Open(Form("M%d%d/mergedV_Prod.root",trkpointmax[trkbin],trkpointmin[trkbin]));
	}
	else{
	    f = TFile::Open(Form("M%d%d/mergedV_Sum.root",trkpointmax[trkbin],trkpointmin[trkbin]));
	}
	TVectorD* vecr0 = (TVectorD*)f->Get(Form("D_%d/D_0/r0",xbin));

        double *r0 = vecr0->GetMatrixArray();
        double r0mean = getmean(r0,ntheta);
        double theta[ntheta];
        for(int itheta=0;itheta<ntheta;itheta++){
            theta[itheta]=itheta*TMath::Pi()/ntheta/nn;
        }
        int maxper10 = findmaxper(r0,ntheta,r0mean);
        double maxper = (double)(maxper10+1)/10;
        c1->cd(trkbin+1);
        hFrame->Draw();
        TGraph *gr0theta = new TGraph(ntheta,theta,r0);
        gr0theta->SetMarkerStyle(20);
        gr0theta->SetMarkerSize(1.3);
        gr0theta->SetMarkerColor(1);
        gr0theta->SetLineColor(1);
	gr0theta->Draw("Psame");
        TLine *lup = new TLine(gr0theta->GetXaxis()->GetXmin(),r0mean*(1+maxper), gr0theta->GetXaxis()->GetXmax(),r0mean*(1+maxper));
        TLine *ldown = new TLine(gr0theta->GetXaxis()->GetXmin(),r0mean*(1-maxper), gr0theta->GetXaxis()->GetXmax(),r0mean*(1-maxper));
        TLine *l = new TLine(hFrame->GetXaxis()->GetXmin(),r0mean, hFrame->GetXaxis()->GetXmax(),r0mean);
        l->SetLineStyle(2);
        lup->SetLineStyle(2);
        ldown->SetLineStyle(2);
        l->SetLineWidth(1.2);
        lup->SetLineWidth(1.2);
        ldown->SetLineWidth(1.2);
        TLatex *tl = new TLatex();
 //     tl->SetNDC();
        tl->SetTextFont(42);
        tl->SetTextSize(0.04);
 //     tl->SetBorderStyle(0);
        tl->DrawLatex(0,r0mean*(1+maxper),Form("mean up %.f%%",maxper*100));
        tl->DrawLatex(0,r0mean*(1-maxper),Form("mean down %.f%%",maxper*100));
        tl->SetNDC();
        tl->DrawLatex(0.7,0.85,Form("Multiplicity %d to %d",trkpointmin[trkbin],trkpointmax[trkbin]));
        l->Draw("same");
        lup->Draw("same");
        ldown->Draw("same");
        }
        c1->cd(ntotbin+1);
        TLatex *tlx0 = new TLatex(0.12,0.3,Form("track"));
        TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0));
        tlx0->SetNDC();
        tlx1->SetNDC();
        tlx0->SetTextSize(0.045);
        tlx1->SetTextSize(0.045);
        hFrame->Draw();
        tlx0->Draw("same");
        tlx1->Draw("same");
	if(isSum==0)c1->SaveAs("hr0theta_Prod.png");
	else c1->SaveAs("hr0theta_Sum.png");
}
예제 #20
0
//__________________________________________________________________________
void Plot_JpsiV2_a2()
{
  //gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+");
  gStyle->SetOptFit(0);

  TFile *f1 = new TFile("etHF/summary/saved_histo.root");
  const char* nameoutfile[2] = {"",
    "etHF"
  };

  const char* eventPlane[2] = {"",
    "EP: etHF"
  };

  // pt integrated
  const int ncentbins    = 2;
  const int nrapbins     = 2;
  const int nptbins      = 3; 
  int    cts[ncentbins]  = {10, 60};
  double raps[nrapbins]  = {0.0, 2.4};
  double pts[nptbins]    = {6.5,10.0,40.0};

  const char* signal[4]      = {"","NSig","NPr","NNp"};
  const char* legend[4]      = {"","Inclusive J/#psi","Prompt J/#psi","Non-prompt J/#psi"};
  int choseSignal            = 1; // 1:inclusive 2:prompt 3:non-prompt
  const char* chosenSignal   = signal[choseSignal];

  // options
  bool bDoDebug         = false;
  bool bSavePlots       = true; 
  bool doCentIntegrated = true;

  int centrality_start  = 0;
  int centrality_end    = 1; 

  int y_start  = 0;
  int y_end    = 1;

  int pt_start = 0;
  int pt_end   = 2;

  int nPads    = pt_end - pt_start;  


  TGraphErrors *g[10][10][10];
  double pr[10][10][10], ep[10][10][10], chi[10][10][10], ndf[10][10][10];
  double vals[4];

  char gTmp[512];
  char tmp0[512],tmp2[512], tmp3[512], tmp4[512], tmp5[512], tmp6[512];
  double vraps1, vraps2, vpts1, vpts2;
  int vcts1, vcts2;

  for(int mcent = centrality_start; mcent < centrality_end; mcent++)
  {
    vcts1 = cts[mcent]; 
    vcts2 = cts[mcent+1];
    cout<<"Centrlality bin: "<<vcts1<<"-"<<vcts2<<endl;

    for(int iy = y_start; iy < y_end; iy++)
    {
      vraps1 = raps[iy];
      vraps2 = raps[iy+1];
      cout<<"Rapidity bin: "<<vraps1<<"-"<<vraps2<<endl;

      for(int jpt = pt_start; jpt < pt_end; jpt++)
      {
        cout<<" producing the TGraphs : "<<mcent<<" "<<iy<<" "<<jpt<<" "<<endl;

        sprintf(gTmp,"rap%.1f-%.1f_cent%d-%d_pT%.1f-%.1f_%s",vraps1,vraps2,vcts1,vcts2,pts[jpt],pts[jpt+1],chosenSignal);
        cout<<"TGraph name : "<<gTmp<<endl;
        TGraphErrors *pgTemp =  (TGraphErrors*)f1->Get(gTmp);
        g[mcent][iy][jpt]  = pgTemp;
        if(!g[mcent][iy][jpt]) {cout<<"Warning: No graph found !!!!"<<endl;continue;}
        cout<<g[mcent][iy][jpt]<<endl;
        double b[4];
        GetV2(g[mcent][iy][jpt], b);

        pr[mcent][iy][jpt]  = b[0];
        ep[mcent][iy][jpt]  = b[1];
        chi[mcent][iy][jpt] = b[2];
        ndf[mcent][iy][jpt] = b[3];

      }//pt bin loop
    }//rapidity loop
  }//centrlaity loop

  // #### Drawing: 
  TLatex *lt1 = new TLatex();
  lt1->SetNDC();

  // frawing: 
  TCanvas *pc1 = new TCanvas("pc1",Form("pcV2_intPt"),0,0,900,500);
  TH1F    *pp  = new TH1F("pp", Form(";| #phi_{J/#psi} - #Psi_{EP} | (rad);#frac{1}{N_{total J/#psi}} #frac{dN}{d#phi} (rad^{-1})"),4,0,TMath::PiOver2());

  pp->GetXaxis()->SetLabelSize(20);
  pp->GetXaxis()->SetLabelFont(43);
  pp->GetXaxis()->SetTitleSize(24);
  pp->GetXaxis()->SetTitleFont(43);
  pp->GetXaxis()->SetTitleOffset(1.2);
  pp->GetXaxis()->CenterTitle();

  pp->GetYaxis()->SetLabelSize(20);
  pp->GetYaxis()->SetLabelFont(43);
  pp->GetYaxis()->SetTitleSize(28);
  pp->GetYaxis()->SetTitleFont(43);
  pp->GetYaxis()->SetTitleOffset(1.3);
  pp->GetYaxis()->CenterTitle();

  makeMultiPanelCanvas(pc1,nPads,1,0.0,0.0,0.2,0.15,0.02);
  int ind = 0;
  for(int mpt = pt_start; mpt < pt_end; mpt++)
  {
    cout<<"ind : "<<ind<<endl;
    vpts1 = pts[mpt]; 
    vpts2 = pts[mpt+1];

    pc1->cd(ind+1);
    for(int ky = y_start; ky < y_end; ky++)
    {
      vraps1 = raps[ky];
      vraps2 = raps[ky+1];
      cout << "Canvas Rapidity = "<< vraps1 << "\t"<<vraps2<<endl;

      for(int lc = centrality_start; lc < centrality_end; lc++)
      {
        vcts1  = cts[lc]; 
        vcts2  = cts[lc+1];
        cout<<"Canvas Centrality: "<<vcts1<<"-"<<vcts2<<endl;

        pp->SetMaximum(1.2);
        pp->SetMinimum(0.2);
        pp->Draw();

        lt1->SetTextSize(0.05);
        if(ind == 1) 
        {
          lt1->DrawLatex(0.62,0.90,Form("Cent. %d - %d %%",vcts1, vcts2)); // centrality
          lt1->DrawLatex(0.07,0.74,Form("|y| < %.1f",vraps2));       // rapidity
          //lt1->DrawLatex(0.6,0.7,Form("%s",eventPlane[1]));        // event plane method
        }

        if(!g[lc][ky][mpt]) 
        {
          cout<<"No graph! continued !!!!"<<endl;
          continue;
        }
        cout<<"#### Drawing: cent:"<<vcts1<<"-"<<vcts2<<"\t rapidity"<<vraps1<<"-"<<vraps2<<"\t pt"<<vpts1<<"-"<<vpts2<<endl;
        g[lc][ky][mpt]->Draw("pz");
        if(ind==0 )
        {
          // drapwing v2 value and chi2
          lt1->SetTextSize(0.04);
          lt1->DrawLatex(0.25,0.22,Form("v_{2} = %.4f #pm %.4f (#chi^{2} / ndf = %.3f / %.0f)", pr[lc][ky][mpt], ep[lc][ky][mpt], chi[lc][ky][mpt], ndf[lc][ky][mpt]));
          lt1->DrawLatex(0.25,0.3,Form("%.1f < p_{T} < %.1f GeV/c", vpts1, vpts2)); 
        }
        else
        {
          lt1->SetTextSize(0.046);
          lt1->DrawLatex(0.07,0.22,Form("v_{2} = %.4f #pm %.4f (#chi^{2} / ndf = %.3f / %.0f)", pr[lc][ky][mpt], ep[lc][ky][mpt], chi[lc][ky][mpt], ndf[lc][ky][mpt]));
          lt1->DrawLatex(0.07,0.3,Form("%.1f < p_{T} < %.1f GeV/c", vpts1, vpts2)); 
        }
      }//centrality bin loop
    }//rapidity bin loop
    ind++;
  }
  //_______ stuff to write
  pc1->cd(1);
  TLatex *tex1 = new TLatex(0.25,0.93,"CMS Preliminary");
  tex1->SetNDC();
  tex1->SetTextAlign(13);
  tex1->SetTextFont(43);
  tex1->SetTextSize(22);
  tex1->SetLineWidth(1);
  tex1->Draw();

  TLatex *tex2 = new TLatex(0.25,0.85,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  tex2->SetNDC();
  tex2->SetTextAlign(13);
  tex2->SetTextFont(43);
  tex2->SetTextSize(22);
  tex2->SetLineWidth(2);
  tex2->Draw();

  TLatex *tex3 = new TLatex(0.25,0.78,"L_{int} = 150 #mub^{-1}");
  tex3->SetNDC();
  tex3->SetTextAlign(13);
  tex3->SetTextFont(43);
  tex3->SetTextSize(22);
  tex3->SetLineWidth(2);
  tex3->Draw();

  pc1->cd(2);
  lt1->SetTextSize(0.055);
  lt1->DrawLatex(0.07,0.90,Form("%s",legend[choseSignal]));  // what signal is
  lt1->DrawLatex(0.07,0.82,Form("%s",eventPlane[1]));        // event plane method
  //_______


  if(bSavePlots)
  {
    pc1->SaveAs(Form("plots/etHF/%s_%s_Jpsi_%d_%d_150mub_a2.png",chosenSignal,nameoutfile[1],pt_start,pt_end));
    pc1->SaveAs(Form("plots/etHF/%s_%s_Jpsi_%d_%d_150mub_a2.pdf",chosenSignal,nameoutfile[1],pt_start,pt_end));

    pc1->Clear();
  }


  // ####### SUMMARY PLOT!!!
  TCanvas *c2 = new TCanvas("c2","c2");
  //  makeMultiPanelCanvas(c2,1,1,0.0,0.0,0.2,0.15,0.02);
  char tmp7[512];

  TH1F *hPad2 = new TH1F("hPad2",";p_{T} (GeV/c);Uncorrected v_{2};",100,0,40);
  hPad2->GetXaxis()->SetLabelSize(20);
  hPad2->GetXaxis()->SetLabelFont(43);
  hPad2->GetXaxis()->SetTitleSize(27);
  hPad2->GetXaxis()->SetTitleFont(43);
  hPad2->GetXaxis()->SetTitleOffset(1.2);
  hPad2->GetXaxis()->CenterTitle();

  hPad2->GetYaxis()->SetLabelSize(20);
  hPad2->GetYaxis()->SetLabelFont(43);
  hPad2->GetYaxis()->SetTitleSize(32);
  hPad2->GetYaxis()->SetTitleFont(43);
  hPad2->GetYaxis()->SetTitleOffset(1.1);
  hPad2->GetYaxis()->CenterTitle();

  hPad2->SetMaximum(0.18);
  hPad2->SetMinimum(-0.05);
  hPad2->Draw();
  TLegend *leg1 = new TLegend(0.5100671,0.2255245,0.7667785,0.3304196);
  leg1->SetFillColor(0);
  leg1->SetBorderSize(0);
  leg1->SetTextSize(0.03);
  c2->cd(1);

  TLatex *tex4 = new TLatex(0.53,0.92,"CMS Preliminary");
  tex4->SetNDC();
  tex4->SetTextAlign(13);
  tex4->SetTextFont(43);
  tex4->SetTextSize(25);
  tex4->SetLineWidth(1);
  tex4->Draw();

  TLatex *tex5 = new TLatex(0.53,0.86,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  tex5->SetNDC();
  tex5->SetTextAlign(13);
  tex5->SetTextFont(43);
  tex5->SetTextSize(25);
  tex5->SetLineWidth(2);
  tex5->Draw();

  TLatex *tex6 = new TLatex(0.53,0.80,"L_{int} = 150 #mub^{-1}");
  tex6->SetNDC();
  tex6->SetTextAlign(13);
  tex6->SetTextFont(43);
  tex6->SetTextSize(25);
  tex6->SetLineWidth(2);
  tex6->Draw();

  lt1->SetTextSize(0.04);
  lt1->DrawLatex(0.18,0.89,Form("%s",legend[choseSignal]));  // what signal is

  TGraphErrors *gPtBarr[3];
  double ptBins[2]      = {8.25,25};
  double ptErrs[2]      = {0.0,0.0};
  for(int ic = pt_start; ic < pt_end; ic++)
  {
    // [centrality][rapidity][pt]
    double v2PtBarr[nptbins-2]    = {pr[0][0][ic]};
    double v2PtBarrErr[nptbins-2] = {ep[0][0][ic]};
    double ptbinlocal[nptbins-2]  = {ptBins[ic]};
    double ptbinlocalerr[nptbins-2]  = {ptErrs[ic]};
    gPtBarr[ic] = new TGraphErrors(nptbins-2, ptbinlocal, v2PtBarr, ptbinlocalerr, v2PtBarrErr);  
    gPtBarr[ic]->SetMarkerStyle(20);
    //gPtBarr[ic]->SetMarkerStyle(20+ic);
    gPtBarr[ic]->SetMarkerSize(1.8);
    gPtBarr[ic]->SetMarkerColor(kBlue+2);

    gPtBarr[ic]->Draw("pz");
    vpts1 = pts[ic]; vpts2 = pts[ic+1];
    leg1->AddEntry(gPtBarr[ic],Form("%.1f < p_{T} < %.1f GeV/c", vpts1, vpts2),"P");

    cout<<" producing the v2 plots in the Canvas : "<<ic<<" "<<endl;
    c2->Update();
  }
  //leg1->Draw("same");
  lt1->SetTextSize(0.038);
  lt1->DrawLatex(0.18,0.83,Form("|y| < %.1f",vraps2));       // rapidity
  lt1->DrawLatex(0.18,0.77,Form("Cent. 10 - 60 %%")); 
  lt1->DrawLatex(0.18,0.71,Form("%s",eventPlane[1]));

  c2->SaveAs(Form("plots/etHF/%s_jpsi_%s_v2_pt_a2.png",chosenSignal,nameoutfile[1]));
  c2->SaveAs(Form("plots/etHF/%s_jpsi_%s_v2_pt_a2.pdf",chosenSignal,nameoutfile[1]));
}
예제 #21
0
파일: DrawMCetabin.C 프로젝트: XuQiao/HI
void DrawMCetabin(){
gStyle->SetOptStat(kFALSE);
gStyle->SetOptFit(kFALSE);
gStyle->SetErrorX(0);
static const int nColor = 8;
static const int colorCode[nColor] = {
    2, 4, 6, 7, 8, 9, 46,1
};
static const int markerCode[nColor] = {
    33, 34, 29, 21, 30, 28,27,20
};

//ofstream fstr("JESsysetabin.txt");
TH2F* hrawptJES[Neta];	 TProfile* hProrawptJES[Neta]; 
TH2F* hrefptJES[Neta];	 TProfile* hProrefptJES[Neta]; 
c1 = new TCanvas("c1","c1",600,600);
    c1->SetTickx(1);
    c1->SetTicky(1);
c2 = new TCanvas("c2","c2",600,600);
    c2->SetTickx(1);
    c2->SetTicky(1);

c2->cd(1)->SetLogx();
makeMultiPanelCanvas(c1,1,1,-0.12,0,0.14,0.12,0.03);
makeMultiPanelCanvas(c2,1,1,-0.12,0,0.14,0.12,0.03);
TLegend *leg1=new TLegend(0.72,0.55,0.88,0.9);
TLegend *leg2=new TLegend(0.72,0.55,0.88,0.9);
leg1->SetTextSize(0.035);
leg2->SetTextSize(0.035);
TH1F* hFrame=new TH1F("","",1000,0,1000);
hFrame->GetXaxis()->SetLimits(29,550);
hFrame->SetTitle("");
hFrame->GetYaxis()->SetRangeUser(1.0,1.3);
fixedFontHist(hFrame,1.2,1.8);
TLatex *T1=new TLatex;
T1->SetNDC();
T1->SetTextAlign(10);
T1->SetTextSize(0.04);
T1->SetTextColor(1);
T1->SetTextFont(42);
TLine *l=new TLine(31,1,550.1,1);
l->SetLineStyle(2);
l->SetLineColor(1);
for(int i=0;i<Neta;i++){
if(i==Neta-1){
hrawptJES[i]=(TH2F*)fMCPPb->Get("rawptJES");
hrefptJES[i]=(TH2F*)fMCPPb->Get("refptJES");
}
else{
hrawptJES[i]=(TH2F*)fMCPPb->Get(Form("rawptJESEtaBin%s",etabinnameswap[i].Data()));
hrefptJES[i]=(TH2F*)fMCPPb->Get(Form("refptJESEtaBin%s",etabinnameswap[i].Data()));
}
hrawptJES[i]->SetName(Form("hrawptJES_%d",i));
hrefptJES[i]->SetName(Form("hrefptJES_%d",i));
hProrawptJES[i]=(TProfile*)hrawptJES[i]->ProfileX();
hProrefptJES[i]=(TProfile*)hrefptJES[i]->ProfileX();
hProrawptJES[i]=(TProfile*)hProrawptJES[i]->Rebin(Nbin_pt,hProrawptJES[i]->GetName(),binbound_pt);
hProrefptJES[i]=(TProfile*)hProrefptJES[i]->Rebin(Nbin_pt,hProrefptJES[i]->GetName(),binbound_pt);
}

c1->cd(1);
hFrame->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
hFrame->GetYaxis()->SetTitle("p_{T}^{jet}/p_{T}^{raw}");
hFrame->DrawCopy();
for(int i=0;i<Neta;i++){
hProrawptJES[i]->SetMarkerStyle(markerCode[i]);
hProrawptJES[i]->SetMarkerColor(colorCode[i]);
hProrawptJES[i]->SetLineColor(colorCode[i]);
hProrawptJES[i]->SetMarkerSize(1.4);
if(canvas[i]!=4){
leg1->AddEntry(hProrawptJES[i],etastring[i],"lp");
hProrawptJES[i]->DrawCopy("same");
}
}
for(int i=0;i<Neta-1;i++)	if(canvas[i]!=3 && canvas[i]!=4) hProrawptJES[i]->DrawCopy("same");

T1->DrawLatex(0.18,0.85,"PYTHIA+HIJING");
T1->DrawLatex(0.18,0.90,"CMS simulation");
T1->DrawLatex(0.28,0.17,"Anti-k_{T} Particle Flow PU Jets: R=0.3");
leg1->SetBorderSize(0);
leg1->SetFillColor(0);
leg1->Draw("same");
//drawCMS(0.4,0.9);
c1->Print(Form("rawptJES_etabin_%s.pdf",algo.Data()));
c2->cd(1)->SetLogx(0);
//hFrame->GetXaxis()->SetNdivisions(1020);
TF1 *fitfun[Neta];
hFrame->GetYaxis()->SetRangeUser(0.96,1.15);
hFrame->GetXaxis()->SetRangeUser(29,550);
//TF1* fitfun=new TF1("fit","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",0,1000);
//fitfun->SetParameters(1,1,100,1000);
hFrame->GetXaxis()->SetTitle("p_{T}^{ref} (GeV/c)");
hFrame->GetYaxis()->SetTitle("p_{T}^{jet}/p_{T}^{ref}");
hFrame->GetXaxis()->SetMoreLogLabels();
hFrame->GetXaxis()->SetNoExponent();
hFrame->DrawCopy();
//fstr<<"fitfun[i]=new TF1(Form(\"fit_\%d\",i),\"[0] + [1]/x + [2]/x/x + [3]/x/x/x\",1,1000);"<<endl;
for(int i=0;i<Neta;i++){
/*fitfun[i]=new TF1(Form("fit_%d",i),"[0] + [1]/x + [2]/x/x + [3]/x/x/x",1,1000);
fitfun[i]->SetParameters(1,-0.893019,-23.1071,4217.43);
fitfun[i]->FixParameter(0,1);
fitfun[i]->SetLineStyle(2);
fitfun[i]->SetLineColor(colorCode[i]);*/
hProrefptJES[i]->SetMarkerStyle(markerCode[i]);
hProrefptJES[i]->SetMarkerColor(colorCode[i]);
hProrefptJES[i]->SetLineColor(colorCode[i]);
hProrefptJES[i]->SetMarkerSize(1.4);
if(canvas[i]!=4)
leg2->AddEntry(hProrefptJES[i],etastring[i],"lp");
/*hProrefptJES[i]->Fit(fitfun[i],"Q","same",20,600);
fstr<<etastring[i]<<endl;
fstr<<fitfun[i]->GetParameter(0)<<"\t";
fstr<<fitfun[i]->GetParameter(1)<<'\t';
fstr<<fitfun[i]->GetParameter(2)<<'\t';
fstr<<fitfun[i]->GetParameter(3)<<endl<<endl;
cout<<"chis="<<fitfun[i]->GetChisquare()<<endl;
cout<<"ndf="<<fitfun[i]->GetNDF()<<endl;*/
l->Draw("same");
if(canvas[i]!=4) hProrefptJES[i]->DrawCopy("same");
}
for(int i=0;i<Neta-1;i++)	if(canvas[i]!=3 && canvas[i]!=4) hProrefptJES[i]->DrawCopy("same");
//fitfun->Draw("same");
//leg2->AddEntry(fitfun,"fit function","l");
//for(int i=0;i<Neta-1;i++)  hProrefptJES[i]->DrawCopy("same");
T1->DrawLatex(0.18,0.85,"PYTHIA+HIJING");
T1->DrawLatex(0.18,0.90,"CMS simulation");
T1->DrawLatex(0.28,0.17,"Anti-k_{T} Particle Flow PU Jets: R=0.3");
leg2->SetBorderSize(0);
leg2->SetFillColor(0);
leg2->Draw("same");
c2->Print(Form("refptJES_etabin_%s.pdf",algo.Data()));
//drawCMS(0.4,0.9);

}
예제 #22
0
void drawTrkD0(
							 TString infname="trkqualhists_dataj35_mc80j1_80_v11_hiGlobPrim_allcent_startBaseCut_pt4.root"
							 //TString infname="trkqualhists_dataj35_mc80j1_80_v11_hiGlobPrim_allcent_unCut_pt4.root"
							 //TString infname="trkqualhists_dataj35_mc80j1_80_v11_hiGlobPrim_allcent_nhit10Cut_pt4.root"
							 //TString infname="trkqualhists_dataj35_mc80j1_80_v11_hiGlobPrim_allcent_startNHit10Chi20_Cut_pt4.root"
    )
{
	Bool_t doLog = 0;
  cout << "input: " << infname << endl;
  TFile * inf = new TFile(infname);	
	//TString outdir = "out/20110519/"+infname;
	TString outdir = "out/20110519/"+infname;
	if (!doLog) outdir = "out/20110519/"+infname+"/lin";
	outdir.ReplaceAll(".root","");
	gSystem->mkdir(outdir,kTRUE);
  cout << "output: " << outdir << endl;

  TCanvas * c4 = new TCanvas("c4","c4",1600,400);
	makeMultiPanelCanvas(c4,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c4,4,1e-5,10,1,-3,3);
  else drawQual(inf,c4,4,1e-5,0.45,0,-3,3);
  c4->Print(outdir+"/Qual4.gif");
  c4->Print(outdir+"/Qual4.pdf");
	
  TCanvas * c5 = new TCanvas("c5","c5",1600,400);
	makeMultiPanelCanvas(c5,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c5,5,1e-5,10,1,-3,3);
	else drawQual(inf,c5,5,1e-5,0.25,0,-3,3);
  c5->Print(outdir+"/Qual5.gif");
  c5->Print(outdir+"/Qual5.pdf");
	
  TCanvas * c9 = new TCanvas("c9","c9",1600,400);
	makeMultiPanelCanvas(c9,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c9,9,1e-5,10,1,-3,3);
	else drawQual(inf,c9,9,1e-5,0.1,0,-8,8);
  c9->Print(outdir+"/Qual9.gif");
  c9->Print(outdir+"/Qual9.pdf");
	
  TCanvas * c10 = new TCanvas("c10","c10",1600,400);
	makeMultiPanelCanvas(c10,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c10,10,1e-5,10,1,-3,3);
  else drawQual(inf,c10,10,1e-5,0.1,0,-8,8);
  c10->Print(outdir+"/Qual10.gif");
  c10->Print(outdir+"/Qual10.pdf");
	
  TCanvas * c13 = new TCanvas("c13","c13",1600,400);
	makeMultiPanelCanvas(c13,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c13,13,1e-5,10,1,-0.2,0.2);
  else drawQual(inf,c13,13,1e-5,0.2,0,-0.1,0.1);
  c13->Print(outdir+"/Qual13.gif");
  c13->Print(outdir+"/Qual13.pdf");

  TCanvas * c14 = new TCanvas("c14","c14",1600,400);
	makeMultiPanelCanvas(c14,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c14,14,1e-5,10,1,0,0.01);
  else drawQual(inf,c14,14,1e-5,0.25,0,0,0.01);
  c14->Print(outdir+"/Qual14.gif");
  c14->Print(outdir+"/Qual14.pdf");
	
	TCanvas * c15 = new TCanvas("c15","c15",1600,400);
	makeMultiPanelCanvas(c15,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c15,15,1e-5,10,1,-0.2,0.2);
  else drawQual(inf,c15,15,1e-5,0.15,0,-0.2,0.2);
  c15->Print(outdir+"/Qual15.gif");
  c15->Print(outdir+"/Qual15.pdf");
	
  TCanvas * c16 = new TCanvas("c16","c16",1600,400);
	makeMultiPanelCanvas(c16,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c16,16,1e-5,10,1,0,0.01);
  else drawQual(inf,c16,16,1e-5,0.1,0,0,0.01);
  c16->Print(outdir+"/Qual16.gif");
  c16->Print(outdir+"/Qual16.pdf");
	
  TCanvas * c17 = new TCanvas("c17","c17",1600,400);
	makeMultiPanelCanvas(c17,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c17,17,1e-5,10,1,-8,8);
  else drawQual(inf,c17,17,1e-5,0.1,0,-8,8);
  c17->Print(outdir+"/Qual17.gif");
  c17->Print(outdir+"/Qual17.pdf");
	
  TCanvas * c18 = new TCanvas("c18","c18",1600,400);
	makeMultiPanelCanvas(c18,5,1,0,0,0.25);
  if (doLog) drawQual(inf,c18,18,1e-5,10,1,-8,8);
  else drawQual(inf,c18,18,1e-5,0.1,0,-8,8);
  c18->Print(outdir+"/Qual18.gif");	
  c18->Print(outdir+"/Qual18.pdf");	
}
예제 #23
0
파일: DrawEffHF.C 프로젝트: XuQiao/HI
void DrawEffHF(){
gStyle->SetOptStat(kFALSE);
gStyle->SetErrorX(0);
const int Ncut=5;	const int Nhist=3;	const int NGen=2; const int Ncent=6;
const double HFbin[]={0,0.1,0.2,0.4,0.6,0.8,1,2,4,6,9,12,15,20,30,50,75,100};
const double xerr[Ncent]={0,0,0,0,0,0};
const double HFbin_cent[Nhist][Ncent+1]={
{0,2.92,10.1,19.3,23.7,30.2,100},
{0,1.03,5.00,11.6,15.0,20.3,100},
{0,2.7,12.6,28.6,36.9,49.6,100}};
const double cent[Ncent]={5,15,25,45,75,95};
const int nHFbin=sizeof(HFbin)/sizeof(double)-1;
double color[NGen][Nhist]={{2,1,4},{2,1,4}};
double Style[NGen][Nhist]={{20,24,28},{20,24,28}};
//TString cut[Ncut]={"HLT","CutGplus","pPA","pprim","vz",""};
//TString cutName[Ncut]={"HLT","CutG","clean","pprim","vz","All cuts"};
TString cut[Ncut]={"HLT","HLT_CutGplus","HLT_CutGplus_pPA","HLT_CutGplus_pPA_pprim",""};
TString cutName[Ncut]={"HLT","HLT+CutGplus","HLT+CutGplus+clean","HLT+CutG+clean+pprim","All cuts"};
TString Gen[NGen]={"Hijing","Epos"};
TString histoname[Nhist]={"hHFEnergy4","hHFEnergyPlus4","hHFEnergyPlus"};
TString etarange[Nhist]={"HF E_{T} |#eta|>4","HF E_{T} #eta>4","HF E_{T} #eta>0(Pb going side)"};
TString filename[Ncut][NGen];
TFile* f[Ncut][NGen];
TH1F* h_or[Ncut][NGen][Nhist];	TH1F* reh_or[Ncut][NGen][Nhist];
TH1F* h_tr[Ncut][NGen][Nhist];	TH1F* reh_tr[Ncut][NGen][Nhist];
TGraphErrors *g_Eff[Ncut][NGen][Nhist]; double EffValue[Ncut][NGen][Nhist][Ncent];	double EffValueErr[Ncut][NGen][Nhist][Ncent];
TH1F* rehEff[Ncut][NGen][Nhist];	TLatex* T1[Nhist];	TLatex* T2[Ncut];	TLatex* T3[NGen];
c1 = new TCanvas("c1"," ",800,500);
c2 = new TCanvas("c2"," ",800,700);
c4 = new TCanvas("c4"," ",1000,800);
makeMultiPanelCanvas(c1,2,1,0.15,0.15,0.15,0.15,0.03);
makeMultiPanelCanvas(c2,1,1,0.15,0.1,0.15,0.1,0.03);
makeMultiPanelCanvas(c4,3,2,0.15,0.15,0.15,0.15,0.03);

for(int k=0;k<NGen;k++){
T3[k]=new TLatex(0.6,0.9,Gen[k]);
T3[k]->SetNDC();
T3[k]->SetTextAlign(12);
T3[k]->SetTextSize(0.06);
T3[k]->SetTextColor(1);
T3[k]->SetTextFont(42);
}
for(int j=0;j<Nhist;j++){
T1[j]=new TLatex(0.4,0.82,etarange[j]);
T1[j]->SetNDC();
T1[j]->SetTextAlign(12);
T1[j]->SetTextSize(0.06);
T1[j]->SetTextColor(1);
T1[j]->SetTextFont(42);
}
for(int i=0;i<Ncut;i++){
T2[i]=new TLatex(0.7,0.25,cutName[i]);
T2[i]->SetNDC();
T2[i]->SetTextAlign(12);
T2[i]->SetTextSize(0.08);
T2[i]->SetTextColor(1);
T2[i]->SetTextFont(42);
}
for(int k=0;k<NGen;k++){
for(int j=0;j<Nhist;j++){
for(int i=0;i<Ncut;i++){
if(i==Ncut-1)
filename[i][k]=Form("pPbHist_%s%s",Gen[k].Data(),cut[i].Data());
else
filename[i][k]=Form("pPbHist_%s_%s",Gen[k].Data(),cut[i].Data());
f[i][k]=TFile::Open(Form("%s.root",filename[i][k].Data()));
h_or[i][k][j]=(TH1F*)f[i][k]->Get(histoname[j]);
h_tr[i][k][j]=(TH1F*)f[i][k]->Get(Form("%s_tr",histoname[j].Data()));
fixedFontHist(h_or[i][k][j],1.8,2);
fixedFontHist(h_tr[i][k][j],1.8,2);
//reh_or[i][k][j]=(TH1F*)h_or[i][k][j]->Rebin(Ncent,Form("re%s%s_%d",Gen[k].Data(),histoname[j].Data(),i),HFbin_cent[j]);
//reh_tr[i][k][j]=(TH1F*)h_tr[i][k][j]->Rebin(Ncent,Form("re%s%s_tr_%d",Gen[k].Data(),histoname[j].Data(),i),HFbin_cent[j]);
reh_or[i][k][j]=(TH1F*)h_or[i][k][j]->Rebin(nHFbin,Form("re%s%s_%d",Gen[k].Data(),histoname[j].Data(),i),HFbin);
reh_tr[i][k][j]=(TH1F*)h_tr[i][k][j]->Rebin(nHFbin,Form("re%s%s_tr_%d",Gen[k].Data(),histoname[j].Data(),i),HFbin);
normalizeByBinWidth(reh_or[i][k][j]);
normalizeByBinWidth(reh_tr[i][k][j]);
rehEff[i][k][j]=(TH1F*)reh_tr[i][k][j]->Clone(Form("rehEff_%s%s_%d",Gen[k].Data(),histoname[j].Data(),i));
rehEff[i][k][j]->Divide(reh_or[i][k][j]);
//rehEff[i][k][j]->GetXaxis()->SetTitleSize(0.06);
//rehEff[i][k][j]->GetXaxis()->SetLabelSize(0.06);
//rehEff[i][k][j]->GetYaxis()->SetTitleSize(0.06);
//rehEff[i][k][j]->GetYaxis()->SetLabelSize(0.06);
rehEff[i][k][j]->SetMarkerColor(color[k][j]);
rehEff[i][k][j]->SetMarkerStyle(Style[k][j]);
rehEff[i][k][j]->SetMarkerSize(1.5);
rehEff[i][k][j]->GetXaxis()->SetLimits(0.1,99);
rehEff[i][k][j]->SetMaximum(1.09);
rehEff[i][k][j]->SetMinimum(0.4);
rehEff[i][k][j]->SetTitle("");
rehEff[i][k][j]->GetXaxis()->SetTitle("HF E_{T} (GeV/c)");
rehEff[i][k][j]->GetYaxis()->SetTitle("Event Selection Efficiency");
for(int icentbin=0;icentbin<Ncent;icentbin++){
//EffValue[i][k][j][icentbin]=h_tr[i][k][j]->Integral(h_tr[i][k][j]->GetXaxis()->FindBin(HFbin_cent[j][Ncent-icentbin-1]),h_tr[i][k][j]->GetXaxis()->FindBin(HFbin_cent[j][Ncent-icentbin]))/h_or[i][k][j]->Integral(h_or[i][k][j]->GetXaxis()->FindBin(HFbin_cent[j][Ncent-icentbin-1]),h_or[i][k][j]->GetXaxis()->FindBin(HFbin_cent[j][Ncent-icentbin]));
EffValue[i][k][j][icentbin]=rehEff[i][k][j]->GetBinContent(Ncent-icentbin);
EffValueErr[i][k][j][icentbin]=rehEff[i][k][j]->GetBinError(Ncent-icentbin);
}
g_Eff[i][k][j]= new TGraphErrors(Ncent,cent,EffValue[i][k][j],xerr,EffValueErr[i][k][j]);
g_Eff[i][k][j]->SetTitle("");
g_Eff[i][k][j]->GetXaxis()->SetTitleSize(0.06);
g_Eff[i][k][j]->GetXaxis()->SetLabelSize(0.06);
g_Eff[i][k][j]->GetYaxis()->SetTitleSize(0.06);
g_Eff[i][k][j]->GetYaxis()->SetLabelSize(0.06);
g_Eff[i][k][j]->SetMarkerSize(0.06);
g_Eff[i][k][j]->GetYaxis()->SetTitle("Event Selection Efficiency");
g_Eff[i][k][j]->GetXaxis()->SetTitle("Centrality");
g_Eff[i][k][j]->GetXaxis()->CenterTitle();
g_Eff[i][k][j]->GetYaxis()->SetTitleOffset(1.2);
g_Eff[i][k][j]->GetXaxis()->SetTitleOffset(0.9);
g_Eff[i][k][j]->GetXaxis()->SetRangeUser(1,99);
g_Eff[i][k][j]->GetYaxis()->CenterTitle();
g_Eff[i][k][j]->SetMarkerSize(1.2);
g_Eff[i][k][j]->SetMarkerColor(color[k][j]);
g_Eff[i][k][j]->SetMarkerStyle(Style[k][j]);
g_Eff[i][k][j]->SetMinimum(0.4);
g_Eff[i][k][j]->SetMaximum(1.09);
}
}
}
/*
c1->cd(i+1)->SetLogy();
reh_or[i]->SetTitle("");
reh_or[i]->GetXaxis()->SetTitle("");
if(i==0)
reh_or[i]->GetYaxis()->SetTitle("Counts");
else
reh_tr[i]->GetYaxis()->SetTitle("");
reh_or[i]->SetMarkerStyle(24);
reh_or[i]->SetMarkerSize(1.2);
reh_or[i]->SetMarkerColor(1);
reh_or[i]->Draw();
reh_tr[i]->SetTitle("");
reh_tr[i]->SetMarkerSize(1.2);
reh_tr[i]->SetMarkerColor(2);
reh_tr[i]->SetMarkerStyle(20);
reh_tr[i]->Draw("same");
TLegend *leg=new TLegend(0.7,0.7,0.8,0.9);
leg->SetTextSize(0.05);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->AddEntry(reh_or[i],"Before Selection","lp");
leg->AddEntry(reh_tr[i],"After Selection","lp");
leg->Draw("same");

T1[i]->Draw("same");
*//*
i=Ncut-1;	//All cut
for(k=0;k<NGen;k++){
c1->cd(k+1);
if(k<1){
rehEff[i][k][j]->GetYaxis()->SetTitle("");
rehEff[i][k][j]->GetYaxis()->SetLabelSize(0);
}
TLegend *leg=new TLegend(0.2,0.2,0.35,0.4);
for(j=0;j<Nhist;j++){
if(j==0)
rehEff[i][k][j]->Draw();
else
rehEff[i][k][j]->Draw("same");
leg->SetTextSize(0.05);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->AddEntry(rehEff[i][k][j],etarange[j],"p");
TLine *l=new TLine(cent[0],1,cent[Ncent-1],1);
l->SetLineStyle(2);
}
l->Draw("same");
leg->Draw("same");
T3[k]->Draw("same");
}
c1->Print(Form("pPbHist_%s_HF.png",cut[i].Data()));
*/
i=Ncut-1;j=1;
//c2->cd()->SetLogy();
c2->cd()->SetLogx();
TLegend *leg=new TLegend(0.6,0.2,0.75,0.3);
for(k=0;k<NGen;k++){
rehEff[i][k][j]->GetXaxis()->SetTitleSize(30);
rehEff[i][k][j]->GetXaxis()->SetLabelSize(30);
rehEff[i][k][j]->GetYaxis()->SetTitleSize(30);
rehEff[i][k][j]->GetYaxis()->SetLabelSize(30);
rehEff[i][k][j]->GetYaxis()->SetTitleOffset(0.9);
rehEff[i][k][j]->GetXaxis()->SetTitleOffset(1.1);
rehEff[i][k][j]->GetYaxis()->SetTitleOffset(1);
if(k==0){
rehEff[i][k][j]->Draw();
rehEff[i][k][j]->SetMarkerColor(1);
rehEff[i][k][j]->SetMarkerStyle(20);
}
else{
rehEff[i][k][j]->Draw("same");
rehEff[i][k][j]->SetMarkerColor(2);
rehEff[i][k][j]->SetMarkerStyle(24);
}
leg->SetTextSize(0.05);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->AddEntry(rehEff[i][k][j],Gen[k],"p");
TLine *l=new TLine(0,1,cent[Ncent-1],1);
l->SetLineStyle(2);
}
T1[j]->Draw("same");
leg->Draw("same");
l->Draw("same");

//c2->Print(Form("pPbHist_%s%s_HF.png",cut[i].Data(),histoname[j].Data()));

j=1;k=0;
for(i=0;i<Ncut;i++){
//rehEff[i][k][j]->GetYaxis()->SetTitleOffset(2.5);
rehEff[i][k][j]->GetXaxis()->SetTitleOffset(2);
if(i!=0 &&  i!=3){
rehEff[i][k][j]->GetYaxis()->SetTitle("");
rehEff[i][k][j]->GetYaxis()->SetLabelSize(0);
}

if(i<3){
rehEff[i][k][j]->GetXaxis()->SetTitle("");
rehEff[i][k][j]->GetXaxis()->SetLabelSize(0);
}
c4->cd(i+1)->SetLogy();
//c4->cd(i+1)->SetLogx();
rehEff[i][k][j]->Draw();
rehEff[i][k][j]->SetMarkerColor(1);
rehEff[i][k][j]->SetMarkerStyle(20);
T2[i]->Draw("same");
}
T3[k]->Draw("same");
if(Ncut==5){
c4->cd(6);
TH1F *fNull=new TH1F("","",100,0,100);
fNull->GetXaxis()->SetLabelSize(0.06);
fNull->Draw();
}
if(Ncut==5)

//c4->Print(Form("pPbHist_%s_%s_newcut_HF.png",Gen[k].Data(),histoname[j].Data()));
else
//c4->Print(Form("pPbHist_%s_%s_HF.png",Gen[k].Data(),histoname[j].Data()));

}
예제 #24
0
파일: plotcorr_4p_pt.C 프로젝트: XuQiao/HI
void plotcorr_4p_pt(){
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetStripDecimals(0);
  gStyle->SetErrorX(0);
c1 = new TCanvas("c1"," ",1200,340);
makeMultiPanelCanvas(c1,4,1,0,0,0.25,0.2,0.03);
//TString dire = "north";
TString dire = "south";
  float const PI = acos(-1.0);
const int ncent = 6;
const int npt = 25;
  TFile *f=TFile::Open("../../../work/200GeV/output_3corr.root");
TH1F* kforebbcw[npt][ncent];
TH1F* hforebbcw[npt][ncent];
TH1F* kbackbbcw2[npt][ncent];
TH1F* kforebbcw_centIn[npt];
TH1F* hforebbcw_centIn[npt];
TH1F* kbackbbcw2_centIn[npt];
double ptbin[npt+1] = {0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0};
//double centbin[ncent+1] = {0,1,5,10,20,30,40,60,100}; //fvtx or cent
//double centbin[ncent+1] = {0,1,5,10,20,30,40,60,100}; //fvtx or cent
double centbin[ncent+1] = {0,5,10,20,40,60,100}; //fvtx or cent
//double centbin[ncent] = {224,170,146,120,89,65,0};
/*double centmin = 1.0; double centmax = 3.0;//has to be boundary
for(int icent=0; icent<ncent; icent++){
if(centmin >= centbin[icent] && centmin < centbin[icent+1]){int xcentmin = icent; continue;}
if(centmax >= centbin[icent] && centmax < centbin[icent+1]){int xcentmax = icent; continue;}
}*/
for(int icent_a=0;icent_a<ncent;icent_a++){
int xcentmin = icent_a*1;
int xcentmax = (icent_a+1)*1;
double centmin = centbin[xcentmin];
double centmax = centbin[xcentmax];

for(int ipt=0; ipt<npt; ipt++){
for(int icent=0; icent<ncent; icent++){
kforebbcw[ipt][icent] = (TH1F*)f->Get(Form("kfore%sbbcw_%d_%d",dire.Data(),icent,ipt));
//htemp = (TH1F*)f->Get(Form("kforeW%sbbcw_%d_%d",dire.Data(),icent,ipt));
//kforebbcw[ipt][icent]->Add(htemp);
hforebbcw[ipt][icent] = (TH1F*)f->Get(Form("hfore%sbbcw_%d_%d",dire.Data(),icent,ipt));
//htemp = (TH1F*)f->Get(Form("hforeW%sbbcw_%d_%d",dire.Data(),icent,ipt));
//hforebbcw[ipt][icent]->Add(htemp);
kbackbbcw2[ipt][icent] = (TH1F*)f->Get(Form("kback%sbbcw2_%d_%d",dire.Data(),icent,ipt));
//htemp = (TH1F*)f->Get(Form("kbackW%sbbcw_%d_%d",dire.Data(),icent,ipt));
//kbackbbcw2[ipt][icent]->Add(htemp);
}
kforebbcw_centIn[ipt] = (TH1F*)kforebbcw[ipt][xcentmin]->Clone();
hforebbcw_centIn[ipt] = (TH1F*)hforebbcw[ipt][xcentmin]->Clone();
kbackbbcw2_centIn[ipt] = (TH1F*)kbackbbcw2[ipt][xcentmin]->Clone();
for(int icent=xcentmin+1; icent<xcentmax; icent++){
kforebbcw_centIn[ipt]->Add(kforebbcw[ipt][icent]);
hforebbcw_centIn[ipt]->Add(hforebbcw[ipt][icent]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2[ipt][icent]);
}
kforebbcw_centIn[ipt]->Rebin(2);
hforebbcw_centIn[ipt]->Rebin(2);
kbackbbcw2_centIn[ipt]->Rebin(2);
}

TH1F* hpp[npt];
TH1F* hbackpp[npt];
for(int ipt=0; ipt<4; ipt++){
  int ipt_add;
	if(ipt==0){
for(int ipt_add=1;ipt_add<5;ipt_add++){
kforebbcw_centIn[ipt]->Add(kforebbcw_centIn[ipt_add]);
hforebbcw_centIn[ipt]->Add(hforebbcw_centIn[ipt_add]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2_centIn[ipt_add]);
}
ptbin[ipt] = 0.2 ;
ptbin[ipt+1] = 1.0 ;
}
	if(ipt==1){
kforebbcw_centIn[ipt]->Reset("M");
hforebbcw_centIn[ipt]->Reset("M");
kbackbbcw2_centIn[ipt]->Reset("M");
for(int ipt_add=5;ipt_add<10;ipt_add++){
kforebbcw_centIn[ipt]->Add(kforebbcw_centIn[ipt_add]);
hforebbcw_centIn[ipt]->Add(hforebbcw_centIn[ipt_add]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2_centIn[ipt_add]);
}
ptbin[ipt] = 1.0 ;
ptbin[ipt+1] = 2.0 ;
}
	if(ipt==2){
kforebbcw_centIn[ipt]->Reset("M");
hforebbcw_centIn[ipt]->Reset("M");
kbackbbcw2_centIn[ipt]->Reset("M");
for(int ipt_add=10;ipt_add<15;ipt_add++){
kforebbcw_centIn[ipt]->Add(kforebbcw_centIn[ipt_add]);
hforebbcw_centIn[ipt]->Add(hforebbcw_centIn[ipt_add]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2_centIn[ipt_add]);
}
ptbin[ipt] = 2.0 ;
ptbin[ipt+1] = 3.0 ;
}
	if(ipt==3){
kforebbcw_centIn[ipt]->Reset("M");
hforebbcw_centIn[ipt]->Reset("M");
kbackbbcw2_centIn[ipt]->Reset("M");
for(int ipt_add=15;ipt_add<20;ipt_add++){
kforebbcw_centIn[ipt]->Add(kforebbcw_centIn[ipt_add]);
hforebbcw_centIn[ipt]->Add(hforebbcw_centIn[ipt_add]);
kbackbbcw2_centIn[ipt]->Add(kbackbbcw2_centIn[ipt_add]);
}
ptbin[ipt] = 3.0 ;
ptbin[ipt+1] = 4.0 ;
}
  hpp[ipt] = (TH1F*)kforebbcw_centIn[ipt]->Clone();
  hbackpp[ipt] = (TH1F*)kbackbbcw2_centIn[ipt]->Clone();
  float nbackpp = hbackpp[ipt]->Integral()/2.0/PI;
  float nforepp = hpp[ipt]->Integral()/2.0/PI;
//float ntrig0 = centforedis_0->Integral(11,30);
   for(int i=0; i<20; i++){
     float pp_cont = 1.0*hpp[ipt]->GetBinContent(i+1);
     //float pp0_err = 1.0*hpp[ipt]->GetBinError(i+1);
     float weight2 = sqrt(1.0*hforebbcw_centIn[ipt]->GetBinContent(i+1));

     float backpp_cont = 1.0*hbackpp[ipt]->GetBinContent(i+1);
    
     float con = pp_cont/backpp_cont*nbackpp/nforepp;
     float err = weight2/backpp_cont*nbackpp/nforepp;

     hpp[ipt]->SetBinContent(i+1, con);
     hpp[ipt]->SetBinError(i+1, err);
   }

  c1->cd(ipt+1);
  gPad->SetTicks(1,1);
  

//  float ymax = 1.032;//hpp[ipt]->GetMaximum()*1.1;
//  float ymin = 0.968;//hpp[ipt]->GetMinimum()*0.9;
  float ymax = 1.03;//hpp[ipt]->GetMaximum()*1.1;
  float ymin = 0.97;//hpp[ipt]->GetMinimum()*0.9;

  hpp[ipt]->SetMinimum(ymin);
  hpp[ipt]->SetMaximum(ymax);

  hpp[ipt]->SetMarkerStyle(20);
  hpp[ipt]->SetMarkerSize(1.3);
  
  hpp[ipt]->SetMarkerColor(4);
  hpp[ipt]->GetYaxis()->SetLabelSize(0.08);
  hpp[ipt]->GetXaxis()->SetLabelSize(0.04);
  hpp[ipt]->GetYaxis()->SetNdivisions(505);
  //hpp[ipt]->GetYaxis()->SetTitleSize(0.6);
  //hpp[ipt]->GetXaxis()->SetTitleSize(0.0);
  hpp[ipt]->Draw("PE");
  TF1 *fun0 = new TF1("fun0","[0]*(1+2*[1]*cos(x)+2*[2]*cos(2*x)+2*[3]*cos(3*x)+2*[4]*cos(4*x))", -0.5*PI, 1.5*PI);

  fun0->SetLineColor(1);
  hpp[ipt]->Fit("fun0","R");


  TF1 *fun1 = new TF1("fun1","[0]*(1+2*[1]*cos(x))",   -0.5*PI, 1.5*PI);
  TF1 *fun2 = new TF1("fun2","[0]*(1+2*[1]*cos(2*x))", -0.5*PI, 1.5*PI);
  TF1 *fun3 = new TF1("fun3","[0]*(1+2*[1]*cos(3*x))", -0.5*PI, 1.5*PI);
  TF1 *fun4 = new TF1("fun4","[0]*(1+2*[1]*cos(4*x))", -0.5*PI, 1.5*PI);

TLegend *leg1 = new TLegend(0.22,0.22,0.82,0.32);
  leg1->SetFillColor(10);
  leg1->SetLineStyle(4000);
  leg1->SetLineColor(10);
  leg1->SetLineWidth(0.);
  leg1->SetTextSize(0.055);
  leg1->SetBorderSize(0);
  leg1->AddEntry(fun0,"1+#Sigma2c_{n}cos(n#Delta#phi)","L");
  if(ipt==1)leg1->Draw();

  TLegend *leg2 = new TLegend(0.12,0.62,0.32,0.85);
  leg2->SetFillColor(10);
  leg2->SetLineStyle(4000);
  leg2->SetLineColor(10);
  leg2->SetLineWidth(0.);
  leg2->SetTextSize(0.055);
  leg2->SetBorderSize(0);
  leg2->AddEntry(fun1,"1+2c_{1}cos(#Delta#phi)","L");
  leg2->AddEntry(fun2,"1+2c_{2}cos(2#Delta#phi)","L");
  leg2->AddEntry(fun3,"1+2c_{3}cos(3#Delta#phi)","L");
  leg2->AddEntry(fun4,"1+2c_{4}cos(4#Delta#phi)","L");
  if(ipt==1)leg2->Draw();

  fun1->SetParameters(fun0->GetParameter(0), fun0->GetParameter(1));
  fun2->SetParameters(fun0->GetParameter(0), fun0->GetParameter(2));
  fun3->SetParameters(fun0->GetParameter(0), fun0->GetParameter(3));
  fun4->SetParameters(fun0->GetParameter(0), fun0->GetParameter(4));

  fun1->SetLineColor(3);
  fun2->SetLineColor(2);
  fun3->SetLineColor(6);
  fun4->SetLineColor(9);

  fun1->SetLineStyle(2);
  fun2->SetLineStyle(3);
  fun3->SetLineStyle(4);
  fun4->SetLineStyle(5);

  fun1->Draw("same");
  fun2->Draw("same");
  fun3->Draw("same");
  fun4->Draw("same");

  hpp[ipt]->GetXaxis()->SetTitle("#Delta#phi");
  hpp[ipt]->GetXaxis()->SetTitleSize(0.08);
  hpp[ipt]->GetXaxis()->SetLabelSize(0.08);
  hpp[ipt]->GetXaxis()->CenterTitle();
  hpp[ipt]->GetXaxis()->SetTitleOffset(1.1);
  if(ipt==0)
  hpp[ipt]->GetYaxis()->SetTitle("C(d#phi)");
  else
  hpp[ipt]->GetYaxis()->SetLabelSize(0);
  hpp[ipt]->GetYaxis()->SetTitleSize(0.08);
  hpp[ipt]->GetYaxis()->CenterTitle();
  hpp[ipt]->GetYaxis()->SetTitleOffset(1.3);
  hpp[ipt]->GetYaxis()->SetLabelSize(0.08);
  if(ipt==0)
  hpp[ipt]->GetYaxis()->SetTitle("C(#Delta#phi)");
  TLatex *t=new TLatex(-1.0,0.88*(ymax-ymin)+ymin, Form("%d)",icent+1));
  TLatex *t=new TLatex(-1.0,0.88*(ymax-ymin)+ymin, Form("%d)",ipt+1));
  t->SetTextSize(0.06);
 // t->Draw();

  TMarker *m0 = new TMarker(-0.6, 0.91*(ymax-ymin)+ymin, 20);
  m0->SetMarkerSize(1.3);
  m0->SetMarkerColor(4);
//  m0->Draw();

  if(ipt==0){
  TLatex *t=new TLatex(-0.4,0.88*(ymax-ymin)+ymin, Form("Run16 d+Au 200GeV"));
  t->SetTextSize(0.06);
  t->Draw();
  TLatex *t=new TLatex(1.2,0.78*(ymax-ymin)+ymin, Form("%.1f < p_{T}^{trig} < %.1f (GeV/c)",ptbin[ipt],ptbin[ipt+1]));
  }
  else
  TLatex *t=new TLatex(1.2,0.78*(ymax-ymin)+ymin, Form("%.1f < p_{T}^{trig} < %.1f (GeV/c)",ptbin[ipt],ptbin[ipt+1]));
 // TLatex *t=new TLatex(-0.1,0.88*(ymax-ymin)+ymin, Form("p+p %.1f < p_{T} < %.1f (GeV/c)",ptbin[ipt],ptbin[ipt+1]));
  t->SetTextSize(0.06);
  t->Draw();

  TLatex *t=new TLatex(-1.2,0.78*(ymax-ymin)+ymin, Form("%.f - %.f%%",centmin,centmax));
  //TLatex *t=new TLatex(-1.2,0.78*(ymax-ymin)+ymin, Form("Minimum Bias"));
  t->SetTextSize(0.06);
  if(ipt==0)t->Draw();

if(dire=="north")
  TLatex *t=new TLatex(-1.2,0.14*(ymax-ymin)+ymin, "3.0<#eta_{asso}<3.9");
else
  TLatex *t=new TLatex(-1.2,0.14*(ymax-ymin)+ymin, "-3.9<#eta_{asso}<-3.0");
  t->SetTextSize(0.06);
  t->SetTextColor(2);
  if(ipt==0)t->Draw();

}
  c1->cd();
/*
  TLatex *tx1=new TLatex(0.30,0.028, "#Delta#phi");
  tx1->SetTextSize(0.04);
  tx1->Draw();

  TLatex *tx2=new TLatex(0.75,0.028, "#Delta#phi");
  tx2->SetTextSize(0.04);
  tx2->Draw();

  TLatex *ty1 = new TLatex(0.052,0.78, "C(#Delta#phi)");
  ty1->SetTextSize(0.04);
  ty1->SetTextAngle(90);
  ty1->Draw();

  TLatex *ty2 = new TLatex(0.052,0.50, "C(#Delta#phi)");
  ty2->SetTextSize(0.04);
  ty2->SetTextAngle(90);
  ty2->Draw();

  TLatex *ty3 = new TLatex(0.052,0.20, "C(#Delta#phi)");
  ty3->SetTextSize(0.04);
  ty3->SetTextAngle(90);
  ty3->Draw();
*/
  c1->Print(Form("fig/ridge_pt_%s_%.1f_%.1f.gif",dire.Data(),centmin,centmax));
  c1->Print(Form("fig/ridge_pt_%s_%.1f_%.1f.png",dire.Data(),centmin,centmax));
  c1->Print(Form("fig/ridge_pt_%s_%.1f_%.1f.pdf",dire.Data(),centmin,centmax));
}

/*  
  cout<<"*************** v2 ***********"<<endl;
  float v2_0 = funvn0->GetParameter(1)/(zym_pp0 + funvn0->GetParameter(0));
  float v2_1 = funvn1->GetParameter(1)/(zym_pp1 + funvn1->GetParameter(0));
  float v2_2 = funvn2->GetParameter(1)/(zym_pp2 + funvn2->GetParameter(0));
  float v2_3 = funvn3->GetParameter(1)/(zym_pp3 + funvn3->GetParameter(0));
  

  cout<<v2_0<<" "<<v2_1<<" "<<v2_2<<" "<<v2_3<<endl;
 
  
  cout<<funvn0->GetParameter(0)*funvn0->GetParameter(1)<<" "
      <<funvn1->GetParameter(0)*funvn1->GetParameter(1)<<" "
      <<funvn2->GetParameter(0)*funvn2->GetParameter(1)<<" "
      <<funvn3->GetParameter(0)*funvn3->GetParameter(1)<<endl;
  

  cout<<"*************** v2 ***********"<<endl;
  cout<<funvn0->GetParameter(2)<<" "<<funvn1->GetParameter(2)<<" "<<funvn2->GetParameter(2)<<" "<<funvn3->GetParameter(2)<<endl;

  cout<<"*************** v3 ***********"<<endl;
  cout<<funvn0->GetParameter(3)<<" "<<funvn1->GetParameter(3)<<" "<<funvn2->GetParameter(3)<<" "<<funvn3->GetParameter(3)<<endl;
*/
}
예제 #25
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();
}
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");




    
}
예제 #27
0
void cent_closure_test(){
TH1D::SetDefaultSumw2();
TFile * f= new TFile("/export/d00/scratch/abaty/trackingEff/closure_ntuples/track_ntuple_HiForest_Pythia_Hydjet_Jet80_Track8_Jet21_STARTHI53_LV1_merged_forest_0_akVs3Calo_testforfake_big.root");
TTree * nt_track = (TTree*)f->Get("nt_track");
TTree * nt_particle = (TTree*)f->Get("nt_particle");


TLegend *leg = new TLegend(0.6,0.75,0.95,0.95);
leg->SetBorderSize(0);
leg->SetFillStyle(0);

double bin_pt_min=0.5;
double bin_pt_max=300;
double nbins = 50;
double low   =0;
double high  = 200;


/*
const int ny=50;
double x[ny+1];
double inix=log(bin_pt_min)/log(10);
double delta=(log(bin_pt_max)-log(bin_pt_min))/(50*log(10));
for(int ix=0; ix<ny+1;ix++){
 x[ix]=pow(10,inix); 
 inix+=delta;
}*/

/*
const int ny=50;
double x[ny+1];
double inix=log(bin_pt_min)/log(10);
double delta=(log(bin_pt_max)-log(bin_pt_min))/(50*log(10));
int maxbin=ny;
for(int ix=0; ix<ny+1;ix++){
 x[ix]=pow(10,inix);
 if(x[ix]>100){
        x[ix]=bin_pt_max;
        maxbin=ix;
        break;
 }
 inix+=delta;
}*/

//eff correction
TH1D * h_gen = new  TH1D("h_gen",";cent;N_{evt}",nbins,low,high);
TH1D * h_gen_select = new  TH1D("h_gen_select",";cent;N_{evt}",nbins,low,high);
TH1D * h_gen_matched_select_corr = new TH1D("h_gen_matched_select_corr",";cent;N_{evt}",nbins,low,high);

nt_particle->Draw("cent>>h_gen","pt>0.5");
nt_particle->Draw("cent>>h_gen_select","(trackselect && pt>0.5)");
nt_particle->Draw("cent>>h_gen_matched_select_corr","(1/eff)*(trackselect && pt>0.5)");

h_gen->SetMarkerColor(1);
h_gen->SetMarkerStyle(25);
h_gen->SetLineWidth(1);
h_gen_select->SetMarkerColor(1);
h_gen_matched_select_corr->SetMarkerColor(kRed);
h_gen_matched_select_corr->SetLineColor(kRed);

TLegend *leg2 = new TLegend(0.2,0.15,0.75,0.55);
leg2->SetBorderSize(0);
leg2->SetFillStyle(0);

leg2->AddEntry((TObject*)0,"CMS Preliminary","");
leg2->AddEntry((TObject*)0,"#hat{p}_{T}>80 GeV/c Pythia+Hydjet","");
leg2->AddEntry((TObject*)0,"VsCalo jets, HI tracking","");
leg2->AddEntry(h_gen,"gen","p");
leg2->AddEntry(h_gen_select,"gen select matched uncorr","p");
leg2->AddEntry(h_gen_matched_select_corr,"gen select matched corr","p");

TCanvas * c2 = new TCanvas("c2","",600,600);
makeMultiPanelCanvas(c2,1,2,0.0,0.0,0.15,0.15,0.02);
c2->cd(1);
//c2->cd(1)->SetLogx();
c2->cd(1)->SetLogy();
h_gen->Draw();

h_gen->GetYaxis()->SetLabelSize(18);
h_gen->GetYaxis()->SetLabelFont(43);
h_gen->GetYaxis()->SetTitleSize(25);
h_gen->GetYaxis()->SetTitleFont(43);
h_gen->GetYaxis()->SetTitleOffset(1.5);
h_gen->GetXaxis()->SetLabelSize(22);
h_gen->GetXaxis()->SetLabelFont(43);
h_gen->GetXaxis()->SetTitleSize(20);
h_gen->GetXaxis()->SetTitleFont(43);
h_gen->GetXaxis()->SetTitleOffset(1.5);

//h_gen->Draw("same hist");
h_gen_select->Draw("same");
h_gen_matched_select_corr->Draw("same");
leg2->Draw("same");
//c2->cd(2);
//c2->cd(2)->SetLogx();

TH1D * hgen_corr_rat = (TH1D*)h_gen_matched_select_corr->Clone("hgen_corr_rat");
hgen_corr_rat->Divide(h_gen);
//hgen_corr_rat->GetYaxis()->SetTitle("N_{gen}/N_{gen,sel,match}");

TH1D * hgen_uncorr_rat = (TH1D*)h_gen_select->Clone("hgen_uncorr_rat");
hgen_uncorr_rat->Divide(h_gen);
hgen_uncorr_rat->SetMaximum(1.1);
hgen_uncorr_rat->SetMinimum(0.2);

hgen_uncorr_rat->GetYaxis()->SetTitle("N_{gen,sel,match}/N_{gen}");
//hgen_corr_rat->SetMaximum(1.1);
//hgen_corr_rat->SetMinimum(0.7);
//hgen_uncorr_rat->Draw();
hgen_uncorr_rat->GetYaxis()->SetLabelSize(18);
hgen_uncorr_rat->GetYaxis()->SetLabelFont(43);
hgen_uncorr_rat->GetYaxis()->SetTitleSize(25);
hgen_uncorr_rat->GetYaxis()->SetTitleFont(43);
hgen_uncorr_rat->GetYaxis()->SetTitleOffset(1.5);
hgen_uncorr_rat->GetXaxis()->SetLabelSize(22);
hgen_uncorr_rat->GetXaxis()->SetLabelFont(43);
hgen_uncorr_rat->GetXaxis()->SetTitleSize(20);
hgen_uncorr_rat->GetXaxis()->SetTitleFont(43);
hgen_uncorr_rat->GetXaxis()->SetTitleOffset(1.5);
//hgen_corr_rat->Draw("same");

TLegend *leg2a = new TLegend(0.7,0.2,0.95,0.4);
leg2a->SetBorderSize(0);
leg2a->SetFillStyle(0);

leg2a->AddEntry(hgen_corr_rat,"corr","p");
leg2a->AddEntry(hgen_uncorr_rat,"uncorr","p");
//leg2a->Draw("same");

c2->cd(2);
hgen_corr_rat->SetMaximum(1.05);
hgen_corr_rat->SetMinimum(0.95);
hgen_corr_rat->GetYaxis()->SetTitle("N_{gen,sel,match,corr}/N_{gen}");
hgen_corr_rat->Draw();
hgen_corr_rat->GetYaxis()->SetLabelSize(18);
hgen_corr_rat->GetYaxis()->SetLabelFont(43);
hgen_corr_rat->GetYaxis()->SetTitleSize(25);
hgen_corr_rat->GetYaxis()->SetTitleFont(43);
hgen_corr_rat->GetYaxis()->SetTitleOffset(1.5);
hgen_corr_rat->GetXaxis()->SetLabelSize(22);
hgen_corr_rat->GetXaxis()->SetLabelFont(43);
hgen_corr_rat->GetXaxis()->SetTitleSize(20);
hgen_corr_rat->GetXaxis()->SetTitleFont(43);
hgen_corr_rat->GetXaxis()->SetTitleOffset(1.5);

TLine * l = new TLine(0,1,200,1);
l->Draw("same");

c2->SaveAs("compare_gen_select_corr_cent.png");
c2->SaveAs("compare_gen_select_corr_cent.pdf");




/***********************************************************************************/
//fake correction
TH1D * h_reco = new  TH1D("h_reco",";cent;N_{evt}",nbins,low,high);
TH1D * h_reco_matched = new  TH1D("h_reco_matched",";cent;N_{evt}",nbins,low,high);
TH1D * h_reco_fakecorr = new TH1D("h_reco_fakecorr",";cent;N_{evt}",nbins,low,high);
nt_track->Draw("cent>>h_reco","(trackselect && pt>0.5)"); 
nt_track->Draw("cent>>h_reco_matched","(trackselect && !trkfake && pt>0.5)"); 
nt_track->Draw("cent>>h_reco_fakecorr","(1-fake)*(trackselect && pt>0.5)"); 

//h_reco->SetMarkerSize(1);
//h_reco->SetMarkerStyle(25);
h_reco_matched->SetMarkerColor(1);
h_reco_matched->SetMarkerStyle(25);
h_reco_fakecorr->SetMarkerColor(kRed);
h_reco_fakecorr->SetLineColor(kRed);

TLegend *leg3 = new TLegend(0.3,0.15,0.75,0.55);
leg3->SetBorderSize(0);
leg3->SetFillStyle(0);

leg3->AddEntry((TObject*)0,"CMS Preliminary","");
leg3->AddEntry((TObject*)0,"#hat{p}_{T}>80 GeV/c Pythia+Hydjet","");
leg3->AddEntry((TObject*)0,"VsCalo jets, HI tracking","");
leg3->AddEntry(h_reco,"reco","p");
leg3->AddEntry(h_reco_matched,"reco matched","p");
leg3->AddEntry(h_reco_fakecorr,"reco fake corr","p");

TCanvas * c3 = new TCanvas("c3","",600,600);
makeMultiPanelCanvas(c3,1,2,0.0,0.0,0.15,0.15,0.02);
c3->cd(1);
//c3->cd(1)->SetLogx();
c3->cd(1)->SetLogy();
h_reco->Draw();
h_reco->GetYaxis()->SetLabelSize(18);
h_reco->GetYaxis()->SetLabelFont(43);
h_reco->GetYaxis()->SetTitleSize(25);
h_reco->GetYaxis()->SetTitleFont(43);
h_reco->GetYaxis()->SetTitleOffset(1.5);
h_reco->GetXaxis()->SetLabelSize(22);
h_reco->GetXaxis()->SetLabelFont(43);
h_reco->GetXaxis()->SetTitleSize(20);
h_reco->GetXaxis()->SetTitleFont(43);
h_reco->GetXaxis()->SetTitleOffset(1.5);
//h_reco->Draw("same hist");
h_reco_matched->Draw("same");
h_reco_fakecorr->Draw("same");
leg3->Draw("same");
//c3->cd(2);
//c3->cd(2)->SetLogx();
TH1D * hreco_fakecorr_rat = (TH1D*)h_reco_fakecorr->Clone("hreco_fakecorr_rat");
hreco_fakecorr_rat->Divide(h_reco_matched);
//hreco_fakecorr_rat->GetYaxis()->SetTitle("N_{reco,matched}/N_{reco,fake}");

TH1D * hreco_fakeuncorr_rat = (TH1D*)h_reco->Clone("hreco_fakeuncorr_rat");
hreco_fakeuncorr_rat->Divide(h_reco_matched);
hreco_fakeuncorr_rat->SetMaximum(1.4);
hreco_fakeuncorr_rat->SetMinimum(0.9);
hreco_fakeuncorr_rat->GetYaxis()->SetTitle("N_{reco}/N_{reco,matched}");
//hreco_fakecorr_rat->SetMaximum(1.1);
//hreco_fakecorr_rat->SetMinimum(0.85);
//hreco_fakeuncorr_rat->Draw();
hreco_fakeuncorr_rat->GetYaxis()->SetLabelSize(18);
hreco_fakeuncorr_rat->GetYaxis()->SetLabelFont(43);
hreco_fakeuncorr_rat->GetYaxis()->SetTitleSize(25);
hreco_fakeuncorr_rat->GetYaxis()->SetTitleFont(43);
hreco_fakeuncorr_rat->GetYaxis()->SetTitleOffset(1.5);
hreco_fakeuncorr_rat->GetXaxis()->SetLabelSize(22);
hreco_fakeuncorr_rat->GetXaxis()->SetLabelFont(43);
hreco_fakeuncorr_rat->GetXaxis()->SetTitleSize(20);
hreco_fakeuncorr_rat->GetXaxis()->SetTitleFont(43);
hreco_fakeuncorr_rat->GetXaxis()->SetTitleOffset(1.5);
//hreco_fakecorr_rat->Draw("same");

TLegend *leg3a = new TLegend(0.5,0.7,0.95,0.9);
leg3a->SetBorderSize(0);
leg3a->SetFillStyle(0);

leg3a->AddEntry(hreco_fakecorr_rat,"corr","p");
leg3a->AddEntry(hreco_fakeuncorr_rat,"uncorr","p");
//leg3a->Draw("same");

c3->cd(2);
hreco_fakecorr_rat->SetMaximum(1.05);
hreco_fakecorr_rat->SetMinimum(0.95);
hreco_fakecorr_rat->GetYaxis()->SetTitle("N_{reco}/N_{reco,matched}");
hreco_fakecorr_rat->Draw();
hreco_fakecorr_rat->GetYaxis()->SetLabelSize(18);
hreco_fakecorr_rat->GetYaxis()->SetLabelFont(43);
hreco_fakecorr_rat->GetYaxis()->SetTitleSize(25);
hreco_fakecorr_rat->GetYaxis()->SetTitleFont(43);
hreco_fakecorr_rat->GetYaxis()->SetTitleOffset(1.5);
hreco_fakecorr_rat->GetXaxis()->SetLabelSize(22);
hreco_fakecorr_rat->GetXaxis()->SetLabelFont(43);
hreco_fakecorr_rat->GetXaxis()->SetTitleSize(20);
hreco_fakecorr_rat->GetXaxis()->SetTitleFont(43);
hreco_fakecorr_rat->GetXaxis()->SetTitleOffset(1.5);


l->Draw("same");

c3->SaveAs("compare_reco_fake_corr_cent.png");
c3->SaveAs("compare_reco_fake_corr_cent.pdf");




/**********************************************************************************/
//full correction
TH1D * h_reco_fakecorr_effcorr = new TH1D("h_reco_fakecorr_effcorr",";cent;N_{evt}",nbins,low,high);
TH1D * h_reco_fakecorr_effcorr_unfold = new TH1D("h_reco_fakecorr_effcorr_unfold",";cent;N_{evt}",nbins,low,high);
nt_track->Draw("cent>>h_reco_fakecorr_effcorr","((1-fake)/eff)*(trackselect && pt>0.5)"); 

h_reco_fakecorr_effcorr->SetMarkerColor(kRed);
h_reco_fakecorr_effcorr->SetLineColor(kRed);
TLegend *leg4 = new TLegend(0.3,0.15,0.75,0.55);
leg4->SetBorderSize(0);
leg4->SetFillStyle(0);

leg4->AddEntry((TObject*)0,"CMS Preliminary","");
leg4->AddEntry((TObject*)0,"#hat{p}_{T}>80 GeV/c Pythia+Hydjet","");
leg4->AddEntry((TObject*)0,"VsCalo jets, HI tracking","");
leg4->AddEntry(h_gen,"gen","p");
leg4->AddEntry(h_reco_fakecorr_effcorr,"reco corr","p");
leg4->AddEntry(h_reco,"reco","p");


TCanvas *c4 = new TCanvas("c4","",600,600);
makeMultiPanelCanvas(c4,1,2,0.0,0.0,0.15,0.15,0.02);

c4->cd(1);
//c4->cd(1)->SetLogx();
c4->cd(1)->SetLogy();
h_gen->Draw();
h_reco->Draw("same");
h_reco_fakecorr_effcorr->Draw("same");
leg4->Draw("same");
//c4->cd(2);
//c4->cd(2)->SetLogx(); 
TH1D * h_genreco_fullcorr=(TH1D*)h_reco_fakecorr_effcorr->Clone("h_genreco_fullcorr");
h_genreco_fullcorr->Divide(h_gen);
//h_genreco_fullcorr->GetYaxis()->SetTitle("N_{reco,select,corr}/N_{gen}");
//h_genreco_fullcorr->SetMaximum(1.2);
//h_genreco_fullcorr->SetMinimum(0.8);

TH1D * h_genreco=(TH1D*)h_reco->Clone("h_genreco");
h_genreco->Divide(h_gen);
h_genreco->GetYaxis()->SetTitle("N_{reco,select,corr}/N_{gen}");
h_genreco->SetMaximum(1.1);
h_genreco->SetMinimum(0.2);
//h_genreco->Draw();
//h_genreco_fullcorr->Draw("same");

TLegend *leg4a = new TLegend(0.7,0.2,0.95,0.4);
leg4a->SetBorderSize(0);
leg4a->SetFillStyle(0);

leg4a->AddEntry(h_genreco_fullcorr,"corr","p");
leg4a->AddEntry(h_genreco,"uncorr","p");
//leg4a->Draw("same");

c4->cd(2);
h_genreco_fullcorr->SetMaximum(1.05);
h_genreco_fullcorr->SetMinimum(0.95);
h_genreco_fullcorr->GetYaxis()->SetTitle("N_{reco,select,corr}/N_{gen}");
h_genreco_fullcorr->Draw();
h_genreco_fullcorr->GetYaxis()->SetLabelSize(18);
h_genreco_fullcorr->GetYaxis()->SetLabelFont(43);
h_genreco_fullcorr->GetYaxis()->SetTitleSize(25);
h_genreco_fullcorr->GetYaxis()->SetTitleFont(43);
h_genreco_fullcorr->GetYaxis()->SetTitleOffset(1.5);
h_genreco_fullcorr->GetXaxis()->SetLabelSize(22);
h_genreco_fullcorr->GetXaxis()->SetLabelFont(43);
h_genreco_fullcorr->GetXaxis()->SetTitleSize(20);
h_genreco_fullcorr->GetXaxis()->SetTitleFont(43);
h_genreco_fullcorr->GetXaxis()->SetTitleOffset(1.5);


l->Draw("same");

c4->SaveAs("compare_select_fullcorr_cent.png");
c4->SaveAs("compare_select_fullcorr_cent.pdf");





//this part is for crosscheck to see if the matched particle spectrum agrees with spectrum of not-fake tracks
/*
TH1D *h_matched_pt_particle= new TH1D("h_matched_pt_particle","",nbins,low,high);
TH1D *h_matched_pt_trk= new TH1D("h_matched_pt_trk","",nbins,low,high);
nt_particle->Draw("matchedpt>>h_matched_pt_particle","");
nt_track->Draw("pt>>h_matched_pt_trk","(trkfake!=1)");
h_matched_pt_trk->SetMarkerColor(kRed);
h_matched_pt_trk->SetLineColor(kRed);
h_matched_pt_particle->SetMarkerStyle(25);

TCanvas *c5 = new TCanvas("c5","",600,800);
makeMultiPanelCanvas(c5,1,2,0.0,0.0,0.15,0.15,0.02);

c5->cd(1);
c5->cd(1)->SetLogx();
c5->cd(1)->SetLogy();
h_matched_pt_trk->Draw();
h_matched_pt_particle->Draw("same");
c5->cd(2); 
c5->cd(2)->SetLogx();
TH1D * h_reco_gen_trk=(TH1D*)h_matched_pt_trk->Clone("h_reco_gen_trk");
h_reco_gen_trk->Divide(h_matched_pt_particle);
h_reco_gen_trk->GetYaxis()->SetTitle("N_{reco,select}/N_{gen,matched,select}");
h_reco_gen_trk->SetMaximum(1.1);
h_reco_gen_trk->SetMinimum(0.85);
h_reco_gen_trk->Draw();
c5->SaveAs("compare_matchedpt_recopt.png");
*/
}
예제 #28
0
void DrawUnfoldingClosure_Etabin(){


c1 = new TCanvas("c1"," ",1200,600);
makeMultiPanelCanvas(c1,4,2,0,0,0.25,0.2,0.03);
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    gStyle->SetErrorX(0);   
   /* TCanvas *c1 = new TCanvas("c1a", "c1",0,0,1000,600);
    c1->Range(0,0,1,1);
    c1->SetFillColor(0);
    c1->SetBorderMode(0);
    c1->SetBorderSize(2);
    c1->SetTickx(1);
    c1->SetTicky(1);
    c1->SetLeftMargin(0.13);
    c1->SetRightMargin(0.06);
    c1->SetTopMargin(0.05);
    c1->SetBottomMargin(0.12);
    c1->SetFrameFillStyle(0);
    c1->SetFrameBorderMode(0);

    gStyle->SetOptStat(0);
    gStyle->SetPadBottomMargin(0.12);
    gStyle->SetPadTopMargin   (0.025);
    gStyle->SetPadLeftMargin  (0.15);
    gStyle->SetPadRightMargin (0.025);
    gStyle->SetPadTickX       (1);
    gStyle->SetPadTickY       (1);*/
//const double binbound_pt[]={ 3, 4, 5, 7, 9, 12, 15, 18, 22, 27, 33, 39, 47, 55, 64,74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 362, 429, 692, 1000};
//TFile *fout = new TFile("Ratio_Unfolded_Gen.root","recreate");
TH1F* hFrame=new TH1F("","",1000,0,1000);
hFrame->GetYaxis()->SetRangeUser(0.51,1.49);
fixedFontHist(hFrame,1.3,1.8);
hFrame->GetYaxis()->SetTitleSize(0.06);
hFrame->GetYaxis()->SetLabelSize(0.07);
hFrame->GetXaxis()->SetTitleSize(0.06);
hFrame->GetXaxis()->SetLabelSize(0.07);
hFrame->GetXaxis()->SetNdivisions(505);

TLatex *com0 = new TLatex(0.1,0.92,"PYTHIA+HIJING");
//TLatex *com0 = new TLatex(0.1,0.92,"HIJING+PYTHIA");
com0->SetTextFont(63);
com0->SetTextSize(15);
com0->SetNDC();
TLatex *com2 = new TLatex(0.5,0.32,"CMS simulation");
com2->SetTextFont(63);
com2->SetTextSize(15);
com2->SetNDC();
TLatex *com3 = new TLatex(0.1,0.24,"Anti-k_{T} Particle Flow Jets: R=0.3");
com3->SetTextFont(63);
com3->SetTextSize(15);
com3->SetNDC();

TLatex *T = new TLatex();
T->SetTextFont(42);
T->SetTextSize(0.06);
T->SetNDC();

TLine *l=new TLine(47.5,1,hFrame->GetXaxis()->GetXmax(),1);
l->SetLineStyle(2);

TFile *f[Neta];
TFile *f1[Neta];
TH1D *hBay[Neta]; TH1F *hGen_PPb[Neta]; TH1F* hBay_Cl[Neta];TH1F* hGen[Neta];
TLegend* leg=new TLegend(0.3,0.05,0.48,0.35);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetTextSize(0.06);
//ofstream fstr[N];
TH1D* hBay[Neta];	TH1F* hMeas[Neta];	TH1F* hBin[Neta];
for(int i=0;i<Neta;i++){
c1->cd(canvas[i]+1);
if(i==0  || i==6){
hFrame->GetYaxis()->SetTitle("Reco / Truth");
hFrame->GetXaxis()->SetNdivisions(510);
hFrame->GetXaxis()->SetLimits(47.5,299);
}
else{
hFrame->GetXaxis()->SetNdivisions(505);
hFrame->GetYaxis()->SetTitle("");
if(i==1 || i==5)
hFrame->GetXaxis()->SetLimits(47.5,360);
else if(i==2 || i==4)
hFrame->GetXaxis()->SetLimits(47.5,420);
else
hFrame->GetXaxis()->SetLimits(47.5,455);
}
if(i>=4)
hFrame->GetXaxis()->SetTitle("p_{T}^{jet} (GeV/c)");
else
hFrame->GetXaxis()->SetTitle("");

hFrame->DrawCopy();
//fstr[i]<<setprecision(4)<<fixed;
//fstr[i].open(Form("jetUnfsys%s.txt",etabinname[i].Data()));

f[i] = TFile::Open(Form("/scratch/xuq7/RpA/UnfoldedOutputs/PPb_UnfoPriorGen_akPu3PFKurtMCNoIDCut_MC_jtpt20_EtaBin%s_Inc_v8.root",etabinnameswap[i].Data()));
//f1[i] = TFile::Open(Form("/home/xuq7/HI/RpA/output/UnfoldedOutputs/PbP_UnfoPriorGen_akPu3PFKurtMCNoIDCut_MCJECv17_jtpt20_GenEtaBin%s_Inc_v17.root",etabinname[i].Data()));
//f[i] = TFile::Open(Form("/scratch/xuq7/RpA/UnfoldedOutputs/PbP_UnfoPriorGen_akPu3PFKurtMCNoIDCut_MCJECv17_jtpt20_EtaBin%s_Inc_v17.root",etabinname[i].Data()));
hBay[i] = (TH1D*)f[i]->Get("hRecoScaled_Cent0");
//hBay[i] = (TH1D*)f[i]->Get("hReco0");
hMeas[i] = (TH1F*)f[i]->Get("hMeasScaled_Cent0");
hBin[i] = (TH1F*)f[i]->Get("hRecoBinByBinScaled_Cent0");
//hGen[i] = (TH1F*)f1[i]->Get("hGen0");

hMeas[i]->SetMarkerStyle(20);
hMeas[i]->SetLineColor(2);
hMeas[i]->SetMarkerColor(2);
hMeas[i]->SetMarkerSize(1.2);

hBay[i]->SetMarkerStyle(25);
hBay[i]->SetLineColor(1);
hBay[i]->SetMarkerColor(1);
hBay[i]->SetMarkerSize(1.2);

hBin[i]->SetMarkerStyle(28);
hBin[i]->SetLineColor(4);
hBin[i]->SetMarkerColor(4);
hBin[i]->SetMarkerSize(1.2);
/*
fout->cd();
hBay[i]->Divide(hGen[i]);
hBay[i]->SetName(Form("Ratio_UnfoldedGen_%s",etabinname[i].Data()));
hBay[i]->Write();
*/
hMeas[i]->DrawCopy("same");
hBay[i]->DrawCopy("same");
hBin[i]->DrawCopy("same");
/*for(int ibin=1;ibin<=hBay_Cl[i]->GetNbinsX();ibin++){
if(hBay_Cl[i]->GetBinCenter(ibin)>50 && hBay_Cl[i]->GetBinCenter(ibin)<600){
fstr[i]<<hBay_Cl[i]->GetBinCenter(ibin)<<'\t';
//fstr[i]<<hBay_Cl[i]->GetXaxis()->GetBinLowEdge(ibin)<<"to"<<hBay_Cl[i]->GetXaxis()->GetBinUpEdge(ibin)<<'\t';
fstr[i]<<100*TMath::Abs((hBay_Cl[i]->GetBinContent(ibin)-1))<<endl;
}
}
*/

if(i==0){
leg->AddEntry(hBay[i],"Bayesian","lp");
leg->AddEntry(hBin[i],"Bin-by-bin","lp");
leg->AddEntry(hMeas[i],"no unfolding","lp");
leg->Draw("same");
}
T->DrawLatex(0.5,0.82,etastring[i]);

l->Draw("same");

}
//for(int i=0;i<N-1;i++) 	hBay_Cl[i]->DrawCopy("same");
com0->Draw();
com2->Draw();
com3->Draw();
//c1->Print(Form("PbPUnfoldingClosure_Etabin.pdf"));
c1->Print(Form("PPbUnfoldingClosure_Etabin.pdf"));
}
예제 #29
0
파일: overlayDataMC.C 프로젝트: XuQiao/HI
void overlayDataMC(){
int ilist=atoi(getenv("LIST"));
TString JetIDNameList[18]={"chMax", "chSum", "neuMax", "neuSum", "phoMax", "phoSum", "chMaxpt", "chSumpt", "neuMaxpt", "neuSumpt", "phoMaxpt", "phoSumpt","SumSumpt","SumSumrawpt","neuMaxr","chN","neuN","phoN"};
const double binbound_pt[]={ 3, 4, 5, 7, 9, 12, 15, 18, 22, 27, 33, 39, 47, 55, 64,74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 429, 692, 1000};
int Nbin_pt=sizeof(binbound_pt)/sizeof(double)-1;
double xrange_pt[2]={30+1e-4,600-1e-4};
TString JetID, Unit;
TString JetIDName = JetIDNameList[ilist];

gStyle->SetOptStat(kFALSE);
gStyle->SetErrorX(0);
if(ilist== 0)   JetID = "Max p_{T}^{charged}";
else if(ilist== 1)      JetID = "#Sigma p_{T}^{charged}";
else if(ilist== 2)      JetID = "Max p_{T}^{neutral}";
else if(ilist== 3) JetID = "#Sigma p_{T}^{neutral}";
else if(ilist== 4) JetID = "Max p_{T}^{photon}";
else if(ilist== 5) JetID = "#Sigma p_{T}^{photon}";
else if(ilist== 6)      JetID = "Max p_{T}^{charged}/p_{T}^{jet}";
else if(ilist== 7)      JetID = "#Sigma p_{T}^{charged}/p_{T}^{jet}";
else if(ilist== 8)      JetID = "Max p_{T}^{neutral}/p_{T}^{jet}";
else if(ilist== 9)      JetID = "#Sigma p_{T}^{neutral}/p_{T}^{jet}";
else if(ilist== 10)     JetID = "Max p_{T}^{photon}/p_{T}^{jet}";
else if(ilist== 11)     JetID = "#Sigma p_{T}^{photon}/p_{T}^{jet}";
else if(ilist== 12)     JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photon} +#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{jet}";
else if(ilist== 13)     JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photon} +#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{raw}";
else if(ilist== 14)     JetID = "Max /(Max p_{T}^{neutral}+Max p_{T}^{charged}+Max p_{T}^{photon})";
else if(ilist== 15)     JetID = "charged Multiplicity";
else if(ilist== 16)     JetID = "neutral Multiplicity";
else if(ilist== 17)     JetID = "photon Multiplicity";
else{   exit();}

if(JetIDName.Contains("pt") || JetIDName=="neuMaxr"){
if(ilist==12 || ilist==13){
double binbound_JetID[]={0,0.2,0.4,0.6,0.7,0.8,0.84,0.86,0.88,0.9,0.92,0.94,0.96,0.98,1.0,1.02,1.04,1.06,1.1,1.15,1.2,1.3,1.4,1.6,1.8,2.};}
else if(ilist==6){
double binbound_JetID[]={0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,1.};}
else{
double binbound_JetID[]={0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.};}
Unit="";
}
else if(JetIDName.Contains("N")){
if(ilist==17){
double binbound_JetID[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,30};}
else if(ilist==16){
double binbound_JetID[]={0,1,2,3,4,5,6,7,8,10};}
else if(ilist==15){
double binbound_JetID[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,24,30,40};}
Unit="";
}
else{
//double binbound_JetID[]={0,15,30,45,60,75,90,105,120,135,150,165,180,195,210,225,240,255,270,285,300};
double binbound_JetID[]={0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200};
Unit="(GeV/c)";
}
int Nbin_JetID=sizeof(binbound_JetID)/sizeof(double)-1;

TString filename="/scratch/xuq7/RpA/TreeAna/Datacombined.root";
TString PPbfilename="/scratch/xuq7/RpA/TreeAna/MCPPbakPu3PF.root";

TString histoname=Form("jetpt%sCombinedSpectra",JetIDName.Data());
TString PPbhistoname=Form("jetpt%s",JetIDName.Data());

TFile *file=TFile::Open(filename);
TFile *PPbfile=TFile::Open(PPbfilename);

TH2F* hdata2F=(TH2F*)file->Get(histoname);
TH2F* hPPb2F=(TH2F*)PPbfile->Get(PPbhistoname);

TH1D* hdata=(TH1D*)hdata2F->ProjectionY("hdata",hdata2F->GetXaxis()->FindBin(xrange_pt[0]),hdata2F->GetXaxis()->FindBin(xrange_pt[1]));
TH1D* hPPb=(TH1D*)hPPb2F->ProjectionY("hPPb",hPPb2F->GetXaxis()->FindBin(xrange_pt[0]),hPPb2F->GetXaxis()->FindBin(xrange_pt[1]));

rehdata=(TH1D*)hdata->Clone("rehdata");
rehPPb=(TH1D*)hPPb->Clone("rehPPb");
rehdata=(TH1D*)hdata->Rebin(Nbin_JetID,"rehdata",binbound_JetID);
rehPPb=(TH1D*)hPPb->Rebin(Nbin_JetID,"rehPPb",binbound_JetID);
normalizeByBinWidth(rehdata);
normalizeByBinWidth(rehPPb);
rehdata->Scale(1./rehdata->Integral(rehdata->FindBin(binbound_JetID[0]),rehdata->FindBin(binbound_JetID[Nbin_JetID])));
rehPPb->Scale(1./rehPPb->Integral(rehPPb->FindBin(binbound_JetID[0]),rehPPb->FindBin(binbound_JetID[Nbin_JetID])));
rehdata->SetMarkerStyle(20);
rehdata->SetMarkerColor(1);
rehdata->SetLineColor(1);
rehdata->SetMarkerSize(1.2);
rehdata->GetYaxis()->SetTitle("Event Fraction");
rehPPb->SetMarkerStyle(0);
rehPPb->SetFillStyle(3004);
rehPPb->SetFillColor(2);
rehPPb->SetLineColor(2);
fixedFontHist(rehdata,1.8,2.6);
fixedFontHist(rehPPb,1.8,2.6);

c1 = new TCanvas("c1","",400,700);
makeMultiPanelCanvas(c1,1,2,-0.12,0,0.18,0.16,0.05);

c1->cd(1)->SetLogy();
rehdata->GetXaxis()->SetTitle(JetID.Data());
rehdata->GetXaxis()->SetRangeUser(binbound_JetID[0],binbound_JetID[Nbin_JetID]);
//if(ilist==12 || ilist==13) 
//rehdata->GetXaxis()->SetRangeUser(0.8,1.2);
rehdata->SetMinimum(TMath::Min(rehdata->GetMinimum(),rehPPb->GetMinimum())/3);
rehdata->SetMaximum(1.5);
rehdata->SetTitle("");
rehdata->Draw("E1");
rehPPb->Draw("HIST E1same");
TLegend *leg1=new TLegend(0.60,0.70,0.80,0.85);
leg1->SetBorderSize(0);
leg1->SetFillColor(0);
leg1->SetTextSize(0.05);
leg1->AddEntry(rehdata,"Data","lpf");
leg1->AddEntry(rehPPb,"PYTHIA+HIJING","lpf");
leg1->Draw("same");
TLatex *T=new TLatex();
T->SetNDC();
T->SetTextAlign(12);
T->SetTextSize(0.05);
T->SetTextColor(1);
T->SetTextFont(42);
T->DrawLatex(0.40,0.90,Form("p_{T}^{jet}: %.f-%.f (GeV/c)",xrange_pt[0],xrange_pt[1]));
T->DrawLatex(0.40,0.20,Form("|#eta < 1|"));
c1->cd(2);
TH1D* ratio=(TH1D*)rehdata->Clone("ratio");
ratio->Divide(rehPPb);
ratio->SetMarkerStyle(20);
ratio->SetMarkerSize(1.2);
ratio->SetMarkerColor(1);
ratio->SetMinimum(0);
ratio->SetMaximum(1.9);
ratio->SetTitle("");
ratio->GetYaxis()->SetTitle("Data/MC");
ratio->Draw("E1");
TLine *l =new TLine(binbound_JetID[0],1,binbound_JetID[Nbin_JetID],1);
l->SetLineStyle(2);
l->SetLineColor(1);
l->Draw("same");

c1->Print(Form("/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/TreeAna/JetID/pic/%s/overlay_DataMC.png",JetIDName.Data()));

}
void drawclosureffgamma() {
  const int yaxismax = 4;
  const int yaxismax2 = 3;
  TFile *_file0 = TFile::Open("closure.root");
  int save = 1;
  const static int ncentbins = 5;
  float binwidth = 5.000000e-01;
  int centmins[] = {0,20,60,100,140};
  int centmaxs[] = {20,60,100,140,200};
  string cents[] = {"0-10%","10-30%","30-50%","50-70%","70-100%"};
  TCanvas * c1_pbpbmc_gen[ncentbins]; // ncentbins
  TH1D * hgammaffxi_pbpbmc_gen_[ncentbins];
  TH1D * hjetpt_pbpbmc_gen_[ncentbins];
  TH1D * hgammaffxi_refcone_pbpbmc_gen_[ncentbins];
  float njets_pbpbmc_gen[ncentbins];

  TCanvas * c1_pbpbmc[ncentbins];
  TH1D * hgammaffxi_pbpbmc_[ncentbins];
  TH1D * hjetpt_pbpbmc_[ncentbins];
  TH1D * hgammaffxi_refcone_pbpbmc_[ncentbins];
  float njets_pbpbmc[ncentbins];

  TCanvas * c1_subpbpb[ncentbins];
  TH2D * dummy_pbpbsub[ncentbins];
  TH2D * dummy2_pbpbsub[ncentbins];
  TH1D * clone_hgammaffxi_refcone_pbpbmc_gen_[ncentbins];
  TH1D * clone_hgammaffxi_pbpbmc_gen_[ncentbins];
  TH1D * clone_hgammaffxi_refcone_pbpbmc_[ncentbins];
  TH1D * clone_hgammaffxi_pbpbmc_[ncentbins];
  TH2D * clone2_hgammaffxi_pbpbmc_gen_[ncentbins];
  TH2D * clone2_hgammaffxi_pbpbmc_[ncentbins];
  TLegend * leg_ff_pbpbsub[ncentbins];
  TLegend * leg_ff_pbpbsub2[ncentbins];

  TCanvas * call = new TCanvas("call","",1600,500);
  // makeMultiPanelCanvas(call,5,1,0,0,0.2,0.2,0.04);
  makeMultiPanelCanvas(call,6,1,0.02,0.0,-6,0.2,0.04);
  for (int icent = 0; icent < 5; icent++) {
    // Raw FF pbpdata
    hgammaffxi_pbpbmc_gen_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent]));
    hjetpt_pbpbmc_gen_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent]));
    hgammaffxi_refcone_pbpbmc_gen_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent]));
    njets_pbpbmc_gen[icent] = hjetpt_pbpbmc_gen_[icent]->Integral();
    hgammaffxi_pbpbmc_gen_[icent]->Sumw2();
    hgammaffxi_refcone_pbpbmc_gen_[icent]->Sumw2();
    hgammaffxi_pbpbmc_gen_[icent]->Scale(1.0/njets_pbpbmc_gen[icent]/binwidth);
    hgammaffxi_refcone_pbpbmc_gen_[icent]->Scale(1.0/njets_pbpbmc_gen[icent]/binwidth);
    hgammaffxi_pbpbmc_gen_[icent]->GetXaxis()->CenterTitle();
    hgammaffxi_pbpbmc_gen_[icent]->SetYTitle("dN/d#xi");
    hgammaffxi_pbpbmc_gen_[icent]->GetYaxis()->CenterTitle();
    hgammaffxi_refcone_pbpbmc_gen_[icent]->SetMarkerStyle(24);
    // Raw FF pbpdata


    // Raw FF pbmc
    hgammaffxi_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent]));
    hjetpt_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbmc__%d_%d",centmins[icent],centmaxs[icent]));
    hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent]));
    njets_pbpbmc[icent] = hjetpt_pbpbmc_[icent]->Integral();
    hgammaffxi_pbpbmc_[icent]->Sumw2();
    hgammaffxi_refcone_pbpbmc_[icent]->Sumw2();
    hgammaffxi_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth);
    hgammaffxi_refcone_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth);
    hgammaffxi_pbpbmc_[icent]->GetXaxis()->CenterTitle();
    hgammaffxi_pbpbmc_[icent]->SetYTitle("dN/d#xi");
    hgammaffxi_pbpbmc_[icent]->GetYaxis()->CenterTitle();
    hgammaffxi_refcone_pbpbmc_[icent]->SetMarkerStyle(24);
    // Raw FF pbpbmc


    // Eta cone subtracted FF pbpbmc_gen and pbpbmc
    call->cd(icent+2);
    dummy_pbpbsub[icent] = new TH2D(Form("dummy_pbpbsub_%d_%d",centmins[icent],centmaxs[icent]),";#xi;dN/d#xi",1,0.01,4.99,1,0,yaxismax);
    dummy_pbpbsub[icent]->GetXaxis()->SetTitleOffset(0.8);
    dummy_pbpbsub[icent]->GetXaxis()->CenterTitle();
    dummy_pbpbsub[icent]->GetYaxis()->CenterTitle();
    dummy_pbpbsub[icent]->GetXaxis()->SetTitleSize(dummy_pbpbsub[icent]->GetXaxis()->GetTitleSize()*1.4);

    clone_hgammaffxi_refcone_pbpbmc_gen_[icent] = (TH1D*) hgammaffxi_refcone_pbpbmc_gen_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent]));
    clone_hgammaffxi_refcone_pbpbmc_gen_[icent]->Scale(-1);
    clone_hgammaffxi_pbpbmc_gen_[icent] = (TH1D*) hgammaffxi_pbpbmc_gen_[icent]->Clone(Form("clone_hgammaffxi_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent]));
    // clone_hgammaffxi_pbpbmc_gen_[icent]->Add(clone_hgammaffxi_refcone_pbpbmc_gen_[icent]); // no longer needed when using sube == 0

    clone_hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) hgammaffxi_refcone_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent]));
    clone_hgammaffxi_refcone_pbpbmc_[icent]->Scale(-1);
    clone_hgammaffxi_pbpbmc_[icent] = (TH1D*) hgammaffxi_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent]));
    clone_hgammaffxi_pbpbmc_[icent]->Add(clone_hgammaffxi_refcone_pbpbmc_[icent]);
    clone_hgammaffxi_pbpbmc_[icent]->SetMarkerColor(kRed);
    clone_hgammaffxi_pbpbmc_gen_[icent]->SetMarkerColor(kBlue);
    // fixedFontHist(dummy_pbpbsub[icent]);
    dummy_pbpbsub[icent]->Draw();
    clone_hgammaffxi_pbpbmc_gen_[icent]->Draw("same");
    // hgammaffxi_pbpbmc_[icent]->Draw("same");
    // hgammaffxi_refcone_pbpbmc_[icent]->Draw("same");
    clone_hgammaffxi_pbpbmc_[icent]->Draw("same");
    if(icent==0)
    {
      leg_ff_pbpbsub[icent] = new TLegend(0.03,0.697,0.3,0.92);
    }
    else
    {
      leg_ff_pbpbsub[icent] = new TLegend(0,0.697,0.27,0.92);
    }
    leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.3);
    leg_ff_pbpbsub[icent]->SetFillColor(0);
    leg_ff_pbpbsub[icent]->SetFillStyle(0);
    leg_ff_pbpbsub[icent]->SetTextFont(42);
    if(icent==0)
    {
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_gen_[icent],"gen jet p_{T} ff","p");
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"reco jet p_{T} ff","p");
    }
    else if(icent==1)
    {
      // leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"#eta cone sub","");
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"trk p_{T}>1 GeV, R < 0.3","");
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"100>#gamma p_{T}>300 GeV","");
    }
    else if(icent==2)
    {
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"0.3 < |#eta^{jet}| < 1.6","");
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"p_{T}^{jet} > 40 GeV","");
    }
    else
    {
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"","");
      leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"","");
    }
    leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],Form("%s",cents[icent].data()),"");
    leg_ff_pbpbsub[icent]->Draw();
    // c1_subpbpb[icent]->SaveAs("pbpbmc_gen_pbpbmc_etaconesubtracted_45_gamma_100.png");
    // Eta cone subtracted FF pbpbmc_gen and pbpbmc

  }
  call->cd(1);

  TH2D * axis_dummy = new TH2D("axis_dummy","",1,0.01,4.99,1,0,yaxismax);
  gStyle->SetFrameLineColor(0);
  axis_dummy->UseCurrentStyle();
  axis_dummy->Draw("FB BB A");

  TLatex * ldndxi = new TLatex(0.4,0.5,"dN/d#xi");
  ldndxi->SetTextSize(ldndxi->GetTextSize()*1.2);
  ldndxi->SetNDC();
  ldndxi->SetTextAngle(90);

  TLatex * laxis[yaxismax];
  for (int ilatex = 0; ilatex < yaxismax; ilatex++) {
    laxis[ilatex] = new TLatex(3.,ilatex-0.1,Form("%d",ilatex));
    laxis[ilatex]->SetTextSize(laxis[ilatex]->GetTextSize()*1.2);
    laxis[ilatex]->Draw();
  }
  ldndxi->Draw();

  TCanvas * callratio = new TCanvas("callratio","",1600,500);
  makeMultiPanelCanvas(callratio,6,1,0.02,0.0,-6,0.2,0.04);
  for (int icent = 0; icent < 5; icent++) {
    callratio->cd(icent+2);
    clone2_hgammaffxi_pbpbmc_gen_[icent] = (TH2D*) clone_hgammaffxi_pbpbmc_gen_[icent]->Clone(Form("clone2_hgammaffxi_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent]));
    clone2_hgammaffxi_pbpbmc_[icent] = (TH2D*) clone_hgammaffxi_pbpbmc_[icent]->Clone(Form("clone2_hgammaffxi_pbpbmc_%d_%d",centmins[icent],centmaxs[icent]));
    clone2_hgammaffxi_pbpbmc_gen_[icent]->Divide(clone2_hgammaffxi_pbpbmc_[icent]);

    dummy2_pbpbsub[icent] = new TH2D(Form("dummy2_pbpbsub_%d_%d",centmins[icent],centmaxs[icent]),";#xi;dN/d#xi",1,0.01,4.99,1,0,yaxismax2);
    dummy2_pbpbsub[icent]->GetXaxis()->SetTitleOffset(0.8);
    dummy2_pbpbsub[icent]->GetXaxis()->CenterTitle();
    dummy2_pbpbsub[icent]->GetYaxis()->CenterTitle();
    dummy2_pbpbsub[icent]->GetXaxis()->SetTitleSize(dummy2_pbpbsub[icent]->GetXaxis()->GetTitleSize()*1.4);
    dummy2_pbpbsub[icent]->Draw();
    // clone2_hgammaffxi_pbpbmc_gen_[icent]->SetMarkerColor(kViolet);
    clone2_hgammaffxi_pbpbmc_gen_[icent]->SetMarkerColor(kBlack);
    clone2_hgammaffxi_pbpbmc_gen_[icent]->Draw("same");
    TLine * lone = new TLine(0,1,5,1);
    lone->SetLineStyle(9);
    lone->Draw();

    if(icent==0)
    {
      leg_ff_pbpbsub2[icent] = new TLegend(0.03,0.697,0.3,0.92);
    }
    else
    {
      leg_ff_pbpbsub2[icent] = new TLegend(0,0.697,0.27,0.92);
    }
    leg_ff_pbpbsub2[icent]->SetTextSize(0.05*1.3);
    leg_ff_pbpbsub2[icent]->SetFillColor(0);
    leg_ff_pbpbsub2[icent]->SetFillStyle(0);
    leg_ff_pbpbsub2[icent]->SetTextFont(42);
    if(icent==0)
    {
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"gen jet p_{T}/reco jet p_{T} ff","p");
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"","");
    }
    else if(icent==1)
    {
      // leg_ff_pbpbsub2[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"#eta cone sub","");
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"trk p_{T}>1 GeV, R < 0.3","");
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"100>#gamma p_{T}>300 GeV","");
    }
    else if(icent==2)
    {
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"0.3 < |#eta^{jet}| < 1.6","");
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"p_{T}^{jet} > 40 GeV","");
    }
    else
    {
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"","");
      leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"","");
    }
    leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],Form("%s",cents[icent].data()),"");
    leg_ff_pbpbsub2[icent]->Draw();

  }
  callratio->cd(1);

  TH2D * axis_dummy_ratio = new TH2D("axis_dummy_ratio","",1,0.01,4.99,1,0,yaxismax2);
  gStyle->SetFrameLineColor(0);
  axis_dummy_ratio->UseCurrentStyle();
  axis_dummy_ratio->Draw("FB BB A");

  TLatex * ldndxi2 = new TLatex(0.4,0.4,"dN/d#xi Gen/Reco");
  ldndxi2->SetTextSize(ldndxi2->GetTextSize()*1.2);
  ldndxi2->SetNDC();
  ldndxi2->SetTextAngle(90);

  TLatex * laxis2[yaxismax2];
  for (int ilatex = 0; ilatex < yaxismax2; ilatex++) {
    laxis2[ilatex] = new TLatex(3.,ilatex-0.1,Form("%d",ilatex));
    laxis2[ilatex]->SetTextSize(laxis2[ilatex]->GetTextSize()*1.2);
    laxis2[ilatex]->Draw();
  }
  ldndxi2->Draw();


}