コード例 #1
0
ファイル: driftITSTPC.C プロジェクト: alisw/AliRoot
void Init(){

  gSystem->Load("libSTAT");
  TStatToolkit toolkit;
  Double_t chi2;
  TVectorD fitParam, fitParam1,fitParam2;
  TVectorD errParam, errParam1,errParam2;
  TMatrixD covMatrix,covMatrix1,covMatrix2;
  
  Int_t npoints;
  //
  TFile f("driftitsTPC.root");
  TTree * tree = (TTree*)f.Get("Test");
  tree->SetAlias("side","(-1+(pTPC.fP[1]>0)*2)");     //side
  tree->SetAlias("z","(pTPC.fP[1]+0.0)");     //z position
  tree->SetAlias("dr","(1-abs(pTPC.fP[1])/250.)");    //norm drift length
  tree->SetAlias("tl","(pTPC.fP[3]+pITS.fP[3])*0.5"); //tan lampbda
  tree->SetAlias("sa","sin(pTPC.fAlpha+0.)");         //sin alpha
  tree->SetAlias("ca","cos(pTPC.fAlpha+0.)");         //cos alpha
  
  tree->SetAlias("dz","(pTPC.fP[1]-pITS.fP[1])");      //z delta
  tree->SetAlias("dy","(pTPC.fP[0]-pITS.fP[0])");      //z delta
  tree->SetAlias("dtl","(pTPC.fP[3]-pITS.fP[3])");     //delta tan lampbda
  tree->SetAlias("etl","sqrt(pITS.fC[9]+0.)");         //error tan lampbda
  tree->SetAlias("ez","sqrt(pITS.fC[2]+0.)");          //error z
}
コード例 #2
0
ファイル: leadFrag.C プロジェクト: CmsHI/CVS_SavedFMa
void leadFrag(char *infname = "dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0.root",
    TCut myCut = "cent<30",
    TString module="djcalo_tower")
{
   TFile *inf = new TFile(infname);
   TTree *t = (TTree*)inf->Get(module+"/djTree");

   const int nBin = 5;
   double bins[nBin+1] = {0.5,1.5,4,8,20,1000};  
   double colors[nBin] = {kGray,kBlue-3,38,kOrange-8,kRed-6};

   // Selection cut
   TCut evtCut = "nljet>120&&abs(nljeta)<2&&aljet>50&&abs(aljeta)<2&&jdphi>2./3*TMath::Pi()";
   t->SetAlias("Aj","(nljet-aljet)/(nljet+aljet)");

   // histograms
   TH2D * hFrag_LJEt = new TH2D("hFrag_LJEt",";p_{T}^{J1};p_{T}^{Tower}/p_{T}^{J1}",50,120,300,50,0,1);
   hFrag_LJEt->GetXaxis()->CenterTitle();
   hFrag_LJEt->GetYaxis()->CenterTitle();
   TH2D * hLeadFrag_LJEt = new TH2D("hLeadFrag_LJEt",";p_{T}^{J1};p_{T}^{Highest Tower}/p_{T}^{J1}",50,120,300,50,0,1);
   hLeadFrag_LJEt->GetXaxis()->CenterTitle();
   hLeadFrag_LJEt->GetYaxis()->CenterTitle();

   // project tree
   t->Project("hLeadFrag_LJEt","lppt[0]/nljet:nljet",evtCut);
   t->Project("hFrag_LJEt","ppt/nljet:nljet",evtCut);


   // plot
   TCanvas *c2 = new TCanvas("c2","",600,600);
   c2->SetRightMargin(0.15);
   c2->SetLogz();
   hFrag_LJEt->Draw("colz");

   TCanvas *c3 = new TCanvas("c3","",600,600);
   c3->SetRightMargin(0.15);
   c3->SetLogz();
   hLeadFrag_LJEt->Draw("colz");

   TCanvas *c4 = new TCanvas("c4","",600,600);
   hLeadFrag_LJEt->ProfileX()->Draw("E");
   TH1D * hLeadFrag_LJEt_pfx = (TH1D*)gDirectory->Get("hLeadFrag_LJEt_pfx");
   hLeadFrag_LJEt_pfx->SetAxisRange(0,0.6,"Y");
   hFrag_LJEt->ProfileX()->Draw("same hist");
   TH1D * hFrag_LJEt_pfx = (TH1D*)gDirectory->Get("hFrag_LJEt_pfx");
}
コード例 #3
0
ファイル: runalias.C プロジェクト: asmagina1995/roottest
//________________________________________________________________________
void draw_tree()
{
   TFile* file = TFile::Open("example.root");
   // create a TTree   
   TTree *tree = (TTree*)file->Get("tree");
   
   tree->SetAlias("mult", "fOffset*fX.fElements");
   
   TCanvas* c1 = new TCanvas("c1");
   c1->Divide(2,3);
   c1->cd(1);
   tree->Draw("fOffset*fX.fElements");
   
   c1->cd(2);
   tree->Draw("mult");
   
   PlotAndCheck(tree,c1,3,"fX.fElements > 1.0");
   PlotAndCheck(tree,c1,5,"fY.fElements > 1.0");
   
}
コード例 #4
0
void balanceMetVsAj(TString infname = "dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0_120_50.root",
                    TCut myCut = "cent<30", char *title = "",bool drawLegend = false,
                    bool drawSys = true
		    )
{
   // ===========================================================
   // Get Input
   // ===========================================================
   TFile *inf = new TFile(infname);
   TTree *t = (TTree*)inf->Get("ntjt");


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

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

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

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

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

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

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

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

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

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

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

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

   if (drawLegend) leg->Draw();

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


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

   TText *titleText = new TText(0.3,30,title);
   titleText->Draw();
}
コード例 #5
0
ファイル: plotRBDphi.C プロジェクト: mandrenguyen/usercode
void plotRBDphi( 
		double dphiCut=3.026,
		// double dphiCut=2.094,
	      double dphiCut2 = 3.026,
		 TString infname = "data.root",
		 TString pythia = "pythia.root",
		 TString mix = "mix.root",
		 bool useWeight = true,
		 bool drawXLabel = false,
		 bool drawLeg = true)
{		
  useWeight = 0;

  int threshold1 = 80;
  int threshold2 = 120;
  gStyle->SetErrorX(0); 
  TString cut1=Form("abs(eta1) < 2 && abs(eta2) < 2 && et1>%d&&et2>50",threshold1);
  TString cut2=Form("abs(eta1) < 2 && abs(eta2) < 2 && et1>%d&&et2>50",threshold2);
  cout <<cut1.Data()<<endl;
  cout <<cut2.Data()<<endl;

  TString trigcut = "";
  TString cstring = "";

  // open the data file
  TFile *inf = new TFile(infname.Data());
  TTree *nt =(TTree*)inf->FindObjectAny("nt");

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

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

  // open output
  TFile *outfile = new TFile("output.root","recreate");
  TNtuple *ntOut = new TNtuple("ntOut","","npart");


  nt->SetAlias("et1","pt1");
  nt->SetAlias("et2","pt2");

  ntMix->SetAlias("et1","pt1");
  ntMix->SetAlias("et2","pt2");
  ntPythia->SetAlias("et1","pt1");
  ntPythia->SetAlias("et2","pt2");

  //  ntMix->SetAlias("pt1","et1");
  //  ntMix->SetAlias("pt2","et2");

  //  ntPythia->SetAlias("pt1","et1");
  //  ntPythia->SetAlias("pt2","et2");

  ntPythia->SetAlias("weight","1");
  ntMix->SetAlias("weight","1");

  const int nBin = 6;
  double m[nBin+1] = {-1.5,-0.5,3.5,7.5,11.5,20.5,40.5};
  double npart[nBin] = {2,358.623,232.909,97.9521};
  double npart2[nBin] = {2,358.623,232.909,97.9521};
  
  double npartValue[40];
  npartValue[0] = 393.633;
  npartValue[1] = 368.819;
  npartValue[2] = 343.073;
  npartValue[3] = 317.625;
  npartValue[4] = 292.932;
  npartValue[5] = 271.917;
  npartValue[6] = 249.851;
  npartValue[7] = 230.72;
  npartValue[8] = 212.465;
  npartValue[9] = 194.752;
  npartValue[10] = 178.571;
  npartValue[11] = 163.23;
  npartValue[12] = 149.187;
  npartValue[13] = 136.011;
  npartValue[14] = 123.414;
  npartValue[15] = 111.7;
  npartValue[16] = 100.831;
  npartValue[17] = 90.7831;
  npartValue[18] = 80.9823;
  npartValue[19] = 72.6236;
  npartValue[20] = 64.1508;
  npartValue[21] = 56.6284;
  npartValue[22] = 49.9984;
  npartValue[23] = 43.3034;
  npartValue[24] = 37.8437;
  npartValue[25] = 32.6659;
  npartValue[26] = 27.83;
  npartValue[27] = 23.7892;
  npartValue[28] = 20.1745;
  npartValue[29] = 16.8453;
  npartValue[30] = 14.0322;
  npartValue[31] = 11.602;
  npartValue[32] = 9.52528;
  npartValue[33] = 7.6984;
  npartValue[34] = 6.446;
  npartValue[35] = 4.96683;
  npartValue[36] = 4.23649;
  npartValue[37] = 3.50147;
  npartValue[38] = 3.16107;
  npartValue[39] = 2.7877;

  TH1D *hTmp = new TH1D("hTmp","",100,-10,400);
  TH1D *h = new TH1D("h","",nBin,m);
  TH1D *hCut = new TH1D("hCut","",nBin,m);
  TH1D *h2 = new TH1D("h2","",nBin,m);
  TH1D *h2Cut = new TH1D("h2Cut","",nBin,m);

  TH1D *hStat = new TH1D("hStat","",nBin,m);
  TH1D *hNpartSum = new TH1D("hNpartSum","",nBin,m);
  TH1D *hStat2 = new TH1D("hStat2","",nBin,m);
  TH1D *hNpartSum2 = new TH1D("hNpartSum2","",nBin,m);


  Float_t bin=0;
  Float_t et1=0;
  nt->SetBranchAddress("bin",&bin);
  nt->SetBranchAddress("pt1",&et1);
  
  for (int i=0;i<nt->GetEntries();i++)
  {
     nt->GetEntry(i);
     if (et1<threshold1) continue;
     
     if (et1>threshold2) {
        hNpartSum2->Fill(bin,npartValue[(int)bin]);
        hStat2->Fill(bin); 
        if (et1>threshold1) {
        hNpartSum->Fill(bin,npartValue[(int)bin]);
        hStat->Fill(bin); 
	}
     }	 
  }

  hNpartSum->Divide(hStat);
  hNpartSum2->Divide(hStat2);
  
  for (int i=1;i<nBin;i++)
  {
     cout <<hNpartSum->GetBinContent(i+1)<<endl;
     npart[i]=hNpartSum->GetBinContent(i+1);
     cout <<hNpartSum2->GetBinContent(i+1)<<endl;
     npart2[i]=hNpartSum2->GetBinContent(i+1);
     
  }

  nt->Draw("bin>>h",Form("abs(dphi)>%f&&%s",dphiCut,cut1.Data()));
  nt->Draw("bin>>hCut",Form("%s",cut1.Data()));
  TGraphAsymmErrors *g = calcEff(hCut,h,npart);
  g->SetMarkerSize(1.25);

  cout <<cut2.Data()<<endl;
  nt->Draw("bin>>h2",Form("abs(dphi)>%f&&%s",dphiCut2,cut2.Data()));
  nt->Draw("bin>>h2Cut",Form("%s",cut2.Data()));
  TGraphAsymmErrors *g2 = calcEff(h2Cut,h2,npart2);
  g2->SetMarkerSize(1.25);


  ntPythia->Draw("bin>>h",Form("abs(dphi)>%f&&%s",dphiCut2,cut2.Data()));
  ntPythia->Draw("bin>>hCut",Form("%s",cut2.Data()));
  TGraphAsymmErrors *gPythia = calcEffpythia(hCut,h,npart);
  gPythia->SetMarkerSize(1.7);
  
  if(useWeight){
    ntMix->Draw("bin>>h",Form("weight*(abs(dphi)>%f&&%s)",dphiCut2,cut2.Data()));
    ntMix->Draw("bin>>hCut",Form("weight*(%s)",cut2.Data()));
  }else{
    ntMix->Draw("bin>>h",Form("(abs(dphi)>%f&&%s)",dphiCut2,cut2.Data()));
    ntMix->Draw("bin>>hCut",Form("(%s)",cut2.Data()));
  }
  TGraphAsymmErrors *gMix = calcEff(hCut,h,npart);
  gMix->SetMarkerSize(1.25);

  TCanvas *c = new TCanvas("c","",500,500);
  //  hTmp->SetMaximum(g->GetY()[0]*2.2);
  hTmp->SetMaximum(0.85);
  hTmp->SetMinimum(0.);

  hTmp->SetXTitle("N_{part}");
  hTmp->SetYTitle(Form("R_{B}(#Delta#phi_{12} > %.3f)",dphiCut));
  hTmp->GetXaxis()->CenterTitle();
  hTmp->GetYaxis()->CenterTitle();
  //  hTmp->GetYaxis()->SetTitleOffset(1.2);
  //  hTmp->GetYaxis()->SetTitleSize(0.055);
  hTmp->Draw();

  double errorbar = 0.02;
/*
  for(int i = 0; i < g->GetN(); ++i){
    double *x = g->GetX();
    double *y = g->GetY();
//    DrawTick(y[i],0.18*y[i],0.18*y[i],x[i],0.012,8.1,16);
  }
  g->Draw("p same");
  g2->SetMarkerStyle(4);
  */
  for(int i = 0; i < g2->GetN(); ++i){
    double *x = g2->GetX();
    double *y = g2->GetY();
    double err = 1.5*(0.0001129*x[i]);
    err = sqrt(err * err + 0.012*0.012);
    cout <<err/y[i]<<" "<<1.5*(0.0001129*x[i])/y[i]<<" "<<0.012/y[i]<<endl;
    double tickSize = 0.012;
    if (err<tickSize) tickSize=err;
    DrawTick(y[i],err,err,x[i],tickSize,8.1,dataColor);
  }
  gPythia->SetMarkerColor(4);
  gPythia->SetLineColor(4);
  gPythia->SetMarkerStyle(29);

  gMix->SetMarkerColor(4);
  gMix->SetLineColor(4);
  gMix->SetMarkerStyle(25);
  //  gMix->Draw("p same");
  gPythia->Draw("p same");

  g2->SetLineColor(dataColor);
  g2->SetMarkerColor(dataColor);

  g2->Draw("p same");

  TLine* pline = new TLine(0,gPythia->GetY()[0],400,gPythia->GetY()[0]);
  pline->SetLineColor(4);
  pline->SetLineStyle(4);
  pline->Draw();

  if(drawLeg){
    TLegend *t3=new TLegend(0.5,0.77,0.9,0.93); 
    t3->AddEntry(g2,"PbPb  #sqrt{s}_{_{NN}}=2.76 TeV","p");
    //    t3->AddEntry(gPythia,"PYTHIA","p");  
    //    t3->AddEntry(gMix,"PYTHIA+DATA","p");

    //    t3->AddEntry(g,"2011","p");
    //    t3->AddEntry(gMix,"2010","p");
    t3->AddEntry(gPythia,"pp #sqrt{s}=2.76 TeV","p");

    t3->SetFillColor(0);
    t3->SetBorderSize(0);
    t3->SetFillStyle(0);
    t3->SetTextFont(63);
    t3->SetTextSize(15);
    t3->Draw();
  }


  TLatex *cms = new TLatex(0.20,0.88,"CMS Preliminary");
  cms->SetNDC();
  cms->SetTextFont(63);
  cms->SetTextSize(18);
  cms->Draw();                                                                                                                                        
  TLatex tsel;
  tsel.SetNDC();
  tsel.SetTextFont(63);
  tsel.SetTextSize(15);
  tsel.DrawLatex(0.25,0.35,"p_{T,1} > 120 GeV/c");
  tsel.DrawLatex(0.25,0.275,"p_{T,2} > 30 GeV/c");
//  tsel.DrawLatex(0.25,0.20,"#Delta#phi_{12} > #frac{2}{3}#pi rad");

  TLatex *lumi = new TLatex(0.20,0.81,"#intL dt = 6.7 #mub^{-1}");
  lumi->SetNDC();
  lumi->SetTextFont(63);
  lumi->SetTextSize(15);
  lumi->Draw(); 
/*
  TF1 *f = new TF1("f","0.5+[0]*x");
  gMix->Fit("f");
  */
  TCanvas *c2 = new TCanvas("c2","",500,500);

  TGraphAsymmErrors *gRatio = divideGraph(g2,gMix);
  gRatio->Draw("ap");
  gRatio->Fit("pol1");
  //gRatio->Fit("pol0");
  
  c->Print(Form("fig/RB_dphi_%d_vs_Npart.eps",(int)(1000*dphiCut)));
  c->Print(Form("fig/RB_dphi_%d_vs_Npart.C",(int)(1000*dphiCut)));
  c->Print(Form("fig/RB_dphi_%d_vs_Npart.gif",(int)(1000*dphiCut)));
  c->Print(Form("fig/RB_dphi_%d_vs_Npart.pdf",(int)(1000*dphiCut)));


}
コード例 #6
0
void doPostProcessing(TString infname, TString outfile, Int_t events, 
		      Float_t xsec, Float_t kfactor,
		      Float_t filt_eff, bool SortBasketsByEntry = false) {
  
  cout << "Processing File " << infname << endl;
  
  TFile *f = TFile::Open(infname.Data(), "READ");
  if (! f || f->IsZombie()) {
    cout << "File does not exist!" << endl;
    return;
  }
  
  TTree* t = (TTree*)f->Get("Events");
  if (! t || t->IsZombie()) {
    cout << "Tree does not exist!" << endl;
    return;
  }
        
  //-------------------------------------------------------------
  // Removes all non *_CMS2.* branches
  //-------------------------------------------------------------`
  t->SetBranchStatus("*", 0);
  t->SetBranchStatus("*_CMS2.*", 1);

  // Removes the branches (if they exist) that we want to replace
  //evt_xsec_excl
  TString bName = t->GetAlias("evt_xsec_excl");
  //cout << "evt_xsec_excl " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_xsec_incl
  bName = t->GetAlias("evt_xsec_incl");
  //cout << "evt_xsec_incl " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0);   
  }
  
  //evt_kfactor
  bName = t->GetAlias("evt_kfactor");
  //cout << "evt_kfactor " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_nEvts
  bName = t->GetAlias("evt_nEvts");
  //cout << "evt_nEvts " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_filt_eff
  bName = t->GetAlias("evt_filt_eff");
  //cout << "evt_filt_eff " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_scale1fb
  bName = t->GetAlias("evt_scale1fb");
  //cout << "evt_scale1fb " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  TFile *out = TFile::Open(outfile.Data(), "RECREATE");
  TTree *clone;
  if(SortBasketsByEntry)
    clone = t->CloneTree(-1, "fastSortBasketsByEntry");
  else 
    clone = t->CloneTree(-1, "fast");
   

  //-------------------------------------------------------------

  //Calculate scaling factor and put variables into tree 
  Float_t scale1fb = xsec*kfactor*1000*filt_eff/(Float_t)events;
  cout << "scale1fb: " << scale1fb << endl; 

  TBranch* b1 = clone->Branch("evtscale1fb", &scale1fb, "evt_scale1fb/F");
  TBranch* b2 = clone->Branch("evtxsecexcl", &xsec, "evt_xsec_excl/F");
  TBranch* b3 = clone->Branch("evtxsecincl", &xsec, "evt_xsec_incl/F");
  TBranch* b4 = clone->Branch("evtkfactor", &kfactor, "evt_kfactor/F");
  TBranch* b5 = clone->Branch("evtnEvts", &events, "evt_nEvts/I");
  TBranch* b6 = clone->Branch("evtfilteff", &filt_eff, "evt_filt_eff/F");
   
  clone->SetAlias("evt_scale1fb",  "evtscale1fb");
  clone->SetAlias("evt_xsec_excl", "evtxsecexcl");
  clone->SetAlias("evt_xsec_incl",  "evtxsecincl");
  clone->SetAlias("evt_kfactor",   "evtkfactor");
  clone->SetAlias("evt_nEvts",     "evtnEvts");
  clone->SetAlias("evt_filt_eff",     "evtfilteff");

  Int_t nentries = t->GetEntries();
  for(Int_t i = 0; i < nentries; i++) {
    b1->Fill();
    b2->Fill();
    b3->Fill();
    b4->Fill();
    b5->Fill();
    b6->Fill();
  }
  //-------------------------------------------------------------

  clone->Write(); 
  out->Close();
  f->Close();
  return;
  
}
コード例 #7
0
void analyzePuRejection(string var = "etaDijet"){


  TH1::SetDefaultSumw2();


  TString infname = "/d101/yetkin/analysis/d0204/ntuple_data_pPb_akPu3PF_forest71_20130204_01.root";
  TString refname = "/d101/yetkin/analysis/d0204/ntuple_data_PbPb_akPu3PF_forest71_20130204_01.root";
  TString mixname = "/d101/yetkin/analysis/d0204/hijing.root";

  TFile *inf = new TFile(infname.Data());
  TTree *nt =(TTree*)inf->FindObjectAny("ntdijet");
  TTree *ntevt =(TTree*)inf->FindObjectAny("ntevt");
  nt->AddFriend(ntevt);

  TFile *infMix = new TFile(mixname.Data());
  TTree *ntMix =(TTree*)infMix->FindObjectAny("ntdijet");
  TTree *ntevtMix =(TTree*)infMix->FindObjectAny("ntevt");
  TTree *ntw =(TTree*)infMix->FindObjectAny("ntw");
  ntMix->AddFriend(ntw);
  ntMix->AddFriend(ntevtMix);

  nt->SetAlias("pt1","jtpt1");
  nt->SetAlias("pt2","jtpt2");
  nt->SetAlias("eta1","jteta1");
  nt->SetAlias("eta2","jteta2");
  nt->SetAlias("phi1","jtphi1");
  nt->SetAlias("phi2","jtphi2");

  ntMix->SetAlias("pt1","jtpt1");
  ntMix->SetAlias("pt2","jtpt2");
  ntMix->SetAlias("eta1","jteta1");
  ntMix->SetAlias("eta2","jteta2");
  ntMix->SetAlias("phi1","jtphi1");
  ntMix->SetAlias("phi2","jtphi2");

  nt->SetAlias("cent","hfp");
  ntMix->SetAlias("cent","hfp");

  nt->SetAlias("etaDijet","(eta1+eta2)/2");
  ntMix->SetAlias("etaDijet","(eta1+eta2)/2");

  nt->SetAlias("x","pt2/pt1");
  ntMix->SetAlias("x","pt2/pt1");

  nt->SetAlias("dphi","acos(cos(phi1-phi2))");
  ntMix->SetAlias("dphi","acos(cos(phi1-phi2))");


  nt->SetAlias("var",var.data());
  ntMix->SetAlias("var",var.data());

  nt->SetAlias("w","pt1> -999");
  ntMix->SetAlias("w","weight*(pthat > 50)");

  TCut noises[2] = {"noise == -1","noise == 1"};

  TTree* t[2] = {nt,ntMix};

  TH2D* h[2];
  TH1D* hMean[3];
  TH1D* hSigma[3];

  double yMax = 250;
  double yMin = 0;

  string varName = "N_{trk}^{offline}";

  if(var == "etaDijet"){
    yMax = 2;
    yMin = -2;
    varName = "#eta_{dijet}=(#eta_{1}+#eta_{2})/2";
  }

  if(var == "x"){
    yMax = 1;
    yMin = 0;
    varName = "p_{T,2}/p_{T,1}";
  }

  if(var == "dphi"){
    yMax = pi;
    yMin = pi-pi/3;
    varName = "#Delta#phi_{1,2}";
  }


  TCanvas* c1 = new TCanvas("c1","",1200,600);
  c1->Divide(2,1);

  for(int i = 0; i < 2; ++i){
    c1->cd(i+1)->SetLogz();
    h[i] = new TH2D(Form("h%d",i),Form(";E_{T}^{HF[#eta > 4]};%s",varName.data()),14,0,70,250,yMin,yMax);
    h[i]->GetXaxis()->CenterTitle();
    h[i]->GetYaxis()->CenterTitle();

    t[0]->Draw(Form("var:cent>>%s",h[i]->GetName()),dijet&&deltaPhi&&jetID&&vtx&&noises[i],"colz");
 
    fitSlices(h[i]);

    hMean[i] = (TH1D*)gDirectory->Get(Form("%s_1",h[i]->GetName()));
    hSigma[i] = (TH1D*)gDirectory->Get(Form("%s_2",h[i]->GetName()));
    hMean[i]->SetTitle("");
    hSigma[i]->SetTitle("");

    hMean[i]->SetLineColor(i+1);
    hSigma[i]->SetLineColor(i+1);
    hMean[i]->SetMarkerColor(i+1);
    hSigma[i]->SetMarkerColor(i+1);
    hMean[i]->GetXaxis()->CenterTitle();
    hMean[i]->GetYaxis()->CenterTitle();
    hSigma[i]->GetXaxis()->CenterTitle();
    hSigma[i]->GetYaxis()->CenterTitle();

    hMean[i]->GetYaxis()->SetTitle(Form("#LT%s#GT",varName.data()));
    hSigma[i]->GetYaxis()->SetTitle(Form("#sigma(%s)",varName.data()));


 }

  c1->Print(Form("figure_%s_HF_correlations_dijets_pu.gif",var.data()));
  c1->Print(Form("figure_%s_HF_correlations_dijets_pu.pdf",var.data()));


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

  if(var == "etaDijet"){
    hMean[0]->SetMinimum(-0.3);
    hMean[0]->SetMaximum(0.3);
  }

  if(var == "x"){
    hMean[0]->SetMinimum(0.6);
    hMean[0]->SetMaximum(0.9);
  }


  hMean[0]->Draw("hist");
  hMean[1]->Draw("same");

  hMean[2] = (TH1D*)hMean[1]->Clone("hr0");
  hMean[2]->Divide(hMean[0]);

  TLegend *t3=new TLegend(0.22,0.72,0.49,0.88);
  t3->SetFillColor(0);
  t3->SetBorderSize(0);
  t3->SetFillStyle(0);
  t3->SetTextFont(63);
  t3->SetTextSize(20);
  t3->AddEntry(hMean[0],Form("pVertexFilterCutGplus"),"l");
  t3->AddEntry(hMean[1],Form("!pVertexFilterCutGplus"),"p");
  t3->Draw();
  c2->Print(Form("figure_%s_HF_mean_dijets_pu.gif",var.data()));
  c2->Print(Form("figure_%s_HF_mean_dijets_pu.pdf",var.data()));


  TCanvas* cr2 = new TCanvas("cr2","",600,600);
  TLine* line = new TLine(0,1,70,1);
  line->SetLineStyle(2);
  hMean[2]->SetMinimum(0);
  hMean[2]->SetMaximum(2);

  hMean[2]->Draw("");
  line->Draw("same");
  t3->Draw();

  cr2->Print(Form("figure_%s_HF_ratio_dijets_pu.gif",var.data()));
  cr2->Print(Form("figure_%s_HF_ratio_dijets_pu.pdf",var.data()));


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

  hSigma[1]->SetMinimum(0);
  hSigma[1]->SetMaximum(120);

  hSigma[0]->Draw("hist");
  hSigma[1]->Draw("same");
  t3->Draw();


  c3->Print(Form("figure_%s_HF_sigma_dijets_pu.gif",var.data()));
  c3->Print(Form("figure_%s_HF_sigma_dijets_pu.pdf",var.data()));





  



}
コード例 #8
0
ファイル: plotFeedDown.C プロジェクト: KiSooLee/DntupleRunII
void plotFeedDown(int ntest=1, int centL=0,int centH=100)
{
   // B cross-section
   TFile *inf = new TFile("output_pp_Bmeson_5TeV_y1.root");
//   TFile *inf = new TFile("outputBplus_D_pp_rap24.root");
//    TFile *inf = new TFile("outputBplus_pp.root");
   TH1D *hBPtMax = (TH1D*)inf->Get("hmaxall");
   TH1D *hBPtMin = (TH1D*)inf->Get("hminall");
   TH1D *hBPt = (TH1D*)inf->Get("hpt");
   hBPt->SetName("hBPt");
   hBPtMax->SetName("hBPtMax");
   hBPtMin->SetName("hBPtMin");

   TH1D *hBMaxRatio = (TH1D*)hBPt->Clone("hBMaxRatio");
   hBMaxRatio->Divide(hBPtMax);

   TH1D *hBMinRatio = (TH1D*)hBPt->Clone("hBMinRatio");
   hBMinRatio->Divide(hBPtMin);

   
   hBPt->Rebin(1); 
   
   // D cross-section
//   TFile *infD = new TFile("outputD0_D_pp.root");
   TFile *infD = new TFile("output_pp_d0meson_5TeV_y1.root");
   TH1D *hDPtMax = (TH1D*)infD->Get("hmaxall");
   TH1D *hDPtMin = (TH1D*)infD->Get("hminall");
   TH1D *hDPt = (TH1D*)infD->Get("hpt");
   hDPt->SetName("hDPt");
   hDPtMax->SetName("hDPtMax");
   hDPtMin->SetName("hDPtMin");
   hDPt->Rebin(1); 

   // ratio of B->D0: not correct85% from PYTHIA
   //hBPt->Scale(0.85);
   hBPt->Scale(0.598);
   
   // c->D (55.7%)
   hDPt->Scale(0.557);

   
   TFile *inf2 = new TFile("/data/HeavyFlavourRun2/BtoDPythia/treefile_merged.root");
//   TFile *inf2 = new TFile("test.root");
   TTree *hi = (TTree*) inf2->Get("ana/hi");

   hi->SetAlias("yD","log((sqrt(1.86484*1.86484+pt*pt*cosh(eta)*cosh(eta))+pt*sinh(eta))/sqrt(1.86484*1.86484+pt*pt))");			    
   hi->SetAlias("yB","log((sqrt(5.3*5.3+pt*pt*cosh(eta)*cosh(eta))+pt*sinh(eta))/sqrt(5.3*5.3+pt*pt))");			    
   hi->SetAlias("yJ","log((sqrt(3.09692*3.09692+pt*pt*cosh(eta)*cosh(eta))+pt*sinh(eta))/sqrt(3.09692*3.09692+pt*pt))");			    


   // 6.5, 8, 10, 13, 30

/*
   TH1D *hBNoCut = (TH1D*)hBPt->Clone("hBNoCut");
   TH1D *hBHasD  = (TH1D*)hBPt->Clone("hBHasD");
   
   hi->Draw("pt>>hBHasD","(abs(pdg)>500&&abs(pdg)<600&&abs(yB)<2.4)&&Sum$(abs(pdg)==421&&abs(yD)<2)>0");
   hi->Draw("pt>>hBNoCut","(abs(pdg)>500&&abs(pdg)<600&&abs(yB)<2.4)");
;

   hBNoCut->Divide(hBHasD);
   hBPt->Divide(hBNoCut);
  */  

// 0-100%
   int npoint = 7;
   	
   double ptBins_npjpsi[8] = {1,3,6.5,8,10,13,30,300};
  
   double raa_npjpsi[7];//      = {1,0.6, 0.52,0.43,0.43,0.34,0.5};  
   double raaStat_npjpsi[7];//  = {1,0.4,0.12,0.08,0.09,0.07,0.5};
   double raaSyst_npjpsi[7];//  = {0,0,0.06,0.05,0.05,0.04,0};

/*
0-10, 10-20, 20-30, 30-40, 40-50, 50-100
double nonPromptJpsiRAA_2012[]           = {0.,0.38,0.43,0.48,0.52,0.65,0.69};
double nonPromptJpsiRAAError_2012[]      = {0.,0.02,0.03,0.03,0.04,0.06,0.07};
double nonPromptJpsiRAAErrorSyst_2012[]  = {0.,0.04,0.05,0.05,0.06,0.07,0.07};
*/

   if (centL==0&&centH==100) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=0.6;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=0.4;	// prelim
      raa_npjpsi[2]=0.52;	raaStat_npjpsi[2]=0.12;		raaSyst_npjpsi[2]=0.06;	// np jpsi pas
      raa_npjpsi[3]=0.43;	raaStat_npjpsi[3]=0.08;		raaSyst_npjpsi[3]=0.05;	// np jpsi pas
      raa_npjpsi[4]=0.43;	raaStat_npjpsi[4]=0.09;		raaSyst_npjpsi[4]=0.05;	// np jpsi pas
      raa_npjpsi[5]=0.34;	raaStat_npjpsi[5]=0.07;		raaSyst_npjpsi[5]=0.04;	// np jpsi pas
      raa_npjpsi[6]=0.5;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.25;	// b-jet
   }
   
   if (centL==0&&centH==10) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.38;	raaStat_npjpsi[2]=0.02;		raaSyst_npjpsi[2]=0.04;	// np jpsi pas
      raa_npjpsi[3]=0.38;	raaStat_npjpsi[3]=0.02;		raaSyst_npjpsi[3]=0.04;	// np jpsi pas
      raa_npjpsi[4]=0.38;	raaStat_npjpsi[4]=0.02;		raaSyst_npjpsi[4]=0.04;	// np jpsi pas
      raa_npjpsi[5]=0.38;	raaStat_npjpsi[5]=0.02;		raaSyst_npjpsi[5]=0.04;	// np jpsi pas
      raa_npjpsi[6]=0.39;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.20;	// b-jet
   
   }

   if (centL==10&&centH==20) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.43;	raaStat_npjpsi[2]=0.03;		raaSyst_npjpsi[2]=0.05;	// np jpsi pas
      raa_npjpsi[3]=0.43;	raaStat_npjpsi[3]=0.03;		raaSyst_npjpsi[3]=0.05;	// np jpsi pas
      raa_npjpsi[4]=0.43;	raaStat_npjpsi[4]=0.03;		raaSyst_npjpsi[4]=0.05;	// np jpsi pas
      raa_npjpsi[5]=0.43;	raaStat_npjpsi[5]=0.03;		raaSyst_npjpsi[5]=0.05;	// np jpsi pas
      raa_npjpsi[6]=0.47;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.24;	// b-jet
   
   }

   if (centL==20&&centH==30) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.48;	raaStat_npjpsi[2]=0.03;		raaSyst_npjpsi[2]=0.05;	// np jpsi pas
      raa_npjpsi[3]=0.48;	raaStat_npjpsi[3]=0.03;		raaSyst_npjpsi[3]=0.05;	// np jpsi pas
      raa_npjpsi[4]=0.48;	raaStat_npjpsi[4]=0.03;		raaSyst_npjpsi[4]=0.05;	// np jpsi pas
      raa_npjpsi[5]=0.48;	raaStat_npjpsi[5]=0.03;		raaSyst_npjpsi[5]=0.05;	// np jpsi pas
      raa_npjpsi[6]=0.47;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.24;	// b-jet
   
   }

   if (centL==30&&centH==40) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.52;	raaStat_npjpsi[2]=0.04;		raaSyst_npjpsi[2]=0.06;	// np jpsi pas
      raa_npjpsi[3]=0.52;	raaStat_npjpsi[3]=0.04;		raaSyst_npjpsi[3]=0.06;	// np jpsi pas
      raa_npjpsi[4]=0.52;	raaStat_npjpsi[4]=0.04;		raaSyst_npjpsi[4]=0.06;	// np jpsi pas
      raa_npjpsi[5]=0.52;	raaStat_npjpsi[5]=0.04;		raaSyst_npjpsi[5]=0.06;	// np jpsi pas
      raa_npjpsi[6]=0.61;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.30;	// b-jet
   
   }

   if (centL==40&&centH==50) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.65;	raaStat_npjpsi[2]=0.06;		raaSyst_npjpsi[2]=0.07;	// np jpsi pas
      raa_npjpsi[3]=0.65;	raaStat_npjpsi[3]=0.06;		raaSyst_npjpsi[3]=0.07;	// np jpsi pas
      raa_npjpsi[4]=0.65;	raaStat_npjpsi[4]=0.06;		raaSyst_npjpsi[4]=0.07;	// np jpsi pas
      raa_npjpsi[5]=0.65;	raaStat_npjpsi[5]=0.06;		raaSyst_npjpsi[5]=0.07;	// np jpsi pas
      raa_npjpsi[6]=0.61;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.30;	// b-jet
   
   }

   if (centL==50&&centH==100) {
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.69;	raaStat_npjpsi[2]=0.07;		raaSyst_npjpsi[2]=0.07;	// np jpsi pas
      raa_npjpsi[3]=0.69;	raaStat_npjpsi[3]=0.07;		raaSyst_npjpsi[3]=0.07;	// np jpsi pas
      raa_npjpsi[4]=0.69;	raaStat_npjpsi[4]=0.07;		raaSyst_npjpsi[4]=0.07;	// np jpsi pas
      raa_npjpsi[5]=0.69;	raaStat_npjpsi[5]=0.07;		raaSyst_npjpsi[5]=0.07;	// np jpsi pas
      raa_npjpsi[6]=0.70;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.35;	// b-jet
   
   }


   if (centL==0&&centH==20) {  //averaged by ncoll
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.4;	raaStat_npjpsi[2]=0.03;		raaSyst_npjpsi[2]=0.05;	// np jpsi pas
      raa_npjpsi[3]=0.4;	raaStat_npjpsi[3]=0.03;		raaSyst_npjpsi[3]=0.05;	// np jpsi pas
      raa_npjpsi[4]=0.4;	raaStat_npjpsi[4]=0.03;		raaSyst_npjpsi[4]=0.05;	// np jpsi pas
      raa_npjpsi[5]=0.4;	raaStat_npjpsi[5]=0.03;		raaSyst_npjpsi[5]=0.05;	// np jpsi pas
      raa_npjpsi[6]=0.42;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.21;	// b-jet
   
   }

   if (centL==10&&centH==30) {  //averaged by ncoll
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.45;	raaStat_npjpsi[2]=0.03;		raaSyst_npjpsi[2]=0.05;	// np jpsi pas
      raa_npjpsi[3]=0.45;	raaStat_npjpsi[3]=0.03;		raaSyst_npjpsi[3]=0.05;	// np jpsi pas
      raa_npjpsi[4]=0.45;	raaStat_npjpsi[4]=0.03;		raaSyst_npjpsi[4]=0.05;	// np jpsi pas
      raa_npjpsi[5]=0.45;	raaStat_npjpsi[5]=0.03;		raaSyst_npjpsi[5]=0.05;	// np jpsi pas
      raa_npjpsi[6]=0.47;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.24;	// b-jet
   
   }


   if (centL==30&&centH==50) {  //averaged by ncoll
      raa_npjpsi[0]=1.0;	raaStat_npjpsi[0]=0.0;		raaSyst_npjpsi[0]=1.0;	// no measurement
      raa_npjpsi[1]=1.0;	raaStat_npjpsi[1]=0.0;		raaSyst_npjpsi[1]=1.0;	// no measurement
      raa_npjpsi[2]=0.57;	raaStat_npjpsi[2]=0.06;		raaSyst_npjpsi[2]=0.07;	// np jpsi pas
      raa_npjpsi[3]=0.57;	raaStat_npjpsi[3]=0.06;		raaSyst_npjpsi[3]=0.07;	// np jpsi pas
      raa_npjpsi[4]=0.57;	raaStat_npjpsi[4]=0.06;		raaSyst_npjpsi[4]=0.07;	// np jpsi pas
      raa_npjpsi[5]=0.57;	raaStat_npjpsi[5]=0.06;		raaSyst_npjpsi[5]=0.07;	// np jpsi pas
      raa_npjpsi[6]=0.61;	raaStat_npjpsi[6]=0.0;		raaSyst_npjpsi[6]=0.30;	// b-jet
   
   }


   TH1D *hNPJpsiRAA = new TH1D("hNPJpsiRAA","",npoint,ptBins_npjpsi);

   for (int i=1;i<=npoint;i++)
   {
      hNPJpsiRAA->SetBinContent(i,raa_npjpsi[i-1]);      
      hNPJpsiRAA->SetBinError(i,sqrt(raaSyst_npjpsi[i-1]*raaSyst_npjpsi[i-1]+raaStat_npjpsi[i-1]*raaStat_npjpsi[i-1]));     }

   TCanvas *cJpsiRAA = new TCanvas("cJpsiRAA","",600,600);
   cJpsiRAA->SetLogx();
   TExec *setex2 = new TExec("setex2","gStyle->SetErrorX(0.5)");
   setex2->Draw();
   hNPJpsiRAA->SetXTitle("Non-prompt J/psi R_{AA} (GeV/c)");
   hNPJpsiRAA->SetXTitle("Non-prompt J/psi p_{T} (GeV/c)");
   hNPJpsiRAA->SetYTitle("R_{AA}");
   hNPJpsiRAA->Draw("e1");


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

   TH2D *hJpsi= new TH2D("hJpsi","",hBPt->GetNbinsX(),hBPt->GetBinLowEdge(1),hBPt->GetBinLowEdge(hBPt->GetNbinsX()+1),
                            299*4,1,300);
   TH2D *hD= new TH2D("hD","",hBPt->GetNbinsX(),hBPt->GetBinLowEdge(1),hBPt->GetBinLowEdge(hBPt->GetNbinsX()+1),
                            299*4,1,300);
    hi->Draw("pt:BPt>>hJpsi","pdg==443&&BPt>0&&abs(yJ)<1");	
    hi->Draw("pt:BPt>>hD","abs(pdg)==421&&BPt>0&&abs(yD)<1");	
 
   hJpsi->Sumw2();   
   hD->Sumw2();   
   reweighthisto(hBPt,hD);
   reweighthisto(hBPt,hJpsi);
   hJpsi->ProjectionY()->Draw("hist");
   hD->SetLineColor(4);
   hD->SetMarkerColor(4);
   hD->ProjectionY()->Draw("hist same");
   hBPt->Draw("hist same");
   
   hJpsi->SetXTitle("B p_{T} (GeV/c)");
   hJpsi->SetYTitle("J/#psi p_{T} (GeV/c)");
   hD->SetXTitle("B p_{T} (GeV/c)");
   hD->SetYTitle("D^{0} p_{T} (GeV/c)");
   
   TCanvas *c2= new TCanvas("c2","B RAA band",600,600);
   
   TRandom2 rnd;
//   hJpsi	->ProjectionX()->Draw("hist");
   TH2D *hRAATmp = new TH2D("hRAATmp","",97,3,100,100,0,2);
   hRAATmp->SetXTitle("B p_{T} (GeV/c)");
   hRAATmp->SetYTitle("R_{AA}");
   hRAATmp->Draw();

   TCanvas *c3= new TCanvas("c3","D RAA band",600,600);
   TH2D *hDRAATmp = new TH2D("hDRAATmp","",47,3,50,100,0,2);
   hDRAATmp->SetXTitle("D^{0} p_{T} (GeV/c)");
   hDRAATmp->SetYTitle("R_{AA}");

   hDRAATmp->Draw();

   TCanvas *c4= new TCanvas("c4","B->D fraction band",600,600);
   TH2D *hBtoDTmp = new TH2D("hBtoDTmp","",47,3,50,100,0,2);
   hBtoDTmp->SetXTitle("D^{0} p_{T} (GeV/c)");
   hBtoDTmp->SetYTitle("Non-prompt D fraction");
   hBtoDTmp->Draw();
   
   TH1D *hDFromBPt= (TH1D*)hD->ProjectionY()->Clone("hDFromBPt");
   TH1D *hDFromBPtFraction= (TH1D*)hD->ProjectionY()->Clone("hDFromBPtFraction");
   hDFromBPtFraction->Divide(hDPt);
   TH1D *hDFromBPtMax= (TH1D*)hD->ProjectionY()->Clone("hDFromBPtMax");
   TH1D *hDFromBPtMin= (TH1D*)hD->ProjectionY()->Clone("hDFromBPtMin");
   
   setHist(hDFromBPtMax,-1e10);
   setHist(hDFromBPtMin,1e10);
   
   for (int i=0;i<ntest;i++)
   {
       if (i%10==0) cout <<i<<endl;	
       TH1D *hRAASample = (TH1D*)hNPJpsiRAA->Clone(Form(	"hRAASample_%d",i));
       for (int j=1;j<=hRAASample->GetNbinsX();j++) {
          double RAA = (rnd.Rndm()*2-1)*hNPJpsiRAA->GetBinError(j)+hNPJpsiRAA->GetBinContent(j);
	  hRAASample->SetBinContent(j,RAA);
       }
       
       TH2D *hJpsiClone = (TH2D*)hJpsi->Clone(Form("hJpsiClone_%d",i));

       reweighthisto(hBPt,hJpsiClone,hRAASample,1);
       TH1D *hBRAA = hJpsiClone->ProjectionX(Form("hBRAA_%d",i));
       
       c2->cd();
       hBRAA->Divide(hBPt);
       hBRAA->SetLineWidth(3);
       hBRAA->SetLineColor(kGray);
       hBRAA->Rebin(4);
       hBRAA->Scale(1./4.);
       hBRAA->Draw("hist c same");
       
       delete hJpsiClone;
       
       TH2D *hDClone = (TH2D*)hD->Clone(Form("hDClone_%d",i));
       reweighthisto(hBPt,hDClone,hBRAA,0,1);
       
       
       TH1D *hDRAA = hDClone->ProjectionY(Form("hDRAA_%d",i));
       
       getMaximum(hDFromBPtMax,hDRAA);
       getMinimum(hDFromBPtMin,hDRAA);
       
       c3->cd();
       hDRAA->Divide(hDFromBPt);
       hDRAA->SetLineWidth(3);
       hDRAA->SetLineColor(kGray);
       hDRAA->Draw("hist c same");
       
       c4->cd();
       TH1D *hBtoDFrac = hDClone->ProjectionY(Form("hBtoDFrac_%d",i));
       
       hBtoDFrac->Divide(hDPt);
       hBtoDFrac->SetLineWidth(3);
       hBtoDFrac->SetLineColor(kGray);
       hBtoDFrac->Draw("hist same");
       
       delete hDClone;      
//       delete hBRAA;      
//       delete hDRAA;      
       
   }	   
   
   TFile *outf = new TFile(Form("BtoD-%d-%d.root",centL,centH),"recreate");

   TH1D *hDFromBPtCentral=(TH1D*)hDFromBPtMax->Clone("hDFromBPtCentral");
   hDFromBPtCentral->Add(hDFromBPtMin);
   hDFromBPtCentral->Scale(1./2);
   
   hNPJpsiRAA->Write();
   hDFromBPtMax->Write();
   hDFromBPtMin->Write();
   hDFromBPtCentral->Write();
   hDFromBPt->Write();
   hJpsi->Write();
   hD->Write();
   hDFromBPtFraction->Write();
   outf->Write();

   
       
}
コード例 #9
0
void balanceMetVsAj(TString infname = "dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0_120_50.root",
                    TCut myCut = "cent<30", char *title = "",bool drawLegend = false,
                    bool drawSys = true
                   )
{
   TFile *inf = new TFile(infname);
   TTree *t = (TTree*)inf->Get("ntjt");
  
   t->SetAlias("metxMerged0","metx0+metx1+metx2");
   t->SetAlias("metxMerged1","metx1+metx2");
   t->SetAlias("metxMerged2","metx2");
   t->SetAlias("metxMerged3","metx3+metx4");
   const int nBin = 4;
   double bins[nBin+1] = {0.5,1.5,4,8,1000};  
   double colors[nBin] = {38, kOrange-8,kBlue-3,kRed};

   const int nBinAj = 4;
   double ajBins[nBinAj+1] = {0.0001,0.11,0.22,0.33,0.49999};
   // Selection cut
   TCut evtCut = "nljet>120&&abs(nljetacorr)<2&&aljet>50&&abs(aljetacorr)<2&&jdphi>2./3*TMath::Pi()&&!maskEvt";

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

   TH1D *p[nBin];

   for (int i=0;i<nBin;i++)
   {
      TH1D *h1 = new TH1D(Form("h1%d",i),"",nBinAj,ajBins);
      TH1D *h2 = new TH1D(Form("h2%d",i),"",nBinAj,ajBins);
      h1->Sumw2();
      h2->Sumw2();
  //    t->Project(Form("h%d",i),"Aj", "1"*(evtCut&&myCut));
//      t->Project(Form("h2%d",i),"Aj", Form("((-1*metxMerged%d))",i)*(evtCut&&myCut));
      t->Draw(Form("Aj>>h1%d",i), "weight"*(evtCut&&myCut));
      t->Draw(Form("Aj>>h2%d",i), Form("((-weight*metxMerged%d))",i)*(evtCut&&myCut));
      p[i]=(TH1D*)h2->Clone();
      p[i]->SetName(Form("p%d",i));     
      p[i]->Divide(h1);
      p[i]->SetLineColor(1);     
      p[i]->SetMarkerColor(colors[i]);
      p[i]->SetFillColor(colors[i]);
//      p[i]->SetFillStyle(3004+fabs(i-1));
      p[i]->SetFillStyle(1001);
     
   }

   TH1D *pall;
   TH1D *h1 = new TH1D(Form("hAll1"),"",nBinAj,ajBins);
   TH1D *h2 = new TH1D(Form("hAll2"),"",nBinAj,ajBins);
   h1->Sumw2();
   h2->Sumw2();
   t->Draw(Form("Aj>>hAll1"), "weight"*(evtCut&&myCut));
   t->Draw(Form("Aj>>hAll2"), Form("((-weight*metx))")*(evtCut&&myCut));

   pall=(TH1D*)h2->Clone();
   pall->SetName("pall");
   pall->Divide(h1);
   pall->SetXTitle("A_{J}");
   pall->SetYTitle("<#slash{p}_{T}^{#parallel}> (GeV/c)");
   pall->GetXaxis()->CenterTitle();
   pall->GetYaxis()->CenterTitle();
   pall->GetXaxis()->SetLabelSize(22);
   pall->GetXaxis()->SetLabelFont(43);
   pall->GetXaxis()->SetTitleSize(24);
   pall->GetXaxis()->SetTitleFont(43);
   pall->GetYaxis()->SetLabelSize(22);
   pall->GetYaxis()->SetLabelFont(43);
   pall->GetYaxis()->SetTitleSize(24);
   pall->GetYaxis()->SetTitleFont(43);
   pall->GetXaxis()->SetTitleOffset(1.8);
   pall->GetYaxis()->SetTitleOffset(2.4);



   pall->SetNdivisions(505);
   pall->SetAxisRange(-59.9,59.9,"Y");
   pall->SetMarkerSize(1);
   pall->Draw("E");
   for (int i=0;i<nBin;++i) {
      p[i]->SetLineWidth(1);
      p[i]->Draw("hist same");
   }
   pall->Draw("E same");

   if (drawSys == 1) {
      for(int i = 0; i < nBinAj; ++i){
        double x = pall->GetBinCenter(i+1);
        double y = pall->GetBinContent(i+1);
        // Quote the difference between GEN and RECO in >8 Bin (20%) before adjusting eff as systematics
        double err = -p[nBin-1]->GetBinContent(i+1)*0.2;
 
        DrawTick(y,err,err,x,1,0.02,1);
      }
   }

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

   if (drawLegend) leg->Draw();

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


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

   TText *titleText = new TText(0.3,30,title);
   titleText->Draw();
}
コード例 #10
0
void DoAnalysisWithTree(TFile* file, int run, int x, int y)
{

  gout << 0 << " " << run << " " << x << " " << y << " ";

  TF1* flandau = new TF1("flandau","landau",0,400);

  TCanvas *c1 = new TCanvas("c1","",1280,960);
  c1->Divide(4,2);

  TCanvas *c2 = new TCanvas("c2","",1280,960);
  c2->Divide(4,2);

  TCanvas *c3 = new TCanvas("c3","",1280,960);
  c3->Divide(4,2);

  TCanvas *c4 = new TCanvas("c4","",1280,960);
  c4->Divide(4,2);

  TTree* tree = (TTree*)file->Get("T");

  tree->SetAlias("Average_HODO_HORIZONTAL","Sum$(TOWER_CALIB_HODO_HORIZONTAL.towerid * (abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) * abs(TOWER_CALIB_HODO_HORIZONTAL.energy))/Sum$((abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) * abs(TOWER_CALIB_HODO_HORIZONTAL.energy))");
  tree->SetAlias("Average_HODO_VERTICAL","Sum$(TOWER_CALIB_HODO_VERTICAL.towerid * (abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) * abs(TOWER_CALIB_HODO_VERTICAL.energy))/Sum$((abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) * abs(TOWER_CALIB_HODO_VERTICAL.energy))");
  tree->SetAlias("Valid_HODO_HORIZONTAL","Sum$(abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) > 0");
  tree->SetAlias("Valid_HODO_VERTICAL","Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) > 0");

  ofstream fout((const char*)Form("DataRunByRun/mapper_run%d.dat",run));

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

      TString drawstring1 = "TOWER_CALIB_TILE_MAPPER[";
      drawstring1 += i*2;
      drawstring1 += "].energy>>hs1_";
      drawstring1 += i+1;
      drawstring1 += "(100,0,400)";

      c1->cd(i+1);
      tree->Fit("flandau",drawstring1,"","","");

      TString drawstring2 = "TOWER_CALIB_TILE_MAPPER[";
      drawstring2 += i*2;
      drawstring2 += "].energy>>hs2_";
      drawstring2 += i+1;
      drawstring2 += "(100,0,400)";

      c2->cd(i+1);
      tree->Fit("flandau",drawstring2,"Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL","","");
      fout << run << " " << 9999 << " " << 9999 << " " << flandau->GetParameter(1) << " " << flandau->GetParError(1) << endl;
      gout << flandau->GetParameter(1) << " " << flandau->GetParError(1) << " ";

      TString drawstring3 = "TOWER_CALIB_TILE_MAPPER[";
      drawstring3 += i*2;
      drawstring3 += "].energy>>hs3_";
      drawstring3 += i+1;
      drawstring3 += "(100,0,400)";

      c3->cd(i+1);
      tree->Fit("flandau",drawstring3,"Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL && abs(TOWER_CALIB_C2[3].energy)<200","","");

      TString drawstring4 = "TOWER_CALIB_TILE_MAPPER[";
      drawstring4 += i*2;
      drawstring4 += "].energy>>hs4_";
      drawstring4 += i+1;
      drawstring4 += "(100,0,400)";

      c4->cd(i+1);
      tree->Fit("flandau",drawstring4,"Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL && abs(TOWER_CALIB_C2[3].energy)>200","","");

    }

  c1->Print(Form("FigsRunByRun/mapper_run%d_step1.png",run));
  c2->Print(Form("FigsRunByRun/mapper_run%d_step2.png",run));
  c3->Print(Form("FigsRunByRun/mapper_run%d_step3.png",run));
  c4->Print(Form("FigsRunByRun/mapper_run%d_step4.png",run));
  c1->Print(Form("FigsRunByRun/mapper_run%d_step1.pdf",run));
  c2->Print(Form("FigsRunByRun/mapper_run%d_step2.pdf",run));
  c3->Print(Form("FigsRunByRun/mapper_run%d_step3.pdf",run));
  c4->Print(Form("FigsRunByRun/mapper_run%d_step4.pdf",run));

  delete c1;
  delete c2;
  delete c3;
  delete c4;

  gout << endl;

  return;

  // --- let's try to have a look at the hodoscope positions

  TCanvas* c5 = new TCanvas("c5","",800,800);
  TH2D* th2d_hodo_fine = new TH2D("th2d_hodo_fine","",40,-0.5,7.5,40,-0.5,7.5);
  TH2D* th2d_hodo_coarse = new TH2D("th2d_hodo_coarse","",8,-0.5,7.5,8,-0.5,7.5);
  th2d_hodo_fine->GetXaxis()->SetTitle("Horizontal Hodoscope");
  th2d_hodo_fine->GetYaxis()->SetTitle("Vertical Hodoscope");
  th2d_hodo_coarse->GetXaxis()->SetTitle("Horizontal Hodoscope");
  th2d_hodo_coarse->GetYaxis()->SetTitle("Vertical Hodoscope");
  tree->Draw("Average_HODO_HORIZONTAL:Average_HODO_VERTICAL>>th2d_hodo_fine","Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL","colz");
  c5->Print(Form("FigsRunByRun/hodoscope_fine_run%d.png",run));
  c5->Print(Form("FigsRunByRun/hodoscope_fine_run%d.pdf",run));
  tree->Draw("Average_HODO_HORIZONTAL:Average_HODO_VERTICAL>>th2d_hodo_coarse","Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL","colz");
  c5->Print(Form("FigsRunByRun/hodoscope_coarse_run%d.png",run));
  c5->Print(Form("FigsRunByRun/hodoscope_coarse_run%d.pdf",run));
  delete c5;

  // --- now lets try to look at the distributions for each hodoscope position

  TCanvas* c6 = new TCanvas("c6","",1280,960);
  c6->Divide(4,2);

  for ( int indexHorizontal = 0; indexHorizontal < 8; ++indexHorizontal)
    {
      for ( int indexVertical = 0; indexVertical < 8; ++indexVertical )
        {
          for ( int indexTile = 0; indexTile < 8; ++indexTile )
            {
              TString drawstring = "TOWER_CALIB_TILE_MAPPER[";
              drawstring += indexTile*2;
              drawstring += "].energy>>hs_";
              drawstring += indexTile+1;
              drawstring += "(100,0,400)";
              cout << "drawstring is " << drawstring << endl;

              TString cutstring = "Valid_HODO_VERTICAL && Valid_HODO_HORIZONTAL";
              cutstring += " && abs(Average_HODO_HORIZONTAL-";
              cutstring += indexHorizontal;
              cutstring += ")<0.5";
              cutstring += " && abs(Average_HODO_VERTICAL-";
              cutstring += indexVertical;
              cutstring += ")<0.5";
              cout << "cutstring is " << cutstring << endl;

              c6->cd(indexTile+1);
              tree->Fit("flandau",drawstring,cutstring,"","");
              fout << run << " " << indexHorizontal << " " << indexVertical << " " << flandau->GetParameter(1) << " " << flandau->GetParError(1) << endl;
            }
          c6->Print(Form("FigsRunByRun/HodoscopeGridFigs/mapper_run%d_H%dV%d.png",run,indexHorizontal,indexVertical));
          c6->Print(Form("FigsRunByRun/HodoscopeGridFigs/mapper_run%d_H%dV%d.pdf",run,indexHorizontal,indexVertical));
        }
    }
  fout.close();

  delete c6;

}
コード例 #11
0
ファイル: plotRJ.C プロジェクト: mandrenguyen/usercode
void plotRJ(  double ajCut=0.24,
	      int cbin = 0,
		 TString infname = "data.root",
		 TString pythia = "pythia.root",
		 TString mix = "mix.root",
		 bool useWeight = true,
		 bool drawXLabel = false,
		 bool drawLeg = true)
{		
  gStyle->SetErrorX(0); 
  TString cut="et1>120 && et2>50 && abs(dphi)>2.5 && abs(eta1) < 2 && abs(eta2) < 2";
  TString cutpp="et1>120 && et2>50 && abs(dphi)>2.5 && abs(eta1) < 2 && abs(eta2) < 2";
  TString trigcut = "";
  TString cstring = "";

  // open the data file
  TFile *inf = new TFile(infname.Data());
  TTree *nt =(TTree*)inf->FindObjectAny("nt");

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

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

  nt->SetAlias("et1","pt1");
  nt->SetAlias("et2","pt2");

  ntPythia->SetAlias("pt1","et1");
  ntPythia->SetAlias("pt2","et2");

  ntMix->SetAlias("pt1","et1");
  ntMix->SetAlias("pt2","et2");

  // open output
  TFile *outfile = new TFile("output.root","recreate");
  TNtuple *ntOut = new TNtuple("ntOut","","a:b");

  const int nBin = 4;
  double m[nBin+1] = {-1.5,-0.5,3.5,11.5, 40.5};
  double npart0[nBin] = {2,355.788,163.34,46.6685}; // Flat Averages
  double npart[nBin] = {2,358.623,232.909,97.9521};
  
  
 /*
  double npart[40];
  npart[0] = 393.633;
  npart[1] = 368.819;
  npart[2] = 343.073;
  npart[3] = 317.625;
  npart[4] = 292.932;
  npart[5] = 271.917;
  npart[6] = 249.851;
  npart[7] = 230.72;
  npart[8] = 212.465;
  npart[9] = 194.752;
  npart[10] = 178.571;
  npart[11] = 163.23;
  npart[12] = 149.187;
  npart[13] = 136.011;
  npart[14] = 123.414;
  npart[15] = 111.7;
  npart[16] = 100.831;
  npart[17] = 90.7831;
  npart[18] = 80.9823;
  npart[19] = 72.6236;
  npart[20] = 64.1508;
  npart[21] = 56.6284;
  npart[22] = 49.9984;
  npart[23] = 43.3034;
  npart[24] = 37.8437;
  npart[25] = 32.6659;
  npart[26] = 27.83;
  npart[27] = 23.7892;
  npart[28] = 20.1745;
  npart[29] = 16.8453;
  npart[30] = 14.0322;
  npart[31] = 11.602;
  npart[32] = 9.52528;
  npart[33] = 7.6984;
  npart[34] = 6.446;
  npart[35] = 4.96683;
  npart[36] = 4.23649;
  npart[37] = 3.50147;
  npart[38] = 3.16107;
  npart[39] = 2.7877;
  */

  TH1D *hTmp = new TH1D("hTmp","",100,0,400);
  TH1D *h = new TH1D("h","",nBin,m);
  TH1D *h2 = new TH1D("h2","",nBin,m);
  
  nt->Draw("bin>>h",Form("(et1-et2)/(et1+et2)>%f&&%s",ajCut,cut.Data()));
  nt->Draw("bin>>h2",Form("%s",cut.Data()));
  TGraphAsymmErrors *g = calcEff(h2,h,npart);

  ntPythia->Draw("bin>>h",Form("(et1-et2)/(et1+et2)>%f&&%s",ajCut,cut.Data()));
  ntPythia->Draw("bin>>h2",Form("%s",cut.Data()));
  TGraphAsymmErrors *gPythia = calcEff(h2,h,npart);
  
  ntMix->Draw("bin>>h",Form("(et1-et2)/(et1+et2)>%f&&%s",ajCut,cut.Data()));
  ntMix->Draw("bin>>h2",Form("%s",cut.Data()));
  TGraphAsymmErrors *gMix = calcEff(h2,h,npart);

  TCanvas *c = new TCanvas("c","",500,500);
  //  hTmp->SetMaximum(g->GetY()[0]*2.2);
  hTmp->SetMaximum(0.7);
  hTmp->SetMinimum(0.15);

  hTmp->SetXTitle("N_{part}");
  hTmp->SetYTitle(Form("R_{A>%0.2f}",ajCut));
  hTmp->GetXaxis()->CenterTitle();
  hTmp->GetYaxis()->CenterTitle();
  hTmp->GetYaxis()->SetTitleOffset(1.0);
  hTmp->Draw();

  double errorbar = 0.02;
  for(int i = 0; i < g->GetN(); ++i){
    double *x = g->GetX();
    double *y = g->GetY();
    DrawTick(y[i],0.18*y[i],0.18*y[i],x[i],0.012,8.1,16);
  }
  g->Draw("p same");
  gPythia->SetMarkerColor(4);
  gPythia->SetLineColor(4);
  gMix->SetMarkerColor(2);
  gMix->SetLineColor(2);
  gMix->Draw("p same");
  gPythia->Draw("p same");

  TLine* pline = new TLine(0,gPythia->GetY()[0],400,gPythia->GetY()[0]);
  pline->SetLineColor(4);
  pline->SetLineStyle(4);
  pline->Draw();

  if(drawLeg){
    TLegend *t3=new TLegend(0.5,0.77,0.9,0.93); 

    //    t3->AddEntry(g,"Pb+Pb  #sqrt{s}_{_{NN}}=2.76 TeV","pl");
    //    t3->AddEntry(gPythia,"PYTHIA","pl");  
    //    t3->AddEntry(gMix,"embedded PYTHIA","pl");

    t3->AddEntry(g,"2011","pl");
    t3->AddEntry(gMix,"2010","pl");
    t3->AddEntry(gPythia,"PYTHIA","pl");

    t3->SetFillColor(0);
    t3->SetBorderSize(0);
    t3->SetFillStyle(0);
    t3->SetTextFont(63);
    t3->SetTextSize(15);
    t3->Draw();
  }


  TLatex *cms = new TLatex(0.20,0.88,"CMS Preliminary");
  cms->SetNDC();
  cms->SetTextFont(63);
  cms->SetTextSize(18);
  cms->Draw();                                                                                                                                        

  TLatex *lumi = new TLatex(0.20,0.81,"#intL dt = 6.7 #mub^{-1}");

  lumi->SetNDC();
  lumi->SetTextFont(63);
  lumi->SetTextSize(15);
  lumi->Draw(); 

  c->Print(Form("Rj_vs_Npart.eps",ajCut));
  c->Print(Form("Rj_vs_Npart.C",ajCut));
  c->Print(Form("Rj_vs_Npart.gif",ajCut));
  c->Print(Form("Rj_vs_Npart.pdf",ajCut));

}
コード例 #12
0
void MakeATGCRatioHistograms() {
  char* dir = "/uscms_data/d2/andersj/Wjj/2012/data/Moriond2013/ReducedTrees/";
  TFile* fSM = new TFile((dir + string("Lambda00_Kappa00_G00.root")).c_str());
  TFile* fSM2 = new TFile((string("Lambda00_Kappa00_G00.root")).c_str());
  TFile* f_L01K00G00 = new TFile((string("Lambda01_Kappa00_G00.root")).c_str());
  TFile* f_L03K00G00 = new TFile((string("Lambda03_Kappa00_G00.root")).c_str());
  TFile* f_L05K00G00 = new TFile((string("Lambda05_Kappa00_G00.root")).c_str());
  TFile* f_L07K00G00 = new TFile((dir + string("Lambda07_Kappa00_G00.root")).c_str());
  TFile* f_L09K00G00 = new TFile((dir + string("Lambda09_Kappa00_G00.root")).c_str());
  TFile* f_L11K00G00 = new TFile((dir + string("Lambda11_Kappa00_G00.root")).c_str());
  TFile* f_L00K05G00 = new TFile((string("Lambda00_Kappa05_G00.root")).c_str());
  TFile* f_L00K11G00 = new TFile((dir + string("Lambda00_Kappa11_G00.root")).c_str());
  TFile* f_L00K16G00 = new TFile((dir + string("Lambda00_Kappa16_G00.root")).c_str());
  TFile* f_L00K20G00 = new TFile((dir + string("Lambda00_Kappa20_G00.root")).c_str());
  TFile* f_L00K00G11 = new TFile((dir + string("Lambda00_Kappa00_G11.root")).c_str());
  TFile* f_L00K00G40 = new TFile((dir + string("Lambda00_Kappa00_G40.root")).c_str());
  TFile* f_L00K00G60 = new TFile((dir + string("Lambda00_Kappa00_G60.root")).c_str());


  TTree* trSM = (TTree*) fSM->Get("WJet");
  TTree* trSM2 = (TTree*) fSM2->Get("WJet");
  TTree* tr_L01K00G00 = (TTree*) f_L01K00G00->Get("WJet");
  TTree* tr_L03K00G00 = (TTree*) f_L03K00G00->Get("WJet");
  TTree* tr_L05K00G00 = (TTree*) f_L05K00G00->Get("WJet");
  TTree* tr_L07K00G00 = (TTree*) f_L07K00G00->Get("WJet");
  TTree* tr_L09K00G00 = (TTree*) f_L09K00G00->Get("WJet");
  TTree* tr_L11K00G00 = (TTree*) f_L11K00G00->Get("WJet");
  TTree* tr_L00K05G00 = (TTree*) f_L00K05G00->Get("WJet");
  TTree* tr_L00K11G00 = (TTree*) f_L00K11G00->Get("WJet");
  TTree* tr_L00K16G00 = (TTree*) f_L00K16G00->Get("WJet");
  TTree* tr_L00K20G00 = (TTree*) f_L00K20G00->Get("WJet");
  TTree* tr_L00K00G11 = (TTree*) f_L00K00G11->Get("WJet");
  TTree* tr_L00K00G40 = (TTree*) f_L00K00G40->Get("WJet");
  TTree* tr_L00K00G60 = (TTree*) f_L00K00G60->Get("WJet");


  char* dijetPt = "sqrt(JetPFCor_Pt[0]**2+JetPFCor_Pt[1]**2+2*JetPFCor_Pt[0]*JetPFCor_Pt[1]*cos(JetPFCor_Phi[0]-JetPFCor_Phi[1]))";
  trSM->SetAlias("dijetPt", dijetPt);
  trSM2->SetAlias("dijetPt", dijetPt);
  tr_L01K00G00->SetAlias("dijetPt", dijetPt);
  tr_L03K00G00->SetAlias("dijetPt", dijetPt);
  tr_L05K00G00->SetAlias("dijetPt", dijetPt);
  tr_L07K00G00->SetAlias("dijetPt", dijetPt);
  tr_L09K00G00->SetAlias("dijetPt", dijetPt);
  tr_L11K00G00->SetAlias("dijetPt", dijetPt);
  tr_L00K05G00->SetAlias("dijetPt", dijetPt);
  tr_L00K11G00->SetAlias("dijetPt", dijetPt);
  tr_L00K16G00->SetAlias("dijetPt", dijetPt);
  tr_L00K20G00->SetAlias("dijetPt", dijetPt);
  tr_L00K00G11->SetAlias("dijetPt", dijetPt);
  tr_L00K00G40->SetAlias("dijetPt", dijetPt);
  tr_L00K00G60->SetAlias("dijetPt", dijetPt);


//   char* cutsNoBoost = "(effwt*puwt)*((W_pt<200.) && (dijetPt>70.) && (event_met_pfmet >25) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>25.) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) &&(JetPFCor_bDiscriminatorCSV[0]<0.244) &&(JetPFCor_bDiscriminatorCSV[1]<0.244) && (Mass2j_PFCor>70. && Mass2j_PFCor<100.))";

//  char* cutsBoosted = "(effwt*puwt)*((W_pt>200.) && (event_met_pfmet >50) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>30.) && (GroomedJet_CA8_pt[0]>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4) &&(JetPFCor_bDiscriminatorCSV[0]<0.244) &&(GroomedJet_numberbjets <1)&&(ggdboostedWevt==1) && (GroomedJet_CA8_tau2tau1[0]<0.55) && (GroomedJet_CA8_mass[0]>70. && GroomedJet_CA8_mass[0]<100.))";



  char* cutsNoBoost = "(effwt*puwt)*((W_pt<200.) && (dijetPt>70.) && (event_met_pfmet >25) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) )";

 char* cutsBoosted = "(effwt*puwt)*((W_pt>200.) && (event_met_pfmet >50) && (GroomedJet_CA8_pt[0]>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4) )";


  char* cutsNoBoostWt = "(effwt*puwt*weight)*((W_pt<200.) && (dijetPt>70.) && (event_met_pfmet >25) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) )";

 char* cutsBoostedWt = "(effwt*puwt*weight)*((W_pt>200.) && (event_met_pfmet >50) && (GroomedJet_CA8_pt[0]>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4) )";


  ///// ----- Create all the histograms ----------
 double xbins[] = {100., 110., 120., 130., 140., 150., 160., 180., 200., 220., 240., 260., 300., 340., 
		   380., 420., 500., 600.};
  TH1D* hSMNoBoost = new TH1D("hSMNoBoost", "", sizeof(xbins)/ sizeof(xbins[0])-1, xbins);
  hSMNoBoost->Sumw2();
  hSMNoBoost->SetLineWidth(2);
  hSMNoBoost->GetXaxis()->SetTitle("dijet p_{T} (GeV)");
  hSMNoBoost->GetYaxis()->SetTitle("Ratio over SM");

  TH1D* hSMNoBoost2 = hSMNoBoost->Clone("hSMNoBoost2");
  TH1D* h_L01K00G00_NoBoost = hSMNoBoost->Clone("h_L01K00G00_NoBoost");
  TH1D* h_L03K00G00_NoBoost = hSMNoBoost->Clone("h_L03K00G00_NoBoost");
  TH1D* h_L05K00G00_NoBoost = hSMNoBoost->Clone("h_L05K00G00_NoBoost");
  TH1D* h_L07K00G00_NoBoost = hSMNoBoost->Clone("h_L07K00G00_NoBoost");
  TH1D* h_L09K00G00_NoBoost = hSMNoBoost->Clone("h_L09K00G00_NoBoost");
  TH1D* h_L11K00G00_NoBoost = hSMNoBoost->Clone("h_L11K00G00_NoBoost");
  TH1D* h_L00K05G00_NoBoost = hSMNoBoost->Clone("h_L00K05G00_NoBoost");
  TH1D* h_L00K11G00_NoBoost = hSMNoBoost->Clone("h_L00K11G00_NoBoost");
  TH1D* h_L00K16G00_NoBoost = hSMNoBoost->Clone("h_L00K16G00_NoBoost");
  TH1D* h_L00K20G00_NoBoost = hSMNoBoost->Clone("h_L00K20G00_NoBoost");
  TH1D* h_L00K00G11_NoBoost = hSMNoBoost->Clone("h_L00K00G11_NoBoost");
  TH1D* h_L00K00G40_NoBoost = hSMNoBoost->Clone("h_L00K00G40_NoBoost");
  TH1D* h_L00K00G60_NoBoost = hSMNoBoost->Clone("h_L00K00G60_NoBoost");

  TH1D* hSMBoosted = hSMNoBoost->Clone("hSMBoosted");
  TH1D* hSMBoosted2 = hSMNoBoost->Clone("hSMBoosted2");
  TH1D* h_L01K00G00_Boosted = hSMNoBoost->Clone("h_L01K00G00_Boosted");
  TH1D* h_L03K00G00_Boosted = hSMNoBoost->Clone("h_L03K00G00_Boosted");
  TH1D* h_L05K00G00_Boosted = hSMNoBoost->Clone("h_L05K00G00_Boosted");
  TH1D* h_L07K00G00_Boosted = hSMNoBoost->Clone("h_L07K00G00_Boosted");
  TH1D* h_L09K00G00_Boosted = hSMNoBoost->Clone("h_L09K00G00_Boosted");
  TH1D* h_L11K00G00_Boosted = hSMNoBoost->Clone("h_L11K00G00_Boosted");
  TH1D* h_L00K05G00_Boosted = hSMNoBoost->Clone("h_L00K05G00_Boosted");
  TH1D* h_L00K11G00_Boosted = hSMNoBoost->Clone("h_L00K11G00_Boosted");
  TH1D* h_L00K16G00_Boosted = hSMNoBoost->Clone("h_L00K16G00_Boosted");
  TH1D* h_L00K20G00_Boosted = hSMNoBoost->Clone("h_L00K20G00_Boosted");
  TH1D* h_L00K00G11_Boosted = hSMNoBoost->Clone("h_L00K00G11_Boosted");
  TH1D* h_L00K00G40_Boosted = hSMNoBoost->Clone("h_L00K00G40_Boosted");
  TH1D* h_L00K00G60_Boosted = hSMNoBoost->Clone("h_L00K00G60_Boosted");

  ///// ----- fill the unboosted histograms -----------
  trSM->Draw("dijetPt>>hSMNoBoost", cutsNoBoost,"goff");
  trSM2->Draw("dijetPt>>hSMNoBoost2", cutsNoBoostWt,"goff");
  tr_L01K00G00->Draw("dijetPt>>h_L01K00G00_NoBoost", cutsNoBoostWt,"goff");
  tr_L03K00G00->Draw("dijetPt>>h_L03K00G00_NoBoost", cutsNoBoostWt,"goff");
  tr_L05K00G00->Draw("dijetPt>>h_L05K00G00_NoBoost", cutsNoBoostWt,"goff");
  tr_L07K00G00->Draw("dijetPt>>h_L07K00G00_NoBoost", cutsNoBoost,"goff");
  tr_L09K00G00->Draw("dijetPt>>h_L09K00G00_NoBoost", cutsNoBoost,"goff");
  tr_L11K00G00->Draw("dijetPt>>h_L11K00G00_NoBoost", cutsNoBoost,"goff");
  tr_L00K05G00->Draw("dijetPt>>h_L00K05G00_NoBoost", cutsNoBoostWt,"goff");
  tr_L00K11G00->Draw("dijetPt>>h_L00K11G00_NoBoost", cutsNoBoost,"goff");
  tr_L00K16G00->Draw("dijetPt>>h_L00K16G00_NoBoost", cutsNoBoost,"goff");
  tr_L00K20G00->Draw("dijetPt>>h_L00K20G00_NoBoost", cutsNoBoost,"goff");
  tr_L00K00G11->Draw("dijetPt>>h_L00K00G11_NoBoost", cutsNoBoost,"goff");
  tr_L00K00G40->Draw("dijetPt>>h_L00K00G40_NoBoost", cutsNoBoost,"goff");
  tr_L00K00G60->Draw("dijetPt>>h_L00K00G60_NoBoost", cutsNoBoost,"goff");

  ///// ----- now fill the boosted histograms -----------
  trSM->Draw("GroomedJet_CA8_pt[0]>>hSMBoosted", cutsBoosted,"goff");
  trSM2->Draw("GroomedJet_CA8_pt[0]>>hSMBoosted2", cutsBoostedWt,"goff");
  tr_L01K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L01K00G00_Boosted", cutsBoostedWt,"goff");
  tr_L03K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L03K00G00_Boosted", cutsBoostedWt,"goff");
  tr_L05K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L05K00G00_Boosted", cutsBoostedWt,"goff");
  tr_L07K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L07K00G00_Boosted", cutsBoosted,"goff");
  tr_L09K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L09K00G00_Boosted", cutsBoosted,"goff");
  tr_L11K00G00->Draw("GroomedJet_CA8_pt[0]>>h_L11K00G00_Boosted", cutsBoosted,"goff");
  tr_L00K05G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K05G00_Boosted", cutsBoostedWt,"goff");
  tr_L00K11G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K11G00_Boosted", cutsBoosted,"goff");
  tr_L00K16G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K16G00_Boosted", cutsBoosted,"goff");
  tr_L00K20G00->Draw("GroomedJet_CA8_pt[0]>>h_L00K20G00_Boosted", cutsBoosted,"goff");
  tr_L00K00G11->Draw("GroomedJet_CA8_pt[0]>>h_L00K00G11_Boosted", cutsBoosted,"goff");
  tr_L00K00G40->Draw("GroomedJet_CA8_pt[0]>>h_L00K00G40_Boosted", cutsBoosted,"goff");
  tr_L00K00G60->Draw("GroomedJet_CA8_pt[0]>>h_L00K00G60_Boosted", cutsBoosted,"goff");


  // --- normalization scales ------ 
  const double SM_scale   = 2.729 / 149395; // SM: lambda=0, dkappa=0, dg1=0
  const double L01K00G00_scale = 2.730 / 90562;
  const double L03K00G00_scale = 2.736 / 136932;
  const double L05K00G00_scale = 2.760 / 137481;
  const double L07K00G00_scale = 2.793 / 146345;
  const double L09K00G00_scale = 2.830 / 136427;
  const double L11K00G00_scale = 2.890 / 138886;

  const double L00K11G00_scale = 2.760 / 130403;
  const double L00K16G00_scale = 2.848 / 139865;
  const double L00K20G00_scale = 2.947 / 129415;

  const double L00K00G11_scale = 2.729 / 129386;
  const double L00K00G40_scale = 2.792 / 124954;
  const double L00K00G60_scale = 2.940 / 127922;

  hSMNoBoost->Scale(SM_scale);
//   h_L01K00G00_NoBoost->Scale(L01K00G00_scale);
//   h_L03K00G00_NoBoost->Scale(L03K00G00_scale);
//   h_L05K00G00_NoBoost->Scale(L05K00G00_scale);
  h_L07K00G00_NoBoost->Scale(L07K00G00_scale);
  h_L09K00G00_NoBoost->Scale(L09K00G00_scale);
  h_L11K00G00_NoBoost->Scale(L11K00G00_scale);
  h_L00K11G00_NoBoost->Scale(L00K11G00_scale);
  h_L00K16G00_NoBoost->Scale(L00K16G00_scale);
  h_L00K20G00_NoBoost->Scale(L00K20G00_scale);
  h_L00K00G11_NoBoost->Scale(L00K00G11_scale);
  h_L00K00G40_NoBoost->Scale(L00K00G40_scale);
  h_L00K00G60_NoBoost->Scale(L00K00G60_scale);


  hSMBoosted->Scale(SM_scale);
//   h_L01K00G00_Boosted->Scale(L01K00G00_scale);
//   h_L03K00G00_Boosted->Scale(L03K00G00_scale);
//   h_L05K00G00_Boosted->Scale(L05K00G00_scale);

  float kscale = 3.;

//   h_L01K00G00_Boosted->Scale(kscale);
//   h_L03K00G00_Boosted->Scale(kscale);
//   h_L05K00G00_Boosted->Scale(kscale);

  h_L07K00G00_Boosted->Scale(L07K00G00_scale);
  h_L09K00G00_Boosted->Scale(L09K00G00_scale);
  h_L11K00G00_Boosted->Scale(L11K00G00_scale);
  h_L00K11G00_Boosted->Scale(L00K11G00_scale);
  h_L00K16G00_Boosted->Scale(L00K16G00_scale);
  h_L00K20G00_Boosted->Scale(L00K20G00_scale);
  h_L00K00G11_Boosted->Scale(L00K00G11_scale);
  h_L00K00G40_Boosted->Scale(L00K00G40_scale);
  h_L00K00G60_Boosted->Scale(L00K00G60_scale);




  //----- combine boosted & unboosted histograms ------
  /*
  TH1D* hSM = hSMBoosted->Clone("hSM");
  TH1D* hSM2 = hSMBoosted2->Clone("hSM2");
  TH1D* h_L01K00G00 = h_L01K00G00_Boosted->Clone("h_L01K00G00");
  TH1D* h_L03K00G00 = h_L03K00G00_Boosted->Clone("h_L03K00G00");
  TH1D* h_L05K00G00 = h_L05K00G00_Boosted->Clone("h_L05K00G00");
  TH1D* h_L07K00G00 = h_L07K00G00_Boosted->Clone("h_L07K00G00");
  TH1D* h_L09K00G00 = h_L09K00G00_Boosted->Clone("h_L09K00G00");
  TH1D* h_L11K00G00 = h_L11K00G00_Boosted->Clone("h_L11K00G00");
  TH1D* h_L00K11G00 = h_L00K11G00_Boosted->Clone("h_L00K11G00");
  TH1D* h_L00K16G00 = h_L00K16G00_Boosted->Clone("h_L00K16G00");
  TH1D* h_L00K20G00 = h_L00K20G00_Boosted->Clone("h_L00K20G00");
  TH1D* h_L00K00G11 = h_L00K00G11_Boosted->Clone("h_L00K00G11");
  TH1D* h_L00K00G40 = h_L00K00G40_Boosted->Clone("h_L00K00G40");
  TH1D* h_L00K00G60 = h_L00K00G60_Boosted->Clone("h_L00K00G60");



  TH1D* hSM = hSMNoBoost->Clone("hSM");
  TH1D* hSM2 = hSMBoosted2->Clone("hSM2");
  TH1D* h_L01K00G00 = h_L01K00G00_NoBoost->Clone("h_L01K00G00");
  TH1D* h_L03K00G00 = h_L03K00G00_NoBoost->Clone("h_L03K00G00");
  TH1D* h_L05K00G00 = h_L05K00G00_NoBoost->Clone("h_L05K00G00");
  TH1D* h_L07K00G00 = h_L07K00G00_NoBoost->Clone("h_L07K00G00");
  TH1D* h_L09K00G00 = h_L09K00G00_NoBoost->Clone("h_L09K00G00");
  TH1D* h_L11K00G00 = h_L11K00G00_NoBoost->Clone("h_L11K00G00");
  TH1D* h_L00K11G00 = h_L00K11G00_NoBoost->Clone("h_L00K11G00");
  TH1D* h_L00K16G00 = h_L00K16G00_NoBoost->Clone("h_L00K16G00");
  TH1D* h_L00K20G00 = h_L00K20G00_NoBoost->Clone("h_L00K20G00");
  TH1D* h_L00K00G11 = h_L00K00G11_NoBoost->Clone("h_L00K00G11");
  TH1D* h_L00K00G40 = h_L00K00G40_NoBoost->Clone("h_L00K00G40");
  TH1D* h_L00K00G60 = h_L00K00G60_NoBoost->Clone("h_L00K00G60");
  hSM->Add(hSMBoosted);
  hSM2->Add(hSMBoosted2);
  h_L01K00G00->Add(h_L01K00G00_Boosted);
  h_L03K00G00->Add(h_L03K00G00_Boosted);
  h_L05K00G00->Add(h_L05K00G00_Boosted);
  h_L07K00G00->Add(h_L07K00G00_Boosted);
  h_L09K00G00->Add(h_L09K00G00_Boosted);
  h_L11K00G00->Add(h_L11K00G00_Boosted);
  h_L00K11G00->Add(h_L00K11G00_Boosted);
  h_L00K16G00->Add(h_L00K16G00_Boosted);
  h_L00K20G00->Add(h_L00K20G00_Boosted);
  h_L00K00G11->Add(h_L00K00G11_Boosted);
  h_L00K00G40->Add(h_L00K00G40_Boosted);
  h_L00K00G60->Add(h_L00K00G60_Boosted);

  */

  // --- divide aTGC histograms by the SM histogram ------ 
  h_L01K00G00_NoBoost->Divide(hSMNoBoost2);
  h_L03K00G00_NoBoost->Divide(hSMNoBoost2);
  h_L05K00G00_NoBoost->Divide(hSMNoBoost2);
  h_L07K00G00_NoBoost->Divide(hSMNoBoost);
  h_L09K00G00_NoBoost->Divide(hSMNoBoost);
  h_L11K00G00_NoBoost->Divide(hSMNoBoost);
  h_L00K05G00_NoBoost->Divide(hSMNoBoost);
  h_L00K11G00_NoBoost->Divide(hSMNoBoost);
  h_L00K16G00_NoBoost->Divide(hSMNoBoost);
  h_L00K20G00_NoBoost->Divide(hSMNoBoost);
  h_L00K00G11_NoBoost->Divide(hSMNoBoost);
  h_L00K00G40_NoBoost->Divide(hSMNoBoost);
  h_L00K00G60_NoBoost->Divide(hSMNoBoost);

  h_L01K00G00_Boosted->Divide(hSMBoosted2);
  h_L03K00G00_Boosted->Divide(hSMBoosted2);
  h_L05K00G00_Boosted->Divide(hSMBoosted2);
  h_L07K00G00_Boosted->Divide(hSMBoosted);
  h_L09K00G00_Boosted->Divide(hSMBoosted);
  h_L11K00G00_Boosted->Divide(hSMBoosted);
  h_L00K05G00_Boosted->Divide(hSMBoosted);
  h_L00K11G00_Boosted->Divide(hSMBoosted);
  h_L00K16G00_Boosted->Divide(hSMBoosted);
  h_L00K20G00_Boosted->Divide(hSMBoosted);
  h_L00K00G11_Boosted->Divide(hSMBoosted);
  h_L00K00G40_Boosted->Divide(hSMBoosted);
  h_L00K00G60_Boosted->Divide(hSMBoosted);



  TH1D* h_L01K00G00 = getWeightedAverage(h_L01K00G00_NoBoost, h_L01K00G00_Boosted,"h_L01K00G00");
  TH1D* h_L03K00G00 = getWeightedAverage(h_L03K00G00_NoBoost, h_L03K00G00_Boosted, "h_L03K00G00");
  TH1D* h_L05K00G00 = getWeightedAverage(h_L05K00G00_NoBoost, h_L05K00G00_Boosted, "h_L05K00G00");
  TH1D* h_L07K00G00 = getWeightedAverage(h_L07K00G00_NoBoost, h_L07K00G00_Boosted, "h_L07K00G00");
  TH1D* h_L09K00G00 = getWeightedAverage(h_L09K00G00_NoBoost, h_L09K00G00_Boosted, "h_L09K00G00");
  TH1D* h_L11K00G00 = getWeightedAverage(h_L11K00G00_NoBoost, h_L11K00G00_Boosted, "h_L11K00G00");
  TH1D* h_L00K05G00 = getWeightedAverage(h_L00K05G00_NoBoost, h_L00K05G00_Boosted, "h_L00K05G00");
  TH1D* h_L00K11G00 = getWeightedAverage(h_L00K11G00_NoBoost, h_L00K11G00_Boosted, "h_L00K11G00");
  TH1D* h_L00K16G00 = getWeightedAverage(h_L00K16G00_NoBoost, h_L00K16G00_Boosted, "h_L00K16G00");
  TH1D* h_L00K20G00 = getWeightedAverage(h_L00K20G00_NoBoost, h_L00K20G00_Boosted, "h_L00K20G00");
  TH1D* h_L00K00G11 = getWeightedAverage(h_L00K00G11_NoBoost, h_L00K00G11_Boosted, "h_L00K00G11");
  TH1D* h_L00K00G40 = getWeightedAverage(h_L00K00G40_NoBoost, h_L00K00G40_Boosted, "h_L00K00G40");
  TH1D* h_L00K00G60 = getWeightedAverage(h_L00K00G60_NoBoost, h_L00K00G60_Boosted, "h_L00K00G60");

//   h_L01K00G00->Divide(hSM2);
//   h_L03K00G00->Divide(hSM2);
//   h_L05K00G00->Divide(hSM2);
//   h_L07K00G00->Divide(hSM);
//   h_L09K00G00->Divide(hSM);
//   h_L11K00G00->Divide(hSM);
//   h_L00K11G00->Divide(hSM);
//   h_L00K16G00->Divide(hSM);
//   h_L00K20G00->Divide(hSM);
//   h_L00K00G11->Divide(hSM);
//   h_L00K00G40->Divide(hSM);
//   h_L00K00G60->Divide(hSM);


  // --- plot histograms ------ 
  gROOT->ProcessLine(".L ~/tdrstyle.C");
  setTDRStyle();
  tdrStyle->SetErrorX(0.5);
  tdrStyle->SetPadLeftMargin(0.18);
  tdrStyle->SetPadRightMargin(0.08);
  tdrStyle->SetLegendBorderSize(0);
  tdrStyle->SetTitleYOffset(1.3);
  tdrStyle->SetOptStat(0); 
  tdrStyle->SetOptFit(0); 


  // --- Plot non-boosted events ------ 
  TCanvas* can00 = new TCanvas("can00","",500,500);
  h_L01K00G00_NoBoost->GetYaxis()->SetRangeUser(0.3, 80);
  h_L01K00G00_NoBoost->GetXaxis()->SetMoreLogLabels();
  h_L01K00G00_NoBoost->GetXaxis()->SetNoExponent();
  h_L05K00G00_NoBoost->SetLineColor(4);
  h_L05K00G00_NoBoost->SetMarkerColor(4);
  h_L11K00G00_NoBoost->SetLineColor(2);
  h_L11K00G00_NoBoost->SetMarkerColor(2);
  h_L00K11G00_NoBoost->SetMarkerStyle(22);
  h_L00K16G00_NoBoost->SetMarkerStyle(22);
  h_L00K11G00_NoBoost->SetMarkerSize(1.3);
  h_L00K16G00_NoBoost->SetMarkerSize(1.3);
  h_L00K11G00_NoBoost->SetLineStyle(2);
  h_L00K16G00_NoBoost->SetLineStyle(2);
  h_L00K11G00_NoBoost->SetLineColor(4);
  h_L00K11G00_NoBoost->SetMarkerColor(4);
  h_L00K16G00_NoBoost->SetLineColor(2);
  h_L00K16G00_NoBoost->SetMarkerColor(2);
  h_L00K00G40_NoBoost->SetMarkerStyle(21);
  h_L00K00G60_NoBoost->SetMarkerStyle(21);
  h_L00K00G40_NoBoost->SetLineStyle(3);
  h_L00K00G60_NoBoost->SetLineStyle(3);
  h_L00K00G40_NoBoost->SetLineColor(4);
  h_L00K00G40_NoBoost->SetMarkerColor(4);
  h_L00K00G60_NoBoost->SetLineColor(2);
  h_L00K00G60_NoBoost->SetMarkerColor(2);
  h_L01K00G00_NoBoost->Draw();
  h_L05K00G00_NoBoost->Draw("same");
  h_L11K00G00_NoBoost->Draw("same");
  h_L00K11G00_NoBoost->Draw("same");
  h_L00K16G00_NoBoost->Draw("same");
  h_L00K00G40_NoBoost->Draw("same");
  h_L00K00G60_NoBoost->Draw("same");
  TLegend* legend = new TLegend(0.24,0.55,0.64,0.9);
  legend->SetFillColor(0);
  legend->AddEntry(h_L01K00G00_NoBoost, "#lambda = 0.01", "PL");  
  legend->AddEntry(h_L05K00G00_NoBoost, "#lambda = 0.05", "PL");  
  legend->AddEntry(h_L11K00G00_NoBoost, "#lambda = 0.11", "PL");  
  legend->AddEntry(h_L00K11G00_NoBoost, "#Delta#kappa = 0.11", "PL");  
  legend->AddEntry(h_L00K16G00_NoBoost, "#Delta#kappa = 0.16", "PL");  
  legend->AddEntry(h_L00K00G40_NoBoost, "#Deltag_{1} = 0.40", "PL");  
  legend->AddEntry(h_L00K00G60_NoBoost, "#Deltag_{1} = 0.60", "PL");  
  legend->Draw();
  can00->SetLogx(1);
  can00->SetLogy(1);
  can00->SaveAs("Fig_aTGC_NoBoost.png");
  can00->SaveAs("Fig_aTGC_NoBoost.pdf");




  // --- Plot boosted events ------ 
  TCanvas* can11 = new TCanvas("can11","",500,500);
  h_L01K00G00_Boosted->GetXaxis()->SetTitle("Jet p_{T} (GeV)");
  h_L01K00G00_Boosted->GetYaxis()->SetRangeUser(0.3, 500);
  h_L01K00G00_Boosted->GetXaxis()->SetMoreLogLabels();
  h_L01K00G00_Boosted->GetXaxis()->SetNoExponent();
  h_L05K00G00_Boosted->SetLineColor(4);
  h_L05K00G00_Boosted->SetMarkerColor(4);
  h_L11K00G00_Boosted->SetLineColor(2);
  h_L11K00G00_Boosted->SetMarkerColor(2);
  h_L00K11G00_Boosted->SetMarkerStyle(22);
  h_L00K16G00_Boosted->SetMarkerStyle(22);
  h_L00K11G00_Boosted->SetMarkerSize(1.3);
  h_L00K16G00_Boosted->SetMarkerSize(1.3);
  h_L00K11G00_Boosted->SetLineStyle(2);
  h_L00K16G00_Boosted->SetLineStyle(2);
  h_L00K11G00_Boosted->SetLineColor(4);
  h_L00K11G00_Boosted->SetMarkerColor(4);
  h_L00K16G00_Boosted->SetLineColor(2);
  h_L00K16G00_Boosted->SetMarkerColor(2);
  h_L00K00G40_Boosted->SetMarkerStyle(21);
  h_L00K00G60_Boosted->SetMarkerStyle(21);
  h_L00K00G40_Boosted->SetLineStyle(3);
  h_L00K00G60_Boosted->SetLineStyle(3);
  h_L00K00G40_Boosted->SetLineColor(4);
  h_L00K00G40_Boosted->SetMarkerColor(4);
  h_L00K00G60_Boosted->SetLineColor(2);
  h_L00K00G60_Boosted->SetMarkerColor(2);
  h_L01K00G00_Boosted->Draw();
  h_L05K00G00_Boosted->Draw("same");
  h_L11K00G00_Boosted->Draw("same");
  h_L00K11G00_Boosted->Draw("same");
  h_L00K16G00_Boosted->Draw("same");
  h_L00K00G40_Boosted->Draw("same");
  h_L00K00G60_Boosted->Draw("same");
  TLegend* legend = new TLegend(0.24,0.55,0.64,0.9);
  legend->SetFillColor(0);
  legend->AddEntry(h_L01K00G00_Boosted, "#lambda = 0.01", "PL");  
  legend->AddEntry(h_L05K00G00_Boosted, "#lambda = 0.05", "PL");  
  legend->AddEntry(h_L11K00G00_Boosted, "#lambda = 0.11", "PL");  
  legend->AddEntry(h_L00K11G00_Boosted, "#Delta#kappa = 0.11", "PL");  
  legend->AddEntry(h_L00K16G00_Boosted, "#Delta#kappa = 0.16", "PL");  
  legend->AddEntry(h_L00K00G40_Boosted, "#Deltag_{1} = 0.40", "PL");  
  legend->AddEntry(h_L00K00G60_Boosted, "#Deltag_{1} = 0.60", "PL");  
  legend->Draw();
  can11->SetLogx(1);
  can11->SetLogy(1);
  can11->SaveAs("Fig_aTGC_Boosted.png");
  can11->SaveAs("Fig_aTGC_Boosted.pdf");




  ///---- combine the boosted & unboosted events ----
  TCanvas* can22 = new TCanvas("can22","",500,500);
  h_L01K00G00->GetXaxis()->SetTitle("Hadronic W p_{T} (GeV)");
  h_L01K00G00->GetYaxis()->SetRangeUser(0.3, 90);
  h_L01K00G00->GetXaxis()->SetMoreLogLabels();
  h_L01K00G00->GetXaxis()->SetNoExponent();

  h_L05K00G00->SetLineColor(4);
  h_L05K00G00->SetMarkerColor(4);
  h_L11K00G00->SetLineColor(2);
  h_L11K00G00->SetMarkerColor(2);
  h_L00K11G00->SetMarkerStyle(22);
  h_L00K16G00->SetMarkerStyle(22);
  h_L00K11G00->SetMarkerSize(1.3);
  h_L00K16G00->SetMarkerSize(1.3);
  h_L00K11G00->SetLineStyle(2);
  h_L00K16G00->SetLineStyle(2);
  h_L00K11G00->SetLineColor(4);
  h_L00K11G00->SetMarkerColor(4);
  h_L00K16G00->SetLineColor(2);
  h_L00K16G00->SetMarkerColor(2);
  h_L00K00G40->SetMarkerStyle(21);
  h_L00K00G60->SetMarkerStyle(21);
  h_L00K00G40->SetLineStyle(3);
  h_L00K00G60->SetLineStyle(3);
  h_L00K00G40->SetLineColor(4);
  h_L00K00G40->SetMarkerColor(4);
  h_L00K00G60->SetLineColor(2);
  h_L00K00G60->SetMarkerColor(2);


 // --- Fit to a quadratic function ------ 
 // TF1 *func = new TF1("func", "1.+ [0]*x +[1]*x*x", 100., 500.);
  //  TF1 *func = new TF1("func", "[0]+[1]*x*x", 100., 500.);
  TF1 *func = new TF1("func", "[0]+[1]*x+[2]*x*x", 50., 1500.);
  TF1 *func2 = new TF1("func2", "[0]+[1]*x*x", 50., 1500.);
  func->SetLineWidth(3);
  func->SetLineColor(1);
  h_L01K00G00->Fit("func","I","");
  h_L03K00G00->Fit("func","I0","");
  func->SetLineColor(4);
  h_L05K00G00->Fit("func","I","same");
  h_L07K00G00->Fit("func","I0","");
  h_L09K00G00->Fit("func","I0","");
  func->SetLineColor(2);
  h_L11K00G00->Fit("func","I","same");
  func->SetLineStyle(2);
  func->SetLineColor(4);
  h_L00K11G00->Fit("func","I","same");
  func->SetLineColor(2);
  h_L00K16G00->Fit("func","I","same");
  h_L00K20G00->Fit("func","I0","");
  h_L00K00G11->Fit("func","I0",""); //-- looks pretty flat ---
  func->SetLineStyle(3);
  func->SetLineColor(4);
  h_L00K00G40->Fit("func","I","same");
  func->SetLineColor(2);
  h_L00K00G60->Fit("func","I","same");
  TLegend* legend = new TLegend(0.24,0.55,0.64,0.9);
  legend->SetFillColor(0);
  legend->AddEntry(h_L01K00G00, "#lambda = 0.01", "PL");  
  legend->AddEntry(h_L05K00G00, "#lambda = 0.05", "PL");  
  legend->AddEntry(h_L11K00G00, "#lambda = 0.11", "PL");  
  legend->AddEntry(h_L00K11G00, "#Delta#kappa = 0.11", "PL");  
  legend->AddEntry(h_L00K16G00, "#Delta#kappa = 0.16", "PL");  
  legend->AddEntry(h_L00K00G40, "#Deltag_{1} = 0.40", "PL");  
  legend->AddEntry(h_L00K00G60, "#Deltag_{1} = 0.60", "PL");  
  legend->Draw();
  can22->SetLogx(1);
  can22->SetLogy(1);
  can22->SaveAs("Fig_aTGC.png");
  can22->SaveAs("Fig_aTGC.pdf");


  //------- Read C0, C1, C2 for all points -----------
  const int numLambdaBins = 6;
  const int numKappaBins = 3;
  const int numG1Bins = 3;

  TF1 fit_L[numLambdaBins];
  TF1 fit_K[numKappaBins];
  TF1 fit_G1[numG1Bins];
  fit_L[0] = h_L01K00G00->GetFunction("func");
  fit_L[1] = h_L03K00G00->GetFunction("func");
  fit_L[2] = h_L05K00G00->GetFunction("func");
  fit_L[3] = h_L07K00G00->GetFunction("func");
  fit_L[4] = h_L09K00G00->GetFunction("func");
  fit_L[5] = h_L11K00G00->GetFunction("func");
  fit_K[0] = h_L00K11G00->GetFunction("func");
  fit_K[1] = h_L00K16G00->GetFunction("func");
  fit_K[2] = h_L00K20G00->GetFunction("func");
  fit_G1[0] = h_L00K00G11->GetFunction("func");
  fit_G1[1] = h_L00K00G40->GetFunction("func");
  fit_G1[2] = h_L00K00G60->GetFunction("func");

  //------- Lambda values and errors ---------
  float Lambda[] = {0.01, 0.03, 0.05, 0.07, 0.09, 0.11};
  float errLambda[] = {0., 0., 0., 0., 0., 0.};
  float L_C0val[numLambdaBins];
  float L_C0err[numLambdaBins];
  float L_C1val[numLambdaBins];
  float L_C1err[numLambdaBins];
  float L_C2val[numLambdaBins];
  float L_C2err[numLambdaBins];

  for(int i=0; i<numLambdaBins; ++i) {
    L_C0val[i] = fit_L[i]->GetParameter(0);
    L_C0err[i] = fit_L[i]->GetParError(0);
    L_C1val[i] = fit_L[i]->GetParameter(1);
    L_C1err[i] = fit_L[i]->GetParError(1);
    L_C2val[i] = fit_L[i]->GetParameter(2);
    L_C2err[i] = fit_L[i]->GetParError(2);
  }

  //------- Kappa values and errors ---------
  float Kappa[] = {0.11, 0.16, 0.20};
  float errKappa[] = {0., 0., 0.};
  float K_C0val[numKappaBins];
  float K_C0err[numKappaBins];
  float K_C1val[numKappaBins];
  float K_C1err[numKappaBins];
  float K_C2val[numKappaBins];
  float K_C2err[numKappaBins];

  for(int i=0; i<numKappaBins; ++i) {
    K_C0val[i] = fit_K[i]->GetParameter(0);
    K_C0err[i] = fit_K[i]->GetParError(0);
    K_C1val[i] = fit_K[i]->GetParameter(1);
    K_C1err[i] = fit_K[i]->GetParError(1);
    K_C2val[i] = fit_K[i]->GetParameter(2);
    K_C2err[i] = fit_K[i]->GetParError(2);
  }

  //------- G1 values and errors ---------
  float G1[] = {0.11, 0.40, 0.60};
  float errG1[] = {0., 0., 0.};
  float G1_C0val[numG1Bins];
  float G1_C0err[numG1Bins];
  float G1_C1val[numG1Bins];
  float G1_C1err[numG1Bins];
  float G1_C2val[numG1Bins];
  float G1_C2err[numG1Bins];

  for(int i=0; i<numG1Bins; ++i) {
    G1_C0val[i] = fit_G1[i]->GetParameter(0);
    G1_C0err[i] = fit_G1[i]->GetParError(0);
    G1_C1val[i] = fit_G1[i]->GetParameter(1);
    G1_C1err[i] = fit_G1[i]->GetParError(1);
    G1_C2val[i] = fit_G1[i]->GetParameter(2);
    G1_C2err[i] = fit_G1[i]->GetParError(2);
  }

  //------- Graph of Lambda C0, C1, C2 ---------
  cout << "=============================================" << endl;
  cout << "------ Graph of Lambda ------" << endl;
  cout << "=============================================" << endl;

  TGraphErrors* grLC0 = new TGraphErrors( numLambdaBins, Lambda, L_C0val, errLambda, L_C0err);
  TGraphErrors* grLC1 = new TGraphErrors( numLambdaBins, Lambda, L_C1val, errLambda, L_C1err);
  grLC1->SetMarkerStyle(4);
  TGraphErrors* grLC2 = new TGraphErrors( numLambdaBins, Lambda, L_C2val, errLambda, L_C2err);
  grLC2->SetMarkerStyle(22);


  TCanvas* can33 = new TCanvas("can33","",500,500);
  grLC0->GetYaxis()->SetRangeUser(5e-09, 50.);
  grLC0->GetXaxis()->SetTitle("#lambda");
  grLC0->GetYaxis()->SetTitle("C_{i}");
  grLC0->Draw("ap");
  grLC0->Fit("func2","","");
  grLC1->Draw("p");
  grLC1->Fit("func2","","");
  grLC2->Draw("p");
  grLC2->Fit("func2","","");
  TLegend* legend = new TLegend(0.7,0.16,0.88,0.35);
  legend->SetFillColor(0);
  legend->AddEntry(grLC0, "C0", "P");  
  legend->AddEntry(grLC1, "C1", "P");  
  legend->AddEntry(grLC2, "C2", "P");  
  legend->Draw();
  can33->SetLogy(1);
  can33->SaveAs("Fig_lambda.png");
  can33->SaveAs("Fig_lambda.pdf");


  //------- Graph of Kappa C0, C1, C2 ---------
  cout << "=============================================" << endl;
  cout << "------ Graph of Kappa C0, C1, C2 ------" << endl;
  cout << "=============================================" << endl;

  TGraphErrors* grKC0 = new TGraphErrors( numKappaBins, Kappa, K_C0val, errKappa, K_C0err);
  TGraphErrors* grKC1 = new TGraphErrors( numKappaBins, Kappa, K_C1val, errKappa, K_C1err);
  grKC1->SetMarkerStyle(4);
  TGraphErrors* grKC2 = new TGraphErrors( numKappaBins, Kappa, K_C2val, errKappa, K_C2err);
  grKC2->SetMarkerStyle(22);

  TCanvas* can44 = new TCanvas("can44","",500,500);
  grKC0->GetYaxis()->SetRangeUser(5e-09, 50.);
  grKC0->GetXaxis()->SetTitle("#Delta_{#kappa}");
  grKC0->GetYaxis()->SetTitle("C_{i}'");
  grKC0->Draw("ap");
  grKC0->Fit("func2","","");
  grKC1->Draw("p");
  grKC1->Fit("func2","","");
  grKC2->Draw("p");
  grKC2->Fit("func2","","");
  TLegend* legend = new TLegend(0.7,0.16,0.88,0.35);
  legend->SetFillColor(0);
  legend->AddEntry(grKC0, "C0'", "P");  
  legend->AddEntry(grKC1, "C1'", "P");  
  legend->AddEntry(grKC2, "C2'", "P");  
  legend->Draw();
  can44->SetLogy(1);
  can44->SaveAs("Fig_kappa.png");
  can44->SaveAs("Fig_kappa.pdf");


  //------- Graph of G1 C0, C1, C2 ---------
  cout << "=============================================" << endl;
  cout << "------ Graph of G1 C0, C1, C2 ------" << endl;
  cout << "=============================================" << endl;

  TGraphErrors* grG1C0 = new TGraphErrors( numG1Bins, G1, G1_C0val, errG1, G1_C0err);
  TGraphErrors* grG1C1 = new TGraphErrors( numG1Bins, G1, G1_C1val, errG1, G1_C1err);
  grG1C1->SetMarkerStyle(4);
  TGraphErrors* grG1C2 = new TGraphErrors( numG1Bins, G1, G1_C2val, errG1, G1_C2err);
  grG1C2->SetMarkerStyle(22);

  TCanvas* can55 = new TCanvas("can55","",500,500);
  grG1C0->GetYaxis()->SetRangeUser(5e-09, 50.);
  grG1C0->GetXaxis()->SetTitle("#Delta_{g1}");
  grG1C0->GetYaxis()->SetTitle("C_{i}''");
  grG1C0->Draw("ap");
  grG1C0->Fit("func2","","");
  grG1C1->Draw("p");
  grG1C1->Fit("func2","","");
  grG1C2->Draw("p");
  grG1C2->Fit("func2","","");
  TLegend* legend = new TLegend(0.7,0.16,0.88,0.35);
  legend->SetFillColor(0);
  legend->AddEntry(grG1C0, "C0''", "P");  
  legend->AddEntry(grG1C1, "C1''", "P");  
  legend->AddEntry(grG1C2, "C2''", "P");  
  legend->Draw();
  can55->SetLogy(1);
  can55->SaveAs("Fig_g1.png");
  can55->SaveAs("Fig_g1.pdf");


//   cout << "p0 = " << fit_L01K00G00_C0 << " +- " << fit_L01K00G00_C0err << endl;
//   cout << "p1 = " << fit_L01K00G00_C1 << " +- " << fit_L01K00G00_C0err << endl;
//   cout << "p2 = " << fit_L01K00G00_C2 << " +- " << fit_L01K00G00_C2err << endl;



}
コード例 #13
0
ファイル: plotFigure.C プロジェクト: kurtejung/PurdueForest
void plotBalance(int cbin,
		 TString infname,
		 TString pythia,
		 TString mix,
		 bool drawXLabel,
		 bool drawLeg)
{

  bool showPbPb = 0;
  if(iPlot == 0 || iPlot == 3) showPbPb = 1;

  if(iPlot != 3) dijet = dijet&&deltaPhi;

  TCut centHF("");
  TCut centNtrk("");

  if(centMode == 0){
    cout<<"Obsolete centrality usage."<<endl;
    return;
    if(cbin==0) centHF = "bin>=20 && bin<26";
    if(cbin==1) centHF = "bin>=26 && bin<27";
    if(cbin==2) centHF = "bin>=27 && bin<28";
    if(cbin==3) centHF = "bin>=28 && bin<29";
    if(cbin==4) centHF = "bin>=29 && bin<31";
    if(cbin==5) centHF = "bin>=31";

    if(cbin==0) centNtrk = "ntrk >= 180";
    if(cbin==1) centNtrk = "150 <= ntrk && ntrk < 180";
    if(cbin==2) centNtrk = "110 <= ntrk && ntrk < 150";
    if(cbin==3) centNtrk = "90 <= ntrk && ntrk < 150";
    if(cbin==4) centNtrk = "60 <= ntrk && ntrk < 90";
    if(cbin==5) centNtrk = "ntrk < 60";
  }

  if(centMode == 1){
    centHF = hfPlusBins[cbin];
    centNtrk = centHF;
  }

  cout<<"plotting ntrk bin : "<<cbin<<endl;

  // open the data file

  if(iPlot > 100) entryMode = 1;

  string treeName = "ntdijet";
  string wName = "ntw";
  if(entryMode == 1){
    treeName = "ntjet";
    wName = "ntjetw";
  }

  if(entryMode == 2){
    treeName = "nttrk";
    wName = "nttrkw";
  }

  TFile *inf = new TFile(infname.Data());
  TTree *nt =(TTree*)inf->FindObjectAny(treeName.data());
  TTree *ntevt =(TTree*)inf->FindObjectAny("ntevt");
  if(entryMode < 1) nt->AddFriend(ntevt);

  // open the pythia (MC) file
  TFile *infReference = new TFile(pythia.Data());
  TTree *ntReference;
  TTree *ntevtReference;

  ntReference = (TTree*) infReference->FindObjectAny(treeName.data());
  ntevtReference = (TTree*) infReference->FindObjectAny("ntevt");
  if(entryMode < 1) ntReference->AddFriend(ntevtReference);
  
  // open the datamix file
  TFile *infMix = new TFile(mix.Data());
  TTree *ntMix =(TTree*)infMix->FindObjectAny(treeName.data());
  TTree *ntevtMix =(TTree*)infMix->FindObjectAny("ntevt");
  //  TFile *infW = new TFile("weights_hydjet.root");
  //  TTree *ntw =(TTree*)infW->FindObjectAny("ntw");

  TTree *ntw =(TTree*)infMix->FindObjectAny(wName.data());
  ntMix->AddFriend(ntw);
  if(entryMode < 1) ntMix->AddFriend(ntevtMix);

  int Nbin = 10;
  double max = 1.;
  double min = 0;

  if(iPlot == 1 || iPlot == 21 || iPlot == 22){
    Nbin = 20;
    max = 2;
    min = -2;
  };

  if(iPlot == 3){
    Nbin = 30;
    max = pi;
  };

  if(iPlot == 8){
    Nbin = 50;
    max = 25;
    min = -25;
  };

  if(iPlot == 9){
    Nbin = 50;
    max = 250;
  };

  if(iPlot == 11 || iPlot == 12){
    Nbin = 50;
    max = 25;
  };

  if(iPlot == 13 || iPlot == 14){
    Nbin = 75;
    max = 150;
  }

  if(iPlot == 101){
    Nbin = 20;
    max = 2;
    min = -2;
  }

  // projection histogram
  TH1D *h = new TH1D(Form("h",cbin),"",Nbin,min,max);
  TH1D *hReference = new TH1D(Form("hReference",cbin),"",Nbin,min,max);
  TH1D *hDataMix = new TH1D(Form("hDataMix",cbin),"",Nbin,min,max);

  TH1D *hB = new TH1D(Form("hB",cbin),"",Nbin,min,max);
  TH1D *hReferenceB = new TH1D(Form("hReferenceB",cbin),"",Nbin,min,max);
  TH1D *hDataMixB = new TH1D(Form("hDataMixB",cbin),"",Nbin,min,max);

  TH1D *hFull = new TH1D("hFull","",Nbin,min,max);
  TH1D *hReferenceFull = new TH1D("hReferenceFull","",Nbin,min,max);
  TH1D *hDataMixFull = new TH1D("hDataMixFull","",Nbin,min,max);

  TH1D* hNorm = new TH1D("hNorm","",1000,0,1000);
  TH1D* hNormReference = new TH1D("hNormReference","",1000,0,1000);
  TH1D* hNormDataMix = new TH1D("hNormDataMix","",1000,0,1000);

  hB->SetLineStyle(2);
  hReferenceB->SetLineStyle(2);
  hDataMixB->SetLineStyle(2);

  //  ntReference->SetAlias("pt1","et1");
  //  ntReference->SetAlias("pt2","et2");

  nt->SetAlias("pt1","jtpt1");
  nt->SetAlias("pt2","jtpt2");
  nt->SetAlias("eta1","jteta1");
  nt->SetAlias("eta2","jteta2");
  nt->SetAlias("phi1","jtphi1");
  nt->SetAlias("phi2","jtphi2");
  ntMix->SetAlias("pt1","jtpt1");
  ntMix->SetAlias("pt2","jtpt2");
  ntMix->SetAlias("eta1","jteta1");
  ntMix->SetAlias("eta2","jteta2");
  ntMix->SetAlias("phi1","jtphi1");
  ntMix->SetAlias("phi2","jtphi2");
  ntReference->SetAlias("pt1","jtpt1");
  ntReference->SetAlias("pt2","jtpt2");
  ntReference->SetAlias("eta1","jteta1");
  ntReference->SetAlias("eta2","jteta2");
  ntReference->SetAlias("phi1","jtphi1");
  ntReference->SetAlias("phi2","jtphi2");

  nt->SetAlias("cent","hfp");
  ntMix->SetAlias("cent","hfp");
  ntReference->SetAlias("cent","hfp");

  nt->SetAlias("dphi","acos(cos(phi1-phi2))");
  ntMix->SetAlias("dphi","acos(cos(phi1-phi2))");
  ntReference->SetAlias("dphi","acos(cos(phi1-phi2))");

  if(iPlot == 0){
    nt->SetAlias("var","pt2/pt1");
    ntReference->SetAlias("var","pt2/pt1");
    ntMix->SetAlias("var","pt2/pt1");
  }

  if(iPlot == 1){
    nt->SetAlias("var","(eta1+eta2)/2");
    ntReference->SetAlias("var","(eta1+eta2)/2");
    ntMix->SetAlias("var","(eta1+eta2)/2");
  }

  if(iPlot == 3){
    nt->SetAlias("var","acos(cos(phi1-phi2))");
    ntReference->SetAlias("var","acos(cos(phi1-phi2))");
    ntMix->SetAlias("var","acos(cos(phi1-phi2))");
  }

  if(iPlot == 8){
    nt->SetAlias("var","pu1-pu2");
    ntReference->SetAlias("var","pu1-pu2");
    ntMix->SetAlias("var","pu1-pu2");
  }

  if(iPlot == 11){
    nt->SetAlias("var","pu1");
    ntReference->SetAlias("var","pu1");
    ntMix->SetAlias("var","pu1");
  }

  if(iPlot == 12){
    nt->SetAlias("var","pu2");
    ntReference->SetAlias("var","pu2");
    ntMix->SetAlias("var","pu2");
  }

  if(iPlot == 13){
    nt->SetAlias("var","trkMax1");
    ntReference->SetAlias("var","trkMax1");
    ntMix->SetAlias("var","trkMax1");
  }

  if(iPlot == 14){
    nt->SetAlias("var","trkMax2");
    ntReference->SetAlias("var","trkMax2");
    ntMix->SetAlias("var","trkMax2");
  }

  if(iPlot == 9){
    nt->SetAlias("var","ntrk");
    ntReference->SetAlias("var","ntrk");
    ntMix->SetAlias("var","ntrk");
  }

  if(iPlot == 21){
    nt->SetAlias("var","eta1");
    ntReference->SetAlias("var","eta1");
    ntMix->SetAlias("var","eta1");
  }

  if(iPlot == 22){
    nt->SetAlias("var","eta2");
    ntReference->SetAlias("var","eta2");
    ntMix->SetAlias("var","eta2");
  }



  if(iPlot == 101){
    nt->SetAlias("var","eta");
    ntReference->SetAlias("var","eta");
    ntMix->SetAlias("var","eta");
  }

  if(iPlot == 51){
    nt->SetAlias("var","matchPt1/pt1");
    ntReference->SetAlias("var","matchPt1/pt1");
    ntMix->SetAlias("var","matchPt1/pt1");
  }

  if(iPlot == 52){
    nt->SetAlias("var","matchPt2/pt2");
    ntReference->SetAlias("var","matchPt2/pt2");
    ntMix->SetAlias("var","matchPt2/pt2");
  }


  nt->Draw("var>>hFull",dijet&&noise&&jetID&&centHF&&vtx); 
  nt->Draw("var>>hB",side&&noise&&jetID&&centHF&&vtx);
  nt->Draw("pt1>>hNorm",lead&&noise&&jetID&&centHF&&vtx);
   
  ntMix->Draw("var>>hDataMixFull",weight*(dijet&&jetID&&centHF&&vtx));
  ntMix->Draw("var>>hDataMixB",weight*(side&&jetID&&centHF&&vtx));
  ntMix->Draw("pt1>>hNormDataMix",weight*(lead&&jetID&&centHF&&vtx));
  
  ntReference->Draw("var>>hReferenceFull",dijet&&noise&&jetID&&centHF&&vtx);
  ntReference->Draw("var>>hReferenceB",side&&noise&&jetID&&centHF&&vtx);
  ntReference->Draw("pt1>>hNormReference",lead&&noise&&jetID&&centHF&&vtx);

  hDataMix->Add(hDataMixFull);
  h->Add(hFull);
  hReference->Add(hReferenceFull);

  if(subtract){
    hDataMix->Add(hDataMixB,-1);
    h->Add(hB,-1);
    hReference->Add(hReferenceB,-1);
  }

  hB->SetFillStyle(3005);
  hB->SetFillColor(15);

  // calculate the statistical error and normalize
  h->SetLineColor(dataColor);
  h->SetMarkerColor(dataColor);
  h->Sumw2();
  if(normLead){
    h->Scale(1./hNorm->Integral());
    hB->Scale(1./hNorm->Integral());
  }else{
    hB->Scale(1./h->Integral());
    h->Scale(1./h->Integral());
  }
  h->SetMarkerStyle(20);

  if(hReference->Integral() > 0){
    hReference->Scale(1./hNormReference->Integral());
  }

  hReference->SetLineColor(kBlue);
  hReference->SetFillColor(kAzure-8);
  hReference->SetFillStyle(3005);

  if(normLead){
    hDataMixB->Scale(1./hNormDataMix->Integral());
    hDataMix->Scale(1./hNormDataMix->Integral());
  }else{
    hDataMixB->Scale(1./hDataMix->Integral());
    hDataMix->Scale(1./hDataMix->Integral());
  }
  hDataMix->SetLineColor(mixColor);
  hDataMix->SetFillColor(mixColor);
  hDataMix->SetFillStyle(3004);
  
  hDataMix->SetMarkerSize(0);
  hDataMix->SetStats(0);

  hDataMix->GetXaxis()->SetLabelSize(22);
  hDataMix->GetXaxis()->SetLabelFont(43);
  hDataMix->GetXaxis()->SetTitleSize(28);
  hDataMix->GetXaxis()->SetTitleFont(43);
  hDataMix->GetXaxis()->SetTitleOffset(2.2);
  hDataMix->GetXaxis()->CenterTitle();
  
  
  hDataMix->GetYaxis()->SetLabelSize(22);
  hDataMix->GetYaxis()->SetLabelFont(43);
  hDataMix->GetYaxis()->SetTitleSize(28);
  hDataMix->GetYaxis()->SetTitleFont(43);
  hDataMix->GetYaxis()->SetTitleOffset(2.2);
  hDataMix->GetYaxis()->CenterTitle();
  
  if(drawXLabel) hDataMix->SetXTitle("A_{J} = (p_{T,1}-p_{T,2})/(p_{T,1}+p_{T,2})");  
  hDataMix->SetYTitle("Event Fraction");

  if(iPlot==1) hDataMix->SetXTitle("#eta_{dijet} = (#eta_{1}+#eta_{2})/2");
  if(iPlot==21) hDataMix->SetXTitle("#eta_{1}");
  if(iPlot==22) hDataMix->SetXTitle("#eta_{2}");

  if(iPlot==8) hDataMix->SetXTitle("p_{T,1}^{background}-p_{T,2}^{background}");
  if(iPlot==9) hDataMix->SetXTitle("N_{trk}^{offline}");

  if(iPlot==11) hDataMix->SetXTitle("p_{T,1}^{background}");
  if(iPlot==12) hDataMix->SetXTitle("p_{T,2}^{background}");

  if(iPlot==13) hDataMix->SetXTitle("p_{T} leading track in leading jet");
  if(iPlot==14) hDataMix->SetXTitle("p_{T} leading track in subleading jet");


  if(drawXLabel){
    if(iPlot==0) hDataMix->SetXTitle("p_{T,2}/p_{T,1}");
    if(iPlot==3) hDataMix->SetXTitle("#Delta #phi_{1,2}");
  }

  if(iPlot==0) hDataMix->SetMaximum(0.32);

  if(iPlot == 1 || iPlot==21 || iPlot==22){
    hDataMix->SetMaximum(0.3);
    hDataMix->SetMinimum(0);
  }


  if(iPlot==3){
    hDataMix->SetMaximum(2.52);
    hDataMix->SetMinimum(0.00004);
  }

  if(iPlot==8){
    hDataMix->SetMaximum(10);
    hDataMix->SetMinimum(0.00004);
  }

  if(iPlot==9){
    hDataMix->SetMaximum(0.15);
    hDataMix->SetMinimum(0.);
  }

  if(iPlot==11 || iPlot == 12){
    hDataMix->SetMaximum(10);
    hDataMix->SetMinimum(0.00004);
  }



  //hDataMix->GetXaxis()->SetNdivisions(905,true);
  hDataMix->GetYaxis()->SetNdivisions(505,true);

  hReference->SetMarkerColor(ppColor);
  hReference->SetLineColor(ppColor);
  hReference->SetMarkerStyle(25);

	hDataMix->Draw();//"hist");
	hDataMix->Draw("hist same");
	if(showPbPb) hReference->Draw("same");

	cout<<"PbPb ENTRIES : "<<endl;
	cout<<hReference->GetEntries()<<endl;

        cout<<"PbPb integral : "<<endl;
        cout<<hReference->Integral()<<endl;

	cout<<"pPb integral : "<<endl;
        cout<<h->Integral()<<endl;

	cout<<"Mix integral : "<<endl;
        cout<<hDataMix->Integral()<<endl;

	h->SetLineWidth(1);
	h->Draw("same");
	h->SetLineWidth(2);
	h->Draw("same");

	//	hDataMixB->Draw("same hist");
	//        hB->Draw("same hist");

	 cout<<" mean value of data "<<h->GetMean()<<endl;

  if(drawLeg){
    TLegend *t3=new TLegend(0.01,0.7,0.3,0.95);
    t3->AddEntry(h,"pPb #sqrt{s}=5.02 TeV","p");
    if(showPbPb) t3->AddEntry(hReference,"PbPb #sqrt{s}=2.76 TeV","p");
    t3->AddEntry(hDataMix,"PYTHIA+HIJING","lf");

    t3->SetFillColor(0);
    t3->SetBorderSize(0);
    t3->SetFillStyle(0);
    t3->SetTextFont(63);
    t3->SetTextSize(15);
    t3->Draw();
  }

}
コード例 #14
0
void balanceMetVsAj(TString infname = "dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0_120_50.root",
                    TCut myCut = "cent<30", char *title = "",bool drawLegend = false,
                    bool drawSys = true
		    )
{
   // ===========================================================
   // Get Input
   // ===========================================================
   TFile *inf = new TFile(infname);
   TTree *t = (TTree*)inf->Get("ntjt");
   t->SetAlias("metxMergedAll","(metx0+metx1+metx2+metx3+metx4+metx5)");
   t->SetAlias("metxMerged0","(metx0+metx1+metx2+metx3)");
   t->SetAlias("metxMerged1","(metx1+metx2+metx3)");
   t->SetAlias("metxMerged2","(metx2+metx3)");
   t->SetAlias("metxMerged3","(metx3)");
   t->SetAlias("metxMerged4","(metx4+metx5)");
   //TString name2(infname);
   //name2.ReplaceAll("ntv2deadforpix_","");
   //name2.ReplaceAll("ntv2_","");
   //t->AddFriend("dj=djTree",name2);

   // ===========================================================
   // Analysis Setup
   // ===========================================================
   Int_t plotLayer=10;
   const int nBin = 5;
   double bins[nBin+1] = {0.5,1.0,2,4,8,1000};  
   
   const int nBinAj = 4;
   double ajBins[nBinAj+1] = {0.0001,0.13,0.24,0.35,0.69999};
   // Selection cut
   TCut evtCut = "nljet>100&&abs(nljetacorr)<1.6&&aljet>40&&abs(aljetacorr)<1.6&&jdphi>2./3*TMath::Pi()&&!maskEvt";

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

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

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

      // =================================
      // Caculated Stat Error of the Mean
      // =================================
      cout << "Stat Error for pt bin " << i << ": ";
      for ( int iaj = 0 ; iaj< nBinAj ; iaj++) {
         he[iaj] = new TH1D(Form("he%d_aj%d",i,iaj),"",100,-200,200);
         TCut ajCut = Form("Aj>%f && Aj<%f", ajBins[iaj],ajBins[iaj+1]);
         t->Draw(Form("((metxMerged%d))>>he%d_aj%d",i,i,iaj), "weight" * evtCut&&myCut&&ajCut);
         float theError = he[iaj]->GetRMS()/ (sqrt(he[iaj]->GetEntries()));
	 cout << theError << " ";
	 p[i]->SetBinError(iaj+1, theError);
      }
      cout << endl;
   }
   // correct the error bars..  cummulative -> it's own.
   subtractError(p[0],p[1]);
   subtractError(p[1],p[2]);
   subtractError(p[2],p[3]);
   
   TH1D *pall;
   TH1D *pallE;
   TH1D *h1 = new TH1D(Form("hAll1"),"",nBinAj,ajBins);
   TH1D *h2 = new TH1D(Form("hAll2"),"",nBinAj,ajBins);

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

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

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

   // ====================
   // Finally Draw
   // ====================
   for (int i=0;i<nBin;++i) {
      if (plotLayer==0) continue;
      if (plotLayer==1&&i!=nBin-1) continue;
      p[i]->SetLineWidth(1);
      //      p[i]->SetMarkerSize(0.1);
      p[i]->Draw("hist same");
   }
   
   // ====================
   // Draw Statistical Error bars
   // ====================
   for (int i=0;i<nBin;++i) {
      if (plotLayer==0) continue;
      if (plotLayer==1&&i!=nBin-1) continue;
      if ( i==0 )       drawErrorShift(p[i],-0.016, addSys);
      if ( i==1 || i==4)       drawErrorShift(p[i],-0.008,addSys);
      if ( i==2 )       drawErrorShift(p[i],0.008,addSys);
      if ( i==3 )       drawErrorShift(p[i],0.016,addSys);
   }
   pall->Draw("E same");
   
   // ====================
   // Draw Systematic Errors
   // ====================
   if (drawSys == 1) {
      for(int i = 0; i < nBinAj; ++i){
        double x = pall->GetBinCenter(i+1);
        double y = pall->GetBinContent(i+1);
        // Quote the difference between GEN and RECO in >8 Bin (20%) before adjusting eff as systematics
        double errReco = -p[nBin-1]->GetBinContent(i+1)*0.2;
	double errBck = 3.0; // compare HYDJET+SIG to SIG
	double err = sqrt(errReco*errReco+errBck*errBck);
        DrawTick(y,err,err,x,1,0.02,1);
      }
   }

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

   if (drawLegend) leg->Draw();

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


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

   TText *titleText = new TText(0.3,30,title);
   titleText->Draw();
}