Example #1
0
void Interface::dessinEnnemi(Objet ennemi)
{
    //  Dessin de l'ennemi
    TBox *dessinEnnemi = new TBox(ennemi.getX()-ennemi.getLongueur(),ennemi.getY()-ennemi.getHauteur(),ennemi.getX(),ennemi.getY());
    dessinEnnemi->SetFillColor(kRed);
    dessinEnnemi->Draw();
}
Example #2
0
File: greyscale.C Project: Y--/root
void greyscale()
{
   TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
   c->SetBorderMode(0);

   Int_t   n = 200;   // tunable parameter
   Float_t n1 = 1./n;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
         TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
         Float_t grey = Float_t(i*n+j)/(n*n);
         b->SetFillColor(TColor::GetColor(grey, grey, grey));
         b->Draw();
      }
   }
   TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
   const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
   p->SetFillColor(TColor::GetColor(guibackground));
   p->Draw();
   p->cd();
   TText *t = new TText(0.5, 0.5, "GUI Background Color");
   t->SetTextAlign(22);
   t->SetTextSize(.09);
   t->Draw();

   c->SetEditable(kFALSE);
}
void drawSysBox(TGraph* gr, int fillcolor=TColor::GetColor("#ffff00"), double xwidth=0.3, double percent=0, double xshift=0)
{

  TBox* box;
  for(int n=0;n<gr->GetN();n++)
  {
    double x,y;
    gr->GetPoint(n,x,y);

    //double percent=0;
    //if(x>=260) percent=0.074;
    //else if(x<260 && x>=200) percent=0.055;
    //else percent=0.039;

    double yerr = y*percent*0.01;
    box = new TBox(x+xshift-xwidth,y-fabs(yerr),x+xwidth,y+fabs(yerr));
    //box->SetFillStyle(3001);
  //box->SetFillColor(fillcolor);
    //box->SetFillColor(2);
    box->SetLineWidth(0);
  box->SetFillColor(kGray);
    box->Draw("Fsame");
    //box->Draw();
  }

}
Example #4
0
void Draw_ALICEFor_JPsi_RaaVsNpart(TLegend *lgd)
{
  int nbinsALICE=9;
  Double_t NPartALICE[10]={357,262,187,128,86,53,30,16,8};
  Double_t ErrNPartALICE[10]={0};
  Double_t RaaALICE[10] = {0.47,0.48,0.51,0.51,0.52,0.61,0.70,0.74,0.94}; 
  Double_t SystErrALICE[10] = {0.03,0.02,0.02,0.02,0.03,0.05,0.06,0.09,0.1};
  
  TGraphErrors *grRaaALICE = new TGraphErrors(nbinsALICE, NPartALICE, RaaALICE, ErrNPartALICE, SystErrALICE);  
  grRaaALICE->SetMarkerStyle(20);
  grRaaALICE->SetMarkerColor(4);
  grRaaALICE->GetYaxis()->SetRangeUser(0,1.7);
  
  TAxis *Xaxis2 = grRaaALICE->GetXaxis();
  Xaxis2->SetLimits(0.,430.0);
  
  grRaaALICE->GetXaxis()->SetTitle("N_{Part}");
  grRaaALICE->GetYaxis()->SetTitle("R_{AA}");

  grRaaALICE->Draw("AP");
 
  TLine *lh3 = new TLine(0.0,1.0,420,1.0);
  lh3->SetLineColor(1);
  lh3->SetLineStyle(1);
  lh3->SetLineWidth(1.5);
  lh3->Draw("same");
 
  //TLatex *tb= new TLatex;
  //tb->SetNDC(); 
  //tb->SetTextAlign(12);
  //tb->SetTextColor(1);
  //tb->SetTextSize(0.040);
  //tb->DrawLatex(0.22,0.22,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");  
   
  
  TBox *RaaJPsiALICESys[12];
  for(int j=0;j<9;j++){
    RaaJPsiALICESys[j] = new TBox(NPartALICE[j]-3,  RaaALICE[j]-SystErrALICE[j], NPartALICE[j]+3, RaaALICE[j]+SystErrALICE[j]);
  }
  
  for(int j=0;j<9;j++){
    RaaJPsiALICESys[j]->SetFillStyle(0000);
    RaaJPsiALICESys[j]->SetLineColor(4);
    RaaJPsiALICESys[j]->Draw("same"); 
  }
  
  TBox *ALICEGlobalSysJPsi;
  ALICEGlobalSysJPsi = new TBox(400-5, 1 - 0.14, 400+5, 1 + 0.14);
  ALICEGlobalSysJPsi->SetFillStyle(3001);
  ALICEGlobalSysJPsi->SetLineColor(4);
  ALICEGlobalSysJPsi->SetFillColor(4);
  ALICEGlobalSysJPsi->Draw("same"); 

  Draw_ALICEMid_JPsi_RaaVsNpart(lgd);

  lgd->AddEntry(grRaaALICE,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, 2.5 #leq y^{J/#psi} #leq 4.0","P");

}
Example #5
0
void Draw_ALICEMid_JPsi_RaaVsNpart(TLegend *lgd)
{
  //ALICE MID rapidity
  int nbinsALICEMid=3;
  Double_t NPartALICEMid[3]={357,193,46};
  Double_t ErrNPartALICEMid[3]={0};
  Double_t RaaALICEMid[3] = {0.82,0.65,0.73}; 
  Double_t SystErrALICEMid[3] = {0.15,0.10,0.16};
  
  TGraphErrors *grRaaALICEMid = new TGraphErrors(nbinsALICEMid, NPartALICEMid, RaaALICEMid, ErrNPartALICEMid, SystErrALICEMid);  
  grRaaALICEMid->SetMarkerStyle(20);
  grRaaALICEMid->SetMarkerColor(2);
  //grRaaALICEMid->SetLineColor(2);
  grRaaALICEMid->GetYaxis()->SetRangeUser(0,1.5);
  
  TAxis *Xaxis = grRaaALICEMid->GetXaxis();
  Xaxis->SetLimits(0.,430.0);
  grRaaALICEMid->GetXaxis()->SetTitle("N_{Part}");
  grRaaALICEMid->GetYaxis()->SetTitle("R_{AA}");
  
  grRaaALICEMid->Draw("Psame");
  
  //TLatex *tb= new TLatex;
  //tb->SetNDC(); 
  //tb->SetTextAlign(12);
  //tb->SetTextColor(1);
  //tb->SetTextSize(0.040);
  //tb->DrawLatex(0.55,0.90,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");  
  //tb->DrawLatex(0.55,0.85,"p_{T}^{J/#psi} > 0.0 GeV/c");  
  
  TLine *lh3 = new TLine(0.0,1.0,420,1.0);
  lh3->SetLineColor(1);
  lh3->SetLineStyle(1);
  lh3->SetLineWidth(1.5);
  lh3->Draw("same");
    
  TBox *RaaJPsiALICEMidSys[12];
  for(int j=0;j<3;j++){
    RaaJPsiALICEMidSys[j] = new TBox(NPartALICEMid[j]-3,  RaaALICEMid[j]-SystErrALICEMid[j], NPartALICEMid[j]+3, RaaALICEMid[j]+SystErrALICEMid[j]);
  }
  
  for(int j=0;j<3;j++){
    RaaJPsiALICEMidSys[j]->SetFillStyle(0000);
    RaaJPsiALICEMidSys[j]->SetLineColor(2);
    RaaJPsiALICEMidSys[j]->Draw("same"); 
  }
  
  TBox *ALICEMidGlobalSysJPsi;
  ALICEMidGlobalSysJPsi = new TBox(385-5, 1 - 0.26, 385+5, 1 + 0.26);
  
  ALICEMidGlobalSysJPsi->SetFillStyle(3001);
  ALICEMidGlobalSysJPsi->SetLineColor(2);
  ALICEMidGlobalSysJPsi->SetFillColor(2);
  ALICEMidGlobalSysJPsi->Draw("same"); 

  lgd->AddEntry(grRaaALICEMid,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, |y^{J/#psi}| #leq 1.0","P");
  
}
Example #6
0
void Draw_CMS_JPsi_RaaVsRap(TLegend *lgd)
{
  //=============== CMS Raa Vs Rap Data ===============================================================//
  //AvpT 10.92,9.65,8.92
  int nbinsRapCMS=3;
  Double_t RapCMSD[3]={0.6,1.4,2.0};
  Double_t ErrRapCMS[3]={0.6,0.2,0.4};
  Double_t RaaRapCMS[3] = {0.31,0.33,0.36}; 
  Double_t RaaRapStatErrCMS[3] = {0.02,0.03,0.03};
  Double_t RaaRapSystErrCMS[3] = {0.03,0.04,0.04};

  TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRapCMS, RapCMSD, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS);  
  grRaaRapCMS->SetMarkerStyle(20);
  grRaaRapCMS->SetMarkerColor(2);
  grRaaRapCMS->GetYaxis()->SetRangeUser(0,1.5);
  grRaaRapCMS->GetXaxis()->SetTitle("|y|");
  grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}");
  
  TAxis *XaxisgrRaaRapCMS = grRaaRapCMS->GetXaxis();
  XaxisgrRaaRapCMS->SetLimits(0.0,2.4);
  
  grRaaRapCMS->Draw("AP"); 

  TLine *lh_grRaaRapCMS = new TLine(0.0,1.0,2.4,1.0);
  lh_grRaaRapCMS->SetLineColor(1);
  lh_grRaaRapCMS->SetLineStyle(1);
  lh_grRaaRapCMS->SetLineWidth(1.5);
  lh_grRaaRapCMS->Draw("same");

  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  tb->DrawLatex(0.20,0.20,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.20,0.15,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 6.5 GeV/c");  
  
  TBox *RaaRapJPsiCMSSys[4];
  for(int j=0;j<3;j++){
    RaaRapJPsiCMSSys[j] = new TBox(RapCMSD[j]-0.05,  RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMSD[j]+0.05,  RaaRapCMS[j]+RaaRapSystErrCMS[j]);
  }
  
  for(int j=0;j<3;j++){
    RaaRapJPsiCMSSys[j]->SetFillStyle(0000);
    RaaRapJPsiCMSSys[j]->SetLineColor(2);
    RaaRapJPsiCMSSys[j]->Draw("same"); 
  }
  
  TBox *CMSGlobalSysJPsiRap;
  CMSGlobalSysJPsiRap = new TBox(0.2-0.05, 1 - 0.05, 0.2+0.05, 1 + 0.05);
  CMSGlobalSysJPsiRap->SetFillStyle(3001);
  CMSGlobalSysJPsiRap->SetLineColor(2);
  CMSGlobalSysJPsiRap->SetFillColor(2);
  CMSGlobalSysJPsiRap->Draw("same"); 


  lgd->AddEntry(grRaaRapCMS,"CMS Data", "P");
}
Example #7
0
void Draw_CMS_JPsi_RaaVsNpart(TLegend *lgd)
{

int nbins = 12;
  Double_t RaaCMS[20]={0.23,0.24,0.29,0.33,0.38,0.40,0.45,0.41,0.52,0.52,0.64,0.64};
  Double_t StatErrCMS[20]={0.01,0.01,0.02,0.02,0.02,0.03,0.03,0.03,0.04,0.04,0.05,0.05};
  Double_t SystErrCMS[20]={0.02,0.03,0.03,0.03,0.04,0.04,0.05,0.04,0.05,0.05,0.07,0.13};
  Double_t NPartCMS[20]={Npart(0,2),Npart(2,4),Npart(4,6),Npart(6,8),Npart(8,10),Npart(10,12),
			 Npart(12,14),Npart(14,16),Npart(16,18),Npart(18,20),Npart(20,24),
			 Npart(24,40)};
  Double_t ErrNPartCMS[20]={0};
  
  TGraphErrors *grRaaCMS = new TGraphErrors(nbins, NPartCMS, RaaCMS, ErrNPartCMS, StatErrCMS);  
  grRaaCMS->SetMarkerStyle(21);
  grRaaCMS->SetMarkerColor(2);
  grRaaCMS->GetYaxis()->SetRangeUser(0,1.7);
  grRaaCMS->GetXaxis()->SetTitle("N_{Part}");
  grRaaCMS->GetYaxis()->SetTitle("R_{AA}");
  
  grRaaCMS->Draw("AP");
  TBox *RaaJPsiSys[12];
  for(int j=0;j<12;j++){
    RaaJPsiSys[j] = new TBox(NPartCMS[j]-3,  RaaCMS[j]-SystErrCMS[j], NPartCMS[j]+3, RaaCMS[j]+SystErrCMS[j]);
  }
  
  for(int j=0;j<12;j++){
    RaaJPsiSys[j]->SetFillStyle(0000);
    RaaJPsiSys[j]->SetLineColor(6);
    RaaJPsiSys[j]->Draw("same"); 
  }
  
  TLine *lh2 = new TLine(0.0,1.0,400,1.0);
  lh2->SetLineColor(1);
  lh2->SetLineStyle(1);
  lh2->SetLineWidth(2);
  lh2->Draw("same");
  
  TBox *GlobalSysJPsi;
  GlobalSysJPsi = new TBox(400-5, 1 - 0.06, 400+5, 1 + 0.06);
  GlobalSysJPsi->SetFillStyle(3001);
  GlobalSysJPsi->SetLineColor(6);
  GlobalSysJPsi->SetFillColor(6);
  GlobalSysJPsi->Draw("same"); 
  
  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  tb->DrawLatex(0.17,0.23,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.17,0.17,"p_{T}^{J/#psi} > 6.5 GeV/c");

  lgd->AddEntry(grRaaCMS,"CMS Data", "P");

}
Example #8
0
//______________________________________________________________________________
void DrawPeriod(int runmin, int runmax, int run1, int run2, double ymin, double ymax, const char* label)
{
  if ( run1 < runmin || run1 > runmax || run2 < runmin || run2 > runmax ) return;

  TBox* b = new TBox(run1,ymin,run2,ymax);
  b->SetFillColor(5);
  b->Draw();
  TText* text = new TText((run1+run2)/2.0,ymax*0.6,label);
  text->SetTextAlign(22);
  text->SetTextSize(0.02);
  text->Draw();
}
Example #9
0
void drawTheory(int i, double mean, double nErr, double pErr, double vstep) {
    
    double lowY = (i+1)*vstep; // margins are 1 vstep each
    double uppY = (i+2)*vstep;

    TBox* band = new TBox(mean-nErr,lowY+0.1*vstep,mean+pErr,uppY-0.1*vstep);
    band->SetFillColor(kYellow-4);
    band->Draw();
    TLine* center = new TLine(mean, 0, mean, 1);
    center->SetLineStyle(2); // dash
    center->SetLineWidth(4);
    center->SetLineColor(2);
    center->Draw();
  return;
}
Example #10
0
void drawBkgBox(int i, int aux[6], double vstep, TH2F* histo) {

  double lowY = (i+1)*vstep; // margins are 1 vstep each
  double uppY = (i+2)*vstep;

  double lowX =LOW_X;
  double uppX =UPP_X;
  //double lowX = histo->GetBinLowEdge(1);
  //double uppX = histo->GetBinLowEdge(histo->GetNbinsX()) +
  //              histo->GetBinWidth(histo->GetNbinsX());

  TBox* band = new TBox(lowX,lowY,uppX,uppY);
  band->SetFillColor(aux[1]);
  band->Draw();


  return;
}
void drawSysBoxValue(TGraph* gr, int fillcolor=TColor::GetColor("#ffff00"), double xwidth=0.3, double *percent, double xshift=0)
{

  TBox* box;
  for(int n=0;n<gr->GetN();n++)
  {
    double x,y;
    gr->GetPoint(n,x,y);

    double yerr = percent[n]*1.0;
    box = new TBox(x+xshift-xwidth,y-fabs(yerr),x+xwidth,y+fabs(yerr));
    //box->SetFillStyle(3001);
  //box->SetFillColor(fillcolor);
    //box->SetFillColor(2);
    box->SetLineWidth(0);
  box->SetFillColor(kGray);
    box->Draw("Fsame");
    //box->Draw();
  }

}
Example #12
0
//--------------------------
// DrawTargetBoundaries
//--------------------------
void DrawTargetBoundaries(int color=target_color)
{
  double Zlo = 50.0;
  double Zhi = Zlo + 30.0;
  double Rlo = 0.0;
  double Rhi = Rlo + 1.5;
  if (full) { Rlo=-1.5; Rhi=Rlo+3; }

  TBox *box = new TBox(Zlo, Rlo, Zhi, Rhi);
  box->SetLineWidth(2.0);
  if (fill_detectors) { box->SetFillColor(color); box->SetFillStyle(1001); }
  else box->SetFillStyle(0);
  box->SetLineColor(color);
  box->Draw();

  TLatex *lab = new TLatex(Zlo-5, 0, "target");
  if (full) lab->SetTextAlign(32); else lab->SetTextAlign(31);
  lab->SetTextSize(0.02);
  lab->SetTextColor(color);
  lab->Draw();
}
Example #13
0
void drawTransition(){
  TBox *bTrans = new TBox(0., 0., 0.97, 0.97);
  if(iColor)bTrans->SetFillColor(kYellow-9);
  if (! iColor)bTrans->SetFillStyle(4017);
  bTrans->Draw();

  TEllipse *eTrans1 = new TEllipse(0., 0., 0.9, 0.7, 70., 90., 0.);
  eTrans1->SetNoEdges();
  eTrans1->SetFillColor(17);
  eTrans1->SetLineWidth(2);
  eTrans1->SetLineStyle(7);
  eTrans1->Draw();

  TEllipse *eTrans2 = new TEllipse(0., 0., 0.9, 0.7, 0., 70., 0.);
  eTrans2->SetNoEdges();
  eTrans2->SetFillColor(17);
  eTrans2->SetLineWidth(2);
  eTrans2->Draw();

  TMarker *mCrit = new TMarker(0.29, 0.6625, 20);
  mCrit->SetMarkerSize(1.4);
  mCrit->Draw();
}
//____________________________________________________________________________________
// Plot mH scan: main entry point
int plotScan( TString* filenames,int* styles, double* mins, bool* bands, int nfiles=1, int index = 68,
              TString drawOpt = "C", double mHmin = 85, double mHmax = 140 )
{

  // Styles
  gROOT->SetStyle("Pub");
  gStyle->SetCanvasColor(0);
  gStyle->SetCanvasDefH( 500 );
  gStyle->SetCanvasDefW( 600 );
  

  double chi2min = -0., chi2max = 4;  // Delta-chi2 range
  double threshold = 1e-4;

  for(int i = 0; i<nfiles; i++ )
  {
    std::cout << "Opening " << filenames[i]; 
    TFile* file = new TFile(filenames[i]);
      if ( !(file->IsOpen()) ) {
      std::cerr << "*** Couldn't open " << filenames[i] << std::endl;
      return -1;
    }
    // Retrieve and correct graph
    TString gName("graph1d");
    gName += index;
    TGraph *gChi2[4];
    gChi2[i] = (TGraph*)file->Get( gName );
    if ( !gChi2 ) {
      std::cerr << "*** Couldn't find graph \"" << gName << "\"" << std::endl;
      return -1;
    }
    if(i==0) zeroSuppress( gChi2[i] );
  }

  // Set plot range
  TH2F* range = new TH2F("range","#chi^{2} fit of lightest Higgs mass",
                         2,mHmin,mHmax,2,chi2min,chi2max);
  range->GetXaxis()->SetTitle("M_{h} [GeV]");
  range->GetYaxis()->SetTitle("#Delta#chi^{2}");
  range->Draw();


  // Find preferred value
//  double mHfavour = findMh( gChi2, 0., mHmin );
//  double negError = mHfavour-findMh( gChi2, 1., mHmin );
//  double posError = findMh( gChi2, 1., mHfavour )-mHfavour;
//  std::cout << "Favoured value: " << mHfavour << "+" << posError << "-" << negError << std::endl;

  // Include LEP limit
  TBox* bLepLimit = new TBox( mHmin, chi2min+0.01, LEPLIMIT, chi2max-0.01 );
  bLepLimit->SetFillColor( 5 );
  bLepLimit->Draw();

  // Find value at lep limit
//  double chi2limit = gChi2->Eval( LEPLIMIT, 0, "S" );
//  std::cout << "Value at limit (" << LEPLIMIT << "): " << chi2limit << std::endl;

  // Include upper theoretical limit
  double theoLimit = 130;
  TBox* bTheoLimit = new TBox( theoLimit, chi2min+0.01, mHmax, chi2max-0.01 );
  bTheoLimit->SetFillColor( 42 );
  bTheoLimit->Draw();

  TGraph* rB[4];
  for (int i=0; i<nfiles; i++)
  { 
    if ( bands[i] ) {
      rB[i]=redBand2( gChi2[i], 1.5, mins[i],0.05);
    }
    gChi2[i]->SetLineWidth(3);
    gChi2[i]->SetMarkerStyle(2);
    gChi2[i]->SetLineColor(4);
    gChi2[i]->SetLineStyle(styles[i]);
  }

  for( int i = 0; i<nfiles; ++i){
    if(bands[i]) rB[i]->Draw("LF");
  }
  for( int i = 0; i<nfiles; ++i) gChi2[i]->Draw(drawOpt);

  // Forbidden regions
  TLatex tt;
  tt.SetTextSize(0.7*gStyle->GetTextSize());
  tt.SetTextAlign(12);
  tt.DrawLatex( mHmin+4, chi2min+0.4, "#splitline{LEP}{excluded}" );
  tt.SetTextAlign(22);
  tt.DrawLatex( (theoLimit+mHmax)/2.01, chi2min+0.4, "#splitline{Theoretically}{inaccessible}" );


  
  return 0;
  
}
//____________________________________________________________________________________
// Plot overlay mH scan (SM + mSugra)
int plotOverlay( TString fileName = "output/msugra-noMH-cut20-v5.root", int index = 68, TString drawOpt = "C" )
{

  // Styles
  gROOT->SetStyle("Pub");
  gStyle->SetCanvasColor(0);
  gStyle->SetCanvasDefH( 500 );
  gStyle->SetCanvasDefW( 600 );
  

  double chi2min = -0., chi2max = 4;  // Delta-chi2 range
  double mHmin   = 30, mHmax = 200;
  double threshold = 1e-4;

  TCanvas* myCanvas = new TCanvas("myCanvas","Pseudo-exps contour",10,10,600,600);
  myCanvas->SetTopMargin(0.02);
  myCanvas->SetLogx(1);
  
  // Retrieve and correct graph
  TFile* file = new TFile(fileName);
  if ( !file->IsOpen() ) {
    std::cerr << "*** Couldn't open " << fileName << std::endl;
    return -1;
  }
  TString gName("graph1d");
  gName += index;
  TGraph* gChi2 = file->Get( gName );
  if ( !gChi2 ) {
    std::cerr << "*** Couldn't find graph \"" << gName << "\"" << std::endl;
    return -1;
  }
  zeroSuppress( gChi2 );

  // Set plot range
  TH2F* range = new TH2F("range","#chi^{2} fit of lightest Higgs mass",
                         2,mHmin,mHmax,2,chi2min,chi2max);
  if ( !doPub ) {
    range->GetXaxis()->SetTitle("M_{h} [GeV/c^{2}]");
    range->GetYaxis()->SetTitle("#Delta#chi^{2}");
    range->GetYaxis()->SetTitleOffset(1.1);
  }
  range->GetXaxis()->SetNoExponent();
  range->GetXaxis()->SetMoreLogLabels(1);
  range->Draw();

  // Find preferred value
  double mHfavour = findMh( gChi2, 0., 100. );
  double negError = mHfavour-findMh( gChi2, 1., 100. );
  double posError = findMh( gChi2, 1., mHfavour )-mHfavour;
  std::cout << "Favoured value: " << mHfavour << "+" << posError << "-" << negError << std::endl;

  
  // Include LEP limit
  int LepColor = 5;
  TBox* bLepLimit = new TBox( mHmin, chi2min+0.01, LEPLIMIT, chi2max-0.01 );
  bLepLimit->SetFillColor( LepColor );
  bLepLimit->Draw();

  TLatex tt;
  if (doPub) tt.SetTextFont(133);
  tt.SetTextSize(14);

  // Blue band
  blueBand();

  // Plot red band (1.5 GeV)
  if ( doBands ) {
    redBand2( gChi2, 1.5, mHfavour, 0.005 );
    gChi2->SetLineColor(4);
    gChi2->SetLineWidth(3);
  } else {
    gChi2->SetLineColor(kMagenta);
    gChi2->SetLineWidth(5);
  }


  // Plot scan
  gChi2->SetMarkerStyle(2);
  gChi2->Draw(drawOpt);
  TMultiGraph* mg = new TMultiGraph();

  // Forbidden regions
  tt.SetTextSize(18);
  tt.SetTextAlign(12);
  tt.DrawLatex( mHmin+4, chi2min+0.4, "#splitline{LEP}{excluded}" );
  tt.SetTextAngle(0);


  // Printout
  // hep-ph number
  TLatex tt;
  tt.SetTextFont(83);
  tt.SetTextSize(18);
  tt.SetTextAlign(32);
  //  tt.DrawTextNDC( 0.89, 0.88, "arXiv:0707.3447" );

//   TString name = "mh-scan-overlay";
//   if ( !doPub ) name += "_label";
//   myCanvas->Print(name+".eps");

  
  return 0;
  
}
void minuitFit()
{

  TH1F::SetDefaultSumw2(); 
  TH1D::SetDefaultSumw2(); 

  cout << "Must Use Same Binning as previous Analysis!" << endl;

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  haveName = kFALSE;
  char fname[100];
  TFile* file;
  Bool_t makePDF = checkMakePDF();
  Bool_t makeROOT = checkMakeRoot();
  if(makeROOT){
    sprintf(fname,"/Users/zach/Research/pythia/200GeVTemplate/FFOutput/%s_FIT.root",FileNameR);
    file = new TFile(fname,"RECREATE");
    if (file->IsOpen()==kFALSE)
    {
      std::cout << "!!! Outfile Not Opened !!!" << std::endl;
      makeROOT = kFALSE;
    }
  }


  char name[1000];
  sprintf(name,"/Users/zach/Research/pythia/200GeVTemplate/currentTemplate.root");
  TFile *fT = new TFile(name,"READ");
  sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root");
  TFile *fD = new TFile(name,"READ");
  if (fT->IsOpen()==kFALSE || fD->IsOpen()==kFALSE)
  { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl
    << "Looking for currentB.root, currentC.root, and currentData.root" << std::endl;
    exit(1); }

  // Set constants and projection bins (from header file anaConst, analysis constants)

  Float_t lowpt[numPtBins],highpt[numPtBins];
  for(Int_t c=0; c< numPtBins; c++){
    lowpt[c] = anaConst::lpt[c];
    highpt[c] = anaConst::hpt[c];
  }
  Float_t hptCut=anaConst::hptCut;

  // Make Canvases
  TCanvas* deltaPhi  = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* deltaPhi2  = new TCanvas("deltaPhi2","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000);
  TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000);
  TCanvas* fitResultC = new TCanvas("fitResultC","RB Extraction Combined Trigs",150,0,1150,1000);
  TCanvas* fitResultP = new TCanvas("fitResultP","RB Previous Analysis",150,0,1150,1000);
  TCanvas* scaleCheck = new TCanvas("scaleCheck","Check scale diff",150,0,1150,1000);
  TCanvas* prettyPlot = new TCanvas("prettyPlot","PrettyPlot",150,0,1150,1000);
  deltaPhi  ->Divide(3,3);
  deltaPhi2 ->Divide(3,3);
  fitResult0->Divide(3,4);
  fitResult2->Divide(3,4);
  fitResultC->Divide(3,4);
  fitResultP->Divide(2,2);
  scaleCheck->Divide(1,2);

  // Get and Draw histos
  TPaveText* lbl[numPtBins];
  TPaveText* stat[4][numPtBins];
  char statLabel[100];
  char textLabel[100];
  Int_t plotbin;
  Double_t norm0,norm2,normB,normC;

  // Get ptbin independent hists
  histoNorms = (TH2F*)fD->Get("histoNorms");
   // Get Previous Analysis
  TFile *file3 = new TFile("/Users/zach/Research/previousNPEhFigures/Chi2_25_35.root");
  Hdphi[0]  = (TH1D*)file3->Get("fit_25_35");
  HpphiD[0] = (TH1D*)file3->Get("De_25_35");
  HpphiB[0] = (TH1D*)file3->Get("Be_25_35");
  TFile *file4 = new TFile("/Users/zach/Research/previousNPEhFigures/Chi2_55_65.root");
  Hdphi[1]  = (TH1D*)file4->Get("fit_55_65");
  HpphiD[1] = (TH1D*)file4->Get("De_55_65");
  HpphiB[1] = (TH1D*)file4->Get("Be_55_65");

  for(Int_t ptbin=0; ptbin<numPtBins; ptbin++)
  {
    bPtNorms[ptbin]   = (TH1F*)fT->Get(Form("beEventTally_%i",ptbin));
    cPtNorms[ptbin]   = (TH1F*)fT->Get(Form("ceEventTally_%i",ptbin));

    norm0 = histoNorms->GetBinContent(histoNorms->GetBin(1,ptbin+1));
    norm2 = histoNorms->GetBinContent(histoNorms->GetBin(3,ptbin+1));
    normB = bPtNorms[ptbin]->GetBinContent(1);
    normC = cPtNorms[ptbin]->GetBinContent(1);

    cout << ptbin << "; 0: " << norm0 << " 2: " << norm2 << endl;

    if( norm0 == 0)
    {
      cout << ptbin << " For this bin, some norm0 = 0" << endl;
      continue;
    }
    if( norm2 == 0 )
    {
      cout << ptbin << " For this bin, some norm2 = 0" << endl;
      continue;
    }
    if( normB == 0 )
    {
      cout << ptbin << " For this bin, some normB = 0" << endl;
      continue;
    }
    if( normC == 0)
    {
      cout << ptbin << " For this bin, some normC = 0" << endl;
      continue;
    }
    plotbin = ptbin;
    // Init necessary plotting tools
    lbl[ptbin] = new TPaveText(.15,.15,.35,.23,Form("NB NDC%i",ptbin));
    sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]);
    lbl[ptbin]->AddText(textLabel);
    lbl[ptbin]->SetFillColor(kWhite);

    projB[ptbin] = (TH1D*)fT->Get(Form("hdPhiRawbe_%i",ptbin));
    projC[ptbin] = (TH1D*)fT->Get(Form("hdPhiRawce_%i",ptbin));
    projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin));
    projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin));
 
    pileupCorrect[ptbin][0] = (TH1D*)fD->Get(Form("pileupCorrection_%i_0",ptbin));
    pileupCorrect[ptbin][1] = (TH1D*)fD->Get(Form("pileupCorrection_%i_2",ptbin));
    pileupCorrect[ptbin][0]->Sumw2();
    pileupCorrect[ptbin][1]->Sumw2();

    // Do any rebinning
    Int_t RB = 1;
    projB[ptbin]->Rebin(RB);
    projC[ptbin]->Rebin(RB);
    projData0[ptbin]->Rebin(RB);
    projData2[ptbin]->Rebin(RB);

    // Clone to make plots without effecting fits
    plotD0[ptbin] = (TH1D*) projData0[ptbin]->Clone();
    plotD2[ptbin] = (TH1D*) projData2[ptbin]->Clone();
    plotB[ptbin]  = (TH1D*) projB[ptbin]->Clone();
    plotC[ptbin]  = (TH1D*) projC[ptbin]->Clone();

    // Set features that are the same in plots
    projData0[ptbin]->SetLineColor(kBlue);
    projData2[ptbin]->SetLineColor(kGreen+3);
    projB[ptbin]->SetLineColor(kRed);
    projC[ptbin]->SetLineColor(kBlack);
    projC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5);
    plotD0[ptbin]->SetLineColor(kBlue);
    plotD2[ptbin]->SetLineColor(kGreen+3);
    plotD0[ptbin]->SetMarkerStyle(20);
    plotD0[ptbin]->SetMarkerColor(kBlue);
    plotD0[ptbin]->SetMarkerSize(0.4);
    plotB[ptbin]->SetLineColor(kRed);
    plotC[ptbin]->SetLineColor(kBlack);
    plotC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5);

    combData[ptbin] = (TH1D*) projData0[ptbin]->Clone();
    combData[ptbin] -> Add(projData2[ptbin]);
    combData[ptbin]->SetLineColor(kBlue);
    combData[ptbin]->SetMarkerStyle(20);
    combData[ptbin]->SetMarkerColor(kBlue);
    combData[ptbin]->SetMarkerSize(0.4);
    combData[ptbin]->SetTitle("");

    // Normalize
    projB[ptbin]     -> Scale(1./normB);
    projC[ptbin]     -> Scale(1./normC);
    projData0[ptbin] -> Scale(1./norm0);
    projData2[ptbin] -> Scale(1./norm2);
    plotD0[ptbin]    -> Scale(1./norm0);
    plotD2[ptbin]    -> Scale(1./norm2);
    plotB[ptbin]     -> Scale(1./normB);
    plotC[ptbin]     -> Scale(1./normC);
    combData[ptbin]  -> Scale(1./(norm0+norm2));

    // Subtract Pileup correction (data only)
    projData0[ptbin]->Sumw2();projData2[ptbin]->Sumw2();
    //projData0[ptbin]->Add(pileupCorrect[ptbin][0],-1);
    //projData2[ptbin]->Add(pileupCorrect[ptbin][1],-1);

    // Draw Templates on own plots
    if(ptbin+1 <= 9) deltaPhi->cd(plotbin+1);
    if(ptbin+1 > 9) deltaPhi2->cd(ptbin-8);
    plotC[ptbin]->GetYaxis()->SetRangeUser(-.1,0.8);
    plotC[ptbin]  -> Draw("hist");
    plotB[ptbin]  -> Draw("same hist");
    plotD0[ptbin] -> Draw("same");
    plotD2[ptbin] -> Draw("same");
    lbl[ptbin]    -> Draw("same");

    TLegend* leg = new TLegend(0.65,0.6,0.85,0.85);
    leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe");
    leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe");
    leg->AddEntry(projData0[ptbin],"HT0","lpe");
    leg->AddEntry(projData2[ptbin],"HT2","lpe");
    leg->Draw();

    deltaPhi->cd(1);
    Hdphi[0]->Draw("same");
    deltaPhi->cd(4);
    Hdphi[1]->Draw("same");

      if(ptbin == 1)
      {
        prettyPlot->cd();
        plotC[ptbin]->GetYaxis()->SetRangeUser(0,0.35);
        plotC[ptbin]->SetMarkerStyle(20);
        plotC[ptbin]->SetMarkerSize(0.6);
        plotB[ptbin]->SetMarkerStyle(21);
        plotB[ptbin]->SetMarkerSize(0.6);
        plotB[ptbin]->SetMarkerColor(kRed);
        plotD0[ptbin]->SetMarkerStyle(22);
        plotD0[ptbin]->SetMarkerSize(0.9);
        plotC[ptbin]->GetXaxis()->SetTitle("#Delta#phi_{NPE-h} (rad)");
        plotC[ptbin]->GetYaxis()->SetTitle("#frac{1}{N_{NPE}} #frac{dN}{d(#Delta#phi)}");
        plotC[ptbin]->DrawClone("P");
        plotB[ptbin]->DrawClone("same P");
        plotD0[ptbin]->DrawClone("same P");
        TLegend* legPret = new TLegend(0.65,0.6,0.85,0.85);
        legPret->AddEntry(plotB[ptbin],"B #rightarrow NPE-h, Monte Carlo","LPE");
        legPret->AddEntry(plotC[ptbin],"D #rightarrow NPE-h, Monte Carlo","LPE");
        legPret->AddEntry(plotD0[ptbin],"NPE-h 2012 STAR Data","LPE");
        lbl[ptbin]->Draw("same");
        legPret->Draw("same");
      }

    /*// Draw Scale Check
      scaleCheck->cd(1);
      TH1F* HT0 = (TH1F*) plotD0[0]->Clone();
      HT0->Divide(HT0,Hdphi[0],1,1);
      HT0->Draw();
      scaleCheck->cd(2);
      TH1F* HT2 = (TH1F*) plotD2[3]->Clone();
      HT2->Divide(HT2,Hdphi[1],1,1);
      HT0->GetXaxis()->SetRangeUser(-3.5,3.5);
      HT2->GetXaxis()->SetRangeUser(-3.5,3.5);
      HT2->Draw();
      lbl[ptbin]->Draw("same");
      TLegend* legSC = new TLegend(0.65,0.6,0.85,0.85);
      legSC->AddEntry(HT0,"HT0/prevdata","lpe");
      legSC->AddEntry(HT2,"HT2/prevdata","lpe");
      legSC->Draw();*/

    /////////////////////
    // Do the actual fits
    /////////////////////

    currentPtBin = ptbin;
    cout << "!!!!!!! HT0 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
    TMinuit* gMinuit = new TMinuit(1);
    gMinuit->SetFCN(chi2_0);
    currentPtBin = ptbin;
    doFit(gMinuit,p01[ptbin],p00[ptbin],e01[ptbin],e00[ptbin]);

    // assign to plotting variables
    if(highpt[ptbin] < 6)
    {
      pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
      dx[plotCount0] = 0.;
      ptOFF1[plotCount0] = pT[ptbin];
      Rb0[plotCount0] = p01[ptbin];///(p01[ptbin]+p00[ptbin]);
      eb0[plotCount0] = e01[ptbin];
      plotCount0++;
    }

    // Plot results
    fitResult0->cd(ptbin+1);
    TH1D* dClone = (TH1D*) projData0[ptbin]->Clone();
    TH1D* cClone = (TH1D*) projC[ptbin]->Clone();
    TH1D* bClone = (TH1D*) projB[ptbin]->Clone();
    stat[0][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin));
    sprintf(statLabel,"Chi2/NDF: %.2f/%.0f",curChi2,curNDF);
    stat[0][ptbin]->InsertText(statLabel);
    stat[0][ptbin]->SetFillColor(kWhite);
    cClone->Scale((1.-p01[ptbin])*p00[ptbin]); bClone->Scale(p00[ptbin]*p01[ptbin]); // scale by contribution param
    cClone->Add(bClone);
    //cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
    dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
    dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
    dClone->Draw();
    cClone->Draw("same");
    stat[0][ptbin]->Draw("same");
    lbl[ptbin]->Draw("same");


    cout << "!!!!!!! HT2 ptbin: " <<  highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
    gMinuit->SetFCN(chi2_2);
    doFit(gMinuit,p21[ptbin],p20[ptbin],e21[ptbin],e20[ptbin]);

    // assign to plotting variables
    if(highpt[ptbin] > 3.6)
    {
      pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
      ptOFF2[plotCount2] = pT[ptbin];
      Rb2[plotCount2] = p21[ptbin];///(p21[ptbin]+p20[ptbin]);
      eb2[plotCount2] = e21[ptbin];
      plotCount2++;
    }

    // Plot results
    fitResult2->cd(ptbin+1);
    dClone = (TH1D*) projData2[ptbin]->Clone();
    cClone = (TH1D*) projC[ptbin]->Clone();
    bClone = (TH1D*) projB[ptbin]->Clone();
    stat[2][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin));
    sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
    stat[2][ptbin]->InsertText(statLabel);
    stat[2][ptbin]->SetFillColor(kWhite);
    cClone->Scale((1.-p21[ptbin])*p20[ptbin]); bClone->Scale(p20[ptbin]*p21[ptbin]); // scale by contribution param
    cClone->Add(bClone);
    // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
    dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
    dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
    dClone->Draw();
    cClone->Draw("same");
    stat[2][ptbin]->Draw("same");
    lbl[ptbin]->Draw("same");

    cout << "!!!!!!! HTC ptbin: " <<  highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
    gMinuit->SetFCN(chi2_C);
    doFit(gMinuit,pC1[ptbin],pC0[ptbin],eC1[ptbin],eC0[ptbin]);
    // assign to plotting variables
    pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
    RbC[plotCount] = pC1[ptbin];///(p21[ptbin]+p20[ptbin]);
    ebC[plotCount] = eC1[ptbin];
    plotCount++;
  }

  cout << "!!!!!!! Previous Data: 0"<<" !!!!!!!"<< endl;

  //////////
  // 2.5-3.5 GeV Bin
  //////////

  gMinuit->SetFCN(chi2_P0);
  doFit(gMinuit,RbP[0],SF[0],EbP[0],eSF[0]);

  // assign plotting variables
  pTP[0] = 3.;

  // Plot results
  fitResultP->cd(1);
  /*TH1D* dClone = (TH1D*) Hdphi[0]->Clone();
    TH1D* cClone = (TH1D*) projC[0]->Clone();
    TH1D* bClone = (TH1D*) projB[0]->Clone();*/
  TH1D* dClone = (TH1D*) projData0[0]->Clone();
  TH1D* cClone = (TH1D*) HpphiD[0]->Clone();
  TH1D* bClone = (TH1D*) HpphiB[0]->Clone();
  stat[3][0] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][0]->InsertText(statLabel);
  stat[3][0]->SetFillColor(kWhite);
  cClone->Scale((1.-RbP[0])*SF[0]); bClone->Scale(RbP[0]*SF[0]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][0]->Draw("same");

  ////////
  // 5.5-6.5 GeV Bin
  ////////

  gMinuit->SetFCN(chi2_P1);
  doFit(gMinuit,RbP[1],SF[1],EbP[1],eSF[1]);

  // assign plotting variables
  pTP[1] = 6.;

  // Plot results
  fitResultP->cd(2);
  /*dClone = (TH1D*) Hdphi[1]->Clone();
    cClone = (TH1D*) projC[3]->Clone();
    bClone = (TH1D*) projB[3]->Clone();*/
  dClone = (TH1D*) projData2[3]->Clone();
  cClone = (TH1D*) HpphiD[1]->Clone();
  bClone = (TH1D*) HpphiB[1]->Clone();
  stat[3][1] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][1]->InsertText(statLabel);
  stat[3][1]->SetFillColor(kWhite);
  cClone->Scale((1.-RbP[1])*SF[1]); bClone->Scale(RbP[1]*SF[1]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][1]->Draw("same");

  ////////
  // Old Data, Old Template
  ///////
  gMinuit->SetFCN(chi2_PP);
  doFit(gMinuit,RbPP[0],SFPP[0],EbPP[0],eSFPP[0]);

  // assign plotting variables
  pTPP[0] = 3.;

  // Plot results
  fitResultP->cd(3);
  dClone = (TH1D*) Hdphi[0]->Clone();
  cClone = (TH1D*) HpphiD[0]->Clone();
  bClone = (TH1D*) HpphiB[0]->Clone();
  stat[3][2] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][2]->InsertText(statLabel);
  stat[3][2]->SetFillColor(kWhite);
  cClone->Scale((1.-RbPP[0])*SFPP[0]); bClone->Scale(RbPP[0]*SFPP[0]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][2]->Draw("same");

  // Bin at 6 GeV
  gMinuit->SetFCN(chi2_PP1);
  doFit(gMinuit,RbPP[1],SFPP[1],EbPP[1],eSFPP[1]);

  // assign plotting variables
  pTPP[1] = 6.;

  // Plot results
  fitResultP->cd(4);
  dClone = (TH1D*) Hdphi[1]->Clone();
  cClone = (TH1D*) HpphiD[1]->Clone();
  bClone = (TH1D*) HpphiB[1]->Clone();
  stat[3][3] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][3]->InsertText(statLabel);
  stat[3][3]->SetFillColor(kWhite);
  cClone->Scale((1.-RbPP[1])*SFPP[1]); bClone->Scale(RbPP[1]*SFPP[1]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][3]->Draw("same");


  // Get FONLL Calc
  Int_t l=0;
  char line[1000];
  Float_t xF[100],yF[100],minF[100],maxF[100];
  ifstream fp("/Users/zach/Research/pythia/200GeVTemplate/FONLL.txt",ios::in);
  while (!fp.eof()){
    fp.getline(line,1000);
    sscanf(line,"%f %f %f %f",&xF[l],&yF[l],&minF[l],&maxF[l]);
    //  printf("L: %f %f\n",xF[l],yF[l]);
    l++;
  }
  fp.close();

  // Get Previous Analysis 
  Int_t p=0;
  Float_t xP[100],yP[100],dyP[100];
  ifstream fp1("/Users/zach/Research/pythia/200GeVTemplate/run5_6.txt",ios::in);
  while (!fp1.eof()){
    fp1.getline(line,1000);
    sscanf(line,"%f %f %f",&xP[p],&yP[p],&dyP[p]);
    // printf("L: %f %f\n",xF[l],yF[l]);
    p++;
  }
  fp1.close();

  //cout << "at bottom contrib plot" << endl;
  TCanvas* c1 = new TCanvas("c1","Bottom Contribution",150,0,1150,1000);
  TGraphErrors *gr0     = new TGraphErrors(plotCount0-1,ptOFF1,Rb0,dx,eb0);
  TGraphErrors *gr2     = new TGraphErrors(plotCount2-1,ptOFF2,Rb2,dx,eb2);
  TGraphErrors *grC     = new TGraphErrors(plotCount-1,pT,RbC,dx,ebC);
  TGraphErrors *grF     = new TGraphErrors(l-1,xF,yF);
  TGraphErrors *grFmax  = new TGraphErrors(l-1,xF,maxF);
  TGraphErrors *grFmin  = new TGraphErrors(l-1,xF,minF);
  TGraphErrors *grP     = new TGraphErrors(p-1,xP,yP,0,dyP);
  TGraphErrors *grPr    = new TGraphErrors(2,pTP,RbP,0,EbP);
  TGraphErrors *grPPr   = new TGraphErrors(2,pTPP,RbPP,0,EbPP);


  c1->cd(1);

  grP->SetTitle("");
  grP->GetXaxis()->SetTitle("NPE p_{T} (GeV/c)");
  grP->GetYaxis()->SetTitle("r_{B}");
  gr0->SetMarkerStyle(20);
  gr0->SetMarkerSize(1);
  gr0->SetLineColor(kBlue);
  gr0->SetMarkerColor(kBlue);
  gr2->SetMarkerStyle(22);
  gr2->SetMarkerSize(1);
  gr2->SetLineColor(kRed);
  gr2->SetMarkerColor(kRed);
  grC->SetMarkerStyle(21);
  grC->SetMarkerSize(1);
  grC->SetLineColor(kRed);
  grC->SetMarkerColor(kRed);
  grP->GetXaxis()->SetLimits(0,10);
  grP->GetYaxis()->SetRangeUser(0,1);
  grF->SetLineStyle(1);
  grFmax->SetLineStyle(2);
  grFmin->SetLineStyle(2);
  grP->SetMarkerStyle(33);
  grP->SetMarkerColor(kBlack);
  grPr->SetMarkerStyle(29);
  grPr->SetMarkerColor(9);
  grPr->SetLineColor(9);
  grPPr->SetMarkerStyle(29);
  grPPr->SetMarkerColor(49);
  grPPr->SetLineColor(49);


  grP->Draw("AP");
  //grC->Draw("same P");
  gr2->Draw("same P");
  grF->Draw("same");
  grFmax->Draw("same");
  grFmin->Draw("same");
  gr0->Draw("same P");
 // grPr->Draw("same P");
  //grPPr->Draw("same P");

  TLegend* leg2 = new TLegend(0.15,0.68,0.48,0.85);
  leg2->AddEntry(gr0,"STAR Run 12 - Low p_{T} Analysis","pe");
  leg2->AddEntry(gr2,"STAR Run 12 - High p_{T} Analysis","pe");
  //leg2->AddEntry(grC,"Combined Trigs","pe");
  leg2->AddEntry(grP,"STAR Run 6 Analysis (Stat. Uncertainty)","pe");
//  leg2->AddEntry(grPr,"Run 12 Data, Run 5/6 Templates)","pe");
  //leg2->AddEntry(grPPr,"Run 5/6 Refit (prev Template)","pe");
  leg2->AddEntry(grF,"FONLL Calculation","l");
  leg2->Draw("same");

  // Write to Root File if open
  if(makeROOT){
    file3->Close();
    file4->Close();
    file->cd();
    grP->Write("PreviousData");
    //grC->Write("same P");
    gr2->Write("HT2");
    grF->Write("FONLL");
    grFmax->Write("FONLLmax");
    grFmin->Write("FONLLmin");
    gr0->Write("HT0");
    // grPr->Write("PrevTempMyData");
    //grPPr->Write("PrevTempPreData");
  }

  // Make PDF with output canvases
  if(makePDF)
  {
    //Set front page
    TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900);
    fp->cd();
    TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99);
    bLabel->SetFillColor(38);
    bLabel->Draw();
    TLatex tl;
    tl.SetNDC();
    tl.SetTextColor(kWhite);
    tl.SetTextSize(0.033);
    char tlName[100];
    char tlName2[100];

    TString titlename = FileName;
    int found = titlename.Last('/');
    if(found >= 0){
      titlename.Replace(0, found+1, "");
    } 
    sprintf(tlName, "RUN 12 NPE-h   #Delta#phi Correlations");
    tl.SetTextSize(0.05);
    tl.SetTextColor(kWhite);
    tl.DrawLatex(0.05, 0.92,tlName);

    TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12);
    bFoot->SetFillColor(38);
    bFoot->Draw();
    tl.SetTextColor(kWhite);
    tl.SetTextSize(0.05);
    tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString());
    tl.SetTextColor(kBlack);
    tl.SetTextSize(0.03);
    tl.DrawLatex(0.1, 0.14, titlename);
    sprintf(tlName,"TEST");
    tl.DrawLatex(0.1, 0.8,tlName);

    // Place canvases in order
    TCanvas* temp = new TCanvas();
    sprintf(name, "FFOutput/%s.pdf[", FileName);
    temp->Print(name);
    sprintf(name, "FFOutput/%s.pdf", FileName);

    temp = deltaPhi; 
    temp->Print(name);
    temp = fitResult0;
    temp->Print(name);
    temp = fitResult2;
    temp->Print(name);
    // temp = fitResultC;
    // temp->Print(name);
    temp = c1;
    temp->Print(name);

    sprintf(name, "FFOutput/%s.pdf]", FileName);
    temp->Print(name);
  }
  if(makeROOT)
  {
    file->Write();
    file->Close();
  }
}
void NuclearModification(
  TString  particle,
  const int      nbins,
  Double_t xbins[],
  Double_t xhbins[],
  Double_t exl[],
  Double_t exl2[],
  Double_t exl0[],
  Double_t yPercSigmapPbSystTotHigh[],
  Double_t yPercSigmapPbSystTotLow[],
  Double_t commonErrorP,
  Double_t commonErrorN,
  Double_t FFsysterror,
  Double_t tagandprobcorrection[],
  TCanvas *canvasSigma,
  TCanvas *canvasRpA,
  int PadNum
){
  gROOT->SetStyle("Plain");
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  
  TFile*filePPReference=new TFile(Form("../../../fonll/output%s.root",particle.Data()));  
  //###TFile*filePPReference=new TFile(Form("../../fonll/output%s.root",particle.Data()));  
  TGraphAsymmErrors*gaeBplusReference=(TGraphAsymmErrors*)filePPReference->Get(Form("gaeSigmaDecay%s",particle.Data()));
  gaeBplusReference->SetName(Form("gae%sReference",particle.Data()));
  
  TFile*filepPb=new TFile(Form("../Results%s/Sigma%s.root",particle.Data(),particle.Data()));
  TH1F*hSigmapPbStat=(TH1F*)filepPb->Get("hPtSigma");  
  TH1F*hPt=(TH1F*)filepPb->Get("hPt");
  TH1F*hEff=(TH1F*)filepPb->Get("hEff");
  
  double scalingfactor=1e-6;
  double yvalue,xvalue,yerrorhigh,yerrorlow;
  
  for (int i=0;i<nbins;i++){
    hSigmapPbStat->SetBinContent(i+1,scalingfactor*hSigmapPbStat->GetBinContent(i+1));
    hSigmapPbStat->SetBinError(i+1,scalingfactor*hSigmapPbStat->GetBinError(i+1));
    
    yvalue=-1.;
    xvalue=-1.;
    yerrorhigh=-1.;
    yerrorlow=-1.;
    
    gaeBplusReference->GetPoint(i,xvalue,yvalue);
    yerrorhigh=gaeBplusReference->GetEYhigh()[i];
    yerrorlow=gaeBplusReference->GetEYlow()[i];
  
    gaeBplusReference->SetPoint(i,xvalue,yvalue*scalingfactor);
    gaeBplusReference->SetPointEYhigh(i,yerrorhigh*scalingfactor);
    gaeBplusReference->SetPointEYlow(i,yerrorlow*scalingfactor);

  } 
  
  
  for (int i=0;i<nbins;i++){
    hSigmapPbStat->SetBinContent(i+1,(1./tagandprobcorrection[i])*hSigmapPbStat->GetBinContent(i+1));
    hSigmapPbStat->SetBinError(i+1,(1./tagandprobcorrection[i])*hSigmapPbStat->GetBinError(i+1));
  
  } 
  Double_t yRefPP[nbins];                        //value y reference
  Double_t xRefPP[nbins];                        //value x reference
  Double_t yPPsystFONLLhigh[nbins];              //y err syst FONLL high
  Double_t yPPsystFONLLlow[nbins];               //y err syst FONLL low
  Double_t yPercPPsystFONLLhigh[nbins];          //y percentuale err syst FONLL high
  Double_t yPercPPsystFONLLlow[nbins];           //y percentuale err syst FONLL low
    
  Double_t ySigmapPb[nbins];                     //value y pPb 
  Double_t xSigmapPb[nbins];                     //value x pPb
  Double_t ySigmapPbStat[nbins];                 //y err stat pPb
  Double_t yPercSigmapPbStat[nbins];             //y err stat pPb
  
  Double_t yFONLL[nbins];                        //1
  Double_t yRpA[nbins];                          //value y RpA 
  Double_t yRpAStat[nbins];                      //y err stat RpA 
  Double_t yRpAsystFONLLhigh[nbins];             //y err syst FONLL RpA high
  Double_t yRpAsystFONLLlow[nbins];              //y err syst FONLL RpA lzow
  Double_t yPercRpAsystFONLLhigh[nbins];         //y percentuale err syst FONLL RpA high
  Double_t yPercRpAsystFONLLlow[nbins];          //y percentuale err syst FONLL RpA low
    
  Double_t ySigmapPbSystTotHigh[nbins];              //y percentuale err syst pPb TOT
  Double_t ySigmapPbSystTotLow[nbins];              //y percentuale err syst pPb TOT

  Double_t yPercRpPbSystTotHigh[nbins];          //y percentuale err syst RpPb TOT
  Double_t yPercRpPbSystTotLow[nbins];          //y percentuale err syst RpPb TOT
  
  Double_t yRpPbSystTotHigh[nbins];              //y percentuale err syst RpPb TOT
  Double_t yRpPbSystTotLow[nbins];              //y percentuale err syst RpPb TOT

  
  double x,y;
  for (Int_t i=0;i<nbins;i++) {
    gaeBplusReference->GetPoint(i,xRefPP[i],yRefPP[i]);
    yPPsystFONLLhigh[i]=gaeBplusReference->GetEYhigh()[i];
    yPPsystFONLLlow[i]=gaeBplusReference->GetEYlow()[i];
    yPercPPsystFONLLhigh[i]=yPPsystFONLLhigh[i]/yRefPP[i];
    yPercPPsystFONLLlow[i]=yPPsystFONLLlow[i]/yRefPP[i];
    yPercPPsystFONLLhigh[i]=TMath::Sqrt(yPercPPsystFONLLhigh[i]*yPercPPsystFONLLhigh[i]+FFsysterror*FFsysterror);
    yPercPPsystFONLLlow[i]=TMath::Sqrt(yPercPPsystFONLLlow[i]*yPercPPsystFONLLlow[i]+FFsysterror*FFsysterror);
    
  }
  
  for(Int_t i=0;i<nbins;i++) {
    ySigmapPb[i]=hSigmapPbStat->GetBinContent(i+1);
    ySigmapPbStat[i]=hSigmapPbStat->GetBinError(i+1);
    yPercSigmapPbStat[i]=ySigmapPbStat[i]/ySigmapPb[i];
    ySigmapPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*ySigmapPb[i];
    ySigmapPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*ySigmapPb[i];
  }
  
  for(Int_t i=0;i<nbins;i++) {
    yRpA[i]=ySigmapPb[i]/yRefPP[i];
    yRpAStat[i]=ySigmapPbStat[i]/yRefPP[i];
    yFONLL[i]=yRpA[i];
    yPercRpAsystFONLLhigh[i]=(yPercPPsystFONLLlow[i]/(1-yPercPPsystFONLLlow[i]));
    yPercRpAsystFONLLlow[i]=(yPercPPsystFONLLhigh[i]/(1+yPercPPsystFONLLhigh[i]));
    yRpAsystFONLLhigh[i]=yPercRpAsystFONLLhigh[i]*yRpA[i];
    yRpAsystFONLLlow[i]=yPercRpAsystFONLLlow[i]*yRpA[i];

    yRpPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*yRpA[i];
    yRpPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*yRpA[i];   

	std::cout << i << " , " << xbins[i] << " , " << ySigmapPb[i] << " , sta: " << ySigmapPbStat[i] << " , syslow: " << ySigmapPbSystTotLow[i] << " ,syshigh: " << ySigmapPbSystTotHigh[i] << std::endl;
	std::cout << "FONLL: " << yRefPP[i] << " - " << yPPsystFONLLlow[i] << " + " << yPPsystFONLLhigh[i] << std::endl;
	std::cout << i << " ####### " << xbins[i] << " , " << yRpA[i] << " , sta: " << yRpAStat[i] << " , syslow: " << yRpPbSystTotLow[i] << " ,syshigh: " << yRpPbSystTotHigh[i] << " ,FONLLlow: " << yRpAsystFONLLlow[i] << " , FONLLhigh: " << yRpAsystFONLLhigh[i] << std::endl;

  TGraphAsymmErrors *gRpAstat = new TGraphAsymmErrors(nbins,xbins,yRpA,exl0,exl0,yRpAStat,yRpAStat);
  TGraphAsymmErrors *gRpAsyst = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpPbSystTotLow,yRpPbSystTotHigh);
  TGraphAsymmErrors *gRpAsystFONLL = new TGraphAsymmErrors(nbins,xbins,yFONLL,exl,exl,yRpAsystFONLLlow,yRpAsystFONLLhigh);
 

  }
  
  TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl2,exl2,ySigmapPbSystTotLow,ySigmapPbSystTotHigh);
  //###TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbSystTotLow,ySigmapPbSystTotHigh);


  gSigmasyst->SetTitle("Sigma syst uncertainty from pPb");
  gSigmasyst->SetMarkerColor(1);
  gSigmasyst->SetLineColor(1);
  gSigmasyst->SetLineWidth(1);   
  gSigmasyst->SetMarkerStyle(21);
  gSigmasyst->SetMarkerColor(1);
  gSigmasyst->SetFillColor(kYellow-7);//5
  gSigmasyst->SetFillStyle(1001);
  TGraphAsymmErrors*gSigmasyst2=(TGraphAsymmErrors*)gSigmasyst->Clone();
  gSigmasyst2->SetMarkerColor(1);
  gSigmasyst2->SetMarkerStyle(25);
  gSigmasyst2->SetFillColor(0);
  gSigmasyst2->SetFillStyle(0);
  gSigmasyst2->SetLineColor(1);//5
  gSigmasyst2->SetLineStyle(1);
  gSigmasyst2->SetLineWidth(1);
 

  //###TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbStat,ySigmapPbStat);
  TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl0,exl0,ySigmapPbStat,ySigmapPbStat);


  gSigmastat->SetTitle("Sigma stat uncertainty from pPb");
  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetLineColor(1);
  gSigmastat->SetLineWidth(2);//###   
  gSigmastat->SetMarkerStyle(21);
  gSigmastat->SetMarkerColor(1);
  
  gSigmastat->SetFillColor(0);
  gSigmastat->SetFillStyle(0);
  gSigmastat->SetFillStyle(0);

  Double_t padcorrection;
  if (particle=="Bplus") padcorrection=Bp_padratio/Bp_padratio;
  else if (particle=="Bzero") padcorrection=Bp_padratio/B0_padratio;
  else if (particle=="Bs") padcorrection=Bp_padratio/Bs_padratio;
  std::cout << "padcorrection: " << padcorrection << std::endl;
  canvasSigma->cd(PadNum);
  //canvasSigma->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasSigma->SetFillColor(0);
  canvasSigma->SetBorderMode(0);
  canvasSigma->SetBorderSize(2);
  //canvasSigma->SetLeftMargin(0.1451613);
  //canvasSigma->SetRightMargin(0.05443548);
  //canvasSigma->SetTopMargin(0.005);//0.08474576
  //canvasSigma->SetBottomMargin(0.1165254);
  canvasSigma->SetFrameBorderMode(0);
  canvasSigma->SetFrameBorderMode(0);
  canvasSigma->SetLogy();
  
  //###TH2F* hempty=new TH2F("hempty","", 10, 0.1, 65., 10., 0.1, 1e3);    
  TH2F* hempty=new TH2F("hempty","", 10, 0.1, 65., 10., 0.3, 1e3);    
  hempty->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  //if(particle=="Bplus") hempty->GetYaxis()->SetTitle("d#sigma / dp_{T} (B^{+}) (pb GeV^{-1}c)");
  //if(particle=="Bzero") hempty->GetYaxis()->SetTitle("d#sigma / dp_{T} (B^{0}) (pb GeV^{-1}c)");
  //if(particle=="Bs") hempty->GetYaxis()->SetTitle("d#sigma / dp_{T} (B_{s}) (pb GeV^{-1}c)");
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  //###hempty->GetYaxis()->SetTitle("d#sigma / dp_{T}( #mub GeV^{-1}c)");
  hempty->GetYaxis()->SetTitle("d#sigma / dp_{T}(#mub/(GeV/c))");
  //###hempty->GetXaxis()->SetTitleOffset(1.0);//###1.0
  if (particle=="Bplus") hempty->GetXaxis()->SetTitleOffset(0.90);//###1.0
  else if (particle=="Bzero") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.80
  else if (particle=="Bs") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.85

  hempty->GetYaxis()->SetTitleOffset(1.0);//###1.3
  hempty->GetXaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetYaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.060*padcorrection);//###0.055
  hempty->GetYaxis()->SetLabelSize(0.060*padcorrection);//###0.055
  if (particle=="Bplus") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.005
  else if (particle=="Bzero") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0001
  else if (particle=="Bs") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0005
  //###hempty->GetXaxis()->SetLabelOffset(0.005);//###0.005
  hempty->SetMaximum(2);
  hempty->SetMinimum(0.);
  hempty->Draw();
  
  gaeBplusReference->SetMarkerColor(1);
  gaeBplusReference->SetMarkerStyle(25);  
  gaeBplusReference->SetFillColor(kYellow-7);//5
  gaeBplusReference->SetFillStyle(1001);
  gaeBplusReference->SetLineColor(kAzure-3);
  gaeBplusReference->SetLineWidth(1);
  
  
  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetLineColor(1);
  gSigmastat->SetLineWidth(2);   
  gSigmastat->SetMarkerStyle(21);
  gSigmastat->SetMarkerColor(1);

  // Histogram style
  TH1D* hBplusReference = new TH1D("hBplusReference","",nbins,xhbins);
  TH1D* hBplusReferenceEYhigh = new TH1D("hBplusReferenceEYhigh","",nbins,xhbins);
  TH1D* hBplusReferenceEYlow = new TH1D("hBplusReferenceEYlow","",nbins,xhbins);



  for (int i=0;i<nbins;i++){
	double xgae,ygae;
	gaeBplusReference->GetPoint(i,xgae,ygae);
	hBplusReference->SetBinContent(i+1,ygae);
	hBplusReferenceEYhigh->SetBinContent(i+1,ygae+gaeBplusReference->GetEYhigh()[i]);
	hBplusReferenceEYlow->SetBinContent(i+1,ygae-gaeBplusReference->GetEYlow()[i]);
	std::cout << "### FONLL (" << i << ") : " << ygae << " + " << gaeBplusReference->GetEYhigh()[i] << " - " << gaeBplusReference->GetEYlow()[i] << std::endl;
}

  //hBplusReference->SetMarkerColor(1);
  //hBplusReference->SetMarkerStyle(25);  
  //hBplusReference->SetFillColor(kYellow-7);//5
  //hBplusReference->SetFillStyle(1001);
  hBplusReference->SetLineColor(kAzure-3);
  hBplusReference->SetLineWidth(2);
  hBplusReferenceEYhigh->SetLineColor(kAzure-3);
  hBplusReferenceEYhigh->SetLineWidth(2);
  hBplusReferenceEYhigh->SetLineStyle(2);
  hBplusReferenceEYlow->SetLineColor(kAzure-3);
  hBplusReferenceEYlow->SetLineWidth(2);
  hBplusReferenceEYlow->SetLineStyle(2);


/*
  hBplusReference->Draw("][,same");

  hBplusReferenceEYhigh->Draw("][,same");
  hBplusReferenceEYlow->Draw("][,same");
*/


/*
  gaeBplusReference->Draw("2psame");//2same
  TGraphAsymmErrors*gaeBplusReference2=(TGraphAsymmErrors*)gaeBplusReference->Clone();
  gaeBplusReference2->SetMarkerColor(1);
  gaeBplusReference2->SetMarkerStyle(25);  
  gaeBplusReference2->SetFillColor(0);
  gaeBplusReference2->SetFillStyle(0);
  gaeBplusReference2->SetLineColor(kAzure-3);
  gaeBplusReference2->SetLineWidth(1);
  gaeBplusReference2->Draw("2psame");//2same
*/
 
  //coord.  for legend for sigma in the B+ pannel 
  //###TLegend *legendSigma=new TLegend(0.468298,0.7045614,0.7678185,0.8757895,"");
  //###TLegend *legendSigma=new TLegend(0.55,0.63,0.85,0.80,"");
  TLegend *legendSigma=new TLegend(0.38,0.67,0.68,0.84,"");


  legendSigma->SetBorderSize(0);
  legendSigma->SetLineColor(0);
  legendSigma->SetFillColor(0);
  legendSigma->SetFillStyle(1001);
  legendSigma->SetTextFont(42);
  legendSigma->SetTextSize(0.060);//###0.045
/* 
  TBox *c = new TBox(3,1-commonErrorN,7,1+commonErrorP);
  c->SetLineColor(5);
  c->SetFillColor(5);
  c->Draw();

  TBox *c2 = c->Clone();
  c2->SetLineColor(1);
  c2->SetFillStyle(0);
  c2->Draw();
*/  
  //TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmastat,"pPb","pf");
  TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmasyst,"pPb","pf");


/*
  ent_SigmapPb->SetTextFont(42);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetMarkerColor(1);
  ent_SigmapPb->SetFillColor(0);
  ent_SigmapPb->SetFillStyle(0);
*/
  ent_SigmapPb->SetTextFont(42);
  ent_SigmapPb->SetMarkerColor(1);
  ent_SigmapPb->SetMarkerStyle(25);  
  //ent_SigmapPb->SetFillColor(kYellow-7);//5
  //ent_SigmapPb->SetFillStyle(1001);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetLineWidth(0);
  ent_SigmapPb->SetLineStyle(0);
 

/*
  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(gaeBplusReference,"FONLL pp ref.","pf");
  ent_Sigmapp->SetTextFont(42);
  ent_Sigmapp->SetLineColor(kAzure-3);//5
  ent_Sigmapp->SetLineStyle(1);
  ent_Sigmapp->SetMarkerColor(1);
  ent_Sigmapp->SetMarkerStyle(21);
*/
  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(hBplusReference,"Scaled FONLL pp ref.","l");
  ent_Sigmapp->SetTextFont(42);
  ent_Sigmapp->SetLineColor(kAzure-3);//5
  ent_Sigmapp->SetLineStyle(1);
  ent_Sigmapp->SetMarkerColor(1);
  ent_Sigmapp->SetMarkerStyle(21);

  TLegendEntry *ent_Sigmapperr=legendSigma->AddEntry(hBplusReferenceEYhigh,"FONLL pp ref. uncert.","l");
  ent_Sigmapperr->SetTextFont(42);
  ent_Sigmapperr->SetLineColor(kAzure-3);//5
  ent_Sigmapperr->SetLineStyle(2);
  ent_Sigmapperr->SetMarkerColor(1);
  ent_Sigmapperr->SetMarkerStyle(21);


  //###gSigmasyst->SetFillColor(0);
  //###gSigmasyst->SetFillStyle(0);

for (int i=0;i<nbins;i++){
        double xgae,ygae;
        gSigmastat->GetPoint(i,xgae,ygae);
        std::cout << "### cross section (" << i << ") : " << ygae << " stat: " << gSigmastat->GetEYhigh()[i] << " syst: " << gSigmasyst->GetEYhigh()[i] << std::endl;
}

  gSigmasyst->Draw("2esame");//###2psame
  gSigmasyst2->Draw("2esame");

  hBplusReference->Draw("][,same");

  hBplusReferenceEYhigh->Draw("][,same");
  hBplusReferenceEYlow->Draw("][,same");

  gSigmastat->SetFillColor(0);
  gSigmastat->Draw("epsame");
/*  
  TBox *d = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  d->SetLineColor(1);
  d->SetFillColor(0);
  d->Draw();
*/  
  //if(PadNum==0 || PadNum==1){
  if(PadNum==3 || PadNum==1 || PadNum==2){


    legendSigma->Draw("same");
    
    //TLatex * tlatex1=new TLatex(0.21,0.88801268,"CMS");
    TLatex * tlatex1=new TLatex(0.19,0.86,"CMS");
    tlatex1->SetNDC();
    tlatex1->SetTextColor(1);
    tlatex1->SetTextFont(62);//42
    tlatex1->SetTextSize(0.07);//0.045
    tlatex1->Draw();
/*
    TLatex * tlatex12=new TLatex(0.35,0.86,"Preliminary");
    tlatex12->SetNDC();
    tlatex12->SetTextColor(1);
    tlatex12->SetTextFont(52);//42
    tlatex12->SetTextSize(0.05);//0.045
    tlatex12->Draw();
*/   
    //TLatex * tlatexlumi=new TLatex(0.471371,0.88801268,"L = 34.8 nb^{-1} (pPb 5.02 TeV)");
    //TLatex * tlatexlumi=new TLatex(0.471371,0.88801268,"34.6 nb^{-1} (pPb 5.02 TeV)");
    TLatex * tlatexlumi;
//###TLatex * tlatexlumi=new TLatex(0.390,0.950,"34.6 nb^{-1} (pPb 5.02 TeV)");
   if (PadNum==1) tlatexlumi = new TLatex(0.41,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
   else tlatexlumi = new TLatex(0.39,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
    tlatexlumi->SetNDC();
    tlatexlumi->SetTextColor(1);
    tlatexlumi->SetTextFont(42);
    tlatexlumi->SetTextSize(0.06);//0.045
    tlatexlumi->Draw();
  }

   //if(PadNum==2){
    if(PadNum==3 || PadNum==1 || PadNum==2) {
    //TLatex * tlatex4=new TLatex(0.60,0.73,"|y_{lab}| < 2.4");
    TLatex * tlatex4=new TLatex(0.65,0.50,"|y_{lab}| < 2.4");


    tlatex4->SetNDC();
    tlatex4->SetTextColor(1);
    tlatex4->SetTextFont(42);//42
    tlatex4->SetTextSize(0.07);//0.045
    tlatex4->Draw();
	 }

	double GloUnc;
	double xtl5=0.54;

   if(PadNum==1) {GloUnc=Bp_commonErrorP*100;xtl5=0.54;}//###0.57
   if(PadNum==2) {GloUnc=B0_commonErrorP*100;xtl5=0.47;}
   if(PadNum==3) {GloUnc=Bs_commonErrorP*100;xtl5=0.42;}

	xtl5=0.54;


//TLegend *legendSigma=new TLegend(0.55,0.63,0.85,0.80,"");
   TLatex * tlatex5=new TLatex(xtl5,0.60,Form("Global uncert. %2.1f%%",GloUnc));
    tlatex5->SetNDC();
    tlatex5->SetTextColor(1);
    tlatex5->SetTextFont(42);//42
    tlatex5->SetTextSize(0.05*padcorrection);//0.045
    tlatex5->Draw();

  //###double xpos=0.8528226;
  //###double ypos=0.6849894;
  double xpos=0.90;//0.86
  double ypos=0.85;//0.86
  
  TString mypar;
  if(particle=="Bplus") mypar="B^{+}";
  if(particle=="Bzero") mypar="B^{0}";
  if(particle=="Bs") mypar="B_{s}^{0}";  

  double xlgap=0.04;
/*
  if(particle=="Bplus") xpos=(0.365816-xlgap)/0.365816;
  if(particle=="Bzero") xpos=1-xlgap/(0.673101-0.365816);
  if(particle=="Bs") xpos=0.94-xlgap/(1-0.673101);;  
*/
  TLatex * tlatex3=new TLatex(xpos,ypos,mypar.Data());
  tlatex3->SetNDC();
  tlatex3->SetTextColor(1);
  tlatex3->SetTextFont(42);
  tlatex3->SetTextSize(0.07*padcorrection);
  tlatex3->Draw();

  TGraphAsymmErrors *gRpAstat = new TGraphAsymmErrors(nbins,xbins,yRpA,exl0,exl0,yRpAStat,yRpAStat);
  gRpAstat->SetTitle("RpA stat uncertainty from pPb");
  gRpAstat->SetMarkerStyle(21);
  gRpAstat->SetMarkerColor(1);
  gRpAstat->SetLineColor(1);
  gRpAstat->SetLineWidth(2);  
  gRpAstat->SetFillColor(0);


  TGraphAsymmErrors *gRpAsyst = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpPbSystTotLow,yRpPbSystTotHigh);
  gRpAsyst->SetTitle("RpA syst uncertainty from pPb");
  gRpAsyst->SetName("gRpAsyst");
/*
  gRpAsyst->SetFillColor(0);
  gRpAsyst->SetMarkerSize(0);
  gRpAsyst->SetLineColor(1);
  gRpAsyst->SetLineWidth(2);
  gRpAsyst->SetFillStyle(0);
*/
  gRpAsyst->SetFillColor(kYellow-7);//###0
  //gRpAsyst->SetMarkerSize(0);
  gRpAsyst->SetLineColor(1);
  gRpAsyst->SetLineWidth(2);
  gRpAsyst->SetFillStyle(1001);
  gRpAsyst->SetMarkerStyle(21);
  gRpAsyst->SetMarkerColor(1);
  TGraphAsymmErrors*gRpAsyst2=(TGraphAsymmErrors*)gRpAsyst->Clone();
  gRpAsyst2->SetMarkerColor(1);
  gRpAsyst2->SetMarkerStyle(25);
  gRpAsyst2->SetFillColor(0);
  gRpAsyst2->SetFillStyle(0);
  gRpAsyst2->SetLineColor(1);//5
  gRpAsyst2->SetLineStyle(1);
  gRpAsyst2->SetLineWidth(2);
  
  TGraphAsymmErrors *gRpAsystFONLL = new TGraphAsymmErrors(nbins,xbins,yFONLL,exl,exl,yRpAsystFONLLlow,yRpAsystFONLLhigh);
  gRpAsystFONLL->SetTitle("RpA syst uncertainty from FONLL reference");
/*
  gRpAsystFONLL->SetFillColor(kYellow-7);//5
  gRpAsystFONLL->SetLineColor(kAzure-3);//5
  gRpAsystFONLL->SetMarkerColor(4);//kAzure-3);

  TGraphAsymmErrors *gRpAsystFONLL2 = (TGraphAsymmErrors*)gRpAsystFONLL->Clone();
  gRpAsystFONLL2->SetFillStyle(0);
  gRpAsystFONLL2->SetLineColor(kAzure-3);//5
  gRpAsystFONLL2->SetMarkerColor(4);//kAzure-3);
*/
  gRpAsystFONLL->SetFillColor(0);//5,kYellow-7
  gRpAsystFONLL->SetLineColor(kAzure-3);//5
  gRpAsystFONLL->SetMarkerColor(4);//kAzure-3);
  gRpAsystFONLL->SetLineStyle(1);
  gRpAsystFONLL->SetLineWidth(2);

  TGraphAsymmErrors*gRpAsystFONLL2=(TGraphAsymmErrors*)gRpAsystFONLL->Clone();
  gRpAsystFONLL2->SetMarkerColor(1);
  gRpAsystFONLL2->SetMarkerStyle(25);
  gRpAsystFONLL2->SetFillColor(0);
  gRpAsystFONLL2->SetFillStyle(0);
  gRpAsystFONLL2->SetLineColor(kAzure-3);//5
  gRpAsystFONLL2->SetLineStyle(1);
  gRpAsystFONLL2->SetLineWidth(2);

  canvasRpA->cd(PadNum);
  //canvasRpA->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasRpA->SetFillColor(0);
  canvasRpA->SetBorderMode(0);
  canvasRpA->SetBorderSize(2);
/*
  canvasRpA->SetLeftMargin(0.1451613);
  canvasRpA->SetRightMargin(0.05443548);
  canvasRpA->SetTopMargin(0.08474576);
  canvasRpA->SetBottomMargin(0.1165254);
*/
  canvasRpA->SetFrameBorderMode(0);
  canvasRpA->SetFrameBorderMode(0);
  
  hempty=new TH2F("hempty","",10,0.1, 62. ,30.,0.,3.0);  
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  hempty->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}");
  //###hempty->GetXaxis()->SetTitleOffset(1.0);//###1.3
  hempty->GetYaxis()->SetTitleOffset(1.0);//###1.1
  hempty->GetXaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetYaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.060*padcorrection);//###0.055
  hempty->GetYaxis()->SetLabelSize(0.060*padcorrection);//###0.055  
  if (particle=="Bplus") hempty->GetXaxis()->SetTitleOffset(0.90);//###1.0
  else if (particle=="Bzero") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.80
  else if (particle=="Bs") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.85
  if (particle=="Bplus") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.005
  else if (particle=="Bzero") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0001
  else if (particle=="Bs") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0005
  //###hempty->SetMaximum(2);
  hempty->SetMaximum(3.0);
  hempty->SetMinimum(0.);

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

  //TLine *line = new TLine(8.740882,1.017445,61,1.008586);
  //###TLine *line = new TLine(4.740882,1.017445,61,1.008586);
  TLine *line = new TLine(4.740882,1.00,61,1.00);


  line->SetLineColor(kRed);//###
  line->SetLineStyle(2);  
  line->SetLineWidth(2);
/*  
  gRpAsystFONLL->Draw("2same");
  gRpAsystFONLL2->Draw("2same");
  line->Draw();
  gRpAsyst->Draw("2esame");
  gRpAstat->Draw("psame");
*/
  gRpAstat->SetMarkerStyle(21);
  gRpAstat->SetLineColor(1);
  gRpAstat->SetMarkerColor(1);

for (int i=0;i<nbins;i++){
         double xgae,ygae;
         gRpAstat->GetPoint(i,xgae,ygae);
         std::cout << "####### RpA (" << i << ") : " << ygae << " stat: " << gRpAstat->GetEYhigh()[i] << " syst: " << gRpAsyst->GetEYhigh()[i] << std::endl;
	 std::cout << "########### FONLL (" << i << ") : " << " + " << gRpAsystFONLL->GetEYhigh()[i] << " - " << gRpAsystFONLL->GetEYlow()[i] << std::    endl;
}

  gRpAsystFONLL->Draw("2same");
  gRpAsystFONLL2->Draw("2same");
  //###line->Draw();

  gRpAsyst->Draw("2esame");
  gRpAsyst2->Draw("2esame");
  gRpAstat->Draw("psame");  
  line->Draw();

 
  TBox *a = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  a->SetLineColor(1);
  a->SetFillColor(0);
  a->Draw();
  std::cout << "%%%%%%% RpA commonError " << " - " << commonErrorN << " + " << commonErrorP << std::endl;
  TBox *b = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  b->SetLineColor(1);
  b->SetFillColor(kGray);
  b->Draw();
  TBox *b2 = (TBox*)b->Clone();
  b2->SetLineColor(1);
  b2->SetFillStyle(0);
  b2->Draw();

  TLegend *legendRpA=new TLegend(0.22,0.60,0.51,0.83,"");

  legendRpA->SetBorderSize(0);
  legendRpA->SetLineColor(0);
  legendRpA->SetFillColor(0);
  legendRpA->SetFillStyle(1001);
  legendRpA->SetTextFont(42);
  legendRpA->SetTextSize(0.060);//###0.045

  TLegendEntry *ent_RpAstat=legendRpA->AddEntry(gRpAstat,"R^{FONLL}_{pA}","p");
  //###TLegendEntry *ent_RpAstat=legendRpA->AddEntry(gRpAstat,"pPb data","pf");

/*
  ent_RpAstat->SetTextFont(42);
  ent_RpAstat->SetLineColor(2);
  ent_RpAstat->SetMarkerColor(2);
*/
  ent_RpAstat->SetTextFont(42);
  ent_RpAstat->SetMarkerColor(1);
  ent_RpAstat->SetMarkerStyle(25);
  //ent_RpAstat->SetFillColor(kYellow-7);//5
  //ent_RpAstat->SetFillStyle(1001);
  ent_RpAstat->SetLineColor(1);
  ent_RpAstat->SetLineWidth(2);
  ent_RpAstat->SetLineStyle(0);

  TLegendEntry *ent_RpAsyst=legendRpA->AddEntry(gRpAsyst,"Syst. pPb data","f");
  ent_RpAsyst->SetTextFont(42);
  ent_RpAsyst->SetMarkerColor(1);
  ent_RpAsyst->SetMarkerStyle(25);
  //ent_RpAsyst->SetFillColor(kYellow-7);//5
  //ent_RpAsyst->SetFillStyle(1001);
  ent_RpAsyst->SetLineColor(1);
  ent_RpAsyst->SetLineWidth(2);
  ent_RpAsyst->SetLineStyle(0);
  
  TLegendEntry *ent_RpAsystFONLL=legendRpA->AddEntry(gRpAsystFONLL,"Syst. FONLL pp ref.","f");
/*
  ent_RpAsystFONLL->SetTextFont(42);
  ent_RpAsystFONLL->SetLineColor(kAzure-3);//5
  ent_RpAsystFONLL->SetLineStyle(1);
  ent_RpAsystFONLL->SetLineWidth(1);
  ent_RpAsystFONLL->SetMarkerColor(kYellow-7);//5
*/

  ent_RpAsystFONLL->SetTextFont(42);
  ent_RpAsystFONLL->SetLineColor(2);//###5
  ent_RpAsystFONLL->SetLineStyle(1);
  ent_RpAsystFONLL->SetMarkerColor(kYellow-7);//5

   TLegendEntry *ent_RpAsystData=legendRpA->AddEntry(b,"Syst. int. lumi + B","f");
/*
  ent_RpAsystData->SetTextFont(42);
  ent_RpAsystData->SetLineColor(1);
  ent_RpAsystData->SetMarkerColor(2);
*/
  ent_RpAsystData->SetTextFont(42);
  ent_RpAsystData->SetLineColor(2);
  ent_RpAsystData->SetMarkerColor(2);
 
  //if(PadNum==1||PadNum==3){
    if(PadNum==3 || PadNum==1 || PadNum==2) {

    legendRpA->Draw();

    //TLatex * tlatex4=new TLatex(0.21,0.88801268,"CMS");
    TLatex * tlatex4=new TLatex(0.19,0.85,"CMS");

    tlatex4->SetNDC();
    tlatex4->SetTextColor(1);
    tlatex4->SetTextFont(62);//42
    tlatex4->SetTextSize(0.07);//0.045
    tlatex4->Draw();
/* 
    TLatex * tlatex42=new TLatex(0.35,0.86,"Preliminary");
    tlatex42->SetNDC();
    tlatex42->SetTextColor(1);
    tlatex42->SetTextFont(52);//42
    tlatex42->SetTextSize(0.05);//0.045
    tlatex42->Draw();
*/ 
    //TLatex * tlatex2=new TLatex(0.471371,0.88801268,"L = 34.8 nb^{-1} (pPb 5.02 TeV)");
    //TLatex * tlatex2=new TLatex(0.471371,0.88801268,"34.6 nb^{-1} (pPb 5.02 TeV)");
    //###TLatex * tlatex2=new TLatex(0.390,0.950,"34.6 nb^{-1} (pPb 5.02 TeV)");
    TLatex * tlatex2;

   if (PadNum==1) tlatex2 = new TLatex(0.41,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
   else tlatex2 = new TLatex(0.39,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");

    tlatex2->SetNDC();
    tlatex2->SetTextColor(1);
    tlatex2->SetTextFont(42);
    tlatex2->SetTextSize(0.06);//0.045
   tlatex2->Draw();
  }
    //if(PadNum==2){
    if(PadNum==3 || PadNum==1 || PadNum==2) {

    TLatex * tlatex4=new TLatex(0.65,0.23,"|y_{lab}| < 2.4");
    tlatex4->SetNDC();
    tlatex4->SetTextColor(1);
    tlatex4->SetTextFont(42);//42
    tlatex4->SetTextSize(0.07);//0.045
    tlatex4->Draw();
	 }

  
  tlatex3->Draw();
  
  
  
  TFile *fout=new TFile(Form("../Results%s/fileRpA%s.root",particle.Data(),particle.Data()),"recreate");  
  fout->cd();
  gSigmasyst->SetName("gSigmasyst");
  gSigmasyst->Write();
  gaeBplusReference->Write();
  hSigmapPbStat->Write();
}
Example #18
0
void plot_ljpsi(const char* fdata, const char* fmc) {
   TFile *tfd = TFile::Open(fdata);
   TFile *tfm = TFile::Open(fmc);

   TCanvas *c1 = new TCanvas();
   c1->cd();
   TPad *p1 = new TPad("p1","",0,0,1,0.33);
   p1->SetBottomMargin(2.*gStyle->GetPadBottomMargin());
   p1->SetTopMargin(0);
   p1->SetFrameBorderMode(0);
   p1->SetBorderMode(0);
   p1->SetBorderSize(0);
   p1->SetGridy();
   if (datamc) p1->Draw();
   TPad *p2 = new TPad("p2","",0,0.33,1,1);
   // p2->SetTopMargin(gStyle->GetPadTopMargin()/(1.-0.2));
   p2->SetBottomMargin(0);
   p2->SetFrameBorderMode(0);
   p2->SetBorderMode(0);
   p2->SetBorderSize(0);
   // p2->SetLogy();
   if (datamc) p2->Draw();
   p1->cd();
   if (!datamc) c1->cd();

   TF1 *dg = new TF1("f1","[0]*([1]*TMath::Gaus(x,[2],[3])+(1-[1])*TMath::Gaus(x,[4],[3]*[5]))",-0.2,0.04);
   dg->SetParLimits(0,0,1e15);
   dg->SetParLimits(1,0.5,1);
   dg->SetParLimits(2,-0.05,0.05);
   dg->SetParLimits(3,0,0.1);
   dg->SetParLimits(4,-0.05,0.05);
   dg->SetParLimits(5,0,100);
   dg->SetParameters(1000,0.8,1e-3,0.03,1e-4,2.);

   TIter next(tfd->GetListOfKeys()); TObject *obj;
   while ((obj = next())) {
      obj = ((TKey*) obj)->ReadObj();
      if (TString(obj->ClassName()) == "TH1F") {
         TH1F *hdata = (TH1F*) tfd->Get(obj->GetName());
         TH1F *hmc = (TH1F*) tfm->Get(obj->GetName());
         // hdata->Rebin(6);
         // hmc->Rebin(6);

         if (!integrate) {
            double int_data = hdata->Integral(hdata->FindBin(-0.015), hdata->FindBin(0.015));
            double int_mc = hmc->Integral(hmc->FindBin(-0.015), hmc->FindBin(0.015));
            hmc->Scale(int_data/int_mc);
         } else {
            double int_mc_all = hmc->Integral(0, hmc->GetNbinsX()+1);
            double int_data_all = hdata->Integral(0, hdata->GetNbinsX()+1);
            hmc->Scale(1./int_mc_all);
            hdata->Scale(1./int_data_all);
            double int_data = hdata->Integral(0, hdata->FindBin(0.));
            double int_mc = hmc->Integral(0, hmc->FindBin(0.));
            hdata->Scale(int_mc/int_data); 
            integrateHist(hdata);
            integrateHist(hmc);
         }
         hdata->GetXaxis()->SetTitle("#font[12]{l}_{J/#psi} [mm]");
         hdata->GetYaxis()->SetTitle("Entries");
         if (integrate) hdata->GetYaxis()->SetTitle("c.d.f.");

         // read the bin from the name
         TString thname(hdata->GetName());
         bool isfwd = (thname.Index("fwd") != kNPOS);
         int pos1 = thname.Index("pt")+2;
         int pos2 = thname.Index("-")-pos1;
         TString tsubstr(thname(pos1,pos2));
         float ptmin = atof(tsubstr.Data());
         pos1 = thname.Index("-")+1;
         pos2 = thname.Length();
         tsubstr = TString(thname(pos1,pos2));
         float ptmax = atof(tsubstr.Data());

         if (datamc) p2->cd();
         hdata->Draw();
         hmc->SetLineColor(kRed);
         hmc->SetMarkerColor(kRed);
         hmc->Draw("same");
         gPad->Update();

         // display the position of the ctau cut
         double a=1,b=1;
         if (!isfwd){a=ctaucut_a_mid_pp; b=ctaucut_b_mid_pp;} 
         else {a=ctaucut_a_fwd_pp; b=ctaucut_b_fwd_pp;}
         double cutmin = a + b / ptmin;
         double cutmax = a + b / ptmax;
         double xmin, xmax, ymin, ymax;
         TBox *tb = new TBox(cutmin,gPad->GetUymin(),cutmax,gPad->GetUymax());
         tb->SetFillColor(kBlack);
         tb->SetFillStyle(3003);
         tb->Draw();

         if (integrate) {
            TLine *tl = new TLine(hdata->GetXaxis()->GetXmin(),0.9,hdata->GetXaxis()->GetXmax(),0.9);
            tl->SetLineStyle(3);
            tl->SetLineColor(kBlack);
            tl->SetLineWidth(5);
            tl->Draw();
         }

         if (datamc) {
            p1->cd();
            TH1F *hratio = (TH1F*) hdata->Clone("hratio");
            hratio->Divide(hmc);
            hratio->GetYaxis()->SetTitle("data/MC");
            hratio->GetYaxis()->SetRangeUser(0.5,1.5);
            hratio->GetXaxis()->SetLabelSize(2.*hratio->GetXaxis()->GetLabelSize());
            hratio->GetXaxis()->SetTitleSize(2.*hratio->GetXaxis()->GetTitleSize());
            hratio->GetYaxis()->SetLabelSize(2.*hratio->GetYaxis()->GetLabelSize());
            hratio->GetYaxis()->SetTitleSize(2.*hratio->GetYaxis()->GetTitleSize());
            hratio->Draw();

            p2->cd();
         }

         // dg->SetParameters(1000,0.8,1e-3,0.03,1e-4,2.);
         // dg->SetParameter(0,int_data);
         // dg->SetParLimits(0,0,int_data*100.);
         // hdata->Fit(dg, "LERQ");
         // double sigma_data = dg->GetParameter(3);
         // double dsigma_data = dg->GetParError(3);
         // dg->SetRange(-5.*sigma_data,1.5*sigma_data);
         // hdata->Fit(dg, "LERQ");
         // sigma_data = dg->GetParameter(3);
         // dsigma_data = dg->GetParError(3);
         // dg->SetRange(-5.*sigma_data,1.5*sigma_data);
         // hdata->Fit(dg, "LERQ");
         // sigma_data = dg->GetParameter(3);
         // dsigma_data = dg->GetParError(3);
         // hmc->Fit(dg, "LERQ");
         // double sigma_mc = dg->GetParameter(3);
         // double dsigma_mc = dg->GetParError(3);

         double lx1=0.61, lx2=0.9, ly1=0.6, ly2=0.88;
         if (integrate) {ly1-=0.4; ly2-=0.4;}
         TLegend *tleg = new TLegend(lx1,ly1,lx2,ly2);
         tleg->SetBorderSize(0);
         TString header("#splitline{");
         header += isfwd ? "1.6<|y|<2.4" : "|y|<1.6";
         header += Form("}{%.1f<pt<%.1f GeV/c}",ptmin,ptmax);
         tleg->SetHeader(header);
         // tleg->AddEntry(hdata,Form("pp data (#sigma = %.3f +/- %.3f)",sigma_data,dsigma_data),"lp");
         // tleg->AddEntry(hmc,Form("pp prompt J/#psi mc (#sigma = %.3f +/- %.3f)",sigma_mc,dsigma_mc),"lp");
         tleg->AddEntry(hdata,"data","lp");
         tleg->AddEntry(hmc,"prompt J/#psi mc","lp");
         tleg->Draw();
         c1->SaveAs(Form("%s.pdf",hdata->GetName()));
         c1->SaveAs(Form("%s.png",hdata->GetName()));
      }
   }
}
Example #19
0
void CorrPtCut(char *prodname = "LHC10d4 PYTHIA D6T 7 TeV p+p", char *shortprodname = "LHC10d4", char *filename="Et.ESD.new.sim.LHC10d4.pp.merged.root"){

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(0);
  TCanvas *c = new TCanvas("c","c",500,400);
  c->SetTopMargin(0.04);
  c->SetRightMargin(0.04);
  c->SetLeftMargin(0.181452);
  c->SetBottomMargin(0.134409);
  c->SetBorderSize(0);
  c->SetFillColor(0);
  c->SetFillColor(0);
  c->SetBorderMode(0);
  c->SetFrameFillColor(0);
  c->SetFrameBorderMode(0);
  float etacut = 0.7;
  cout<<"Pt cut = 150 MeV/c"<<endl;
  TH1D *High = GetHisto(0.15-.001,"High",filename,etacut);
  float tpcHigh=highbound;
  float tpcLow=lowbound;
  float tpcsyserr = syserr;
  float tpcmean = mean;
  float x1 = High->GetXaxis()->GetBinLowEdge(1);
  //TBox *tpcBox = new TBox(-x1*.99,1.0-tpcLow,x1*.99,1.0-tpcHigh);
  TBox *tpcBox = new TBox(-x1*.99,1.0-(mean-syserr),x1*.99,1.0-(mean+syserr));
  tpcBox->SetFillColor(5);
  tpcBox->SetLineColor(0);
  tpcBox->SetFillStyle(1001);
  cout<<"Pt cut = 100 MeV/c"<<endl;
  TH1D *Low = GetHisto(0.1-.001,"Low",filename,etacut);
  float itsHigh=highbound;
  float itsLow=lowbound;
  float itssyserr = syserr;
  float itsmean = mean;

  cout<<Form("dataset & %2.4f \\pm %2.4f &  %2.4f \\pm %2.4f \\",itsmean,itssyserr,tpcmean,tpcsyserr)<<endl;
  float x = Low->GetXaxis()->GetBinLowEdge(1);
  //TBox *itsBox = new TBox(-x*.99,1.0-itsLow,x*.99,1.0-itsHigh);
  TBox *itsBox = new TBox(-x1*.99,1.0-(mean-syserr),x1*.99,1.0-(mean+syserr));
  itsBox->SetFillColor(5);
  itsBox->SetLineColor(0);
  itsBox->SetFillStyle(1001);
  cout<<"Pt cut = 50 MeV/c"<<endl;
  TH1D *Lowest = GetHisto(0.05-.001,"Lowest",filename,etacut);
  TF1 *funcLow = new TF1("funcLow","[0]",-.7,.7);
  funcLow->SetParameter(0,0.01);
  Low->Fit(funcLow);
  TF1 *funcHigh = new TF1("funcHigh","[0]",-.7,.7);
  funcHigh->SetParameter(0,0.02);
  High->Fit(funcLow);
  High->SetMaximum(0.06);
  High->SetMinimum(0.0);
  High->SetMarkerColor(2);
  Low->SetMarkerColor(4);
  High->SetLineColor(2);
  Low->SetLineColor(4);
  High->SetMinimum(0.0);
  High->SetMarkerStyle(20);
  Low->SetMarkerStyle(21);
  Lowest->SetMarkerStyle(22);
  High->Draw();
  tpcBox->Draw("f");
  High->Draw("same");
  itsBox->Draw("f");
  //return;
  Low->Draw("same");
  //Lowest->Draw("same");
  TLatex *tex = new TLatex(-0.723444,0.0373593+0.019,prodname);
  tex->SetTextSize(0.0537634);
  tex->Draw();
  TLegend *leg = new TLegend(0.217742,0.696237,0.477823,0.873656);
  leg->AddEntry(High,"p_{T} cut-off = 0.15 GeV/c");
  leg->AddEntry(Low,"p_{T} cut-off = 0.1 GeV/c");
  //leg->AddEntry(Lowest,"p_{T} cut-off = 0.05 GeV/c");
  leg->SetFillStyle(0);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.0537634);
  leg->Draw();
  c->SaveAs(Form("pics/%s/fptcut.eps",shortprodname));
  c->SaveAs(Form("pics/%s/fptcut.png",shortprodname));
  c->SaveAs(Form("pics/%s/fptcut.pdf",shortprodname));
}
Example #20
0
void CSVPlot()
{
    TFile *f_data = new TFile("../../../plots/Analysis/2015-11-21/histograms_data.root");
    TFile *f_correct = new TFile("../../../plots/Analysis/2015-11-21/correct_histograms_TTJets.root");
    TFile *f_incorrect = new TFile("../../../plots/Analysis/2015-11-21/incorrect_histograms_TTJets.root");
    TFile *f_qcd = new TFile("../../../plots/Analysis/2015-11-21/histograms_qcd_combined.root");

    TH1D *h_data, *h_correct, *h_incorrect, *h_qcd;
    TString name = "h_csv";
    f_data->GetObject(name, h_data);
    f_correct->GetObject(name, h_correct);
    f_incorrect->GetObject(name, h_incorrect);
    f_qcd->GetObject(name, h_qcd);

    double factor = h_data->Integral(1, 10000)/h_correct->Integral(1, 10000);
    h_correct->Scale(factor);

    h_data->SetLineColor(1);
    h_data->SetMarkerStyle(20);
    h_data->SetMarkerSize(0.5);
    h_data->GetXaxis()->SetRangeUser(0.0, 1.05);
    h_data->SetTitle();
    h_data->SetMaximum(7.0e6);
    h_data->GetXaxis()->SetTitleSize(0.045);
    h_data->GetYaxis()->SetTitleSize(0.045);

    h_correct->SetLineColor(3);
    h_incorrect->SetLineColor(2);
    //h_qcd->SetLineColor(4);

    TLine *cut = new TLine(0.95, 0.0, 0.95, 7.0e6);
    cut->SetLineColor(6);
    cut->SetLineStyle(2);
    cut->SetLineWidth(3);
    TBox *hash = new TBox(0.92, 0.0, 0.95, 7.0e6);
    hash->SetFillColor(6);
    hash->SetFillStyle(3004);

    gStyle->SetOptStat(0);

    TCanvas *c1 = new TCanvas("c1", "c1", 800, 600);
    c1->cd();
    c1->SetLogy();
    c1->SetTickx();
    c1->SetTicky();

    h_data->Draw();
    h_correct->Draw("hist same");
    //h_incorrect->Draw("hist same");
    //h_qcd->Draw("hist same");
    hash->Draw();
    cut->Draw();

    TLegend *leg = new TLegend(0.4, 0.25, 0.75, 0.4);
    leg->SetLineColor(0);
    leg->SetFillColor(0);
    leg->AddEntry(h_data, "data", "lp");
    leg->AddEntry(h_correct, "t#bar{t}, normalized to data area", "l");
    leg->Draw();

    h_data->Draw("sameaxis");

    CMS_lumi(c1, 4, 1);

    return;
}
Example #21
0
void gluinoMass(double lumi=-1., double maxInstLumi=-1.) {
	
  if (lumi<0)
    lumi=877.;
  if (maxInstLumi<0)
    maxInstLumi=1300.;
  LimitPlots plots(lumi);
  
  plots.calculateCrossSections(7,4,39,9);
	
  // expected limit (1 and 2 sigma bands)
  TGraph* g_exp = plots.getExpMassLimitGluino();
  TGraphAsymmErrors* g_exp1 = plots.getExpMassLimitGluino1Sig();
  TGraphAsymmErrors* g_exp2 = plots.getExpMassLimitGluino2Sig();
  
  // three points on counting expt curve
  TGraph* g_gluino = plots.getMassLimitGluino();
  TGraph* g_stop = plots.getMassLimitStop();
  
  // one point from lifetime fit
  TGraph* g_tp = plots.getMassLimitGluinoTP();
  
  // theory prediction
  TGraph* g_thGluino = plots.getGluinoTheory();
  TGraph* g_thStop = plots.getStopTheory();
  
  TCanvas* canvas = new TCanvas("canvas");
  
  //canvas->SetGrid();
  canvas->SetLogy();
  
  TH1 * h;
  h = canvas->DrawFrame(300., .02, 1000., 1e2);
  //h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; Stopped HSCP Cross Section #times BR [pb]");
  h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; #sigma(pp #rightarrow #tilde{g}#tilde{g}) #times BR(#tilde{g} #rightarrow g#tilde{#chi}^{0}) [pb]");
  
  // not covered region
  TBox* nc = new TBox(100., .1, 150., 5e2);
  nc->SetFillStyle(3354);
  nc->SetFillColor(kRed-4);
  //nc->Draw();
  
  // details
  TPaveText* blurb = new TPaveText(300., 2, 550., 1e2);
  blurb->AddText("CMS Preliminary 2012");

  std::stringstream label;
  label<<"#int L dt = "<<lumi<<" fb^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  double peakInstLumi=maxInstLumi;
  int exponent=30;
  while (peakInstLumi>10) {
    peakInstLumi/=10.;
    ++exponent;
  }
  label<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  label << "#sqrt{s} = " << ENERGY << " TeV";
  blurb->AddText(label.str().c_str());
  blurb->AddText("m_{#tilde{g}} - m_{#tilde{#chi}^{0}} = 100 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{t}} - m_{#tilde{#chi}^{0}} = 200 GeV/c^{2}");	
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.032);

  
  // legend
  TBox *legbg = new TBox(600., 2., 900., 1e2);
  legbg->Draw();
  TLegend *leg = new TLegend(600., 2., 900., 1e2,"95% C.L. Limits","");
  leg->SetTextSize(0.028);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);
  leg->AddEntry(g_exp, "Expected: 10 #mus - 1000 s Counting Exp. ", "l");
  leg->AddEntry(g_exp1, "Expected #pm1#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
  leg->AddEntry(g_exp2, "Expected #pm2#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
  //	  leg->AddEntry(graph3, "Obs.: 10^{6} s Counting Exp.", "l");
  leg->AddEntry(g_gluino, "Obs.: 10 #mus - 1000 s Counting Exp. ", "l");
  leg->AddEntry(g_tp, "Obs.: 10 #mus Timing Profile ", "l");
  //leg->AddEntry(g_stop, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{t})", "l");
  //leg->AddEntry(graph_em, "Obs.: 10 #mus - 1000 s Counting Exp. (EM only)", "l");
  //  leg->AddEntry(graph1, "Obs.: 570 ns Counting Exp.", "l");
  leg->Draw();
  
  
  
  // 2 sigma expected band
  g_exp2->SetLineColor(0);
  g_exp2->SetLineStyle(0);
  g_exp2->SetLineWidth(0);
  g_exp2->SetFillColor(5);
  g_exp2->SetFillStyle(1001);
  g_exp2->Draw("3");
  
  // 1 sigma expected band
  g_exp1->SetLineColor(0);
  g_exp1->SetLineStyle(0);
  g_exp1->SetLineWidth(0);
  g_exp1->SetFillColor(3);
  g_exp1->SetFillStyle(1001);
  g_exp1->Draw("3");  
  
  // expected line
  g_exp->SetLineStyle(2);
  g_exp->SetLineWidth(1);
  g_exp->Draw("l");
  
 
  // plateau limit - 1 ms
  g_gluino->SetLineColor(1);
  g_gluino->SetLineStyle(1);
  g_gluino->SetLineWidth(2);
  g_gluino->Draw("l");
  
  // stop curve
  g_stop->SetLineColor(1);
  g_stop->SetLineStyle(5);
  g_stop->SetLineWidth(2);
  //g_stop->Draw("l");
 

  // 1 mus lifetime fit limit
  g_tp->SetLineColor(kRed);
  g_tp->SetLineStyle(1);
  g_tp->SetLineWidth(2);
  g_tp->Draw("l");
  
  // theory line
  g_thGluino->SetLineColor(kBlue);
  g_thGluino->SetLineStyle(1);
  g_thGluino->SetLineWidth(2);
  g_thGluino->SetFillStyle(3001);
  g_thGluino->SetFillColor(kBlue-4);
  g_thGluino->Draw("l3");
  
  g_thStop->SetLineColor(kRed);
  g_thStop->SetLineStyle(1);
  g_thStop->SetLineWidth(2);
  g_thStop->SetFillStyle(3001);
  g_thStop->SetFillColor(kRed-4);
  //g_thStop->Draw("l3");


  // theory line label
  TLatex* th = new TLatex(600., .3, "NLO+NLL #tilde{g}");
  th->SetTextColor(kBlue);
  th->SetTextFont(42);
  th->SetTextSize(0.035);
  th->Draw();

  TLatex* ths = new TLatex(330., 2., "NLO+NLL #tilde{t}");
  ths->SetTextColor(kRed);
  ths->SetTextFont(42);
  ths->SetTextSize(0.035);
  //ths->Draw();

  // not explored label
  TText* ne = new TText(125., .2, "Not Sensitive");
  ne->SetTextColor(kRed+1);
  ne->SetTextFont(42);
  ne->SetTextAngle(90);
  ne->SetTextSize(0.035);
  //ne->Draw();

  blurb->Draw();

  canvas->RedrawAxis();

  canvas->Print("gluinoMassLimit.pdf");
  canvas->Print("gluinoMassLimit.C");

  plots.calculateIntercepts();
  
}
Example #22
0
void Draw_ALICEFor_JPsi_RaaVspT(TLegend *legend_ratio)
{
  // Centrality, rapidity and transverse momentum dependence of
  // J/psi suppression in Pb-Pb collisions at sqrt{s} = 2.76 TeV ALICE
  // arxiv.1311.0214v1
  
  //================= ALICE Forward Rapidity Raa Vs Pt ===================================//
  int nbinsPtALICEFor=7;
  Double_t PtALICEFor[7]={0.50,1.50,2.50,3.50,4.50,5.50,7.0};
  Double_t ErrPtALICEFor[7]={0};

  //Double_t RaaPtALICEFor[7] = {0.61,0.53,0.45,0.38,0.37,0.34,0.35}; 
  //Double_t RaaPtStatErrALICEFor[7] = {0.06,0.04,0.03,0.04,0.05,0.06,0.07};
  //Double_t RaaPtSystErrALICEFor[7] = {0.08,0.07,0.06,0.05,0.05,0.05,0.04};


  Double_t RaaPtALICEFor[7] = {0.78,0.68,0.52,0.43,0.41,0.32,0.36}; 
  Double_t RaaPtStatErrALICEFor[7] = {0.08,0.05,0.04,0.04,0.05,0.05,0.08};
  Double_t RaaPtSystErrALICEFor[7] = {0.11,0.08,0.06,0.05,0.05,0.04,0.04};
  


  TGraphErrors *grRaaPtALICEFor = new TGraphErrors(nbinsPtALICEFor, PtALICEFor, RaaPtALICEFor, ErrPtALICEFor, RaaPtStatErrALICEFor);  
  grRaaPtALICEFor->SetMarkerStyle(20);
  grRaaPtALICEFor->SetMarkerColor(4);
  grRaaPtALICEFor->SetMarkerSize(1.3);
  grRaaPtALICEFor->SetLineColor(1);
  grRaaPtALICEFor->GetYaxis()->SetRangeUser(0,1.5);
  grRaaPtALICEFor->GetXaxis()->SetTitle("p_{T}(GeV/c)");
  grRaaPtALICEFor->GetYaxis()->SetTitle("R_{AA}");

  TLine *lh4 = new TLine(0.0,1.0,7.6,1.0);
  lh4->SetLineColor(1);
  lh4->SetLineStyle(1);
  lh4->SetLineWidth(1.5);
  //lh4->Draw("same");
  
  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  
  TBox *RaaPtJPsiALICEForSys[12];
  for(int j=0;j<7;j++){
    RaaPtJPsiALICEForSys[j] = new TBox(PtALICEFor[j]-0.4,  RaaPtALICEFor[j]-RaaPtSystErrALICEFor[j], PtALICEFor[j]+0.4,  RaaPtALICEFor[j]+RaaPtSystErrALICEFor[j]);
  }
  
  for(int j=0;j<7;j++){
    RaaPtJPsiALICEForSys[j]->SetFillStyle(1001);
    RaaPtJPsiALICEForSys[j]->SetFillColor(kAzure-4);
    RaaPtJPsiALICEForSys[j]->SetLineColor(1);
  }
  
  TBox *ALICEGlobalSysJPsiPtFor;
  //ALICEGlobalSysJPsiPtFor = new TBox(7.2-0.2, 1 - 0.14, 7.2+0.2, 1 + 0.14);
  //ALICEGlobalSysJPsiPtFor = new TBox(18.424,0.858,19.165,1.137); // By Abd
  ALICEGlobalSysJPsiPtFor = new TBox(18.424,1.0-0.08,19.165,1.0+0.08); // By Abd
  ALICEGlobalSysJPsiPtFor->SetFillStyle(3001);
  ALICEGlobalSysJPsiPtFor->SetLineColor(4);
  ALICEGlobalSysJPsiPtFor->SetFillColor(4);
  
  grRaaPtALICEFor->Draw("sameP");
  for(int j=0;j<7;j++) RaaPtJPsiALICEForSys[j]->Draw("sameL"); 
  grRaaPtALICEFor->Draw("Psame");
  ALICEGlobalSysJPsiPtFor->Draw("sameL"); 
  legend_ratio->SetTextColor(4);
  //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");  
  //legend_ratio->AddEntry(grRaaPtALICEFor,"ALICE: J/#psi #rightarrow #mu^{+} #mu^{-}, 2.5 < |y| < 2.4 & p_{T}^{J/#psi} > 0.0 GeV/c", "P");  
  legend_ratio->AddEntry(grRaaPtALICEFor,"J/#psi ALICE: 2.5 < |y| < 2.4", "P");  
}
//////---------- channel: 0==muon dijet, 1== electron dijet
/////                     2==muon  boosted,   3== electron boosted
void makeATGCLimitDataCards(int channel) {

//   const Int_t bins = 8; 
//   const Float_t dm_min = 200.; 
//   const Float_t dm_max = 600.;

  Int_t bins = 7; 
  Float_t dm_min = 100.; 
  Float_t dm_max = 275.;
  if(channel>1) { bins = 15; dm_min = 200.; dm_max = 800; }

  Int_t binsmc = (int)(10*(dm_max - dm_min)); // units of 0.1GeV, set up for smearing post-binning!

  domu = true;
  if(channel==1 || channel==3) domu = false;

 
  TString outfile = (domu?TString("mu"):TString("el"))+ 
    (channel<2?TString("dijet"):TString("boosted"));
  TFile* outputForLimit = TFile::Open(outfile+".root", "recreate");


  TString cutsDijet("(W_pt<200.) && (dijetPt>70.) && (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.)");



  // Do not put jet pt in the cut string here, since it is going to be smeared
  TString cutsMerged("(vbf_event==0) && (W_pt>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4)&&(ggdboostedWevt==1) && (GroomedJet_CA8_deltaphi_METca8jet[0]>2.0) && (GroomedJet_CA8_deltaR_lca8jet[0]>1.57) && (numPFCorJetBTags<1) && (GroomedJet_CA8_tau2tau1[0]<0.55) && (GroomedJet_CA8_mass_pr[0]>70. && GroomedJet_CA8_mass_pr[0]<100.)");

  // && (GroomedJet_CA8_deltaR_lca8jet[1]<-900 || GroomedJet_CA8_deltaR_lca8jet[1]>7.0)

  TString        lepton_cut = "(event_met_pfmet >30) && (W_electron_pt>35.)";
  if(channel==0) lepton_cut = "(event_met_pfmet >25) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>25.)";
  if(channel==1) lepton_cut = "(event_met_pfmet >30) && (W_electron_pt>30.)";
  if(channel==2) lepton_cut = "(event_met_pfmet >50) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>30.)";
  if(channel==3) lepton_cut = "(event_met_pfmet >70) && (W_electron_pt>35.)";

  TString And = " && ";

  TString jet_cut = cutsDijet;
  TString jetptcut,mcjetptcut;

  if(channel>1) jet_cut = cutsMerged;

  char* observable = "dijetPt";
  char* mcobservable = "dijetPt";
  char* xtitle = "p_{T}^{jj} [GeV]"; 
  double jetptcutval;
  if(channel>1) {
    double jetthresh = 80;

    /*observable = 
      "(GroomedJet_CA8_pt[0]>jetthresh)+\
      (GroomedJet_CA8_pt[1]>jetthresh)+\
      (GroomedJet_CA8_pt[2]>jetthresh)+\
      (GroomedJet_CA8_pt[3]>jetthresh)+\
      (GroomedJet_CA8_pt[4]>jetthresh)+\
      (GroomedJet_CA8_pt[5]>jetthresh)";*/

    mcobservable = "GroomedJet_CA8_pt_smeared[0]";
    //mcobservable = "GroomedJet_CA8_pt[0]";
    observable = "GroomedJet_CA8_pt[0]";
    jetptcutval = 200.;
    jetptcut   = Form("(%s > %f)",  observable,jetptcutval);
    mcjetptcut = Form("(%s > %f)",mcobservable,jetptcutval);
    xtitle = "p_{T}^{j} [GeV]";
  }


  TCut mccut( TString("(effwt*puwt)*(")+ lepton_cut+And+jet_cut+And+mcjetptcut + TString(")") );
  TCut datacut( TString("(") + lepton_cut+And+jet_cut+And+jetptcut + TString(")") );
  //TCut the_cut( TString("(effwt*puwt)*(")+ lepton_cut+And+jet_cut+And+jetptcut + TString(")") );

  // for combining ttbar files
  TString mttstr
    ("sqrt((W_top_E+W_atop_E)^2 -(W_top_px+W_atop_px)^2 -(W_top_py+W_atop_py)^2 -(W_top_pz+W_atop_pz)^2)");

  // weight default sample by 1 for mtt<700, by half above for adding the high mtt samples
  TCut mttwt(TString("(")+mttstr+TString("<700)?1.0:0.5"));

  InstantiateTrees();


  //th1data  = new TH1D("th1data",  "th1data",  bins, ptbins_boosted); // bins, dm_min, dm_max);
  th1data  = new TH1D("th1data",  "th1data",  bins, dm_min, dm_max);
  th1data->Sumw2();
  th1data->SetMarkerStyle(20);
  th1data->SetMarkerSize(1.25);
  th1data->SetLineWidth(2);
  th1data->SetMinimum(0.0);

  TString drawstr = TString(observable)+TString(">>th1data");

  cout <<
    TString("treedata->Draw(\"")+drawstr+TString("\", \"")+
    TString((const char*)datacut)+TString("\", \"goff\")") << endl;

  treedata->Draw(drawstr, datacut, "goff");

  // ------- Get WW/WZ ------- 
  th1wwlo = new TH1D("th1wwlo", "th1wwlo", bins, dm_min, dm_max);
  th1wwhi = new TH1D("th1wwhi", "th1wwhi", bins, dm_min, dm_max);
  th1ww   = new TH1D("th1ww", "th1ww", bins, dm_min, dm_max);
  th1wzlo = new TH1D("th1wzlo", "th1wzlo", bins, dm_min, dm_max);
  th1wzhi = new TH1D("th1wzhi", "th1wzhi", bins, dm_min, dm_max);
  th1wz   = new TH1D("th1wz", "th1wz", bins, dm_min, dm_max);
  //th1wz = new TH1D("th1wz", "th1wz", bins, ptbins_boosted);
  th1wwlo->Sumw2();
  th1wwhi->Sumw2();
  th1wzlo->Sumw2();
  th1wzhi->Sumw2();
  th1wz->Sumw2();

  fillMChisto(th1wwlo,treewwlo,mcobservable,mccut);
  fillMChisto(th1wwhi,treewwhi,mcobservable,mccut);
  fillMChisto(th1wzlo,treewzlo,mcobservable,mccut);
  fillMChisto(th1wzhi,treewzhi,mcobservable,mccut);

  // ------- Get ttbar ------- 
  th1Top   = new TH1D("th1Top", "th1Top", bins, dm_min, dm_max);
  th1toplo = new TH1D("th1toplo", "th1toplo", bins, dm_min, dm_max);
  th1topmd = new TH1D("th1topmd", "th1topmd", bins, dm_min, dm_max);
  th1tophi = new TH1D("th1tophi", "th1tophi", bins, dm_min, dm_max);

  //th1Top = new TH1D("th1Top", "th1Top", bins, ptbins_boosted);
  th1Top->Sumw2();
  th1toplo->Sumw2();
  th1topmd->Sumw2();
  th1tophi->Sumw2();

  fillMChisto(th1toplo,treettblo,mcobservable,mttwt*mccut);
  fillMChisto(th1topmd,treettbmd,mcobservable,mccut);
  fillMChisto(th1tophi,treettbhi,mcobservable,mccut);

    // ------- Get WJets ------- 
  th1wjlo  = new TH1D("th1wjlo",  "th1wjlo",  bins, dm_min, dm_max);
  th1wjhi  = new TH1D("th1wjhi",  "th1wjhi",  bins, dm_min, dm_max);
  th1wjets = new TH1D("th1wjets", "th1wjets", bins, dm_min, dm_max);
  th1wjlo->Sumw2();
  th1wjhi->Sumw2();

  fillMChisto(th1wjlo,treewjlo,mcobservable,mccut);
  fillMChisto(th1wjhi,treewjhi,mcobservable,mccut);

  //th1wjets  = new TH1D("th1wjets",  "th1wjets", bins, ptbins_boosted);

  // ------- Get QCD ------- 
  //th1qcd = new TH1D("th1qcd", "th1qcd", bins, dm_min, dm_max);
  //th1qcd = new TH1D("th1qcd", "th1qcd", bins, ptbins_boosted);
  //th1qcd->Sumw2();
  //treeqcd->Draw(TString(observable)+TString(">>th1qcd"), mccut, "goff");

  // ------- Get Z+Jets ------- 
  //th1zjets = new TH1D("th1zjets", "th1zjets", bins, dm_min, dm_max);
  //th1zjets->Sumw2();
  //treezj->Draw(TString(observable)+TString(">>th1zjets"), mccut, "goff");


  // ------- Get Single top ------- 
  th1stops = new TH1D("th1stops", "th1stops", bins, dm_min, dm_max);
  th1stopt = new TH1D("th1stopt", "th1stopt", bins, dm_min, dm_max);
  th1stoptw = new TH1D("th1stoptw", "th1stoptw", bins, dm_min, dm_max);
  //th1stops = new TH1D("th1stops", "th1stops", bins, ptbins_boosted);
  //th1stopt = new TH1D("th1stopt", "th1stopt", bins, ptbins_boosted);
  //th1stoptw = new TH1D("th1stoptw", "th1stoptw", bins, ptbins_boosted);
  th1stops->Sumw2();
  th1stopt->Sumw2();
  th1stoptw->Sumw2();
  
  fillMChisto(th1stops,treests,mcobservable,mccut);
  fillMChisto(th1stopt,treestt,mcobservable,mccut);
  fillMChisto(th1stoptw,treestw,mcobservable,mccut);
 
  th1stopps = new TH1D("th1stopps", "th1stopps", bins, dm_min, dm_max);
  th1stoppt = new TH1D("th1stoppt", "th1stoppt", bins, dm_min, dm_max);
  th1stopptw = new TH1D("th1stopptw", "th1stopptw", bins, dm_min, dm_max);
  //th1stopps = new TH1D("th1stopps", "th1stopps", bins, ptbins_boosted);
  //th1stoppt = new TH1D("th1stoppt", "th1stoppt", bins, ptbins_boosted);
  //th1stopptw = new TH1D("th1stopptw", "th1stopptw", bins, ptbins_boosted);
  th1stopps->Sumw2();
  th1stoppt->Sumw2();
  th1stopptw->Sumw2();

  fillMChisto(th1stopps,tree64,mcobservable,mccut);
  fillMChisto(th1stoppt,tree65,mcobservable,mccut);
  fillMChisto(th1stopptw,tree66,mcobservable,mccut);

  // ---- Scale the histos ---- 
  ScaleHistos(channel);

#if 0    
  // ---- Make smooth diboson shape ----------
  TH1D* th1wvclone = (TH1D *)th1wv->Clone("th1wvclone");
  float tmin = 200.0;
  if(channel>1) tmin = 300.0;
  gaus2 = new TF1("gaus2","gaus", tmin, 1000000000.);
  th1wvclone->Fit(gaus2,"I0","");
#endif
    
  // ---- Empty histograms for display/plotting ---- 
  SetupEmptyHistogram(bins, dm_min, dm_max, xtitle);
  //SetupEmptyHistogram(bins, ptbins_boosted, xtitle);
  
  // ---- Sum all backgrounds ----------
  TH1D* th1wv_no_overflow = (TH1D *)th1wv->Clone("th1wv_no_overflow");
  SumAllBackgrounds();

#if 1
  // ---- Get signal histogram ----------
  TCut wwsigratio= GetSigRatioFunction(mcobservable);
  TCut wzsigratio= GetSigRatioFunction(mcobservable,"wz");
  
  TCut wwsigcut = mccut*wwsigratio;
  TCut wzsigcut = mccut*wzsigratio;
  
  wwatgc4Display = new TH1D("wwatgc4Display","wwatgc4Display",bins,dm_min,dm_max);
  wzatgc4Display = new TH1D("wzatgc4Display","wzatgc4Display",bins,dm_min,dm_max);
  //wwatgc4Display = new TH1D("wwatgc4Display","wwatgc4Display",bins,ptbins_boosted);
  
  drawstr = TString(mcobservable)+TString(">>wwatgc4Display");

  cout <<
    TString("wwtree->Draw(\"")+drawstr+TString("\", \"")+
    TString((const char*)wwsigcut)+TString("\", \"goff\")") << endl;

  TH1D *th1wwlosc = new TH1D("sigwwlo","sigwwlo",bins,dm_min,dm_max);
  TH1D *th1wwhisc = new TH1D("sigwwhi","sigwwhi",bins,dm_min,dm_max);
  TH1D *th1wzlosc = new TH1D("sigwzlo","sigwzlo",bins,dm_min,dm_max);
  TH1D *th1wzhisc = new TH1D("sigwzhi","sigwzhi",bins,dm_min,dm_max);

  fillMChisto(th1wwlosc,treewwlo,mcobservable,wwsigcut,false);
  fillMChisto(th1wwhisc,treewwhi,mcobservable,wwsigcut,false);
  fillMChisto(th1wzlosc,treewzlo,mcobservable,wzsigcut,false);
  fillMChisto(th1wzhisc,treewzhi,mcobservable,wzsigcut,false);

  th1wwlosc->Scale(WW_scale_lo);
  th1wwhisc->Scale(WW_scale_hi);

  th1wzlosc->Scale(WZ_scale_lo);
  th1wzhisc->Scale(WZ_scale_hi);

  // stitch the two histograms together into one, post-smearing.
  for (int ibin=1;ibin<=wwatgc4Display->GetNbinsX();ibin++) {
    if (wwatgc4Display->GetBinLowEdge(ibin)<stitchwwgev) {
      wwatgc4Display->SetBinContent(ibin,th1wwlosc->GetBinContent(ibin));
      wwatgc4Display->SetBinError  (ibin,th1wwlosc->GetBinError  (ibin));
    } else {
      wwatgc4Display->SetBinContent(ibin,th1wwhisc->GetBinContent(ibin));
      wwatgc4Display->SetBinError  (ibin,th1wwhisc->GetBinError  (ibin));
    }
  }

  wwatgc4Display->Scale(WW_scale_NLO * (domu ? intLUMIinvpb_mu : intLUMIinvpb_el));

  // stitch the two WZ histograms together into one, post-smearing.
  for (int ibin=0;ibin<=wzatgc4Display->GetNbinsX()+1;ibin++) {
    if (wzatgc4Display->GetBinLowEdge(ibin)<stitchwzgev) {
      wzatgc4Display->SetBinContent(ibin,th1wzlosc->GetBinContent(ibin));
      wzatgc4Display->SetBinError  (ibin,th1wzlosc->GetBinError  (ibin));
    } else {
      wzatgc4Display->SetBinContent(ibin,th1wzhisc->GetBinContent(ibin));
      wzatgc4Display->SetBinError  (ibin,th1wzhisc->GetBinError  (ibin));
    }
  }

  wzatgc4Display->Scale(WZ_scale_NLO * (domu ? intLUMIinvpb_mu : intLUMIinvpb_el));

  cout << "wwatgc4Display nentries = " << wwatgc4Display->GetEntries() << endl;

  // ----- need to subtract the diboson contribution 
  wwatgc4Display->SetLineWidth(2);
  wwatgc4Display->SetLineColor(1);
  wwatgc4Display->SetFillColor(0);

  // ----- need to subtract the diboson contribution 
  wzatgc4Display->SetLineWidth(2);
  wzatgc4Display->SetLineColor(1);
  wzatgc4Display->SetFillColor(0);
  wzatgc4Display->SetLineStyle(2);

  //-------- Add overflow bin ----------------
  AddOverflowBin(wwatgc4Display);
  AddOverflowBin(wzatgc4Display);
  
#endif

  // ---- Compose the stack ----------
  THStack* hs = new THStack("hs","MC contribution");
  //hs->Add(th1zjets); 
 //hs->Add(th1qcd);
  hs->Add(th1Top);
  hs->Add(th1wjets);
  hs->Add(th1wv);  // add WW in with backgrounds for display only
  hs->Add(wwatgc4Display);
  hs->Add(wzatgc4Display);



  // ---- Stack for shape systematics Up ----------
  double bkgd_norm_fracerror = domu ? mu_bkgd_norm_error : el_bkgd_norm_error;
  double sig_norm_fracerror = domu ? mu_sig_norm_error : el_sig_norm_error;

  cout << "Background normalization fractional systematic = " << bkgd_norm_fracerror << endl;
  cout << "Signal     normalization fractional systematic = " << sig_norm_fracerror << endl;

  //TF1* formScaleUp = new TF1("formScaleUp", "1.0+0.4*log(x/5)", dm_min, dm_max);
  //TF1* formScaleDn = new TF1("formScaleDn", "1.0-0.2*log(x/5)", dm_min, dm_max);
  TF1* formScaleUp = new TF1("formScaleUp", Form("1.0+%f",bkgd_norm_fracerror), dm_min, dm_max);
  TF1* formScaleDn = new TF1("formScaleDn", Form("1.0-%f",bkgd_norm_fracerror), dm_min, dm_max);

  systUp = (TH1D*) th1wjets->Clone("systUp");
  systUp->Multiply(formScaleUp);
  //systUp->Add(th1zjets);
  //systUp->Add(th1qcd);
  systUp->Add(th1Top);
  systUp->SetFillColor(0);
  systUp->SetLineStyle(2);
  systUp->SetLineColor(2);
  systUp->SetLineWidth(3);

  // ---- Stack for shape systematics Down ----------
  systDown = (TH1D*) th1wjets->Clone("systDown");
  systDown->Multiply(formScaleDn);
  //systDown->Add(th1zjets);
  //systDown->Add(th1qcd);
  systDown->Add(th1Top);
  systDown->SetFillColor(0);
  systDown->SetLineWidth(3);
  systDown->SetLineStyle(2);
  systDown->SetLineColor(2);

  /////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  

  // ------- Setup the canvas ------- 
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  // gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadLeftMargin(0.15);
  // gStyle->SetPadRightMargin(0.2);
  gStyle->SetPadBottomMargin(0.3);
  // gStyle->SetErrorX(0.5);

  TCanvas* c1 = new TCanvas("dijetPt", "", 10,10, 500, 500);

  TPad *d1, *d2;
  c1->Divide(1,2,0,0);
  d1 = (TPad*)c1->GetPad(1);
  d1->SetPad(0.01,0.30,0.95,0.99);
  d2 = (TPad*)c1->GetPad(2);
  d2->SetPad(0.01,0.02,0.95,0.30);
  d1->cd();

  gPad->SetBottomMargin(0.005);

  gPad->SetTopMargin(0.1);
  gPad->SetRightMargin(0.04);
  // gPad->SetLeftMargin(0.14);


  // Draw it all
  double ymax= 5000000.;
  double ymin= 7.0;
  if(channel>1) { 
    ymax= 3000.;
    ymin= 0.10;
  }

  th1totempty->GetYaxis()->SetRangeUser(ymin, ymax);
  th1data->GetYaxis()->SetRangeUser(ymin, ymax);
  th1totempty->Draw();
  hs->Draw("samehist");
  for (int i=1;i<=th1tot->GetNbinsX();i++)
    {
      double val = th1tot->GetBinContent(i); // / (ptbins_boosted[i]-ptbins_boosted[i-1]);
      double err = fabs(th1tot->GetBinError(i)); // / (ptbins_boosted[i]-ptbins_boosted[i-1]);
      TBox *b = new TBox(th1tot->GetBinLowEdge(i),
			 val-err,th1tot->GetBinLowEdge(i+1),val+err);
      b->SetLineColor(1);
      b->SetFillColor(1);
      b->SetFillStyle(3001);
      b->SetLineStyle(3001);	 
      b->Draw();
    }
  //data2draw->Draw("esame");

#ifndef BLINDED
  th1data->Draw("esame");
#endif

  cmspre(); 
  // Set up the legend
  TLegend* Leg = GetLegend(channel);   
  Leg->Draw();  
  gPad->SetLogy();
  gPad->RedrawAxis();

  d2->cd();
  gPad->SetTopMargin(0.02);
  gPad->SetRightMargin(0.04);
  gPad->SetFrameBorderSize(0);
  gPad->SetBottomMargin(0.45);
  gPad->SetTickx();

  th1emptyclone->Draw();
#ifndef BLINDED
  hhratio->Draw("esame");
  //hhratioUp->Draw("hist lsame");
  //hhratioDown->Draw("hist lsame");
#endif
  TLine *line; line = new TLine(dm_min,1.0,dm_max,1.0);
  line->SetLineStyle(1);
  line->SetLineWidth(1);
  line->SetLineColor(1);
  line->Draw();

  //gPad->WaitPrimitive();
  c1->Modified();
  c1->Update();

  c1->Print(TString("OutDir/")+outfile
#ifdef BLINDED
	    +TString("_fatjetPt_blinded.png")
#else
	    +TString("_fatjetPt_unblinded.png")
#endif
	    );

  c1->SaveAs(TString("OutDir/") + outfile
#ifdef BLINDED
	     +TString("_fatjetPt_blinded.pdf")
#else
	     +TString("_fatjetPt_unblinded.pdf")
#endif
	     );
  c1->SaveAs(TString("OutDir/") + outfile
#ifdef BLINDED
	     +TString("_fatjetPt_blinded.root")
#else
	     +TString("_fatjetPt_unblinded.root")
#endif
	     );
   

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

  if(saveDataCards_) {
    outputForLimit->cd();
    th1data->SetName("data_obs");     th1data->Write("data_obs");
    th1tot->SetName("background");    th1tot->Write("background");
    th1ww->SetName("ww");             th1ww->Write("ww");
    th1ww->SetName("wz");             th1wz->Write("wz");
    th1wv->SetName("diboson");        th1wv->Write("diboson");

    th1wv_no_overflow->Write("th1wv_no_overflow");
    char* tempname = "background_backshapeUp";
    if(channel==0) tempname = "background_mudijet_backshapeUp";
    if(channel==1) tempname = "background_eldijet_backshapeUp";
    if(channel==2) tempname = "background_muboosted_backshapeUp";
    if(channel==3) tempname = "background_elboosted_backshapeUp";
    systUp->SetName(tempname);
    systUp->Write(tempname);
    tempname = "background_backshapeDown";
    if(channel==0) tempname = "background_mudijet_backshapeDown";
    if(channel==1) tempname = "background_eldijet_backshapeDown";
    if(channel==2) tempname = "background_muboosted_backshapeDown";
    if(channel==3) tempname = "background_elboosted_backshapeDown";
    systDown->SetName(tempname);
    systDown->Write(tempname);

    outputForLimit->Close();

  } ///// close if saveDataCards_

    //delete th1wvclone;
}
Example #24
0
void Draw_CMS_JPsi_RaaVspT(TLegend *legend_ratio)
{
  
  int nbinsPtCMS=4;
  Double_t PtCMSD[4]={7.31,8.97,11.32,16.52};
  Double_t ErrPtCMS[4]={0};
  Double_t RaaPtCMS[4] = {0.35,0.34,0.34,0.29}; 
  Double_t RaaPtStatErrCMS[4] = {0.09,0.03,0.03,0.04};
  Double_t RaaPtSystErrCMS[4] = {0.04,0.04,0.03,0.03};
  
  TGraphErrors *grRaaPtCMS = new TGraphErrors(nbinsPtCMS, PtCMSD, RaaPtCMS, ErrPtCMS, RaaPtStatErrCMS);  
  grRaaPtCMS->SetMarkerStyle(21);
  grRaaPtCMS->SetMarkerColor(kRed+1);
  grRaaPtCMS->SetMarkerSize(1.3);
  //grRaaPtCMS->SetFillColor(kRed);
  grRaaPtCMS->SetLineColor(1);
  grRaaPtCMS->GetYaxis()->SetRangeUser(0,1.5);
  grRaaPtCMS->GetXaxis()->SetTitle("p_{T}(GeV/c)");
  grRaaPtCMS->GetYaxis()->SetTitle("R_{AA}");
  
  TLine *lh5 = new TLine(0.0,1.0,20.0,1.0);
  lh5->SetLineColor(1);
  lh5->SetLineStyle(1);
  lh5->SetLineWidth(1.5);
  
  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  
  TBox *RaaPtJPsiCMSSys[4];
  for(int j=0;j<4;j++){
    RaaPtJPsiCMSSys[j] = new TBox(PtCMSD[j]-0.4,  RaaPtCMS[j]-RaaPtSystErrCMS[j], PtCMSD[j]+0.4,  RaaPtCMS[j]+RaaPtSystErrCMS[j]);
  }
  
  for(int j=0;j<4;j++){
    RaaPtJPsiCMSSys[j]->SetFillStyle(1001);
    RaaPtJPsiCMSSys[j]->SetFillColor(kPink+1);
    RaaPtJPsiCMSSys[j]->SetLineColor(1);
  }
  
  TBox *CMSGlobalSysJPsiPt;
  //CMSGlobalSysJPsiPt = new TBox(27.0-1.0, 1 - 0.075, 27.0+1.0, 1 + 0.075);
  CMSGlobalSysJPsiPt = new TBox(19.165,0.923,19.948,1.067);
  CMSGlobalSysJPsiPt->SetFillStyle(3001);
  CMSGlobalSysJPsiPt->SetLineColor(2);
  CMSGlobalSysJPsiPt->SetFillColor(2);
  
  TAxis *XaxisgrRaaPtCMS = grRaaPtCMS->GetXaxis();
  XaxisgrRaaPtCMS->SetLimits(0.0,20.0);
  grRaaPtCMS->Draw("AP");
  for(int j=0;j<4;j++) RaaPtJPsiCMSSys[j]->Draw("same"); 
  grRaaPtCMS->Draw("Psame");
  CMSGlobalSysJPsiPt->Draw("same"); 
  tb->SetTextSize(0.030);
  //tb->DrawLatex(0.20,0.20,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.71476,0.91289,"J/#psi #rightarrow #mu^{+} #mu^{-}");  
  lh5->Draw("same");
  //legend_ratio->AddEntry(grRaaPtCMS,"PbPb #sqrt{s_{NN}} = 2.76 TeV and Au-Au #sqrt{s_{NN}} = 0.2 TeV", "");
  legend_ratio->AddEntry(grRaaPtCMS,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV", "");
  legend_ratio->AddEntry(grRaaPtCMS,"Prompt J/#psi CMS: |y| < 2.4", "P");

  //legend_ratio->AddEntry(grRaaPtCMS,"PbPb #sqrt{s_{NN}} = 2.76 TeV and Au-Au #sqrt{s_{NN}} = 0.2 TeV", "");
  //legend_ratio->AddEntry(grRaaPtCMS,"CMS: J/#psi #rightarrow #mu^{+} #mu^{-}, |y| < 2.4 & p_{T}^{J/#psi} > 6.5 GeV/c", "P");
  //legend_ratio->AddEntry(grRaaPtCMS,"CMS: J/#psi #rightarrow #mu^{+} #mu^{-}, |y| < 2.4 & p_{T}^{J/#psi} > 6.5 GeV/c", "P");
}
void MakeSignificancePlot( int option = 0) {

  int NBins = 15;
  if (option == 1) NBins = 20;

  Double_t x[NBins];  
  Double_t y[NBins];
  x[0] = -0.5;
  for (int i=1; i<NBins; ++i)  x[i] = i-1;

  if (option == 0) {
    //use significance computed from log likelihood
    
    // //**************************
    // //2.3+4.0 dataset
    // //**************************
    // //highPt Category
    // y[0] = -1000;
    // y[1] = 1.1;
    // y[2] = 0.9;
    // y[3] = 0;
    // y[4] = -0.7;
    // y[5] = 0.8;
    // y[6] = 1.3;
    // y[7] = 0.8;
    // y[8] = 0.7;
    // //hbb category  
    // y[9] = 0.6;
    // //highres category
    // y[10] = -0.4;
    // y[11] = 1.1;
    // y[12] = 0.8;
    // y[13] = 1.7;
    // y[14] = 0.7;

   // //**************************
   //  //2.3+12.9 dataset
   //  //**************************
   //  //highPt Category
   //  y[0] = -1000;
   //  y[1] = 2.5;
   //  y[2] = 0.2;
   //  y[3] = -1.4;
   //  y[4] = -0.4;
   //  y[5] = -1.6;
   //  y[6] = 1.9;
   //  y[7] = 0.6;
   //  y[8] = 0.8;
   //  //hbb category  
   //  y[9] = 1.0;
   //  //highres category
   //  y[10] = -0.2;
   //  y[11] = 1.7;
   //  y[12] = 0.0;
   //  y[13] = 0.5;
   //  y[14] = 0.2;

    //*********************************************
    //full 2016 dataset: 36.8 /fb dataset
    //*********************************************
    //highPt Category
    y[0] = -1000;
    y[1] = 0.7;
    y[2] = -1.4;
    y[3] = -0.9;
    y[4] = 0.4;
    y[5] = 0.6;
    y[6] = 1.6;
    y[7] = 0.1;
    y[8] = -0.0;
    //hbb category  
    y[9] = 1.0;
    //highres category
    y[10] = -0.2;
    y[11] = 0.1;
    y[12] = -0.6;
    y[13] = 0.2;
    y[14] = 0.2;

  } else if (option == 1) {
    //use fitted signal yield / uncertainty
    
    //highPt Category
    y[0] = -1000;
    y[1] = 2.0/2.2;
    y[2] = 2.0/2.5;
    y[3] = 0;
    y[4] = -8.6/11.4;
    y[5] = 3.9/5.3;
    y[6] = 4.3/3.5;
    y[7] = 3.9/4.8;
    y[8] = 1.9/2.7;
    //hbb category  
    y[9] = 1.9/3.3;
    //highres category
    y[10] = -8.8/20.3;
    y[11] = 2.7/2.3;
    y[12] = 2.7/3.7;
    y[13] = 21.3/12.2;
    y[14] = 3.5/4.4;
    //low res category
    y[15] = -3.6/8.6;
    y[16] = 0.5/0.5;
    y[17] = 0.9/1.3;
    y[18] = 7.2/4.6;
    y[19] = 1.4/1.9;
  }


  TCanvas *cv = new TCanvas("cv","cv",800,600);
  cv->SetBottomMargin(0.115);
  TH1F *hist = 0;
  if (option == 0) hist = new TH1F("hist",";Bin Number; Observed Significance;", 14, -0.5, 13.5);
  else if (option == 1) hist = new TH1F("hist",";Bin Number; Fitted Signal Yield / Uncertainty;", 19, -0.5, 18.5);
  // else if (option == 1) hist = new TH1F("hist",";Bin Number; Fitted N_{signal} / #sigma_{N_{signal}};", 19, -0.5, 18.5);
  
  hist->GetXaxis()->SetBinLabel(1, "Bin 0");
  hist->GetXaxis()->SetBinLabel(2, "Bin 1");
  hist->GetXaxis()->SetBinLabel(3, "Bin 2");
  hist->GetXaxis()->SetBinLabel(4, "Bin 3");
  hist->GetXaxis()->SetBinLabel(5, "Bin 4");
  hist->GetXaxis()->SetBinLabel(6, "Bin 5");
  hist->GetXaxis()->SetBinLabel(7, "Bin 6");
  hist->GetXaxis()->SetBinLabel(8, "Bin 7");
  hist->GetXaxis()->SetBinLabel(9, "Bin 8");
  hist->GetXaxis()->SetBinLabel(10, "Bin 9");
  hist->GetXaxis()->SetBinLabel(11, "Bin 10");
  hist->GetXaxis()->SetBinLabel(12, "Bin 11");
  hist->GetXaxis()->SetBinLabel(13, "Bin 12");
  hist->GetXaxis()->SetBinLabel(14, "Bin 13");
  hist->GetXaxis()->LabelsOption("v");
  hist->SetStats(0);
  hist->SetMaximum(5);
  hist->SetMinimum(-8.0);
  hist->GetYaxis()->SetTitleSize(0.05);
  hist->GetYaxis()->SetTitleOffset(0.85);
  hist->GetYaxis()->SetLabelSize(0.045);
  hist->GetXaxis()->SetTitle("");
  hist->GetXaxis()->SetTitleSize(0.05);
  hist->GetXaxis()->SetTitleOffset(0.85);
  hist->GetXaxis()->SetLabelSize(0.05);
  hist->Draw();


  TGraph *gr =0;
  gr = new TGraphAsymmErrors(NBins,x,y);
  gr->SetTitle("");
  //gr->Draw("psame");
  gr->SetLineWidth(2);
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(1.5);
  // gr->GetXaxis()->SetTitle("Bin Number");
  // gr->GetYaxis()->SetTitle("Observed Significance");
  // gr->GetXaxis()->SetTitleSize(0.05);
  // gr->GetXaxis()->SetTitleOffset(0.8);
  // gr->GetYaxis()->SetTitleSize(0.05);
  // gr->GetYaxis()->SetTitleOffset(0.8);
  // gr->GetYaxis()->SetRangeUser(-7,5);

  TBox *TwoSigmaBand = 0;
  TBox *OneSigmaBand = 0;
  TLine *l = 0;

  if (option == 0) {
    TwoSigmaBand = new TBox(-0.48, -2, 13.5, 2);
    OneSigmaBand = new TBox(-0.48, -1, 13.5, 1);
    l = new TLine(-0.48,0,13.5,0);
  } else if (option == 1) {
    TwoSigmaBand = new TBox(-0.48, -2, 18.5, 2);
    OneSigmaBand = new TBox(-0.48, -1, 18.5, 1);
    l = new TLine(-0.48,0,18.5,0);
  }

  TwoSigmaBand->SetFillColor(kYellow);
  //box->SetFillStyle(3001);
  TwoSigmaBand->Draw("same");   
  OneSigmaBand->SetFillColor(kGreen);
  //box->SetFillStyle(3001);
  OneSigmaBand->Draw("same");
  
  l->SetLineWidth(2);
  l->SetLineColor(kBlue);
  l->Draw();

  gr->Draw("P");
  gPad->Update();
  gPad->RedrawAxis();

  TLine ll;
  ll.DrawLine(gPad->GetUxmin(), gPad->GetUymax(), gPad->GetUxmax(), gPad->GetUymax());
  ll.DrawLine(gPad->GetUxmax(), gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymax());

  TLatex *tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSize(0.040);
  tex->SetTextFont(42);
  tex->SetTextColor(kBlack);
  tex->DrawLatex(0.7, 0.92, "35.9 fb^{-1} (13 TeV)");
  //tex->DrawLatex(0.4, 0.92, "Razor H#rightarrow#gamma#gamma Search");
  tex->Draw();
  
  TLatex *CMSLabel = new TLatex();
  CMSLabel->SetNDC();
  CMSLabel->SetTextSize(0.050);
  CMSLabel->SetTextFont(42);
  CMSLabel->SetTextColor(kBlack);
  CMSLabel->DrawLatex(0.1,0.92,"#bf{CMS}");
  CMSLabel->SetTextSize(0.045);
  //CMSLabel->DrawLatex(0.19,0.92,"Preliminary");
  CMSLabel->Draw();


  TLine *l1 = new TLine(7.5,-8,7.5,5);
  l1->SetLineWidth(2);
  l1->SetLineStyle(2);
  l1->SetLineColor(kBlack);
  l1->Draw();

  TLine *l2 = new TLine(8.5,-8,8.5,5);
  l2->SetLineWidth(2);
  l2->SetLineStyle(2);
  l2->SetLineColor(kBlack);
  l2->Draw();

  if (option == 1) {
    TLine *l3 = new TLine(13.5,-8,13.5,5);
    l3->SetLineWidth(2);
    l3->SetLineStyle(2);
    l3->SetLineColor(kBlack);
    l3->Draw();
  }

  TLatex *HighPtLabel = new TLatex();
  HighPtLabel->SetNDC();
  HighPtLabel->SetTextAngle(90);
  HighPtLabel->SetTextSize(0.035);
  HighPtLabel->SetTextFont(42);
  HighPtLabel->SetTextColor(kBlack);
  HighPtLabel->DrawLatex(0.34,0.13,"#bf{HighPt Category}");
  HighPtLabel->Draw();

  TLatex *HbbLabel = new TLatex();
  HbbLabel->SetNDC();
  HbbLabel->SetTextAngle(90);
  HbbLabel->SetTextSize(0.035);
  HbbLabel->SetTextFont(42);
  HbbLabel->SetTextColor(kBlack);
  if (option == 0) HbbLabel->DrawLatex(0.59,0.13,"#bf{H(#gamma#gamma)-HZ(bb) Category}");
  else if (option ==1) HbbLabel->DrawLatex(0.465,0.13,"#bf{H(#gamma#gamma)-Z(bb) Category}");
  HbbLabel->Draw();

  if (option == 0) {
    TLatex *HighResLowResLabel = new TLatex();
    HighResLowResLabel->SetNDC();
    HighResLowResLabel->SetTextAngle(90);
    HighResLowResLabel->SetTextSize(0.035);
    HighResLowResLabel->SetTextFont(42);
    HighResLowResLabel->SetTextColor(kBlack);
    HighResLowResLabel->DrawLatex(0.730,0.13,"#bf{HighRes/LowRes}");
    HighResLowResLabel->DrawLatex(0.760,0.20,"#bf{Category}");
    HighResLowResLabel->Draw();
  
  } else if (option == 1) {
    TLatex *HighResLabel = new TLatex();
    HighResLabel->SetNDC();
    HighResLabel->SetTextAngle(90);
    HighResLabel->SetTextSize(0.035);
    HighResLabel->SetTextFont(42);
    HighResLabel->SetTextColor(kBlack);
    HighResLabel->DrawLatex(0.60,0.13,"#bf{HighRes Category}");
    HighResLabel->Draw();
    
    TLatex *LowResLabel = new TLatex();
    LowResLabel->SetNDC();
    LowResLabel->SetTextAngle(90);
    LowResLabel->SetTextSize(0.035);
    LowResLabel->SetTextFont(42);
    LowResLabel->SetTextColor(kBlack);
    LowResLabel->DrawLatex(0.80,0.13,"#bf{LowRes Category}");
    LowResLabel->Draw();
  }
    

  cv->SaveAs("SignificanceVsBin.png");
  cv->SaveAs("SignificanceVsBin.pdf");


}
Example #26
0
void makeRaa_pt( bool bSavePlots=1,
		 bool bDoDebug = 0, // adds some numbers, numerator, denominator, to help figure out if things are read properly
		 bool bAddLumi = 0, // add the lumi boxes at raa=1
		 int  whichSample     = 1,//0: no TnP corrections; 1: w/ TnP corr on Data; 2: w/ TnP corr on MC; 3: lxy w/ TnP on MC
		 const char* inputDir="../readFitTable", // the place where the input root files, with the histograms are
		 const char* outputDir="figs")// where the output figures will be
{
  gSystem->mkdir(Form("./%s/png",outputDir), kTRUE);
  gSystem->mkdir(Form("./%s/pdf",outputDir), kTRUE);
 // set the style
  setTDRStyle();
 
  // type of available comparisons:
  const char* sample[4] = {"noTnP","dataTnP","mcTnP","lxyTnP"};

  const int nInHist = 4;
  const char* yieldHistNames[nInHist] = {"pt", "ptLow", "ptLow_mb", "mb"};

  // input files: are in the filesRaa_2015.h

  // open the files with yields and do the math
  TFile *fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[0]));
  TFile *fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_1[1]));
  
  TFile *fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[0]));
  TFile *fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_1[1]));

  TFile *fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile[0]));
  TFile *fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile[1]));

  switch(whichSample){
  case 0:
    cout << "You are making Raa, with NOT TnP corrections whatsoever!"<<endl;
    fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[0]));
    fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_0[1]));
  
    fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[0]));
    fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_0[1]));

    fEffFile_aa = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[0]));
    fEffFile_pp = new TFile(Form("%s/%s",inputDir,effHistFile_noTnP[1]));
    break;

  case 2:
    cout << "You are making Raa, with TnP corrections applied on MC!"<<endl;
    fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[0]));
    fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_2[1]));
  
    fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[0]));
    fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_2[1]));
    break;

  case 3: 
    cout << "You are making Raa, with Lxy and TnP corrections applie on MC!"<<endl;
    fYesWeighFile_aa   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[0]));
    fYesWeighFile_pp   = new TFile(Form("%s/%s",inputDir,yieldHistFile_yesWeight_3[1]));
  
    fNoWeighFile_aa = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[0]));
    fNoWeighFile_pp = new TFile(Form("%s/%s",inputDir,yieldHistFile_noWeight_3[1]));
    break;

  case 1:
  default:
    cout<<" You are doing Raa Nominal: TnP on data!"<<endl;
    break;
  }

  if (!fYesWeighFile_aa->IsOpen() || !fYesWeighFile_pp->IsOpen()|| !fNoWeighFile_aa->IsOpen() || !fNoWeighFile_pp->IsOpen() || !fEffFile_aa->IsOpen() || !fEffFile_pp->IsOpen()) {
    cout << "One or more input files are missing" << endl;
    return ;
  }

  TH1F *phRaw_pr_pp; 
  TH1F *phCorr_pr_pp;
  TH1F *phEff_pr_pp;
  TH1F *phRaw_pr_aa; 
  TH1F *phCorr_pr_aa;
  TH1F *phEff_pr_aa;

  TH1F *phRaw_npr_pp; 
  TH1F *phCorr_npr_pp;
  TH1F *phEff_npr_pp;
  TH1F *phRaw_npr_aa; 
  TH1F *phCorr_npr_aa;
  TH1F *phEff_npr_aa;
  
  for(int ih=0; ih<nInHist;ih++) // for each kinematic range
  {
    TString hist_pr(Form("phPrp_%s",yieldHistNames[ih]));
    TString hist_npr(Form("phNPrp_%s",yieldHistNames[ih]));
    
    cout<<"histogram input name: "<< hist_pr<<"\t"<<hist_npr<<endl; 

    // prompt histos
    phRaw_pr_pp  = (TH1F*)fNoWeighFile_pp->Get(hist_pr);
    phCorr_pr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_pr);
    phRaw_pr_aa  = (TH1F*)fNoWeighFile_aa->Get(hist_pr);
    phCorr_pr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_pr);
    
    // non-prompt histos
    phRaw_npr_pp  = (TH1F*)fNoWeighFile_pp->Get(hist_npr);
    phCorr_npr_pp = (TH1F*)fYesWeighFile_pp->Get(hist_npr);
    phRaw_npr_aa  = (TH1F*)fNoWeighFile_aa->Get(hist_npr);
    phCorr_npr_aa = (TH1F*)fYesWeighFile_aa->Get(hist_npr);

    // efficiency histos
    phEff_pr_pp  = (TH1F*)fEffFile_pp->Get(hist_pr);
    phEff_npr_pp = (TH1F*)fEffFile_pp->Get(hist_npr);
    phEff_pr_aa  = (TH1F*)fEffFile_aa->Get(hist_pr);
    phEff_npr_aa = (TH1F*)fEffFile_aa->Get(hist_npr);

    double scaleFactor = ppLumi/nMbEvents;
    double scale_cent = 1/(adTaaMB[0]*adDeltaCentMB[0]);
  
    int numBins = 0;
    if(ih==0) numBins = nBinsPt;
    if(ih==1 || ih==2) numBins = nBinsPt3;
    if(ih==3) numBins = nBinsMB;

    for(int ibin=1; ibin<=numBins; ibin++)
    {
      double raa_pr=0, raaErr_pr=0, raa_npr=0, raaErr_npr=0;

      //prompt
      double dRelErrRaw_pr_pp  = phRaw_pr_pp->GetBinError(ibin)/phRaw_pr_pp->GetBinContent(ibin);
      double dRelErrRaw_pr_aa  = phRaw_pr_aa->GetBinError(ibin)/phRaw_pr_aa->GetBinContent(ibin);
      double yieldRatio_pr     = phCorr_pr_aa->GetBinContent(ibin)/phCorr_pr_pp->GetBinContent(ibin);
     
      raa_pr      =  yieldRatio_pr * scaleFactor * scale_cent;
      raaErr_pr   = TMath::Sqrt(TMath::Power(dRelErrRaw_pr_pp,2)+TMath::Power(dRelErrRaw_pr_aa,2))*raa_pr;

      //non-prompt
      // get the rel uncert from the raw sample
      double dRelErrRaw_npr_pp  = phRaw_npr_pp->GetBinError(ibin)/phRaw_npr_pp->GetBinContent(ibin);
      double dRelErrRaw_npr_aa  = phRaw_npr_aa->GetBinError(ibin)/phRaw_npr_aa->GetBinContent(ibin);
      double yieldRatio_npr     = phCorr_npr_aa->GetBinContent(ibin)/phCorr_npr_pp->GetBinContent(ibin);
    
      raa_npr    = yieldRatio_npr * scaleFactor * scale_cent;
      raaErr_npr = TMath::Sqrt(TMath::Power(dRelErrRaw_npr_pp,2)+TMath::Power(dRelErrRaw_npr_aa,2))*raa_npr;
     
      // fill the corresponding array
      switch(ih){
      case 0:
        prJpsi_pt[ibin-1]    = raa_pr;
        prJpsiErr_pt[ibin-1] = raaErr_pr;
              
        nonPrJpsi_pt[ibin-1]    = raa_npr;
        nonPrJpsiErr_pt[ibin-1] = raaErr_npr;
        break;

      case 1:
        prJpsi_pt365y1624_pt[ibin-1]        = raa_pr;
        prJpsiErr_pt365y1624_pt[ibin-1]     = raaErr_pr;

        nonPrJpsi_pt365y1624_pt[ibin-1]     = raa_npr;
        nonPrJpsiErr_pt365y1624_pt[ibin-1]  = raaErr_npr;
        break;

      case 2:
        prJpsi_y1624MB_pt[ibin-1]        = raa_pr;
        prJpsiErr_y1624MB_pt[ibin-1]     = raaErr_pr;

        nonPrJpsi_y1624MB_pt[ibin-1]     = raa_npr;
        nonPrJpsiErr_y1624MB_pt[ibin-1]  = raaErr_npr;

        if(bDoDebug)
        {
	  cout<<"yield_npr_aa "<<phCorr_npr_aa->GetBinContent(ibin)<<"\t yield_pr_pp "<<phCorr_npr_pp->GetBinContent(ibin)<<endl;
	  cout<<setprecision(2);
          cout<<"!!!!! raa_pr = "<<raa_pr<<"\t raa_npr= "<<raa_npr<<endl;
        }
        break;
      case 3:
        // mb
        prJpsi_mb[0]     = raa_pr;
        prJpsiErr_mb[0]  = raaErr_pr;
        
        nonPrJpsi_mb[0]     = raa_npr;
        nonPrJpsiErr_mb[0]  = raaErr_npr;
        break;
      }
    }//loop end: for(int ibin=1; ibin<=numBins; ibin++)
  }//loop end: for(int ih=0; ih<nInHist;ih++)

  // ***** //Drawing
  // pr
  TGraphErrors *gPrJpsi     = new TGraphErrors(nBinsPt, binsPt, prJpsi_pt, binsPtErr, prJpsiErr_pt);
  TGraphErrors *gPrJpsiP    = new TGraphErrors(nBinsPt, binsPt, prJpsi_pt, binsPtErr, prJpsiErr_pt);
  TGraphErrors *gPrJpsiSyst = new TGraphErrors(nBinsPt, binsPt, prJpsi_pt, binsPtX, prJpsiErrSyst_pt);

  TGraphErrors *gPrJpsi_mb     = new TGraphErrors(nBinsMB, binsPtMB, prJpsi_pt, binsPtMBErr, prJpsiErr_pt);
  TGraphErrors *gPrJpsiP_mb    = new TGraphErrors(nBinsMB, binsPtMB, prJpsi_pt, binsPtMBErr, prJpsiErr_pt);
  TGraphErrors *gPrJpsiSyst_mb = new TGraphErrors(nBinsMB, binsPtMB, prJpsi_pt, binsPtMBX  , prJpsiErrSyst_pt);
 
  TGraphErrors *gPrJpsi_y1624_mb     = new TGraphErrors(nBinsPt3, binsPt3_mb, prJpsi_y1624MB_pt, binsPt3Err_mb, prJpsiErr_y1624MB_pt);
  TGraphErrors *gPrJpsiP_y1624_mb    = new TGraphErrors(nBinsPt3, binsPt3_mb, prJpsi_y1624MB_pt, binsPt3Err_mb, prJpsiErr_y1624MB_pt);
  TGraphErrors *gPrJpsiSyst_y1624_mb = new TGraphErrors(nBinsPt3, binsPt3_mb, prJpsi_y1624MB_pt, binsPt3X_mb,   prJpsiErrSyst_y1624MB_pt);


  TGraphErrors *gPrJpsi_pt365y1624     = new TGraphErrors(nBinsPt3, binsPt3, prJpsi_pt365y1624_pt, binsPt3Err, prJpsiErr_pt365y1624_pt);
  TGraphErrors *gPrJpsiP_pt365y1624    = new TGraphErrors(nBinsPt3, binsPt3, prJpsi_pt365y1624_pt, binsPt3Err, prJpsiErr_pt365y1624_pt);
  TGraphErrors *gPrJpsiSyst_pt365y1624 = new TGraphErrors(nBinsPt3, binsPt3, prJpsi_pt365y1624_pt, binsPt3X, prJpsiErrSyst_pt365y1624_pt);

 
  // nonPr   
  TGraphErrors *gNonPrJpsi     = new TGraphErrors(nBinsPt, binsPt, nonPrJpsi_pt, binsPtErr, nonPrJpsiErr_pt);
  TGraphErrors *gNonPrJpsiP    = new TGraphErrors(nBinsPt, binsPt, nonPrJpsi_pt, binsPtErr, nonPrJpsiErr_pt);
  TGraphErrors *gNonPrJpsiSyst = new TGraphErrors(nBinsPt, binsPt, nonPrJpsi_pt, binsPtX, nonPrJpsiErrSyst_pt);

  TGraphErrors *gNonPrJpsi_mb     = new TGraphErrors(nBinsMB, binsPtMB, nonPrJpsi_pt, binsPtMBErr, nonPrJpsiErr_pt);
  TGraphErrors *gNonPrJpsiP_mb    = new TGraphErrors(nBinsMB, binsPtMB, nonPrJpsi_pt, binsPtMBErr, nonPrJpsiErr_pt);
  TGraphErrors *gNonPrJpsiSyst_mb = new TGraphErrors(nBinsMB, binsPtMB, nonPrJpsi_pt, binsPtMBX, nonPrJpsiErrSyst_pt);


  TGraphErrors *gNonPrJpsi_y1624_mb     = new TGraphErrors(nBinsPt3, binsPt3_mb, nonPrJpsi_y1624MB_pt, binsPt3Err_mb, nonPrJpsiErr_y1624MB_pt);
  TGraphErrors *gNonPrJpsiP_y1624_mb    = new TGraphErrors(nBinsPt3, binsPt3_mb, nonPrJpsi_y1624MB_pt, binsPt3Err_mb, nonPrJpsiErr_y1624MB_pt);
  TGraphErrors *gNonPrJpsiSyst_y1624_mb = new TGraphErrors(nBinsPt3, binsPt3_mb, nonPrJpsi_y1624MB_pt, binsPt3X_mb,   nonPrJpsiErrSyst_y1624MB_pt);

  TGraphErrors *gNonPrJpsi_pt365y1624     = new TGraphErrors(nBinsPt3, binsPt3, nonPrJpsi_pt365y1624_pt, binsPt3Err, nonPrJpsiErr_pt365y1624_pt);
  TGraphErrors *gNonPrJpsiP_pt365y1624    = new TGraphErrors(nBinsPt3, binsPt3, nonPrJpsi_pt365y1624_pt, binsPt3Err, nonPrJpsiErr_pt365y1624_pt);
  TGraphErrors *gNonPrJpsiSyst_pt365y1624 = new TGraphErrors(nBinsPt3, binsPt3, nonPrJpsi_pt365y1624_pt, binsPt3X,   nonPrJpsiErrSyst_pt365y1624_pt);


  //-------------------------------------------------------------------
  // **************** marker colors
  //prompt
  gPrJpsi->SetMarkerColor(kRed);
  gPrJpsi_pt365y1624->SetMarkerColor(kViolet+2);
    
  // non-prompt
  gNonPrJpsi->SetMarkerColor(kOrange+2);
  gNonPrJpsi_pt365y1624->SetMarkerColor(kViolet+2);

  //mnbias colors
  gPrJpsi_mb->SetMarkerColor(kCyan+2);
  gNonPrJpsi_mb->SetMarkerColor(kCyan+2);

  gPrJpsi_y1624_mb->SetMarkerColor(kBlue-4);
  gNonPrJpsi_y1624_mb->SetMarkerColor(kBlue-4);

  //--------- marker style  
  // pr
  gPrJpsi->SetMarkerStyle(21);
  gPrJpsiP->SetMarkerStyle(25);

  gPrJpsi_pt365y1624->SetMarkerStyle(34);
  gPrJpsiP_pt365y1624->SetMarkerStyle(28);

  // non-pr
  gNonPrJpsi->SetMarkerStyle(29);
  gNonPrJpsiP->SetMarkerStyle(30);
  
  gNonPrJpsi_pt365y1624->SetMarkerStyle(34);
  gNonPrJpsiP_pt365y1624->SetMarkerStyle(28);

  //mb
  gPrJpsi_mb->SetMarkerStyle(28);
  gPrJpsi_y1624_mb->SetMarkerStyle(21);   
  
  gNonPrJpsi_mb->SetMarkerStyle(28);
  gNonPrJpsi_y1624_mb->SetMarkerStyle(21);


  // ************** contour
  // pr
  gPrJpsiP->SetMarkerColor(kBlack);
  gPrJpsiP_pt365y1624->SetMarkerColor(kBlack);

  // nonPr
  gNonPrJpsiP->SetMarkerColor(kBlack);
  gNonPrJpsiP_pt365y1624->SetMarkerColor(kBlack);


  // marker size
  // pr
  gPrJpsi->SetMarkerSize(1.2);
  gPrJpsiP->SetMarkerSize(1.2);

  gPrJpsiP_pt365y1624->SetMarkerSize(1.7);
  gPrJpsi_pt365y1624->SetMarkerSize(1.7);

  gPrJpsi_mb->SetMarkerSize(1.5);
  gNonPrJpsi_y1624_mb->SetMarkerSize(1.5);

  // nonPr
  gNonPrJpsi->SetMarkerSize(2.0);
  gNonPrJpsiP->SetMarkerSize(2.0);
  
  gNonPrJpsiP_pt365y1624->SetMarkerSize(1.7);
  gNonPrJpsi_pt365y1624->SetMarkerSize(1.7);


  //stat boxes
  gPrJpsiSyst->SetFillColor(kRed-9);
  gPrJpsiSyst_pt365y1624->SetFillColor(kViolet-9);

  // non-pr
  gNonPrJpsiSyst->SetFillColor(kOrange-9);
  gNonPrJpsiSyst_pt365y1624->SetFillColor(kViolet-9);

  //mb
  // gPrJpsiP_mb->SetFillColor(kBlue-9);
  // gNonPrJpsiP_y1624_mb->SetFillColor(kBlue-9);
  //-------------------------------------------
  TF1 *f4 = new TF1("f4","1",0,30);
  f4->SetLineWidth(1);
  f4->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f4->GetYaxis()->SetTitle("R_{AA}");
  f4->GetYaxis()->SetRangeUser(0.0,1.5);
  f4->GetXaxis()->CenterTitle(kTRUE);

 // sqrt(sig_lumi(6%)*sig_lumi(6%)+sig_taa(5.7%)*sig_taa(5.7%)) = 0.083
  TBox *lumi = new TBox(0.0,0.917,1.,1.083);
  lumi->SetFillColor(kGray+1);


  //---------------- general stuff
  TLatex *ly     = new TLatex(20.0,0.05,"|y| < 2.4");
  ly->SetTextFont(42);
  ly->SetTextSize(0.05);
  TLatex *lcent = new TLatex(19,1.03,"Cent. 0-100%");
  lcent->SetTextFont(42);
  lcent->SetTextSize(0.05);

  TLatex *lPr = new TLatex(2,1.35,"Prompt J/#psi");
  lPr->SetTextFont(42);
  lPr->SetTextSize(0.05);

  TLatex *lNpr = new TLatex(2,1.35,"Non-prompt J/#psi");
  lNpr->SetTextFont(42);
  lNpr->SetTextSize(0.05);

  TLegend *leg11a = new TLegend(0.65,0.52,0.8,0.65);
  leg11a->SetFillStyle(0);
  leg11a->SetFillColor(0);
  leg11a->SetBorderSize(0);
  leg11a->SetMargin(0.2);
  leg11a->SetTextSize(0.04);
  leg11a->AddEntry(gPrJpsi,"|y|<2.4","P");
  leg11a->AddEntry(gPrJpsi_pt365y1624,"1.6<|y|<2.4","P");

  TLegend *leg11b = new TLegend(0.65,0.52,0.8,0.65);
  leg11b->SetFillStyle(0);
  leg11b->SetFillColor(0);
  leg11b->SetBorderSize(0);
  leg11b->SetMargin(0.2);
  leg11b->SetTextSize(0.04);
  
  leg11b->AddEntry(gPrJpsi_mb,"|y|<2.4","P");
  leg11b->AddEntry(gPrJpsi_y1624_mb,"1.6<|y|<2.4","P");

  TLegend *leg22a = new TLegend(0.65,0.52,0.8,0.65);
  leg22a->SetFillStyle(0);
  leg22a->SetFillColor(0);
  leg22a->SetBorderSize(0);
  leg22a->SetMargin(0.2);
  leg22a->SetTextSize(0.04);
  leg22a->AddEntry(gNonPrJpsi,"|y|<2.4","P");
  leg22a->AddEntry(gNonPrJpsi_pt365y1624,"1.6<|y|<2.4","P");
 
  TLegend *leg22b = new TLegend(0.65,0.52,0.8,0.65);
  leg22b->SetFillStyle(0);
  leg22b->SetFillColor(0);
  leg22b->SetBorderSize(0);
  leg22b->SetMargin(0.2);
  leg22b->SetTextSize(0.04);
  
  leg22b->AddEntry(gNonPrJpsi_mb,"|y|<2.4","P");
  leg22b->AddEntry(gNonPrJpsi_y1624_mb,"1.6<|y|<2.4","P");
 

  // ##################################################### pr plots
  TCanvas *c1 = new TCanvas("c1","c1");
  // general stuff
  f4->Draw();// axis
  if(bAddLumi) 
  {
    lumi->Draw();
    f4->Draw("same");
  }
 
  CMS_lumi(c1,103,33);
  lcent->Draw();
  lPr->Draw();
  leg11a->Draw();
  
  gPrJpsiSyst->Draw("2");
  gPrJpsi->Draw("P");
  gPrJpsiP->Draw("P");

  gPrJpsiSyst_pt365y1624->Draw("2");
  gPrJpsi_pt365y1624->Draw("P");
  gPrJpsiP_pt365y1624->Draw("P");


  if(bSavePlots)
  {
    c1->SaveAs(Form("%s/pdf/PrJpsi_vsPt_%s.pdf",outputDir,sample[whichSample]));
    c1->SaveAs(Form("%s/png/PrJpsi_vsPt_%s.png",outputDir,sample[whichSample]));
  }
  
  //-------------------minbias dependence
  TCanvas *c11b = new TCanvas("c11b","c11b");
  f4->Draw();
  if(bAddLumi)
  {
    lumi->Draw();
    f4->Draw("same");
  }
  CMS_lumi(c11b,103,33);
  lcent->Draw();
  lPr->Draw();
  leg11b->Draw();
  
  gPrJpsiSyst_mb->Draw("2");
  gPrJpsi_mb->Draw("P");
 
  gPrJpsiSyst_y1624_mb->Draw("2");
  gPrJpsi_y1624_mb->Draw("P");
 
  gPad->RedrawAxis();

  if(bSavePlots)
  {
    c11b->SaveAs(Form("%s/pdf/PrJpsi_vsPt_mb_%s.pdf",outputDir,sample[whichSample]));
    c11b->SaveAs(Form("%s/png/PrJpsi_vsPt_mb_%s.png",outputDir,sample[whichSample]));
  }

  //   // ############################################## non-pr 
  //   // ############################################## non-pr
  //   // ############################################## non-pr
  TCanvas *c2 = new TCanvas("c2","c2");
  // general stuff
  f4->Draw();// axis
  if(bAddLumi) 
  {
    lumi->Draw();
    f4->Draw("same");
  }
 
  CMS_lumi(c2,103,33);
  lcent->Draw();
  lNpr->Draw(0);
  leg22a->Draw();

  gNonPrJpsiSyst->Draw("2");
  gNonPrJpsi->Draw("P");
  gNonPrJpsiP->Draw("P");

  gNonPrJpsiSyst_pt365y1624->Draw("2");
  gNonPrJpsi_pt365y1624->Draw("P");
  gNonPrJpsiP_pt365y1624->Draw("P");

  if(bSavePlots)
  {
    c2->SaveAs(Form("%s/pdf/nonPrJpsi_vsPt_%s.pdf",outputDir,sample[whichSample]));
    c2->SaveAs(Form("%s/png/nonPrJpsi_vsPt_%s.png",outputDir,sample[whichSample]));
  }
  
  //-------------------minbias dependence
  TCanvas *c22b = new TCanvas("c22b","c22b");
  f4->Draw();
  if(bAddLumi)
  {
    lumi->Draw();
    f4->Draw("same");
  }

  CMS_lumi(c22b,103,33);
  lcent->Draw();
  lNpr->Draw(0);
  leg22b->Draw();
   
  gNonPrJpsiSyst_mb->Draw("2");
  gNonPrJpsi_mb->Draw("P");
 
  gNonPrJpsiSyst_y1624_mb->Draw("2");
  gNonPrJpsi_y1624_mb->Draw("P");

 
  gPad->RedrawAxis();

  if(bSavePlots)
  {
    c22b->SaveAs(Form("%s/pdf/nonPrJpsi_vsPt_mb_%s.pdf",outputDir,sample[whichSample]));
    c22b->SaveAs(Form("%s/png/nonPrJpsi_vsPt_mb_%s.png",outputDir,sample[whichSample]));
  }


}
Example #27
0
void plotAnaMult4(char *infname="ana.root")
{    
   TFile *inf = new TFile(infname);
   
   TTree *tData = (TTree*) inf->Get("Data_tree");
   TTree *tMC   = (TTree*) inf->Get("MC_tree");
   TTree *tPP   = (TTree*) inf->Get("PP_tree");

   TCanvas *c1 = new TCanvas("c","",1200,700);
//   c->Divide(4,1);
   TCut recoCut = "leadingJetPt>120&&subleadingJetPt>50&&dphi>5*3.14159265358979/6.&&abs(leadingJetEta)<1.6&&abs(subleadingJetEta)<1.6";
   TCut genCut = "genleadingJetPt>120&&gensubleadingJetPt>50&&genDphi>5*3.14159265358979/6.&&abs(genleadingJetEta)<1.6&&abs(gensubleadingJetEta)<1.6";

   
   const int nPtBin=5;
   Float_t PtBins[nPtBin+1] = {0.001,0.5,1,1.5,2,3.2};
   
   Int_t centBin[5] = {200,100,60,20,0};
   makeMultiPanelCanvas(c1,4,2,0.0,0.0,0.2,0.2,0.02);
   
   for (int i=0;i<4;i++) {
      c1->cd(i+1);
      TH1D * empty=new TH1D("empty","",100,0,3.19);
//      empty->Fill(0.5,1000); 
      empty->SetMaximum(39.99); 
      empty->SetMinimum(0.001); 
      empty->SetNdivisions(105,"X");
      empty->GetXaxis()->SetTitleSize(28);
      empty->GetXaxis()->SetTitleFont(43); 
      empty->GetXaxis()->SetTitleOffset(1.8);
      empty->GetXaxis()->SetLabelSize(22);
      empty->GetXaxis()->SetLabelFont(43);
      empty->GetYaxis()->SetTitleSize(28);
      empty->GetYaxis()->SetTitleFont(43); 
      empty->GetYaxis()->SetTitleOffset(1.8);
      empty->GetYaxis()->SetLabelSize(22);
      empty->GetYaxis()->SetLabelFont(43);
      empty->GetXaxis()->CenterTitle();
      empty->GetYaxis()->CenterTitle();

      empty->SetXTitle("#Delta#eta_{1,2}");
      empty->SetYTitle("Multiplicity Difference");
   
      TProfile *pData = new TProfile(Form("pData%d",i),"",nPtBin,PtBins);
      TProfile *pMC = new TProfile(Form("pMC%d",i),"",nPtBin,PtBins);
      TProfile *pPP = new TProfile(Form("pPP%d",i),"",nPtBin,PtBins);
      TProfile *pGen = new TProfile(Form("pGen%d",i),"",nPtBin,PtBins);
      TCut centCut = Form("hiBin>=%d&&hiBin<%d",centBin[i+1],centBin[i]);
      tData->Draw(Form("-multDiff:abs(leadingJetEta-subleadingJetEta)>>pData%d",i),recoCut&&centCut);
      tPP->Draw(Form("-multDiff:abs(leadingJetEta-subleadingJetEta)>>pPP%d",i),recoCut);
      tMC->Draw(Form("-multDiff:abs(leadingJetEta-subleadingJetEta)>>pMC%d",i),recoCut&&centCut);  
      tMC->Draw(Form("-genMultDiff:abs(genleadingJetEta-gensubleadingJetEta)>>pGen%d",i),genCut&&centCut);  

      pMC->SetLineColor(2);
      pMC->SetMarkerColor(2);
      pPP->SetLineColor(4);
      pPP->SetMarkerColor(4);
      
//      pData->SetAxisRange(0,50,"Y");
//      pData->SetAxisRange(0,0.49,"X");
      empty->Draw();

      double diff=0;
      if (i==0) diff=0.1;
      drawText(Form("%d-%d %%",(int)(0.5*centBin[i+1]),(int)(0.5*centBin[i])),0.22+diff,0.65);
      if (i==0) drawText("PbPb #sqrt{s_{NN}}=2.76 TeV 150/#mub",0.22+diff,0.85);
      if (i==0) drawText("pp      #sqrt{s_{NN}}=2.76 TeV 5.3/pb",0.22+diff,0.75);
      if (i==3) drawText("CMS Preliminary",0.3+diff,0.85);
            
      Float_t sys[4]={1,1,2.5,3};
      

      for (int j=1;j<=pData->GetNbinsX();j++)
      {
         TBox *b = new TBox(pData->GetBinLowEdge(j),pData->GetBinContent(j)-sys[i],pData->GetBinLowEdge(j+1),pData->GetBinContent(j)+sys[i]);
	 //b->SetFillColor(kGray);
	 b->SetFillStyle(0);
	 b->SetLineColor(1);
	 b->Draw();
         TBox *b2 = new TBox(pPP->GetBinLowEdge(j),pPP->GetBinContent(j)-1,pPP->GetBinLowEdge(j+1),pPP->GetBinContent(j)+1);
	 //b2->SetFillColor(65);
	 b2->SetFillStyle(0);
	 b2->SetLineColor(4);
	 b2->Draw();
      }
      pData->Draw("same");
      pMC->Draw("same");
      pPP->Draw("same");
      pGen->SetMarkerColor(4);
      pGen->SetMarkerStyle(24);
      pData->Draw("same");
      
//      pGen->Draw(" same");

      c1->cd(5+i);
      TH1D *empty2 = (TH1D*)empty->Clone("empty2");
      empty2->SetYTitle("PbPb - pp");
      empty2->SetMinimum(-5);
      empty2->SetMaximum(+29.99);
      empty2->Draw();
//      TProfile *pDiff = (TProfile*)pData->Clone("pDiff");
      TH1D *pDiff = new TH1D("pDiff","",nPtBin,PtBins);
      
      for (int j=1;j<=pData->GetNbinsX();j++)
      {
	 pDiff->SetBinContent(j,pData->GetBinContent(j)-pPP->GetBinContent(j));
  	 pDiff->SetBinError(j,sqrt(pData->GetBinError(j)*pData->GetBinError(j)+pPP->GetBinError(j)*pPP->GetBinError(j)));
         TBox *b = new TBox(pDiff->GetBinLowEdge(j),pDiff->GetBinContent(j)-sys[i],pDiff->GetBinLowEdge(j+1),pDiff->GetBinContent(j)+sys[i]);
         TBox *b2 = new TBox(pDiff->GetBinLowEdge(j),pDiff->GetBinContent(j)-sys[i],pDiff->GetBinLowEdge(j+1),pDiff->GetBinContent(j)+sys[i]);
         b->SetFillColor(TColor::GetColor("#FFEE00"));
	 b2->SetLineColor(1);
	 b2->SetFillStyle(0);
	 b->Draw();
	 b2->Draw();
      }
      
      pDiff->Draw("p same");


      TLegend *leg = new TLegend(0.3,0.6,0.9,0.9);
      leg->SetFillStyle(0);
      leg->SetBorderSize(0);
      leg->AddEntry(pData,"PbPb","pl");
      leg->AddEntry(pPP,"pp","pl");
      leg->AddEntry(pMC,"PYTHIA+HYDJET","pl");
      if (i==0) leg->Draw();

      if (i==1) drawText("p_{T,1} > 120 GeV/c",0.22+diff,0.85);
      if (i==1) drawText("p_{T,2} >  50 GeV/c",0.22+diff,0.75);
      if (i==1) drawText("#Delta#phi_{1,2} > 5#pi/6",0.22+diff,0.65);

   }
/*
   TCanvas *c1 = new TCanvas("c1","",(ncent+1)*300,700);
   makeMultiPanelCanvas(c1,ncent+1,2,0.0,0.0,0.2,0.2,0.02);
   TH1D * empty=new TH1D("empty",Form(";%s;<#slash{p}_{T}^{#parallel}> (GeV)",axistitle[index_var].Data()),nalpha/2+1,frac);
   TH1D * empty2=new TH1D("empty2",Form(";%s;<#slash{p}_{T}^{#parallel}> (GeV)",axistitle[index_var].Data()),nalpha/2+1,frac);
   empty->Fill(0.5,1000); 
   empty2->Fill(0.5,1000);   
   if(doIntegrate){
      if(index_var==0){
         empty->SetMaximum(30); 
         empty->SetMinimum(-70); 
      }else{
         empty->SetMaximum(35); 
         empty->SetMinimum(-45); 
      }
   }else{
      empty->SetMaximum(15); 
      empty->SetMinimum(-10); 
      empty2->SetMaximum(15); 
      empty2->SetMinimum(-10); 
   }
   empty->GetXaxis()->SetTitleSize(28);
   empty->GetXaxis()->SetTitleFont(43); 
   empty->GetXaxis()->SetTitleOffset(2.2);
   empty->GetXaxis()->SetLabelSize(22);
   empty->GetXaxis()->SetLabelFont(43);
   empty->GetYaxis()->SetTitleSize(28);
   empty->GetYaxis()->SetTitleFont(43); 
   empty->GetYaxis()->SetTitleOffset(2.2);
   empty->GetYaxis()->SetLabelSize(22);
   empty->GetYaxis()->SetLabelFont(43);
   empty2->GetXaxis()->SetTitleSize(28);
   empty2->GetXaxis()->SetTitleFont(43); 
   empty2->GetXaxis()->SetTitleOffset(2.2);
   empty2->GetXaxis()->SetLabelSize(22);
   empty2->GetXaxis()->SetLabelFont(43);
   empty2->GetYaxis()->SetTitleSize(28);
   empty2->GetYaxis()->SetTitleFont(43); 
   empty2->GetYaxis()->SetTitleOffset(2.2);
   empty2->GetYaxis()->SetLabelSize(22);
   empty2->GetYaxis()->SetLabelFont(43);
   
   
   c1->cd(ncent+2); 
*/

   c1->SaveAs("results/MultiplicityDifference-DeltaEta.C");
   c1->SaveAs("results/MultiplicityDifference-DeltaEta.gif");
   c1->SaveAs("results/MultiplicityDifference-DeltaEta.eps");
   c1->SaveAs("results/MultiplicityDifference-DeltaEta.pdf");


}
void NuclearModificationFactorCent(TString inputPP="ROOTfiles/CrossSectionPP.root", TString inputPbPb="ROOTfiles/CrossSectionPbPb.root", TString inputEffPP = "ROOTfiles/MCstudiesPP_INC.root", TString inputEffPbPb = "ROOTfiles/MCstudiesPbPb_CENT.root", TString label="PbPb", TString outputfile="RAAfile.root", int doDataCor = 0, double PPlumi=1., double nMBEvt=1., Float_t centMin=0., Float_t centMax=100.)
{
  float pti = _ptBins[0];
  float pte = _ptBins[_nBins];

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetEndErrorSize(0);
  gStyle->SetMarkerStyle(20);
  gStyle->SetPadRightMargin(0.03);//###0.020
  gStyle->SetPadLeftMargin(0.12);
  gStyle->SetPadTopMargin(0.075);
  gStyle->SetPadBottomMargin(0.12);

  TFile *fpp=new TFile(inputPP.Data());
  TFile *fPbPb=new TFile(inputPbPb.Data());
  TFile *fEffpp=new TFile(inputEffPP.Data());
  TFile *fEffPbPb=new TFile(inputEffPbPb.Data());

  TH1D*hSigmaPP1Bin=(TH1D*)fpp->Get("hPt");
  TH1D*hSigmaPbPb=(TH1D*)fPbPb->Get("hPt");
  TH1D*hEffPP1Bin=(TH1D*)fEffpp->Get("hEff");
  TH1D*hEffPbPb=(TH1D*)fEffPbPb->Get("hEff");

  TH1D*hSigmaPPStat = new TH1D("hSigmaPPStat","",_nBins,_ptBins);
  TH1D*hEffPP = new TH1D("hEffPP","",_nBins,_ptBins);
  for(int i=0;i<_nBins;i++){
    hSigmaPPStat->SetBinContent(i+1,hSigmaPP1Bin->GetBinContent(1));
    hSigmaPPStat->SetBinError(i+1,hSigmaPP1Bin->GetBinError(1));
    hEffPP->SetBinContent(i+1,hEffPP1Bin->GetBinContent(1));
    hEffPP->SetBinError(i+1,hEffPP1Bin->GetBinError(1));
  }
  if(doDataCor != 1) hSigmaPPStat->Divide(hEffPP);
  hSigmaPPStat->Scale(1./(2*PPlumi*BRchain));

  TH1D*hSigmaPbPbStat=(TH1D*)fPbPb->Get("hPt");
  for(int i=0;i<_nBins;i++){
  }
  hSigmaPbPbStat->SetName("hSigmaPbPbStat");
  if(doDataCor != 1) hSigmaPbPbStat->Divide(hEffPbPb);
  hSigmaPbPbStat->Divide(hSigmaPPStat);
  for(int i=0;i<_nBins;i++){
    double pbpbScale = 2*BRchain*(nMBEvt*(_ptBins[i+1]-_ptBins[i])/2/100*TAA[i]/1e9);
    hSigmaPbPbStat->SetBinContent(i+1, hSigmaPbPbStat->GetBinContent(i+1)/pbpbScale);
    hSigmaPbPbStat->SetBinError(i+1, hSigmaPbPbStat->GetBinError(i+1)/pbpbScale);
    //std::cout<<"RAA: "<<hSigmaPbPbStat->GetBinContent(i+1)<<std::endl;
  }

  /*
  double mod_ptBins[_nBins+1];
  for(int i=0;i<_nBins+1;i++){
    mod_ptBins[i] = _ptBins[i]/2.;
  }  
  TH1D*hNuclearModification = new TH1D("hNuclearModification","",_nBins,mod_ptBins);
  for(int i=0;i<_nBins;i++){
    hNuclearModification->SetBinContent(i+1, hSigmaPbPbStat->GetBinContent(i+1));
    hNuclearModification->SetBinError(i+1, hSigmaPbPbStat->GetBinError(i+1));
  }

  double apt[_nBins];
  //bin half width
  double aptl[_nBins];
  //number of every rebined bin
  double bin_num[_nBins];

  for (int ibin=0; ibin<_nBins; ibin++){
    apt[ibin]=(mod_ptBins[ibin+1]+mod_ptBins[ibin])/2.;
    aptl[ibin] = (mod_ptBins[ibin+1]-mod_ptBins[ibin])/2;
    bin_num[ibin]=aptl[ibin]/binsize*2;
  }
  pti = pti/2.;
  pte = pte/2.;

  Double_t xr[_nBins], yr[_nBins], xrlow[_nBins], yrlow[_nBins],xrhigh[_nBins],yrhigh[_nBins];
  for(int i=0;i<_nBins;i++)
  {
    yr[i] = hNuclearModification->GetBinContent(i+1);
    double systematic=0.01*systematicsForRAACent(hNuclearModification->GetBinCenter(i+1),centMin,centMax,0.,0.);
    //double systematic=0.;
    yrlow[i] = hNuclearModification->GetBinContent(i+1)*systematic;
    yrhigh[i] =hNuclearModification->GetBinContent(i+1)*systematic;
  }
  */

  double mod_ptBins[_nBins];
  for(int i=0;i<_nBins;i++){
    mod_ptBins[i] = npart[_nBins-1-i];
  }  
  double apt[_nBins];
  //bin half width
  double aptl[_nBins];
  //number of every rebined bin
  double bin_num[_nBins];

  for (int ibin=0; ibin<_nBins; ibin++){
    apt[ibin]  = mod_ptBins[ibin];
    aptl[ibin] = 10;
  }

  pti = 0;
  pte = apt[_nBins-1]+50;

  Double_t xr[_nBins], yr[_nBins], xrlow[_nBins], yrlow[_nBins],xrhigh[_nBins],yrhigh[_nBins];
  Double_t yrStatlow[_nBins], yrStathigh[_nBins];
  for(int i=0;i<_nBins;i++)
  {
    yr[i] = hSigmaPbPbStat->GetBinContent(_nBins-i);
    double systematic=0.01*systematicsForRAACent(hSigmaPbPbStat->GetBinCenter(_nBins-i)/2.,centMin,centMax,0.,0.);
    //double systematic=0.;
    yrStatlow[i]  = hSigmaPbPbStat->GetBinError(_nBins-i);
    yrStathigh[i] = hSigmaPbPbStat->GetBinError(_nBins-i);
    yrlow[i]  = hSigmaPbPbStat->GetBinContent(_nBins-i)*systematic;
    yrhigh[i] = hSigmaPbPbStat->GetBinContent(_nBins-i)*systematic;
  }

  TGraphAsymmErrors* hNuclearModification = new TGraphAsymmErrors(_nBins,apt,yr,aptl,aptl,yrStatlow,yrStathigh);
  hNuclearModification->SetName("hNuclearModification");

  TGraphAsymmErrors* gNuclearModification = new TGraphAsymmErrors(_nBins,apt,yr,aptl,aptl,yrlow,yrhigh);
  gNuclearModification->SetName("gNuclearModification");

  TCanvas*canvasRAA=new TCanvas("canvasRAA","canvasRAA",600,600);
  canvasRAA->cd();
  //canvasRAA->SetLogx();

  TH2F* hemptyEff=new TH2F("hemptyEff","",50,pti,pte,10.,0,1.55);  
  hemptyEff->GetXaxis()->CenterTitle();
  hemptyEff->GetYaxis()->CenterTitle();
  hemptyEff->GetYaxis()->SetTitle("B^{+} R_{AA}");
  hemptyEff->GetXaxis()->SetTitle("N_{part}");
  hemptyEff->GetXaxis()->SetTitleOffset(1.0);
  hemptyEff->GetYaxis()->SetTitleOffset(1.1);
  hemptyEff->GetXaxis()->SetTitleSize(0.05);
  hemptyEff->GetYaxis()->SetTitleSize(0.05);
  hemptyEff->GetXaxis()->SetTitleFont(42);
  hemptyEff->GetYaxis()->SetTitleFont(42);
  hemptyEff->GetXaxis()->SetLabelFont(42);
  hemptyEff->GetYaxis()->SetLabelFont(42);
  hemptyEff->GetXaxis()->SetLabelSize(0.04);
  hemptyEff->GetYaxis()->SetLabelSize(0.04);  
  hemptyEff->SetMaximum(2);
  hemptyEff->SetMinimum(0.);
  hemptyEff->Draw();

  TLine *line = new TLine(pti,1,pte,1);
  line->SetLineStyle(2);
  line->SetLineWidth(2);
  line->Draw();

  //gNuclearModification->SetFillColor(5);//1
  gNuclearModification->SetFillColor(kOrange);//1
  gNuclearModification->SetFillStyle(3001);//0
  gNuclearModification->SetLineWidth(1);//3
  gNuclearModification->SetMarkerSize(1);
  gNuclearModification->SetMarkerStyle(21);
  //gNuclearModification->SetLineColor(1);//kGreen+4
  //gNuclearModification->SetMarkerColor(1);//kGreen+4
  gNuclearModification->SetLineColor(kOrange);//kGreen+4
  //gNuclearModification->SetMarkerColor(kOrange);//kGreen+4
  gNuclearModification->SetMarkerColor(kRed);//kGreen+4
  gNuclearModification->Draw("5same");

  hNuclearModification->SetLineWidth(3);
  hNuclearModification->SetLineColor(kRed);
  hNuclearModification->SetMarkerColor(kRed);
  hNuclearModification->SetMarkerStyle(21);
  //hNuclearModification->Draw("same");
  hNuclearModification->Draw("same p");

  Float_t systnorm = normalizationUncertaintyForRAA()*1.e-2;
  TBox* bSystnorm = new TBox(pti,1-systnorm,pti+10,1+systnorm);
  if(drawDRAA) bSystnorm = new TBox(pti,1-systnorm,pti+10,1+systnorm);
  bSystnorm->SetLineColor(16);
  bSystnorm->SetFillColor(16);
  bSystnorm->Draw();

  TLatex * tlatexeff2=new TLatex(0.41,0.58,Form("p_{T} %.0f-%.0f (GeV/c)",ptBinsInc[0], ptBinsInc[1]));
  tlatexeff2->SetNDC();
  tlatexeff2->SetTextColor(1);
  tlatexeff2->SetTextFont(42);
  tlatexeff2->SetTextSize(0.050);
  tlatexeff2->Draw();
  TLatex * texY = new TLatex(0.41,0.53,"|y| < 2.4");//0.2612903,0.8425793
  texY->SetNDC();
  texY->SetTextColor(1);
  texY->SetTextFont(42);
  texY->SetTextSize(0.045);
  texY->SetLineWidth(2);
  //texY->Draw();

  TLatex* texlumi = new TLatex(0.13,0.936,"27.7 pb^{-1} (5.02 TeV pp) + 350.68 #mub^{-1} (5.02 TeV PbPb)");
  texlumi->SetNDC();
  //texlumi->SetTextAlign(31);
  texlumi->SetTextFont(42);
  texlumi->SetTextSize(0.038);
  texlumi->SetLineWidth(2);
  texlumi->Draw();
  TLatex* texcms = new TLatex(0.15,0.90,"CMS");
  texcms->SetNDC();
  texcms->SetTextAlign(13);
  texcms->SetTextFont(62);//61
  texcms->SetTextSize(0.06);
  texcms->SetLineWidth(2);
  texcms->Draw();
  TLatex* texpre = new TLatex(0.15,0.84,"Preliminary");
  texpre->SetNDC();
  texpre->SetTextAlign(13);
  texpre->SetTextFont(52);
  texpre->SetTextSize(0.05);
  texpre->SetLineWidth(2);
  texpre->Draw();

  //TLegend *legendSigma=new TLegend(0.40,0.5168644,0.8084677,0.6605932,"");
  TLegend *legendSigma=new TLegend(0.5436242,0.7474695,0.942953,0.8457592,"");
  if(drawDRAA)legendSigma=new TLegend(0.5436242,0.6774695,0.942953,0.8757592,"");
  legendSigma->SetBorderSize(0);
  legendSigma->SetLineColor(0);
  legendSigma->SetFillColor(0);
  legendSigma->SetFillStyle(1001);
  legendSigma->SetTextFont(42);
  legendSigma->SetTextSize(0.045);

//  TLegendEntry *ent_SigmaPP=legendSigma->AddEntry(hNuclearModification,"R_{AA} stat. unc.","pf");
//  ent_SigmaPP->SetTextFont(42);
//  ent_SigmaPP->SetLineColor(1);
//  ent_SigmaPP->SetMarkerColor(1);
//  ent_SigmaPP->SetTextSize(0.045);
//
//  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(gNuclearModification,"R_{AA} syst.","f");
//  ent_Sigmapp->SetTextFont(42);
//  ent_Sigmapp->SetLineColor(5);
//  ent_Sigmapp->SetMarkerColor(1);
//  ent_Sigmapp->SetTextSize(0.045);

  TLegendEntry *ent_B = legendSigma->AddEntry(gNuclearModification,"R_{AA} B^{+} |y| < 2.4","pf");
  ent_B->SetTextFont(42);
  ent_B->SetLineColor(4);
  ent_B->SetMarkerColor(4);
  ent_B->SetTextSize(0.043);//0.03

  TLatex* texSystnorm = new TLatex(0.23,0.70,"T_{AA} and lumi.");
  if(drawDRAA) texSystnorm = new TLatex(0.17,0.70,"T_{AA} and lumi.");
  texSystnorm->SetNDC();
  texSystnorm->SetTextColor(1);
  texSystnorm->SetTextFont(42);
  texSystnorm->SetTextSize(0.04);
  texSystnorm->SetLineWidth(2);
  texSystnorm->Draw();
  texSystnorm = new TLatex(0.23,0.65,"uncertainty");
  if(drawDRAA) texSystnorm = new TLatex(0.17,0.65,"uncertainty");
  texSystnorm->SetNDC();
  texSystnorm->SetTextColor(1);
  texSystnorm->SetTextFont(42);
  texSystnorm->SetTextSize(0.04);
  texSystnorm->SetLineWidth(2);
  texSystnorm->Draw();

  if(drawDRAA){
    TGraphAsymmErrors* gDNuclearModification = new TGraphAsymmErrors();
    Draw_DRAA(canvasRAA, gDNuclearModification);
    gDNuclearModification->SetFillColor(kYellow-9);
    TLegendEntry *ent_Dhighpt = legendSigma->AddEntry(gDNuclearModification,"R_{AA} D^{0} |y| < 1.0","pf");
    ent_Dhighpt->SetTextFont(42);
    ent_Dhighpt->SetLineColor(4);
    ent_Dhighpt->SetMarkerColor(4);
    ent_Dhighpt->SetTextSize(0.043);//0.03
  }

  legendSigma->Draw();

  canvasRAA->Update();
  canvasRAA->RedrawAxis();

  TString _postfix = "";
  if(doDataCor==1) _postfix = "_EFFCOR";
  if(!drawDRAA){
    canvasRAA->SaveAs(Form("plotRAA/canvasRAA%s_%.0f_%.0f_Cent%s.pdf",label.Data(),centMin,centMax,_postfix.Data()));
    canvasRAA->SaveAs(Form("plotRAA/canvasRAA%s_%.0f_%.0f_Cent%s.png",label.Data(),centMin,centMax,_postfix.Data()));
  }
  if(drawDRAA){
    canvasRAA->SaveAs(Form("plotRAA/canvasRAA_DRAA_%s_%.0f_%.0f_Cent%s.pdf",label.Data(),centMin,centMax,_postfix.Data()));
    canvasRAA->SaveAs(Form("plotRAA/canvasRAA_DRAA_%s_%.0f_%.0f_Cent%s.png",label.Data(),centMin,centMax,_postfix.Data()));
  }
  TFile *fRAA=new TFile(outputfile.Data(),"recreate");
  fRAA->cd();
  gNuclearModification->Write();
  hNuclearModification->Write();
}
void raaTheoryOpen_pt(const char* inputDir = "../macro_raa/outRoot", // the place where the input root files, with the histograms are
                     bool bSavePlots      = true,
                     bool bDoBRaa  = true
                     )
{
   // set the style
  gSystem->mkdir(Form("./figs/png"), kTRUE);
  gSystem->mkdir(Form("./figs/pdf"), kTRUE);
  setTDRStyle();
  
  // read CMS graphs
  TFile *pgRaaCms_pt   = new TFile(Form("%s/makeRaa_pt.root",inputDir));
  // ##################### HIGH PT ############################
  TGraphErrors *pgCms     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi");
  TGraphErrors *pgCmsP    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP");
  TGraphErrors *pgCmsSyst = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst");
  pgCmsSyst->SetFillColorAlpha(kOrange-9,0.5);
  pgCms->SetName("gNonPrJpsi");

  TBox *lumi = (TBox*)pgRaaCms_pt->Get("lumi");
  lumi->SetFillColor(kGray+1);
  lumi->SetFillStyle(1001);
  lumi->SetX1(28.5); lumi->SetX2(30);

  // ##################### LOW PT ############################
  TGraphErrors *pgCms_lowpt     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi_pt365y1624");
  TGraphErrors *pgCmsP_lowpt    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP_pt365y1624");
  TGraphErrors *pgCmsSyst_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst_pt365y1624");
  pgCmsSyst_lowpt->SetFillColorAlpha(kViolet-9,0.5);
  pgCms_lowpt->SetName("gNonPrJpsi_pt365y1624");

   
  //-------------------------------------------------------------------- 
  // *********** Theory curves with filled area
  TGraph *pgRaaB_rapp       = new TGraph(2*raaB_rapp_vspt_numpoints);
  pgRaaB_rapp->SetName("pgRaaB_rapp");
  for (int i=0; i<raaB_rapp_vspt_numpoints; i++) {
    pgRaaB_rapp->SetPoint(i,raaB_rapp_pt[i],raaB_rapp_vspt_yhigh[i]);
    pgRaaB_rapp->SetPoint(raaB_rapp_vspt_numpoints+i,
        raaB_rapp_pt[raaB_rapp_vspt_numpoints-i-1],raaB_rapp_vspt_ylow[raaB_rapp_vspt_numpoints-i-1]);
  }

  TGraph *pgRaaB_whdg       = new TGraph(2*raaB_whdg_vspt_numpoints);
  pgRaaB_whdg->SetName("pgRaaB_whdg");
  for (int i=0; i<raaB_whdg_vspt_numpoints; i++) {
    pgRaaB_whdg->SetPoint(i,raaB_whdg_pt[i],raaB_whdg_vspt_yhigh[i]);
    pgRaaB_whdg->SetPoint(raaB_whdg_vspt_numpoints+i,
        raaB_whdg_pt[raaB_whdg_vspt_numpoints-i-1],raaB_whdg_vspt_ylow[raaB_whdg_vspt_numpoints-i-1]);
  }

  TGraph *pgRaaNPJpsi_vitev       = new TGraph(2*raaNPJpsi_vitev_vspt_numpoints);
  pgRaaNPJpsi_vitev->SetName("pgRaaNPJpsi_vitev");
  for (int i=0; i<raaNPJpsi_vitev_vspt_numpoints; i++) {
    pgRaaNPJpsi_vitev->SetPoint(i,raaNPJpsi_vitev_pt[i],raaNPJpsi_vitev_vspt_yhigh[i]);
    pgRaaNPJpsi_vitev->SetPoint(raaNPJpsi_vitev_vspt_numpoints+i,
        raaNPJpsi_vitev_pt[raaNPJpsi_vitev_vspt_numpoints-i-1],raaNPJpsi_vitev_vspt_ylow[raaNPJpsi_vitev_vspt_numpoints-i-1]);
  }

  TGraph *pgRaaNPJpsi_vitev_noDissoc = new TGraph(2*raaNPJpsi_vitev_vspt_noDissoc_numpoints);
  pgRaaNPJpsi_vitev_noDissoc->SetName("pgRaaNPJpsi_vitev_noDissoc");
  for (int i=0; i<raaNPJpsi_vitev_vspt_noDissoc_numpoints; i++) {
    pgRaaNPJpsi_vitev_noDissoc->SetPoint(i,raaNPJpsi_vitev_noDissoc_pt[i],raaNPJpsi_vitev_vspt_noDissoc_yhigh[i]);
    pgRaaNPJpsi_vitev_noDissoc->SetPoint(raaNPJpsi_vitev_vspt_noDissoc_numpoints+i,
        raaNPJpsi_vitev_noDissoc_pt[raaNPJpsi_vitev_vspt_noDissoc_numpoints-i-1],raaNPJpsi_vitev_vspt_noDissoc_ylow[raaNPJpsi_vitev_vspt_noDissoc_numpoints-i-1]);
  }

  // *********** Theory curves with line
  TGraph *pgRaaNPJpsi_mcatshq     = new TGraph(raaNPJpsi_mcatshq_vspt_numpoints,raaNPJpsi_mcatshq_pt,raaNPJpsi_mcatshq_vspt);
  pgRaaNPJpsi_mcatshq->SetName("pgRaaNPJpsi_mcatshq");
  TGraph *pgRaaNPJpsi_mcatshq_rad = new TGraph(raaNPJpsi_mcatshq_rad_vspt_numpoints,raaNPJpsi_mcatshq_rad_pt,raaNPJpsi_mcatshq_rad_vspt);
  pgRaaNPJpsi_mcatshq_rad->SetName("pgRaaNPJpsi_mcatshq_rad");
  TGraph *pgRaaNPJpsi_bamps       = new TGraph(raaNPJpsi_bamps_vspt_numpoints,raaNPJpsi_bamps_pt,raaNPJpsi_bamps_vspt_yval);
  pgRaaNPJpsi_bamps->SetName("pgRaaNPJpsi_bamps");

  // Style for filled graphs
  pgRaaB_rapp->SetFillColor(kRed-7);
  pgRaaB_rapp->SetFillStyle(1001);
  pgRaaB_whdg->SetFillColor(kOrange);
  pgRaaB_whdg->SetFillStyle(1001);

  pgRaaNPJpsi_vitev->SetFillColor(kAzure+1);
  pgRaaNPJpsi_vitev->SetFillStyle(1001);
  pgRaaNPJpsi_vitev_noDissoc->SetFillColor(kAzure-9);
  pgRaaNPJpsi_vitev_noDissoc->SetFillStyle(1001);

  // Style for line graphs
  pgRaaNPJpsi_mcatshq->SetLineColor(kTeal+4);
  pgRaaNPJpsi_mcatshq_rad->SetLineColor(kTeal+3);
  pgRaaNPJpsi_bamps->SetLineColor(kRed+1);
  
//  pgRaaNPJpsi_mcatshq->SetLineStyle(3);
//  pgRaaNPJpsi_mcatshq_rad->SetLineStyle(3);
//  pgRaaNPJpsi_bamps->SetLineStyle(3);
  
  pgRaaNPJpsi_mcatshq->SetLineWidth(4);
  pgRaaNPJpsi_mcatshq_rad->SetLineWidth(4);
  pgRaaNPJpsi_bamps->SetLineWidth(3);


  //---------------------------------------------------------
  TLine *line = new TLine(0.,1,30,1);
  line->SetLineStyle(1);
  line->SetLineWidth(1);

  TCanvas *pc = new TCanvas("pc","pc");

  TF1 *f4 = new TF1("f4","1",0,30);
  f4->SetLineWidth(1);
  f4->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f4->GetYaxis()->SetTitle("R_{AA}");
  f4->GetYaxis()->SetRangeUser(0.0,1.5);
  f4->GetXaxis()->CenterTitle(kTRUE);
 
  f4->Draw();
  lumi->Draw();
  pc->Update();
  
  pgCmsSyst->Draw("2"); // for drawing x-axis
  if(bDoBRaa)
  {
    pgRaaB_whdg->Draw("f");
  }
  pgRaaNPJpsi_vitev->Draw("f");
  pgRaaNPJpsi_vitev_noDissoc->Draw("f");
  if(bDoBRaa)
  {
    pgRaaB_rapp->Draw("f");
  }
  pgRaaNPJpsi_mcatshq->Draw("l");
  pgRaaNPJpsi_mcatshq_rad->Draw("l");
  pgRaaNPJpsi_bamps->Draw("l");

  pgCmsSyst->Draw("2");
  pgCmsP->Draw("P");
  pgCms->Draw("P");
  pgCmsSyst_lowpt->Draw("2");
  pgCmsP_lowpt->Draw("P");
  pgCms_lowpt->Draw("P");

  // additional info
  CMS_lumi(pc,12003000,0);

  TLegend *leg_cent = new TLegend(0.59,0.50,0.89,0.64,NULL,"brNDC");
//  TLegend *leg_cent = new TLegend(0.29,0.81,0.83,0.89,NULL,"brNDC"); // at top center
  leg_cent->SetMargin(0.17);
  leg_cent->SetBorderSize(0);
  leg_cent->SetTextFont(132);
  leg_cent->SetTextSize(0.03);
  leg_cent->SetLineColor(1);
  leg_cent->SetLineStyle(1);
  leg_cent->SetLineWidth(1);
  leg_cent->SetFillColor(19);
  leg_cent->SetFillStyle(0);

  TLegendEntry *entry_cent;
  entry_cent=leg_cent->AddEntry("raab","Nonprompt J/#psi","");
  entry_cent->SetTextFont(132);
  entry_cent->SetTextSize(ltxSetTextSize3);
  entry_cent=leg_cent->AddEntry("gNonPrJpsi_pt365y1624", "1.6 < |y| < 2.4","p");
//  entry_cent->SetTextColor(kViolet+2);
  entry_cent->SetTextFont(42);
  entry_cent->SetTextSize(entrySize);
  entry_cent=leg_cent->AddEntry("gNonPrJpsi", "|y| < 2.4","p");
//  entry_cent->SetTextColor(kOrange+2);
  entry_cent->SetTextFont(42);
  entry_cent->SetTextSize(entrySize);

  TLegend *leg_theory_cent = new TLegend(0.285,0.681,0.83,0.881,NULL,"brNDC");
//  TLegend *leg_theory_cent = new TLegend(0.29,0.61,0.83,0.81,NULL,"brNDC");
  leg_theory_cent->SetMargin(0.1);
  leg_theory_cent->SetBorderSize(0);
  leg_theory_cent->SetTextFont(62);
  leg_theory_cent->SetTextSize(0.027);
  leg_theory_cent->SetLineColor(1);
  leg_theory_cent->SetLineStyle(1);
  leg_theory_cent->SetLineWidth(1);
  leg_theory_cent->SetFillColor(10);
  leg_theory_cent->SetFillStyle(1001);
  
  TLegendEntry *entry_theory_cent;
  entry_theory_cent=leg_theory_cent->AddEntry("pgRaaNPJpsi_mcatshq_rad","MC@sHQ+EPOS+rad+LPM: standard (0-100%, |y| < 1)","l");
  entry_theory_cent->SetTextFont(42);
  entry_theory_cent=leg_theory_cent->AddEntry("pgRaaNPJpsi_mcatshq","MC@sHQ+EPOS: standard (0-100%, |y| < 1)","l");
  entry_theory_cent->SetTextFont(42);
  entry_theory_cent=leg_theory_cent->AddEntry("pgRaaNPJpsi_bamps","BAMPS: b=5 fm (|y| < 2.4)","l");
  entry_theory_cent->SetTextFont(42);
  entry_theory_cent=leg_theory_cent->AddEntry("pgRaaNPJpsi_vitev","Vitev: Rad E loss+CNM+Dissoc (0-10%, y~0)","f");
  entry_theory_cent->SetTextFont(42);
  entry_theory_cent=leg_theory_cent->AddEntry("pgRaaNPJpsi_vitev_noDissoc","Vitev: Rad E loss+CNM (0-10%, y~0)","f");
  entry_theory_cent->SetTextFont(42);
  if(bDoBRaa)
  {
    entry_theory_cent=leg_theory_cent->AddEntry("pgRaaB_rapp","He,Fries,Rapp: HF transport (0-90%, y~0)","f");
    entry_theory_cent->SetTextFont(42);
    entry_theory_cent=leg_theory_cent->AddEntry("pgRaaB_whdg","WHDG: Rad+Coll E loss (0-80%, y~0)","f");
    entry_theory_cent->SetTextFont(42);
  }

  TLatex *lat = new TLatex();
  lat->SetNDC();
  lat->SetTextFont(42);
  lat->SetTextSize(ltxSetTextSize2);
  lat->DrawLatex(0.2,0.17,"Cent. 0-100%");

  line->Draw();
  leg_cent->Draw();
  leg_theory_cent->Draw();
  gPad->RedrawAxis();
  if(bSavePlots)
  {
    pc->SaveAs(Form("figs/pdf/raaTheoryOpen_pt_withB%d.pdf",bDoBRaa));
    pc->SaveAs(Form("figs/png/raaTheoryOpen_pt_withB%d.png",bDoBRaa));
  }
}
void makeV2_DataOnly_Cen(const int flag=0)
{
  gROOT->Reset();
  const Double_t MassD = 1.865;
  const Double_t MassKs = 0.498;
  const Double_t MassPhi = 1.019;
  const Double_t MassLa = 1.1156;
  const Double_t MassXi = 1.3217;
  const Double_t MassOmega = 1.672;

  ifstream inData;
  // new data
  TFile *fin = new TFile("Systematics_D0vn_SL16d_2016-10-14.ME.root");
  TGraphErrors *gr_data_0_80 = (TGraphErrors *)(fin->Get("vnStat_0_80"));
  gr_data_0_80->RemovePoint(0);
  TGraphErrors *gr_data_0_80_sys = (TGraphErrors *)(fin->Get("vnSyst_0_80"));
  gr_data_0_80_sys->RemovePoint(0);

  cout << gr_data_0_80->GetN() << endl;
  cout << gr_data_0_80_sys->GetN() << endl;
  
  const Double_t scale_w_Ks = 1.0;
  const Int_t n_data_new = 8;
  //////////////////////////////////////////////
  // Read-in data points for 0-80% centrality
  //////////////////////////////////////////////
  Double_t nonflow[n_data_new] = { 0.032629 , 0.0336555 , 0.0336555 , 0.033947 , 0.0346236 , 0.0353009 , 0.0361988 , 0.0382869};  // full range 0-80%
  Double_t x_data_new[n_data_new], y_data_new[n_data_new], ye_data_new[n_data_new], yes_data_new[n_data_new], yesL_data_new[n_data_new];
  Double_t yeL_data_new[n_data_new], yeU_data_new[n_data_new];
  Double_t x_mTScaled_data_new[n_data_new], yScaled_data_new[n_data_new], yeScaled_data_new[n_data_new], yesScaled_data_new[n_data_new], yesLScaled_data_new[n_data_new];
  Double_t yeLScaled_data_new[n_data_new], yeUScaled_data_new[n_data_new];
  for(int i=0;i<gr_data_0_80->GetN();i++) {
    cout << i << endl;
    x_data_new[i] = gr_data_0_80->GetX()[i];
    y_data_new[i] = gr_data_0_80->GetY()[i];
    ye_data_new[i] = gr_data_0_80->GetEY()[i];
    yes_data_new[i] = gr_data_0_80_sys->GetEY()[i];
    yesL_data_new[i] = nonflow[i];

    x_mTScaled_data_new[i] = (sqrt(x_data_new[i]*x_data_new[i] + MassD*MassD) - MassD)/2;
    yScaled_data_new[i] = y_data_new[i]/2 * scale_w_Ks;
    yeScaled_data_new[i] = ye_data_new[i]/2 * scale_w_Ks;
    yesScaled_data_new[i] = yes_data_new[i]/2 * scale_w_Ks;
    yesLScaled_data_new[i] = yesL_data_new[i]/2 * scale_w_Ks;
  
    yeL_data_new[i] = sqrt(ye_data_new[i]**2+yes_data_new[i]**2+yesL_data_new[i]**2) * scale_w_Ks;
    yeU_data_new[i] = sqrt(ye_data_new[i]**2+yes_data_new[i]**2) * scale_w_Ks;

    yeLScaled_data_new[i] = yeL_data_new[i]/2 * scale_w_Ks;
    yeUScaled_data_new[i] = yeU_data_new[i]/2 * scale_w_Ks;
  }

  //////////////////////////////
  // different centrality bins
  //////////////////////////////
  const Int_t NCen = 3;
  TGraphErrors *gr_data_cen[NCen];
  TGraphErrors *gr_data_cen_sys[NCen];
  TGraphErrors *gr_data_mT_cen[NCen];
  const Char_t *CenName[NCen] = {"40_80","10_40","0_10"};
  for(int i=0;i<NCen;i++) {
    gr_data_cen[i] = (TGraphErrors *)(fin->Get(Form("vnStat_%s",CenName[i])));
    gr_data_cen[i]->RemovePoint(0);
    gr_data_cen_sys[i] = (TGraphErrors *)(fin->Get(Form("vnSyst_%s",CenName[i])));
    gr_data_cen_sys[i]->RemovePoint(0);
  }

  const Int_t n_data_cen = 8;
  Double_t nonflow_cen[NCen][n_data_cen] = {{ 0.115456 , 0.118967 , 0.118967 , 0.120065 , 0.122454 , 0.124808 , 0.128025 , 0.135539},
					    { 0.0210766 , 0.0217398 , 0.0217398 , 0.0219309 , 0.0223667 , 0.0228055 , 0.0233849 , 0.0247439},
					    { 0.0202398 , 0.0208774 , 0.0208774 , 0.0210541 , 0.0214741 , 0.021893 , 0.0224473 , 0.0237127}};

  Double_t x_data_cen[NCen][n_data_cen], y_data_cen[NCen][n_data_cen], ye_data_cen[NCen][n_data_cen], yes_data_cen[NCen][n_data_cen], yesL_data_cen[NCen][n_data_cen];
  Double_t yeL_data_cen[NCen][n_data_cen], yeU_data_cen[NCen][n_data_cen];
  Double_t x_mTScaled_data_cen[NCen][n_data_cen], yScaled_data_cen[NCen][n_data_cen], yeScaled_data_cen[NCen][n_data_cen], yesScaled_data_cen[NCen][n_data_cen], yesLScaled_data_cen[NCen][n_data_cen];
  Double_t yeLScaled_data_cen[NCen][n_data_cen], yeUScaled_data_cen[NCen][n_data_cen];
  for(int ic=0;ic<NCen;ic++) {
    for(int i=0;i<gr_data_cen[ic]->GetN();i++) {
      x_data_cen[ic][i] = gr_data_cen[ic]->GetX()[i];
      y_data_cen[ic][i] = gr_data_cen[ic]->GetY()[i];
      ye_data_cen[ic][i] = gr_data_cen[ic]->GetEY()[i];
      yes_data_cen[ic][i] = gr_data_cen_sys[ic]->GetEY()[i];
      yesL_data_cen[ic][i] = nonflow_cen[ic][i];
      
      x_mTScaled_data_cen[ic][i] = (sqrt(x_data_cen[ic][i]*x_data_cen[ic][i] + MassD*MassD) - MassD)/2;
      yScaled_data_cen[ic][i] = y_data_cen[ic][i]/2 * scale_w_Ks;
      yeScaled_data_cen[ic][i] = ye_data_cen[ic][i]/2 * scale_w_Ks;
      yesScaled_data_cen[ic][i] = yes_data_cen[ic][i]/2 * scale_w_Ks;
      yesLScaled_data_cen[ic][i] = yesL_data_cen[ic][i]/2 * scale_w_Ks;
      
      yeL_data_cen[ic][i] = sqrt(ye_data_cen[ic][i]**2+yes_data_cen[ic][i]**2+yesL_data_cen[ic][i]**2) * scale_w_Ks;
      yeU_data_cen[ic][i] = sqrt(ye_data_cen[ic][i]**2+yes_data_cen[ic][i]**2) * scale_w_Ks;
      
      yeLScaled_data_cen[ic][i] = yeL_data_cen[ic][i]/2 * scale_w_Ks;
      yeUScaled_data_cen[ic][i] = yeU_data_cen[ic][i]/2 * scale_w_Ks;      
    }
    gr_data_mT_cen[ic] = new TGraphErrors(n_data_cen, x_mTScaled_data_cen[ic], yScaled_data_cen[ic], 0, yeScaled_data_cen[ic]);
  }

  cout << " Read-in D0 data done ..." << endl;
  
 /* const Int_t n_ks_cen = 19;
  const Int_t n_la_cen = 18;

  Double_t x_ks_cen[n_ks_cen], y_ks_cen[NCen][n_ks_cen], ye_ks_cen[NCen][n_ks_cen], yes_ks_cen[NCen][n_ks_cen];
  Double_t x_la_cen[n_la_cen], y_la_cen[NCen][n_la_cen], ye_la_cen[NCen][n_la_cen], yes_la_cen[NCen][n_la_cen];

  Double_t x_mTScaled_ks_cen[n_ks_cen], yScaled_ks_cen[NCen][n_ks_cen], yeScaled_ks_cen[NCen][n_ks_cen], yesScaled_ks_cen[NCen][n_ks_cen];
  Double_t x_mTScaled_la_cen[n_la_cen], yScaled_la_cen[NCen][n_la_cen], yeScaled_la_cen[NCen][n_la_cen], yesScaled_la_cen[NCen][n_la_cen];


  inData.open("Run14/ks_v2_cen_PRC77.txt");
  for(int i=0;i<n_ks_cen;i++) {
    double a, b, c;
    inData >> x_ks_cen[i] >> a >> b >> c >> y_ks_cen[0][i] >> ye_ks_cen[0][i] >> yes_ks_cen[0][i] >> y_ks_cen[1][i] >> ye_ks_cen[1][i] >> yes_ks_cen[1][i] >> y_ks_cen[2][i] >> ye_ks_cen[2][i] >> yes_ks_cen[2][i];

    x_mTScaled_ks_cen[i] = (sqrt(x_ks_cen[i]*x_ks_cen[i]+MassKs*MassKs)-MassKs)/2;
    for(int ic=0;ic<NCen;ic++) {
      yScaled_ks_cen[ic][i] = y_ks_cen[ic][i]/2.;
      yeScaled_ks_cen[ic][i] = ye_ks_cen[ic][i]/2.;
      yesScaled_ks_cen[ic][i] = yes_ks_cen[ic][i]/2.;
    }

  }
  inData.close();

  TGraphErrors *gr_ks_cen[NCen], *gr_ks_mT_cen[NCen];
  for(int ic=0;ic<NCen;ic++) {
    gr_ks_cen[ic] = new TGraphErrors(n_ks_cen, x_ks_cen, y_ks_cen[ic], 0, ye_ks_cen[ic]);
    gr_ks_mT_cen[ic] = new TGraphErrors(n_ks_cen, x_mTScaled_ks_cen, yScaled_ks_cen[ic], 0, yeScaled_ks_cen[ic]);
    //    gr_ks_mT_cen[ic]->Print();
  }
  cout << " Read-in Ks data points done ... " << endl;
  
  inData.open("Run14/lambda_v2_cen_PRC77.txt");
  for(int i=0;i<n_la_cen;i++) {
    double a, b, c;
    inData >> x_la_cen[i] >> a >> b >> c >> y_la_cen[0][i] >> ye_la_cen[0][i] >> yes_la_cen[0][i] >> y_la_cen[1][i] >> ye_la_cen[1][i] >> yes_la_cen[1][i] >> y_la_cen[2][i] >> ye_la_cen[2][i] >> yes_la_cen[2][i];

    x_mTScaled_la_cen[i] = (sqrt(x_la_cen[i]*x_la_cen[i]+MassLa*MassLa)-MassLa)/3;
    for(int ic=0;ic<NCen;ic++) {
      yScaled_la_cen[ic][i] = y_la_cen[ic][i]/3.;
      yeScaled_la_cen[ic][i] = ye_la_cen[ic][i]/3.;
      yesScaled_la_cen[ic][i] = yes_la_cen[ic][i]/3.;
    }

  }
  inData.close();
  TGraphErrors *gr_la_cen[NCen], *gr_la_mT_cen[NCen];
  for(int ic=0;ic<NCen;ic++) {
    gr_la_cen[ic] = new TGraphErrors(n_la_cen, x_la_cen, y_la_cen[ic], 0, ye_la_cen[ic]);
    gr_la_mT_cen[ic] = new TGraphErrors(n_la_cen, x_mTScaled_la_cen, yScaled_la_cen[ic], 0, yeScaled_la_cen[ic]);
  }
  cout << " Read-in Lambda data points done ... " << endl;
  
  // Xi data points, format is a bit different
  const Int_t n_xi_cenMax = 9;
  Int_t n_xi_cen[NCen];
  Double_t x_xi_cen[NCen][n_xi_cenMax], y_xi_cen[NCen][n_xi_cenMax], ye_xi_cen[NCen][n_xi_cenMax];
  Double_t x_mTScaled_xi_cen[NCen][n_xi_cenMax], yScaled_xi_cen[NCen][n_xi_cenMax], yeScaled_xi_cen[NCen][n_xi_cenMax];
  TGraphErrors *gr_xi_cen[NCen];
  TGraphErrors *gr_xi_mT_cen[NCen];
  for(int ic=0;ic<NCen;ic++) {
    gr_xi_cen[ic] = new TGraphErrors(Form("Run14/xi_v2_%s.txt",CenName[ic]),"%lg %lg %lg");

    n_xi_cen[ic] = gr_xi_cen[ic]->GetN();
    for(int i=0;i<gr_xi_cen[ic]->GetN();i++) {
      x_xi_cen[ic][i] = gr_xi_cen[ic]->GetX()[i];
      y_xi_cen[ic][i] = gr_xi_cen[ic]->GetY()[i];
      ye_xi_cen[ic][i] = gr_xi_cen[ic]->GetEY()[i];

      x_mTScaled_xi_cen[ic][i] = (sqrt(x_xi_cen[ic][i]*x_xi_cen[ic][i]+MassXi*MassXi)-MassXi)/3;
      yScaled_xi_cen[ic][i] = y_xi_cen[ic][i]/3.;
      yeScaled_xi_cen[ic][i] = ye_xi_cen[ic][i]/3.;      
    }
    
    gr_xi_mT_cen[ic] = new TGraphErrors(n_xi_cen[ic], x_mTScaled_xi_cen[ic], yScaled_xi_cen[ic], 0, yeScaled_xi_cen[ic]);
  }
  cout << " Read-in Xi data points done ... " << endl;

  const Int_t n_phi_cenMax = 7;
  Int_t n_phi_cen[NCen];
  Double_t x_phi_cen[NCen][n_phi_cenMax], y_phi_cen[NCen][n_phi_cenMax], ye_phi_cen[NCen][n_phi_cenMax], yes_phi_cen[NCen][n_phi_cenMax];
  Double_t x_mTScaled_phi_cen[NCen][n_phi_cenMax], yScaled_phi_cen[NCen][n_phi_cenMax], yeScaled_phi_cen[NCen][n_phi_cenMax], yesScaled_phi_cen[NCen][n_phi_cenMax];
  TGraphErrors *gr_phi_cen[NCen];
  TGraphErrors *gr_phi_mT_cen[NCen];
  const Char_t *CenName_Phi[NCen] = {"40_80","10_40","0_5"};
  for(int ic=0;ic<NCen;ic++) {
    gr_phi_cen[ic] = new TGraphErrors(Form("Run14/phi_v2_%s_PRC.txt",CenName_Phi[ic]),"%lg %lg %lg");

    n_phi_cen[ic] = gr_phi_cen[ic]->GetN();
    inData.open(Form("Run14/phi_v2_%s_PRC.txt",CenName_Phi[ic]));
    for(int i=0;i<gr_phi_cen[ic]->GetN();i++) {
      x_phi_cen[ic][i] = gr_phi_cen[ic]->GetX()[i];
      y_phi_cen[ic][i] = gr_phi_cen[ic]->GetY()[i];
      ye_phi_cen[ic][i] = gr_phi_cen[ic]->GetEY()[i];

      double a, b, c, d;
      inData >> a >> b >> c >> d;
      yes_phi_cen[ic][i] = d;

      x_mTScaled_phi_cen[ic][i] = (sqrt(x_phi_cen[ic][i]*x_phi_cen[ic][i]+MassPhi*MassPhi)-MassPhi)/2.;
      yScaled_phi_cen[ic][i] = y_phi_cen[ic][i]/2.;
      yeScaled_phi_cen[ic][i] = ye_phi_cen[ic][i]/2.;
      yesScaled_phi_cen[ic][i] = yes_phi_cen[ic][i]/2.;
    }
    
    gr_phi_mT_cen[ic] = new TGraphErrors(n_phi_cen[ic], x_mTScaled_phi_cen[ic], yScaled_phi_cen[ic], 0, yeScaled_phi_cen[ic]);
  }
  cout << " Read-in Phi data points done ... " << endl;*/
  
  

  TCanvas *c1 = new TCanvas("c1", "c1",0,0,1600,900);
  gStyle->SetOptFit(0);
  gStyle->SetOptStat(0);
  gStyle->SetEndErrorSize(0);
  gStyle->SetTitleBorderSize(0);
  c1->SetFillColor(10);
  c1->SetFillStyle(0);
  c1->SetBorderMode(0);
  c1->SetBorderSize(0);
  c1->SetFrameFillColor(10);
  c1->SetFrameFillStyle(0);
  c1->SetFrameBorderMode(0);
  
  /*TPad* p1 = new TPad("p1","p1",0.,0.5,1.0,1.0);
  p1->SetFillColor(10);
  p1->SetFillStyle(0);
  p1->SetBorderMode(0);
  p1->SetBorderSize(0);
  p1->SetFrameFillColor(10);
  p1->SetFrameFillStyle(0);
  p1->SetFrameBorderMode(0);
  //p1->SetLogy();
  p1->SetGridx(0);
  p1->SetGridy(0);
  p1->SetLeftMargin(0.16);
  p1->SetBottomMargin(0.15);
  p1->SetTopMargin(0.02);
  p1->SetRightMargin(0.02);
  p1->Draw();
  //p1->cd();*/
  
  double x1 = 0.0;
  double x2 = 6.8;
  double y1 = -0.05;
  double y2 = 0.38;
  TH1 *h0 = new TH1D("h0","",1,x1, x2);
  h0->SetMinimum(y1);
  h0->SetMaximum(y2);
  h0->GetXaxis()->SetNdivisions(208);
  h0->GetXaxis()->CenterTitle();
  h0->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  h0->GetXaxis()->SetTitleOffset(.9);
  h0->GetXaxis()->SetTitleSize(0.05);
  h0->GetXaxis()->SetLabelOffset(0.005);
  h0->GetXaxis()->SetLabelSize(0.04);
  h0->GetXaxis()->SetLabelFont(42);
  h0->GetXaxis()->SetTitleFont(42);
  h0->GetYaxis()->SetNdivisions(505);
  h0->GetYaxis()->CenterTitle();
  h0->GetYaxis()->SetTitle("Anisotropy Parameter, v_{2}");
  h0->GetYaxis()->SetTitleOffset(.9);
  h0->GetYaxis()->SetTitleSize(0.05);
  h0->GetYaxis()->SetLabelOffset(0.005);
  h0->GetYaxis()->SetLabelSize(0.04);
  h0->GetYaxis()->SetLabelFont(42);
  h0->GetYaxis()->SetTitleFont(42);
  h0->Draw("c");

  
  double pt[2] = {1.766, 4.459};
  double pt1Bin[1] = {1.866};
  double v2[2] = {0.08329931, 0.126231279};
  double eptLow[2] = {.766, .459};
  double eptHigh[2] = {2.234, 2.341};
  double eptSyst[2] = { 0.0, 0.0};
  double eptSyst1Bin[1] = { 0.0};
  double ev2Low[2] = { 0.00736501, 0.012241649};
  double ev2High[2] = { 0.00736501, 0.012241649};
  double ev2Syst[2] = {.0124948965, .02145931743 };
  
  
  TGraphAsymmErrors *AlexData = new TGraphAsymmErrors(2, pt, v2, eptLow, eptHigh, ev2Low, ev2High);
  
  AlexData->SetMarkerColor(2);
  AlexData->SetMarkerStyle(21);
  AlexData->SetMarkerSize(2);
  AlexData->SetLineColor(2);
  AlexData->SetLineWidth(3);
  
  TGraphErrors *AlexDataSyst = new TGraphErrors(2, pt, v2, eptSyst, ev2Syst);
  
  AlexDataSyst->SetMarkerColor(2);
  AlexDataSyst->SetMarkerStyle(21);
  AlexDataSyst->SetMarkerSize(1.1);
  AlexDataSyst->SetLineColor(2);
  AlexDataSyst->SetLineWidth(33);
  
  
  
  // 8 data points
   
 
  
  double weights[6] = {0.4034, .3058, .1696, .0778, .0316, .0119};

  double avgV2[1] = {0};
  double avgV2StatErrorSquared[1] = {0};
  double avgV2SystErrorSquared[1] = {0};
  double avgV2StatError[1] = {0};
  double avgV2SystError[1] = {0};
  
  for(int i = 0; i < 6; i++){

    cout << "V2: " << y_data_cen[1][i] << endl;
    
    avgV2[0] = avgV2[0] + (weights[i]*y_data_cen[1][i]);
    
    avgV2StatErrorSquared[0] = avgV2StatErrorSquared[0] + (weights[i]*weights[i])*(ye_data_cen[1][i]*ye_data_cen[1][i]);
    avgV2SystErrorSquared[0] = avgV2SystErrorSquared[0] + (weights[i]*weights[i])*(yes_data_cen[1][i]*yes_data_cen[1][i]);
    
  }
    
  avgV2StatError[0] = TMath::Sqrt(avgV2StatErrorSquared[0]);
  avgV2SystError[0] = TMath::Sqrt(avgV2SystErrorSquared[0]);
    
  TGraphErrors *AvgV2Data = new TGraphErrors(1, pt1Bin, avgV2, eptSyst1Bin, avgV2StatError);
  
  AvgV2Data->SetMarkerColor(4);
  AvgV2Data->SetMarkerStyle(22);
  AvgV2Data->SetMarkerSize(2.5);
  AvgV2Data->SetLineColor(4);
  //AvgV2Data->SetLineWidth(15);
  
  TGraphErrors *AvgV2DataSyst = new TGraphErrors(1, pt1Bin, avgV2, eptSyst1Bin, avgV2SystError);
  
  AvgV2DataSyst->SetMarkerColor(4);
  AvgV2DataSyst->SetMarkerStyle(22);
  AvgV2DataSyst->SetMarkerSize(2.5);
  AvgV2DataSyst->SetLineColor(4);
  AvgV2DataSyst->SetLineWidth(29);
  
  
  
  /*TH1 *hAlex1 = new TH1D("","", 7, 0, 6.8);
  hAlex1->SetMarkerStyle(20);
  hAlex1->SetMarkerColor(2);
  hAlex1->SetMarkerSize(1.5);
  //hAlex->SetBinContent(3, 0.0801251);
  //hAlex->SetBinError(3, 0.00244519);
  
  hAlex1->SetBinContent(1, 0.122872);
  hAlex1->SetBinError(1, 0.0149516);
  
 // hAlex1->SetBinContent(5, 0.0789727);
  //hAlex1->SetBinError(5, 0.00444987);
  
  TH1 *hAlex2 = new TH1D("","", 1, 1, 4);
  hAlex2->SetMarkerStyle(20);
  hAlex2->SetMarkerColor(2);
  hAlex2->SetMarkerSize(1.5);
  hAlex2->SetBinContent(1, 0.0801251);
  hAlex2->SetBinError(1, 0.00244519);
  
  TH1 *hAlex3 = new TH1D("","", 1, 4, 6.8);
  hAlex3->SetMarkerStyle(20);
  hAlex3->SetMarkerColor(2);
  hAlex3->SetMarkerSize(1.5);
  hAlex3->SetBinContent(1, 0.0789727);
  hAlex3->SetBinError(1, 0.00444987);
  //////////////////////////////////////////////////////////////////
  TH1 *hAlex1Syst = new TH1D("","", 7, 0, 6.8);
  hAlex1Syst->SetMarkerStyle(20);
  hAlex1Syst->SetMarkerColor(2);
  hAlex1Syst->SetMarkerSize(1.5);
  //hAlex1Syst->SetEndErrorSize(2);
  hAlex1Syst->SetBinContent(1, 0.122872);
  hAlex1Syst->SetBinError(1, 0.02);
  
 
  TH1 *hAlex2Syst = new TH1D("","", 1, 1, 4);
  hAlex2Syst->SetMarkerStyle(20);
  hAlex2Syst->SetMarkerColor(2);
  hAlex2Syst->SetMarkerSize(1.5);
  hAlex2Syst->SetBinContent(1, 0.0801251);
  hAlex2Syst->SetBinError(1, 0.006172166);
  
  TH1 *hAlex3Syst = new TH1D("","", 1, 4, 6.8);
  hAlex3Syst->SetMarkerStyle(20);
  hAlex3Syst->SetMarkerColor(2);
  hAlex3Syst->SetMarkerSize(1.5);
  hAlex3Syst->SetBinContent(1, 0.0789727);
  hAlex3Syst->SetBinError(1, 0.004869332);*/
  
 
  
  /*TLine *l1 = new TLine(x1,y1,x2,y1);
  l1->SetLineWidth(2);
  l1->Draw("same");
  TLine *l2 = new TLine(x1,y2,x2,y2);
  l2->SetLineWidth(2);
  l2->Draw("same");
  TLine *l3 = new TLine(x1,y1,x1,y2);
  l3->SetLineWidth(2);
  l3->Draw("same");
  TLine *l4 = new TLine(x2,y1,x2,y2);
  l4->SetLineWidth(2);
  l4->Draw("same");

  TLine *l0 = new TLine(x1, 0, x2, 0);
  l0->SetLineWidth(2);
  l0->SetLineStyle(2);
  l0->Draw("same");*/

  /*for(int i=0;i<n_ks_cen;i++) {
    double x1 = x_ks_cen[i]-0.08;
    double x2 = x_ks_cen[i]+0.08;
    double y1 = y_ks_cen[1][i]-yes_ks_cen[1][i];
    double y2 = y_ks_cen[1][i]+yes_ks_cen[1][i];
    
    TLine *la = new TLine(x1, y1, x1, y1+0.003);
    la->Draw("same");
    TLine *lb = new TLine(x2, y1, x2, y1+0.003);
    lb->Draw("same");
    TLine *lc = new TLine(x1, y2, x1, y2-0.003);
    lc->Draw("same");
    TLine *ld = new TLine(x2, y2, x2, y2-0.003);
    ld->Draw("same");
    TLine *le = new TLine(x1, y1, x2, y1);
    le->SetLineWidth(2);
    le->Draw("same");
    TLine *lf = new TLine(x1, y2, x2, y2);
    lf->SetLineWidth(2);
    lf->Draw("same");
  }*/
  
  /*gr_ks_cen[1]->Print();
  gr_ks_cen[1]->SetMarkerStyle(25);
  gr_ks_cen[1]->SetMarkerColor(1);
  gr_ks_cen[1]->SetMarkerSize(1.2);
  gr_ks_cen[1]->SetLineColor(1);
  gr_ks_cen[1]->SetLineWidth(2);
  gr_ks_cen[1]->Draw("p");*/

  
 /* for(int i=0;i<n_la_cen;i++) {
    double x1 = x_la_cen[i]-0.08;
    double x2 = x_la_cen[i]+0.08;
    double y1 = y_la_cen[1][i]-yes_la_cen[1][i];
    double y2 = y_la_cen[1][i]+yes_la_cen[1][i];
    
    TLine *la = new TLine(x1, y1, x1, y1+0.003);
    la->Draw("same");
    TLine *lb = new TLine(x2, y1, x2, y1+0.003);
    lb->Draw("same");
    TLine *lc = new TLine(x1, y2, x1, y2-0.003);
    lc->Draw("same");
    TLine *ld = new TLine(x2, y2, x2, y2-0.003);
    ld->Draw("same");
    TLine *le = new TLine(x1, y1, x2, y1);
    le->SetLineWidth(2);
    le->Draw("same");
    TLine *lf = new TLine(x1, y2, x2, y2);
    lf->SetLineWidth(2);
    lf->Draw("same");
  }
  
  gr_la_cen[1]->Print();
  gr_la_cen[1]->SetMarkerStyle(24);
  gr_la_cen[1]->SetMarkerColor(1);
  gr_la_cen[1]->SetMarkerSize(1.2);
  gr_la_cen[1]->SetLineColor(1);
  gr_la_cen[1]->SetLineWidth(2);
  gr_la_cen[1]->Draw("p");


  gr_xi_cen[1]->Print();
  gr_xi_cen[1]->SetMarkerStyle(26);
  gr_xi_cen[1]->SetMarkerColor(1);
  gr_xi_cen[1]->SetMarkerSize(1.2);
  gr_xi_cen[1]->SetLineColor(1);
  gr_xi_cen[1]->SetLineWidth(2);
  gr_xi_cen[1]->Draw("p");
  
  gr_phi_cen[1]->Print();
  gr_phi_cen[1]->SetMarkerStyle(25);
  gr_phi_cen[1]->SetMarkerColor(1);
  gr_phi_cen[1]->SetMarkerSize(1.2);
  gr_phi_cen[1]->SetLineColor(1);
  gr_phi_cen[1]->SetLineWidth(2);
  //  gr_phi_cen[1]->Draw("p");*/

    for(int i=0;i<n_data_cen[1];i++) {
    double x1 = x_data_cen[1][i]-0.08;
    double x2 = x_data_cen[1][i]+0.08;
    double y1 = y_data_cen[1][i]-yes_data_cen[1][i];
    double y2 = y_data_cen[1][i]+yes_data_cen[1][i];

    double y3 = y_data_cen[1][i] - yesL_data_cen[1][i];
    double y4 = y_data_cen[1][i];
    TBox *box = new TBox(x1, y3, x2, y4);
    box->SetLineColor(16);
    box->SetFillColor(16);
    box->Draw("same");
    
    TLine *la = new TLine(x1, y1, x1, y1+0.003);
    la->SetLineColor(4);
    la->Draw("same");
    TLine *lb = new TLine(x2, y1, x2, y1+0.003);
    lb->SetLineColor(4);
    lb->Draw("same");
    TLine *lc = new TLine(x1, y2, x1, y2-0.003);
    lc->SetLineColor(4);
    lc->Draw("same");
    TLine *ld = new TLine(x2, y2, x2, y2-0.003);
    ld->SetLineColor(4);
    ld->Draw("same");
    TLine *le = new TLine(x1, y1, x2, y1);
    le->SetLineWidth(2);
    le->SetLineColor(4);
    le->Draw("same");
    TLine *lf = new TLine(x1, y2, x2, y2);
    lf->SetLineWidth(2);
    lf->SetLineColor(4);
    lf->Draw("same");
  }
   
   gr_data_cen[1]->SetMarkerStyle(20);
   //gr_data_cen[1]->SetMarkerColorAlpha(4, 0.35);
   gr_data_cen[1]->SetMarkerColor(4);
   
   gr_data_cen[1]->SetMarkerSize(1.5);
   gr_data_cen[1]->SetLineWidth(2);
   gr_data_cen[1]->SetLineColor(4);
   gr_data_cen[1]->Draw("p");
  
  /////MY DATA HERE////////////////////////
    for(int i = 0; i < 2; i++) {
        double x1 = pt[i]-0.08;
        double x2 = pt[i]+0.08;
        double y1 = v2[i]-ev2Syst[i];
        double y2 = v2[i]+ev2Syst[i];

   
    
        TLine *la = new TLine(x1, y1, x1, y1+0.003);
        la->SetLineColor(2);
        la->Draw("same");
        TLine *lb = new TLine(x2, y1, x2, y1+0.003);
        lb->SetLineColor(2);
        lb->Draw("same");
        TLine *lc = new TLine(x1, y2, x1, y2-0.003);
        lc->SetLineColor(2);
        lc->Draw("same");
        TLine *ld = new TLine(x2, y2, x2, y2-0.003);
        ld->SetLineColor(2);
        ld->Draw("same");
        TLine *le = new TLine(x1, y1, x2, y1);
        le->SetLineWidth(2);
        le->SetLineColor(2);
        le->Draw("same");
        TLine *lf = new TLine(x1, y2, x2, y2);
        lf->SetLineWidth(2);
        lf->SetLineColor(2);
        lf->Draw("same");
    }
  

  //TLatex *tex = new TLatex(5.5, 0.28, "10-40%");
  //tex->SetTextFont(42);
  //tex->SetTextSize(0.055);
  //tex->Draw();
  
  TLegend *leg = new TLegend(0.1, 0.72, 0.55, 0.9);
  leg->SetFillStyle(0);
  leg->SetLineStyle(4000);
  leg->SetLineColor(10);
  //leg->SetLineWidth(1.0);
  leg->SetBorderSize(0.0);
  leg->SetTextSize(0.045);
  leg->AddEntry(gr_data_cen[1], "D^{0} Event Plane, 10-40% ", "p");
  leg->AddEntry(AlexData, "D^{0}-Hadron Angular Corr, 20-50%", "p");
  //leg->AddEntry(AvgV2Data, "D^{0} Event Plane Avg. of 1 GeV/c < p_{t} < 4 GeV/c", "p");
  //leg->AddEntry(gr_xi_cen[1], "#Xi^{-}", "p");
  //leg->AddEntry(gr_la_cen[1], "#Lambda", "p");
  //leg->AddEntry(gr_ks_cen[1], "K_{S}", "p");
  //  leg->AddEntry(gr_phi_cen[1], "#phi", "p");
  leg->Draw();
  
  AlexData->Draw("SAME P");
  //AlexDataSyst->Draw("SAME []");
  //AvgV2Data->Draw("SAME P");
  //AvgV2DataSyst->Draw("SAME []");
  
  TString starPrelim = "STAR Preliminary";
  
  TPaveText *starPrelimTextBox = new TPaveText(0.7, 0.7, .8, .77, "NB NDC");
  starPrelimTextBox->SetFillColor(0);
  starPrelimTextBox->AddText(starPrelim);
  starPrelimTextBox->GetLine(0)->SetTextSize(.055);
  starPrelimTextBox->GetLine(0)->SetTextColor(2);
  starPrelimTextBox->Draw("SAME");

  TLatex *tex = new TLatex(4.2, 0.345, "STAR  Au+Au @ 200 GeV");
  tex->SetTextFont(42);
  tex->SetTextSize(0.05);
  tex->Draw();
  //hAlex2->Draw("SAME");
  //hAlex3->Draw("SAME");
  //hAlex1Syst->Draw("SAME E1");
  //hAlex2Syst->Draw("SAME E1");
  //hAlex3Syst->Draw("SAME E1");
  
 // tex = new TLatex(0.2, 0.34, "a)");
  //tex->SetTextFont(42);
  //tex->SetTextSize(0.065);
  //tex->Draw();

  //p1->Modified();
  //c1->Update();
  //c1->cd();

  /*TPad* p2 = new TPad("p2","",0.,0.,1.0,0.5);
  p2->SetFillColor(10);
  p2->SetFillStyle(0);
  p2->SetBorderMode(0);
  p2->SetBorderSize(0);
  p2->SetFrameFillColor(10);
  p2->SetFrameFillStyle(0);
  p2->SetFrameBorderMode(0);
  //p2->SetLogy();
  p2->SetGridx(0);
  p2->SetGridy(0);
  p2->SetLeftMargin(0.16);
  p2->SetBottomMargin(0.18);
  p2->SetTopMargin(0.01);
  p2->SetRightMargin(0.02);
  p2->Draw();
  p2->cd();*/

 /* double x1 = 0.;
  double x2 = 2.8;
  double y1 = -0.025;
  double y2 = 0.18;
  TH1 *h0 = new TH1D("h0","",1,x1, x2);
  h0->SetMinimum(y1);
  h0->SetMaximum(y2);
  h0->GetXaxis()->SetNdivisions(208);
  h0->GetXaxis()->CenterTitle();
  h0->GetXaxis()->SetTitle("(m_{T} - m_{0}) / n_{q} (GeV/c^{ 2})");
  h0->GetXaxis()->SetTitleOffset(1.1);
  h0->GetXaxis()->SetTitleSize(0.065);
  h0->GetXaxis()->SetLabelOffset(0.01);
  h0->GetXaxis()->SetLabelSize(0.055);
  h0->GetXaxis()->SetLabelFont(42);
  h0->GetXaxis()->SetTitleFont(42);
  h0->GetYaxis()->SetNdivisions(505);
  h0->GetYaxis()->CenterTitle();
  h0->GetYaxis()->SetTitle("Anisotropy Parameter, v_{2} / n_{q}");
  h0->GetYaxis()->SetTitleOffset(1.1);
  h0->GetYaxis()->SetTitleSize(0.065);
  h0->GetYaxis()->SetLabelOffset(0.015);
  h0->GetYaxis()->SetLabelSize(0.055);
  h0->GetYaxis()->SetLabelFont(42);
  h0->GetYaxis()->SetTitleFont(42);
  h0->Draw("c");

  TLine *l1 = new TLine(x1,y1,x2,y1);
  l1->SetLineWidth(2);
  l1->Draw("same");
  TLine *l2 = new TLine(x1,y2,x2,y2);
  l2->SetLineWidth(2);
  l2->Draw("same");
  TLine *l3 = new TLine(x1,y1,x1,y2);
  l3->SetLineWidth(2);
  l3->Draw("same");
  TLine *l4 = new TLine(x2,y1,x2,y2);
  l4->SetLineWidth(2);
  l4->Draw("same");

  TLine *l0 = new TLine(x1, 0, x2, 0);
  l0->SetLineWidth(2);
  l0->SetLineStyle(2);
  l0->Draw("same");*/

  /*for(int i=0;i<n_ks_cen;i++) {
    double x1 = x_mTScaled_ks_cen[i]-0.04;
    double x2 = x_mTScaled_ks_cen[i]+0.04;
    double y1 = yScaled_ks_cen[1][i]-yesScaled_ks_cen[1][i];
    double y2 = yScaled_ks_cen[1][i]+yesScaled_ks_cen[1][i];
    
    TLine *la = new TLine(x1, y1, x1, y1+0.0015);
    la->Draw("same");
    TLine *lb = new TLine(x2, y1, x2, y1+0.0015);
    lb->Draw("same");
    TLine *lc = new TLine(x1, y2, x1, y2-0.0015);
    lc->Draw("same");
    TLine *ld = new TLine(x2, y2, x2, y2-0.0015);
    ld->Draw("same");
    TLine *le = new TLine(x1, y1, x2, y1);
    le->SetLineWidth(2);
    le->Draw("same");
    TLine *lf = new TLine(x1, y2, x2, y2);
    lf->SetLineWidth(2);
    lf->Draw("same");
  }
  
  gr_ks_mT_cen[1]->Print();
  gr_ks_mT_cen[1]->SetMarkerStyle(25);
  gr_ks_mT_cen[1]->SetMarkerColor(1);
  gr_ks_mT_cen[1]->SetMarkerSize(1.2);
  gr_ks_mT_cen[1]->SetLineColor(1);
  gr_ks_mT_cen[1]->SetLineWidth(2);
  gr_ks_mT_cen[1]->Draw("p");

  
  for(int i=0;i<n_la_cen;i++) {
    double x1 = x_mTScaled_la_cen[i]-0.04;
    double x2 = x_mTScaled_la_cen[i]+0.04;
    double y1 = yScaled_la_cen[1][i]-yesScaled_la_cen[1][i];
    double y2 = yScaled_la_cen[1][i]+yesScaled_la_cen[1][i];
    
    TLine *la = new TLine(x1, y1, x1, y1+0.0015);
    la->Draw("same");
    TLine *lb = new TLine(x2, y1, x2, y1+0.0015);
    lb->Draw("same");
    TLine *lc = new TLine(x1, y2, x1, y2-0.0015);
    lc->Draw("same");
    TLine *ld = new TLine(x2, y2, x2, y2-0.0015);
    ld->Draw("same");
    TLine *le = new TLine(x1, y1, x2, y1);
    le->SetLineWidth(2);
    le->Draw("same");
    TLine *lf = new TLine(x1, y2, x2, y2);
    lf->SetLineWidth(2);
    lf->Draw("same");
  }
  
  gr_la_mT_cen[1]->Print();
  gr_la_mT_cen[1]->SetMarkerStyle(24);
  gr_la_mT_cen[1]->SetMarkerColor(1);
  gr_la_mT_cen[1]->SetMarkerSize(1.2);
  gr_la_mT_cen[1]->SetLineColor(1);
  gr_la_mT_cen[1]->SetLineWidth(2);
  gr_la_mT_cen[1]->Draw("p");


  gr_xi_mT_cen[1]->Print();
  gr_xi_mT_cen[1]->SetMarkerStyle(26);
  gr_xi_mT_cen[1]->SetMarkerColor(1);
  gr_xi_mT_cen[1]->SetMarkerSize(1.2);
  gr_xi_mT_cen[1]->SetLineColor(1);
  gr_xi_mT_cen[1]->SetLineWidth(2);
  gr_xi_mT_cen[1]->Draw("p");
  
  gr_phi_mT_cen[1]->Print();
  gr_phi_mT_cen[1]->SetMarkerStyle(25);
  gr_phi_mT_cen[1]->SetMarkerColor(1);
  gr_phi_mT_cen[1]->SetMarkerSize(1.2);
  gr_phi_mT_cen[1]->SetLineColor(1);
  gr_phi_mT_cen[1]->SetLineWidth(2);
  //  gr_phi_mT_cen[1]->Draw("p");*/

/*  for(int i=0;i<n_data_cen[1];i++) {
    double x1 = x_mTScaled_data_cen[1][i]-0.04;
    double x2 = x_mTScaled_data_cen[1][i]+0.04;
    double y1 = yScaled_data_cen[1][i]-yesScaled_data_cen[1][i];
    double y2 = yScaled_data_cen[1][i]+yesScaled_data_cen[1][i];

    double y3 = yScaled_data_cen[1][i] - yesLScaled_data_cen[1][i];
    double y4 = yScaled_data_cen[1][i];
    TBox *box = new TBox(x1, y3, x2, y4);
    box->SetLineColor(16);
    box->SetFillColor(16);
    box->Draw("same");
    
    TLine *la = new TLine(x1, y1, x1, y1+0.0015);
    la->SetLineColor(4);
    la->Draw("same");
    TLine *lb = new TLine(x2, y1, x2, y1+0.0015);
    lb->SetLineColor(4);
    lb->Draw("same");
    TLine *lc = new TLine(x1, y2, x1, y2-0.0015);
    lc->SetLineColor(4);
    lc->Draw("same");
    TLine *ld = new TLine(x2, y2, x2, y2-0.0015);
    ld->SetLineColor(4);
    ld->Draw("same");
    TLine *le = new TLine(x1, y1, x2, y1);
    le->SetLineColor(4);
    le->SetLineWidth(2);
    le->Draw("same");
    TLine *lf = new TLine(x1, y2, x2, y2);
    lf->SetLineColor(4);
    lf->SetLineWidth(2);
    lf->Draw("same");
  }*/
   
   //gr_data_mT_cen[1]->SetMarkerStyle(20);
   //gr_data_mT_cen[1]->SetMarkerColor(4);
   //gr_data_mT_cen[1]->SetMarkerSize(1.5);
   //gr_data_mT_cen[1]->SetLineWidth(2);
   //gr_data_mT_cen[1]->SetLineColor(4);
   //gr_data_mT_cen[1]->Draw("p");
  
  
  //TLegend *leg = new TLegend(0.22, 0.66, 0.5, 0.96);
  //leg->SetFillStyle(0);
  //leg->SetLineStyle(4000);
  //leg->SetLineColor(-1);
  //leg->SetLineWidth(0);
  //leg->SetTextSize(0.06);
  //leg->AddEntry(gr_data_mT_cen[1], "D^{0}", "p");
  //leg->AddEntry(gr_xi_mT_cen[1], "#Xi^{-}", "p");
  //leg->AddEntry(gr_la_mT_cen[1], "#Lambda", "p");
  //leg->AddEntry(gr_ks_mT_cen[1], "K_{S}", "p");  
  //  leg->AddEntry(gr_phi_mT_cen[1], "#phi", "p");  
  //leg->Draw();

  //TLatex *tex = new TLatex(1.2, 0.155, "STAR  Au+Au @ 200 GeV");
 // tex->SetTextFont(42);
  //tex->SetTextSize(0.065);
  //tex->Draw();

  //TLatex *tex = new TLatex(2.27, 0.13, "10-40%");
  //tex->SetTextFont(42);
  //tex->SetTextSize(0.065);
  //tex->Draw();


  //tex = new TLatex(0.08, 0.155, "b)");
  //tex->SetTextFont(42);
  //tex->SetTextSize(0.065);
  //tex->Draw();

  //p2->Modified();
  //c1->Update();
  //c1->cd();

  //c1->SaveAs("v2CompareWithData.eps");
  c1->SaveAs("v2_plot.png");

}