void makePlots_hlt_eventbyevent_comparison( std::string inputFile_="input.root", std::string target_label_="Target", std::string outputSuffix_="_out" ) {

  TFile *file = new TFile(inputFile_.c_str());

  std::string dirprefix = "Images" + outputSuffix_;
  struct stat st;
  if( stat(dirprefix.c_str(),&st) != 0 )  mkdir(dirprefix.c_str(),0777);

  std::string label_ref = "Reference";
  std::string label_tgt = target_label_;

  TH1D* h_ref = (TH1D*)file->Get("eventbyevent/HLT_Ref");
  TH1D* h_tgt = (TH1D*)file->Get("eventbyevent/HLT_Tgt");
  TH1D* h_tgt_sep = (TH1D*)file->Get("eventbyevent/HLT_Tgt_sep");

  std::map<std::string, int> hlt_counts_per_path_ref_;
  std::map<std::string, int> hlt_counts_per_path_tgt_;
  std::map<double, std::string> hlt_counts_per_path_diff_;

  std::vector<std::string> hlt_common_paths;

  TAxis * axis = h_ref->GetXaxis();

  // loop over target paths
  for( int iPath=0; iPath<h_tgt_sep->GetNbinsX(); iPath++ ){
    std::string name(h_tgt_sep->GetXaxis()->GetBinLabel(iPath+1));
    
    int bin = axis->FindBin(name.c_str());

    if( bin<1 ) continue;

    double cnt_ref = h_ref->GetBinContent(bin);
    double cnt_tgt = h_tgt->GetBinContent(bin);

    int diff = int( cnt_ref - cnt_tgt );
    double rel_diff = double(diff);

    if( cnt_ref>0 )      rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_ref;
    else if( cnt_tgt>0 ) rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_tgt;
    else                 rel_diff = 0.;

    // printf("%s\t %d\t %d\t %d\t %.3f \n",
    // 	   name.c_str(), int(cnt_ref), int(cnt_tgt), diff, rel_diff ); 

    hlt_counts_per_path_ref_[name] = int(cnt_ref);
    hlt_counts_per_path_tgt_[name] = int(cnt_tgt);

    hlt_counts_per_path_diff_[rel_diff] = name;

    if( rel_diff>0.15 ) hlt_common_paths.push_back(name);
  }


  std::map<double, std::string>::reverse_iterator rit;
  for( rit=hlt_counts_per_path_diff_.rbegin(); rit!=hlt_counts_per_path_diff_.rend(); ++rit )
    std::cout << "path: " << rit->second << "\t" << rit->first << "\t" << hlt_counts_per_path_ref_[rit->second] << "\t" << hlt_counts_per_path_tgt_[rit->second] << std::endl;


  int numPaths = int( hlt_counts_per_path_ref_.size() );
  TH1D* h_hlt_ref = new TH1D("h_hlt_ref",";HLT path", numPaths, 0, numPaths );
  TH1D* h_hlt_tgt = new TH1D("h_hlt_tgt",";HLT path", numPaths, 0, numPaths );
  TH1D* h_hlt_diff = new TH1D("h_hlt_diff",";HLT path", numPaths, 0, numPaths );

  int iHLT=0;
  for( std::map<std::string, int>::iterator it=hlt_counts_per_path_ref_.begin(); it!=hlt_counts_per_path_ref_.end(); ++it ){
    iHLT++;
    std::string name = it->first;

    double cnt_ref = double(hlt_counts_per_path_ref_[name]);
    double cnt_tgt = double(hlt_counts_per_path_tgt_[name]);

    double rel_diff = 1.0;
    if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
    else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
    else                 rel_diff = 0.;

    h_hlt_ref->SetBinContent(iHLT,cnt_ref);
    h_hlt_tgt->SetBinContent(iHLT,cnt_tgt);
    h_hlt_diff->SetBinContent(iHLT,rel_diff);

    h_hlt_ref->GetXaxis()->SetBinLabel(iHLT,name.c_str());
    h_hlt_diff->GetXaxis()->SetBinLabel(iHLT,name.c_str());
  }


  h_hlt_ref->SetStats(0);

  h_hlt_ref->SetLineColor(kBlue);
  h_hlt_tgt->SetLineColor(kRed);

  if( true ){
    // TLegend *legend = new TLegend(0.255,0.78,0.92,0.89);
    TLegend *legend = new TLegend(0.255,0.92,0.92,0.99);

    legend->SetFillColor(kWhite);
    legend->SetLineColor(kWhite);
    legend->SetShadowColor(kWhite);
    legend->SetTextFont(42);
    legend->SetTextSize(0.035);

    legend->SetNColumns(2);

    legend->AddEntry(h_hlt_ref,label_ref.c_str(),"l");
    legend->AddEntry(h_hlt_tgt,label_tgt.c_str(),"l");


    //// Original
    // double ratioMin = -1.2;
    // double ratioMax = 1.2;
    double ratioMin = -0.6;
    double ratioMax = 0.6;

    //Hack to get it plotted with ratio plot
    TCanvas* myC = new TCanvas("myC", "myC", 1200,700);

    gStyle->SetPadBorderMode(0);
    gStyle->SetFrameBorderMode(0);
    Float_t small = 1.e-5;
    myC->Divide(1,2,small,small);
    const float padding=1e-5; const float ydivide=0.3;
    myC->GetPad(1)->SetPad( padding, ydivide + padding , 1-padding, 1-padding);
    myC->GetPad(2)->SetPad( padding, padding, 1-padding, ydivide-padding);
    myC->GetPad(1)->SetLeftMargin(.11);
    myC->GetPad(2)->SetLeftMargin(.11);
    myC->GetPad(1)->SetRightMargin(.05);
    myC->GetPad(2)->SetRightMargin(.05);
    myC->GetPad(1)->SetBottomMargin(.3);
    myC->GetPad(2)->SetBottomMargin(.3);
    myC->GetPad(1)->Modified();
    myC->GetPad(2)->Modified();
    myC->cd(1);
    gPad->SetBottomMargin(small);
    gPad->Modified();



    TH1D* myRatio = (TH1D*)h_hlt_diff->Clone("myRatio");

    myRatio->SetStats(0);
    myRatio->Sumw2();
    myRatio->SetLineColor(kBlack);
    myRatio->SetMarkerColor(kBlack);

    myRatio->SetMinimum(ratioMin);
    myRatio->SetMaximum(ratioMax);
    //myRatio->GetYaxis()->SetNdivisions(50000+404);
    myRatio->GetYaxis()->SetNdivisions(20000+505);
    myRatio->GetYaxis()->SetLabelSize(0.1); //make y label bigger
    myRatio->GetXaxis()->SetLabelSize(0.1); //make y label bigger
    myRatio->GetXaxis()->SetTitleOffset(1.1);
    myRatio->GetXaxis()->SetTitle(h_hlt_diff->GetXaxis()->GetTitle()); //make y label bigger
    myRatio->GetXaxis()->SetLabelSize(0.12);
    myRatio->GetXaxis()->SetLabelOffset(0.04);
    myRatio->GetXaxis()->SetTitleSize(0.12);
    // myRatio->GetYaxis()->SetTitle("Data/MC");
    myRatio->GetYaxis()->SetTitle("New - Old / Old");
    myRatio->GetYaxis()->SetTitleSize(0.1);
    myRatio->GetYaxis()->SetTitleOffset(.45);
    myC->cd(2);
    gPad->SetTopMargin(small);
    gPad->SetTickx();
    gPad->Modified();

    myC->cd(1);

    h_hlt_ref->GetYaxis()->SetTitle("Number of Events");
    h_hlt_ref->GetYaxis()->SetTitleSize(0.05);
    h_hlt_ref->GetYaxis()->SetTitleOffset(.95);

    h_hlt_ref->Draw();
    h_hlt_tgt->Draw("same");

    legend->Draw();

    double xmin = h_hlt_ref->GetBinLowEdge(1);
    double xmax = h_hlt_ref->GetBinLowEdge(h_hlt_ref->GetNbinsX()) + h_hlt_ref->GetBinWidth(h_hlt_ref->GetNbinsX());

    myC->cd(2);

    myRatio->SetLineWidth(2);

    myRatio->Draw("hist");

    TLine* myLine;
    myLine = new TLine(xmin, 0, xmax, 0);
    myLine->Draw();

    std::string outputFile = dirprefix + "/hlt_path_comparison" + outputSuffix_ + ".pdf";
    myC->Print(outputFile.c_str());

    delete legend;
    delete myC;
    delete myLine;
  }


  if( true ){
    int numCommonPaths = int(hlt_common_paths.size());

    for( int iPath=0; iPath<numCommonPaths; iPath++ ){
      std::cout << " ====================== " << std::endl;
      std::string name = hlt_common_paths[iPath];
      std::string pathName_ref = "eventbyevent/h_path_ref_" + name;
      std::string pathName_tgt = "eventbyevent/h_path_tgt_" + name;

      std::string diffname = "h_path_diff_" + name;

      //std::cout << " path is " << pathName_ref << std::endl;

      if( name=="HLT_LogMonitor" ) continue;

      TH1D* h_hlt_filt_ref = (TH1D*)file->Get(pathName_ref.c_str());
      TH1D* h_hlt_filt_tgt = (TH1D*)file->Get(pathName_tgt.c_str());
      TH1D* h_hlt_filt_diff = (TH1D*)h_hlt_filt_ref->Clone(diffname.c_str());

      bool printOut = true;
      for( int iBin=0; iBin<h_hlt_filt_tgt->GetNbinsX(); iBin++ ){
	double cnt_ref = h_hlt_filt_ref->GetBinContent(iBin+1);
	double cnt_tgt = h_hlt_filt_tgt->GetBinContent(iBin+1);

	double rel_diff = 1.0;
	if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
	else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
	else                 rel_diff = 0.;

	h_hlt_filt_diff->SetBinContent(iBin+1,rel_diff);

	//if( fabs(rel_diff)>0.0002 ) printOut = true;
      }

      if( printOut ){
	double cnt_ref = double(hlt_counts_per_path_ref_[name]);
	double cnt_tgt = double(hlt_counts_per_path_tgt_[name]);

	double rel_diff = 1.0;
	if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
	else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
	else                 rel_diff = 0.;

	printf("%s: relative difference = %.3f,\t reference = %d,\t target = %d \n",
	       name.c_str(), rel_diff, hlt_counts_per_path_ref_[name], hlt_counts_per_path_tgt_[name]);

	for( int iBin=0; iBin<h_hlt_filt_tgt->GetNbinsX(); iBin++ ){
	  double my_cnt_ref = h_hlt_filt_ref->GetBinContent(iBin+1);
	  double my_cnt_tgt = h_hlt_filt_tgt->GetBinContent(iBin+1);

	  double my_rel_diff = 1.0;
	  if( my_cnt_ref>0 )      my_rel_diff = (my_cnt_tgt - my_cnt_ref)/my_cnt_ref;
	  else if( my_cnt_tgt>0 ) my_rel_diff = (my_cnt_tgt - my_cnt_ref)/my_cnt_tgt;
	  else                   my_rel_diff = 0.;

	  printf("\t %s \t %.3f \t %.0f \t %.0f \n",
		 h_hlt_filt_ref->GetXaxis()->GetBinLabel(iBin+1), my_rel_diff, my_cnt_ref, my_cnt_tgt);
	}
      }

      h_hlt_filt_ref->SetStats(0);

      h_hlt_filt_ref->SetLineColor(kBlue);
      h_hlt_filt_tgt->SetLineColor(kRed);

      //TLegend *legend = new TLegend(0.255,0.78,0.92,0.89);
      TLegend *legend = new TLegend(0.255,0.92,0.92,0.99);

      legend->SetFillColor(kWhite);
      legend->SetLineColor(kWhite);
      legend->SetShadowColor(kWhite);
      legend->SetTextFont(42);
      legend->SetTextSize(0.035);

      legend->SetNColumns(2);

      legend->AddEntry(h_hlt_filt_ref,label_ref.c_str(),"l");
      legend->AddEntry(h_hlt_filt_tgt,label_tgt.c_str(),"l");


      double ratioMin = -1.2;
      double ratioMax = 1.2;

      //Hack to get it plotted with ratio plot
      TCanvas* myC = new TCanvas("myC", "myC", 600,700);

      gStyle->SetPadBorderMode(0);
      gStyle->SetFrameBorderMode(0);
      Float_t small = 1.e-5;
      myC->Divide(1,2,small,small);
      const float padding=1e-5; const float ydivide=0.3;
      myC->GetPad(1)->SetPad( padding, ydivide + padding , 1-padding, 1-padding);
      myC->GetPad(2)->SetPad( padding, padding, 1-padding, ydivide-padding);
      myC->GetPad(1)->SetLeftMargin(.11);
      myC->GetPad(2)->SetLeftMargin(.11);
      myC->GetPad(1)->SetRightMargin(.05);
      myC->GetPad(2)->SetRightMargin(.05);
      myC->GetPad(1)->SetBottomMargin(.3);
      myC->GetPad(2)->SetBottomMargin(.3);
      myC->GetPad(1)->Modified();
      myC->GetPad(2)->Modified();
      myC->cd(1);
      gPad->SetBottomMargin(small);
      gPad->Modified();



      TH1D* myRatio = (TH1D*)h_hlt_filt_diff->Clone();

      myRatio->SetStats(0);
      myRatio->Sumw2();
      myRatio->SetLineColor(kBlack);
      myRatio->SetMarkerColor(kBlack);

      myRatio->SetMinimum(ratioMin);
      myRatio->SetMaximum(ratioMax);
      myRatio->GetYaxis()->SetNdivisions(50000+404);
      myRatio->GetYaxis()->SetLabelSize(0.1); //make y label bigger
      myRatio->GetXaxis()->SetLabelSize(0.1); //make y label bigger
      myRatio->GetXaxis()->SetTitleOffset(1.1);
      myRatio->GetXaxis()->SetTitle(h_hlt_diff->GetXaxis()->GetTitle()); //make y label bigger
      myRatio->GetXaxis()->SetLabelSize(0.12);
      myRatio->GetXaxis()->SetLabelOffset(0.04);
      myRatio->GetXaxis()->SetTitleSize(0.12);
      // myRatio->GetYaxis()->SetTitle("Data/MC");
      myRatio->GetYaxis()->SetTitle("New - Old / Old");
      myRatio->GetYaxis()->SetTitleSize(0.1);
      myRatio->GetYaxis()->SetTitleOffset(.45);
      myC->cd(2);
      gPad->SetTopMargin(small);
      gPad->SetTickx();
      gPad->Modified();

      myC->cd(1);

      h_hlt_filt_ref->GetYaxis()->SetTitle("Number of Events");
      h_hlt_filt_ref->GetYaxis()->SetTitleSize(0.05);
      h_hlt_filt_ref->GetYaxis()->SetTitleOffset(.95);

      h_hlt_filt_ref->Draw();
      h_hlt_filt_tgt->Draw("same");

      legend->Draw();

      double xmin = h_hlt_filt_ref->GetBinLowEdge(1);
      double xmax = h_hlt_filt_ref->GetBinLowEdge(h_hlt_filt_ref->GetNbinsX()) + h_hlt_filt_ref->GetBinWidth(h_hlt_filt_ref->GetNbinsX());

      myC->cd(2);

      myRatio->SetLineWidth(2);

      myRatio->Draw("hist");

      TLine* myLine;
      myLine = new TLine(xmin, 0, xmax, 0);
      myLine->Draw();

      std::string outputFile = dirprefix + "/hlt_path_" + name + outputSuffix_ + ".pdf";
      myC->Print(outputFile.c_str());

      delete legend;
      delete myC;
      delete myLine;
    }
    std::cout << " ====================== " << std::endl;

  }

  // close file
  file->Close();

}
void QA_Draw_Jet_Summary(const char *jet_family = "AntiKt_Tower",
                         const char *qa_file_name_new =
                             "data/G4sPHENIXCells_2000jets25GeV.root_qa.root",
                         const char *qa_file_name_ref =
                             "data/G4sPHENIXCells_250jets25GeV.root_qa.root")
{
  //! drawing energy range
  const double min_Et = 10;
  const double max_Et = 80;

  SetsPhenixStyle();
  TVirtualFitter::SetDefaultFitter("Minuit2");

  // file IO
  TFile *qa_file_new = new TFile(qa_file_name_new);
  assert(qa_file_new->IsOpen());

  // buffer for results
  vector<float> vec_radius;
  vector<TGraphErrors *> vec_phi_res;
  vector<TGraphErrors *> vec_eta_res;
  vector<TGraphErrors *> vec_e_res;
  vector<TGraphErrors *> vec_et_res;
  vector<TGraphErrors *> vec_reco_eff;
  vector<TGraphErrors *> vec_purity;

  // list and process all jets
  TList *hist_key_list = qa_file_new->GetListOfKeys();
  for (int i = 0; i < hist_key_list->GetSize(); ++i)
  {
    TString key_name = hist_key_list->At(i)->GetName();

    TString s_re_fullname = Form(
        "h_QAG4SimJet_.*_r[0-9]*_%s_r[0-9]*_Matching_Count_Truth_Et",
        jet_family);  // regular expression for search
    TRegexp re_fullname(s_re_fullname, false);
    if (key_name.Index(re_fullname) == kNPOS)
      continue;

    //      cout << " key_name = " << key_name << endl;
    TString jet_pair_name = key_name(0,
                                     key_name.Length() - TString("_Matching_Count_Truth_Et").Length());  // remove suffix

    //      cout << " jet_pair_name = " << jet_pair_name << endl;

    //get jet radius
    TRegexp re_jetradius("_r[0-9]*", false);
    Ssiz_t index_radius = key_name.Index(re_jetradius);             // first radius
    index_radius = key_name.Index(re_jetradius, index_radius + 1);  // second radius
    assert(index_radius != kNPOS);
    float radius = 0;
    sscanf(key_name(index_radius, 100).Data(), "_r%f", &radius);
    //      cout << " index_radius = " << index_radius << endl;
    assert(radius != 0);
    radius /= 10;  // jet radius convention in DST names

    cout << "QA_Draw_Jet_Summary - process jet pair " << jet_pair_name
         << " with radius = " << radius << endl;

    vector<TGraphErrors *> resolution_efficiency_summary(
        QA_Draw_Jet_TruthMatching(jet_pair_name, qa_file_name_new,
                                  qa_file_name_ref));

    //save results
    vec_radius.push_back(radius);
    vec_phi_res.push_back(resolution_efficiency_summary[0]);
    vec_eta_res.push_back(resolution_efficiency_summary[1]);
    vec_e_res.push_back(resolution_efficiency_summary[2]);
    vec_et_res.push_back(resolution_efficiency_summary[3]);
    vec_reco_eff.push_back(resolution_efficiency_summary[4]);
    vec_purity.push_back(resolution_efficiency_summary[5]);

    //      break;
  }

  // plot
  TCanvas *c1 = new TCanvas(
      TString("QA_Draw_Jet_Summary_") + TString(jet_family),
      TString("QA_Draw_Jet_Summary_") + TString(jet_family), 1800, 900);
  c1->Divide(3, 2);
  int idx = 1;
  TPad *p;

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  TH1 *h_frame =
      p->DrawFrame(min_Et, -.1, max_Et, .1,
                   TString(jet_family) + " #phi Reconstruction;E_{T, Truth} (GeV);#phi_{Reco} - #phi_{Truth} (rad)");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  TLine *l = new TLine(min_Et, 0, max_Et, 0);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  TLegend *legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_phi_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame =
      p->DrawFrame(min_Et, -.1, max_Et, .1,
                   TString(jet_family) + " #eta Reconstruction;E_{T, Truth} (GeV);#eta_{Reco} - #eta_{Truth}");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 0, max_Et, 0);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_eta_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame = p->DrawFrame(min_Et, 0, max_Et, 2,
                         TString(jet_family) + " Jet Energy Reconstruction;E_{Truth} (GeV);E_{Reco} / E_{Truth}");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_e_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame =
      p->DrawFrame(min_Et, 0, max_Et, 2,
                   TString(jet_family) + " Jet E_{T} Reconstruction;E_{T, Truth} (GeV);E_{T, Reco} / E_{T, Truth}");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_et_res[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame = p->DrawFrame(min_Et, 0, max_Et, 1.2,
                         TString(jet_family) + " Reco Efficiency;E_{T, Truth} (GeV);Reco efficiency");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_reco_eff[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  // ------------------------------------
  p = (TPad *) c1->cd(idx++);
  c1->Update();
  //  p->SetLogz();

  h_frame = p->DrawFrame(min_Et, 0, max_Et, 1.2,
                         TString(jet_family) + " Reconstruction Purity;E_{T, Reco} (GeV);Reconstruction Purity");
  //  h_frame->GetYaxis()->SetTitleOffset(1.01);
  l = new TLine(min_Et, 1, max_Et, 1);
  l->Draw();
  p->SetGridx(0);
  p->SetGridy(0);
  legend = new TLegend(0.7, 0.2, .95, 0.5);
  legend->SetFillColor(kWhite);
  legend->SetFillStyle(1001);
  legend->SetLineWidth(2);
  legend->SetLineColor(kBlack);
  legend->SetLineStyle(kSolid);
  for (int i = 0; i < vec_radius.size(); ++i)
  {
    const float radius = vec_radius[i];

    TGraphErrors *ge = vec_purity[i];
    assert(ge);
    ge = new TGraphErrors(*ge);  // make a copy

    ge->SetLineColor(i + 2);    // automatic color scheme from ROOT
    ge->SetMarkerColor(i + 2);  // automatic color scheme from ROOT
    for (int idata = 0; idata < ge->GetN(); ++idata)
    {
      (ge->GetX())[idata] += i * 0.5;  // shift x a little bit
      (ge->GetEX())[idata] = 0;        // no x error bar
    }
    ge->Draw("p E l");
    legend->AddEntry(ge, Form("r = %.1f", radius), "elp");
  }
  legend->Draw();

  //  PutInputFileName(c1, .03, qa_file_name_new, qa_file_name_ref);
  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
}
Exemplo n.º 3
0
Arquivo: Draweff.C Projeto: XuQiao/HI
void Draweff(){
	int sth=1, Gth=0;
	TFile *f = TFile::Open(outG);
	if(sth==0){TString dirname = "std";}
        else if(sth==1){TString dirname ="Gri055";}
        else {TString dirname ="Gri101";}
	gStyle->SetErrorX(0);
	TString name;
        TObjString* dataname = (TObjString*)f->Get(Form("dataname"));
        TObjString* histoname = (TObjString*)f->Get(Form("histoname"));
        if(Gth==0)
                name = "G0";
        else if(Gth<nGlau)
                name = Form("Glau_%d",Gth);
        else
                name = Form("bin_%d",Gth-nGlau+1);
        TObjString* Glaubername = (TObjString*)f->Get(Form("%s/%s/Glaubername",dirname.Data(),name.Data()));
        TVectorD* xmin = (TVectorD*)f->Get(Form("%s/%s/xmin",dirname.Data(),name.Data()));
        TVectorD* xmax = (TVectorD*)f->Get(Form("%s/%s/xmax",dirname.Data(),name.Data()));
        TVectorD* mubest = (TVectorD*)f->Get(Form("%s/%s/mubest",dirname.Data(),name.Data()));
        TVectorD* kbest = (TVectorD*)f->Get(Form("%s/%s/kbest",dirname.Data(),name.Data()));
        TVectorD* Ndf = (TVectorD*)f->Get(Form("%s/%s/Ndf",dirname.Data(),name.Data()));
        TVectorD* chis = (TVectorD*)f->Get(Form("%s/%s/chis",dirname.Data(),name.Data()));
	TVectorD *kpoint = (TVectorD*)f->Get(Form("%s/%s/kpoint",dirname.Data(),name.Data()));
	TFile *fdata = TFile::Open(dataname->GetString());
	TH1D *histo_obs = (TH1D*)fdata->Get(histoname->GetString());
	histo_obs->Sumw2();
	TFile *fGlauber = TFile::Open(Glaubername->GetString());
        int binnum = histo_obs->GetNbinsX();
        double Minx = histo_obs->GetXaxis()->GetXmin();
        double Maxx = histo_obs->GetXaxis()->GetXmax();
	double binsize = (Double_t)(Maxx-Minx)/binnum;
        int xbinmin=(int)(((*xmin)[0]-Minx)/binsize);
        int xbinmax=(int)(((*xmax)[0]-Minx)/binsize);
	TH1D *histo_exp = new TH1D("histo_exp","Simulated distribution;Multiplicity;Event Fraction",binnum,Minx,Maxx);
	histo_exp->Sumw2();
	Int_t ibin;
		
	TH1D *histo_obs_norm = (TH1D*)histo_obs->Clone();
        histo_obs_norm->Scale(1/histo_obs->Integral(xbinmin,xbinmax));

	TF1 *NBD_fun = new 
	TF1("NBD_fun","[0]*TMath::Gamma(x+[1])/(TMath::Gamma(x+1)*TMath::Gamma([1]))*TMath::Power([2]/[1],x)/TMath::Power([2]/[1]+1,x+[1])",0,100);
	NBD_fun->SetParameter(0,1);	//[0]: Normalized constant
	NBD_fun->SetParameter(1,(*kbest)[0]);	//[1]: k value
	NBD_fun->SetParameter(2,(*mubest)[0]);	//[2]: mu value
		
	TTree *t = (TTree*) fGlauber->Get("nt_p_Pb");
	Long_t Nevent;

	Nevent = (Long_t) t->GetEntries();

	Long_t Ev;	Int_t Bino;	Double_t Para, Bi_Para, Mult;
	Float_t Ncoll;
	t->SetBranchAddress("Ncoll",&Ncoll);

	for(Ev=0; Ev<Nevent; Ev++){
		if(Ev%100000==0)	 cout<<"Have run "<<Ev<<" events"<<endl;
		t->GetEntry(Ev);
		Para = 0; //make sure that Para doesn't accumulate through loops
		for(Bino=0; Bino<Ncoll; Bino++){
                         Bi_Para = NBD_fun->GetRandom();
                         Para += Bi_Para;
		}	
		histo_exp->Fill(Para);
	}
	Double_t SumEvent, scale;
	SumEvent = histo_exp->Integral(xbinmin,xbinmax);
	scale = 1/SumEvent;
	TH1D *histo_exp_norm = (TH1D*) histo_exp->Clone();
	histo_exp_norm->Scale(scale);

	TCanvas *c1 = new TCanvas();
        gStyle->SetOptStat(kFALSE);

	double hfbin[]={0,1,2,3,4,6,8,10,13,16,20,25,30,40,55,70,90};
	int nhfbin = 16;
	rehisto_obs_norm = (TH1D*)histo_obs_norm->Rebin(nhfbin,"rehisto_obs_norm",hfbin);
	normalizeByBinWidth(rehisto_obs_norm);
	rehisto_exp_norm = (TH1D*)histo_exp_norm->Rebin(nhfbin,"rehisto_exp_norm",hfbin);
	normalizeByBinWidth(rehisto_exp_norm);
	TH1D* ratio = (TH1D*)rehisto_obs_norm->Clone("ratio");
	ratio->Divide(rehisto_exp_norm);
        ratio->SetMaximum(1.2);
        ratio->SetMinimum(0);
        ratio->GetXaxis()->SetTitle("HF #Sigma E_{T} |#eta|>4");
       	ratio->GetYaxis()->SetTitle("ratio");

	TFile *fDSeff = TFile::Open("/afs/cern.ch/work/q/qixu/private/RpA/GlobalEvent/CentrDep/pPbHijing_EffCorr_forNBD.root");
	TFile *ftreff = TFile::Open("/afs/cern.ch/user/q/qixu/CMSSW_6_2_5/src/Centrality/Correction/pPbHist_Hijing_TrandEs.root");
	TH1D* hbef = (TH1D*)ftreff->Get("hHFEnergy4");
	TH1D* rehbef = (TH1D*)hbef->Rebin(nhfbin,"rehHFEnergy4",hfbin);
	TH1D* haft = (TH1D*)ftreff->Get("hHFEnergy4_tr");
	TH1D* rehaft = (TH1D*)haft->Rebin(nhfbin,"rehHFEnergy4_tr",hfbin);
	TGraphAsymmErrors *gtreff = new TGraphAsymmErrors();
	gtreff->BayesDivide(rehaft,rehbef);

	TGraphAsymmErrors *geff = (TGraphAsymmErrors*)fDSeff->Get("regEffHF4");
	for(int i=0;i<geff->GetN();i++){
		geff->SetPointEXlow(i,0);
		geff->SetPointEXhigh(i,0);
		gtreff->SetPointEXlow(i,0);
		gtreff->SetPointEXhigh(i,0);
	}

	ratio->SetTitle("");
	ratio->SetLineColor(1);
	ratio->SetMarkerStyle(24);
	ratio->SetMarkerColor(1);
        ratio->SetMarkerSize(1.5);
	ratio->Draw("P");	

	geff->SetMarkerStyle(33);
	geff->SetMarkerColor(2);
	geff->SetMarkerSize(1.5);
	geff->Draw("Psame");

	gtreff->SetMarkerStyle(21);
	gtreff->SetMarkerColor(4);
	gtreff->SetMarkerSize(1.3);
	gtreff->Draw("Psame");

        TLegend *leg = new TLegend(0.60, 0.2, 0.78, 0.4);
        leg->SetFillColor(10);
        leg->SetFillStyle(0);
        leg->SetBorderSize(0.035);
        leg->SetTextFont(42);
        leg->SetTextSize(0.045);
        leg->AddEntry(ratio,"data/fit","p");
        leg->AddEntry(geff,"DS efficiency","p");
        leg->AddEntry(gtreff,"Event selection efficiency","p");
	leg->Draw("same");
	
	TLine *l = new TLine(0,1,90,1);
	l->SetLineStyle(2);
	l->Draw("same");
	c1->SaveAs(Form("%sratiovseff.png",dirname.Data()));	

}
Exemplo n.º 4
0
void outputBDTplots(TString setup, TString MVA, TString dir, int MSTOP, int MLSP,bool lineacut,bool logbool){


	  gStyle->SetOptStat(0);
	  gStyle->SetCanvasColor(0);
	  gStyle->SetPadColor(0);
	  gStyle->SetMarkerStyle(15);
	  gStyle->SetMarkerSize(0.25);
	  gStyle->SetTextFont(42);
	  gStyle->SetMarkerColor(37);


          std::ostringstream ostr1;
          ostr1 << MSTOP; 
          std::string stop = ostr1.str();

          std::ostringstream ostr2;
          ostr2 << MLSP;
          std::string neut = ostr2.str();

          TString ntpdir ="ntuples_setup0_nomt_setup1_mt"; 
	  TString dataset_name;
          TString datasetnombre;
	
	
	  if (dir == "T2bw025") {dataset_name = "t2bw_025";}
	  if (dir == "T2bw050") {dataset_name = "t2bw_050";}
	  if (dir == "T2bw075") {dataset_name = "t2bw_075";}
	  if (dir == "T2tt") {dataset_name = "t2tt_all";}
	  if (dir == "T2tt") {datasetnombre = "t2tt_half";}
	  
          TFile ttbar(ntpdir+"/"+setup+"/"+dir+"/ttbar/output/ttbar_all_0.root");
          TFile wjets(ntpdir+"/"+setup+"/"+dir+"/wjets/output/wjets_all_0.root");
          TFile others(ntpdir+"/"+setup+"/"+dir+"/others/output/others_all_0.root");
          TFile sig(ntpdir+"/"+setup+"/"+dir+"/signal/"+TString(stop)+"/"+TString(neut)+"/output/"+dataset_name+"_0.root");



	  TH1D* TTBar= (TH1D*)ttbar.Get(MVA);
	  TH1D* WJets= (TH1D*)wjets.Get(MVA);
	  TH1D* Others= (TH1D*)others.Get(MVA);
	  TH1D* signal= (TH1D*)sig.Get(MVA);

	  TTBar->SetFillColor(40);
	  TTBar->SetFillStyle(3001);
	  TTBar->SetLineWidth(0.);
	  signal->SetLineColor(kRed);
	  signal->SetLineWidth(2.);


    	  WJets->SetFillColor(41);
    	  Others->SetFillColor(43);
	  
		  
	  
          THStack *stack= new THStack("stack", "");
          stack->Add(Others);
          stack->Add(WJets);
          stack->Add(TTBar);

         

          int nbins = TTBar->GetNbinsX();
          double hmin = TTBar->GetXaxis()->GetBinLowEdge(1);
          double hmax = TTBar->GetXaxis()->GetBinUpEdge(nbins);


          TH1D* SoB = new TH1D("","",nbins,hmin,hmax);
          int max_bin;
          double cutvalue; 
	  double nsignal = signal->Integral();




          SoB->SetLineColor(kBlue);
          SoB->SetLineWidth(2.);




	      for(int b=1; b<=nbins; ++b){

	      //cout << "Bkg: " << TTBar->Integral(b,nbins+1) << endl;
	      //cout << "Sig: " << signal->Integral(b,nbins+1) << endl;

	      double sig_ = signal->Integral(b,nbins+1);
	      double bkg_ = TTBar->Integral(b,nbins+1) + WJets->Integral(b,nbins+1) + Others->Integral(b,nbins+1);
	      
	      double SoSqrtB = calcSoSqrtB(sig_, bkg_ );

	      SoB->SetBinContent(b,SoSqrtB);

	      }


	/*      double bkgcut=0.;

 if (MLSP==150 && (MSTOP ==300 || MSTOP == 400 ||  MSTOP == 500 || MSTOP == 600 || MSTOP == 700 || MSTOP == 800)){
	     
	     double binR1=TTBar->FindBin(0.25);
	     double binR2=TTBar->FindBin(0.4);
	     double binR3=TTBar->FindBin(0.5);
	     double binR4=TTBar->FindBin(0.5);
	     double binR5=TTBar->FindBin(0.4);
	     double binR6=TTBar->FindBin(0.1);
	     
	     TH1F *histobackground=(TH1F*)TTBar->Clone();
	     histobackground->Add(WJets);
	     histobackground->Add(Others);
	     
	     //histobackground->SetAxisRange(0.3,1,"X");
	    	      
	      if (MSTOP==300)  cout << TTBar->Integral(binR1,nbins+1)+Others->Integral(binR1,nbins+1)+WJets->Integral(binR1,nbins+1) << " +/- "  << sqrt(histobackground->Integral(binR1,nbins+1)) <<  endl; 
	      if (MSTOP==400)  cout << histobackground->Integral(binR2,nbins+1) << " +/- "  << sqrt(histobackground->Integral(binR2,nbins+1)) <<  endl;  
	      if (MSTOP==500)  cout << histobackground->Integral(binR3,nbins+1) << " +/- "  << sqrt(histobackground->Integral(binR3,nbins+1)) <<  endl;  
	      if (MSTOP==600)  cout << histobackground->Integral(binR4,nbins+1) << " +/- "  << sqrt(histobackground->Integral(binR4,nbins+1)) <<  endl;  
	      if (MSTOP==700)  cout << histobackground->Integral(binR5,nbins+1) << " +/- "  << sqrt(histobackground->Integral(binR5,nbins+1)) <<  endl;  
	      if (MSTOP==800)  cout << histobackground->Integral(binR6,nbins+1) << " +/- "  << sqrt(histobackground->Integral(binR6,nbins+1)) <<  endl;  

	       }*/
 


	   max_bin = maxbin(SoB);
	   cutvalue = TTBar->GetBinLowEdge(max_bin);
           

	   double sob = SoB->GetBinContent(max_bin);

       	   char cutval_[32];
	   snprintf(cutval_, 32, "%.1g", cutvalue);
       	   char fom_[32];
	   snprintf(fom_, 32, "%.2g", sob);
       	   char signal_[32];
	   snprintf(signal_, 32, "%.2g", nsignal);

           TLegendEntry *legge;
           TLegend *leg;
           leg = new TLegend(0.6,0.55,0.9,0.85);
           leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.043);
           legge = leg->AddEntry(TTBar,   "t#bar{t} + Jets", "F");
           legge = leg->AddEntry(WJets,   "W + Jets", "F");
           legge = leg->AddEntry(Others,   "Others", "F");
           legge = leg->AddEntry(signal, "sig("+TString(stop)+","+TString(neut)+")", "l");
           leg->SetFillColor(0);

 

           TCanvas c2("c2","c2",800,600);
	   
	 	   
	   stack->Draw("");
	   signal->Draw("same");
	  
	  stack->GetYaxis()->SetTitle("Entries");
	  stack->GetXaxis()->SetTitle("BDT output");
	  
	  signal->GetXaxis()->SetRangeUser(-0.4,0.8);
	  stack->GetXaxis()->SetRangeUser(-0.4,0.8);
	  
	  signal->SetMinimum(0.3);
	  stack->SetMinimum(0.3);
	  
	  //signal->GetYaxis()->SetNdivisions(10);
	  //stack->GetYaxis()->SetNdivisions(10);
	  
	  
	   if(logbool) c2.SetLogy();
           leg->Draw();
	   
	  
	   
	   double maximobin=stack->GetMaximum();
	   double cutvalueplot = atof(TString(cutval_));
	   TLine *linea = new TLine(cutvalueplot,0,cutvalueplot,maximobin);
	   linea->SetLineWidth(2);
	   linea->SetLineColor(4);
	   if (lineacut) linea->Draw();
           TLatex l1;
           l1.SetTextAlign(12);
           l1.SetTextSize(0.04);
           l1.SetNDC();
           l1.DrawLatex(0.155, 0.98, "CMS Simulation, 20 fb^{-1}");
           l1.DrawLatex(0.7, 0.98, "#sqrt{s} = 8 TeV");

           TLatex l2;
           l2.SetTextAlign(12);
           l2.SetTextSize(0.04);
           l2.SetNDC();
           l2.DrawLatex(0.22, 0.3, "#color[2]{Optimal cut: \t "+TString(cutval_)+"}");
           l2.DrawLatex(0.22, 0.25, "#color[2]{FOM@cut: \t "+TString(fom_)+"}");
           l2.DrawLatex(0.22, 0.2, "#color[2]{Tot. N_{Signal}: \t "+TString(signal_)+"}");
	   
          if (!logbool)  c2.Print("~/www/STOP/BDTTraining/8TeV/"+dataset_name+"_half/BestSet/"+TString(MVA)+"/histo_"+TString(stop)+"_"+TString(neut)+"_lineal.png");
          if(logbool)   c2.Print("~/www/STOP/BDTTraining/8TeV/"+dataset_name+"_half/BestSet/"+TString(MVA)+"/histo_"+TString(stop)+"_"+TString(neut)+"_log.png");
}
Exemplo n.º 5
0
void SignfificanceT2tt(bool pval, int exp=0){


    TFile *f = TFile::Open("Significances2DHistograms_T2tt.root");
    TH2F *h;
    if(pval){
        if(exp==0) h = (TH2F*)f->Get("hpObs");
        else if(exp==1) h = (TH2F*)f->Get("hpExpPosteriori");
        else if(exp==2) h = (TH2F*)f->Get("hpExpPriori");
    }
    else {
        if(exp==0) h = (TH2F*)f->Get("hObs");
        else if(exp==1) h = (TH2F*)f->Get("hExpPosteriori");
        else if(exp==2) h = (TH2F*)f->Get("hExpPriori");
    }
    h->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
    h->GetXaxis()->SetLabelFont(42);
    h->GetXaxis()->SetLabelSize(0.035);
    h->GetXaxis()->SetTitleSize(0.05);
    h->GetXaxis()->SetTitleOffset(1.2);
    h->GetXaxis()->SetTitleFont(42);
    h->GetYaxis()->SetTitle("m_{#tilde{#chi}_{1}^{0}} [GeV]");
    h->GetYaxis()->SetLabelFont(42);
    h->GetYaxis()->SetLabelSize(0.035);
    h->GetYaxis()->SetTitleSize(0.05);
    h->GetYaxis()->SetTitleOffset(1.35);
    h->GetYaxis()->SetTitleFont(42);
    double maximum = h->GetMaximum();
    double minimum = h->GetMinimum();
    double sigmin = 99; int sigminx=-1; int sigminy=-1; if(pval) sigmin = -99;
    h->GetZaxis()->SetRangeUser(minimum,maximum);
    for(int x = 1; x<=h->GetNbinsX();++x){
        for(int y = 1; y<=h->GetNbinsX();++y){
            if(!pval&&h->GetBinContent(x,y)<sigmin){ sigmin =h->GetBinContent(x,y); sigminx = x; sigminy = y; }
            if( pval&&h->GetBinContent(x,y)>sigmin){ sigmin =h->GetBinContent(x,y); sigminx = x; sigminy = y; }
            if(!pval&&h->GetXaxis()->GetBinLowEdge(x)<h->GetYaxis()->GetBinLowEdge(y)+75) h->SetBinContent(x,y,-999);
            if(h->GetXaxis()->GetBinLowEdge(x)<374) continue;
            if(h->GetXaxis()->GetBinLowEdge(x)>424) continue;
            if(h->GetYaxis()->GetBinLowEdge(y)<199) continue;
            if(h->GetYaxis()->GetBinLowEdge(y)>249) continue;
            if(!pval&&h->GetBinContent(x,y)>0.3) h->SetBinContent(x,y,0.05);
        }
    }
    h->GetZaxis()->SetRangeUser(minimum,maximum);
    if(!pval) cout << "minimal significance " << sigmin << " at " << h->GetXaxis()->GetBinLowEdge(sigminx) << "-" << h->GetYaxis()->GetBinLowEdge(sigminy) << endl;
    else cout << "maximal p- value " << sigmin << " at " << h->GetXaxis()->GetBinLowEdge(sigminx) << "-" << h->GetYaxis()->GetBinLowEdge(sigminy) << endl;
    
   TCanvas *c1 = new TCanvas("c1", "c1",50,50,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetErrorX(0.5); 
   //c1->Range(-6.311689,-1.891383,28.75325,4.56342);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
//   c1->SetRightMargin(0.05);
    c1->SetRightMargin(0.15);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.15);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   gStyle->SetHatchesLineWidth(0);

   TH1F *hSum = new TH1F("hSum","",10,100,900);
   hSum->SetMinimum(0.);
   hSum->SetMaximum(550);
   hSum->SetDirectory(0);
   hSum->SetStats(0);
    hSum->Draw();
    hSum->GetYaxis()->SetRangeUser(0,500);
    hSum->GetXaxis()->SetRangeUser(100,900);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hSum->SetLineColor(ci);
   hSum->SetLineStyle(0);
   hSum->SetMarkerStyle(20);
   hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
   //hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
   hSum->GetXaxis()->SetLabelFont(42);
   //hSum->GetXaxis()->SetLabelOffset(0.005);
   hSum->GetXaxis()->SetLabelSize(0.035);
   hSum->GetXaxis()->SetTitleSize(0.06);
   hSum->GetXaxis()->SetTitleOffset(1.2);
   hSum->GetXaxis()->SetTitleFont(42);
   hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
   hSum->GetYaxis()->SetLabelFont(42);
   //hSum->GetYaxis()->SetLabelOffset(0.007);
   hSum->GetYaxis()->SetLabelSize(0.035);
   hSum->GetYaxis()->SetTitleSize(0.05);
   hSum->GetYaxis()->SetTitleOffset(1.3);
   hSum->GetYaxis()->SetTitleFont(42);
    
   /*
    TLegend *legO = new TLegend(0.175,0.675,0.50,0.855,NULL,"brNDC");
    //legO-> SetNColumns(2);
    legO->SetBorderSize(0);
    legO->SetTextSize(0.04);
    legO->SetTextFont(42);
    legO->SetLineColor(1);
    legO->SetLineStyle(1);
    legO->SetLineWidth(2);
    legO->SetFillColor(0);
    legO->SetFillStyle(1001);
    legO->SetHeader("Observed");
    legO->AddEntry(gObs, "unpolarized","l");
    legO->AddEntry(gObsR, "right-handed","l");
    legO->AddEntry(gObsL, "left-handed","l");
    */
    
    TGraph* graphWhite = new TGraph(5);
    graphWhite->SetName("white");
    graphWhite->SetTitle("white");
    graphWhite->SetFillColor(kWhite);
    graphWhite->SetFillStyle(1001);
    graphWhite->SetLineColor(kBlack);
    graphWhite->SetLineStyle(1);
    graphWhite->SetLineWidth(3);
    graphWhite->SetPoint(0,100, 500);
    graphWhite->SetPoint(1,900, 500);
    graphWhite->SetPoint(2,900, 500*0.75);
    graphWhite->SetPoint(3,100, 500*0.75);
    graphWhite->SetPoint(4,100, 500);
    
    Float_t diagX[4] = {175.+25.,175.+25.+5000,175.-25.+5000,175.-25.};
    Float_t diagY[4] = {0,5000,5000,0};
    TGraph *gdiagonal = new TGraph(4, diagX, diagY);
    gdiagonal->SetName("MtopDiagonal");
    gdiagonal->SetFillColor(kWhite);
    //#gdiagonal->SetFillColor(18);
    TLine* ldiagonal = new TLine(175,0.,650-25.,450);
    //TLine* ldiagonal = new TLine(175.,25,175+500,500);
    ldiagonal->SetLineColor(kGray);
    ldiagonal->SetLineStyle(2);
    TLatex* tdiagonal = new TLatex(400-2.5, 400-172.5,"m_{#tilde{t}} = m_{t} + m_{#tilde{#chi}_{1}^{0}}");
    //tdiagonal->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    tdiagonal->SetTextAngle(56.31);
    tdiagonal->SetTextColor(kGray+2);
    tdiagonal->SetTextAlign(11);
    tdiagonal->SetTextSize(0.025);

    TLine* l2 = new TLine(150,75,585,500);
    l2->SetLineColor(kGray);
    l2->SetLineStyle(2);
//    if(killlowdiag){
//        l2->SetX1(200); l2->SetY1(0); l2->SetX2(600); l2->SetY2(400);
//    }
    TLatex *t2 = new TLatex(300, 300-72.5,"m_{#tilde{t}} = m_{W} + m_{#tilde{#chi}_{1}^{0}}");
    //t2->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    t2->SetTextAngle(56.31);
    t2->SetTextColor(kGray+2);
    t2->SetTextAlign(11);
    t2->SetTextSize(0.025);
    
    


    hSum->Draw("axis");
    h->Draw("COLZsame");

    gdiagonal->Draw("FSAME");
    ldiagonal->Draw("LSAME");
    l2->Draw();
//    if(!killlowdiag) t2->Draw();
    tdiagonal->Draw("SAME");
    graphWhite->Draw("FSAME");
    graphWhite->Draw("LSAME");

    string textstring = "observed";
    if(exp!=0) textstring = "expected";
    TLatex* textOE= new TLatex(0.175,0.715,textstring.c_str() );
    textOE->SetNDC();
    textOE->SetTextAlign(13);
    textOE->SetTextFont(42);
    textOE->SetTextSize(0.042);
    textOE->Draw();
    

    TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"#tilde{#chi} ");
    textModelLabel->SetNDC();
    textModelLabel->SetTextAlign(13);
    textModelLabel->SetTextFont(42);
    textModelLabel->SetTextSize(0.042);
    textModelLabel->Draw();
    TLatex* textlLabel= new TLatex(0.175,0.85,"NLO+NLL significance");
    textlLabel->SetNDC();
    textlLabel->SetTextAlign(13);
    textlLabel->SetTextFont(42);
    textlLabel->SetTextSize(0.042);
    textlLabel->Draw();
    
    string psig = "significance [#sigma]";
    if(pval) psig = "p-value";
    TLatex * ztex = new TLatex(0.985,0.92,psig.c_str() );
    ztex->SetNDC();
    ztex->SetTextAlign(31);
    ztex->SetTextFont(42);
    ztex->SetTextSize(0.045);
    ztex->SetTextAngle(90);
    ztex->SetLineWidth(2);
    ztex->Draw();
    
    //final CMS style
    TLatex *tLumi = new TLatex(0.81,0.944,"2.3 fb^{-1} (13 TeV)");
    tLumi->SetNDC();
    tLumi->SetTextAlign(31);
    tLumi->SetTextFont(42);
    tLumi->SetTextSize(0.042);
    tLumi->SetLineWidth(2);
    tLumi->Draw();
    TLatex *tCMS = new TLatex(0.152,0.944,"CMS");
    tCMS->SetNDC();
    tCMS->SetTextAlign(11);
    tCMS->SetTextFont(61);
    tCMS->SetTextSize(0.0525);
    tCMS->SetLineWidth(2);
    tCMS->Draw();
    TLatex *tPrel = new TLatex(0.265,0.944,"Preliminary");
    tPrel->SetNDC();
    tPrel->SetTextAlign(11);
    tPrel->SetTextFont(52);
    tPrel->SetTextSize(0.042);
    tPrel->SetLineWidth(2);
    tPrel->Draw();
    
   c1->Modified();
   c1->cd();
    c1->Update();
   c1->SetSelected(c1);

}
Exemplo n.º 6
0
void Polarization(){

    TGraph *gObs;
    TGraph *gExp;
    TGraph *gObsL;
    TGraph *gExpL;
    TGraph *gObsR;
    TGraph *gExpR;
    
    TFile *fc = TFile::Open("Limits2DHistograms_T2tt_postfit.root");
    TFile *fl = TFile::Open("Limits2DHistograms_T2tt_lefthanded_postfit.root");
    TFile *fr = TFile::Open("Limits2DHistograms_T2tt_righthanded_postfit.root");
    
    TGraph *g;
    fc->cd();
    g = (TGraph*)fc->Get("gObs");
    gObs = (TGraph*)g->Clone("Obs");
    g = (TGraph*)fc->Get("gExp");
    gExp = (TGraph*)g->Clone("Exp");
    fl->cd();
    g = (TGraph*)fl->Get("gObs_2");
    gObsL = (TGraph*)g->Clone("ObsL");
    g = (TGraph*)fl->Get("gExp_2");
    gExpL = (TGraph*)g->Clone("ExpL");
    fr->cd();
    g = (TGraph*)fr->Get("gObs");
    gObsR = (TGraph*)g->Clone("ObsR");
    g = (TGraph*)fr->Get("gExp");
    gExpR = (TGraph*)g->Clone("ExpR");
    
    gObs->SetLineWidth(4);
    gExp->SetLineWidth(4);
    gObsL->SetLineWidth(2);
    gExpL->SetLineWidth(2);
    gObsR->SetLineWidth(2);
    gExpR->SetLineWidth(2);
    gObs->SetLineStyle(1);
    gExp->SetLineStyle(7);
    gObsL->SetLineStyle(1);
    gExpL->SetLineStyle(7);
    gObsR->SetLineStyle(1);
    gExpR->SetLineStyle(7);
    gObs->SetLineColor(kBlack);
    gExp->SetLineColor(kBlack);
    gObsL->SetLineColor(kBlue);
    gExpL->SetLineColor(kBlue);
    gObsR->SetLineColor(kRed);
    gExpR->SetLineColor(kRed);
    if(killlowdiag){
    for( int i = gObs->GetN()-1; i>=0;--i){
        double x,y;
        gObs->GetPoint(i,x,y);
        if(x-y<172.5) gObs->RemovePoint(i);
    }
    for( int i = gExp->GetN()-1; i>=0;--i){
        double x,y;
        gExp->GetPoint(i,x,y);
        if(x-y<172.5) gExp->RemovePoint(i);
    }
    }
    for( int i = gObsL->GetN()-1; i>=0;--i){
        double x,y;
        gObsL->GetPoint(i,x,y);
        if(x-y<172.5) gObsL->RemovePoint(i);
    }
    for( int i = gObsR->GetN()-1; i>=0;--i){
        double x,y;
        gObsR->GetPoint(i,x,y);
        if(x-y<172.5) gObsR->RemovePoint(i);
    }
    for( int i = gExpL->GetN()-1; i>=0;--i){
        double x,y;
        gExpL->GetPoint(i,x,y);
        if(x-y<172.5) gExpL->RemovePoint(i);
    }
    for( int i = gExpR->GetN()-1; i>=0;--i){
        double x,y;
        gExpR->GetPoint(i,x,y);
        if(x-y<172.5) gExpR->RemovePoint(i);
    }

    
   TCanvas *c1 = new TCanvas("c1", "c1",50,50,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetErrorX(0.5); 
   //c1->Range(-6.311689,-1.891383,28.75325,4.56342);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
   c1->SetRightMargin(0.05);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.15);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   gStyle->SetHatchesLineWidth(0);

   TH1F *hSum = new TH1F("hSum","",10,150,950);
   hSum->SetMinimum(0.);
   hSum->SetMaximum(550);
   hSum->SetDirectory(0);
   hSum->SetStats(0);
    hSum->Draw();
    hSum->GetYaxis()->SetRangeUser(0,500);
    hSum->GetXaxis()->SetRangeUser(150,950);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hSum->SetLineColor(ci);
   hSum->SetLineStyle(0);
   hSum->SetMarkerStyle(20);
   hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
   //hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
   hSum->GetXaxis()->SetLabelFont(42);
   //hSum->GetXaxis()->SetLabelOffset(0.005);
   hSum->GetXaxis()->SetLabelSize(0.035);
   hSum->GetXaxis()->SetTitleSize(0.06);
   hSum->GetXaxis()->SetTitleOffset(1.2);
   hSum->GetXaxis()->SetTitleFont(42);
   hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
   hSum->GetYaxis()->SetLabelFont(42);
   //hSum->GetYaxis()->SetLabelOffset(0.007);
   hSum->GetYaxis()->SetLabelSize(0.035);
   hSum->GetYaxis()->SetTitleSize(0.05);
   hSum->GetYaxis()->SetTitleOffset(1.3);
   hSum->GetYaxis()->SetTitleFont(42);
    
    //TLegend *leg = new TLegend(0.4992416,0.4811189,0.898906,0.7503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.4992416,0.4811189,0.698906,0.7503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.6992416,0.2811189,0.898906,0.4503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.6992416,0.3311189,0.898906,0.7903497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.7582416,0.4211189,0.912,0.8043497,NULL,"brNDC");
    TLegend *legE = new TLegend(0.51,0.675,0.81,0.855,NULL,"brNDC");
    //leg-> SetNColumns(2);
    legE->SetBorderSize(0);
    legE->SetTextSize(0.04);
    legE->SetTextFont(42);
    legE->SetLineColor(1);
    legE->SetLineStyle(1);
    legE->SetLineWidth(2);
    legE->SetFillColor(0);
    legE->SetFillStyle(1001);
    legE->SetHeader("Expected");
    legE->AddEntry(gExp, "unpolarized","l");
    legE->AddEntry(gExpR, "right-handed","l");
    legE->AddEntry(gExpL, "left-handed","l");
    
    TLegend *legO = new TLegend(0.175,0.675,0.50,0.855,NULL,"brNDC");
    //legO-> SetNColumns(2);
    legO->SetBorderSize(0);
    legO->SetTextSize(0.04);
    legO->SetTextFont(42);
    legO->SetLineColor(1);
    legO->SetLineStyle(1);
    legO->SetLineWidth(2);
    legO->SetFillColor(0);
    legO->SetFillStyle(1001);
    legO->SetHeader("Observed");
    legO->AddEntry(gObs, "unpolarized","l");
    legO->AddEntry(gObsR, "right-handed","l");
    legO->AddEntry(gObsL, "left-handed","l");
    
    
    TGraph* graphWhite = new TGraph(5);
    graphWhite->SetName("white");
    graphWhite->SetTitle("white");
    graphWhite->SetFillColor(kWhite);
    graphWhite->SetFillStyle(1001);
    graphWhite->SetLineColor(kBlack);
    graphWhite->SetLineStyle(1);
    graphWhite->SetLineWidth(3);
    graphWhite->SetPoint(0,150, 500);
    graphWhite->SetPoint(1,950, 500);
    graphWhite->SetPoint(2,950, 500*0.6666666667);
    graphWhite->SetPoint(3,150, 500*0.6666666667);
    graphWhite->SetPoint(4,150, 500);
    
    Float_t diagX[4] = {175.+25.,175.+25.+5000,175.-25.+5000,175.-25.};
    Float_t diagY[4] = {0,5000,5000,0};
    TGraph *gdiagonal = new TGraph(4, diagX, diagY);
    gdiagonal->SetName("MtopDiagonal");
    gdiagonal->SetFillColor(kWhite);
    //#gdiagonal->SetFillColor(18);
    TLine* ldiagonal = new TLine(175,0.,650-25.,450);
    //TLine* ldiagonal = new TLine(175.,25,175+500,500);
    ldiagonal->SetLineColor(kGray);
    ldiagonal->SetLineStyle(2);
    TLatex* tdiagonal = new TLatex(400-2.5, 400-172.5,"m_{#tilde{t}} = m_{t} + m_{#tilde{#chi}_{1}^{0}}");
    //tdiagonal->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    tdiagonal->SetTextAngle(56.31);
    tdiagonal->SetTextColor(kGray+2);
    tdiagonal->SetTextAlign(11);
    tdiagonal->SetTextSize(0.025);

    TLine* l2 = new TLine(150,75,585,500);
    l2->SetLineColor(kGray);
    l2->SetLineStyle(2);
    if(killlowdiag){
        l2->SetX1(200); l2->SetY1(0); l2->SetX2(600); l2->SetY2(400);
    }
    TLatex *t2 = new TLatex(300, 300-72.5,"m_{#tilde{t}} = m_{W} + m_{#tilde{#chi}_{1}^{0}}");
    //t2->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    t2->SetTextAngle(56.31);
    t2->SetTextColor(kGray+2);
    t2->SetTextAlign(11);
    t2->SetTextSize(0.025);

    hSum->Draw("axis");
    
    gExpR->Draw("c");
    gExpL->Draw("c");
    gExp->Draw("c");
    gObsR->Draw("c");
    gObsL->Draw("c");
    gObs->Draw("c");

    gdiagonal->Draw("FSAME");
    ldiagonal->Draw("LSAME");
    l2->Draw();
    if(!killlowdiag) t2->Draw();
    tdiagonal->Draw("SAME");
    graphWhite->Draw("FSAME");
    graphWhite->Draw("LSAME");

    legE->Draw();
    legO->Draw();
    
    TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}  NLO+NLL exclusion");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"#tilde{#chi} ");
    textModelLabel->SetNDC();
    textModelLabel->SetTextAlign(13);
    textModelLabel->SetTextFont(42);
    textModelLabel->SetTextSize(0.042);
    textModelLabel->Draw();
    
    //final CMS style
    TLatex *tLumi = new TLatex(0.95,0.944,"2.3 fb^{-1} (13 TeV)");
    tLumi->SetNDC();
    tLumi->SetTextAlign(31);
    tLumi->SetTextFont(42);
    tLumi->SetTextSize(0.042);
    tLumi->SetLineWidth(2);
    tLumi->Draw();
    TLatex *tCMS = new TLatex(0.152,0.944,"CMS");
    tCMS->SetNDC();
    tCMS->SetTextAlign(11);
    tCMS->SetTextFont(61);
    tCMS->SetTextSize(0.0525);
    tCMS->SetLineWidth(2);
    tCMS->Draw();
    TLatex *tPrel = new TLatex(0.265,0.944,"Preliminary");
    tPrel->SetNDC();
    tPrel->SetTextAlign(11);
    tPrel->SetTextFont(52);
    tPrel->SetTextSize(0.042);
    tPrel->SetLineWidth(2);
    tPrel->Draw();
    
   c1->Modified();
   c1->cd();
    c1->Update();
   c1->SetSelected(c1);

}
Exemplo n.º 7
0
void YieldStudies(TString inputPP="hPtSpectrumDzeroPP.root",TString inputPPMC="hPtSpectrumDzeroPPMCClosure.root")
{
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetEndErrorSize(0);
  gStyle->SetMarkerStyle(20);


  TFile* filesPP=new TFile(inputPP.Data());
  TFile* filesPPMC=new TFile(inputPPMC.Data());
  TH1D* hMeanPP=(TH1D*)filesPP->Get("hMean");
  TH1D* hMeanPPMC=(TH1D*)filesPPMC->Get("hMean");
  TH1D* hSigmaGaus1PP=(TH1D*)filesPP->Get("hSigmaGaus1");
  TH1D* hSigmaGaus1PPMC=(TH1D*)filesPPMC->Get("hSigmaGaus1");
  TH1D* hSigmaGaus2PP=(TH1D*)filesPP->Get("hSigmaGaus2");
  TH1D* hSigmaGaus2PPMC=(TH1D*)filesPPMC->Get("hSigmaGaus2");
  TH1D* hRelMagnGaus1Gaus2PP=(TH1D*)filesPP->Get("hRelMagnGaus1Gaus2");
  TH1D* hRelMagnGaus1Gaus2PPMC=(TH1D*)filesPPMC->Get("hRelMagnGaus1Gaus2");
  
  TH1D* hClosure=(TH1D*)filesPPMC->Get("hPtCor");
  TH1D* hPtGen=(TH1D*)filesPPMC->Get("hPtGen");
  hClosure->Sumw2();
  hClosure->Divide(hPtGen);


  TH2F* hemptySigma1=new TH2F("hemptySigma1","",50,0.,100.,10.,0.,0.1);  
  hemptySigma1->GetXaxis()->CenterTitle();
  hemptySigma1->GetYaxis()->CenterTitle();
  hemptySigma1->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hemptySigma1->GetYaxis()->SetTitle("#sigma_{1} (GeV/c^{2})");
  hemptySigma1->GetXaxis()->SetTitleOffset(1.);
  hemptySigma1->GetYaxis()->SetTitleOffset(1.4);
  hemptySigma1->GetXaxis()->SetTitleSize(0.045);
  hemptySigma1->GetYaxis()->SetTitleSize(0.05);
  hemptySigma1->GetXaxis()->SetTitleFont(42);
  hemptySigma1->GetYaxis()->SetTitleFont(42);
  hemptySigma1->GetXaxis()->SetLabelFont(42);
  hemptySigma1->GetYaxis()->SetLabelFont(42);
  hemptySigma1->GetXaxis()->SetLabelSize(0.04);
  hemptySigma1->GetYaxis()->SetLabelSize(0.04);  
 
  TH2F* hemptyRelMag=new TH2F("hemptyRelMag","",50,0.,100.,10.,0.,0.3);  
  hemptyRelMag->GetXaxis()->CenterTitle();
  hemptyRelMag->GetYaxis()->CenterTitle();
  hemptyRelMag->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hemptyRelMag->GetYaxis()->SetTitle("norm(#sigma_1)/norm(#sigma_1)+norm(#sigma_2)");
  hemptyRelMag->GetXaxis()->SetTitleOffset(1.);
  hemptyRelMag->GetYaxis()->SetTitleOffset(1.4);
  hemptyRelMag->GetXaxis()->SetTitleSize(0.045);
  hemptyRelMag->GetYaxis()->SetTitleSize(0.05);
  hemptyRelMag->GetXaxis()->SetTitleFont(42);
  hemptyRelMag->GetYaxis()->SetTitleFont(42);
  hemptyRelMag->GetXaxis()->SetLabelFont(42);
  hemptyRelMag->GetYaxis()->SetLabelFont(42);
  hemptyRelMag->GetXaxis()->SetLabelSize(0.04);
  hemptyRelMag->GetYaxis()->SetLabelSize(0.04);  

  TH2F* hemptySigma2=new TH2F("hemptySigma2","",50,0.,100.,10.,0.,0.03);  
  hemptySigma2->GetXaxis()->CenterTitle();
  hemptySigma2->GetYaxis()->CenterTitle();
  hemptySigma2->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hemptySigma2->GetYaxis()->SetTitle("#sigma_{2} (GeV/c^{2})");
  hemptySigma2->GetXaxis()->SetTitleOffset(1.);
  hemptySigma2->GetYaxis()->SetTitleOffset(1.4);
  hemptySigma2->GetXaxis()->SetTitleSize(0.045);
  hemptySigma2->GetYaxis()->SetTitleSize(0.05);
  hemptySigma2->GetXaxis()->SetTitleFont(42);
  hemptySigma2->GetYaxis()->SetTitleFont(42);
  hemptySigma2->GetXaxis()->SetLabelFont(42);
  hemptySigma2->GetYaxis()->SetLabelFont(42);
  hemptySigma2->GetXaxis()->SetLabelSize(0.04);
  hemptySigma2->GetYaxis()->SetLabelSize(0.04);  
  
  TH2F* hemptyMean=new TH2F("hemptyMean","",50,0.,110.,10.,1.855,1.88);  
  hemptyMean->GetXaxis()->CenterTitle();
  hemptyMean->GetYaxis()->CenterTitle();
  hemptyMean->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hemptyMean->GetYaxis()->SetTitle("Mean (GeV/c^{2})");
  hemptyMean->GetXaxis()->SetTitleOffset(1.);
  hemptyMean->GetYaxis()->SetTitleOffset(1.4);
  hemptyMean->GetXaxis()->SetTitleSize(0.045);
  hemptyMean->GetYaxis()->SetTitleSize(0.05);
  hemptyMean->GetXaxis()->SetTitleFont(42);
  hemptyMean->GetYaxis()->SetTitleFont(42);
  hemptyMean->GetXaxis()->SetLabelFont(42);
  hemptyMean->GetYaxis()->SetLabelFont(42);
  hemptyMean->GetXaxis()->SetLabelSize(0.04);
  hemptyMean->GetYaxis()->SetLabelSize(0.04);  

  TCanvas* cYields = new TCanvas("cYields","",1000,1000);
  cYields->Divide(2,2);
  cYields->cd(1);
  hemptyMean->Draw();
  hMeanPP->SetLineWidth(2);
  hMeanPP->Draw("same");
  hMeanPPMC->SetLineColor(2);
  hMeanPPMC->SetLineWidth(2);
  hMeanPPMC->Draw("same");
  TLegend *legendMean=new TLegend(0.4958166,0.7558707,0.7949297,0.9299148,"");
  legendMean->SetBorderSize(0);
  legendMean->SetLineColor(0);
  legendMean->SetFillColor(0);
  legendMean->SetFillStyle(1001);
  legendMean->SetTextFont(42);
  legendMean->SetTextSize(0.045);
  TLegendEntry *ent_MeanPP=legendMean->AddEntry(hMeanPP,"Data","pf");
  ent_MeanPP->SetTextFont(42);
  ent_MeanPP->SetLineColor(1);
  TLegendEntry *ent_MeanPPMC=legendMean->AddEntry(hMeanPPMC,"MC","pf");
  ent_MeanPPMC->SetTextFont(42);
  ent_MeanPPMC->SetLineColor(2);
  legendMean->Draw("same");
  TLine* l = new TLine(5,1.865,100,1.865);
  l->SetLineWidth(2);
  l->SetLineStyle(2);
  l->Draw();
  cYields->cd(2);
  hemptySigma1->Draw();
  hSigmaGaus1PP->SetLineWidth(2);
  hSigmaGaus1PP->Draw("same");
  hSigmaGaus1PPMC->SetLineColor(2);
  hSigmaGaus1PPMC->SetLineWidth(2);
  hSigmaGaus1PPMC->Draw("same");
  TLegend *legendSigma1=new TLegend(0.4958166,0.7558707,0.7949297,0.9299148,"");
  legendSigma1->SetBorderSize(0);
  legendSigma1->SetLineColor(0);
  legendSigma1->SetFillColor(0);
  legendSigma1->SetFillStyle(1001);
  legendSigma1->SetTextFont(42);
  legendSigma1->SetTextSize(0.045);
  TLegendEntry *ent_Sigma1PP=legendSigma1->AddEntry(hSigmaGaus1PP,"Data","pf");
  ent_Sigma1PP->SetTextFont(42);
  ent_Sigma1PP->SetLineColor(1);
  TLegendEntry *ent_Sigma1PPMC=legendSigma1->AddEntry(hSigmaGaus1PPMC,"MC","pf");
  ent_Sigma1PPMC->SetTextFont(42);
  ent_Sigma1PPMC->SetLineColor(2);
  legendSigma1->Draw("same");

  cYields->cd(3);
  hemptySigma2->Draw();
  hSigmaGaus2PP->SetLineWidth(2);
  hSigmaGaus2PP->Draw("same");
  hSigmaGaus2PPMC->SetLineColor(2);
  hSigmaGaus2PPMC->SetLineWidth(2);
  hSigmaGaus2PPMC->Draw("same");
  TLegend *legendSigma2=new TLegend(0.4958166,0.7558707,0.7949297,0.9299148,"");
  legendSigma2->SetBorderSize(0);
  legendSigma2->SetLineColor(0);
  legendSigma2->SetFillColor(0);
  legendSigma2->SetFillStyle(1001);
  legendSigma2->SetTextFont(42);
  legendSigma2->SetTextSize(0.045);
  TLegendEntry *ent_Sigma2PP=legendSigma2->AddEntry(hSigmaGaus2PP,"Data","pf");
  ent_Sigma2PP->SetTextFont(42);
  ent_Sigma2PP->SetLineColor(1);
  TLegendEntry *ent_Sigma2PPMC=legendSigma2->AddEntry(hSigmaGaus2PPMC,"MC","pf");
  ent_Sigma2PPMC->SetTextFont(42);
  ent_Sigma2PPMC->SetLineColor(2);
  legendSigma2->Draw("same");
  cYields->cd(4);
  hemptyRelMag->Draw();
  hRelMagnGaus1Gaus2PP->SetLineWidth(2);
  hRelMagnGaus1Gaus2PP->Draw("same");
  
  TH2F* hemptyClosure=new TH2F("hemptyClosure","",50,0.,100.,10.,0.7,1.3);  
  hemptyClosure->GetXaxis()->CenterTitle();
  hemptyClosure->GetYaxis()->CenterTitle();
  hemptyClosure->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hemptyClosure->GetYaxis()->SetTitle("Corr. yield/Gen");
  hemptyClosure->GetXaxis()->SetTitleOffset(1.);
  hemptyClosure->GetYaxis()->SetTitleOffset(1.4);
  hemptyClosure->GetXaxis()->SetTitleSize(0.045);
  hemptyClosure->GetYaxis()->SetTitleSize(0.05);
  hemptyClosure->GetXaxis()->SetTitleFont(42);
  hemptyClosure->GetYaxis()->SetTitleFont(42);
  hemptyClosure->GetXaxis()->SetLabelFont(42);
  hemptyClosure->GetYaxis()->SetLabelFont(42);
  hemptyClosure->GetXaxis()->SetLabelSize(0.04);
  hemptyClosure->GetYaxis()->SetLabelSize(0.04);  
  cYields->SaveAs("cYieldStudies.pdf");
  
  TCanvas* cClosure = new TCanvas("cClosure","",500,500);
  cClosure->cd(1);
  hemptyClosure->Draw();
  hClosure->SetLineWidth(2);
  hClosure->Draw("same");
  TLine* lunity = new TLine(5,1,100,1);
  lunity->SetLineWidth(2);
  lunity->SetLineStyle(2);
  lunity->Draw("same");
  cClosure->SaveAs("cClosure.pdf");

  }
Exemplo n.º 8
0
// ______________________________________________________________________________________
void plotVsEta_nice(const Char_t* name = "ratioVsEta") {

    gROOT->LoadMacro("include/toolsEtaNice.C++");

    SetupStyle();

    SetGlobals();

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

    TFile *inFiles[nEtaSets][nDataSets][nMoments];

    TGraphErrors *graphs[nEtaSets][nDataSets][nMoments];

    for (int idxEta = 0 ; idxEta < nEtaSets; ++idxEta)
        for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet)
            for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {
                inFiles[idxEta][idxDataSet][idxMoment] = TFile::Open(Form("output/%s/%s/Moments_%s.root",
                        aEtaSets[idxEta], aDataSets[idxDataSet], aMoments[idxMoment]));
                graphs[idxEta][idxDataSet][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEta][idxDataSet][idxMoment]->Get(aMoments[idxMoment]))->Clone());
                if (inFiles[idxEta][idxDataSet][idxMoment])
                    (inFiles[idxEta][idxDataSet][idxMoment])->Close();
            }

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

    TLegend *legRat[nDataSets];

    for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
        legRat[idxDataSet] = new TLegend(0.14, 0.12, 0.78, 0.27);
        legRat[idxDataSet]->SetTextAlign(12);
        legRat[idxDataSet]->SetTextSize(0.06);
        legRat[idxDataSet]->SetFillColor(1182);
        legRat[idxDataSet]->SetLineColor(0);
        legRat[idxDataSet]->SetBorderSize(0);
        legRat[idxDataSet]->SetNColumns(3);
    }

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

    TGraphErrors *etaGraphs[9][nEtaSuperSets][nDataSets][nMoments];

    for (int idxCent = 0; idxCent < nCent; idxCent++) {
        for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
            for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) {

                int idxEta = -1;
                for (int idxEtaSuper = 0 ; idxEtaSuper < nEtaSuperSets; ++idxEtaSuper) {
                    float x[aEtaSuperSets[idxEtaSuper]];
                    float y[aEtaSuperSets[idxEtaSuper]];
                    float ex[aEtaSuperSets[idxEtaSuper]];
                    float ey[aEtaSuperSets[idxEtaSuper]];

                    for (int idxEtaSub = 0 ; idxEtaSub < aEtaSuperSets[idxEtaSuper]; ++idxEtaSub) {
                        ++idxEta;

                        x[idxEtaSub]  = aEtaSetBinCenter[idxEta];
                        ex[idxEtaSub] = aEtaSetBinWidth[idxEta]/2.;
                        y[idxEtaSub]  = graphs[idxEta][idxDataSet][idxMoment]->GetY()[idxCent];
                        ey[idxEtaSub] = graphs[idxEta][idxDataSet][idxMoment]->GetEY()[idxCent];
                    } // for (int idxEtaSub = 0 ; idxEtaSub < aEtaSuperSets[idxEtaSuper]; ++idxEtaSub) {

                    etaGraphs[idxCent][idxEtaSuper][idxDataSet][idxMoment] = new TGraphErrors(aEtaSuperSets[idxEtaSuper], x, y, ex, ey);
                    PrepareGraph(etaGraphs[idxCent][idxEtaSuper][idxDataSet][idxMoment]);
                } // for (int idxEtaSuper = 0 ; idxEtaSuper < nEtaSuperSets; ++idxEtaSuper) {

            } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {
        } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
    } // for (int idxCent = 0; idxCent < 9; idxCent++) {

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

    for (int idxCent = 0; idxCent < 1; idxCent++) {
        for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
            TPad *pad = SetupCanvas(Form("canEta_Ratio_%s_%s", aDataSets[idxDataSet], cent[idxCent]), aDataSetsTitle[idxDataSet], "#eta", 0.45);

            for (int idxEtaSuper = 0 ; idxEtaSuper < nEtaSuperSets; ++idxEtaSuper) {

                if (idxEtaSuper == 1 || idxEtaSuper == 3 || idxEtaSuper == 5 || idxEtaSuper == 7 || idxEtaSuper == 8 )
                    continue;

                for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) {
                    pad->cd(idxMoment-3);

                    TGraphErrors *g = etaGraphs[idxCent][idxEtaSuper][idxDataSet][idxMoment];

                    // if (idxCent == 0)
                    //   ShiftGraphX(g, -0.015);
                    // else if (idxCent == 1)
                    //   ShiftGraphX(g, -0.005);
                    // else if (idxCent == 4)
                    //   ShiftGraphX(g, 0.005);
                    // else if (idxCent == 8)
                    //   ShiftGraphX(g, 0.015);

                    ConfigGraph(g, idxMoment, idxEtaSuper);

                    if (idxEtaSuper == 0) {
                        g->Draw("AP");

                        TLine *line05 = new TLine( 0.5, aMinY[idxMoment],  0.5, aMaxY[idxMoment]);
                        line05->SetLineColor(kGray+1);
                        line05->SetLineStyle(3);
                        line05->Draw();

                        TLine *line50 = new TLine(-0.5, aMinY[idxMoment], -0.5, aMaxY[idxMoment]);
                        line50->SetLineColor(kGray+1);
                        line50->SetLineStyle(3);
                        line50->Draw();

                        TLine *line00 = new TLine(0., aMinY[idxMoment],0, aMaxY[idxMoment]);
                        line00->SetLineColor(kGray+1);
                        line00->SetLineStyle(3);
                        line00->Draw();

                        if (idxMoment == 5) {
                            // TLine *line0 = new TLine(aMinX, 0, aMaxX, 0);
                            // line0->SetLineColor(kGray+1);
                            // line0->SetLineStyle(2);
                            // line0->SetLineWidth(2);
                            // line0->Draw();
                        }
                        else if (idxMoment == 6) {
                            TLine *line1 = new TLine(aMinX, 1, aMaxX, 1);
                            line1->SetLineColor(kGray+1);
                            line1->SetLineStyle(2);
                            line1->SetLineWidth(2);
                            line1->Draw();
                        }
                    }
                    g->Draw("PSAME");

                } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) {

                if (idxCent == 0)  {
                    legRat[idxDataSet]->AddEntry(etaGraphs[0][idxEtaSuper][idxDataSet][4],
                                                 Form("#Delta#eta = %.1f", aEtaSuperSetsBinWidth[idxEtaSuper]), "pl");
                }
            } // for (int idxEta = 0 ; idxEta < nEta; ++idxEta) {

            TLine *linex = new TLine(-0.55, 1, 0.55, 1);
            linex->SetLineColor(kGray+1);
            linex->SetLineStyle(2);
            linex->SetLineWidth(2);
            legRat[idxDataSet]->AddEntry(linex, "Poisson", "l");

            pad->cd(1);
            TLatex *texb_3 = new TLatex(-0.49, 9.3, "Au+Au collisions #sqrt{#it{s}_{NN}} = 14.5 GeV");
            texb_3->SetTextSize(0.07);
            texb_3->Draw("same");

            TLatex *texb_3a = new TLatex(-0.49,8.9, "Net-Charge, 0.2 < #it{p}_{T} (GeV/#it{c}) < 2.0, 0-5%");
            texb_3a->SetTextSize(0.07);
            texb_3a->Draw("same");

            pad->cd(2);
            TLatex *texb_3b = new TLatex(0.49,0.42, "statistical errors only");
            texb_3b->SetTextSize(0.06);
            texb_3b->SetTextAlign(31);
            texb_3b->Draw("same");

            TLatex *texb_3c = new TLatex(0.49,0.38, "horizontal error: #Delta#eta width");
            texb_3c->SetTextSize(0.06);
            texb_3c->SetTextAlign(31);
            texb_3c->Draw("same");

            TLatex *texb_4 = new TLatex(-0.49, 0.42, "STAR Preliminary");
            texb_4->SetTextSize(0.07);
            texb_4->Draw("same");

            pad->cd(3);
            legRat[idxDataSet]->Draw("lt");

            pad->Modified();
        } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) {
    } // for (int idxCent = 0; idxCent < 9; idxCent++) {

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

    SaveCanvas(name);
}
Exemplo n.º 9
0
void drawPlots( bool printgif = false ){
  
  TFile *f = TFile::Open("output/data_e_ttbarV1align_histos.root");

  //electron/muon eta
  TH1F * heleta_metlt20 = (TH1F*) f->Get("heleta_metlt20");
  TH1F * heleta_metgt30 = (TH1F*) f->Get("heleta_metgt30");
  TH1F * hmueta_metlt20 = (TH1F*) f->Get("hmueta_metlt20");
  TH1F * hmueta_metgt30 = (TH1F*) f->Get("hmueta_metgt30");

  TH1F * hdphijetmet_metgt30_ee = (TH1F*) f->Get("hdphijetmet_metgt30_ee");
  TH1F * hdphijetmet_metlt20_ee = (TH1F*) f->Get("hdphijetmet_metlt20_ee");
  TH1F * hdphijetmet_metgt30_mm = (TH1F*) f->Get("hdphijetmet_metgt30_mm");
  TH1F * hdphijetmet_metlt20_mm = (TH1F*) f->Get("hdphijetmet_metlt20_mm");


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

  TLegend *leg = new TLegend(0.7,0.7,0.95,0.9);
  leg->SetFillColor(0);
  leg->SetBorderSize(1);

  TLine line;
  line.SetLineColor(6);

  c1->cd(1);
  heleta_metlt20->Rebin(10);
  heleta_metlt20->SetTitle("");
  heleta_metgt30->Rebin(10);
  heleta_metlt20->SetLineColor(4);
  heleta_metlt20->Draw("hist");
  heleta_metgt30->SetLineColor(2);
  heleta_metgt30->SetMarkerColor(2);
  heleta_metlt20->SetMarkerSize(0);
  heleta_metgt30->Draw("sameE1");
  heleta_metlt20->GetXaxis()->SetRangeUser(-3,3);
  leg->AddEntry(heleta_metlt20,"tcmet < 20 GeV");
  leg->AddEntry(heleta_metgt30,"tcmet > 30 GeV");
  line.DrawLine(-1.479,0,-1.479,1.05*heleta_metlt20->GetMaximum());
  line.DrawLine(1.479, 0, 1.479,1.05*heleta_metlt20->GetMaximum());
  leg->Draw();

  c1->cd(2);
  hmueta_metlt20->Rebin(10);
  hmueta_metlt20->SetTitle("");
  hmueta_metgt30->Rebin(10);
  hmueta_metlt20->SetLineColor(4);
  hmueta_metlt20->Draw("hist");
  hmueta_metgt30->SetLineColor(2);
  hmueta_metgt30->SetMarkerColor(2);
  hmueta_metgt30->Draw("sameE1");
  hmueta_metlt20->GetXaxis()->SetRangeUser(-3,3);
  leg->Draw();

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

  c2->cd(1);
  hdphijetmet_metlt20_ee->Rebin(5);
  hdphijetmet_metlt20_ee->SetTitle("ee");
  hdphijetmet_metlt20_ee->GetXaxis()->SetTitle("#Delta#phi(jet,tcmet)");
  hdphijetmet_metgt30_ee->Rebin(5);
  hdphijetmet_metlt20_ee->SetLineColor(4);
  hdphijetmet_metlt20_ee->Draw("hist");
  hdphijetmet_metgt30_ee->SetLineColor(2);
  hdphijetmet_metgt30_ee->SetMarkerColor(2);
  hdphijetmet_metlt20_ee->SetMarkerSize(0);
  hdphijetmet_metgt30_ee->Draw("sameE1");
  hdphijetmet_metlt20_ee->GetXaxis()->SetRangeUser(-3,3);
  leg->Draw();

  c2->cd(2);
  hdphijetmet_metlt20_mm->Rebin(5);
  hdphijetmet_metlt20_mm->SetTitle("#mu#mu");
  hdphijetmet_metlt20_mm->GetXaxis()->SetTitle("#Delta#phi(jet,tcmet)");
  hdphijetmet_metgt30_mm->Rebin(5);
  hdphijetmet_metlt20_mm->SetLineColor(4);
  hdphijetmet_metlt20_mm->Draw("hist");
  hdphijetmet_metgt30_mm->SetLineColor(2);
  hdphijetmet_metgt30_mm->SetMarkerColor(2);
  hdphijetmet_metlt20_mm->SetMarkerSize(0);
  hdphijetmet_metgt30_mm->Draw("sameE1");
  hdphijetmet_metlt20_mm->GetXaxis()->SetRangeUser(-3,3);
  leg->Draw();

  if( printgif ){

    c1->Modified();
    c1->Update();
    c1->Print("plots/lepeta.gif");

    c2->Modified();
    c2->Update();
    c2->Print("plots/dphijetmet.gif");
  }

}
Exemplo n.º 10
0
void feynman()
{
   //Draw Feynman diagrams
   //Author: Nik Berry 
  
  TString diagramName;
//  diagramName = "ttbardilepton";
  diagramName = "ttgammadilepton";
//  diagramName = "ttgammadileptonsinglephoton"; 

   TCanvas *c1 = new TCanvas("c1", "A canvas", 10,10, 600, 300);
   c1->Range(0, -40, 140, 100);
   Int_t linsav = gStyle->GetLineWidth();
   gStyle->SetLineWidth(3);
   TLatex t;
   t.SetTextAlign(22);
   t.SetTextSize(0.1);

   TCurlyLine *g;
   g = new TCurlyLine(10, 10, 30, 30); g->Draw(); 
   g = new TCurlyLine(10, 50, 30, 30); g->Draw();
   t.DrawLatex(7,10,"g");
   t.DrawLatex(7,50,"g");

   g  = new TCurlyLine(30, 30, 55, 30); g->Draw(); 
   t.DrawLatex(42.5, 39,"g");    
    
   TLine *l; 
   l = new TLine(55, 30, 75, 10); l->Draw();
   l = new TLine(55, 30, 75, 50); l->Draw();
   t.DrawLatex(65,14,"#bar{t}");
   t.DrawLatex(65,46,"t");

   TCurlyLine *W;
   W = new TCurlyLine(75,50,95,75); W->SetWavy(); W->Draw();
   t.DrawLatex(85,75,"W^{+}");
   
   l = new TLine(75,50,115,40); l->Draw();
   t.DrawLatex(85,40,"b");

   l = new TLine(95,75,115,65); l->Draw();
   l = new TLine(95,75,115,85); l->Draw();
   t.DrawLatex(120,65,"#nu_{e,#mu}");
   t.DrawLatex(120,85,"e^{+}#mu^{+}"); 

   W = new TCurlyLine(75,10,95,-15); W->SetWavy(); W->Draw();
   t.DrawLatex(85,-18,"W^{-}");
    
   l = new TLine(75,10,115,20); l->Draw(); 
   t.DrawLatex(85,22,"#bar{b}"); 
    
   l = new TLine(95,-15,115,-25); l->Draw();
   l = new TLine(95,-15,115,-10); l->Draw();
   t.DrawLatex(120,-25,"#bar{#nu}_{e,#mu}");
   t.DrawLatex(120,-10,"e^{-}#mu^{-}");

if(diagramName == "ttgammadileptonsinglephoton"){
   TCurlyLine* gamma;
   gamma = new TCurlyLine(65,40,80,95); gamma->SetWavy(); gamma->Draw();
   t.DrawLatex(69,75,"#gamma");
}

if(diagramName == "ttgammadilepton"){
   TCurlyLine* gamma;
   gamma = new TCurlyLine(65,40,80,95); gamma->SetWavy(); gamma->Draw(); //top
   gamma = new TCurlyLine(90,47,110,60); gamma->SetWavy(); gamma->Draw(); //b
   gamma = new TCurlyLine(85,0,105,7); gamma->SetWavy(); gamma->Draw(); //W
   gamma = new TCurlyLine(108,-11,125,15); gamma->SetWavy(); gamma->Draw();
   t.DrawLatex(69,75,"#gamma");
   t.DrawLatex(112,55,"#gamma");
   t.DrawLatex(108,6,"#gamma");
   t.DrawLatex(127,15,"#gamma");
}

//   TLine * l;
//   l = new TLine(10, 10, 30, 30); l->Draw();
//   l = new TLine(10, 50, 30, 30); l->Draw();
//   TCurlyArc *ginit = new TCurlyArc(30, 30, 12.5*sqrt(2), 135, 225);
//   ginit->SetWavy();
//   ginit->Draw();
//   t.DrawLatex(7,6,"e^{-}");
//   t.DrawLatex(7,55,"e^{+}");
//   t.DrawLatex(7,30,"#gamma");

//   TCurlyLine *gamma = new TCurlyLine(30, 30, 55, 30);
//   gamma->SetWavy();
//   gamma->Draw();
//   t.DrawLatex(42.5,37.7,"#gamma");

//   TArc *a = new TArc(70, 30, 15);
//   a->Draw();
//   t.DrawLatex(55, 45,"#bar{q}");
//   t.DrawLatex(85, 15,"q");
//   TCurlyLine *gluon = new TCurlyLine(70, 45, 70, 15);
//   gluon->Draw();
//   t.DrawLatex(77.5,30,"g");

//    TCurlyLine *z0 = new TCurlyLine(85, 30, 110, 30);
//    z0->SetWavy();
//    z0->Draw();
//    t.DrawLatex(100, 37.5,"Z^{0}");
   
//   l = new TLine(110, 30, 130, 10); l->Draw();
//   l = new TLine(110, 30, 130, 50); l->Draw();

//   TCurlyArc *gluon1 = new TCurlyArc(110, 30, 12.5*sqrt(2), 315, 45);
//   gluon1->Draw();

//   t.DrawLatex(135,6,"#bar{q}");
//   t.DrawLatex(135,55,"q");
//   t.DrawLatex(135,30,"g");
   c1->Update();
   gStyle->SetLineWidth(linsav);
   c1->SaveAs("Plots/FeynmanDiagrams/" + diagramName + ".pdf");
   c1->SaveAs("Plots/FeynmanDiagrams/" + diagramName + ".png");
   c1->SaveAs("Plots/FeynmanDiagrams/" + diagramName + ".eps");
}
Exemplo n.º 11
0
int main(int argc, char** argv)
{
 
 gROOT->Reset();
 gROOT->SetStyle("Plain");
 gStyle->SetPalette(1);
 gStyle->SetOptStat(1111);
 gStyle->SetOptFit(111);
 
 TF1 gaussian("gaussian","-exp(-0.1*x) + exp(-0.2 * x)",0,50);
 
 TH1F histo("histo","histo",1000,0,50);
 histo.FillRandom("gaussian",100000);
 
 TCanvas cc("cc","cc",400,400);
 
 histo.SetLineColor(kRed);
 histo.Draw();
 
 std::cerr << "===== Get Neyman intervals ====" << std::endl;

 std::vector<double> band = getSigmaBands_FeldmanCousins (histo) ;
 
 
 std::cerr << "=======================" << std::endl;
 std::cerr << " " << band.at(0) << " <<  " << band.at(1) << " << " << band.at(2) << " << " << band.at(3) << " << " << band.at(4) << std::endl;
 std::cerr << "=======================" << std::endl;
 
 TLine* lVertLeft95 = new TLine(band.at(0),0,band.at(0),1000);
 lVertLeft95->SetLineColor(kBlue);
 lVertLeft95->SetLineWidth(2);
 lVertLeft95->SetLineStyle(5);
 
 TLine* lVertLeft68 = new TLine(band.at(1),0,band.at(1),1000);
 lVertLeft68->SetLineColor(kMagenta);
 lVertLeft68->SetLineWidth(2);
 lVertLeft68->SetLineStyle(5);
 
 TLine* lVertMiddle = new TLine(band.at(2),0,band.at(2),1000);
 lVertMiddle->SetLineColor(kGreen);
 lVertMiddle->SetLineWidth(2);
 lVertMiddle->SetLineStyle(5);
 
 TLine* lVertRight68 = new TLine(band.at(3),0,band.at(3),1000);
 lVertRight68->SetLineColor(kMagenta);
 lVertRight68->SetLineWidth(2);
 lVertRight68->SetLineStyle(5);

 TLine* lVertRight95 = new TLine(band.at(4),0,band.at(4),1000);
 lVertRight95->SetLineColor(kBlue);
 lVertRight95->SetLineWidth(2);
 lVertRight95->SetLineStyle(5);
 
 
 lVertLeft95->Draw();
 lVertLeft68->Draw();
 lVertMiddle->Draw();
 lVertRight68->Draw();
 lVertRight95->Draw();
 
 cc.SaveAs("exampleBand.png");
 
 
 
  
  return 0;
}
Exemplo n.º 12
0
void makeMETPlots(){

  gStyle->SetOptFit(0);

  TChain *ch = new TChain("t");
  //ch->Add("../output/V00-02-09/highpt/LM6v2_smallTree.root");
  //ch->Add("../output/V00-02-00/LM4_baby.root");
  //ch->Add("../output/V00-02-16/highpt/LM6v2_smallTree_gen_TEMP.root");
  ch->Add("../output/V00-02-18/highpt/LM6v2_smallTree_gen.root");

  vector<TCut> metcuts;
  vector<float> metcutvals;

  metcuts.push_back(TCut("pfmet>200")); metcutvals.push_back(200);
  metcuts.push_back(TCut("pfmet>275")); metcutvals.push_back(275);

  //TCut sel("njets>=2 && ht>100 && !passz");
  TCut sel("foundPair==1 && reco1==1 && reco2==1 && ht>100 && htgen2>100 && ngenjets>=2");

  const unsigned int n = metcuts.size();

  TH1F* hpass[n];
  TH1F* hall[n];

  for( unsigned int i = 0 ; i < metcuts.size() ; ++i){

    hpass[i]   = new TH1F(Form("hpass_%i",i),Form("hpass_%i",i),25,0,500);
    hall[i]    = new TH1F(Form("hall_%i",i), Form("hall_%i",i) ,25,0,500);

    ch->Draw(Form("genmet>>hpass_%i",i),sel+metcuts.at(i));
    ch->Draw(Form("genmet>>hall_%i",i)  ,sel);

  }




  TCanvas *can = new TCanvas();
  can->cd();
  gPad->SetRightMargin(0.1);
  gPad->SetTopMargin(0.1);
  gPad->SetGridx();
  gPad->SetGridy();  
  gStyle->SetOptFit(0);

  TGraphAsymmErrors* gr[n];  
  TLegend *leg = new TLegend(0.6,0.2,0.87,0.4);
  leg->SetFillColor(0);
  leg->SetBorderSize(1);
  leg->SetTextSize(0.03);

  TF1* erf[n];

  TLine line;
  line.SetLineWidth(2);
  line.SetLineStyle(2);

  for( unsigned int i = 0 ; i < metcuts.size() ; ++i){

    //can[i] = new TCanvas(Form("can_%i",i),Form("can_%i",i),500,500);
    //can[i]->cd();
    
    // TF1* efunc = new TF1("efitf", fitf, 0, 500, 3);
    // efunc->SetParameters(1, 100, 10);
    // efunc->SetParNames("norm", "offset", "width");

    erf[i] = new TF1("efitf", fitf, 0, 500, 3);
    erf[i]->SetParameters(1, 100, 30);
    erf[i]->SetParNames("norm", "offset", "width");
    erf[i]->SetLineWidth(2);
    //erf[i]->FixParameter(0,1);

    //erf[i] = new TF1(Form("erf_%i",i),mfitf,0,400);

    //erf[i]->SetParameter(0,100*(i+1));
    //erf[i]->SetParameter(1,10);

    gr[i] = new TGraphAsymmErrors();
    if( i==0 ){
      erf[i]->SetLineColor(1);
      line.SetLineColor(1);
    }

    if( i==1 ){
      line.SetLineColor(2);
      gr[i]->SetLineColor(2);
      gr[i]->SetMarkerColor(2);
      gr[i]->SetMarkerStyle(21);
      erf[i]->SetLineColor(2);
    }
    if( i==2 ){
      gr[i]->SetLineColor(4);
      gr[i]->SetMarkerColor(4);
      gr[i]->SetMarkerStyle(25);
      erf[i]->SetLineColor(4);
    }

    leg->AddEntry(gr[i],Form("E_{T}^{miss}>%.0f GeV",metcutvals.at(i)),"p");

    gr[i]->GetXaxis()->SetRangeUser(0,500);
    gr[i]->GetXaxis()->SetTitle("generator-level E_{T}^{miss} (GeV)");
    gr[i]->GetYaxis()->SetTitle("efficiency");
    gr[i]->SetMaximum(1);
    gr[i]->BayesDivide(hpass[i],hall[i]);

    //gr[i]->Fit(efunc,"R");
    gr[i]->Fit(erf[i],"R");


    if( i==0 ) gr[i]->Draw("AP");
    else       gr[i]->Draw("sameP");

    gr[i]->GetXaxis()->SetRangeUser(0,500);
    gr[i]->GetXaxis()->SetTitle("generator-level E_{T}^{miss} (GeV)");
    gr[i]->GetYaxis()->SetTitle("efficiency");

    line.DrawLine(metcutvals.at(i),0,metcutvals.at(i),1);
    //erf[i]->Draw("same");
  }

  leg->Draw();



  TLatex *t = new TLatex();
  t->SetNDC();
  t->SetTextSize(0.05);
  t->DrawLatex(0.25,0.92,"CMS Simulation, #sqrt{s} = 7 TeV");


  can->Print("../plots/met_turnon_LM6.pdf");





}
Exemplo n.º 13
0
//================================================
void eventBinning(const Int_t save = 0)
{
  TH1F *hVtxZ = (TH1F*)f->Get(Form("mhVertexZ_%s",trigName[kTrigType]));
  c = draw1D(hVtxZ,"",kFALSE,kFALSE);
  for(int i=0; i<19; i++)
    {
      double value = -100 + i*10 + 10;
      double height = hVtxZ->GetBinContent(hVtxZ->FindFixBin(value));
      TLine *line = GetLine(value,0,value,height,2,1,1);
      line->Draw();
    }
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.png",run_type,run_cfg_name.Data()));
    }

  TH1F *hgRefMultCorr = (TH1F*)f->Get(Form("mhgRefMultCorr_%s",trigName[kTrigType]));
  c = draw1D(hgRefMultCorr,"",kTRUE,kFALSE);
  //double bounds[9] = {472,401,283,193,126,77,44,23,11};
  double bounds[16] = {11,16,23,32,44,59,77,99,126,157,193,235,283,338,401,472};
  for(int i=0; i<16; i++)
    {
      double value = bounds[i];
      double height = hgRefMultCorr->GetBinContent(hgRefMultCorr->FindFixBin(value));
      TLine *line = GetLine(value,0,value,height,2,1,1);
      line->Draw();
    }
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.png",run_type,run_cfg_name.Data()));
    }

  // centrality
  TH1F *hgRefMult = (TH1F*)f->Get(Form("mhgRefMult_%s",trigName[kTrigType]));
  hgRefMult->SetLineColor(2);
  c = draw1D(hgRefMult,"",kTRUE,kFALSE);
  hgRefMultCorr->Draw("sames HIST");
  TLegend *leg = new TLegend(0.15,0.3,0.4,0.5);
  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->SetTextSize(0.04);
  leg->AddEntry(hgRefMult,"Raw gRefMult","L");
  leg->AddEntry(hgRefMultCorr,"Corrected gRefMult","L");
  leg->Draw();
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.png",run_type,run_cfg_name.Data()));
    }


  TH1F *hCentrality = (TH1F*)f->Get(Form("mhCentrality_%s",trigName[kTrigType]));
  c = draw1D(hCentrality,"",kTRUE,kFALSE);
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.png",run_type,run_cfg_name.Data()));
    }

  // event plane
  TH2F *hExcVsIncRawEP = (TH2F*)f->Get(Form("mhExcVsIncRawEP_%s",trigName[kTrigType]));
  c = draw2D(hExcVsIncRawEP);

  TH1F *hEventPlane = (TH1F*)f->Get(Form("mhEventPlane_%s",trigName[kTrigType]));
  c = draw1D(hEventPlane,"",kFALSE,kFALSE);
}
Exemplo n.º 14
0
void doCarlosPlots() {
   
   TCanvas *c1 = new TCanvas("c1","Luminosity",200,10,700,500);

   // c1->SetFillColor(42);
   c1->SetGrid();
   // c1->GetFrame()->SetFillColor(21);
   // c1->GetFrame()->SetBorderSize(12);

   const Int_t n = 6;
   Float_t x[n]  = {0., 28., 54., 74., 91., 100.};
   // Float_t y[n]  = {8.0E29, 3.4E30, 2.5E31, 4.9E31, 5.1E31, 1.4E32};
   Float_t y[n]  = {8.0E29, 3.4E30, 2.5E31, 4.9E31, 5.1E31, 6.278E31};

   Float_t ex[n] = {.0001,.0001,.0001,.0001,.0001,.0001};
   Float_t ey[n] = {0.,0.,0.,0.,0.,0.};

   Float_t y2[n]  = {0., 2., 15., 40.,70.,99.7};

   Float_t xd[2]  = {0., 100.};
   Float_t yd[2]  = {-10000.,1500000.};
   Float_t yd2[2]  = {0.001,0.3};

   Float_t exd[n] = {.0001,.0001};
   Float_t eyd[n] = {0.,0.}; 

   TGraphErrors *gr3 = new TGraphErrors(n,x,y,ex,ey);    
   gr3->SetMarkerColor(2);
   gr3->SetLineColor(2);
   gr3->SetLineWidth(3);
   gr3->SetMarkerStyle(20);
   gr3->SetMinimum(-2.E30);
   gr3->GetXaxis()->SetTitle("Time (days)");
   gr3->GetYaxis()->SetTitle("L_{inst} (cm^{-2} s^{-1})");
   gr3->Draw("ALP");

   TLine *hline = new TLine(-10.,1E31,36.,1E31);
   hline->SetLineColor(4);
   hline->SetLineWidth(3);
   hline->Draw("SAME");
   TLine *vline = new TLine(36.,-2E30,36.,1E31);
   vline->SetLineColor(4);
   vline->SetLineWidth(3);
   vline->Draw("SAME");

   c1->Update();
   c1->SaveAs("LumiInst.gif");

   TGraphErrors *gr2 = new TGraphErrors(n,x,y2,ex,ey);
   gr2->SetMarkerColor(2);     
   gr2->SetMinimum(-5.0);
   gr2->SetMaximum(110.0);
   gr2->SetMarkerStyle(20);
   gr2->GetXaxis()->SetTitle("Time (days)");
   gr2->GetYaxis()->SetTitle("L_{integ} (pb^{-1})");
   gr2->Draw("AP");

   TF1 *ftotal = new TF1("ftotal","myFunc(x)",0.,101.); 
   ftotal->SetLineWidth(3);
   ftotal->SetLineColor(2);
   ftotal->Draw("SAME");

   TLine *hline2 = new TLine(-10.,3.85,36.,3.85);
   hline2->SetLineColor(4);
   hline2->SetLineWidth(3);
   hline2->Draw("SAME");
   TLine *vline2 = new TLine(36.,-5.0,36.,3.85);
   vline2->SetLineColor(4);
   vline2->SetLineWidth(3);
   vline2->Draw("SAME");

   c1->Update();
   c1->SaveAs("LumiInteg.gif");
   c1->SetLogy();
   c1->Update();
   c1->SaveAs("LumiIntegLog.gif");

   TCanvas *c2 = new TCanvas("c2","Events",300,100,700,500);  
   c2->cd();
   c2->SetGrid();
 
   TGraphErrors *gr4 = new TGraphErrors(2,xd,yd,exd,eyd);   // DUMMY
   gr4->SetMarkerColor(kWhite);     
   gr4->GetXaxis()->SetTitle("Time (days)");
   gr4->GetYaxis()->SetTitle("N (prompt J/#psi reco)");
  
   TLine *vline3 = new TLine(36.,-20000.0,36.,900000.);  // MENU CHANGE
   vline3->SetLineColor(kMagenta);
   vline3->SetLineStyle(kDashed);
   vline3->SetLineWidth(2);
 
   /// FUNCTIONS: HLTMu3
   TF1 *fhighHLTMu3 = new TF1("fhighHLTMu3","23887*myFunc(x)",0.,36.);
   fhighHLTMu3->SetLineWidth(4);
   fhighHLTMu3->SetLineColor(2);
   TF1 *fmediumHLTMu3 = new TF1("fmediumHLTMu3","30993*myFunc(x)",0.,36.);
   fmediumHLTMu3->SetLineWidth(2);
   fmediumHLTMu3->SetLineColor(4);
   TF1 *flowHLTMu3 = new TF1("flowHLTMu3","66119*myFunc(x)",0.,36.);
   flowHLTMu3->SetLineWidth(2);
   flowHLTMu3->SetLineColor(3);
   TF1 *ftotalHLTMu3 = new TF1("ftotalHLTMu3","121000*myFunc(x)",0.,36.);
   ftotalHLTMu3->SetLineWidth(4);
   ftotalHLTMu3->SetLineColor(1);
   ///
   /// FUNCTIONS: HLTMu5
   TF1 *fhighHLTMu5 = new TF1("fhighHLTMu5","491*myFunc(x)+90309",36.,100.);
   fhighHLTMu5->SetLineWidth(4);
   fhighHLTMu5->SetLineColor(2);
   TF1 *fmediumHLTMu5 = new TF1("fmediumHLTMu5","475*myFunc(x)+117799",36.,100.);
   fmediumHLTMu5->SetLineWidth(2);
   fmediumHLTMu5->SetLineColor(4);
   TF1 *flowHLTMu5 = new TF1("flowHLTMu5","1112*myFunc(x)+250927",36.,100.);
   flowHLTMu5->SetLineWidth(2);
   flowHLTMu5->SetLineColor(3);
   TF1 *ftotalHLTMu5 = new TF1("ftotalHLTMu5","2078*myFunc(x)+459038",36.,100.);
   ftotalHLTMu5->SetLineWidth(4);
   ftotalHLTMu5->SetLineColor(1);
   ///
   /// FUNCTIONS: HLTMu9
   TF1 *fhighHLTMu9 = new TF1("fhighHLTMu9","2430*myFunc(x)+82824",36.,100.);
   fhighHLTMu9->SetLineWidth(4);
   fhighHLTMu9->SetLineColor(2);
   TF1 *fmediumHLTMu9 = new TF1("fmediumHLTMu9","1401*myFunc(x)+114225",36.,100.);
   fmediumHLTMu9->SetLineWidth(2);
   fmediumHLTMu9->SetLineColor(4);
   TF1 *flowHLTMu9 = new TF1("flowHLTMu9","2833*myFunc(x)+244283",36.,100.);
   flowHLTMu9->SetLineWidth(2);
   flowHLTMu9->SetLineColor(3);
   TF1 *ftotalHLTMu9 = new TF1("ftotalHLTMu9","6664*myFunc(x)+441337",36.,100.);
   ftotalHLTMu9->SetLineWidth(4);
   ftotalHLTMu9->SetLineColor(1);
   ///
   /// FUNCTIONS: HLT2Mu3
   TF1 *fhighHLT2Mu3 = new TF1("fhighHLT2Mu3","10271*myFunc(x)+52258",36.,100.);
   fhighHLT2Mu3->SetLineWidth(4);
   fhighHLT2Mu3->SetLineColor(2);
   TF1 *fmediumHLT2Mu3 = new TF1("fmediumHLT2Mu3","1157*myFunc(x)+115167",36.,100.);
   fmediumHLT2Mu3->SetLineWidth(2);
   fmediumHLT2Mu3->SetLineColor(4);
   TF1 *flowHLT2Mu3 = new TF1("flowHLT2Mu3","52*myFunc(x)+255122",36.,100.);
   flowHLT2Mu3->SetLineWidth(2);
   flowHLT2Mu3->SetLineColor(3);
   TF1 *ftotalHLT2Mu3 = new TF1("ftotalHLT2Mu3","11480*myFunc(x)+422747",36.,100.);
   ftotalHLT2Mu3->SetLineWidth(4);
   ftotalHLT2Mu3->SetLineColor(1);
   ///
   
   /// FIRST PLOT: HLTMu3 + HLTMu5
   gr4->Draw("AP");
   fhighHLTMu3->Draw("SAME"); 
   fmediumHLTMu3->Draw("SAME");
   flowHLTMu3->Draw("SAME");
   ftotalHLTMu3->Draw("SAME");
   fhighHLTMu5->Draw("SAME"); 
   fmediumHLTMu5->Draw("SAME");
   flowHLTMu5->Draw("SAME");
   ftotalHLTMu5->Draw("SAME");
   vline3->Draw("SAME"); 

   // LEGENDS
   leg = new TLegend(0.20,0.65,0.60,0.9);
   leg->AddEntry(fhighHLTMu3,"2 global muons","l");
   leg->AddEntry(fmediumHLTMu3,"1 global + 1 tracker muon","l");
   leg->AddEntry(flowHLTMu3,"1 global + 1 calo muon","l");
   leg->AddEntry(ftotalHLTMu3,"all muons","l");
   leg->AddEntry(vline3,"Trigger menu switch","l");
   leg->Draw("SAME");
   hltmu3 = new TPaveLabel(-5.,400000.,20.,550000.,"HLT_Mu3 (1x1)");
   hltmu3->SetTextColor(kMagenta);
   hltmu3->Draw("SAME");
   hltmu5 = new TPaveLabel(65.,1100000.,95.,1250000.,"HLT_Mu5 (25x1)");
   hltmu5->SetTextColor(kMagenta);
   hltmu5->Draw("SAME");

   c2->Update();
   c2->SaveAs("Njpsi_Mu3Mu5.gif");

   /// SECOND PLOT: HLTMu3 + HLTMu9
   gr4->Draw("AP");
   fhighHLTMu3->Draw("SAME"); 
   fmediumHLTMu3->Draw("SAME");
   flowHLTMu3->Draw("SAME");
   ftotalHLTMu3->Draw("SAME");
   fhighHLTMu9->Draw("SAME"); 
   fmediumHLTMu9->Draw("SAME");
   flowHLTMu9->Draw("SAME");
   ftotalHLTMu9->Draw("SAME");
   vline3->Draw("SAME"); 

   // LEGENDS
   leg->Draw("SAME");
   hltmu3->Draw("SAME");
   hltmu9 = new TPaveLabel(65.,1100000.,90.,1250000.,"HLT_Mu9 (1x1)");
   hltmu9->SetTextColor(kMagenta);
   hltmu9->Draw("SAME");

   c2->Update();
   c2->SaveAs("Njpsi_Mu3Mu9.gif");

   /// THIRD PLOT: HLTMu3 + HLT2Mu3
   gr4->Draw("AP");
   fhighHLTMu3->Draw("SAME"); 
   fmediumHLTMu3->Draw("SAME");
   flowHLTMu3->Draw("SAME");
   ftotalHLTMu3->Draw("SAME");
   fhighHLT2Mu3->Draw("SAME"); 
   fmediumHLT2Mu3->Draw("SAME");
   flowHLT2Mu3->Draw("SAME");
   ftotalHLT2Mu3->Draw("SAME");
   vline3->Draw("SAME"); 

   // LEGENDS
   leg->Draw("SAME");
   hltmu3->Draw("SAME");
   hltmu9 = new TPaveLabel(60.,1200000.,87.,1350000.,"HLT_2Mu3 (1x1)");
   hltmu9->SetTextColor(kMagenta);
   hltmu9->Draw("SAME");

   c2->Update();
   c2->SaveAs("Njpsi_Mu32Mu3.gif");

   // S/B
   TCanvas *c3 = new TCanvas("c3","Events",500,300,700,500);  
   c3->cd();
   c3->SetGrid();
   c3->SetLogy();
 
   TGraphErrors *grsb4 = new TGraphErrors(2,xd,yd2,exd,eyd);   // DUMMY
   grsb4->SetMarkerColor(kWhite);     
   grsb4->GetXaxis()->SetTitle("Time (days)");
   grsb4->GetYaxis()->SetTitle("sqrt(S+B)/S (prompt J/#psi reco)");
  
   TLine *vline6 = new TLine(36.,0.0,36.,0.3);  // MENU CHANGE
   vline6->SetLineColor(kMagenta);
   vline6->SetLineStyle(kDashed);
   vline6->SetLineWidth(2);
 
   /// FUNCTIONS: HLTMu3
   TF1 *sbhighHLTMu3 = new TF1("sbhighHLTMu3","sqrt(31649*myFunc(x))/(23887*myFunc(x))",0.,36.);
   sbhighHLTMu3->SetLineWidth(4);
   sbhighHLTMu3->SetLineColor(2);
   TF1 *sbmediumHLTMu3 = new TF1("sbmediumHLTMu3","sqrt(215502*myFunc(x))/(30993*myFunc(x))",0.,36.);
   sbmediumHLTMu3->SetLineWidth(2);
   sbmediumHLTMu3->SetLineColor(4);
   TF1 *sblowHLTMu3 = new TF1("sblowHLTMu3","sqrt(493892*myFunc(x))/(66119*myFunc(x))",0.,36.);
   sblowHLTMu3->SetLineWidth(2);
   sblowHLTMu3->SetLineColor(3);
   TF1 *sbtotalHLTMu3 = new TF1("sbtotalHLTMu3","sqrt(741043*myFunc(x))/(121000*myFunc(x))",0.,36.);
   sbtotalHLTMu3->SetLineWidth(4);
   sbtotalHLTMu3->SetLineColor(1);
   ///
   /// FUNCTIONS: HLTMu5
   TF1 *sbhighHLTMu5 = new TF1("sbhighHLTMu5","sqrt(636*myFunc(x)+119747)/(491*myFunc(x)+90309)",36.,100.);
   sbhighHLTMu5->SetLineWidth(4);
   sbhighHLTMu5->SetLineColor(2);
   TF1 *sbmediumHLTMu5 = new TF1("sbmediumHLTMu5","sqrt(3640*myFunc(x)+821259)/(475*myFunc(x)+117799)",36.,100.);
   sbmediumHLTMu5->SetLineWidth(2);
   sbmediumHLTMu5->SetLineColor(4);
   TF1 *sblowHLTMu5 = new TF1("sblowHLTMu5","sqrt(7050*myFunc(x)+1674140)/(1112*myFunc(x)+250927)",36.,100.);
   sblowHLTMu5->SetLineWidth(2);
   sblowHLTMu5->SetLineColor(3);
   TF1 *sbtotalHLTMu5 = new TF1("sbtotalHLTMu5","sqrt(11326*myFunc(x)+2615146)/(2078*myFunc(x)+459038)",36.,100.);
   sbtotalHLTMu5->SetLineWidth(4);
   sbtotalHLTMu5->SetLineColor(1);
   ///
   /// FUNCTIONS: HLTMu9
   TF1 *sbhighHLTMu9 = new TF1("sbhighHLTMu9","sqrt(3339*myFunc(x)+109315)/(2430*myFunc(x)+82824)",36.,100.);
   sbhighHLTMu9->SetLineWidth(4);
   sbhighHLTMu9->SetLineColor(2);
   TF1 *sbmediumHLTMu9 = new TF1("sbmediumHLTMu9","sqrt(17310*myFunc(x)+768495)/(1401*myFunc(x)+114225)",36.,100.);
   sbmediumHLTMu9->SetLineWidth(2);
   sbmediumHLTMu9->SetLineColor(4);
   TF1 *sblowHLTMu9 = new TF1("sblowHLTMu9","sqrt(12969*myFunc(x)+1856362)/(2833*myFunc(x)+244283)",36.,100.);
   sblowHLTMu9->SetLineWidth(2);
   sblowHLTMu9->SetLineColor(3);
   TF1 *sbtotalHLTMu9 = new TF1("sbtotalHLTMu9","sqrt(33438*myFunc(x)+2734172)/(6664*myFunc(x)+441337)",36.,100.);
   sbtotalHLTMu9->SetLineWidth(4);
   sbtotalHLTMu9->SetLineColor(1);
   ///
   /// FUNCTIONS: HLT2Mu3
   TF1 *sbhighHLT2Mu3 = new TF1("sbhighHLT2Mu3","sqrt(12498*myFunc(x)+73661)/(10271*myFunc(x)+52258)",36.,100.);
   sbhighHLT2Mu3->SetLineWidth(4);
   sbhighHLT2Mu3->SetLineColor(2);
   TF1 *sbmediumHLT2Mu3 = new TF1("sbmediumHLT2Mu3","sqrt(6702*myFunc(x)+809442)/(1157*myFunc(x)+115167)",36.,100.);
   sbmediumHLT2Mu3->SetLineWidth(2);
   sbmediumHLT2Mu3->SetLineColor(4);
   TF1 *sblowHLT2Mu3 = new TF1("sblowHLT2Mu3","sqrt(5233*myFunc(x)+1886327)/(52*myFunc(x)+255122)",36.,100.);
   sblowHLT2Mu3->SetLineWidth(2);
   sblowHLT2Mu3->SetLineColor(3);
   TF1 *sbtotalHLT2Mu3 = new TF1("sbtotalHLT2Mu3","sqrt(24433*myFunc(x)+2769430)/(11480*myFunc(x)+422747)",36.,100.);
   sbtotalHLT2Mu3->SetLineWidth(4);
   sbtotalHLT2Mu3->SetLineColor(1);
   ///
   
   /// FIRST PLOT: HLTMu3 + HLTMu5
   grsb4->Draw("AP");
   sbhighHLTMu3->Draw("SAME"); 
   sbmediumHLTMu3->Draw("SAME");
   sblowHLTMu3->Draw("SAME");
   sbtotalHLTMu3->Draw("SAME");
   sbhighHLTMu5->Draw("SAME"); 
   sbmediumHLTMu5->Draw("SAME");
   sblowHLTMu5->Draw("SAME");
   sbtotalHLTMu5->Draw("SAME");
   vline6->Draw("SAME"); 

   // LEGENDS
   leg = new TLegend(0.50,0.65,0.90,0.9);
   leg->AddEntry(sbhighHLTMu3,"2 global muons","l");
   leg->AddEntry(sbmediumHLTMu3,"1 global + 1 tracker muon","l");
   leg->AddEntry(sblowHLTMu3,"1 global + 1 calo muon","l");
   leg->AddEntry(sbtotalHLTMu3,"all muons","l");
   leg->AddEntry(vline6,"Trigger menu switch","l");
   leg->Draw("SAME");
   hltmu3 = new TPaveLabel(-5.,0.002,20.,0.004,"HLT_Mu3 (1x1)");
   hltmu3->SetTextColor(kMagenta);
   hltmu3->Draw("SAME");
   hltmu5 = new TPaveLabel(65.,0.02,95.,0.03,"HLT_Mu5 (25x1)");
   hltmu5->SetTextColor(kMagenta);
   hltmu5->Draw("SAME");

   c3->Update();
   c3->SaveAs("SBjpsi_Mu3Mu5.gif");

   /// SECOND PLOT: HLTMu3 + HLTMu9
   grsb4->Draw("AP");
   sbhighHLTMu3->Draw("SAME"); 
   sbmediumHLTMu3->Draw("SAME");
   sblowHLTMu3->Draw("SAME");
   sbtotalHLTMu3->Draw("SAME");
   sbhighHLTMu9->Draw("SAME"); 
   sbmediumHLTMu9->Draw("SAME");
   sblowHLTMu9->Draw("SAME");
   sbtotalHLTMu9->Draw("SAME");
   vline6->Draw("SAME"); 

   // LEGENDS
   leg->Draw("SAME");
   hltmu3->Draw("SAME");
   hltmu9 = new TPaveLabel(65.,0.02,90.,0.03,"HLT_Mu9 (1x1)");
   hltmu9->SetTextColor(kMagenta);
   hltmu9->Draw("SAME");

   c3->Update();
   c3->SaveAs("SBjpsi_Mu3Mu9.gif");

   /// THIRD PLOT: HLTMu3 + HLT2Mu3
   grsb4->Draw("AP");
   sbhighHLTMu3->Draw("SAME"); 
   sbmediumHLTMu3->Draw("SAME");
   sblowHLTMu3->Draw("SAME");
   sbtotalHLTMu3->Draw("SAME");
   sbhighHLT2Mu3->Draw("SAME"); 
   sbmediumHLT2Mu3->Draw("SAME");
   sblowHLT2Mu3->Draw("SAME");
   sbtotalHLT2Mu3->Draw("SAME");
   vline6->Draw("SAME"); 

   // LEGENDS
   leg->Draw("SAME");
   hltmu3->Draw("SAME");
   hltmu9 = new TPaveLabel(60.,0.02,87.,0.03,"HLT_2Mu3 (1x1)");
   hltmu9->SetTextColor(kMagenta);
   hltmu9->Draw("SAME");

   c3->Update();
   c3->SaveAs("SBjpsi_Mu32Mu3.gif"); 

   // S/B (pt < 6)
   TCanvas *c4 = new TCanvas("c4","Events",600,400,700,500);  
   c4->cd();
   c4->SetGrid();
   c4->SetLogy();

   /// FUNCTIONS: HLTMu3
   TF1 *sbpt6highHLTMu3 = new TF1("sbpt6highHLTMu3","sqrt(4301*myFunc(x))/(3301*myFunc(x))",0.,36.);
   sbpt6highHLTMu3->SetLineWidth(4);
   sbpt6highHLTMu3->SetLineColor(2);
   TF1 *sbpt6mediumHLTMu3 = new TF1("sbpt6mediumHLTMu3","sqrt(85523*myFunc(x))/(14660*myFunc(x))",0.,36.);
   sbpt6mediumHLTMu3->SetLineWidth(2);
   sbpt6mediumHLTMu3->SetLineColor(4);
   TF1 *sbpt6lowHLTMu3 = new TF1("sbpt6lowHLTMu3","sqrt(174973*myFunc(x))/(35700*myFunc(x))",0.,36.);
   sbpt6lowHLTMu3->SetLineWidth(2);
   sbpt6lowHLTMu3->SetLineColor(3);
   TF1 *sbpt6totalHLTMu3 = new TF1("sbpt6totalHLTMu3","sqrt(264797*myFunc(x))/(53661*myFunc(x))",0.,36.);
   sbpt6totalHLTMu3->SetLineWidth(4);
   sbpt6totalHLTMu3->SetLineColor(1);
   /// FUNCTIONS: HLTMu5 (NON PRESCALED)
   TF1 *sbpt6highHLTMu5 = new TF1("sbpt6highHLTMu5","sqrt(402*myFunc(x)+15050)/(311*myFunc(x)+11541)",36.,100.);
   sbpt6highHLTMu5->SetLineWidth(4);
   sbpt6highHLTMu5->SetLineColor(2);
   TF1 *sbpt6mediumHLTMu5 = new TF1("sbpt6mediumHLTMu5","sqrt(10083*myFunc(x)+291198)/(2902*myFunc(x)+45385)",36.,100.);
   sbpt6mediumHLTMu5->SetLineWidth(2);
   sbpt6mediumHLTMu5->SetLineColor(4);
   TF1 *sbpt6lowHLTMu5 = new TF1("sbpt6lowHLTMu5","sqrt(38740*myFunc(x)+525859)/(11650*myFunc(x)+92833)",36.,100.);
   sbpt6lowHLTMu5->SetLineWidth(2);
   sbpt6lowHLTMu5->SetLineColor(3);
   TF1 *sbpt6totalHLTMu5 = new TF1("sbpt6totalHLTMu5","sqrt(49225*myFunc(x)+832107)/(14863*myFunc(x)+149759)",36.,100.);
   sbpt6totalHLTMu5->SetLineWidth(4);
   sbpt6totalHLTMu5->SetLineColor(1);

   /// FIRST PLOT: HLTMu3 + HLTMu5
   grsb4->GetYaxis()->SetTitle("sqrt(S+B)/S (p_{T} < 6 GeV)");
   grsb4->Draw("AP");
   sbpt6highHLTMu3->Draw("SAME"); 
   sbpt6mediumHLTMu3->Draw("SAME");
   sbpt6lowHLTMu3->Draw("SAME");
   sbpt6totalHLTMu3->Draw("SAME");
   sbpt6highHLTMu5->Draw("SAME"); 
   sbpt6mediumHLTMu5->Draw("SAME");
   sbpt6lowHLTMu5->Draw("SAME");
   sbpt6totalHLTMu5->Draw("SAME");
   vline6->Draw("SAME"); 

   // LEGENDS
   leg->Draw("SAME");
   hltmu3->Draw("SAME");
   hltmu5 = new TPaveLabel(65.,0.02,90.,0.03,"HLT_Mu5 (1x1)");
   hltmu5->SetTextColor(kMagenta);
   hltmu5->Draw("SAME");

   c4->Update();
   c4->SaveAs("SBjpsi_Mu3Mu5_ptlt6.gif"); 

}
Exemplo n.º 15
0
//______________________________________________________________________________
void TAPSEnergy()
{
    // Main method.

    Char_t tmp[256];

    // load CaLib
    gSystem->Load("libCaLib.so");

    // general configuration
    Bool_t watch = kFALSE;
    const Char_t* data = "Data.TAPS.LG.E1";
    const Char_t* hName = "CaLib_TAPS_IM_Neut_1CB_1TAPS";
    //const Char_t* hName = "CaLib_TAPS_IM_Neut_2TAPS";
    Double_t yMin = 110;
    Double_t yMax = 160;

    // configuration
    const Char_t calibration[] = "LH2_May_18";
    const Char_t* fLoc = "$HOME/loc/presort/data/May_18";

    // create histogram
    gHOverview = new TH1F("Overview", "Overview", 40000, 0, 40000);
    TCanvas* cOverview = new TCanvas();
    gHOverview->GetYaxis()->SetRangeUser(yMin, yMax);
    gHOverview->Draw("E1");

    // create line
    gLine = new TLine();
    gLine->SetLineColor(kBlue);
    gLine->SetLineWidth(2);

    // init fitting function
    gFitFunc = 0;

    // create fitting canvas
    gCFit = new TCanvas();

    // get number of sets
    Int_t nSets = TCMySQLManager::GetManager()->GetNsets(data, calibration);

    // total number of runs
    Int_t nTotRuns = 0;

    // first and last runs
    Int_t first_run, last_run;

    // loop over sets
    for (Int_t i = 0; i < nSets; i++)
    {
        // get runs of set
        Int_t nRuns;
        Int_t* runs = TCMySQLManager::GetManager()->GetRunsOfSet(data, calibration, i, &nRuns);

        // loop over runs
        for (Int_t j = 0; j < nRuns; j++)
        {
            // save first and last runs
            if (i == 0 && j == 0) first_run = runs[j];
            if (i == nSets-1 && j == nRuns-1) last_run = runs[j];

            // clean-up
            if (gH) delete gH;
            if (gH2) delete gH2;
            if (gRFile) delete gRFile;
            gH = 0;
            gH2 = 0;
            gRFile = 0;

            // load ROOT file
            sprintf(tmp, "%s/ARHistograms_CBTaggTAPS_%d.root", fLoc, runs[j]);
            gRFile = new TFile(tmp);

            // check file
            if (!gRFile) continue;
            if (gRFile->IsZombie()) continue;

            // load histogram
            gH2 = (TH2*) gRFile->Get(hName);
            if (!gH2) continue;
            if (!gH2->GetEntries()) continue;

            // project histogram
            sprintf(tmp, "Proj_%d", runs[j]);
            gH = gH2->ProjectionX(tmp);

            // fit the histogram
            Fit(runs[j]);

            // update canvases and sleep
            if (watch)
            {
                cOverview->Update();
                gCFit->Update();
                gSystem->Sleep(50);
            }

            // count run
            nTotRuns++;
        }

        // clean-up
        delete runs;

        // draw runset markers
        cOverview->cd();

        // get first run of set
        Int_t frun = TCMySQLManager::GetManager()->GetFirstRunOfSet(data, calibration, i);

        // draw line
        TLine* aLine = new TLine(frun, yMin, frun, yMax);
        aLine->SetLineColor(kBlue);
        aLine->SetLineWidth(2);
        aLine->Draw("same");
    }

    // adjust axis
    gHOverview->GetXaxis()->SetRangeUser(first_run-10, last_run+10);

    TFile* fout = new TFile("runset_overview.root", "recreate");
    cOverview->Write();
    delete fout;

    printf("%d runs analyzed.\n", nTotRuns);

    gSystem->Exit(0);
}
Exemplo n.º 16
0
void drawCMSresponse() {

  // New style settings
  // #include "tdrstyle_mod14.C"
  setTDRStyle();
  // call cmsPrel(iPeriod, iPos);
  // int iPeriod = 2;    // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV 
  // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot
  // iPos=11 : top-left, left-aligned
  // iPos=33 : top-right, right-aligned
  // iPos=22 : center, centered
  // mode generally : 
  //   iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right)

  if (!_jec) {

    const char *sd = "CondFormats/JetMETObjects/data";
    const char *st = "Winter14_V5_MC";
    const char *s;

    //s = Form("%s/%s_L1FastJet_AK5PFchs.txt",sd,st); cout << s << endl;
    //JetCorrectorParameters *l1 = new JetCorrectorParameters(s);
    s = Form("%s/%s_L2Relative_AK5PFchs.txt",sd,st); cout << s << endl;
    JetCorrectorParameters *l2 = new JetCorrectorParameters(s);
    s = Form("%s/%s_L3Absolute_AK5PFchs.txt",sd,st); cout << s << endl;
    JetCorrectorParameters *l3 = new JetCorrectorParameters(s);

    vector<JetCorrectorParameters> v;
    //v.push_back(l1);
    v.push_back(*l2);
    v.push_back(*l3);
    _jec = new FactorizedJetCorrector(v);
  }
  if (!_jecpt) {
    _jecpt = new TF1("jecpt",fJECPt,0,4000,3);
  }

  //double ergs[] = {30, 60, 110, 400, 2000};
  //const int ne = sizeof(ergs)/sizeof(ergs[0]);
  double pts[] = {10, 30, 100, 400, 2000};
  const int npt = sizeof(pts)/sizeof(pts[0]);
  const int neta = 48;//52;
  const int jeta = TMath::Pi()*0.5*0.5;
  const int mu = 0;

  TGraph *gs[npt];
  //for (int ie = 0; ie != ne; ++ie) {
  for (int ipt = 0; ipt != npt; ++ipt) {

    //double energy = ergs[ie];
    double pt = pts[ipt];

    TGraph *g = new TGraph(0); gs[ipt] = g;
    for (int ieta = 0; ieta != neta; ++ieta) {
      
      double eta = (ieta+0.5)*0.1;
      //double pt = energy / cosh(eta);
      double energy = pt * cosh(eta);
      if (pt >= 10. && energy < 4000.) {

	double jes = getResp(pt, eta, jeta, mu);
	int n = g->GetN();
	g->SetPoint(n, eta, jes);
      }
    } // for ie
  } // for ieta


  // Draw results
  TH1D *h = new TH1D("h",";Jet |#eta|;Simulated jet response",40,0,4.8);
  h->SetMaximum(1.25);
  h->SetMinimum(0.5);
  TCanvas *c1 = tdrCanvas("c1",h,2,0,kSquare);

  TLegend *leg1 = tdrLeg(0.25,0.25,0.55,0.30);
  TLegend *leg2 = tdrLeg(0.25,0.20,0.55,0.25);
  TLegend *leg3 = tdrLeg(0.25,0.15,0.55,0.20);
  TLegend *leg4 = tdrLeg(0.55,0.25,0.85,0.30);
  TLegend *leg5 = tdrLeg(0.55,0.20,0.85,0.25);
  TLegend *legs[npt] = {leg1, leg2, leg3, leg4, leg5};

  int colors[] = {kGreen+2, kBlack, kOrange+1, kBlue, kRed+1};
  int markers[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare,
		   kFullTriangleUp};

  for (int ipt = 0; ipt != npt; ++ipt) {
    
    TGraph *g = gs[ipt];
    g->SetMarkerColor(colors[ipt]);
    g->SetMarkerStyle(markers[ipt]);
    g->Draw("SAMEP");

    //TLegend *leg = (ie<3 ? leg1 : leg2);
    TLegend *leg = legs[ipt];
    leg->SetTextColor(colors[ipt]);
    //leg->AddEntry(g, Form("E = %1.0f GeV",ergs[ie]), "P");
    leg->AddEntry(g, Form("p_{T} = %1.0f GeV",pts[ipt]), "P");
  }


  TLatex *tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSize(0.045);
  
  TLine *l = new TLine();
  l->DrawLine(1.3,0.7,1.3,1.1);
  l->DrawLine(2.5,0.7,2.5,1.1);
  l->DrawLine(3.0,0.7,3.0,1.1);
  l->DrawLine(4.5,0.7,4.5,1.1);
  l->SetLineStyle(kDashed);
  l->DrawLine(3.2,0.7,3.2,1.1);

  tex->DrawLatex(0.30,0.86,"2012 JES: Anti-k_{t} R = 0.5, PF+CHS");

  tex->DrawLatex(0.19,0.78,"Barrel");
  tex->DrawLatex(0.47,0.78,"Endcap"); //0.42
  tex->DrawLatex(0.73,0.78,"Forward");

  tex->DrawLatex(0.21,0.73,"BB");
  tex->DrawLatex(0.43,0.73,"EC1");
  tex->DrawLatex(0.57,0.73,"EC2");
  tex->DrawLatex(0.77,0.73,"HF");

  c1->SaveAs("pdf/drawCMSresponse.pdf");
} // drawCMSresponse
Exemplo n.º 17
0
void sysChi2Cutoff(int n = 2, double e = 1.0){

  int norder_  = n;
  double tkEta = e;

  double ratioGamma1ExpMin = 0.0;
  double ratioGamma1ExpMax = 0.5;
  double ratioVn6Vn4Min    = 0.9;
  double ratioVn6Vn4Max    = 1.1;
  double ratioVn8Vn4Min    = 0.9;
  double ratioVn8Vn4Max    = 1.1;
  double ratioVn8Vn6Min    = 0.9;
  double ratioVn8Vn6Max    = 1.1;

  double chi2Min = 0.1;
  double chi2Max = 10000;

  double ratioMin = 0.98;
  double ratioMax = 1.02;

  TLatex latex;

  //-- Analyzer Output
  TFile * fAna;
  TH1D * hObs[NCENT];

  //-- Unfolding output
  TFile * fUnfold;
  TH1D * hUnfold[NCENT][NITER];
  TH1D * hRefold[NCENT][NITER];

  //-- Chi2 Refold vs iter
  TGraphErrors * grChi2NDFvsIter[NCENT];
  double chi2NDF[NCENT][NITER];

  //-- Stat Uncert Output
  TFile * fStat;
  TH1D * hVarianceOfMean_Vn2[NCHI2];
  TH1D * hVarianceOfMean_Vn4[NCHI2];
  TH1D * hVarianceOfMean_Vn6[NCHI2];
  TH1D * hVarianceOfMean_Vn8[NCHI2];
  TH1D * hVarianceOfMean_Gamma1Exp[NCHI2];
  TH1D * hVarianceOfMean_Vn6Vn4[NCHI2];
  TH1D * hVarianceOfMean_Vn8Vn4[NCHI2];
  TH1D * hVarianceOfMean_Vn8Vn6[NCHI2];
  TH1D * hVarianceOfMean_Vn46_Vn68[NCHI2];

  //-- Cumu vs chi2 Cutoff
  double unfold_Vn2VSChi2Cut[NCENT][NCHI2];
  double unfold_Vn4VSChi2Cut[NCENT][NCHI2];
  double unfold_Vn6VSChi2Cut[NCENT][NCHI2];
  double unfold_Vn8VSChi2Cut[NCENT][NCHI2];
  double unfold_Gamma1ExpVSChi2Cut[NCENT][NCHI2];
  double unfold_Vn6Vn4VSChi2Cut[NCENT][NCHI2];
  double unfold_Vn8Vn4VSChi2Cut[NCENT][NCHI2];
  double unfold_Vn8Vn6VSChi2Cut[NCENT][NCHI2];
  double unfold_Vn46_Vn68VSChi2Cut[NCENT][NCHI2];

  double unfold_Vn2VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn4VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn6VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn8VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Gamma1ExpVSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn6Vn4VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn8Vn4VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn8Vn6VSChi2Cut_staterr[NCENT][NCHI2];
  double unfold_Vn46_Vn68VSChi2Cut_staterr[NCENT][NCHI2];

  //-- Ratio to the Chi2=1 cutoff scenario
  double unfoldVn2_RatioToChi21[NCENT][NCHI2];
  double unfoldVn4_RatioToChi21[NCENT][NCHI2];
  double unfoldVn6_RatioToChi21[NCENT][NCHI2];
  double unfoldVn8_RatioToChi21[NCENT][NCHI2];
  double unfoldGamma1Exp_RatioToChi21[NCENT][NCHI2];
  double unfoldVn6Vn4_RatioToChi21[NCENT][NCHI2];
  double unfoldVn8Vn4_RatioToChi21[NCENT][NCHI2];
  double unfoldVn8Vn6_RatioToChi21[NCENT][NCHI2];
  double unfoldVn46_Vn68_RatioToChi21[NCENT][NCHI2];

  double unfoldVn2_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn4_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn6_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn8_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldGamma1Exp_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn6Vn4_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn8Vn4_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn8Vn6_RatioToChi21_staterr[NCENT][NCHI2];
  double unfoldVn46_Vn68_RatioToChi21_staterr[NCENT][NCHI2];

  bool iterCutoff[NCHI2];

  //-- Ratio chi2 = 2 / chi2 = 1 vs cent
  double ratioChi2_21_vn2[NCENT];
  double ratioChi2_21_vn4[NCENT];
  double ratioChi2_21_vn6[NCENT];
  double ratioChi2_21_vn8[NCENT];
  double ratioChi2_21_gamma1exp[NCENT];
  double ratioChi2_21_vn6vn4[NCENT];
  double ratioChi2_21_vn8vn4[NCENT];
  double ratioChi2_21_vn8vn6[NCENT];
  double ratioChi2_21_vn46_vn68[NCENT];

  double ratioChi2_21_vn2_staterr[NCENT];
  double ratioChi2_21_vn4_staterr[NCENT];
  double ratioChi2_21_vn6_staterr[NCENT];
  double ratioChi2_21_vn8_staterr[NCENT];
  double ratioChi2_21_gamma1exp_staterr[NCENT];
  double ratioChi2_21_vn6vn4_staterr[NCENT];
  double ratioChi2_21_vn8vn4_staterr[NCENT];
  double ratioChi2_21_vn8vn6_staterr[NCENT];
  double ratioChi2_21_vn46_vn68_staterr[NCENT];

  TGraphErrors * grRatioChi2_21_vn2;
  TGraphErrors * grRatioChi2_21_vn4;
  TGraphErrors * grRatioChi2_21_vn6;
  TGraphErrors * grRatioChi2_21_vn8;
  TGraphErrors * grRatioChi2_21_gamma1exp;
  TGraphErrors * grRatioChi2_21_vn6vn4;
  TGraphErrors * grRatioChi2_21_vn8vn4;
  TGraphErrors * grRatioChi2_21_vn8vn6;
  TGraphErrors * grRatioChi2_21_vn46_vn68;

  int finalIteration[NCENT][NCHI2];

  //
  // MAIN
  //

  setTDRStyle();
  latex.SetNDC();
  //gErrorIgnoreLevel = kWarning;

  //-- Get the Analyzer output file
  fAna = new TFile( "../../AnalyzerResults/CastleEbyE.root" );
  fUnfold = new TFile( Form("../../UnfoldResults/dataResp/data%i.root", norder_) );

  //-- Grab the statistical errors
  fStat = new TFile( Form("../../../../statErrorHandle/v%i/eta%.1f/systematicStudies/chi2Cutoff/StatUncertChi2Cutoff_v%i.root", norder_, tkEta, norder_) );
  for(int ichi = 0; ichi < NCHI2; ichi++){
    hVarianceOfMean_Vn2[ichi]       = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn2_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn4[ichi]       = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn4_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn6[ichi]       = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn6_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn8[ichi]       = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn8_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Gamma1Exp[ichi] = (TH1D*) fStat->Get( Form("hVarianceOfMean_Gamma1Exp_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn6Vn4[ichi]    = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn6Vn4_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn8Vn4[ichi]    = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn8Vn4_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn8Vn6[ichi]    = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn8Vn6_chi2Cut%.1f", chi2Cutoff[ichi]) );
    hVarianceOfMean_Vn46_Vn68[ichi] = (TH1D*) fStat->Get( Form("hVarianceOfMean_Vn46_Vn68_chi2Cut%.1f", chi2Cutoff[ichi]) );

    if( !hVarianceOfMean_Vn2[ichi] ) break;

    for(int icent = 0; icent < NCENT; icent++){
      unfold_Vn2VSChi2Cut_staterr[icent][ichi]       = sqrt( hVarianceOfMean_Vn2[ichi]->GetBinContent(icent+1) );
      unfold_Vn4VSChi2Cut_staterr[icent][ichi]       = sqrt( hVarianceOfMean_Vn4[ichi]->GetBinContent(icent+1) );
      unfold_Vn6VSChi2Cut_staterr[icent][ichi]       = sqrt( hVarianceOfMean_Vn6[ichi]->GetBinContent(icent+1) );
      unfold_Vn8VSChi2Cut_staterr[icent][ichi]       = sqrt( hVarianceOfMean_Vn8[ichi]->GetBinContent(icent+1) );
      unfold_Gamma1ExpVSChi2Cut_staterr[icent][ichi] = sqrt( hVarianceOfMean_Gamma1Exp[ichi]->GetBinContent(icent+1) );
      unfold_Vn6Vn4VSChi2Cut_staterr[icent][ichi]    = sqrt( hVarianceOfMean_Vn6Vn4[ichi]->GetBinContent(icent+1) );
      unfold_Vn8Vn4VSChi2Cut_staterr[icent][ichi]    = sqrt( hVarianceOfMean_Vn8Vn4[ichi]->GetBinContent(icent+1) );
      unfold_Vn8Vn6VSChi2Cut_staterr[icent][ichi]    = sqrt( hVarianceOfMean_Vn8Vn6[ichi]->GetBinContent(icent+1) );
      unfold_Vn46_Vn68VSChi2Cut_staterr[icent][ichi] = sqrt( hVarianceOfMean_Vn46_Vn68[ichi]->GetBinContent(icent+1) );
    }
  }

  if( !hVarianceOfMean_Vn2[0] ) {
    std::cout << "WARNING! Statistical resampling procedure not run!\n"
              << "Please run the procedure first and then run this macro\n"
              << "Exiting now..."
              << std::endl;
    exit(0);
  }

  //-- Start looping over the data...
  for(int icent = 0; icent < NCENT; icent++){

    //-- Get the VN observed histogram
    hObs[icent] = (TH1D*) fAna->Get( Form("qwebye/hVnFull_c%i", icent) );
    if( !hObs[icent] ) break;
    hObs[icent]->SetMaximum( 10.*hObs[icent]->GetMaximum() );

    //-- Reset the flags that say whether or no the chi2 cutoff has been reached
    for(int ichi = 0; ichi < NCHI2; ichi++) iterCutoff[ichi] = 0;

    //-- Loop over iterations
    for(int i = 0; i < NITER; i++){

      //-- Get the unfolded histograms
      hUnfold[icent][i] = (TH1D*) fUnfold->Get( Form("hreco%i_c%i", iter[i], icent) );
      if( !hUnfold[icent][i] ) break;
      hUnfold[icent][i]->SetLineColor(col[i]);
      hUnfold[icent][i]->SetMarkerColor(col[i]);

      //-- Get the Refolded histograms
      hRefold[icent][i] = (TH1D*) fUnfold->Get( Form("hrefold%i_c%i", iter[i], icent) );
      if( !hRefold[icent][i] ) break;
      hRefold[icent][i]->SetLineWidth(2);
      hRefold[icent][i]->SetLineColor(col[i]);
      hRefold[icent][i]->SetMarkerColor(col[i]);

      //-- Calculate the cumulants of each unfolded histogram
      FixUnfold( hUnfold[icent][i] );
      EbyECumu cumu(hUnfold[icent][i]);
      double vn2       = cumu.GetCumu_vn2();
      double vn4       = cumu.GetCumu_vn4();
      double vn6       = cumu.GetCumu_vn6();
      double vn8       = cumu.GetCumu_vn8();
      double gamma1exp = cumu.GetGamma1Exp();
      double vn6vn4;
      if(vn4 == 0) vn6vn4 = 0;
      else         vn6vn4 = vn6 / vn4;
      double vn8vn4;
      if(vn4 == 0) vn8vn4 = 0;
      else         vn8vn4 = vn8 / vn4;
      double vn8vn6;
      if(vn6 == 0) vn8vn6 = 0;
      else         vn8vn6 = vn8 / vn6;
      double vn46_vn68;
      if(vn4 == 0 || vn6 == 0 || vn8 == 0) vn46_vn68 = 0;
      else                                 vn46_vn68 = (vn4 - vn6)/(vn6 - vn8);

      //-- Calculate the refold chi2
      double chi2NDF_Refold = hRefold[icent][i]->Chi2Test(hObs[icent], "UWCHI2/NDF");
      chi2NDF[icent][i] = chi2NDF_Refold;

      //-- loop over the scenarios and choose the iteration for each
      for(int ichi = 0; ichi < NCHI2; ichi++){

	if( chi2NDF_Refold <= chi2Cutoff[ichi] && !iterCutoff[ichi] ){
	  unfold_Vn2VSChi2Cut[icent][ichi]         = vn2;
	  unfold_Vn4VSChi2Cut[icent][ichi]         = vn4;
	  unfold_Vn6VSChi2Cut[icent][ichi]         = vn6;
	  unfold_Vn8VSChi2Cut[icent][ichi]         = vn8;
	  unfold_Gamma1ExpVSChi2Cut[icent][ichi]   = gamma1exp;
	  unfold_Vn6Vn4VSChi2Cut[icent][ichi]      = vn6vn4;
	  unfold_Vn8Vn4VSChi2Cut[icent][ichi]      = vn8vn4;
	  unfold_Vn8Vn6VSChi2Cut[icent][ichi]      = vn8vn6;
	  unfold_Vn46_Vn68VSChi2Cut[icent][ichi]   = vn46_vn68;

	  iterCutoff[ichi] = 1;
	  finalIteration[icent][ichi] = i;
	}
	if( i == NITER-1 && !iterCutoff[ichi] ){
	  unfold_Vn2VSChi2Cut[icent][ichi]         = vn2;
          unfold_Vn4VSChi2Cut[icent][ichi]         = vn4;
          unfold_Vn6VSChi2Cut[icent][ichi]         = vn6;
	  unfold_Vn8VSChi2Cut[icent][ichi]         = vn8;
          unfold_Gamma1ExpVSChi2Cut[icent][ichi]   = gamma1exp;
          unfold_Vn6Vn4VSChi2Cut[icent][ichi]      = vn6vn4;
	  unfold_Vn8Vn4VSChi2Cut[icent][ichi]      = vn8vn4;
          unfold_Vn8Vn6VSChi2Cut[icent][ichi]      = vn8vn6;
	  unfold_Vn46_Vn68VSChi2Cut[icent][ichi]   = vn46_vn68;

	  iterCutoff[ichi] = 1;
	  finalIteration[icent][ichi] = i;
	}

      } //-- End chi2 scenario loop

    } //-- End unfold iteration loop

    //-- Ratio to the Chi2=1 cutoff scenario
    for(int ichi = 0; ichi < NCHI2; ichi++){

      double vn2_i  = unfold_Vn2VSChi2Cut[icent][ichi];
      double vn2_0  = unfold_Vn2VSChi2Cut[icent][0];
      double vn4_i  = unfold_Vn4VSChi2Cut[icent][ichi];
      double vn4_0  = unfold_Vn4VSChi2Cut[icent][0];
      double vn6_i  = unfold_Vn6VSChi2Cut[icent][ichi];
      double vn6_0  = unfold_Vn6VSChi2Cut[icent][0];
      double vn8_i  = unfold_Vn8VSChi2Cut[icent][ichi];
      double vn8_0  = unfold_Vn8VSChi2Cut[icent][0];

      double gamma1exp_i = unfold_Gamma1ExpVSChi2Cut[icent][ichi];
      double gamma1exp_0 = unfold_Gamma1ExpVSChi2Cut[icent][0];
      double vn6vn4_i    = unfold_Vn6Vn4VSChi2Cut[icent][ichi];
      double vn6vn4_0    = unfold_Vn6Vn4VSChi2Cut[icent][0];
      double vn8vn4_i    = unfold_Vn8Vn4VSChi2Cut[icent][ichi];
      double vn8vn4_0    = unfold_Vn8Vn4VSChi2Cut[icent][0];
      double vn8vn6_i    = unfold_Vn8Vn6VSChi2Cut[icent][ichi];
      double vn8vn6_0    = unfold_Vn8Vn6VSChi2Cut[icent][0];
      double vn46_vn68_i = unfold_Vn46_Vn68VSChi2Cut[icent][ichi];
      double vn46_vn68_0 = unfold_Vn46_Vn68VSChi2Cut[icent][0];

      double vn2Rat       = vn2_i / vn2_0;
      double vn4Rat       = vn4_i / vn4_0;
      double vn6Rat       = vn6_i / vn6_0;
      double vn8Rat       = vn8_i / vn8_0;
      double g1expRat     = gamma1exp_i / gamma1exp_0;
      double vn6vn4Rat    = vn6vn4_i / vn6vn4_0;
      double vn8vn4Rat    = vn8vn4_i / vn8vn4_0;
      double vn8vn6Rat    = vn8vn6_i / vn8vn6_0;
      double vn46_vn68Rat = vn46_vn68_i / vn46_vn68_0;

      double vn2_i_se  = unfold_Vn2VSChi2Cut_staterr[icent][ichi];
      double vn2_0_se  = unfold_Vn2VSChi2Cut_staterr[icent][0];
      double vn4_i_se  = unfold_Vn4VSChi2Cut_staterr[icent][ichi];
      double vn4_0_se  = unfold_Vn4VSChi2Cut_staterr[icent][0];
      double vn6_i_se  = unfold_Vn6VSChi2Cut_staterr[icent][ichi];
      double vn6_0_se  = unfold_Vn6VSChi2Cut_staterr[icent][0];
      double vn8_i_se  = unfold_Vn8VSChi2Cut_staterr[icent][ichi];
      double vn8_0_se  = unfold_Vn8VSChi2Cut_staterr[icent][0];

      double gamma1exp_i_se = unfold_Gamma1ExpVSChi2Cut_staterr[icent][ichi];
      double gamma1exp_0_se = unfold_Gamma1ExpVSChi2Cut_staterr[icent][0];
      double vn6vn4_i_se    = unfold_Vn6Vn4VSChi2Cut_staterr[icent][ichi];
      double vn6vn4_0_se    = unfold_Vn6Vn4VSChi2Cut_staterr[icent][0];
      double vn8vn4_i_se    = unfold_Vn8Vn4VSChi2Cut_staterr[icent][ichi];
      double vn8vn4_0_se    = unfold_Vn8Vn4VSChi2Cut_staterr[icent][0];
      double vn8vn6_i_se    = unfold_Vn8Vn6VSChi2Cut_staterr[icent][ichi];
      double vn8vn6_0_se    = unfold_Vn8Vn6VSChi2Cut_staterr[icent][0];
      double vn46_vn68_i_se = unfold_Vn46_Vn68VSChi2Cut_staterr[icent][ichi];
      double vn46_vn68_0_se = unfold_Vn46_Vn68VSChi2Cut_staterr[icent][0];

      double vn2Rat_staterr       = sqrt( pow(vn2_i_se/vn2_0, 2) + pow( vn2_i*vn2_0_se/vn2_0/vn2_0, 2) );
      double vn4Rat_staterr       = sqrt( pow(vn4_i_se/vn4_0, 2) + pow( vn4_i*vn4_0_se/vn4_0/vn4_0, 2) );
      double vn6Rat_staterr       = sqrt( pow(vn6_i_se/vn6_0, 2) + pow( vn6_i*vn6_0_se/vn6_0/vn6_0, 2) );
      double vn8Rat_staterr       = sqrt( pow(vn8_i_se/vn8_0, 2) + pow( vn8_i*vn8_0_se/vn8_0/vn8_0, 2) );
      double g1expRat_staterr     = sqrt( pow(gamma1exp_i_se/gamma1exp_0, 2) + pow( gamma1exp_i*gamma1exp_0_se/gamma1exp_0/gamma1exp_0, 2) );
      double vn6vn4Rat_staterr    = sqrt( pow(vn6vn4_i_se/vn6vn4_0, 2) + pow( vn6vn4_i*vn6vn4_0_se/vn6vn4_0/vn6vn4_0, 2) );
      double vn8vn4Rat_staterr    = sqrt( pow(vn8vn4_i_se/vn8vn4_0, 2) + pow( vn8vn4_i*vn8vn4_0_se/vn8vn4_0/vn8vn4_0, 2) );
      double vn8vn6Rat_staterr    = sqrt( pow(vn8vn6_i_se/vn8vn6_0, 2) + pow( vn8vn6_i*vn8vn6_0_se/vn8vn6_0/vn8vn6_0, 2) );
      double vn46_vn68Rat_staterr = sqrt( pow(vn46_vn68_i_se/vn46_vn68_0, 2) + pow( vn46_vn68_i*vn46_vn68_0_se/vn46_vn68_0/vn46_vn68_0, 2) );

      unfoldVn2_RatioToChi21[icent][ichi]        = vn2Rat;
      unfoldVn4_RatioToChi21[icent][ichi]        = vn4Rat;
      unfoldVn6_RatioToChi21[icent][ichi]        = vn6Rat;
      unfoldVn8_RatioToChi21[icent][ichi]        = vn8Rat;
      unfoldGamma1Exp_RatioToChi21[icent][ichi]  = g1expRat;
      unfoldVn6Vn4_RatioToChi21[icent][ichi]     = vn6vn4Rat;
      unfoldVn8Vn4_RatioToChi21[icent][ichi]     = vn8vn4Rat;
      unfoldVn8Vn6_RatioToChi21[icent][ichi]     = vn8vn6Rat;
      unfoldVn46_Vn68_RatioToChi21[icent][ichi]  = vn46_vn68Rat;

      unfoldVn2_RatioToChi21_staterr[icent][ichi]       = vn2Rat_staterr;
      unfoldVn4_RatioToChi21_staterr[icent][ichi]       = vn4Rat_staterr;
      unfoldVn6_RatioToChi21_staterr[icent][ichi]       = vn6Rat_staterr;
      unfoldVn8_RatioToChi21_staterr[icent][ichi]       = vn8Rat_staterr;
      unfoldGamma1Exp_RatioToChi21_staterr[icent][ichi] = g1expRat_staterr;
      unfoldVn6Vn4_RatioToChi21_staterr[icent][ichi]    = vn6vn4Rat_staterr;
      unfoldVn8Vn4_RatioToChi21_staterr[icent][ichi]    = vn8vn4Rat_staterr;
      unfoldVn8Vn6_RatioToChi21_staterr[icent][ichi]    = vn8vn6Rat_staterr;
      unfoldVn46_Vn68_RatioToChi21_staterr[icent][ichi] = vn46_vn68Rat_staterr;

    } //-- End chi2 loop for ratios


    //-- Set up all the wonderful graphs
    grChi2NDFvsIter[icent] = new TGraphErrors(NITER, diter, chi2NDF[icent], iterErr, iterErr); 
    formatGraph(grChi2NDFvsIter[icent], "Iteration", chi2Min, chi2Max, "#chi^{2}/NDF", 1, 20, Form("grChi2NDFvsIter_c%i", icent) );

  } //-- End cent loop

  if( !hObs[0] || !hUnfold[0][0] || !hRefold[0][0] ){
    std::cout << "WARNING! Unfolding procedure not run!\n"
              << "Please run the unfolding procedure first and then run this macro\n"
              << "Exiting now..."
              << std::endl;
    exit(0);
  }

  //gErrorIgnoreLevel = kError;

  //----------------------------------------------------------------------------------------------------
  //-- Chi2/NDF big plot

  TLine * l1 = new TLine(diter[0], 1.2, diter[NITER-1], 1.2);
  l1->SetLineColor(1);
  l1->SetLineWidth(2);
  l1->SetLineStyle(2);

  TCanvas * cChi2NDF_Big   = new TCanvas( "cChi2NDF_Big_%s", "cChi2NDF_Big_%s", 1500, 2000);
  cChi2NDF_Big->Divide(3,4);

  for(int icent = 0; icent < NCENT; icent++){
    cChi2NDF_Big->cd(icent+1);
    cChi2NDF_Big->cd(icent+1)->SetLogx();
    grChi2NDFvsIter[icent]->Draw("alp");
    formatGraph(grChi2NDFvsIter[icent], "Iteration", chi2Min, chi2Max, "#chi^{2}/NDF", 1, 20, Form("grChi2NDFvsIter_c%i", icent) );
    cChi2NDF_Big->cd(icent+1)->SetLogy();
    latex.DrawLatex(0.18, 0.88, Form("Cent %i - %i%s", cent_min[icent], cent_max[icent], "%"));
    l1->Draw("same");
  }

  cChi2NDF_Big->Update();
  cChi2NDF_Big->SaveAs( "../../plots/systematicStudies/cChi2NDF_Big.pdf" );


  //----------------------------------------------------------------------------------------------------
  //-- Ratio chi2 = 2 / chi2 = 1 vs cent
  double cErr[NCENT];
  for(int icent = 0; icent < NCENT; icent++){
    ratioChi2_21_vn2[icent]        = unfoldVn2_RatioToChi21[icent][3];
    ratioChi2_21_vn4[icent]        = unfoldVn4_RatioToChi21[icent][3];
    ratioChi2_21_vn6[icent]        = unfoldVn6_RatioToChi21[icent][3];
    ratioChi2_21_vn8[icent]        = unfoldVn8_RatioToChi21[icent][3];
    ratioChi2_21_gamma1exp[icent]  = fabs( 1.0 - unfoldGamma1Exp_RatioToChi21[icent][3] );
    ratioChi2_21_vn6vn4[icent]     = unfoldVn6Vn4_RatioToChi21[icent][3];
    ratioChi2_21_vn8vn4[icent]     = unfoldVn8Vn4_RatioToChi21[icent][3];
    ratioChi2_21_vn8vn6[icent]     = unfoldVn8Vn6_RatioToChi21[icent][3];
    ratioChi2_21_vn46_vn68[icent]  = unfoldVn46_Vn68_RatioToChi21[icent][3];

    std::cout<<ratioChi2_21_vn46_vn68[icent]<<std::endl;

    ratioChi2_21_vn2_staterr[icent]        = unfoldVn2_RatioToChi21_staterr[icent][3];
    ratioChi2_21_vn4_staterr[icent]        = unfoldVn4_RatioToChi21_staterr[icent][3];
    ratioChi2_21_vn6_staterr[icent]        = unfoldVn6_RatioToChi21_staterr[icent][3];
    ratioChi2_21_vn8_staterr[icent]        = unfoldVn8_RatioToChi21_staterr[icent][3];
    ratioChi2_21_gamma1exp_staterr[icent]  = fabs( unfoldGamma1Exp_RatioToChi21_staterr[icent][3] );
    ratioChi2_21_vn6vn4_staterr[icent]     = unfoldVn6Vn4_RatioToChi21_staterr[icent][3];
    ratioChi2_21_vn8vn4_staterr[icent]     = unfoldVn8Vn4_RatioToChi21_staterr[icent][3];
    ratioChi2_21_vn8vn6_staterr[icent]     = unfoldVn8Vn6_RatioToChi21_staterr[icent][3];
    ratioChi2_21_vn46_vn68_staterr[icent]  = unfoldVn46_Vn68_RatioToChi21_staterr[icent][3];

    cErr[icent] = 0;
  }

  grRatioChi2_21_vn2 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn2, cErr, ratioChi2_21_vn2_staterr);
  formatGraph(grRatioChi2_21_vn2, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{2} [#chi^{2}=2]/[#chi^{2}=1]", norder_), 1, 24, "grRatioChi2_21_vn2");
  grRatioChi2_21_vn4 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn4, cErr, ratioChi2_21_vn4_staterr);
  formatGraph(grRatioChi2_21_vn4, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{4} [#chi^{2}=2]/[#chi^{2}=1]", norder_), kSpring+4, 25, "grRatioChi2_21_vn4");
  grRatioChi2_21_vn6 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn6, cErr, ratioChi2_21_vn6_staterr);
  formatGraph(grRatioChi2_21_vn6, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{6} [#chi^{2}=2]/[#chi^{2}=1]", norder_), 6, 28, "grRatioChi2_21_vn6");
  grRatioChi2_21_vn8 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn8, cErr, ratioChi2_21_vn8_staterr);
  formatGraph(grRatioChi2_21_vn8, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{8} [#chi^{2}=2]/[#chi^{2}=1]", norder_), kOrange+7, 27, "grRatioChi2_21_vn8");

  grRatioChi2_21_gamma1exp = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_gamma1exp, cErr, ratioChi2_21_gamma1exp_staterr);
  formatGraph(grRatioChi2_21_gamma1exp, "Centrality %", ratioGamma1ExpMin, ratioGamma1ExpMax, "|1-#gamma_{1}^{exp} [#chi^{2}=2]/[#chi^{2}=1]|", 2, 20, "grRatioChi2_21_gamma1exp");
  grRatioChi2_21_vn6vn4 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn6vn4, cErr, ratioChi2_21_vn6vn4_staterr);
  formatGraph(grRatioChi2_21_vn6vn4, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{6}/v_{%i}{4} [#chi^{2}=2]/[#chi^{2}=1]", norder_, norder_), 4, 21, "grRatioChi2_21_vn6vn4");
  grRatioChi2_21_vn8vn4 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn8vn4, cErr, ratioChi2_21_vn8vn4_staterr);
  formatGraph(grRatioChi2_21_vn8vn4, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{8}/v_{%i}{4} [#chi^{2}=2]/[#chi^{2}=1]", norder_, norder_), kGreen+2, 34, "grRatioChi2_21_vn8vn4");
  grRatioChi2_21_vn8vn6 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn8vn6, cErr, ratioChi2_21_vn8vn6_staterr);
  formatGraph(grRatioChi2_21_vn8vn6, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{8}/v_{%i}{6} [#chi^{2}=2]/[#chi^{2}=1]", norder_, norder_), kViolet-1, 33, "grRatioChi2_21_vn8vn6");
  grRatioChi2_21_vn46_vn68 = new TGraphErrors(NCENT, centBinCenter, ratioChi2_21_vn46_vn68, cErr, ratioChi2_21_vn46_vn68_staterr);
  formatGraph(grRatioChi2_21_vn46_vn68, "Centrality %", 0.80, 1.20, Form("(v_{%i}{4} - v_{%i}{6})/(v_{%i}{6} - v_{%i}{8}) [#chi^{2}=2]/[#chi^{2}=1]", norder_, norder_, norder_, norder_), kGray+2, 22, "grRatioChi2_21_vn46_vn68");

  TLegend * leg2 = new TLegend(0.1946, 0.1995, 0.3452, 0.4157);
  leg2->SetFillStyle(0);
  leg2->SetBorderSize(0);
  leg2->AddEntry(grRatioChi2_21_vn2, Form("v_{%i}{%i}", norder_, 2), "lp");
  leg2->AddEntry(grRatioChi2_21_vn4, Form("v_{%i}{%i}", norder_, 4), "lp");
  leg2->AddEntry(grRatioChi2_21_vn6, Form("v_{%i}{%i}", norder_, 6), "lp");

  TLine * line = new TLine(grRatioChi2_21_vn2->GetXaxis()->GetXmin(), 1.0, grRatioChi2_21_vn2->GetXaxis()->GetXmax(), 1.0);
  line->SetLineColor(1);
  line->SetLineStyle(2);
  line->SetLineWidth(2);

  TCanvas * cCumuCentDep = new TCanvas("cCumuCentDep","cCumuCentDep", 1000, 1000);
  cCumuCentDep->Divide(2,2);
  cCumuCentDep->cd(1);
  grRatioChi2_21_vn2->Draw("ap");
  line->Draw("same");
  cCumuCentDep->cd(2);
  grRatioChi2_21_vn4->Draw("ap");
  line->Draw("same");
  cCumuCentDep->cd(3);
  grRatioChi2_21_vn6->Draw("ap");
  line->Draw("same");
  cCumuCentDep->cd(4);
  grRatioChi2_21_vn8->Draw("ap");
  line->Draw("same");
  cCumuCentDep->SaveAs("../../plots/systematicStudies/cSysChi2Cut_CumuCent.pdf" );

  TCanvas * cGamma1ExpCentDep = new TCanvas("cGamma1ExpCentDep","cGamma1ExpCentDep", 500, 500);
  cGamma1ExpCentDep->cd();
  grRatioChi2_21_gamma1exp->Draw("ap");
  //line->Draw("same");
  cGamma1ExpCentDep->SaveAs("../../plots/systematicStudies/cSysChi2Cut_Gamma1ExpCent.pdf" );

  TCanvas * cvnCumuRatioCentDep = new TCanvas("cvnCumuRatioCentDep","cvnCumuRatioCentDep", 1500, 500);
  cvnCumuRatioCentDep->Divide(3,1);
  cvnCumuRatioCentDep->cd(1);
  cvnCumuRatioCentDep->cd(1)->SetLeftMargin(0.2);
  grRatioChi2_21_vn6vn4->GetYaxis()->SetTitleOffset(1.6);
  grRatioChi2_21_vn6vn4->Draw("ap");
  line->Draw("same");
  cvnCumuRatioCentDep->cd(2);
  grRatioChi2_21_vn8vn4->Draw("ap");
  line->Draw("same");
  cvnCumuRatioCentDep->cd(3);
  grRatioChi2_21_vn8vn6->Draw("ap");
  line->Draw("same");
  cvnCumuRatioCentDep->SaveAs("../../plots/systematicStudies/cSysChi2Cut_CumuRatioCent.pdf" );

  TCanvas * cVn46_Vn68 = new TCanvas("cVn46_Vn68", "cVn46_Vn68", 500, 500);
  cVn46_Vn68->cd();
  grRatioChi2_21_vn46_vn68->Draw("ap");
  line->Draw("same");
  cVn46_Vn68->SaveAs("../../plots/systematicStudies/cSysChi2Cut_Vn46_Vn68.pdf");

  //---------------------------------------------------------------------------------------------------- 
  //-- Save plots for smoothing
  TFile * fSave = new TFile("SysReg.root", "recreate");
  fSave->cd();
  grRatioChi2_21_vn2->Write("grRatioChi2_21_vn2");
  grRatioChi2_21_vn4->Write("grRatioChi2_21_vn4");
  grRatioChi2_21_vn6->Write("grRatioChi2_21_vn6");
  grRatioChi2_21_vn8->Write("grRatioChi2_21_vn8");
  grRatioChi2_21_vn6vn4->Write("grRatioChi2_21_vn6vn4");
  grRatioChi2_21_vn8vn4->Write("grRatioChi2_21_vn8vn4");
  grRatioChi2_21_vn8vn6->Write("grRatioChi2_21_vn8vn6");
  grRatioChi2_21_vn46_vn68->Write("grRatioChi2_21_vn46_vn68");
  grRatioChi2_21_gamma1exp->Write("grRatioChi2_21_gamma1exp");

  //-- Save the unfolded distns for when the cutoff is chi2=2.
  for(int icent = 0; icent < NCENT; icent++){
    int i = finalIteration[icent][3];
    std::cout<<i<<std::endl;
    hUnfold[icent][i]->SetLineColor(1);
    hUnfold[icent][i]->SetMarkerColor(1);
    hUnfold[icent][i]->Write( Form("hFinalUnfold_SysReg_c%i", icent) );
  }


  
}
Exemplo n.º 18
0
void makeFitPlotPTRW()
{   
   gROOT->SetBatch();
   gROOT->SetStyle("Plain");
   
   gStyle->SetOptStat(0);

   gROOT->ProcessLine(".x def.C");
   gROOT->ProcessLine(".x common.C");
   
   TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500);
   c1->Draw();
   c1->cd();
   
   gStyle->SetHistTopMargin(0);

   TLegend *leg = new TLegend(0.70,0.90,0.90,0.55);
   leg->SetFillColor(253);
   leg->SetBorderSize(0);
   
   int Nbins = 153;
/*
   std::string tname = "results/table_ptrw.tex";
   std::string tname_inc = "results/table_ptrw_inc.tex";
   
   std::ofstream ft(tname.c_str());
   std::ofstream fti(tname_inc.c_str());
   
   std::string header1 = "\\documentclass[a4paper]{article} \n
\\usepackage[english]{babel} \n
\\usepackage{graphicx} \n
\\begin{document}";
   
   std::string header2 = "
\\begin{table}[hbt!] \n
\\small \n
\\begin{center} \n
\\resizebox{16cm}{!}{ \n
\\begin{tabular}{|c|c|c|c|c|c|c|c|} \n
\\hline";
				
   ft << header1 << std::endl;
   ft << header2 << std::endl;
   
   fti << header2 << std::endl;
  */ 
   std::ifstream f("results/ptrw_merged.txt");

   int nb[10000];
   double x1[10000];
   double x2[10000];
   double sf[10000];
   double sferr[10000];

   int i = 0;
   while( ! f.eof() )
     {
	f >> nb[i] >> x1[i] >> x2[i] >> sf[i] >> sferr[i];
	if( ! (sf[i] == 1 && sferr[i] == 0) )
	  i++;
     }   

   f.close();

   std::ofstream fout("results/jtplotPtRW.txt");
   
   TH1F *h_sf = new TH1F("h_sf","h_sf",Nbins,xbins);
   for(int j=0;j<i;j++)
     {
	h_sf->SetBinContent(nb[j]+1,sf[j]);
	h_sf->SetBinError(nb[j]+1,sferr[j]);
	fout << nb[j] << " " << x1[j] << " " << x2[j] << " " << sf[j] << " " << sferr[j] << std::endl;
     }      

   fout.close();      
   
   h_sf->Draw("e1");
   h_sf->SetMaximum(3.0);
   h_sf->SetMarkerSize(0.5);
   h_sf->GetXaxis()->SetRange(0,Nbins-7);
   h_sf->GetXaxis()->SetTitle("P_{T} [TeV]");
   h_sf->GetYaxis()->SetTitle("Data/MC");
   
   const int nxl = 25;
//   double xl[nxl] = {0.020,0.030,0.040,0.050,0.060,0.075,0.090,0.110,0.140,0.200,0.260,0.340,0.500};
   double xl[nxl] = {0.020,0.030,0.040,0.050,0.060,0.075,0.090,
	0.110,0.140,0.200,0.260,0.300,0.340,0.400,0.450,0.500,
	0.550,0.600,0.700,0.850,1.000,1.250,1.500,1.750,2.000};
   for(int i=0;i<nxl;i++)
     {	
	TLine *lpt = new TLine(xl[i],0,xl[i],3.0);
	lpt->SetLineStyle(2);
	lpt->SetLineWidth(2);
	lpt->SetLineColor(kBlue-9);
	lpt->Draw("same");
     }   

   h_sf->GetXaxis()->SetRangeUser(0.02,0.5);
   c1->SetLogx(1);
   c1->Print("pics/fit_PTRW.eps");
   
   gApplication->Terminate();
}
Exemplo n.º 19
0
TCanvas* makePlot(TH1F* h1,TString legh1, TH1F* h2, TString legh2, TString xtitle, TString ytitle, TString style = "R"){
	//Style: N - normal, R- drawn with ratio,
	if (strcmp("R",style.Data())==0 || strcmp("r",style.Data())==0){
	    
	    gStyle->SetOptTitle(0); 
	    gStyle->SetOptStat(0); 
	    //gStyle->SetLabelSize(0.04,"xy");
	    gStyle->SetLabelOffset(0.005,"xy");
	    //gStyle->SetTitleSize(0.02,"xy");
	    gStyle->SetTitleOffset(1.,"xy");
	    gStyle->SetTextFont(43);
	    //gStyle->SetTextSize(16);

	    TCanvas* c = new TCanvas("c","",200,10,700,500);
	    c->SetTicks(1,1);
	    c->cd();
	    TPad* p[2];

	    //Set margin size for pads
        Float_t padmarginX = 0.08;
        Float_t padmarginY = 0.1;
        Float_t textsize[2];

        TLine* line = new TLine();
        line->SetLineWidth(1);
        line->SetLineStyle(2);

        h1->GetYaxis()->SetTitle(ytitle.Data());
        h2->GetYaxis()->SetTitle(ytitle.Data());
        h1->GetXaxis()->SetTitle(xtitle.Data());
        h2->GetXaxis()->SetTitle(xtitle.Data());

	    p[0] = new TPad("p1", "p1", 0, 0.29, 1, 1, 0, 0, 0);
	    p[0]->SetBottomMargin(0);
	    p[0]->SetTopMargin(padmarginY);
	    p[0]->SetLeftMargin(padmarginX*1.5);
	    p[0]->SetRightMargin(padmarginX);
	    p[0]->SetTicks(1,1);
	    //p[0]->SetLogy();
	    p[0]->SetFixedAspectRatio();
	    textsize[0] = 18/(p[0]->GetWh()*p[0]->GetAbsHNDC());
	    p[0]->Draw();

	    p[1] = new TPad("p2", "p2", 0, 0, 1, 0.29, 0, 0, 0);
	    p[1]->SetBottomMargin(padmarginY*3);
	    p[1]->SetTopMargin(0);
	    p[1]->SetLeftMargin(padmarginX*1.5);
	    p[1]->SetRightMargin(padmarginX);
	    p[1]->SetTicks(1,1);
	    p[1]->SetFixedAspectRatio();
	    textsize[1] = 18/(p[1]->GetWh()*p[1]->GetAbsHNDC());
	    p[1]->Draw();

        p[0]->cd();
        h1->GetYaxis()->SetNdivisions(10);
        h2->GetYaxis()->SetNdivisions(10);
        h1->GetXaxis()->SetLabelSize(textsize[0]);
        h1->GetYaxis()->SetLabelSize(textsize[0]);
        h2->GetXaxis()->SetLabelSize(textsize[0]);
        h2->GetYaxis()->SetLabelSize(textsize[0]);
        h1->GetXaxis()->SetTitleSize(textsize[0]);
        h1->GetYaxis()->SetTitleSize(textsize[0]);
        h2->GetXaxis()->SetTitleSize(textsize[0]);
        h2->GetYaxis()->SetTitleSize(textsize[0]);
        h1->SetLineColor(2);
        h1->SetLineColor(8);
        h1->Draw("e1");
        h2->Draw("e1same");

        p[1]->cd();
        TH1F* hratio = (TH1F*)h1->Clone();
        hratio->Divide(h2);
        hratio->GetYaxis()->SetTitle("Ratio");
        hratio->GetXaxis()->SetTitle(xtitle.Data());
        hratio->GetYaxis()->SetNdivisions(5);
        hratio->GetYaxis()->SetRangeUser(0.89,1.12);
        hratio->GetXaxis()->SetLabelSize(textsize[1]);
        hratio->GetYaxis()->SetLabelSize(textsize[1]);
        hratio->GetXaxis()->SetTitleSize(textsize[1]);
        hratio->GetYaxis()->SetTitleSize(textsize[1]);
        hratio->GetYaxis()->CenterTitle();
        hratio->GetYaxis()->SetTitleOffset(0.7*textsize[0]/textsize[1]);
        hratio->SetTickLength(h1->GetTickLength()*textsize[1]/textsize[0]);
        hratio->Draw("e1");
        line->DrawLine(-180.,1.,180.,1.);
        
        p[0]->cd();
        TLegend *leg = new TLegend(0.65,0.09,0.84,0.25);
        leg->AddEntry(h1,legh1.Data(),"l");
		leg->AddEntry(h2,legh2.Data(),"l");
		leg->SetBorderSize(0);
		leg->Draw();

        return c;
	}
}
Exemplo n.º 20
0
void comp(int s1 = 7, int s2 = 18, TString str1 = "|#eta| < 2.4", TString str2 = "|#eta| < 0.8") {
//	bool bAlice = false;
	bool bAlice = true;

	SetStyle();
	if ( bAlice ) ALICE();
	TFile * f1 = new TFile(Form("%s/out_rebin.root", ftxt[s1]));
	TFile * f2 = new TFile(Form("%s/out_rebin.root", ftxt[s2]));


	TH1D * h3PartSS_Cent1 = (TH1D*) f1->Get("h3PartSS_Cent");
	TH1D * h3PartOS_Cent1 = (TH1D*) f1->Get("h3PartOS_Cent");

	TH1D * h3PartSS_Cent2 = (TH1D*) f2->Get("h3PartSS_Cent");
	TH1D * h3PartOS_Cent2 = (TH1D*) f2->Get("h3PartOS_Cent");

	TCanvas * c1 = MakeCanvas("c1", "c1", 500, 400);
	TH2D * hframe_3part = new TH2D("hframe_3part", "hframe_3part", 1, 0, 200, 1, -0.001, 0.002);
	InitHist(hframe_3part, "Centrality Bin", "cos(#phi_{#alpha}+#phi_{#beta}-2#Psi_{2})");
	hframe_3part->Draw();

	TLine * zero = new TLine(0, 0, 200, 0);
	zero->Draw();

	h3PartSS_Cent1->SetMarkerStyle(kFullCircle);
	h3PartOS_Cent1->SetMarkerStyle(kFullCircle);
	h3PartSS_Cent1->SetMarkerColor(kRed);
	h3PartOS_Cent1->SetMarkerColor(kBlue);
	h3PartSS_Cent1->SetLineColor(kRed);
	h3PartOS_Cent1->SetLineColor(kBlue);

	h3PartSS_Cent2->SetMarkerStyle(kFullSquare);
	h3PartOS_Cent2->SetMarkerStyle(kFullSquare);
	h3PartSS_Cent2->SetMarkerColor(kRed);
	h3PartOS_Cent2->SetMarkerColor(kBlue);
	h3PartSS_Cent2->SetLineColor(kRed);
	h3PartOS_Cent2->SetLineColor(kBlue);


	h3PartSS_Cent1->Draw("same");
	h3PartOS_Cent1->Draw("same");
	h3PartSS_Cent2->Draw("same");
	h3PartOS_Cent2->Draw("same");

	if ( bAlice ) gr_ALICE_3part_tpccumu_os->Draw("psame");
	if ( bAlice ) gr_ALICE_3part_tpccumu_ss->Draw("psame");

	TLegend * leg1 = new TLegend(0.2, 0.5, 0.5, 0.9);
	leg1->SetFillColor(kWhite);
	leg1->SetTextFont(42);
	leg1->SetTextSize(0.06);
	leg1->SetBorderSize(0);

	leg1->AddEntry(h3PartSS_Cent1, Form("SS %s", str1.Data()), "p");
	leg1->AddEntry(h3PartOS_Cent1, Form("OS %s", str1.Data()), "p");
	leg1->AddEntry(h3PartSS_Cent2, Form("SS %s", str2.Data()), "p");
	leg1->AddEntry(h3PartOS_Cent2, Form("OS %s", str2.Data()), "p");

	if ( bAlice ) leg1->AddEntry(gr_ALICE_3part_tpccumu_ss, "ALICE SS", "p");
	else leg1->AddEntry(gr_ALICE_3part_tpccumu_ss, " ", "");
	if ( bAlice ) leg1->AddEntry(gr_ALICE_3part_tpccumu_os, "ALICE OS", "p");
	else leg1->AddEntry(gr_ALICE_3part_tpccumu_os, " ", "");

	leg1->Draw();

	///////////
	TCanvas * c2 = MakeCanvas("c2", "c2", 500, 400);
	TH2D * hframe_2part = new TH2D("hframe_2part", "hframe_2part", 1, 0, 200, 1, -0.01, 0.03);
	InitHist(hframe_2part, "Centrality Bin", "#LTcos(#phi_{#alpha}-#phi_{#beta})#GT");

	TH1D * hQ1pp_Cent1 = (TH1D*) f1->Get("hQ1pp_Cent");
	TH1D * hQ1nn_Cent1 = (TH1D*) f1->Get("hQ1nn_Cent");
	TH1D * hQ1pn_Cent1 = (TH1D*) f1->Get("hQ1pn_Cent");
	TH1D * hQ1ppw_Cent1= (TH1D*) f1->Get("hQ1ppw_Cent");
	TH1D * hQ1nnw_Cent1= (TH1D*) f1->Get("hQ1nnw_Cent");
	TH1D * hQ1pnw_Cent1= (TH1D*) f1->Get("hQ1pnw_Cent");

	TH1D * hQ1pp_Cent2 = (TH1D*) f2->Get("hQ1pp_Cent");
	TH1D * hQ1nn_Cent2 = (TH1D*) f2->Get("hQ1nn_Cent");
	TH1D * hQ1pn_Cent2 = (TH1D*) f2->Get("hQ1pn_Cent");
	TH1D * hQ1ppw_Cent2= (TH1D*) f2->Get("hQ1ppw_Cent");
	TH1D * hQ1nnw_Cent2= (TH1D*) f2->Get("hQ1nnw_Cent");
	TH1D * hQ1pnw_Cent2= (TH1D*) f2->Get("hQ1pnw_Cent");

	hQ1pp_Cent1->Add(hQ1nn_Cent1);
	hQ1ppw_Cent1->Add(hQ1nnw_Cent1);
	hQ1pp_Cent2->Add(hQ1nn_Cent2);
	hQ1ppw_Cent2->Add(hQ1nnw_Cent2);

	hQ1pp_Cent1->Divide(hQ1ppw_Cent1);
	hQ1pp_Cent2->Divide(hQ1ppw_Cent2);
	hQ1pn_Cent1->Divide(hQ1pnw_Cent1);
	hQ1pn_Cent2->Divide(hQ1pnw_Cent2);


	hQ1pp_Cent1->SetMarkerStyle(kFullCircle);
	hQ1pn_Cent1->SetMarkerStyle(kFullCircle);
	hQ1pp_Cent1->SetMarkerColor(kRed);
	hQ1pn_Cent1->SetMarkerColor(kBlue);
	hQ1pp_Cent1->SetLineColor(kRed);
	hQ1pn_Cent1->SetLineColor(kBlue);

	hQ1pp_Cent2->SetMarkerStyle(kFullSquare);
	hQ1pn_Cent2->SetMarkerStyle(kFullSquare);
	hQ1pp_Cent2->SetMarkerColor(kRed);
	hQ1pn_Cent2->SetMarkerColor(kBlue);
	hQ1pp_Cent2->SetLineColor(kRed);
	hQ1pn_Cent2->SetLineColor(kBlue);


	hframe_2part->Draw();
	zero->Draw();
	hQ1pp_Cent1->Draw("same");
	hQ1pn_Cent1->Draw("same");
	hQ1pp_Cent2->Draw("same");
	hQ1pn_Cent2->Draw("same");
	if ( bAlice ) gr_ALICE_2part_tpccumu_os->Draw("psame");
	if ( bAlice ) gr_ALICE_2part_tpccumu_ss->Draw("psame");

	TLegend * leg2 = new TLegend(0.2, 0.5, 0.5, 0.9);
	leg2->SetFillColor(kWhite);
	leg2->SetTextFont(42);
	leg2->SetTextSize(0.06);
	leg2->SetBorderSize(0);

	leg2->AddEntry(hQ1pp_Cent1, Form("SS %s", str1.Data()), "p");
	leg2->AddEntry(hQ1pn_Cent1, Form("OS %s", str1.Data()), "p");
	leg2->AddEntry(hQ1pp_Cent2, Form("SS %s", str2.Data()), "p");
	leg2->AddEntry(hQ1pn_Cent2, Form("OS %s", str2.Data()), "p");

	if ( bAlice ) leg2->AddEntry(gr_ALICE_2part_tpccumu_ss, "ALICE SS", "p");
	else leg2->AddEntry(gr_ALICE_2part_tpccumu_ss, " ", "");
	if ( bAlice ) leg2->AddEntry(gr_ALICE_2part_tpccumu_os, "ALICE OS", "p");
	else leg2->AddEntry(gr_ALICE_2part_tpccumu_os, " ", "");

	leg2->Draw();


	///////////////
	TH1D * hCC_SS1 = (TH1D*)hQ1pp_Cent1->Clone("hCC_SS1");
	TH1D * hCC_OS1 = (TH1D*)hQ1pn_Cent1->Clone("hCC_OS1");
	TH1D * hCC_SS2 = (TH1D*)hQ1pp_Cent2->Clone("hCC_SS2");
	TH1D * hCC_OS2 = (TH1D*)hQ1pn_Cent2->Clone("hCC_OS2");

	hCC_SS1->Add(h3PartSS_Cent1);
	hCC_SS1->Scale(0.5);
	hCC_OS1->Add(h3PartOS_Cent1);
	hCC_OS1->Scale(0.5);
	hCC_SS2->Add(h3PartSS_Cent2);
	hCC_SS2->Scale(0.5);
	hCC_OS2->Add(h3PartOS_Cent2);
	hCC_OS2->Scale(0.5);

	TH1D * hSS_SS1 = (TH1D*)hQ1pp_Cent1->Clone("hSS_SS1");
	TH1D * hSS_OS1 = (TH1D*)hQ1pn_Cent1->Clone("hSS_OS1");
	TH1D * hSS_SS2 = (TH1D*)hQ1pp_Cent2->Clone("hSS_SS2");
	TH1D * hSS_OS2 = (TH1D*)hQ1pn_Cent2->Clone("hSS_OS2");

	hSS_SS1->Add(h3PartSS_Cent1, -1);
	hSS_SS1->Scale(0.5);
	hSS_OS1->Add(h3PartOS_Cent1, -1);
	hSS_OS1->Scale(0.5);
	hSS_SS2->Add(h3PartSS_Cent2, -1);
	hSS_SS2->Scale(0.5);
	hSS_OS2->Add(h3PartOS_Cent2, -1);
	hSS_OS2->Scale(0.5);


	////
	TCanvas * c3 = MakeCanvas("c3", "c3", 500, 400);
	TH2D * hframe_cos = new TH2D("hframe_cos", "hframe_cos", 1, 0, 200, 1, -0.01, 0.02);
	InitHist(hframe_cos, "Centrality Bin", "#LTcos(#Delta#phi_{#alpha})cos(#Delta#phi_{#beta})");

	hframe_cos->Draw();
	zero->Draw();

	hCC_SS1->Draw("same");
	hCC_SS2->Draw("same");
	hCC_OS1->Draw("same");
	hCC_OS2->Draw("same");

	if ( bAlice ) gr_ALICE_coscos_ss->Draw("psame");
	if ( bAlice ) gr_ALICE_coscos_os->Draw("psame");

	TLegend * leg_cos = new TLegend(0.2, 0.5, 0.5, 0.9);
	leg_cos->SetFillColor(kWhite);
	leg_cos->SetTextFont(42);
	leg_cos->SetTextSize(0.06);
	leg_cos->SetBorderSize(0);

	leg_cos->AddEntry(hCC_SS1, Form("SS %s", str1.Data()), "p");
	leg_cos->AddEntry(hCC_OS1, Form("OS %s", str1.Data()), "p");
	leg_cos->AddEntry(hCC_SS2, Form("SS %s", str2.Data()), "p");
	leg_cos->AddEntry(hCC_OS2, Form("OS %s", str2.Data()), "p");

	if ( bAlice ) leg_cos->AddEntry(gr_ALICE_coscos_ss, "ALICE SS", "p");
	else leg_cos->AddEntry(gr_ALICE_coscos_ss, " ", "");
	if ( bAlice ) leg_cos->AddEntry(gr_ALICE_coscos_os, "ALICE OS", "p");
	else leg_cos->AddEntry(gr_ALICE_coscos_os, " ", "");

	leg_cos->Draw();


	///
	TCanvas * c4 = MakeCanvas("c4", "c4", 500, 400);
	TH2D * hframe_sin = new TH2D("hframe_sin", "hframe_sin", 1, 0, 200, 1, -0.01, 0.02);
	InitHist(hframe_sin, "Centrality Bin", "#LTsin(#Delta#phi_{#alpha})sin(#Delta#phi_{#beta})");

	hframe_sin->Draw();
	zero->Draw();

	hSS_SS1->Draw("same");
	hSS_SS2->Draw("same");
	hSS_OS1->Draw("same");
	hSS_OS2->Draw("same");

	if ( bAlice ) gr_ALICE_sinsin_ss->Draw("psame");
	if ( bAlice ) gr_ALICE_sinsin_os->Draw("psame");

	TLegend * leg_sin = new TLegend(0.2, 0.5, 0.5, 0.9);
	leg_sin->SetFillColor(kWhite);
	leg_sin->SetTextFont(42);
	leg_sin->SetTextSize(0.06);
	leg_sin->SetBorderSize(0);

	leg_sin->AddEntry(hSS_SS1, Form("SS %s", str1.Data()), "p");
	leg_sin->AddEntry(hSS_OS1, Form("OS %s", str1.Data()), "p");
	leg_sin->AddEntry(hSS_SS2, Form("SS %s", str2.Data()), "p");
	leg_sin->AddEntry(hSS_OS2, Form("OS %s", str2.Data()), "p");

	if ( bAlice ) leg_sin->AddEntry(gr_ALICE_sinsin_ss, "ALICE SS", "p");
	else leg_sin->AddEntry(gr_ALICE_sinsin_ss, " ", "");
	if ( bAlice ) leg_sin->AddEntry(gr_ALICE_sinsin_os, "ALICE OS", "p");
	else leg_sin->AddEntry(gr_ALICE_sinsin_os, " ", "");

	leg_sin->Draw();




	c1->SaveAs(Form("3part%s_%i_%i.pdf", bAlice?"_Alice":"", s1, s2));
	c2->SaveAs(Form("2part%s_%i_%i.pdf", bAlice?"_Alice":"", s1, s2));
	c3->SaveAs(Form("coscos%s_%i_%i.pdf", bAlice?"_Alice":"", s1, s2));
	c4->SaveAs(Form("sinsin%s_%i_%i.pdf", bAlice?"_Alice":"", s1, s2));


}
Exemplo n.º 21
0
void plotV2vstheta(){
	TFile *f;
        int isSum=0;
        const int ntotbin=5;
        const int trkpointmin[ntotbin] = {120,150,185,220,260};
        const int trkpointmax[ntotbin] = {150,185,220,260,300};
        int trkbin=1;
	int xbin=0;
        c1 = new TCanvas("c1"," ",1200,700);
        makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03);
        gStyle->SetOptFit(1);
        gStyle->SetOptStat(0);
        gStyle->SetOptTitle(0);
        gStyle->SetErrorX(0);
        TH1D *hFrame = new TH1D("","",100,0,2);
        hFrame->SetTitle("");
        hFrame->GetXaxis()->SetTitle("#theta");
        hFrame->GetYaxis()->SetTitle("reference V_{2}");
        hFrame->GetYaxis()->SetTitleOffset(1.1);
        hFrame->GetXaxis()->SetTitleSize(0.04);
        hFrame->GetYaxis()->SetTitleSize(0.04);
        hFrame->GetXaxis()->SetRangeUser(0,1.5);
        hFrame->SetMinimum(0.020);
        hFrame->SetMaximum(0.060);
        for(int trkbin=0;trkbin<ntotbin; trkbin++){
	if(isSum==0){
	    f = TFile::Open(Form("M%d%d/mergedV_Prod.root",trkpointmax[trkbin],trkpointmin[trkbin]));
	}
	else{
	    f = TFile::Open(Form("M%d%d/mergedV_Sum.root",trkpointmax[trkbin],trkpointmin[trkbin]));
	}
	TVectorD* vecVmean = (TVectorD*)f->Get(Form("D_%d/Vmean",xbin));
        TVectorD* vecV = (TVectorD*)f->Get(Form("D_%d/D_0/V",xbin));

        double Vmean = (*vecVmean)[0];
        double *V = vecV->GetMatrixArray();
        double theta[ntheta];
        for(int itheta=0;itheta<ntheta;itheta++){
            theta[itheta]=itheta*TMath::Pi()/ntheta/nn;
        }
        int maxper10 = findmaxper(V,ntheta,Vmean);
        double maxper = (double)(maxper10+1)/10;
        c1->cd(trkbin+1);
        hFrame->Draw();
        TGraph *gV2theta = new TGraph(ntheta,theta,V);
        gV2theta->SetMarkerStyle(20);
        gV2theta->SetMarkerSize(1.3);
        gV2theta->SetMarkerColor(1);
        gV2theta->SetLineColor(1);
	gV2theta->Draw("Psame");
        TLine *lup = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1+maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1+maxper));
        TLine *ldown = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1-maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1-maxper));
        TLine *l = new TLine(hFrame->GetXaxis()->GetXmin(),Vmean, hFrame->GetXaxis()->GetXmax(),Vmean);
        l->SetLineStyle(2);
        lup->SetLineStyle(2);
        ldown->SetLineStyle(2);
        l->SetLineWidth(1.2);
        lup->SetLineWidth(1.2);
        ldown->SetLineWidth(1.2);
        TLatex *tl = new TLatex();
 //     tl->SetNDC();
        tl->SetTextFont(42);
        tl->SetTextSize(0.04);
 //     tl->SetBorderStyle(0);
        tl->DrawLatex(0,Vmean*(1+maxper),Form("mean up %.f%%",maxper*100));
        tl->DrawLatex(0,Vmean*(1-maxper),Form("mean down %.f%%",maxper*100));
        tl->SetNDC();
        tl->DrawLatex(0.7,0.85,Form("Multiplicity %d to %d",trkpointmin[trkbin],trkpointmax[trkbin]));
        l->Draw("same");
        lup->Draw("same");
        ldown->Draw("same");
        }
        c1->cd(ntotbin+1);
        TLatex *tlx0 = new TLatex(0.12,0.3,Form("track"));
        TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0));
        tlx0->SetNDC();
        tlx1->SetNDC();
        tlx0->SetTextSize(0.045);
        tlx1->SetTextSize(0.045);
        hFrame->Draw();
        tlx0->Draw("same");
        tlx1->Draw("same");
	if(isSum==0)c1->SaveAs("hV2theta_Prod.png");
	else c1->SaveAs("hV2theta_Sum.png");
}
Exemplo n.º 22
0
// int massPlotPost() {
int main() {
	gStyle->SetOptStat(""); // DOES NOTHING AS HIST ALREADY HAS OPT STATS!!!!
	gStyle->SetLegendBorderSize(0);
	gStyle->SetHistLineWidth(2);
	gStyle->SetLegendFillColor(kWhite);

	TH1::SetDefaultSumw2();
	TCanvas* c1 = new TCanvas("c1");
	std::string directory = "../Combined";
	std::string app = "";

	////////////////////////////
	// Open files, get hists //
	////////////////////////////
	TFile* fQCDb = TFile::Open("../QCDb_HLT_bare/output_bare_bg_muRand_HLT_dR1.root","READ");
	TFile* fQCDScatter = TFile::Open("../QCDbcScatter_HLT_bare/output_bare_bg_muRand_HLT_dR1.root","READ");
	TFile* fSignal = TFile::Open("../Signal_1prong_HLT_bare/output_bare_sig_muRand_HLT_dR1.root","READ");

	std::vector<TFile*> files;
	files.push_back(fQCDb);
	files.push_back(fQCDScatter);

	TH1D* histCorr1D_side_1to2p5_Robin_QCDb = (TH1D*) fQCDb->Get("hCorr1D_side_1to2p5");
	TH1D* histCorr1D_side_1to2p5_Robin_QCDScatter = (TH1D*) fQCDScatter->Get("hCorr1D_side_1to2p5");
	TH1D* histCorr1D_side_1to2p5_Robin_Signal = (TH1D*) fSignal->Get("hCorr1D_side_1to2p5");
	histCorr1D_side_1to2p5_Robin_QCDb->SetStats(kFALSE);
	histCorr1D_side_1to2p5_Robin_QCDScatter->SetStats(kFALSE);
	histCorr1D_side_1to2p5_Robin_Signal->SetStats(kFALSE);
	
	////////////////////////////
	// Make Data 1D hist //
	////////////////////////////
	TH1D* histCorr1D_side_1to2p5_Data = (TH1D*) histCorr1D_side_1to2p5_Robin_QCDb->Clone("hCorr1D_side_1to2p5_Data");
	// double arrContents[] = {1.00, 1.02, 0.95, 1.21, 0.96, 0.93, 0.97, 1.1, 1.1, 1.03};
	double arrContents[] = {0.95, 1.02, 1.02, 1.10, 1.01, 0.96, 0.93, 1.07, 0.98, 0.91};
	double arrErrors[]   = {0.04, 0.03, 0.05, 0.07, 0.03, 0.05, 0.06, 0.12, 0.10, 0.19};
	for (unsigned i = 1; i <= histCorr1D_side_1to2p5_Robin_QCDb->GetNbinsX(); i++) {
		histCorr1D_side_1to2p5_Data->SetBinContent(i,arrContents[i-1]);
		histCorr1D_side_1to2p5_Data->SetBinError(i,arrErrors[i-1]);
	}

	//////////////////////////////////////////
	// Plot individual components together //
	//////////////////////////////////////////
	histCorr1D_side_1to2p5_Robin_QCDb->SetLineWidth(2);
	histCorr1D_side_1to2p5_Robin_QCDb->SetMarkerStyle(21);
	histCorr1D_side_1to2p5_Robin_QCDScatter->SetLineColor(kGreen+2);
	histCorr1D_side_1to2p5_Robin_QCDScatter->SetLineWidth(2);
	// histCorr1D_side_1to2p5_Robin_QCDScatter->SetLineStyle(2);
	histCorr1D_side_1to2p5_Robin_QCDScatter->SetMarkerColor(kGreen+2);
	histCorr1D_side_1to2p5_Robin_QCDScatter->SetMarkerStyle(22);
	histCorr1D_side_1to2p5_Data->SetLineColor(kGreen+2);
	histCorr1D_side_1to2p5_Data->SetLineWidth(2);
	histCorr1D_side_1to2p5_Data->SetMarkerColor(kGreen+2);
	THStack stack("stack","");
	stack.Add(histCorr1D_side_1to2p5_Robin_QCDb);
	// stack.Add(histCorr1D_side_1to2p5_Robin_QCDScatter);
	stack.Add(histCorr1D_side_1to2p5_Data);
	stack.Draw("EPNOSTACK");
	(stack.GetHistogram())->SetXTitle("Bin");
	(stack.GetHistogram())->SetYTitle("Correlation coefficient");
	stack.GetHistogram()->GetXaxis()->SetTitleSize(0.05);
    stack.GetHistogram()->GetXaxis()->SetLabelSize(0.07);
	// stack.GetHistogram()->GetXaxis()->SetTitleOffset(0.05);
    
    stack.GetHistogram()->GetYaxis()->SetTitleSize(0.05);
    stack.GetHistogram()->GetYaxis()->SetLabelSize(0.05);
    // stack.GetHistogram()->GetYaxis()->SetTitleOffset(1.2);
	stack.SetMaximum(2.0);
	stack.SetMinimum(0.0);

	// Add a legend
	// TLegend leg(0.12,0.6,0.4,0.88);
	TLegend leg(0.6,0.67,0.88,0.88);
	leg.SetFillStyle(0);
	leg.AddEntry(histCorr1D_side_1to2p5_Robin_QCDb,"QCD b#bar{b} MC","lp");
	// leg.AddEntry(histCorr1D_side_1to2p5_Robin_QCDScatter,"#splitline{QCD MC (q-g scatter),}{q = b, #bar{b}, c, #bar{c}}","lp");
	leg.AddEntry(histCorr1D_side_1to2p5_Data,"Data","lp");
	leg.Draw();

	// Draw a horizontal line at 1
	double min = histCorr1D_side_1to2p5_Data->GetBinLowEdge(1);
	double max = histCorr1D_side_1to2p5_Data->GetBinLowEdge(histCorr1D_side_1to2p5_Data->GetNbinsX()+1);
	TLine *line = new TLine(min,1,max,1);
	line->SetLineColor(kBlack);
	line->SetLineWidth(2);
	line->SetLineStyle(2);
	line->Draw();

	TPaveText t(0.15, 0.7, 0.4, 0.8, "NDC");
	t.AddText("Control region A");
    t.SetFillColor(kWhite);
    t.SetBorderSize(0);
    t.Draw();

	// Default canvas has name c1
	c1->SetTicks(1,1); // Put tick marks on top x and right y axes
	c1->SaveAs("../Combined/histCorr1D_side_1to2p5_qcdb_data.pdf");

	THStack* stack_sig = (THStack*) stack.Clone("stack_sig");
	histCorr1D_side_1to2p5_Robin_Signal->SetLineColor(kOrange);
	histCorr1D_side_1to2p5_Robin_Signal->SetLineWidth(2);
	histCorr1D_side_1to2p5_Robin_Signal->SetMarkerColor(kOrange);
	stack_sig->Add(histCorr1D_side_1to2p5_Robin_Signal);
	stack_sig->Draw("EPNOSTACK");
	TLegend* leg_sig = (TLegend*) leg.Clone();
	leg_sig->AddEntry(histCorr1D_side_1to2p5_Robin_Signal, "#splitline{Signal MC}{m_{#varphi} = 8 GeV}","lp");
	leg_sig->Draw();
	line->Draw();
	t.Draw();
	c1->SaveAs("../Combined/histCorr1D_side_1to2p5_signal_qcdb_data.pdf");

	stack.Add(histCorr1D_side_1to2p5_Robin_QCDScatter);
	stack.Draw("EPNOSTACK");
	leg.AddEntry(histCorr1D_side_1to2p5_Robin_QCDScatter,"#splitline{QCD q-g scatter MC}{q = b, #bar{b}, c, #bar{c}}","lp");
	leg.Draw();
	line->Draw();
	t.Draw();
	c1->SaveAs("../Combined/histCorr1D_side_1to2p5.pdf");

	//////////////////////////////////////////////////////////////////
	// Now combine QCD plots - need to reweight for cross-sections //
	//////////////////////////////////////////////////////////////////

	// Need to redo whole correlation coefficient calculation as we have to scale according to # events
	// So get raw #, scale to lumi&xsec, then add, normalise and do as normal.
	TH1D* histM_side_1to2p5_unscaled_QCDb = (TH1D*) fQCDb->Get("hM_side_1to2p5_unnormalised");
	TH1D* histM_side_1to2p5_unscaled_QCDScatter = (TH1D*) fQCDScatter->Get("hM_side_1to2p5_unnormalised");
	std::vector<TH1D*> plots1D;
	plots1D.push_back(histM_side_1to2p5_unscaled_QCDb);
	plots1D.push_back(histM_side_1to2p5_unscaled_QCDScatter);

	TH2D* histM1vsM2_side_1to2p5_unscaled_QCDb = (TH2D*) fQCDb->Get("hM1vsM2_side_1to2p5_unnormalised");
	TH2D* histM1vsM2_side_1to2p5_unscaled_QCDScatter = (TH2D*) fQCDScatter->Get("hM1vsM2_side_1to2p5_unnormalised");
	std::vector<TH2D*> plots2D;
	plots2D.push_back(histM1vsM2_side_1to2p5_unscaled_QCDb);
	plots2D.push_back(histM1vsM2_side_1to2p5_unscaled_QCDScatter);

	///////////////////////////////
	// SET SCALING FACTORS HERE //
	///////////////////////////////
	std::vector<double> scalingFactors;
	scalingFactors.push_back(2.9475); // QCDb
	scalingFactors.push_back(2.6577); // QCDscatter

	// Create combination 2D plot (numerator)
	TH2D* histM1vsM2_side_1to2p5 = (TH2D*) combinePlots(plots2D, scalingFactors);
	drawHistAndSave(histM1vsM2_side_1to2p5, "COLZTEXTE", "histM1vsM2_side_1to2p5_unscaled", directory, app);
	normaliseHist(histM1vsM2_side_1to2p5);

	// Create combination 1D sideband plot (denominator)
	TH1D* histM_side_1to2p5 = (TH1D*) combinePlots(plots1D, scalingFactors);
	drawHistAndSave(histM_side_1to2p5, "HISTE", "histM_side_1to2p5_unscaled", directory, app);
	normaliseHist(histM_side_1to2p5);

	// Create 2D from 1D x 1D
	TH2D* histM1timesM1_side_1to2p5 = create2Dfrom1D(massBins, histM_side_1to2p5);

	// Calculate new correlation coeffs & plot
	TH2D* histM1vsM2_correlations_side_1to2p5 = (TH2D*)histM1vsM2_side_1to2p5->Clone("hM1vsM2_correlations_side_1to2p5");
	histM1vsM2_correlations_side_1to2p5->SetTitle(
		"m(#mu_{1}-tk) vs m(#mu_{2}-tk) / m(sideband) #times m(sideband), (soft tk p_{T} = 1 - 2.5 GeV);m(#mu_{1}-tk) [GeV];m(#mu_{2}-tk) [GeV]");
	histM1vsM2_correlations_side_1to2p5->Divide(histM1timesM1_side_1to2p5);

	// Make 1D plots of unique bins from 2D correlation plot
	TH1D* histCorr1D_side_1to2p5_combo = unique1DBinsFrom2D(histM1vsM2_correlations_side_1to2p5, (nBinsX+1)*nBinsX/2.);

	drawHistAndSave(histM1vsM2_side_1to2p5, "colzTEXTE","M1vsM2_side_1to2p5", directory, app);
	drawHistAndSave(histM1timesM1_side_1to2p5, "colzTEXTE","M1timesM1_side_1to2p5", directory, app);
	drawHistAndSave(histM_side_1to2p5, "HISTE", "M_side_1to2p5", directory, app);
	drawHistAndSave(histM1vsM2_correlations_side_1to2p5, "colzTEXTE","M1vsM2_correlations_side_1to2p5", directory, app);
	histCorr1D_side_1to2p5_combo->SetMaximum(2.0);
	histCorr1D_side_1to2p5_combo->SetMinimum(0);
	drawHistAndSave(histCorr1D_side_1to2p5_combo, "e1", "Correlations1D_side_1to2p5", directory, app);

	// Plot alongside Data
	THStack stack2("stack2","");
	histCorr1D_side_1to2p5_combo->SetLineWidth(2);
	histCorr1D_side_1to2p5_combo->SetMarkerStyle(21);
	stack2.Add(histCorr1D_side_1to2p5_combo);
	stack2.Add(histCorr1D_side_1to2p5_Data);
	histCorr1D_side_1to2p5_Data->SetLineWidth(2);
	stack2.Draw("EPNOSTACK");

	// (stack2.GetHistogram())->SetXTitle("Bin");
	// (stack2.GetHistogram())->SetTitleSize(0.05,"X");
	// (stack2.GetHistogram())->SetLabelSize(0.07,"X");
	// (stack2.GetHistogram())->SetLabelSize(0.05,"Y");
	// (stack2.GetHistogram())->SetYTitle("Correlation coefficient");
	// (stack2.GetHistogram())->SetTitleSize(0.05,"Y");
	// cout << (stack2.GetHistogram())->GetMaximum() << endl;
	// (stack2).SetMaximum(2.0);
	// (stack2).SetMinimum(0);
	setupCorrStuff(stack2.GetHistogram());
	stack2.Draw("EPNOSTACK");

	// Add a legend
	TLegend leg2(0.53,0.63,0.87,0.9);
	// leg2.SetFillColor(kWhite);
	leg2.SetFillStyle(0);
	TH1D blank("","",1,0,1);
	leg2.AddEntry(histCorr1D_side_1to2p5_combo,"Gen. level QCD MC","lp");
	leg2.AddEntry(&blank,"(b#bar{b} + q-g scatter,","");
	leg2.AddEntry(&blank,"q = b, #bar{b}, c, #bar{c})","");
	leg2.AddEntry(histCorr1D_side_1to2p5_Data,"Data","lp");
	leg2.Draw();
	
	line->Draw();

	c1->SetTicks(1,1);
	t.Draw();
	c1->SaveAs("../Combined/histCorr1D_side_1to2p5_combo_allQCD.pdf");
}
Exemplo n.º 23
0
void drawRoC( DrawBase* db, float ptMin, float ptMax, const std::string& flag, TH1D* h1_new_gluon, TH1D* h1_new_quark, TH1D* h1_old_gluon, TH1D* h1_old_quark, TH1D* h1_MLP_gluon, TH1D* h1_MLP_quark, const std::string& labelText ) {


  TGraph* gr_RoC_old = new TGraph(0);
  TGraph* gr_RoC_new = new TGraph(0);
  TGraph* gr_RoC_MLP = new TGraph(0);

  int nbins = h1_new_quark->GetNbinsX();

  for( unsigned int ibin=1; ibin<nbins+1; ++ibin ) {

    float eff_q_old = -1.;
    float eff_g_old = -1.;
  
    if( h1_old_quark!=0 && h1_old_gluon!=0 ) {
      eff_q_old = h1_old_quark->Integral( nbins-ibin, nbins )/h1_old_quark->Integral( 1, nbins );
      eff_g_old = h1_old_gluon->Integral( nbins-ibin, nbins )/h1_old_gluon->Integral( 1, nbins );
    }
  
    float eff_q_MLP = -1.;
    float eff_g_MLP = -1.;
  
    if( h1_MLP_quark!=0 && h1_MLP_gluon!=0 ) { //opposite convention:
      eff_q_MLP = h1_MLP_quark->Integral( 1, ibin )/h1_MLP_quark->Integral( 1, nbins );
      eff_g_MLP = h1_MLP_gluon->Integral( 1, ibin )/h1_MLP_gluon->Integral( 1, nbins );
    }
  
    float eff_q_new = h1_new_quark->Integral( nbins-ibin, nbins )/h1_new_quark->Integral( 1, nbins );
    float eff_g_new = h1_new_gluon->Integral( nbins-ibin, nbins )/h1_new_gluon->Integral( 1, nbins );
  
    gr_RoC_new->SetPoint( ibin-1, 1.-eff_g_new, eff_q_new );

    if( h1_old_quark!=0 && h1_old_gluon!=0 ) 
      gr_RoC_old->SetPoint( ibin-1, 1.-eff_g_old, eff_q_old );

    if( h1_MLP_quark!=0 && h1_MLP_gluon!=0 ) 
      gr_RoC_MLP->SetPoint( ibin-1, 1.-eff_g_MLP, eff_q_MLP );

  }


  gr_RoC_new->SetMarkerSize(1.3);
  gr_RoC_new->SetMarkerStyle(24);
  gr_RoC_new->SetMarkerColor(kRed+3);

  if( h1_old_quark!=0 && h1_old_gluon!=0 ) {
    gr_RoC_old->SetMarkerSize(1.3);
    gr_RoC_old->SetMarkerStyle(20);
    gr_RoC_old->SetMarkerColor(kOrange+1);
  }

  if( h1_MLP_quark!=0 && h1_MLP_gluon!=0 ) {
    gr_RoC_MLP->SetMarkerSize(1.3);
    gr_RoC_MLP->SetMarkerStyle(21);
    gr_RoC_MLP->SetMarkerColor(29);
  }

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

  TH2D* h2_axes = new TH2D("axes_roc", "", 10, 0., 1.0001, 10, 0., 1.0001);
  h2_axes->SetXTitle( "Gluon Jet Rejection" );
  h2_axes->SetYTitle( "Quark Jet Efficiency" );

  h2_axes->Draw();

  TLine* diag = new TLine(0., 1., 1., 0.);
  diag->Draw("same");


  char legendTitle[300];
  sprintf( legendTitle, "%.0f < p_{T} < %.0f GeV", ptMin, ptMax );
  TLegend* legend = new TLegend( 0.2, 0.2, 0.45, 0.45, legendTitle );
  legend->SetFillColor(0);
  legend->SetTextSize(0.04);
  if( h1_old_quark!=0 && h1_old_gluon!=0 )
    legend->AddEntry( gr_RoC_old, "Old LD", "P");
  legend->AddEntry( gr_RoC_new, "New LD", "P");
  if( h1_MLP_quark!=0 && h1_MLP_gluon!=0 )
    legend->AddEntry( gr_RoC_MLP, "MLP", "P");
  legend->Draw("same");

  TPaveText* labelTop = db->get_labelTop();
  labelTop->Draw("same");

  TPaveText* label = new TPaveText( 0.7, 0.83, 0.9, 0.9, "brNDC" );
  label->SetTextSize(0.04);
  label->SetFillColor(0);
  label->AddText(labelText.c_str());
  if( labelText!="" )
    label->Draw("same");

  
  if( h1_MLP_quark!=0 && h1_MLP_gluon!=0 ) 
    gr_RoC_MLP->Draw("p same");
  if( h1_old_quark!=0 && h1_old_gluon!=0 ) 
    gr_RoC_old->Draw("p same");
  gr_RoC_new->Draw("p same");

  gPad->RedrawAxis();

  char canvasName[500];
  sprintf( canvasName, "%s/RoC_pt%.0f_%.0f%s.eps", plotsdir.c_str(), ptMin, ptMax, flag.c_str());
  c1->SaveAs(canvasName);
  sprintf( canvasName, "%s/RoC_pt%.0f_%.0f%s.png", plotsdir.c_str(), ptMin, ptMax, flag.c_str());
  c1->SaveAs(canvasName);

  delete c1;
  delete h2_axes;
  delete legend;
}
Exemplo n.º 24
0
void draw_mapping(TH1 *h,int ctch,int where)
{
    // Cards naming scheme:
    // SALEVE   10-S1 10-S2 10-S3   6-S1 6-S2 .... 6-S7  10-J3 10-J2 10-J1   JURA

    vector<string> cards;
    switch( ctch )
    {
        case 328:
            cards.push_back("4X-10-J1");    //  0
            cards.push_back("4X-10-J2");    //  1
            cards.push_back("4X-10-J3");    //  2
            cards.push_back("4X- 6-S7");    //  3
            cards.push_back("4X- 6-S6");    //  4
            cards.push_back("4X- 6-S5");    //  5
            cards.push_back("4X- 6-S4");    //  6
            cards.push_back("4X- 6-S3");    //  7
            cards.push_back("4X- 6-S2");    //  8
            cards.push_back("4X- 6-S1");    //  9
            cards.push_back("4X-10-S3");    // 10
            cards.push_back("4X-10-S2");    // 11
            cards.push_back("4X-10-S1");    // 12
            cards.push_back("4X- 6-ph");    // 13
            cards.push_back("4Y-10-B1");    // 14
            cards.push_back("4Y-10-B2");    // 15
            break;
        case 329:
            cards.push_back("4Y- 6-B1");    //  0
            cards.push_back("4Y- 6-B2");    //  1
            cards.push_back("4Y- 6-B3");    //  2
            cards.push_back("4Y- 6-B4");    //  3
            cards.push_back("4Y- 6-B5");    //  4
            cards.push_back("4Y- 6-B6");    //  5
            cards.push_back("4Y-10-T2");    //  6
            cards.push_back("4Y-10-T1");    //  7
            cards.push_back("4Y- 6-ph");    //  8
            cards.push_back("4U-10-S1");    //  9
            cards.push_back("4U-10-S2");    // 10
            cards.push_back("4U-10-S3");    // 11
            cards.push_back("4U- 6-S1");    // 12
            cards.push_back("4U- 6-S2");    // 13
            cards.push_back("4U- 6-S3");    // 14
            cards.push_back("4U- 6-S4");    // 15
            break;
        case 330:
            cards.push_back("4U- 6-S5");    //  0
            cards.push_back("4U- 6-S6");    //  1
            cards.push_back("4U- 6-S7");    //  2
            cards.push_back("4U-10-J3");    //  3
            cards.push_back("4U-10-J2");    //  4
            cards.push_back("4U-10-J1");    //  5
            cards.push_back("4U- 6-ph");    //  6
            cards.push_back("        ");    //  7
            cards.push_back("6V-10-J1");    //  8
            cards.push_back("6V-10-J2");    //  9
            cards.push_back("6V-10-J3");    // 10
            cards.push_back("6V- 6-S7");    // 11
            cards.push_back("6V- 6-S6");    // 12
            cards.push_back("6V- 6-S5");    // 13
            cards.push_back("6V- 6-S4");    // 14
            cards.push_back("6V- 6-S3");    // 15
            break;
        case 331:
            cards.push_back("6V- 6-S2");    //  0
            cards.push_back("6V- 6-S1");    //  1
            cards.push_back("6V-10-S3");    //  2
            cards.push_back("6V-10-S2");    //  3
            cards.push_back("6V-10-S1");    //  4
            cards.push_back("6V- 6-ph");    //  5
            cards.push_back("6Y-10-T1");    //  6
            cards.push_back("6Y-10-T2");    //  7
            cards.push_back("6Y- 6-B6");    //  8
            cards.push_back("6Y- 6-B5");    //  9
            cards.push_back("6Y- 6-B4");    // 10
            cards.push_back("6Y- 6-B3");    // 11
            cards.push_back("6Y- 6-B2");    // 12
            cards.push_back("6Y- 6-B1");    // 13
            cards.push_back("6Y-10-B2");    // 14
            cards.push_back("6Y-10-B1");    // 15
            break;
        case 332:
            cards.push_back("6Y- 6-ph");    //  0
            cards.push_back("6X-10-S1");    //  1
            cards.push_back("6X-10-S2");    //  2
            cards.push_back("6X-10-S3");    //  3
            cards.push_back("6X- 6-S1");    //  4
            cards.push_back("6X- 6-S2");    //  5
            cards.push_back("6X- 6-S3");    //  6
            cards.push_back("6X- 6-S4");    //  7
            cards.push_back("6X- 6-S5");    //  8
            cards.push_back("6X- 6-S6");    //  9
            cards.push_back("6X- 6-S7");    // 10
            cards.push_back("6X-10-J3");    // 11
            cards.push_back("6X-10-J2");    // 12
            cards.push_back("6X-10-J1");    // 13
            cards.push_back("6X- 6-ph");    // 14
            cards.push_back("        ");    // 15
            break;
        default:
            printf("No mapping found for catch %d!\n",ctch);
    }


    for( int port=0; port<16; port++ )
    {
        int pos_port=0, pos_det=0;
        if( where==0 )
        {
            // histogram bottom
            pos_port = h->GetMinimum();
            pos_det  = h->GetMinimum()+170;
        }
        else
        {
            // histogram top
            pos_port = h->GetMaximum()-2;
            pos_det  = h->GetMaximum()-11;
        }
    
        TLine *l = new TLine(port*64,h->GetMinimum(),port*64,h->GetMaximum());
        l->SetLineStyle(2);
        l->Draw();
        
        char buf[99];
        sprintf(buf,"%d",port);

        (new TText(10+port*64,pos_port,buf))->Draw();

        if( cards.size()>=port+1 )
        {
            if( 1 )
            {
                vector<int> *v = new vector<int>;
                card_channel[cards[port]] = v;
                for( int echan=0; echan<64; echan++ )
                    v->push_back(h->GetBinContent(port*64+echan+1));
            }

            sprintf(buf,cards[port].c_str());
            int offset=40;
            TText *m = new TText(offset+port*64,pos_det,buf);
            m->SetTextAngle(90);
            m->Draw();
        }
    }
}
Exemplo n.º 25
0
void plTpcEffCorrect(bool print=true){
  gStyle->SetPalette(1);
  gStyle->SetOptStat(100000000);
  const float PI=TMath::Pi();
  TList *Lx;  TLine *ln;

  //input files for TPC effic correction
  TString core="/star/data05/scratch/stevens4/wAnalysisOut/apsXsec/";
  TFile *fdQcd = TFile::Open("outMC/tpcEffic/uncorrected/rcf10016.wana.hist.root");
  //TFile *fdQcd = TFile::Open("outMC/corrected/rcf10016.wana.hist.root");
  TFile *fdData = TFile::Open(core+"forJoe/data/run9setABCD.wana.hist.root");
  TFile *fdCorrected = TFile::Open("/star/data05/scratch/stevens4/wAnalysisOut/apsXsec/feb01/data/run9setABCD.wana.hist.root");

  //#if 0
  //plots for pt>1
  //hQcd=(TH2F*)fdQcd->Get("muTr2D1"); assert(hQcd);
  //hData=(TH2F*)fdData->Get("muTr2D1"); assert(hData);

  //plots for pt>5
  hQcd=(TH2F*)fdQcd->Get("muTr2D1pt5"); assert(hQcd);
  hData=(TH2F*)fdData->Get("muTr2D1pt5"); assert(hData);
  hCorr=(TH2F*)fdCorrected->Get("muTr2D1pt5weight"); assert(hCorr);

  //get plots rebinned in my (eta,phi) mapping
  hQcdRebin=(TH2F*) hQcd->Clone();
  hDataRebin=(TH2F*) hData->Clone();
  hCorrRebin=(TH2F*) hCorr->Clone();
  hQcdRebin->Rebin2D(10,10); hDataRebin->Rebin2D(10,10);
  hCorrRebin->Rebin2D(10,10);
  //hDataRebin->Draw("colz"); hDataRebin->SetMinimum(0);
  

  //add etabin lines to original plot
  Lx=hQcd->GetListOfFunctions();
  //Lx=hData->GetListOfFunctions();
  for(int i=0; i<9; i++){
    float binlim=(i*.22)-.88;
    ln=new TLine(binlim,-PI,binlim,PI);
    ln->SetLineColor(kRed);
    ln->SetLineWidth(2);
    Lx->Add(ln);
  }
  //hQcd->Rebin2D(3,2); hQcd->Draw("colz");
  //hData->Draw("colz");

  //ratio of QCD MC to Data
  hRatio=(TH2F*) hQcdRebin->Clone();
  hRatio->Divide(hDataRebin);
  //hRatio->Draw("colz"); hRatio->SetMaximum(.13);
  
#if 0
  //final slices in |eta| to compare ratio
  gStyle->SetOptStat(1011);
  hRatio->ProjectionY("hRatioFin1",1,2);
  hRatio->ProjectionY("hRatioFin2",3,4);
  hRatio->ProjectionY("hRatioFin3",5,6);
  hRatio->ProjectionY("hRatioFin4",7,8);
  hRatio->ProjectionY("hRatioFin5",9,10);
  hRatioFin1->SetMinimum(0);hRatioFin1->SetMaximum(0.25); hRatioFin1->SetTitle("Ratio MC/Data tracks eta<-0.66");
  hRatioFin2->SetMinimum(0);hRatioFin2->SetMaximum(0.25); hRatioFin2->SetTitle("Ratio MC/Data tracks -0.66<eta<-0.22");
  hRatioFin3->SetMinimum(0); hRatioFin3->SetMaximum(0.25); hRatioFin3->SetTitle("Ratio MC/Data tracks |eta|<0.22");
  hRatioFin4->SetMinimum(0);hRatioFin4->SetMaximum(0.25); hRatioFin4->SetTitle("Ratio MC/Data tracks 0.22<eta<0.66");
  hRatioFin5->SetMinimum(0);hRatioFin5->SetMaximum(0.25); hRatioFin5->SetTitle("Ratio MC/Data tracks eta>0.66");
  c3=new TCanvas("cc","cc",1500,500);
  c3->Divide(5,1);
  c3->cd(1);
  hRatioFin1->Draw();
  c3->cd(2);
  hRatioFin2->Draw();
  c3->cd(3);
  hRatioFin3->Draw();
  c3->cd(4);
  hRatioFin4->Draw();
  c3->cd(5);
  hRatioFin5->Draw();
#endif

  //make projections to get ratio of MC/Data for each eta bin
  TH1 *hRatioAll[10];
  hRatio->ProjectionY("hRatioA",1,1);   hRatioAll[0]=hRatioA;
  hRatio->ProjectionY("hRatioB",2,2);   hRatioAll[1]=hRatioB;
  hRatio->ProjectionY("hRatioC",3,3);   hRatioAll[2]=hRatioC;
  hRatio->ProjectionY("hRatioH",8,8);   hRatioAll[7]=hRatioH;
  hRatio->ProjectionY("hRatioI",9,9);   hRatioAll[8]=hRatioI;
  hRatio->ProjectionY("hRatioJ",10,10); hRatioAll[9]=hRatioJ;

  float normal[10]={0.07,0.075,0.08,0,0,0,0,0.08,0.075,0.07};//determined from looking at data where yield was high
  //float normal[10]={0.049,0.065,0.069,0,0,0,0,0.068,0.062,0.055};//for syst error chosen for lowest phi bin in each eta slice
  if(print) c=new TCanvas("aa","aa",800,600);
  for(int j=0; j<10; j++){
    if(j>2 && j<7) continue;
    hRatioAll[j]->SetTitle(Form("Eta bin %c: Ratio of tracks QCD MC to run 9 data (track pt > 5)",'A'+j));
    hRatioAll[j]->SetMinimum(0); hRatioAll[j]->SetLineWidth(2);
    Lx=hRatioAll[j]->GetListOfFunctions(); hRatioAll[j]->SetStats(false);
    ln=new TLine(-PI,normal[j],PI,normal[j]);
    ln->SetLineColor(kRed); ln->SetLineWidth(2);  
    Lx->Add(ln);
    if(print){
      hRatioAll[j]->Draw();
      c->Print(Form("etabin%c.png",'A'+j));
    }
  }
  
  
  float phiRad=999;
  float etaDet=999;
  
  //initialize and clear eff values
  float effic[10][24];
  float efficSec[10][24];
  for(int i=0;i<10;i++){ 
    for(int l=0;l<24;l++){
      effic[i][l]=0;
      efficSec[i][l]=0;
    }
  }
  
  //calculate inefficiency
  for(int ieta=0; ieta<10; ieta++){
    if(ieta>2 && ieta<7) continue;
    for(int iphi=0; iphi<24; iphi++){
      float binVal=hRatioAll[ieta]->GetBinContent(iphi+1);
      effic[ieta][iphi]=binVal/normal[ieta];
      //cout<<"Eta "<<Form("%c",ieta+'A')<<" phi "<<iphi<<" effic "<<binVal<<endl;
      phiRad=hRatioAll[ieta]->GetXaxis()->GetBinCenter(iphi+1);
      
      //find tpc sector
      if(ieta<3) etaDet=-1;
      else if(ieta>6) etaDet=1;
      const float PI=TMath::Pi();
      int sec=0;
      float phi=phiRad/PI*180; // now in degrees
      if (etaDet>0) { // West TPC
	float x=75-phi;
	while(x<0) x+=360;
	sec=1+(int)( x/30.);
      } else {
	float x=phi-105;
	while(x<0) x+=360;
	sec=13+(int)( x/30.);
      }
      
      efficSec[ieta][sec-1]+=effic[ieta][iphi]/2; //average 2 bins in sector
    }
#if 0 //print weight arrays to use on data in W algo
    cout<<"mWeight"<<ieta+1<<"={";
    for(int isec=0; isec<24; isec++){
      //cout<<"sector "<<isec+1<<" eta "<<ieta<<" effic "<<efficSec[ieta][isec]<<endl;
      cout<<efficSec[ieta][isec]<<",";
    }
    cout<<"};"<<endl;
#endif
    //set weight arrays to use on MC in W algo
    for(int isec=0; isec<24; isec++){
      if(efficSec[ieta][isec]!=0) efficSec[ieta][isec]=1/efficSec[ieta][isec];
    //  cout<<"sector "<<isec+1<<" eta "<<ieta<<" effic "<<efficSec[ieta][isec]<<endl;
    }


  }

  //#endif
  
  
  //Data corrected for efficiencies in outer eta bins
  //hCorr->Draw("colz");
  hCorr->Rebin2D(10,10);
  hRatioCorr=(TH2F*) hQcdRebin->Clone();
  hRatioCorr->Divide(hCorrRebin);
  //hRatioCorr->Draw("colz");

  //add sector across pi boundry separately
  hCorr->ProjectionX("h1",1,1);
  hCorr->ProjectionX("h24",24,24);
  TH1 * hMidCorr[12];
  hMidCorr[11]=h1;hMidCorr[11]->Add(h24);
  
  bool print2=false;
  if(print2) c2=new TCanvas("bb","bb",800,600);
  for(int iphi=1; iphi<22; iphi+=2){ // get sector slices
    hCorr->ProjectionX(Form("h",iphi+1),iphi+1,iphi+2);   
    hMidCorr[(iphi-1)/2]=h;
   
    //find tpc sector
    float phiRad=hCorr->GetYaxis()->GetBinCenter(iphi+1);
    float etaDet=1;
    const float PI=TMath::Pi();
    int sec1=0; int sec2=0;
    float phi=phiRad/PI*180; // now in degrees
    float x=75-phi;
    while(x<0) x+=360;
    sec1=1+(int)( x/30.);
    float x=phi-105;
    while(x<0) x+=360;
    sec2=13+(int)( x/30.);

    
    //#if 0
    //calculate efficiency at midrapidity
    float etaVal[10]; float etaEffic[10];
    for(int ieta=0; ieta<10; ieta++)
      etaVal[ieta]=hMidCorr[(iphi-1)/2]->GetBinContent(ieta+1);
    float midRapVal=(etaVal[2]+etaVal[7])/2;
    if(sec2==13) float midRapVal=etaVal[2];
    for(int ieta2=3; ieta2<7; ieta2++){
      etaEffic[ieta2]=etaVal[ieta2]/midRapVal;
      if(ieta2<5){
	sec=sec2;
	//cout<<"sec "<<sec2<<" iphi "<<iphi<<" ieta "<<ieta2<<" effic "<<etaEffic[ieta2]<<endl;
      }
      else{
	sec=sec1;
	//cout<<"sec "<<sec1<<" iphi "<<iphi<<" ieta "<<ieta2<<" effic "<<etaEffic[ieta2]<<endl;
      }
      efficSec[ieta2][sec-1]=etaEffic[ieta2];
    }
    //#endif

    if(print2){
      Lx=h->GetListOfFunctions();
      h->SetStats(false);
      ln=new TLine(-0.44,midRapVal,0.44,midRapVal);
      ln->SetLineColor(kRed);  ln->SetLineWidth(2);
      Lx->Add(ln);
      h->SetMinimum(0); h->SetFillColor(kBlue);
      h->Draw();
      h->SetTitle(Form("Sectors %d and %d Tracks vs Eta",sec1,sec2)); 
      //c2->Print(Form("sec%d_%d.png",sec1,sec2));
    }
  }

  //do sector 9,15 separately
  for(int ieta=0; ieta<10; ieta++)
    etaVal[ieta]=hMidCorr[11]->GetBinContent(ieta+1);
  float midRapVal=(etaVal[2]+etaVal[7])/2;
  if(print2) {
    hMidCorr[11]->SetTitle("Sectors 9 and 15 Tracks vs Eta"); 
    hMidCorr[11]->Draw(); hMidCorr[11]->SetMinimum(0); c2->Print("sec9_15.ps");
    Lx=h->GetListOfFunctions();
    ln=new TLine(-PI,midRapVal,PI,midRapVal);
    ln->SetLineColor(kRed);  
    Lx->Add(ln);
  }
  for(int ieta2=3; ieta2<7; ieta2++){
    etaEffic[ieta2]=etaVal[ieta2]/midRapVal;
    if(ieta2<5){
      sec=15;
      //cout<<"sec "<<sec2<<" iphi "<<iphi<<" ieta "<<ieta2<<" effic "<<etaEffic[ieta2]<<endl;
    }
    else{
      sec=9;
      //cout<<"sec "<<sec1<<" iphi "<<iphi<<" ieta "<<ieta2<<" effic "<<etaEffic[ieta2]<<endl;
    }
    efficSec[ieta2][sec-1]=etaEffic[ieta2];
  }

#if 0  
  //print effic numbers
  for(int jeta=0;jeta<10;jeta++){
    cout<<"float mWeight"<<jeta+1<<"={";
    for(int jsec=0;jsec<24;jsec++){
      //cout<<"sec "<<jsec+1<<" eta "<<jeta<<" effic "<<efficSec[jeta][jsec]<<endl;
      cout<<efficSec[jeta][jsec]<<",";
    }
    cout<<"};"<<endl;
  }
#endif
  

}
Exemplo n.º 26
0
TH1F *draw_detector(string &name,map<string,void*> &card_channel)
{
    TH1F *h=new TH1F(name.c_str(),name.c_str(),13*64,0,13*64);
    h->SetMinimum(-2000);
    h->SetMaximum(-300);
    h->Draw();
    gPad->Update();

    if(1)
    {
        // Draw line between cards
        TLine *l = new TLine(h->GetXaxis()->GetXmin(),-800,h->GetXaxis()->GetXmax(),-800);
        //printf("(new TLine(%d,%d,%d,%d))->Draw();\n",i*64,h->GetMinimum(),i*64,h->GetMaximum());
        l->SetLineStyle(1);
        l->SetLineWidth(3);
        l->SetLineColor(kRed);
        l->Draw();
    }
    
    char
        *cards_x[]={"-10-S1","-10-S2","-10-S3",
                    "- 6-S1","- 6-S2","- 6-S3","- 6-S4","- 6-S5","- 6-S6",
                    "-10-J3","-10-J2","-10-J1",
                    "- 6-ph"},
        *cards_y[]={"-10-B1","-10-B2",
                    "- 6-B1","- 6-B2","- 6-B3","- 6-B4","- 6-B5","- 6-B6",
                    "-10-T2","-10-T1"};
    char **cards = name[1]=='Y' ? cards_y : cards_x;
    int cards_amount = name[1]=='Y' ? sizeof(cards_y)/sizeof(*cards_y) : sizeof(cards_x)/sizeof(*cards_x);
    
    for( int i=0; i<cards_amount; i++ )
    {
        string s = name+string(cards[i]);

        if(1)
        {
            // Draw line between cards
            TLine *l = new TLine(i*64,h->GetMinimum(),i*64,h->GetMaximum());
            //printf("(new TLine(%d,%d,%d,%d))->Draw();\n",i*64,h->GetMinimum(),i*64,h->GetMaximum());
            l->SetLineStyle(2);
            l->Draw();
        }

        if(1)
        {
            // Put the card name
            TText *m = new TText(i*64+40,h->GetMinimum()+5,s.c_str());
            m->SetTextAngle(90);
            m->Draw();
        }
    
        vector<int> *v = card_channel[s];
        if( v==NULL )
        {
            printf("Card not found: %s\n",s.c_str());
            continue;
        }
        
        if( v->size()!=64 )
            printf("Bad number of channels!  %d\n",v->size());

        for( int b=0; b<v->size(); b++ )
            h->SetBinContent(i*64+b+1,(*v)[b]);
    }
    
    return h;
}
void PostProcessQAMultistrange(Int_t   icasType        = 0,                             // 0) Xi- 1) Xi+ 2) Omega- 3) Omega+
                               Int_t   collidingsystem = 2,                             // 0) PbPb  1) pp 2) pPb
                               Bool_t  isMC            = kTRUE,                         // kTRUE-->MC and kFALSE-->Exp.
                               Char_t *fileDir         = ".",                           // Input file directory
                               Char_t *filein          = "AnalysisResults.root"         // Input file name
                              ) {


     //___________________
     //DEFINE DRAW OPTIONS
     gStyle->SetOptStat(1110);
     gStyle->SetOptStat(kFALSE);
     gStyle->SetOptTitle(kFALSE);
     gStyle->SetFrameLineWidth(2.5);
     gStyle->SetCanvasColor(0);
     gStyle->SetPadColor(0);
     gStyle->SetHistLineWidth(2.5);
     gStyle->SetLabelSize(0.05, "x");
     gStyle->SetLabelSize(0.05, "y");
     gStyle->SetTitleSize(0.05, "x");
     gStyle->SetTitleSize(0.05, "y");
     gStyle->SetTitleOffset(1.1, "x");
     gStyle->SetPadBottomMargin(0.14);

     //_______________________
     //SOURCE USEFUL LIBRARIES
     gSystem->Load("libANALYSIS.so");
     gSystem->Load("libANALYSISalice.so");
     gSystem->Load("libCORRFW.so");

     //_________________________________
     //SOURCE THE FILE AND THE CONTAINER
     TFile *f1 = new TFile(Form("%s/%s",fileDir,filein));
     AliCFContainer *cf = (AliCFContainer*) (f1->Get("PWGLFStrangeness.outputCheckCascade/fCFContCascadeCuts"));  
 
     //____________
     //DEEFINE TEXT
     TLatex* t1 = new TLatex(0.6,0.55,"#color[3]{OK!!}");
     t1->SetTextSize(0.1);
     t1->SetNDC();
     TLatex* t2 = new TLatex(0.6,0.55,"#color[2]{NOT OK!!}");
     t2->SetTextSize(0.1);
     t2->SetNDC();
     t2->SetTextColor(2);
     TLatex* tcasc;
     if      (icasType == 0) tcasc = new TLatex(0.8,0.7,"#color[1]{#Xi^{-}}");
     else if (icasType == 1) tcasc = new TLatex(0.8,0.7,"#color[1]{#Xi^{+}}");
     else if (icasType == 2) tcasc = new TLatex(0.8,0.7,"#color[1]{#Omega^{-}}");
     else if (icasType == 3) tcasc = new TLatex(0.8,0.7,"#color[1]{#Omega^{+}}");
     tcasc->SetTextSize(0.2);
     tcasc->SetNDC();
     tcasc->SetTextColor(2);
     TLatex* tpdgmass;
     if      (icasType == 0) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.321 GeV/c^{2}}");
     else if (icasType == 1) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.321 GeV/c^{2}}");
     else if (icasType == 2) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.672 GeV/c^{2}}");
     else if (icasType == 3) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.672 GeV/c^{2}}");
     tpdgmass->SetTextSize(0.07);
     tpdgmass->SetNDC();
     tpdgmass->SetTextColor(2);

     //________________________________ 
     //DEFINE 1st CANVAS AND DRAW PLOTS
     TCanvas *c1 = new TCanvas("c1","",1200,800);
     c1->Divide(2,3); 
       //Pad 1: DCA cascade daughters
       c1->cd(1);
       gPad->SetLogy();
       TH1D *hvar0 = cf->ShowProjection(0,icasType);
       hvar0->Draw("histo");
       Double_t x0;
       if      (collidingsystem == 0) x0 = 0.3;
       else if (collidingsystem == 1) x0 = 2.0;
       else if (collidingsystem == 2) x0 = 2.0;
       TLine *line0 = new TLine(x0,0.,x0,hvar0->GetBinContent(hvar0->GetMaximumBin()));
       line0->SetLineColor(kRed);
       line0->SetLineStyle(9);
       line0->SetLineWidth(2.0);
       line0->Draw("same");
          Bool_t check_0 = checkOverTheLimit(hvar0, x0);
          if (check_0) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       tcasc->Draw();
       //Pad 2: Bachelor IP to PV
       c1->cd(2);
       gPad->SetLogy();
       TH1D *hvar1 = cf->ShowProjection(1,icasType);
       hvar1->GetXaxis()->SetRangeUser(0.,0.24);
       hvar1->Draw("histo");
       Double_t x1;
       if      (collidingsystem == 0) x1 = 0.03;
       else if (collidingsystem == 1) x1 = 0.01;
       else if (collidingsystem == 2) x1 = 0.03;
       TLine *line1 = new TLine(x1,0.,x1,hvar1->GetBinContent(hvar1->GetMaximumBin()));
       line1->SetLineColor(kRed);
       line1->SetLineStyle(9);
       line1->SetLineWidth(2.0);
       line1->Draw("same");
          Bool_t check_1 = checkUnderTheLimit(hvar1, x1);
          if (check_1) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 3: Cascade cosine of Pointing Angle
       c1->cd(3);
       gPad->SetLogy();
       TH1D *hvar2 = cf->ShowProjection(2,icasType);
       Double_t max2 = hvar2->GetBinContent(hvar2->GetMaximumBin());
       hvar2->GetYaxis()->SetRangeUser(0.01,max2*1.5);
       hvar2->Draw("histo");
       Double_t x2;
       if      (collidingsystem == 0) x2 = 0.999;
       else if (collidingsystem == 1) x2 = 0.98;
       else if (collidingsystem == 2) x2 = 0.95;
       TLine *line2 = new TLine(x2,0.,x2,hvar2->GetBinContent(hvar2->GetMaximumBin()));
       line2->SetLineColor(kRed);
       line2->SetLineStyle(9);
       line2->SetLineWidth(2.0);
       line2->Draw("same");
       line1->Draw("same");
          Bool_t check_2 = checkUnderTheLimit(hvar2, x2);
          if (check_2) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 4: Cascade radius of fiducial volume
       c1->cd(4);
       gPad->SetLogy();
       TH1D *hvar3 = cf->ShowProjection(3,icasType);
       hvar3->GetXaxis()->SetRangeUser(0.,3.8);
       hvar3->Draw("histo");
       Double_t x3;
       if      (collidingsystem == 0) x3 = 0.9;
       else if (collidingsystem == 1) x3 = 0.2;
       else if (collidingsystem == 2) x3 = 0.4;
       TLine *line3 = new TLine(x3,0.,x3,hvar3->GetBinContent(hvar3->GetMaximumBin()));
       line3->SetLineColor(kRed);
       line3->SetLineStyle(9);
       line3->SetLineWidth(2.0);
       line3->Draw("same");
          Bool_t check_3 = checkUnderTheLimit(hvar3, x3);
          if (check_3) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 5: Invariant mass Lambda
       c1->cd(5);
       TH1D *hvar4 = cf->ShowProjection(4,icasType);
       hvar4->Draw("histo");
       Double_t x41;
       if      (collidingsystem < 2)  x41 = 1.116 + 0.008;
       else if (collidingsystem == 2) x41 = 1.116 + 0.010;
       TLine *line41 = new TLine(x41,0.,x41,hvar4->GetBinContent(hvar4->GetMaximumBin()));
       line41->SetLineColor(kRed);
       line41->SetLineStyle(9);
       line41->SetLineWidth(2.0);
       line41->Draw("same");
       Double_t x42;
       if      (collidingsystem < 2)  x42 = 1.115 - 0.008;
       else if (collidingsystem == 2) x42 = 1.115 - 0.010;
       TLine *line42 = new TLine(x42,0.,x42,hvar4->GetBinContent(hvar4->GetMaximumBin()));
       line42->SetLineColor(kRed);
       line42->SetLineStyle(9);
       line42->SetLineWidth(2.0);
       line42->Draw("same");

       //   for (Int_t i = 0; i < hvar4->GetNbinsX()+1; i++) {
       //        cout<<"Content bin:   "<<i<<": "<<hvar4->GetBinContent(i)<<endl;
       //        cout<<"Bin low edge:  "<<hvar4->GetBinLowEdge(i)<<endl;
       //        cout<<"Bin high edge: "<<hvar4->GetBinLowEdge(i+1)<<endl;
       //   }   
       //   cout<<"Low check limit: "<<x42<<endl;
       //   cout<<"High check limit: "<<x41<<endl;

          Bool_t check_4_1 = checkUnderTheLimit(hvar4, x42);
          Bool_t check_4_2 = checkOverTheLimit(hvar4, x41);
          if (check_4_1 && check_4_2) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else                        { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 6: DCA V0 daughters
       c1->cd(6);
       gPad->SetLogy();
       TH1D *hvar5 = cf->ShowProjection(5,icasType);
       hvar5->Draw("histo");
       Double_t x5;
       if      (collidingsystem == 0) x5 = 1.0;
       else if (collidingsystem == 1) x5 = 1.5;
       else if (collidingsystem == 2) x5 = 2.0;
       TLine *line5 = new TLine(x5,0.,x5,hvar5->GetBinContent(hvar5->GetMaximumBin()));
       line5->SetLineColor(kRed);
       line5->SetLineStyle(9);
       line5->SetLineWidth(2.0);
       line5->Draw("same");
          Bool_t check_5 = checkOverTheLimit(hvar5, x5);
          if (check_5) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
     c1->SaveAs("fig_lf_Multistrange.pdf(");
    
     //________________________________
     //DEFINE 2nd CANVAS AND DRAW PLOTS
     TCanvas *c2 = new TCanvas("c2","",1200,800);
     c2->Divide(2,3);
       //Pad 1: V0 cosine of Pointing Angle to PV
       c2->cd(1);
       gPad->SetLogy();
       TH1D *hvar6 = cf->ShowProjection(6,icasType);
       Double_t max6 = hvar6->GetBinContent(hvar6->GetMaximumBin());
       hvar6->GetYaxis()->SetRangeUser(0.01,max6*1.5);
       hvar6->Draw("histo");
       //Pad 2: Min V0 Radius Fid. Vol.  
       c2->cd(2);
       gPad->SetLogy();
       TH1D *hvar7 = cf->ShowProjection(7,icasType);
       hvar7->GetXaxis()->SetRangeUser(0.,3.0);
       hvar7->Draw("histo");
       Double_t x7;
       if      (collidingsystem == 0) x7 = 0.9;
       else if (collidingsystem == 1) x7 = 0.2;
       else if (collidingsystem == 2) x7 = 0.4;
       TLine *line7 = new TLine(x7,0.,x7,hvar7->GetBinContent(hvar7->GetMaximumBin()));
       line7->SetLineColor(kRed);
       line7->SetLineStyle(9);
       line7->SetLineWidth(2.0);
       line7->Draw("same");
          Bool_t check_7 = checkUnderTheLimit(hvar7, x7);
          if (check_7) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad3: Min DCA V0 To PV
       c2->cd(3);
       gPad->SetLogy();
       TH1D *hvar8 = cf->ShowProjection(8,icasType);
       hvar8->GetXaxis()->SetRangeUser(0.,0.3);
       hvar8->Draw("histo");
       Double_t x8;
       if      (collidingsystem == 0) x8 = 0.05;
       else if (collidingsystem == 1) x8 = 0.01;
       else if (collidingsystem == 2) x8 = 0.05;
       TLine *line8 = new TLine(x8,0.,x8,hvar8->GetBinContent(hvar8->GetMaximumBin()));
       line8->SetLineColor(kRed);
       line8->SetLineStyle(9);
       line8->SetLineWidth(2.0);
       line8->Draw("same");
          Bool_t check_8 = checkUnderTheLimit(hvar8, x8);
          if (check_8) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 4: Min DCA Pos To PV
       c2->cd(4);
       gPad->SetLogy();
       TH1D *hvar9 = cf->ShowProjection(9,icasType);
       hvar9->GetXaxis()->SetRangeUser(0.,0.2);
       hvar9->Draw("histo");
       Double_t x9;
       if      (collidingsystem == 0) x9 = 0.1;
       else if (collidingsystem == 1) x9 = 0.05;
       else if (collidingsystem == 2) x9 = 0.02;
       TLine *line9 = new TLine(x9,0.,x9,hvar9->GetBinContent(hvar9->GetMaximumBin()));
       line9->SetLineColor(kRed);
       line9->SetLineStyle(9);
       line9->SetLineWidth(2.0);
       line9->Draw("same");
          Bool_t check_9 = checkUnderTheLimit(hvar9, x9);
          if (check_9) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 5: Min DCA Neg To PV
       c2->cd(5);
       gPad->SetLogy();
       TH1D *hvar10 = cf->ShowProjection(10,icasType);
       hvar10->GetXaxis()->SetRangeUser(0.,0.2);
       hvar10->Draw("histo");
       Double_t x10;
       if      (collidingsystem == 0) x10 = 0.1;
       else if (collidingsystem == 1) x10 = 0.05;
       else if (collidingsystem == 2) x10 = 0.02;
       TLine *line10 = new TLine(x10,0.,x10,hvar10->GetBinContent(hvar10->GetMaximumBin()));
       line10->SetLineColor(kRed);
       line10->SetLineStyle(9);
       line10->SetLineWidth(2.0);
       line10->Draw("same");
          Bool_t check_10 = checkUnderTheLimit(hvar10, x10);
          if (check_10) { cout<<"The cut is OK!!"<<endl; t1->Draw(); }
          else         { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); }
       //Pad 6: V0 cosine of Pointing Angle to Xi vtx
       c2->cd(6);
       gPad->SetLogy();
       TH1D *hvar20 = cf->ShowProjection(18,icasType);
       Double_t max20 = hvar20->GetBinContent(hvar20->GetMaximumBin());
       hvar20->GetYaxis()->SetRangeUser(0.01,max20*1.5);
       hvar20->Draw("histo");
     c2->SaveAs("fig_lf_Multistrange.pdf");

     //________________________________
     //DEFINE 3rd CANVAS AND DRAW PLOTS
     TCanvas *c3 = new TCanvas("c3","",1200,800);
     c3->Divide(2,3);
       //Pad 1: InvMass
       c3->cd(1);
       TH1D *hvar12 = cf->ShowProjection(11+icasType/2,icasType);
       hvar12->Draw("histo");
       tpdgmass->Draw(); 
       TLine *linemass;
       if      (icasType == 0) linemass = new TLine(1.32171,0.,1.32171,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin()));
       else if (icasType == 1) linemass = new TLine(1.32171,0.,1.32171,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin()));
       else if (icasType == 2) linemass = new TLine(1.67245,0.,1.67245,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin()));
       else if (icasType == 3) linemass = new TLine(1.67245,0.,1.67245,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin()));
       linemass->SetLineColor(kRed);
       linemass->SetLineStyle(1);
       linemass->SetLineWidth(2.0);
       linemass->Draw("same");
       //Pad 2: Transverse momentum
       c3->cd(2);
       TH1D *hvar13 = cf->ShowProjection(13,icasType);
       hvar13->Draw("histo");
       //Pad 3: Y
       c3->cd(3);
       TH1D *hvar14 = cf->ShowProjection(14+icasType/2,icasType);
       hvar14->Draw("histo");
       //Pad 4: Cascade proper length
       c3->cd(4);
       TH1D *hvar18;
       hvar18 = cf->ShowProjection(16,icasType);
       hvar18->GetXaxis()->SetRangeUser(0.,90.);
       hvar18->Draw("histo");
       //Pad 5: V0 proper length 
       c3->cd(5);
       TH1D *hvar19;
       hvar19 = cf->ShowProjection(17,icasType);
       hvar19->GetXaxis()->SetRangeUser(0.,90.);
       hvar19->Draw("histo");
       //Pad 6
       // empty 
     c3->SaveAs("fig_lf_Multistrange.pdf");

     //________________________________ 
     //DEFINE 4th CANVAS AND DRAW PLOTS
     TCanvas *c4 = new TCanvas("c4","",600,400);
     c4->Divide(2,1);
       //Pad1: invariant mass fit
       c4->cd(1);
       TH1D *hvar18 = cf->ShowProjection(11+icasType/2,icasType);
       hvar18->Draw("histo");
        // - SOME PARAMETER VALUE
        Bool_t kfitgauss = kFALSE;
        Bool_t kfitleft  = kFALSE;
        Bool_t kfitright = kFALSE;
        Int_t  ptbinNarrowY = 0;
        if (icasType < 2) ptbinNarrowY = 10;   // 6;
        else              ptbinNarrowY =  3;   // 2;
        // - SOME DEFINITIONS
        Float_t lowlimmass;
        Float_t uplimmass;
        Float_t lowgausslim;
        Float_t upgausslim;
        if (icasType==0||icasType==1) {
            lowlimmass=1.30;
            uplimmass=1.34;
            lowgausslim=1.312;
            upgausslim=1.332;
        } else {
            lowlimmass=1.645;
            uplimmass=1.70;
            lowgausslim=1.668;
            upgausslim=1.678;
        }
        TF1*  fitinvmass = new TF1("fitinvmass","gaus(0)+pol2(3)",lowlimmass,uplimmass);
        fitinvmass->SetParName(0, "cnstntG");
        fitinvmass->SetParName(1, "meanG");
        fitinvmass->SetParName(2, "sigmaG");
        fitinvmass->SetParLimits(0,0.,500000.);
        if (icasType==0||icasType==1) {
            fitinvmass->SetParameter(1, 1.32171);
            fitinvmass->SetParLimits(1, 1.31,1.33);
            fitinvmass->SetParLimits(2,0.001,0.005);
        } else {
            fitinvmass->SetParameter(1, 1.67245);
            fitinvmass->SetParLimits(1, 1.664,1.68);
            fitinvmass->SetParLimits(2,0.0008,0.006);
        }
        hvar18->Fit("fitinvmass","rimeN");
        fitinvmass->SetLineColor(kRed);
        fitinvmass->Draw("same");
        Float_t meanGauss   = fitinvmass->GetParameter(1);
        Float_t sigmaGauss  = fitinvmass->GetParameter(2);
       cout<<"Mean: "<<meanGauss<<endl;
       cout<<"Sigma: "<<sigmaGauss<<endl;
       //Pad2: Text
       c4->cd(2);
       Float_t refwidth = 0.002;
       if (icasType > 1) refwidth = 0.0025;
       TPaveText *pave1 = new TPaveText(0.05,0.3,0.95,0.5);
       pave1->SetFillColor(0);
       pave1->SetTextSize(0.04);
       pave1->SetTextAlign(12);
       if (icasType < 2) pave1->AddText("PDG mass: 1.32171 GeV/c^{2}");
       else              pave1->AddText("PDG mass: 1.67245 GeV/c^{2}");
       pave1->AddText(Form("#color[1]{Mass form Fit: %.5f #pm %.5f GeV/c^{2}}",meanGauss,sigmaGauss));
       if (sigmaGauss > refwidth - 0.0003 && sigmaGauss < refwidth + 0.0003) pave1->AddText("#color[3]{OK!! The width is compatible with standard.}");
       else                                                                  pave1->AddText("#color[2]{NOT OK!! Problem.}");
       pave1->Draw();
       cout<<"   "<<refwidth - 0.0003<<"<"<<sigmaGauss<<"<"<<refwidth + 0.0003<<endl;
     c4->SaveAs("fig_lf_Multistrange.pdf");   

     //________________________________ 
     //DEFINE 5th CANVAS AND DRAW PLOTS
     if (collidingsystem == 0 || collidingsystem == 2) {
         TCanvas *c5 = new TCanvas("c5","",600,720);//1200,270);
         //c5->Divide(2,1);
           //Pad 1: centrality
           c5->cd(1);
           TH1D *hvar16 = cf->ShowProjection(19,icasType);
           hvar16->Draw("histo");
           //Pad 2: track multiplicity
           //c5->cd(2);
           //TH1D *hvar17 = cf->ShowProjection(20,icasType);
           //hvar17->Draw("histo");
         if      (!isMC) c5->SaveAs("fig_lf_Multistrange.pdf)");
         else if (isMC) c5->SaveAs("fig_lf_Multistrange.pdf");
     }
    


     //_______________________________
     //CHECK ON MONTE CARLO PRODUCTION
     if (isMC) { 
           
            AliCFContainer *cfMC = (AliCFContainer*) (f1->Get("PWGLFStrangeness.outputCheckCascade/fCFContCascadeMCgen"));
            //DEFINE 6th CANVAS AND DRAW PLOTS
            TCanvas *c6 = new TCanvas("c6","",1200,800);
            c6->Divide(2,3);
            //Pad 1: Total Momentum
            c6->cd(1);
            TH1D *hvar17 = cfMC->ShowProjection(0,icasType);
            hvar17->Draw("histo");
            tcasc->Draw();
            //Pad 2: Transverse Momentum
            c6->cd(2);
            TH1D *hvar18 = cfMC->ShowProjection(1,icasType);
            hvar18->Draw("histo");
            //Pad 3: Rapidity (y)
            c6->cd(3);
            TH1D *hvar19 = cfMC->ShowProjection(2,icasType);
            hvar19->Draw("histo");
            //Pad 4: Pseudo-rapidity (eta)
            c6->cd(4);
            TH1D *hvar20 = cfMC->ShowProjection(3,icasType);
            hvar20->Draw("histo");
            //Pad 5: Theta
            c6->cd(5);
            TH1D *hvar21 = cfMC->ShowProjection(4,icasType);
            hvar21->Draw("histo");
            //Pad 6: Phi
            c6->cd(6);
            TH1D *hvar22 = cfMC->ShowProjection(5,icasType);
            hvar22->Draw("histo");
    
            c6->SaveAs("fig_lf_Multistrange.pdf)");
     }


}
Exemplo n.º 28
0
TF1* fit(Double_t ptmin, Double_t ptmax)
{
  TCanvas* c = new TCanvas(Form("c_%.0f_%.0f",ptmin,ptmax),"",600,600);
  TFile* infile = new TFile(Form("%s_%s_%.0f_%.0f.root",infname.Data(),collisionsystem.Data(),ptmin,ptmax));
  TH1D* h = (TH1D*)infile->Get("h");                    h->SetName(Form("h_%.0f_%.0f",ptmin,ptmax));
  TH1D* hMCSignal = (TH1D*)infile->Get("hMCSignal");    hMCSignal->SetName(Form("hMCSignal_%.0f_%.0f",ptmin,ptmax));
  TH1D* hMCSwapped = (TH1D*)infile->Get("hMCSwapped");  hMCSwapped->SetName(Form("hMCSwapped_%.0f_%.0f",ptmin,ptmax));
  TF1* f = new TF1(Form("f_%.0f_%.0f",ptmin,ptmax),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]*exp([4]*x)", 1.7, 2.0);

  f->SetParLimits(10,0.001,0.05);
  f->SetParLimits(2,0.01,0.1);
  f->SetParLimits(8,0.02,0.2);
  f->SetParLimits(7,0,1);
  f->SetParLimits(9,0,1);
  
  f->SetParameter(0,setparam0);
  f->SetParameter(1,setparam1);
  f->SetParameter(2,setparam2);
  f->SetParameter(10,setparam10);
  f->SetParameter(9,setparam9);

  f->FixParameter(8,setparam8);
  f->FixParameter(7,1);
  f->FixParameter(1,fixparam1);
  f->FixParameter(3,0);
  f->FixParameter(4,0);
  h->GetEntries();
  
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  f->FixParameter(1,f->GetParameter(1));
  f->FixParameter(2,f->GetParameter(2));
  f->FixParameter(10,f->GetParameter(10));
  f->FixParameter(9,f->GetParameter(9));
  f->FixParameter(7,0);
  f->ReleaseParameter(8);
  f->SetParameter(8,setparam8);
  
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  f->SetParLimits(0,0,1.e+6);
  f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000)));
  f->FixParameter(8,f->GetParameter(8));
  f->ReleaseParameter(3);
  f->ReleaseParameter(4);
  f->SetParLimits(3,0,1.e+10);
  f->SetParameter(3,1.e+3);

  f->SetLineColor(kRed);
  
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  f->SetParLimits(1,1.85,1.90);
  //f->ReleaseParameter(2);                                     // you need to release these two parameters if you want to perform studies on the sigma shape
  //f->ReleaseParameter(10);                                   // you need to release these two parameters if you want to perform studies on the sigma shape
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  TF1* background = new TF1(Form("background_%.0f_%.0f",ptmin,ptmax),"[0]*exp([1]*x)");
  background->SetParameter(0,f->GetParameter(3));
  background->SetParameter(1,f->GetParameter(4));
  background->SetLineColor(4);
  background->SetRange(minhisto,maxhisto);
  background->SetLineStyle(2);
  
  TF1* mass = new TF1(Form("fmass_%.0f_%.0f",ptmin,ptmax),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))");
  mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10));
  mass->SetParError(0,f->GetParError(0));
  mass->SetParError(1,f->GetParError(1));
  mass->SetParError(2,f->GetParError(2));
  mass->SetParError(3,f->GetParError(7));
  mass->SetParError(4,f->GetParError(9));
  mass->SetParError(5,f->GetParError(10));
  mass->SetFillColor(kOrange-3);
  mass->SetFillStyle(3002);
  mass->SetLineColor(kOrange-3);
  mass->SetLineWidth(3);
  mass->SetLineStyle(2);
  
  TF1* massSwap = new TF1(Form("fmassSwap_%.0f_%.0f",ptmin,ptmax),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])");
  massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8));
  massSwap->SetParError(0,f->GetParError(0));
  massSwap->SetParError(1,f->GetParError(1));
  massSwap->SetParError(2,f->GetParError(7));
  massSwap->SetParError(3,f->GetParError(8));
  massSwap->SetFillColor(kGreen+4);
  massSwap->SetFillStyle(3005);
  massSwap->SetLineColor(kGreen+4);
  massSwap->SetLineWidth(3);
  massSwap->SetLineStyle(1);
  
  h->SetXTitle("m_{#piK} (GeV/c^{2})");
  h->SetYTitle("Entries / (5 MeV/c^{2})");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");

  background->Draw("same");   
  mass->SetRange(minhisto,maxhisto);	
  mass->Draw("same");
  massSwap->SetRange(minhisto,maxhisto);
  massSwap->Draw("same");
  f->Draw("same");
  
  Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
  Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
  
  std::cout<<"YIELD="<<yield<<std::endl;

  TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f");
  leg->AddEntry(massSwap,"K-#pi swapped","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  texCms->SetNDC();
  texCms->SetTextAlign(12);
  texCms->SetTextSize(0.04);
  texCms->SetTextFont(42);
  texCms->Draw();

  TLatex* texCol = new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV",collisionsystem.Data()));
  texCol->SetNDC();
  texCol->SetTextAlign(32);
  texCol->SetTextSize(0.04);
  texCol->SetTextFont(42);
  texCol->Draw();

  TLatex* texPt = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax));
  texPt->SetNDC();
  texPt->SetTextFont(42);
  texPt->SetTextSize(0.04);
  texPt->SetLineWidth(2);
  texPt->Draw();

  TLatex* texY = new TLatex(0.22,0.83,"|y| < 1.0");
  texY->SetNDC();
  texY->SetTextFont(42);
  texY->SetTextSize(0.04);
  texY->SetLineWidth(2);
  texY->Draw();

  TLatex* texYield = new TLatex(0.22,0.73,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr));
  texYield->SetNDC();
  texYield->SetTextFont(42);
  texYield->SetTextSize(0.04);
  texYield->SetLineWidth(2);
  texYield->Draw();

  c->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f.pdf",collisionsystem.Data(),ptmin,ptmax));
  
  TCanvas* cPull = new TCanvas(Form("cPull_%.0f_%.0f",ptmin,ptmax),"",600,700);
  TH1D* hPull = (TH1D*)h->Clone("hPull");
  for(int i=0;i<h->GetNbinsX();i++)
    {
      Double_t nfit = f->Integral(h->GetBinLowEdge(i+1),h->GetBinLowEdge(i+1)+h->GetBinWidth(i+1))/h->GetBinWidth(i+1);
      if(h->GetBinError(i+1)==0)
        {
          hPull->SetBinContent(i+1,0.);
        }
      else hPull->SetBinContent(i+1,(h->GetBinContent(i+1)-nfit)/h->GetBinError(i+1));
      hPull->SetBinError(i+1,0);
    }
  hPull->SetMinimum(-4.);
  hPull->SetMaximum(4.);
  hPull->SetYTitle("Pull");
  hPull->GetXaxis()->SetTitleOffset(1.);
  hPull->GetYaxis()->SetTitleOffset(0.65);
  hPull->GetXaxis()->SetLabelOffset(0.007);
  hPull->GetYaxis()->SetLabelOffset(0.007);
  hPull->GetXaxis()->SetTitleSize(0.12);
  hPull->GetYaxis()->SetTitleSize(0.12);
  hPull->GetXaxis()->SetLabelSize(0.1);
  hPull->GetYaxis()->SetLabelSize(0.1);
  hPull->GetYaxis()->SetNdivisions(504);
  TLine* lPull = new TLine(1.7, 0, 2., 0);
  lPull->SetLineWidth(1);
  lPull->SetLineStyle(7);
  lPull->SetLineColor(1);
  TPad* pFit = new TPad("pFit","",0,0.3,1,1);
  pFit->SetBottomMargin(0);
  pFit->Draw();
  pFit->cd();
  h->Draw("e");
  background->Draw("same");
  mass->Draw("same");
  massSwap->Draw("same");
  f->Draw("same");
  leg->Draw("same");
  texCms->Draw();
  texCol->Draw();
  texPt->Draw();
  texY->Draw();
  texYield->Draw();
  cPull->cd();
  TPad* pPull = new TPad("pPull","",0,0,1,0.3);
  pPull->SetTopMargin(0);
  pPull->SetBottomMargin(0.3);
  pPull->Draw();
  pPull->cd();
  hPull->Draw("p");
  lPull->Draw();
  cPull->cd();
  cPull->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f_Pull.pdf",collisionsystem.Data(),ptmin,ptmax));

  return mass;
}
Exemplo n.º 29
0
void unfoldAssess(){

  int norder_     = 3;
  int QnBinOrder_ = 2;
  double tkEta    = 2.4;

  bool RFplot     = 1;
  bool SaveSumPl  = 1;

  bool dosys     = 0;

  bool looseChi2IterCut   = 0;
  bool nominalChi2IterCut = 1;
  bool tightChi2IterCut   = 0;

  double momentMin = 0.0;
  double momentMax = 0.39;

  double momentTitleSize = 0.05;
  double momentTitleOffS = 1.5;
  double momentAxisLabS  = 0.04;
  double qnmin           = 0;
  double qnmax           = 0.26;
  double chi2Min         = 0.1;
  double chi2Max         = 10000.;

  TLatex latex;
  TLatex latex2;

  //-- Qn binning
  TFile * fQn;
  TH1D * hqbins[NCENT][NEPSymm];
  TH1D * hqnHF_EP[NCENT][NEPSymm];

  //-- Analyzer Output
  TFile * fAna;
  TH1D * hObs[NCENT][NEPSymm][NQN];

  //-- Unfolding output
  TFile * fUnfold;
  TH2D * hResp[NCENT][NEPSymm][NQN];
  TH1D * hUnfold[NCENT][NEPSymm][NQN][NITER];
  TH1D * hRefold[NCENT][NEPSymm][NQN][NITER];
  TH1D * hRefoldRatio[NCENT][NEPSymm][NQN][NITER];

  //-- Unfolding moments
  double unfold_mean[NCENT][NEPSymm][NQN][NITER];
  double unfold_stDev[NCENT][NEPSymm][NQN][NITER];
  double unfold_RMS[NCENT][NEPSymm][NQN][NITER];
  double unfold_RelFluct[NCENT][NEPSymm][NQN][NITER];

  double unfold_meane[NCENT][NEPSymm][NQN][NITER];
  double unfold_stDeve[NCENT][NEPSymm][NQN][NITER];
  double unfold_RMSe[NCENT][NEPSymm][NQN][NITER];
  double unfold_RelFlucte[NCENT][NEPSymm][NQN][NITER];

  //-- Moment vs iter graphs
  TMultiGraph * grMoments[NCENT][NEPSymm][NQN];
  TGraphErrors * grUnfoldMean[NCENT][NEPSymm][NQN];
  TGraphErrors * grUnfoldStDev[NCENT][NEPSymm][NQN];
  TGraphErrors * grUnfoldRMS[NCENT][NEPSymm][NQN];

  //-- Chi Squares for iteration cutoffs
  double chi2NDF_Refold[NCENT][NEPSymm][NQN][NITER];

  //-- Chi square plots
  double chi2Cut;
  TGraphErrors * grChi2NDF_Refold[NCENT][NEPSymm][NQN];

  //-- Canvases
  TCanvas * cSummary[NCENT][NEPSymm][NQN];

  //
  // MAIN
  //

  setTDRStyle();
  latex.SetNDC();
  latex2.SetNDC();
  latex2.SetTextFont(43);
  latex2.SetTextSize(15);

  //-- Set the chi2 cutoff
  bool c2c1 = looseChi2IterCut   && nominalChi2IterCut;
  bool c2c2 = looseChi2IterCut   && tightChi2IterCut;
  bool c2c3 = nominalChi2IterCut && tightChi2IterCut;
  bool c2c4 = looseChi2IterCut   && nominalChi2IterCut && tightChi2IterCut;

  if( c2c1 || c2c2 || c2c3 || c2c4){
    std::cout<<"WARNING! More than one chi2 cutoff scenario defined for unfolding.  Check the flags at the beginning of this macro and fix your mistake."<<std::endl;
    std::cout<<"Exiting macro now...  Have a nice day!"<<std::endl;
    exit(0);
  }

  if( looseChi2IterCut )   chi2Cut = 1.5;
  if( nominalChi2IterCut ) chi2Cut = 1.2;
  if( tightChi2IterCut )   chi2Cut = 1.0;

  //-- Get the QN binning file
  fQn = new TFile( Form( "../../v%i/eta2.4/AnalyzerResults/q%iCuts.root", QnBinOrder_, QnBinOrder_) );

  //-- Get the Analyzer output file
  fAna = new TFile( "AnalyzerResults/CastleEbyE.root" );

  //-- Get the unfolding output file
  fUnfold = new TFile( Form("UnfoldResults/dataResp/data%i.root", norder_) );


  //-- Start looping over the data...
  for(int icent = 0; icent < NCENT; icent++){

    for(int iEP = 0; iEP < NEPSymm; iEP++){
      if( iEP != EPSymmBin ) continue;

      //-- Get the QN binning and the QN distributions
      hqbins[icent][iEP]   = (TH1D*) fQn->Get( Form("hqbins_%s_c%i", EPSymmNames[iEP].data(), icent) );
      hqnHF_EP[icent][iEP] = (TH1D*) fQn->Get( Form("hqnHF_c%i_EP%i", icent, iEP) );

      for(int iqn = 0; iqn < NQN; iqn++){

	//-- Get the VN observed histogram
	hObs[icent][iEP][iqn] = (TH1D*) fAna->Get( Form("qwebye/hVnFull_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn) );
	hObs[icent][iEP][iqn]->SetMaximum( 10.*hObs[icent][iEP][iqn]->GetMaximum() );
	hObs[icent][iEP][iqn]->SetMarkerStyle(24);

	bool cutoff = 0;
	for(int i = 0; i < NITER; i++){

	  //-- Get the Response histogram
	  hResp[icent][iEP][iqn] = (TH2D*) fUnfold->Get( Form("hresp_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn) );

	  //-- Get the unfolded histograms
	  hUnfold[icent][iEP][iqn][i] = (TH1D*) fUnfold->Get( Form("hreco%i_%s_c%i_qbin%i", iter[i], EPSymmNames[iEP].data(), icent, iqn) );
	  hUnfold[icent][iEP][iqn][i]->SetLineColor(col[i]);
	  hUnfold[icent][iEP][iqn][i]->SetMarkerColor(col[i]);

	  //-- Get the Refolded histograms
	  hRefold[icent][iEP][iqn][i] = (TH1D*) fUnfold->Get( Form("hrefold%i_%s_c%i_qbin%i", iter[i], EPSymmNames[iEP].data(), icent, iqn) );
	  hRefold[icent][iEP][iqn][i]->SetLineWidth(2);
	  hRefold[icent][iEP][iqn][i]->SetLineColor(col[i]);
          hRefold[icent][iEP][iqn][i]->SetMarkerColor(col[i]);

	  //-- Make the refold/observed histograms
	  hRefoldRatio[icent][iEP][iqn][i] = (TH1D*) hRefold[icent][iEP][iqn][i]->Clone( Form("hRefoldRatio%i_%s_c%i_qbin%i", iter[i], EPSymmNames[iEP].data(), icent, iqn) );
	  hRefoldRatio[icent][iEP][iqn][i]->GetXaxis()->SetTitle( Form("v_{%i}", norder_) );
	  hRefoldRatio[icent][iEP][iqn][i]->GetYaxis()->SetTitle( Form("v_{%i}^{Refold} / v_{%i}^{Obs}", norder_, norder_) );
	  hRefoldRatio[icent][iEP][iqn][i]->Divide( hObs[icent][iEP][iqn] );

	  //-- Calculate the moments of each unfolded histogram
	  double uMu   = hUnfold[icent][iEP][iqn][i]->GetMean();
	  double uMue  = hUnfold[icent][iEP][iqn][i]->GetMeanError();
	  double uSig  = hUnfold[icent][iEP][iqn][i]->GetRMS();
	  double uSige = hUnfold[icent][iEP][iqn][i]->GetRMSError();
	  double uRMS  = TMath::Sqrt( pow(uMu, 2) + pow(uSig, 2) );
	  double uRMSe = TMath::Sqrt( ( pow(uMu * uMue, 2) + pow(uSig * uSige, 2) ) / ( pow(uMu,2) + pow(uSig,2) ) );
	  double uRF   = uSig / uMu;
	  double uRFe  = TMath::Sqrt( pow(uSig*uMue/uMu/uMu, 2) + pow(uSige/uMu, 2) );

	  unfold_mean[icent][iEP][iqn][i]      = uMu;
	  unfold_RMS[icent][iEP][iqn][i]       = uRMS;
	  unfold_stDev[icent][iEP][iqn][i]     = uSig;
	  unfold_RelFluct[icent][iEP][iqn][i]  = uRF;

	  unfold_meane[icent][iEP][iqn][i]     = uMue;
	  unfold_RMSe[icent][iEP][iqn][i]      = uRMSe;
	  unfold_stDeve[icent][iEP][iqn][i]    = uSige;
	  unfold_RelFlucte[icent][iEP][iqn][i] = uRFe;

	  //-- Chi squares
	  chi2NDF_Refold[icent][iEP][iqn][i] = hRefold[icent][iEP][iqn][i]->Chi2Test(hObs[icent][iEP][iqn], "CHI2/NDF");

	  if( chi2NDF_Refold[icent][iEP][iqn][i] <= chi2Cut && !cutoff ){
	    cutoff = 1;
	  }
	  if( i == NITER-1 && !cutoff ){
	    cutoff = 1;
	  }

	} //-- End unfold iteration loop

	//-- Set up all the wonderful graphs
	grUnfoldMean[icent][iEP][iqn]  = new TGraphErrors(NITER, diter, unfold_mean[icent][iEP][iqn], iterErr, unfold_meane[icent][iEP][iqn] );
	grUnfoldMean[icent][iEP][iqn]->GetXaxis()->SetTitle("Iteration");
	grUnfoldMean[icent][iEP][iqn]->GetYaxis()->SetRangeUser(momentMin, momentMax);
	grUnfoldMean[icent][iEP][iqn]->GetYaxis()->SetTitle("Moment");
	grUnfoldMean[icent][iEP][iqn]->SetLineColor(8);
	grUnfoldMean[icent][iEP][iqn]->SetMarkerColor(8);
	grUnfoldMean[icent][iEP][iqn]->SetMarkerStyle(20);

	grUnfoldStDev[icent][iEP][iqn] = new TGraphErrors(NITER, diter, unfold_stDev[icent][iEP][iqn], iterErr, unfold_stDeve[icent][iEP][iqn] ); //46
	grUnfoldStDev[icent][iEP][iqn]->GetXaxis()->SetTitle("Iteration");
	grUnfoldStDev[icent][iEP][iqn]->GetYaxis()->SetRangeUser(momentMin, momentMax);
	grUnfoldStDev[icent][iEP][iqn]->GetYaxis()->SetTitle("Moment");
        grUnfoldStDev[icent][iEP][iqn]->SetLineColor(46);
	grUnfoldStDev[icent][iEP][iqn]->SetMarkerColor(46);
	grUnfoldStDev[icent][iEP][iqn]->SetMarkerStyle(20);

	grUnfoldRMS[icent][iEP][iqn]   = new TGraphErrors(NITER, diter, unfold_RMS[icent][iEP][iqn], iterErr, unfold_RMSe[icent][iEP][iqn] ); //9
	grUnfoldRMS[icent][iEP][iqn]->GetXaxis()->SetTitle("Iteration");
	grUnfoldRMS[icent][iEP][iqn]->GetYaxis()->SetRangeUser(momentMin, momentMax);
	grUnfoldRMS[icent][iEP][iqn]->GetYaxis()->SetTitle("Moment");
        grUnfoldRMS[icent][iEP][iqn]->SetLineColor(9);
	grUnfoldRMS[icent][iEP][iqn]->SetMarkerColor(9);
	grUnfoldRMS[icent][iEP][iqn]->SetMarkerStyle(20);

	grChi2NDF_Refold[icent][iEP][iqn]    = new TGraphErrors(NITER, diter, chi2NDF_Refold[icent][iEP][iqn],    iterErr, iterErr);
	grChi2NDF_Refold[icent][iEP][iqn]->GetXaxis()->SetTitle("Iteration");
	grChi2NDF_Refold[icent][iEP][iqn]->GetYaxis()->SetTitle("#chi^{2}/NDF");
	grChi2NDF_Refold[icent][iEP][iqn]->GetYaxis()->SetRangeUser(chi2Min, chi2Max);
	grChi2NDF_Refold[icent][iEP][iqn]->SetLineColor(4);
	grChi2NDF_Refold[icent][iEP][iqn]->SetMarkerColor(4);
	grChi2NDF_Refold[icent][iEP][iqn]->SetMarkerStyle(20);

      } //-- End QN loop
    } //-- End EP loop
  } //-- End cent loop

  TLegend * leg = new TLegend(0.1283, 0.1440, 0.8108, 0.7539);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->AddEntry(hObs[0][0][0], Form("v_{%i}^{obs}", norder_), "lp");
  for(int i = 0; i < NITER; i++) leg->AddEntry(hUnfold[0][0][0][i], Form("D'Agostini iter = %i", iter[i]), "lp");

  TLegend * legMoment = new TLegend(0.6025, 0.7404, 0.9742, 0.8824);
  legMoment->SetFillStyle(0);
  legMoment->SetBorderSize(0);
  legMoment->SetNColumns(2);
  legMoment->AddEntry(grUnfoldRMS[0][0][0],   "#sqrt{#LTv_{2}^{2}#GT}", "lp");
  legMoment->AddEntry(grUnfoldMean[0][0][0],  "#LTv_{2}#GT", "lp");
  legMoment->AddEntry(grUnfoldStDev[0][0][0], "#sigma_{v_{2}}", "lp");

  TLine * line = new TLine(iter[0], 1., iter[NITER-1], 1);
  line->SetLineStyle(2);
  line->SetLineWidth(2);

  //-- DRAW!!!!
  for(int icent = 0; icent < NCENT; icent++){

    for(int iEP = 0; iEP < NEPSymm; iEP++){
      if( iEP != EPSymmBin ) continue;
      for(int iqn = 0; iqn < NQN; iqn++){

	cSummary[icent][iEP][iqn] = new TCanvas( Form("summary_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("summary_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 1000, 600);
	cSummary[icent][iEP][iqn]->Divide(3,2);

	cSummary[icent][iEP][iqn]->cd(1);
	cSummary[icent][iEP][iqn]->cd(1)->SetLogy();
	hObs[icent][iEP][iqn]->Draw();
	for(int i = 0; i < NITER; i++) hUnfold[icent][iEP][iqn][i]->Draw("same");
	latex.DrawLatex(0.18, 0.88, "Unfolding");

	cSummary[icent][iEP][iqn]->cd(2);
        cSummary[icent][iEP][iqn]->cd(2)->SetLogy();
        hObs[icent][iEP][iqn]->Draw();
        for(int i = 0; i < NITER; i++) hRefold[icent][iEP][iqn][i]->Draw("same");
	hObs[icent][iEP][iqn]->Draw("same");
	latex.DrawLatex(0.18, 0.88, "Refolding");

	cSummary[icent][iEP][iqn]->cd(3);
        cSummary[icent][iEP][iqn]->cd(3)->SetLogy();
        for(int i = 0; i < NITER; i++){
          if(i==0) hRefoldRatio[icent][iEP][iqn][i]->Draw();
          else     hRefoldRatio[icent][iEP][iqn][i]->Draw("same");
        }

	cSummary[icent][iEP][iqn]->cd(4);
	cSummary[icent][iEP][iqn]->cd(4)->SetLogx();
	grUnfoldMean[icent][iEP][iqn]->Draw("alp");
	grUnfoldStDev[icent][iEP][iqn]->Draw("lpsame");
	grUnfoldRMS[icent][iEP][iqn]->Draw("lpsame");

	grUnfoldMean[icent][iEP][iqn]->GetYaxis()->SetRangeUser(momentMin, momentMax);
	grUnfoldRMS[icent][iEP][iqn]->GetYaxis()->SetRangeUser(momentMin, momentMax);
	grUnfoldStDev[icent][iEP][iqn]->GetYaxis()->SetRangeUser(momentMin, momentMax);
	legMoment->Draw("same");

	cSummary[icent][iEP][iqn]->cd(5);
	cSummary[icent][iEP][iqn]->cd(5)->SetLogx();
	grChi2NDF_Refold[icent][iEP][iqn]->Draw("alp");

	grChi2NDF_Refold[icent][iEP][iqn]->GetYaxis()->SetRangeUser(chi2Min, chi2Max);
	cSummary[icent][iEP][iqn]->cd(5)->SetLogy();
	line->Draw("same");

	cSummary[icent][iEP][iqn]->cd(6);
	cSummary[icent][iEP][iqn]->cd(6)->SetLogy();
	leg->Draw();
	int qmin = 100*(iqn)/NQN;
	int qmax = 100*(iqn+1)/NQN;
	latex.DrawLatex(0.18, 0.92, Form("Centrality %i - %i%s", cent_min[icent], cent_max[icent], "%"));
	latex.DrawLatex(0.18, 0.85, Form("|#eta| < %.1f", tkEta) );
	latex.DrawLatex(0.18, 0.78,  Form("q_{%i} %i - %i%s", norder_, qmin, qmax, "%"));

	cSummary[icent][iEP][iqn]->Update();
	if( SaveSumPl ) cSummary[icent][iEP][iqn]->SaveAs( Form("plots/unfolding/summary_%s_c%i_qbin%i.pdf", EPSymmNames[iEP].data(), icent, iqn) );

      } //-- end Qn loop
    } //-- End EP loop
  } //-- End Cent loop

}
void MakeRelDiffPlots(TProfile *MC, TProfile *DATA, TProfile *GEO, std::string nametag, TFile* outputfile_ptr){
  std::string filename;

  //=========Macro generated from canvas: c1/c1
  //=========  (Wed Jul 27 17:25:29 2016) by ROOT version5.34/25
  TCanvas *c1 = new TCanvas("c1", "c1",19,48,700,500);

  c1->Range(-0.5063291,-0.1924051,2.658228,1.010127);
  c1->SetFillColor(0);
  c1->SetBorderMode(0);
  c1->SetBorderSize(2);
  c1->SetTickx(1);
  c1->SetTicky(1);
  c1->SetLeftMargin(0.16);
  c1->SetRightMargin(0.05);
  c1->SetTopMargin(0.05);
  c1->SetBottomMargin(0.16);
  c1->SetFrameBorderMode(0);

  c1->Modified();
  c1->cd();
  c1->SetSelected(c1);

std::cout << ">>> !!! DEBUG LINE: " << "1" << " !!!" << std::endl; 

  MC->SetMarkerColor(1);
  MC->SetMarkerStyle(20);
  MC->SetMarkerSize(0.9);
  //MC->SetMinimum(0);
  //MC->SetMaximum(2);
  MC->SetEntries(2552568);
  MC->SetStats(0);
  MC->SetLineWidth(2);
  MC->GetXaxis()->SetTitle("|#font[152]{h}_{#font[52]{e}}|");
  MC->GetXaxis()->SetLabelFont(42);
  MC->GetXaxis()->SetLabelSize(0.05);
  MC->GetXaxis()->SetTitleSize(0.05);
  MC->GetXaxis()->SetTitleOffset(1.4);
  MC->GetXaxis()->SetTitleFont(42);
  MC->GetYaxis()->SetTitle("E1/E2");
  MC->GetYaxis()->SetLabelFont(42);
  MC->GetYaxis()->SetLabelSize(0.05);
  MC->GetYaxis()->SetTitleSize(0.05);
  MC->GetYaxis()->SetTitleOffset(1.4);
  MC->GetYaxis()->SetTitleFont(42);
  MC->GetZaxis()->SetLabelFont(42);
  MC->GetZaxis()->SetLabelSize(0.05);
  MC->GetZaxis()->SetTitleSize(0.05);
  MC->GetZaxis()->SetTitleFont(42);
  MC->Draw();

std::cout << ">>> !!! DEBUG LINE: " << "2" << " !!!" << std::endl; 

  GEO->SetMarkerColor(2);
  GEO->SetMarkerStyle(15);
  GEO->SetMarkerSize(0.9);
  GEO->Draw("same");

  TLegend* legend = new TLegend(0.172,0.2,0.55,0.3);
  legend->SetBorderSize(0);  // no border
  legend->SetFillStyle(0);
  legend->SetTextSize(0.04);
  legend->AddEntry(MC,"MC15c nom. geo.","P");
  legend->AddEntry(GEO,"MC15c s2984","P");
  legend->Draw("same");

  filename = "output/E1E2" + nametag + "_mc2015_s2984.png";
  c1->SaveAs(filename.c_str());

  TH1D * temp1 = MC->ProjectionX("temp1");
  TH1D * temp2 = GEO->ProjectionX("temp2");
  TH1D * h3 = new TH1D(*temp1);

  h3->Add(MC, GEO, -1, 1);
  h3->Sumw2();
  h3->Divide(MC);
  h3->GetYaxis()->SetTitle("#font[152]{d}_{#font[52]{rel}}#font[52]{E_{1/2}}");
  MC->GetYaxis()->SetTitleSize(0.02);
  h3->SetMarkerColor(1);
  h3->SetMarkerStyle(20);
  h3->SetMarkerSize(0.9);
  h3->SetMinimum(-0.05);
  h3->SetMaximum(0.25);
  h3->Draw();

  TLine *line = new TLine(0,0,2.5,0);
  line->SetLineColor(kBlack);
  line->SetLineStyle(2);
  line->Draw("same");

  filename = "output/E1E2" + nametag + "_mc2015_s2984_Diff.png";
  c1->SaveAs(filename.c_str());

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "_mc2015_s2984_Diff";
  h3->Write(filename.c_str());


  //Different formatting on the above plot for OCIP symposium talk
  h3->GetYaxis()->SetTitle("#font[52]{E_{1/2}}");
  MC->GetYaxis()->SetTitleSize(0.02);
  h3->SetMarkerColor(4);
  h3->SetMarkerStyle(20);
  h3->SetMarkerSize(1.2);
  h3->SetMinimum(-0.4);
  h3->SetMaximum(0.2);
  h3->SetStats(0);
  h3->Draw();

  line->Draw("same");

  filename = "output/E1E2" + nametag + "_mc2015_s2984_Diff_formatted.png";
  c1->SaveAs(filename.c_str());

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "_mc2015_s2984_Diff_formatted";
  h3->Write(filename.c_str());

  delete temp1;
  delete temp2;

  //Create a TGraphErrors that holds the relative difference plot (ie the same plot as above, but centered vertically at 0. And in a TGraphErrors instead of a profile, for error propagation (I guess)).
  
  double temp_x;
  double temp_y;
  std::vector<double> relDiff_x;
  std::vector<double> relDiff_y;
  std::vector<double> relDiff_y_errors;

  for(int i=0; i!=(h3->GetXaxis()->GetNbins()); i++) {
    temp_x = h3->GetBinCenter(i+1); 
    temp_y = h3->GetBinContent(i+1); 
    relDiff_x.push_back(temp_x);
    relDiff_y.push_back(temp_y);
    relDiff_y_errors.push_back(h3->GetBinError(i+1));
  }

  TGraphErrors* relDiff = new TGraphErrors(h3->GetXaxis()->GetNbins(),&relDiff_x[0], &relDiff_y[0], 0, &relDiff_y_errors[0]);
  relDiff -> Draw("APE");

//for (double element : relDiff_y_errors) {std::cout << element << std::endl;}

  relDiff->SetLineWidth(2);
  relDiff->SetMarkerColor(1);
  relDiff->SetMarkerStyle(20);
  relDiff->SetMarkerSize(1.2);
  //relDiff->SetMaximum(1);
  //relDiff->SetMinimum(-1);
  relDiff->GetXaxis()->SetTitle("|#font[152]{h}_{#font[52]{e}}|");
  relDiff->GetXaxis()->SetLabelFont(42);
  relDiff->GetXaxis()->SetLabelSize(0.05);
  relDiff->GetXaxis()->SetTitleSize(0.05);
  relDiff->GetXaxis()->SetTitleOffset(1.4);
  relDiff->GetXaxis()->SetTitleFont(42);
  relDiff->GetYaxis()->SetLabelFont(42);
  relDiff->GetYaxis()->SetLabelSize(0.05);
  relDiff->GetYaxis()->SetTitleSize(0.05);
  relDiff->GetYaxis()->SetTitleOffset(1.4);
  relDiff->GetYaxis()->SetTitleFont(42);
  relDiff->GetYaxis()->SetTitle("#font[152]{d}_{#font[52]{rel}}#font[52]{E_{1/2}}");

  TLine *line0 = new TLine(0,0,2.7,0);
  line0->SetLineColor(kBlack);
  line0->SetLineStyle(2);
  line0->Draw("same");

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "_mc2015_s2984_relDiff";
  relDiff->Write(filename.c_str());

 //Now make a plot with data and the alternate geometry
  TH1D * DATA_temp = DATA->ProjectionX("DATA_temp");
  TH1D * GEO_temp  = GEO->ProjectionX("GEO_temp");
  TH1D * h4 = new TH1D(*GEO_temp);

  DATA_temp->SetMarkerColor(2);
  DATA_temp->SetMarkerStyle(15);
  DATA_temp->SetMarkerSize(0.9);

  GEO_temp->SetMarkerColor(1);
  GEO_temp->SetMarkerStyle(15);
  GEO_temp->SetMarkerSize(0.9);
  GEO_temp->SetMinimum(0);
  GEO_temp->SetMaximum(2);
  GEO_temp->GetXaxis()->SetTitle("|#font[152]{h}_{#font[52]{e}}|");
  GEO_temp->GetYaxis()->SetTitle("#font[52]{E_{1/2}}");

  GEO_temp->Draw("PE");
  DATA_temp->Draw("PEsame");

  TLegend* legend2 = new TLegend(0.172,0.8,0.55,0.9);
  legend2->SetBorderSize(0);  // no border
  legend2->SetFillStyle(0);
  legend2->SetTextSize(0.04);
  legend2->AddEntry(GEO_temp,"MC15c s2984","P");
  legend2->AddEntry(DATA_temp,"Data 2015-16","P");
  legend2->Draw("same");

  filename = "output/E1E2" + nametag + "mc2015_s2984_both_data.png";
  c1->SaveAs(filename.c_str());

  h4->Add(GEO_temp, DATA_temp, -1, 1);
  h4->Divide(GEO_temp);
  h4->GetYaxis()->SetTitle("#font[152]{D}#font[52]{E_{1/2}^{data,s2984}}");
  //h4->GetYaxis()->SetTitleSize(0.02);
  h4->SetMarkerColor(1);
  h4->SetMarkerStyle(20);
  h4->SetMarkerSize(0.9);
  h4->SetMinimum(-0.3);
  h4->SetMaximum(0.3);
  h4->Draw();
/*
  for(int i=0; i!=GEO_temp->GetXaxis()->GetNbins(); i++) {
    std::cout << ">>> !!! DEBUG LINE: " << "GEO_temp->GetBinContent() " << GEO_temp->GetBinContent(i)  << std::endl; 
  }   
*/
  line->Draw("same");

  filename = "output/E1E2" + nametag + "mc2015_s2984_rel_data.png";
  c1->SaveAs(filename.c_str());

  outputfile_ptr->cd();
  filename = "E1E2" + nametag + "mc2015_s2984_rel_data";
  h4->Write(filename.c_str());

  delete h3;
  delete h4;
  delete DATA_temp;
  delete GEO_temp;
  delete c1;
}