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();

}
Example #2
0
int plotMass(const char* cut, char *filename) {
  
  // ------ root settings ---------
  gROOT->Reset();  
  gROOT->SetStyle("Plain");
  gStyle->SetPadGridX(kTRUE);
  gStyle->SetPadGridY(kTRUE);
  //gStyle->SetOptStat("kKsSiourRmMen");
  //gStyle->SetOptStat("iourme");
  gStyle->SetOptStat("rme");
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(1111);
  gStyle->SetPadLeftMargin(0.14);
  gStyle->SetPadRightMargin(0.06);
  // ------------------------------ 

  float min=75;
  float max=105;
  int nbins=70;
  float step=(max-min)/float(nbins);
  char stepstr[20];
  sprintf(stepstr,"Events/%4.2f GeV",step);

  TFile *fileData = TFile::Open("results/hzzTree.root");
  TFile *fileDY = TFile::Open("results/hzzTree_id111.root");

  TTree *treeData = (TTree*)fileData->Get("zeetree/probe_tree");
  TTree *treeDY = (TTree*)fileDY->Get("zeetree/probe_tree");
  treeDY->AddFriend( "zeetree/pu_probe_tree = zeetree/probe_tree", "results/hzzTree_id111_puw.root" );

  TH1D *massDYsmear = new TH1D("massDYsmear","",nbins,min,max);
  TH1D *massData = new TH1D("massData","",nbins,min,max);

  // cosmetics
  massDYsmear->Sumw2();
  massDYsmear->SetFillColor(kCyan-9);
  massDYsmear->SetFillStyle(3003);
  massDYsmear->SetLineColor(kAzure+3);
  massDYsmear->GetXaxis()->SetTitle("M_{ee} (GeV/c^{2})");
  massDYsmear->GetYaxis()->SetTitle(stepstr);
  massData->SetMarkerSize(0.8);
  massData->SetMarkerStyle(21);
  massData->SetMaximum(massData->GetMaximum()+0.1*massData->GetMaximum());
  
  TString finalcutData = TString("(")+TString(cut)+TString(")*1");
  TString finalcutMC = TString("(")+TString(cut)+TString(")*puW");
  
  treeData->Project("massData","zmll",finalcutData);
  treeDY->Project("massDYsmear","zmll",finalcutMC);

  massDYsmear->Scale(massData->Integral()/massDYsmear->Integral());

  TLegend* leg = new TLegend(0.2,0.7,0.4,0.89);
  leg->SetBorderSize(     0);
  leg->SetFillColor (     0);
  leg->SetTextAlign (    12);
  leg->SetTextFont  (    42);
  leg->SetTextSize  (0.05);
  leg->SetFillColor(0);
  leg->AddEntry(massDYsmear,"MC smeared","F");
  leg->AddEntry(massData,"Data","pe");

  TCanvas *c1 = new TCanvas("c1","c1");
  massDYsmear->Draw("hist");
  massData->Draw("same pe1");
  leg->Draw();

  c1->SaveAs(filename);

  fileData->Close();
  fileDY->Close();

  return 0;
 
}
Example #3
0
void plotLimit(TString outputDir="./", TString inputs="", TString inputXSec="", bool strengthLimit=true, bool blind=false, double energy=7, double luminosity=5.035, TString legendName="ee and #mu#mu channels")
{
  //style options
  gStyle->SetCanvasBorderMode(0);
  gStyle->SetCanvasColor(kWhite);
  gStyle->SetFrameBorderMode(0);
  gStyle->SetFrameBorderSize(1);
  gStyle->SetFrameFillColor(0);
  gStyle->SetFrameFillStyle(0);
  gStyle->SetFrameLineColor(1);
  gStyle->SetFrameLineStyle(1);
  gStyle->SetFrameLineWidth(1);
  gStyle->SetOptFit(1);
  gStyle->SetFitFormat("5.4g");
  gStyle->SetFuncColor(2);
  gStyle->SetOptFile(0);
  //gStyle->SetOptStat(0);
  gStyle->SetOptStat("mr");
  gStyle->SetStatColor(kWhite);
  gStyle->SetStatFont(42);
  gStyle->SetStatFontSize(0.04);
  gStyle->SetStatTextColor(1);
  gStyle->SetStatFormat("6.4g");
  gStyle->SetStatBorderSize(1);
  gStyle->SetStatH(0.1);
  gStyle->SetStatW(0.2);
  gStyle->SetPadTopMargin(0.05);
  gStyle->SetPadBottomMargin(0.13);
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadRightMargin(0.02);
  gStyle->SetOptTitle(0);
  gStyle->SetTitleFont(42);
  gStyle->SetTitleColor(1);
  gStyle->SetTitleTextColor(1);
  gStyle->SetTitleFillColor(10);
  gStyle->SetTitleFontSize(0.05);
  gStyle->SetAxisColor(1, "XYZ");
  gStyle->SetStripDecimals(kTRUE);
  gStyle->SetTickLength(0.03, "XYZ");
  gStyle->SetNdivisions(510, "XYZ");
  gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  gStyle->SetPadTickY(1);
  gStyle->SetEndErrorSize(2);
  gStyle->SetErrorX(0.);
  gStyle->SetMarkerStyle(20); 
  gROOT->ForceStyle();
  gStyle->SetPadTopMargin   (0.06);
  gStyle->SetPadBottomMargin(0.12);
  gStyle->SetPadRightMargin (0.06);
  gStyle->SetPadLeftMargin  (0.14);
  gStyle->SetTitleSize(0.04, "XYZ");
  gStyle->SetTitleXOffset(1.1);
  gStyle->SetTitleYOffset(1.45);
  gStyle->SetPalette(1);
  gStyle->SetNdivisions(505);


  string suffix = string(outputDir.Data());
  double cprime=1.0; double  brnew=0.0;
  double XSecScaleFactor = 1.0;
  if(suffix.find("_cp")!=string::npos){
     sscanf(suffix.c_str()+suffix.find("_cp"), "_cp%lf_brn%lf", &cprime, &brnew);
     XSecScaleFactor = pow(cprime,2) * (1-brnew);
  }
 
  //get xsec * br from summary file
  getXSecXBR(inputXSec); 
  //get the limits from the tree
  TFile* file = TFile::Open(inputs);
  printf("Looping on %s\n",inputs.Data());
  if(!file) return;
  if(file->IsZombie()) return;
  TTree* tree = (TTree*)file->Get("limit");
  tree->GetBranch("mh"              )->SetAddress(&Tmh      );
  tree->GetBranch("limit"           )->SetAddress(&Tlimit   );
  tree->GetBranch("limitErr"        )->SetAddress(&TlimitErr);
  tree->GetBranch("quantileExpected")->SetAddress(&TquantExp);
  int N = tree->GetEntriesFast() / 6 ;// 6Limits per mass point (observed, meand , +-1sigma, +-2sigma)
  double* MassAxis   = new double[N];
  double* ObsLimit   = new double[N];  fillLimitArray(tree,-1   ,ObsLimit,MassAxis);  if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ObsLimit);
  double* ExpLimitm2 = new double[N];  fillLimitArray(tree,0.025,ExpLimitm2);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitm2);
  double* ExpLimitm1 = new double[N];  fillLimitArray(tree,0.160,ExpLimitm1);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitm1);
  double* ExpLimit   = new double[N];  fillLimitArray(tree,0.500,ExpLimit  );         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimit);
  double* ExpLimitp1 = new double[N];  fillLimitArray(tree,0.840,ExpLimitp1);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitp1);
  double* ExpLimitp2 = new double[N];  fillLimitArray(tree,0.975,ExpLimitp2);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitp2);
  file->Close();

  //make TH Cross-sections
  double* ThXSec   = new double[N]; for(unsigned int i=0;i<N;i++){ThXSec[i] = xsecXbr[MassAxis[i]];} 

  //scale TH cross-section and limits according to scale factor 
  //this only apply to NarrowResonnance case
  for(unsigned int i=0;i<N;i++){
    if(strengthLimit){
    ObsLimit[i]  /= XSecScaleFactor;
    ExpLimitm2[i]/= XSecScaleFactor;
    ExpLimitm1[i]/= XSecScaleFactor;
    ExpLimit  [i]/= XSecScaleFactor;
    ExpLimitp1[i]/= XSecScaleFactor;
    ExpLimitp2[i]/= XSecScaleFactor;
    }
    ThXSec[i]    *= XSecScaleFactor;
  }

    
  //limits in terms of signal strength
  TCanvas* c = new TCanvas("c", "c",600,600);
  TH1F* framework = new TH1F("Graph","Graph",1,90,160);
  framework->SetStats(false);
  framework->SetTitle("");
  framework->GetXaxis()->SetTitle("Higgs boson mass [GeV]");
  framework->GetYaxis()->SetTitleOffset(1.70);
  if(strengthLimit){
  framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}");
  framework->GetYaxis()->SetRangeUser(9E-1,1E3);
  c->SetLogy(true);
  }else{
  framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)");
  framework->GetYaxis()->SetRangeUser(1E-1,1E3);
  c->SetLogy(true);
  }
  framework->Draw();

  TGraph* TGObsLimit   = new TGraph(N,MassAxis,ObsLimit);  TGObsLimit->SetLineWidth(2);
  TGraph* TGExpLimit   = new TGraph(N,MassAxis,ExpLimit);  TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2);
  TCutG* TGExpLimit1S  = GetErrorBand("1S", N, MassAxis, ExpLimitm1, ExpLimitp1);  
  TCutG* TGExpLimit2S  = GetErrorBand("2S", N, MassAxis, ExpLimitm2, ExpLimitp2);  TGExpLimit2S->SetFillColor(5);
  TGraph* THXSec        = new TGraph(N,MassAxis,ThXSec); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4);


  TGExpLimit->SetLineColor(2);  TGExpLimit->SetLineStyle(1);
  TGObsLimit->SetLineWidth(2);  TGObsLimit->SetMarkerStyle(20);
  TGExpLimit2S->Draw("fc same");
  TGExpLimit1S->Draw("fc same");
  if(!blind) TGObsLimit->Draw("same CP");
  TGExpLimit->Draw("same C");

  if(strengthLimit){
     TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0);
     SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4);      
     SMLine->Draw("same C");
  }else{
     THXSec->Draw("same C");
  }


  TPaveText *pave = new TPaveText(0.1,0.96,0.99,0.99,"NDC");
  char LumiLabel[1024];
  if(energy<9){  sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=%.0f TeV, #scale[0.5]{#int} L=%6.1ffb^{-1} - %20s",energy, luminosity,legendName.Data());
  }else{         sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",7.0,5.0,8.0,19.7);
  }
  pave->SetBorderSize(0);
  pave->SetFillStyle(0);
  pave->SetTextFont(42);
  TObjArray* tokens = (TString(LumiLabel)).Tokenize("\\\\");
  int nt = tokens->GetEntries();
  for(int it=0; it<nt; ++it){
    TObjString * t = (TObjString *)tokens->At(it);
    pave->AddText(t->GetString());
  }
  pave->Draw("same");


  TLegend* LEG = new TLegend(0.55,0.75,0.85,0.95);
  LEG->SetHeader("");
  LEG->SetFillColor(0);
  LEG->SetFillStyle(0);
  LEG->SetTextFont(42);
  LEG->SetBorderSize(0);
  LEG->AddEntry(THXSec  , "SM prediction"  ,"L");
  LEG->AddEntry(TGExpLimit  , "median expected"  ,"L");
  LEG->AddEntry(TGExpLimit1S  , "expected #pm 1#sigma"  ,"F");
  LEG->AddEntry(TGExpLimit2S  , "expected #pm 2#sigma"  ,"F");
  if(!blind) LEG->AddEntry(TGObsLimit  , "observed"  ,"LP");
  LEG->Draw();
  c->RedrawAxis();
  c->SaveAs(outputDir+"Limit.png");
  c->SaveAs(outputDir+"Limit.C");
  c->SaveAs(outputDir+"Limit.pdf"); 


  //save a summary of the limits
  FILE* pFileSum = fopen((outputDir+"LimitSummary").Data(),"w");
  for(int i=0;i<N;i++){
    fprintf(pFileSum, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ & Th=$%8.6E$\\\\\\hline\n",MassAxis[i], ExpLimit[i], ExpLimitm1[i], ExpLimitp1[i], ExpLimitm2[i],  ExpLimitp2[i], ObsLimit[i], ThXSec[i]);
    if(int(MassAxis[i])%50!=0)continue; printf("%f ",ObsLimit[i]);
  }printf("\n");
  fclose(pFileSum);

  pFileSum = fopen((outputDir+"LimitRange").Data(),"w");
  fprintf(pFileSum, "EXPECTED LIMIT --> ");                   printLimits(pFileSum,TGExpLimit, MassAxis[0], MassAxis[N-1]);
  if(!blind) fprintf(pFileSum, "OBSERVED LIMIT --> ");        printLimits(pFileSum,TGObsLimit, MassAxis[0], MassAxis[N-1]);
  fprintf(pFileSum, "Exp Limits for Model are: ");              for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f+-%f ",ExpLimit[i], (ExpLimitp1[i]-ExpLimitm1[i]))/2.0;}fprintf(pFileSum,"\n");
  if(!blind) { fprintf(pFileSum, "Obs Limits for Model are: "); for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f ",ObsLimit[i]);}fprintf(pFileSum,"\n"); }
  fclose(pFileSum);
}
////////////////////////////////////////////////////////////////////////////////////////
// Draw and save the canvas
// This bit shouldn't need to be updated except the region and channel labels
// As of Jan 10,2013 - the known issues are:
// ++ Error bands don't show correctly
// ++ Data histogram needs to be converted to TGraphAsymmErrors and 
//    plotted w/ poisson errors
// ++ Ratio plot needs to divide the Data TGraphAsymmErrors and
//    TGraphAsymmErrors for the total SM (by turning off the errors since they are
//    shown explicitly)
////////////////////////////////////////////////////////////////////////////////////////
void PlotUnifier(
                  TH1F* histos[9],                   // Array of pointers to histograms
                  TGraphAsymmErrors* smErrorBand,    // Error band for the top pad
                  TGraphAsymmErrors* ratioErrorBand  // Error band for the bottom pad
                )
{
  ////////////////////////////////////////////////////////////////////////////////////////
  // Set Histogram Properties, build the stack and make the ratio plot
  histos[0]->SetMarkerStyle(20)     ; histos[0]->SetMarkerSize(1.2); 
  histos[1]->SetFillColor(kOrange-2); histos[4]->SetLineWidth (2);
  histos[2]->SetFillColor(kAzure-9 ); histos[1]->SetLineWidth (2);
  histos[3]->SetFillColor(kSpring+1); histos[2]->SetLineWidth (2);
  histos[4]->SetFillColor(kAzure+4 ); histos[3]->SetLineWidth (2);
  histos[5]->SetFillColor(kGray    ); histos[5]->SetLineWidth (2);
  histos[6]->SetFillColor(kYellow-9); histos[6]->SetLineWidth (2);
  histos[7]->SetLineColor(kMagenta ); histos[7]->SetLineWidth (3); histos[7]->SetLineStyle(2);
  histos[8]->SetLineColor(kGreen+1 ); histos[8]->SetLineWidth (3); histos[8]->SetLineStyle(2);
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Here comes the stack 
  THStack* sm = new THStack("sm","sm");
  sm->Add(histos[6]);
  sm->Add(histos[5]);
  sm->Add(histos[4]);
  sm->Add(histos[3]);
  sm->Add(histos[2]);
  sm->Add(histos[1]);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Define the legend and fill in the stack order
  TLegend* legendA        = new TLegend(0.49,0.65,0.74,0.85);
  TLegend* legendB        = new TLegend(0.62,0.65,0.87,0.85);
  legendA->SetTextFont(42);    
  legendB->SetTextFont(42);    
  legendA->SetTextSize(0.03);
  legendB->SetTextSize(0.03);
  legendA->SetBorderSize(0);
  legendB->SetBorderSize(0);
  legendA->SetFillColor(0);
  legendB->SetFillColor(0);
  legendA->AddEntry(histos[0],"Data"               ,"p");
  legendA->AddEntry(histos[1],"Z+jets"             ,"f");
  legendA->AddEntry(histos[2],"WW"                 ,"f");
  legendA->AddEntry(histos[3],"t#bar{t}+Wt"        ,"f");
  legendA->AddEntry(histos[4],"ZV"                 ,"f");
  legendB->AddEntry(histos[5],"Non-prompt leptons" ,"f");
  legendB->AddEntry(histos[6],"Higgs"              ,"f");
  TH1F* histoError = new TH1F("histoError"         ,"histoError",1,0,1);
  histoError->SetFillStyle(3004);
  histoError->SetFillColor(kBlack);
  legendB->AddEntry(histoError,"Bkg. Uncert."      ,"f");
  legendB->AddEntry(histos[7],"Signal 1"           ,"l");
  legendB->AddEntry(histos[8],"Signal 2"           ,"l");

  ////////////////////////////////////////////////////////////////////////////////////////
  // Ratio plot 
  TH1F* ratio      = (TH1F*) histos[0]->Clone(); ratio->Reset(); 
  TH1F* stackHisto = (TH1F*) sm->GetStack()->Last();
  ratio->Divide(histos[0],stackHisto);
  ratio->SetMarkerSize(1.2);
  ratio->SetMarkerStyle(20);
  ratio->SetLineColor(kBlack);
  ratio->SetLineWidth(2);

  ratio->GetXaxis()->SetTitle("Observable");
  ratio->GetYaxis()->SetTitle("Data/SM");
  ratio->GetXaxis()->SetLabelSize(0.13);
  ratio->GetXaxis()->SetLabelOffset(0.02);
  ratio->GetXaxis()->SetTitleSize(0.14);
  ratio->GetXaxis()->SetTitleOffset(1.2);

  ratio->GetYaxis()->SetRangeUser(0,2);
  ratio->GetYaxis()->SetLabelSize(0.13);
  ratio->GetYaxis()->SetLabelOffset(0.0125);
  ratio->GetYaxis()->SetTitleSize(0.14);
  ratio->GetYaxis()->SetTitleOffset(0.5);
  ratio->GetYaxis()->SetNdivisions(5);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Error bands
  smErrorBand->SetMarkerSize(0); 
  smErrorBand->SetFillStyle(3004);
  smErrorBand->SetFillColor(kBlack);
  ratioErrorBand->SetMarkerSize(0); 
  ratioErrorBand->SetFillStyle(3004);
  ratioErrorBand->SetFillColor(kBlack);
 
  ////////////////////////////////////////////////////////////////////////////////////////
  // Draw and save the canvas
  TCanvas* canvas = new TCanvas("canvas","canvas",500,500);
  TPad*    topPad = new TPad("pTop","pTop",0,0.2,1,1);
  TPad*    botPad = new TPad("pBot","pBot",0,0.0,1,0.3);
  topPad->Draw();
  botPad->Draw();

  ////////////////////////////////////////////////////////////////////////////////////////
  // Data is special since I use it to draw the axis labels etc.
  histos[0]->GetXaxis()->SetTitle("Observable"); 
  histos[0]->GetYaxis()->SetTitle("Events / Bin"); 
  histos[0]->GetXaxis()->SetLabelOffset(1.2); 
  histos[0]->GetXaxis()->SetLabelSize(0.03);
  histos[0]->GetYaxis()->SetRangeUser(1.e-2,1.e5);
  histos[0]->GetYaxis()->SetTitleSize(0.055);
  histos[0]->GetYaxis()->SetTitleOffset(1.28);
  histos[0]->GetYaxis()->SetLabelSize(0.05);
  histos[0]->GetYaxis()->SetLabelOffset(0.01);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Top Pad
  topPad      ->cd();
  topPad      ->SetBottomMargin(0.15);
  histos[0]   ->Draw("p && e && x0");
  sm          ->Draw("same && hists");
  smErrorBand ->Draw("same && E2");
  histos[0]   ->Draw("same && p && e && x0");
  histos[7]   ->Draw("same && hist");
  histos[8]   ->Draw("same && hist");
  legendA     ->Draw();
  legendB     ->Draw();
  gPad        ->RedrawAxis();
  gPad        ->SetLogy(1);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Decoration
  char annoyingLabel1[100] = "#bf{#it{ATLAS}}, #sqrt{s} = 8 TeV, 20.3 fb^{-1}";
  char annoyingLabel2[100] = "SF/DF channel"; 
  char annoyingLabel3[100] = "- Top CR for SR-#scale[0.9]{m_{T2}} and SR-WWb/c";
  myText(0.53,0.880,kBlack,annoyingLabel1);
  myText(0.17,0.965,kBlack,annoyingLabel2);
  myText(0.37,0.965,kBlack,annoyingLabel3);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Bottom Pad
  botPad ->cd();
  botPad ->SetBottomMargin(0.4);
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // 1 Line
  TLine* line = new TLine(histos[0]->GetXaxis()->GetXmin(),1,histos[0]->GetXaxis()->GetXmax(),1);
  line   ->SetLineColor(kRed);
  line   ->SetLineStyle(7);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Draw
  ratio          ->Draw("p && e && x0");
  ratioErrorBand ->Draw("same && E2");
  line           ->Draw("same");
  ratio          ->Draw("same && p && e && x0");
  gPad           ->SetGridy(1);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Save
  canvas ->SaveAs("Test_v3.eps");

} 
Example #5
0
TF1 *fit(TTree *nt, TTree *ntMC, Double_t ptmin, Double_t ptmax, int isMC,bool isPbPb,TF1* &total,Float_t centmin, Float_t centmax)
{
	//cout<<cut.Data()<<endl;
	static Int_t count=0;
	count++;
	TCanvas* c= new TCanvas(Form("c%d",count),"",600,600);
	TH1D* h = new TH1D(Form("h%d",count),"",nbinsmasshisto,minhisto,maxhisto);

	//   TF1* f = new TF1(Form("f%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [6]*Gaus(x,[7],[8])/(sqrt(2*3.14159)*[8]) + [9]+[10]*x ");
	//   TF1* f = new TF1(Form("f%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [9]+[10]*x ");
	TF1* f = new TF1(Form("f%d",count),"[0]*TMath::Erf((x-[1])/[2]) + [0] + [9]+[10]*x ");

	if(isMC==1) nt->Project(Form("h%d",count),"Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f)","1",seldata.Data(),ptmin,ptmax));   
	else nt->Project(Form("h%d",count),"Bmass",Form("(%s&&Bpt>%f&&Bpt<%f)",seldata.Data(),ptmin,ptmax));   

	clean0(h);

	h->Draw();
	f->SetParLimits(0, 1e-2, 1e4);
	f->SetParLimits(1, 5.02, 5.06);
	f->SetParLimits(2, 0.001, 0.1);

	f->SetParLimits(3, 1e-2, 1e4);
	f->SetParLimits(4, 5.06, 5.10);
	f->SetParLimits(5, 0.001, 0.1);

	f->SetParLimits(6, 0, 1e4);
	f->SetParLimits(7, 5.3, 5.4);
	f->SetParLimits(8, 0.001, 0.5);

	f->SetParLimits(9, 0, 1e5);
	f->SetParLimits(10, -500,  100);

	f->SetParameter(0,1e2);
	f->SetParameter(1,5.03);
	f->SetParameter(2,0.05);

	f->SetParameter(0,1e2);
	f->SetParameter(1,5.03);
	f->SetParameter(2,0.05);

	f->SetParameter(3,1e2);
	f->SetParameter(4,5.07);
	f->SetParameter(5,0.05);

	f->SetParameter(6,1e2);
	f->SetParameter(7,5.35);
	f->SetParameter(8,0.05);

	f->SetParameter(9,1e3);
	f->SetParameter(10,-1);

	//error fn
	f->SetParLimits(0, 1e1, 1e3);
	f->SetParLimits(1, 5., 5.3);
	f->SetParLimits(2, -10, 0);
	f->SetParameter(0,100);
	f->SetParameter(1,5.1);
	f->SetParameter(2,0);

	h->GetEntries();

	h->Fit(Form("f%d",count),"q","",minhisto,maxhisto);
	h->Fit(Form("f%d",count),"q","",minhisto,maxhisto);
	h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto);
	h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto);
	h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto);
	h->Fit(Form("f%d",count),"L m","",minhisto,maxhisto);
	h->SetMarkerSize(0.8);
	h->SetMarkerStyle(20);

	TF1 *background = new TF1(Form("background%d",count),"[0]+[1]*x");
	background->SetParameter(0,f->GetParameter(9));
	background->SetParameter(1,f->GetParameter(10));
	background->SetLineColor(4);
	background->SetRange(minhisto,maxhisto);
	background->SetLineStyle(2);

	//   TF1 *mass = new TF1(Form("fmass%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [6]*Gaus(x,[7],[8])/(sqrt(2*3.14159)*[8])");
	//   mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(3),f->GetParameter(4),f->GetParameter(5),f->GetParameter(6),f->GetParameter(7),f->GetParameter(8));
	//TF1 *mass = new TF1(Form("fmass%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5])");
	//mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(3),f->GetParameter(4),f->GetParameter(5));
	TF1 *mass = new TF1(Form("fmass%d",count),"[0]*TMath::Erf((x-[1])/[2]) + [0]");
	mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2));
	//mass->SetParError(0,f->GetParError(0));
	//mass->SetParError(1,f->GetParError(1));
	//mass->SetParError(2,f->GetParError(2));
	mass->SetLineColor(2);

	h->SetXTitle("m_{#mu#muK} (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");
	mass->SetLineStyle(2);
	mass->SetFillStyle(3004);
	mass->SetFillColor(2);
	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);

	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,"Peaking BG","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;
	if(collisionsystem=="pp"||collisionsystem=="PP") texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","pp"));
	else texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","PbPb"));
	texCol->SetNDC();
	texCol->SetTextAlign(32);
	texCol->SetTextSize(0.04);
	texCol->SetTextFont(42);
	texCol->Draw();

	TLatex* tex;

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

	if(centMax>0){
		TString texper="%";
		tex = new TLatex(0.22,0.71,Form("Centrality %.0f-%.0f%s",centMin,centMax,texper.Data()));//0.2612903,0.8425793
		tex->SetNDC();
		tex->SetTextColor(1);
		tex->SetTextFont(42);
		tex->SetTextSize(0.045);
		tex->SetLineWidth(2);
		tex->Draw();
	}

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

	total=f;

	h->Write();
	f->Write();
	if(!isPbPb) c->SaveAs(Form("plotNP/BMass%s_%d.pdf",collisionsystem.Data(),count));
	else c->SaveAs(Form("plotNP/BMass%s_%.0f_%.0f_%d.pdf",collisionsystem.Data(),centMin,centMax,count));
	return mass;
}
Example #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);

}
Example #7
0
// main function
int PU()
{
  //--------------------------------------------------------------
  // Samples
  //--------------------------------------------------------------

  //TFile* TTJetsSummer11 = new TFile("TTJetsSummer11.root", "READ");
  TFile* TTJetsFall11   = new TFile("TTJetsFall11_new.root",   "READ");
  TFile* SingleTop      = new TFile("SingleTop_new.root",      "READ");
  TFile* ZJets          = new TFile("ZJets_new.root",          "READ");
  //TFile* WJets          = new TFile("WJets.root",          "READ");
  TFile* WJetsHT        = new TFile("WJetsHT_new.root",        "READ");
  TFile* QCD            = new TFile("QCD_new.root",            "READ");
  
  //TFile* LM3            = new TFile("LM3.root",            "READ");
  TFile* LM6            = new TFile("LM6_new.root",            "READ");
  TFile* LM8            = new TFile("LM8_new.root",            "READ");
  TFile* LM9            = new TFile("LM9_new.root",            "READ");
  //TFile* LM13           = new TFile("LM13.root",           "READ");

  TFile* Data = new TFile("PU_Data_73500_new.root", "Read"); 

  //-------------------------------------------------------------------------------------------------------------------
  // addSample(TFile* sample, TString name, double weight, int lc, int fc, int fs)
  //-------------------------------------------------------------------------------------------------------------------

  addSample(TTJetsFall11, "TTJets",    "t#bar{t}+Jets",    1, kRed,     0, 0);
  addSample(SingleTop,    "SingleTop", "Single Top",       1, kGreen-3, 0, 0);
  addSample(ZJets,        "ZJets",     "Z/#gamma*+Jets",   1, kBlue-7,  0, 0);
  addSample(WJetsHT,      "WJets",     "W+Jets",           1, 1,        0, 0);
  addSample(QCD,          "QCD",       "QCD",              1, kRed+2,   0, 0);
  
  addSample(LM6,       "LM6",     "LM6",          1, kBlack,       0, 0);
  addSample(LM8,       "LM8",     "LM8",          1, kBlue,        0, 0);
  addSample(LM9,       "LM9",     "LM9",          1, kRed,        0, 0);
  
//   addSample(LM3,       "LM3",         1, kRed+2,   0, 0);
//   addSample(LM8,       "LM8",         1, 1,        0, 0);
//   addSample(LM13,      "LM13",        1, kBlue,    0, 0);

  //-------------------------------------------------------------------------------------------------
  // push back selection step to vector<TString> Selections and DataSelection;
  //-------------------------------------------------------------------------------------------------

  Selections.push_back("analyzeSUSY1m_noCuts");
  
  //-------------------------------------------------------------------------------------------------
  // push back histogram to vector<int> Histograms and DataHistograms;
  //-------------------------------------------------------------------------------------------------

  addHistogram("nPU");
  addHistogram("nPU_noWgt");

  //------------
  // set style 
  //------------ 

  setTDRStyle();
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadRightMargin(0.05);
  gStyle->SetPadTopMargin(0.08);
  gStyle->SetPadBottomMargin(0.14);

  //--------
  // Plot
  //--------

  // loop over samples
   for(int ndx=0; ndx<(int)Files.size(); ++ndx)
     {

       std::cout << "\n"<< Names[ndx] << std::endl;
       std::cout << "---------------" << std::endl;

       // loop over selections
       for(int sdx=0; sdx<(int)Selections.size(); ++sdx)
	 {
	   TCanvas *c1=new TCanvas(Selections[sdx]+"_"+Histograms[0]+"_"+Labels[ndx],Selections[sdx]+"_"+Histograms[0]+"_"+Labels[ndx], 1);
	   
	   TLegend *leg = new TLegend(.58,.65,.95,.92);
	   leg->SetTextFont(62);
	   leg->SetTextSize(0.04);
	   leg->SetFillColor(0);
	   leg->SetLineColor(1);
	   leg->SetShadowColor(0);
	   leg->SetLineColor(1);
	   
	   // label
	   TPaveText *label = new TPaveText(0.12,0.94,0.99,1.,"NDC");
	   label->SetFillColor(0);
	   label->SetTextFont(62);
	   label->SetTextSize(0.045);
	   label->SetBorderSize(0);
	   label->SetTextAlign(12);
	   TText *text=label->AddText("Simulation, #sqrt{s} = 7 TeV");

	   // Draw first histogram
	   TH1F* Temp1=(TH1F*)Files[ndx]->Get(Selections[sdx]+"/"+Histograms[0]);

	   //std::cout << "Integral after weighting: " << Temp1->Integral() << std::endl;

	   // Normalization and ranges
	   Temp1->Scale(1/(Temp1->Integral()));

	   // Title
	   Temp1->SetTitle("");

	   // Line color, style, and width
	   Temp1->SetLineColor(LineColors[ndx]);
	   Temp1->SetLineStyle(7);
	   Temp1->SetLineWidth(3);

	   // Axes
	   Temp1->GetXaxis()->SetTitle("Number of PU interactions");
	   Temp1->GetXaxis()->SetTitleSize(0.05);
	   Temp1->GetXaxis()->SetTitleFont(62);
	   Temp1->GetXaxis()->SetTitleOffset(1.4);

	   Temp1->GetYaxis()->SetTitle("a.u.");
	   Temp1->GetYaxis()->SetTitleOffset(1.7);
	   Temp1->GetYaxis()->SetTitleSize(0.05);
	   Temp1->GetYaxis()->SetTitleFont(62);

	   // Labels
	   Temp1->SetLabelColor(1, "XYZ");
	   Temp1->SetLabelFont(62, "XYZ");
	   Temp1->SetLabelOffset(0.007, "XYZ");
	   Temp1->SetLabelSize(0.04, "XYZ");
	   Temp1->GetXaxis()->SetRangeUser(0,30);

	   Temp1->Draw("Hist");

	   // Draw second histogram
	   TH1F* Temp2=(TH1F*)Files[ndx]->Get(Selections[sdx]+"/"+Histograms[1]);

	   //std::cout << "Integral before weighting: " << Temp2->Integral() << std::endl;

	   // Normalization
	   Temp2->Scale(1/(Temp2->Integral()));

	   // Line color, style, and width
	   Temp2->SetLineColor(LineColors[ndx]);
	   Temp2->SetLineStyle(1);
	   Temp2->SetLineWidth(2);

	   Temp2->Draw("same Hist");

	   // Draw third histogram
	   TH1F* Temp3=(TH1F*)Data->Get("pileup");

	   // Normalization
	   Temp3->Scale(1/(Temp3->Integral()));

	   // Line color, style, and width
	   Temp3->SetLineColor(1);
	   Temp3->SetLineWidth(1);

	   // Marker style, colors, and size
	   Temp3->SetMarkerStyle(20);
	   Temp3->SetMarkerColor(1);
	   Temp3->SetMarkerSize(0.9);

	   Temp3->Draw("same E");

	   // Add entries to legend
	   leg->AddEntry(Temp3,"Data","l P");
	   leg->AddEntry((TObject*)0, Labels[ndx]+":", "");
	   leg->AddEntry(Temp2,"w/o reweighting","l P");
	   leg->AddEntry(Temp1,"w reweighting","l P");
	   	 
	   // Draw legend and labels
	   leg->Draw();
	   label->Draw("same");

	   // Save canvas
	   c1->SaveAs("PU_"+Names[ndx]+".pdf");
	 }
     }
}
Example #8
0
void overlay_plotsPAS(const string& fFile0, const string& fFile1, const string& fPlot0, const string& fPlot1, const double fXmin, const double fXmax, const double fYmin, const double fYmax,const string& fXAxisLabel, const string& fYAxisLabel, const string& fTitle, const string& fName, const int doFit) {
  
   gStyle->SetOptStat(kTRUE);
   gStyle->SetOptTitle(1);
 
   TH2F *h2[4];
   TH1F *h[2];
   
   TFile file0(fFile0.c_str());
   h2[0] = (TH2F*)file0.Get(fPlot0.c_str()); 
   h2[1] = (TH2F*)file0.Get(fPlot1.c_str()); 
   
   h2[0]->Add(h2[1],1.0);
   
   TFile file1(fFile1.c_str());
   h2[2] = (TH2F*)file1.Get(fPlot0.c_str()); 
   h2[3] = (TH2F*)file1.Get(fPlot1.c_str()); 
   
   h2[2]->Add(h2[3],1.0);
   
   h[0] = new TH1F("h0","h0",h2[0]->GetXaxis()->GetNbins(),h2[0]->GetXaxis()->GetXmin(),h2[0]->GetXaxis()->GetXmax());
   h[1] = new TH1F("h1","h1",h2[2]->GetXaxis()->GetNbins(),h2[2]->GetXaxis()->GetXmin(),h2[2]->GetXaxis()->GetXmax());
   
   TCanvas *c0 = new TCanvas("c0");
   c0->cd();
   
//    for(Int_t i=1; i<=h2[0]->GetNbinsX(); i++) {
   for(Int_t i=1; i<=14; i++) {

     string title;
    
     if( fTitle.find("900") != string::npos ) title = Form("h_SIM_900GeV_%i",i);
     else if( fTitle.find("2360") != string::npos ) title = Form("h_SIM_2360GeV_%i",i);
    
     TH1D* h_temp = h2[0]->ProjectionY(title.c_str(), i, i, "e");
     h_temp->SetTitle(title.c_str());
     h_temp->GetXaxis()->SetTitle("#slash{E}_{x,y}");
     
     Int_t ngroup = 1;

     if( fTitle.find("900") != string::npos ) {
       if(i==10) ngroup = 2;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     } else if( fTitle.find("2360") != string::npos ) {
       if(i==10) ngroup = 4;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     }
     
     h_temp->Rebin(ngroup);
     
     TF1* f1= new TF1("f1", "gaus", h_temp->GetXaxis()->GetXmin(), h_temp->GetXaxis()->GetXmax());
     f1->SetParameters(h_temp->GetBinContent(h_temp->GetMaximumBin()),h_temp->GetMean(),h_temp->GetRMS());
     h_temp->Fit("f1","R", "",h_temp->GetXaxis()->GetXmin(),h_temp->GetXaxis()->GetXmax());

//      h_temp->Draw();
//      c0->SetLogy();
//      c0->SaveAs((title+".png").c_str());
     
     h[0]->SetBinContent(i, f1->GetParameter(2));
     h[0]->SetBinError(i, f1->GetParError(2));
      
     delete f1;
     delete h_temp;
   }
   
//    for(Int_t i=1; i<=h2[2]->GetNbinsX(); i++) {
   for(Int_t i=1; i<=14; i++) {
    
     string title;
    
     if( fTitle.find("900") != string::npos ) title = Form("h_DATA_900GeV_%i",i);
     else if( fTitle.find("2360") != string::npos ) title = Form("h_DATA_2360GeV_%i",i);
    
     TH1D* h_temp = h2[2]->ProjectionY(title.c_str(), i, i, "e");
     h_temp->SetTitle(title.c_str());
     h_temp->GetXaxis()->SetTitle("#slash{E}_{x,y}");
          
     Int_t ngroup = 1;

     if( fTitle.find("900") != string::npos ) {
       if(i==10) ngroup = 2;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     } else if( fTitle.find("2360") != string::npos ) {
       if(i==10) ngroup = 4;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     }
     
     h_temp->Rebin(ngroup);
  
     TF1* f1= new TF1("f1", "gaus", h_temp->GetXaxis()->GetXmin(), h_temp->GetXaxis()->GetXmax());
     f1->SetParameters(h_temp->GetBinContent(h_temp->GetMaximumBin()),h_temp->GetMean(),h_temp->GetRMS());
     h_temp->Fit("f1","R", "",h_temp->GetXaxis()->GetXmin(),h_temp->GetXaxis()->GetXmax());
  
//      h_temp->Draw();
//      c0->SetLogy();
//      c0->SaveAs((title+".png").c_str());
     
     h[1]->SetBinContent(i, f1->GetParameter(2));
     h[1]->SetBinError(i, f1->GetParError(2));
      
     delete f1;
     delete h_temp;
   }
   
   h[0]->SetTitle(fTitle.c_str());
   h[0]->GetXaxis()->SetTitle(fXAxisLabel.c_str());
   h[0]->GetYaxis()->SetTitle(fYAxisLabel.c_str());
   h[0]->GetXaxis()->SetRangeUser(fXmin,fXmax);
   h[0]->GetYaxis()->SetRangeUser(fYmin,fYmax);

   h[0]->SetTitleOffset(1.,"X");
   h[0]->SetTitleOffset(1.,"Y");
//    h[0]->GetXaxis()->SetTitleSize(0.04);
//    h[0]->GetYaxis()->SetTitleSize(0.04);

   gStyle->SetOptStat(kFALSE);
   gStyle->SetOptTitle(0);

//    TCanvas *c = new TCanvas("c","",1200,800);
   TCanvas *c = new TCanvas("c");
   c->cd();
  
   h[0]->SetLineWidth(2);
   h[0]->SetLineStyle(2);
   h[0]->SetLineColor(kRed);
   h[0]->SetFillColor(kRed);
   h[0]->SetMarkerSize(1.);
   h[0]->SetMarkerStyle(26);
   h[0]->SetMarkerColor(kRed);
   h[0]->Draw("");
   h[1]->SetLineWidth(2);
//    h[1]->SetLineStyle(3);
   h[1]->SetLineColor(kBlack);
   h[1]->SetMarkerSize(1.);
   h[1]->SetMarkerStyle(20);
   h[1]->SetMarkerColor(kBlack);
   h[1]->Draw("same");
   
   TLegend *legend = new TLegend(.61,.26,.91,.41);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
//    legend->SetFillStyle(0);
   legend->SetTextFont(42);
   legend->AddEntry(h[1],"Data","lp");
   legend->AddEntry(h[0],"Simulation","lp");
   legend->Draw();
   
   TLatex l;
   l.SetTextAlign(12);
   l.SetTextSize(0.04);
   l.SetTextFont(62);
   l.SetNDC();
   l.DrawLatex(0.15,0.88,("#splitline{CMS Preliminary 2009}{#sqrt{s}="+fTitle+"}").c_str());

   c->SetGridx();
   c->SetGridy();
   
   string fileName = fName;
   c->SaveAs(fileName.c_str());
   
   delete legend;
   delete h[0];
   delete h[1];
   delete c0;
   delete c;
}
void plot_golfcourse_Graviton(){

  bool useNewStyle=true;
  if(useNewStyle)  setFPStyle();

   TFile *fFREQ=new TFile("higgsCombineGrav2L2Q_MCMC.RSGrav05.root","READ");
   // TFile *fFREQ=new TFile("higgsCombineGrav2L2Q_Asymptotic.RSGrav05.root","READ");

  TTree *t=(TTree*)fFREQ->Get("limit");

  double mh,limit;
  double quant;
  t->SetBranchAddress("mh",&mh);
  t->SetBranchAddress("limit",&limit);
  t->SetBranchAddress("quantileExpected",&quant);

  vector<double> v_mh, v_median,v_68l,v_68h,v_95l,v_95h, v_obs;

  for(int i=0;i<t->GetEntries();i++){
    // int i=j;
    // if(j==t->GetEntries())i=0;
    t->GetEntry(i);
    //cout<<"i "<<i<<flush<<"  m = "<<mh<<endl;
    // if(mh==600)cout<<"$$$$$$$$$ TREE 600 $$$$$$$$$$$$$$"<<endl;

    if(quant>-1.01&&quant<-0.99){
      v_obs.push_back(limit);
      v_mh.push_back(mh);
    }
    else if(quant>0.02&&quant<0.03)v_95l.push_back(limit);
    else if(quant>0.15&&quant<0.17)v_68l.push_back(limit);
    else if(quant>0.49&&quant<0.51)v_median.push_back(limit);
    else if(quant>0.83&&quant<0.85)v_68h.push_back(limit);
    else if(quant>0.965&&quant<0.98){
      //   cout<<"95% -> at M="<<mh<<" I found "<<limit<<endl;
      v_95h.push_back(limit);
    }

    else {cout<<"Error! Quantile =  "<<quant<<endl;}
  }
  cout<<"Out of the loop !"<<endl;

 
  ////////////////////////////////////////
  ///
 //read in theoretical values from text files
  // bool   applyExtraTherUnc=true;
  string xsect_file_th="./RSGravXSectTimesBRToZZ_Pythia_c05.txt";
  string xsect_file_interpol="./RSGravXSectTimesBRToZZ_Pythia_c05_EXPOINTERP.txt";
 
  //  make_interpolated_xsect(xsect_file_th, xsect_file_interpol);
  // ifstream xsect_file("./RSGravXSectTimesBRToZZ_Pythia_c05.txt",ios::in);
  ifstream xsect_file(xsect_file_interpol.c_str(),ios::in);
  if (! xsect_file.is_open()){ cout<<"Failed to open file with xsections"<<endl;}
  float mH, CS;
 

  vector<float> v_mhxs, v_xs,  v_brzz2l2q,v_toterrh,v_toterrl;
  while(xsect_file.good()){
    xsect_file >> mH>> CS;
    if(mH==600)cout<<"~~~~~ 600 theor ~~~~~~~~~~~~~"<<endl;
    if(mH<300.0)continue;
    v_mhxs.push_back(mH);
    v_xs.push_back(CS/1000.0);//*BRZZ2l2q
   
    //unavailable theor errors for graviton   

    float tot_err_p=0.0;
    float tot_err_m=0.0;
 
    v_toterrh.push_back(1.0+(tot_err_p));
    v_toterrl.push_back(1.0-(tot_err_m));
  }
  cout<<"Size of theor "<<v_mhxs.size()<<endl;
  xsect_file.close();

  string xsect_file_interpol2="./RSGravXSectTimesBRToZZ_Pythia_c10_EXPOINTERP.txt";
  ifstream xsect_file2(xsect_file_interpol2.c_str(),ios::in);
  if (! xsect_file2.is_open()){ cout<<"Failed to open file with xsections (c=0.10)"<<endl;}
  float mH2,CS10;
 
  vector<float>  v_xs10;
  while(xsect_file2.good()){
    xsect_file2 >> mH2>> CS10;
    if(mH2==975)cout<<"~~~~~ 975 theor ~~~~~~~~~~~~~"<<endl;
    if(mH2<300.0)continue;
    v_xs10.push_back(CS10);//*BRZZ2l2q
   
    //unavailable theor errors for graviton   
    float tot_err_p=0.0;
    float tot_err_m=0.0;
 
    //    v_toterrh.push_back(1.0+(tot_err_p));
    //  v_toterrl.push_back(1.0-(tot_err_m));
  }
  cout<<"Size of theor "<<v_xs10.size()<<endl;
  xsect_file2.close();
  //
  //END THEOR INPUT PART
  ///////////////

  const int nMass= v_mh.size();
  double mass[nMass],mass1[nMass],obs_lim_cls[nMass]; 
  double medianD[nMass];
  double up68err[nMass],down68err[nMass],up95err[nMass],down95err[nMass];
  double xs[nMass], xs_uperr[nMass], xs_downerr[nMass];
  double xs10[nMass], xs10_uperr[nMass], xs10_downerr[nMass];
  int nMassEff=0,nMassEff1=0;
  int nM95=0;
  double mass95[nMass],median95[nMass];
  int nexcluded=0;
  bool excl; 
  for(int im=0;im<nMass;im++){
    // if( mass[nMassEff-1]>490.) cout<<"Array "<<im<<flush<<"  m = "<<v_mh.at(im)<<endl;;
    //protection against messed up jobs
    excl=false;
    if(v_68h.at(im)>=v_95h.at(im) || v_68l.at(im)<=v_95l.at(im) ){
      cout<<"Point at M = "<<v_mh.at(im) <<" excluded"<<endl;
      nexcluded++;
      // continue;
      excl=true; 
    }
    //    if(im%2==1)excl=true;//sample only one half of the points

    //search for right index in theor vectors
    bool found=false;
    int indtmp=0,ind=-1;
    while(!found){
      if(v_mhxs.at(indtmp)==v_mh.at(im)){found=true;ind=indtmp;}
      indtmp++;
      if(indtmp==v_mhxs.size()){
	cout<<"!!! m="<<flush<<v_mh.at(im)<<" NOT found in theor matrix."<<endl;
	break;
      }
    }//end while    
   
  

    if(!found){
      cout<<"(2) m="<<v_mh.at(im)<<" NOT found in theor matrix."<<endl;
      continue;
    }
  
    double fl_xs=double(v_xs.at(ind));
    double fl_xs10=double(v_xs10.at(ind));
   
    mass[nMassEff]=v_mh.at(im);
    //if( mass[nMassEff]==600.0)cout<<"=============> 600 !!!"<<endl;
    obs_lim_cls[nMassEff]=v_obs.at(im)*fl_xs;
    nMassEff++;
    if(!excl){
      mass1[nMassEff1]=v_mh.at(im);
      medianD[nMassEff1]=v_median.at(im)*fl_xs;
      up68err[nMassEff1]=(v_68h.at(im)-v_median.at(im))*fl_xs;
      down68err[nMassEff1]=(v_median.at(im)-v_68l.at(im))*fl_xs;

      
      xs[nMassEff1]=fl_xs;
      xs_uperr[nMassEff1]=double( v_toterrh.at(ind))*xs[nMassEff1]- xs[nMassEff1];
      xs_downerr[nMassEff1]=  xs[nMassEff1]- double( v_toterrl.at(ind))* xs[nMassEff1];

      xs10[nMassEff1]=fl_xs10;
      xs10_uperr[nMassEff1]=double( v_toterrh.at(ind))*xs10[nMassEff1]- xs10[nMassEff1];
      xs10_downerr[nMassEff1]=  xs10[nMassEff1]- double( v_toterrl.at(ind))* xs10[nMassEff1];
    
      //cout<<"Theor err on 4g for M="<<mass[nMassEff]<<"  "<< ggxs4g_downerr[nMassEff] << "  "<<ggxs4g_uperr[nMassEff]<<endl;
      nMassEff1++;
      

      bool skip95= false;//
      //     skip95=v_mh.at(im)==204||v_mh.at(im)==208||v_mh.at(im)==212||v_mh.at(im)==214|| v_mh.at(im)==232 || v_mh.at(im)==240  || v_mh.at(im)==240 || v_mh.at(im)==244 || v_mh.at(im)==252 || v_mh.at(im)==264 || v_mh.at(im)==272 || v_mh.at(im)==288 ;
      //  skip95=false;
      
      if(skip95 )continue;
      mass95[nM95]=v_mh.at(im);
      median95[nM95]=v_median.at(im)*fl_xs;
      up95err[nM95]=(v_95h.at(im)-v_median.at(im))*fl_xs;
      down95err[nM95]=(v_median.at(im)-v_95l.at(im))*fl_xs;
   
      //  cout<<"M95: "<< mass95[nM95]<<" "<<median95[nM95]<<" +"<<up95err[nM95]<<"   -"<< down95err[nM95]<<
      //	" ("<<v_95h.at(im) <<" - "<<v_median.at(im) <<")"<<endl;
      nM95++; 
    }//end if not excluded mass point
  }//end loop over im (mass points)
  cout<<"Excluded "<<nexcluded<<" sick mass points."<<endl;

  


  //  cout<<"Working on TGraph"<<endl;
  TGraph *grobslim_cls=new TGraphAsymmErrors(nMassEff,mass,obs_lim_cls);
  grobslim_cls->SetName("LimitObservedCLs");
  TGraph *grmedian_cls=new TGraphAsymmErrors(nMassEff1,mass1,medianD);
  grmedian_cls->SetName("LimitExpectedCLs");
  TGraphAsymmErrors *gr68_cls=new TGraphAsymmErrors(nMassEff1,mass1,medianD,0,0,down68err,up68err);
  gr68_cls->SetName("Limit68CLs");
  TGraphAsymmErrors *gr95_cls=new TGraphAsymmErrors(nM95,mass95,median95,0,0,down95err,up95err);
  gr95_cls->SetName("Limit95CLs");

  TGraphAsymmErrors *grthSM=new TGraphAsymmErrors(nMassEff1,mass1,xs,0,0,0,0);//xs_downerr,xs_uperr);
  grthSM->SetName("SMXSection");

  TGraphAsymmErrors *grthSM10=new TGraphAsymmErrors(nMassEff1,mass1,xs10,0,0,0,0);
  grthSM10->SetName("SMXSection_c.10");
 
  // cout<<"Plotting"<<endl;
  double fr_left=390.0, fr_down=0.01,fr_right=1010.0,fr_up=10.0;
  TCanvas *cMCMC=new TCanvas("c_lim_Asymp","canvas with limits for Asymptotic CLs",630,600);
  cMCMC->cd();
  cMCMC->SetGridx(1);
  cMCMC->SetGridy(1);
  // draw a frame to define the range

  TH1F *hr = cMCMC->DrawFrame(fr_left,fr_down,fr_right,fr_up,"");
  hr->SetXTitle("m_{G} [GeV]");
  hr->SetYTitle("#sigma_{95%} #times BR(G #rightarrow ZZ) [pb]");// #rightarrow 2l2q
  // cMCMC->GetFrame()->SetFillColor(21);
  //cMCMC->GetFrame()->SetBorderSize(12);
  
  gr95_cls->SetFillColor(kYellow);
  gr95_cls->SetFillStyle(1001);//solid
  gr95_cls->SetLineStyle(kDashed);
  gr95_cls->SetLineWidth(3);
  gr95_cls->GetXaxis()->SetTitle("m_{G} [GeV]");
  gr95_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(G #rightarrow ZZ) [pb]");// #rightarrow 2l2q
  gr95_cls->GetXaxis()->SetRangeUser(fr_left,fr_right);
  
  gr95_cls->Draw("3");
  
  gr68_cls->SetFillColor(kGreen);
  gr68_cls->SetFillStyle(1001);//solid
  gr68_cls->SetLineStyle(kDashed);
  gr68_cls->SetLineWidth(3);
  gr68_cls->Draw("3same");
  grmedian_cls->GetXaxis()->SetTitle("m_{G} [GeV]");
  grmedian_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(G #rightarrow ZZ) [pb]");// #rightarrow 2l2q
  grmedian_cls->SetMarkerStyle(24);//25=hollow squre
  grmedian_cls->SetMarkerColor(kBlack);
  grmedian_cls->SetLineStyle(2);
  grmedian_cls->SetLineWidth(3);
  grmedian_cls->SetMinimum(0.0);
  grmedian_cls->SetMaximum(8.0);
 
  grobslim_cls->SetMarkerColor(kBlack);
  grobslim_cls->SetMarkerStyle(21);//24=hollow circle
  grobslim_cls->SetMarkerSize(1.0);
  grobslim_cls->SetLineStyle(1);
  grobslim_cls->SetLineWidth(3);
  
  grthSM->SetLineColor(kRed);
  grthSM->SetLineWidth(2);
  grthSM->SetLineStyle(kDashed);
  grthSM->SetFillColor(kRed);
  grthSM->SetFillStyle(3344);

  grthSM10->SetLineColor(kRed);
  grthSM10->SetLineWidth(2);
  grthSM10->SetLineStyle(1);
  grthSM10->SetFillColor(kRed);
  grthSM10->SetFillStyle(3344);

  grthSM->Draw("L3");
  grthSM10->Draw("L3");
  grmedian_cls->Draw("L");
  grobslim_cls->Draw("LP");

 //draw grid on top of limits
  gStyle->SetOptStat(0);
  TH1D* postGrid = new TH1D("postGrid","",1,fr_left,fr_right);
  postGrid->GetYaxis()->SetRangeUser(fr_down,fr_up);
  postGrid->Draw("AXIGSAME");

  TLine *l1=new TLine();
  l1->SetLineStyle(1);
  l1->SetLineWidth(2.0);
  l1->SetLineColor(kRed);
  //  l1->DrawLine(200.0,1.0,600.0,1.0);
  //  cMCMC->Update();
  cMCMC->RedrawAxis("");
   gPad->RedrawAxis("");
  // hr->GetYaxis()->DrawClone();
   cMCMC->Update();
  


  //more graphics
  TLegend *leg = new TLegend(.50,.75,.94,.90);
  //   TLegend *leg = new TLegend(.35,.71,.90,.90);
   leg->SetFillColor(0);
   leg->SetShadowColor(0);
   leg->SetTextFont(42);
   leg->SetTextSize(0.027);
   //   leg->SetBorderMode(0);
   leg->AddEntry(grobslim_cls, "Bayesian MCMC Observed", "LP");
   leg->AddEntry(gr68_cls, "Bayesian MCMC  Expected #pm 1#sigma", "LF");
   leg->AddEntry(gr95_cls, "Bayesian MCMC  Expected #pm 2#sigma", "LF");
   //  leg->AddEntry(grthSM, "#sigma(pp#rightarrow RSG) x BR(G #rightarrow ZZ), c=0.05", "LF");// #rightarrow 2l2q
   // leg->AddEntry(grthSM10, "#sigma(pp#rightarrow RSG) x BR(G #rightarrow ZZ), c=0.10", "LF");// #rightarrow 2l2q
   leg->AddEntry(grthSM, "#sigma_{th} x BR, c=0.05", "LF");// #rightarrow 2l2q
   leg->AddEntry(grthSM10, "#sigma_{th} x BR, c=0.10", "LF");// #rightarrow 2l2q
   leg->Draw();
   
 if(useNewStyle){
   TPaveText* cmslabel = new TPaveText( 0.145, 0.953, 0.6, 0.975, "brNDC");
   cmslabel->SetFillColor(kWhite);
   cmslabel->SetTextSize(0.038);
   cmslabel->SetTextAlign(11);
   cmslabel->SetTextFont(62);
   cmslabel->SetBorderSize(0);
   //   std::string leftText = "CMS Preliminary 2011";
   std::string leftText = "CMS";
   std::string units = "fb ^{-1}";
   char lumiText[300];
   sprintf( lumiText, "%.1f %s", intLumi, units.c_str());
   cmslabel->AddText(Form("%s,  #sqrt{s} = 7 TeV, %s", leftText.c_str(), lumiText));
   //cmslabel->Draw();

   TPaveText* label_sqrt = new TPaveText(0.4,0.953,0.96,0.975, "brNDC");
   label_sqrt->SetFillColor(kWhite);
   label_sqrt->SetBorderSize(0);
   label_sqrt->SetTextSize(0.038);
   label_sqrt->SetTextFont(62);   
   label_sqrt->SetTextAlign(31); // align right
   // label_sqrt->AddText("#sqrt{s} = 7 TeV");
   label_sqrt->AddText(Form("%s, L = %s at  #sqrt{s} = 7 TeV", leftText.c_str(), lumiText));
   label_sqrt->Draw();

   }
   else{

   TLatex * latex = new TLatex();
   latex->SetNDC();
   latex->SetTextSize(0.04);
   latex->SetTextAlign(31);
   latex->SetTextAlign(11); // align left 
   latex->DrawLatex(0.18, 0.96, "CMS preliminary 2011");
   latex->DrawLatex(0.60,0.96,Form("%.1f fb^{-1} at #sqrt{s} = 7 TeV",intLumi));
   
   }

   TLine *l1b=new TLine();
   l1b->SetLineStyle(1);
   l1b->SetLineWidth(2.0);
   l1b->SetLineColor(kRed);
   //l1b->DrawLine(200.0,1.0,600.0,1.0);
   cMCMC->Update();
   
   
   // cMCMC->RedrawAxis("");
   gPad->RedrawAxis("");
   // hr->GetYaxis()->DrawClone();
   cMCMC->Update();
   cMCMC->SaveAs("Grav2l2q_UL_MCMC.root");
   cMCMC->SaveAs("Grav2l2q_UL_MCMC.eps");
   cMCMC->SaveAs("Grav2l2q_UL_MCMC.pdf");
   cMCMC->SaveAs("Grav2l2q_UL_MCMC.png");
   gPad->SetLogy();
   cMCMC->SaveAs("Grav2l2q_UL_MCMC_log.eps");
   cMCMC->SaveAs("Grav2l2q_UL_MCMC_log.pdf");
   cMCMC->SaveAs("Grav2l2q_UL_MCMC_log.png");
  // cMCMC->SaveAs("ClsLimit_1fb.png");

   TFile *fout=new TFile("MCMC_graph.root","RECREATE");
   fout->cd();
   grobslim_cls->Write();
   fout->Close();

}//end main
Example #10
0
void MakeSystPlot(const TString& channel, TFile * input, RooWorkspace * ws, const RooArgList * obs, 
                  const Int_t p, const Int_t up, const Int_t down)
{
    TString pdfname = g_pdfname;
    pdfname.ReplaceAll("$CHANNEL", channel);

    const TString& process = g_processes[p];
    TString systUp = g_systematics[up];
    systUp.ReplaceAll("$CHANNEL", channel);
    systUp.ReplaceAll("$PROCESS", process);
    
    TString systDown = g_systematics[down];
    systDown.ReplaceAll("$CHANNEL", channel);
    systDown.ReplaceAll("$PROCESS", process);

    if (process != "Wj0b" && process != "Wj1b" && process != "Wj2b") {
        if (systUp.Contains("WJModel") || systDown.Contains("WJModel") || systUp.Contains("WJSlope") || systDown.Contains("WJSlope"))
            return;
    }

    if (process != "Zj0b" && process != "Zj1b" && process != "Zj2b") {
        if (systUp.Contains("ZJModel") || systDown.Contains("ZJModel") || systUp.Contains("ZJSlope") || systDown.Contains("ZJSlope"))
            return;
    }
    
    if (process != "TT") {
        if (systUp.Contains("TTModel") || systDown.Contains("TTModel"))
            return;
    }
    
    TH1F * h = (TH1F *) input->Get(channel + "/" + process);
    TH1F * hUp = (TH1F *) input->Get(channel + "/" + process + "_" + systUp);
    TH1F * hDown = (TH1F *) input->Get(channel + "/" + process + "_" + systDown);
    if ((h->Integral() > 0. && hUp->Integral() <= 0.) || h->Integral() <= 0.) {
        TString clonename = hUp->GetName();
        delete hUp;
        hUp = (TH1F*) h->Clone(clonename);
    }
    if ((h->Integral() > 0. && hDown->Integral() <= 0.) || h->Integral() <= 0.) {
        TString clonename = hDown->GetName();
        delete hDown;
        hDown = (TH1F*) h->Clone(clonename);
    }
    if (process == "WH" || process == "ZH" || process == "VH") {
        if (systUp.Contains("eff_b"))
            systUp.ReplaceAll("eff_b", "eff_b_SIG");
        if (systDown.Contains("eff_b"))
            systDown.ReplaceAll("eff_b", "eff_b_SIG");
    }
    RooDataHist * dhUp = new RooDataHist(process + "_" + systUp, "", *obs, hUp);
    ws->import(*dhUp);
    RooDataHist * dhDown = new RooDataHist(process + "_" + systDown, "", *obs, hDown);
    ws->import(*dhDown);
    
    h->SetStats(0);
    h->SetTitle("; BDT");
    h->SetLineColor(1);
    h->SetLineWidth(2);
    h->SetFillColor(0);
    h->SetMarkerStyle(20);
    h->SetMinimum(0.01);
    h->GetXaxis()->CenterTitle();
    
    hUp->SetLineColor(g_upcol);
    hUp->SetLineWidth(2);
    hUp->SetFillColor(0);
    
    hDown->SetLineColor(g_downcol);
    hDown->SetLineWidth(2);
    hDown->SetFillColor(0);
    
    h->Draw("e1");
    hUp->Draw("hist same");
    hDown->Draw("hist same");
    h->Draw("e1 same");
    
    TLegend * leg = new TLegend(0.35, 0.20, 0.92, 0.35);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->SetLineColor(0);
    leg->SetShadowColor(0);
    leg->SetTextFont(62);
    //leg->SetTextSize(0.015);
    leg->AddEntry(h, process, "pl");
    leg->AddEntry(hUp, systUp, "l");
    leg->AddEntry(hDown, systDown, "l");
    leg->Draw();

    gPad->RedrawAxis();
    gPad->Modified();
    gPad->Update();
    gPad->Print(pdfname);
    
    delete dhUp;
    delete dhDown;
    delete leg;
    
    return;
}
Example #11
0
void overlay_plots(const string& fFile0, const string& fFile1, const string& fPlot0, const string& fPlot1, const double fXmin, const double fXmax, const double fYmin, const double fYmax,const string& fXAxisLabel, const string& fYAxisLabel, const string& fTitle, const string& fName, const int doFit) {
  
   gStyle->SetOptStat(kFALSE);
 
   TH2F *h2[4];
   TH1F *h[2];
   
   TFile file0(fFile0.c_str());
   h2[0] = (TH2F*)file0.Get(fPlot0.c_str()); 
   h2[1] = (TH2F*)file0.Get(fPlot1.c_str()); 
   
   h2[0]->Add(h2[1],1.0);
   
   TFile file1(fFile1.c_str());
   h2[2] = (TH2F*)file1.Get(fPlot0.c_str()); 
   h2[3] = (TH2F*)file1.Get(fPlot1.c_str()); 
   
   h2[2]->Add(h2[3],1.0);
   
   h[0] = new TH1F("h0","h0",h2[0]->GetXaxis()->GetNbins(),h2[0]->GetXaxis()->GetXmin(),h2[0]->GetXaxis()->GetXmax());
   h[1] = new TH1F("h1","h1",h2[2]->GetXaxis()->GetNbins(),h2[2]->GetXaxis()->GetXmin(),h2[2]->GetXaxis()->GetXmax());
   
//    for(Int_t i=1; i<=h2[0]->GetNbinsX(); i++) {
     for(Int_t i=1; i<=14; i++) {

     TH1D* h_temp = h2[0]->ProjectionY("h_temp", i, i, "e");

     Int_t ngroup = 1;

     if( fTitle.find("900") != string::npos ) {
       if(i==10) ngroup = 2;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     } else if( fTitle.find("2360") != string::npos ) {
       if(i==10) ngroup = 4;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     }
     
     h_temp->Rebin(ngroup);
     
     TF1* f1= new TF1("f1", "gaus", h_temp->GetXaxis()->GetXmin(), h_temp->GetXaxis()->GetXmax());
     f1->SetParameters(h_temp->GetBinContent(h_temp->GetMaximumBin()),h_temp->GetMean(),h_temp->GetRMS());
     
     h_temp->Fit("f1","R", "",h_temp->GetXaxis()->GetXmin(),h_temp->GetXaxis()->GetXmax());
  
     h[0]->SetBinContent(i, f1->GetParameter(2));
     h[0]->SetBinError(i, f1->GetParError(2));
      
     delete f1;
     delete h_temp;
   }
   
//    for(Int_t i=1; i<=h2[2]->GetNbinsX(); i++) {
   for(Int_t i=1; i<=14; i++) {
    
     TH1D* h_temp = h2[2]->ProjectionY("h_temp", i, i, "e");
     
     Int_t ngroup = 1;

     if( fTitle.find("900") != string::npos ) {
       if(i==10) ngroup = 2;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     } else if( fTitle.find("2360") != string::npos ) {
       if(i==10) ngroup = 4;
       else if(i==11) ngroup = 4;
       else if(i==12) ngroup = 4;
       else if(i==13) ngroup = 4;
       else if(i==14) ngroup = 8;
       else if(i==15) ngroup = 8;
     }
     
     h_temp->Rebin(ngroup);
  
     TF1* f1= new TF1("f1", "gaus", h_temp->GetXaxis()->GetXmin(), h_temp->GetXaxis()->GetXmax());
     f1->SetParameters(h_temp->GetBinContent(h_temp->GetMaximumBin()),h_temp->GetMean(),h_temp->GetRMS());
     h_temp->Fit("f1","R", "",h_temp->GetXaxis()->GetXmin(),h_temp->GetXaxis()->GetXmax());
  
     h[1]->SetBinContent(i, f1->GetParameter(2));
     h[1]->SetBinError(i, f1->GetParError(2));
      
     delete f1;
     delete h_temp;
   }
   
   h[1]->SetTitle(fTitle.c_str());
   h[1]->GetXaxis()->SetTitle(fXAxisLabel.c_str());
   h[1]->GetYaxis()->SetTitle(fYAxisLabel.c_str());
   h[1]->GetXaxis()->SetRangeUser(fXmin,fXmax);
   h[1]->GetYaxis()->SetRangeUser(fYmin,fYmax);

   h[1]->SetTitleOffset(1.,"X");
   h[1]->SetTitleOffset(1.,"Y");
//    h[1]->GetXaxis()->SetTitleSize(0.04);
//    h[1]->GetYaxis()->SetTitleSize(0.04);
   
   TCanvas *c = new TCanvas("c","",1200,800);
//    TCanvas *c = new TCanvas("c");
   c->cd();

   TF1 *fit = new TF1("fit","sqrt(pow([0],2)+pow([1],2)*(x-[3])+pow([2]*(x-[3]),2))",fXmin,(fXmax+1));
   fit->SetParName(0, "A");
   fit->SetParameter(0, 0.5);
   fit->SetParLimits(0, 0.1, 2);
   fit->SetParName(1, "B");
   fit->SetParameter(1, 0.5);
   fit->SetParLimits(1, 0, 1.5);
   fit->SetParName(2, "C");
   fit->SetParameter(2, 0.02);
   fit->SetParLimits(2, 0, 0.2);
   fit->SetParName(3, "D");
   fit->SetParameter(3, 3);
   fit->SetParLimits(3, 2, 5);
//    fit->FixParameter(3, 0);

   if(doFit==1) h[1]->Fit("fit","RV");

   h[0]->SetLineWidth(2);
   h[0]->SetLineStyle(2);
   h[0]->SetLineColor(kRed);
   h[0]->SetFillColor(kRed);
//    h[0]->SetMarkerSize(.6);
   h[0]->SetMarkerStyle(26);
   h[0]->SetMarkerColor(kRed);
   h[1]->SetLineWidth(2);
//    h[1]->SetLineStyle(3);
   h[1]->SetLineColor(kBlack);
//    h[1]->SetMarkerSize(.8);
   h[1]->SetMarkerStyle(20);
   h[1]->SetMarkerColor(kBlack);
   h[1]->Draw("");
   h[0]->Draw("same");
   if(doFit==1) fit->Draw("same");
   
   TLegend *legend = new TLegend(.65,.25,.95,.4);
   legend->SetBorderSize(0);
   legend->SetFillColor(0);
   legend->SetFillStyle(0);
   legend->SetTextFont(62);
   legend->AddEntry(h[1],"Data","lp");
   legend->AddEntry(h[0],"Simulation","lp");
   legend->Draw();
   
   TLatex l;
   l.SetTextAlign(12);
   l.SetTextSize(0.05);
   l.SetTextFont(62);
   l.SetNDC();
   l.DrawLatex(0.14,0.84,"CMS 2009 Preliminary");
   l.DrawLatex(0.14,0.79,("#sqrt{s}="+fTitle).c_str());
   l.DrawLatex(0.12,0.5,"f(x)=#sqrt{A^{2}+B^{2}(x-D)+C^{2}(x-D)^{2}}");

   c->SetGridx();
   c->SetGridy();

   c->SaveAs(fName.c_str());
   
   delete legend;
   delete h[0];
   delete h[1];
   delete c;
}
Example #12
0
void makePassFail_QCDMC(const string numeHistName, const string denoHistName, 
			const string title, const string HTbinlabel, 
			const string signalHistName, const string controlHistName,
			const pair<unsigned, unsigned>& jetBin,
			const float fitrange_xmin = 50, const float fitrange_xmax = 150) 
{
	incMHTBins.clear();
	for (int i=0; i<nMHTbins; ++i) incMHTBins.push_back(arrMHTbins[i]);
	const bool logScale = true;
	const float scaleTo = fDATA_LUMI; // pb-1

	TH1 *Hist_pass = GetHist(numeHistName, scaleTo);
	TH1 *Hist_fail = GetHist(denoHistName, scaleTo);

	Hist_pass->SetMarkerColor(kBlack);
	Hist_pass->SetLineColor(kBlack);
	/*new TCanvas();
	gPad->SetLogy();
	Hist_pass->SetLineColor(kRed);
	Hist_pass->SetMarkerColor(kRed);
	Hist_pass->DrawCopy();
	Hist_fail->DrawCopy("same");
	*/
	//gPad->Print("range.eps");
	cout << __LINE__ << ": Integrals= " << Hist_fail->Integral() << "/" << Hist_pass->Integral() << endl;
	if (Hist_fail->GetEntries()<1 || Hist_pass->GetEntries()<1) 
	{
		cout << __LINE__ << ": not enough intries to make the plots!!! " << Hist_fail->Integral() << "/" << Hist_pass->Integral() << endl;
		return;
	}

//	DumpHist(Hist_pass);
//	DumpHist(Hist_fail);

	Hist_pass->Divide(Hist_fail);

//	cout << ">>>>>>> AFTER DIVIDE <<<<< " << endl;
//	DumpHist(Hist_pass);
	const int maxbin = Hist_pass->GetMaximumBin();
	const double max = Hist_pass->GetBinContent(maxbin);
	//Hist_pass->GetYaxis()->SetRangeUser(-0.05, max+0.05);


	//fit range
	//const float fitrange_xmin = 50, fitrange_xmax = 120;
	stringstream newtitle;
	//newtitle << "Fit Range " << fitrange_xmin << "--" << fitrange_xmax << title;
	//newtitle << title << " (fit range = " <<  fitrange_xmin << "--" << fitrange_xmax << "), c = " << CONST_C << ";MHT [GeV];Ratio (r);";
	newtitle << title << " (fit range = " <<  fitrange_xmin << "-" << fitrange_xmax << ");MHT [GeV];Ratio (r);";


	gStyle->SetOptStat(0);	
	new TCanvas();
	//gPad->SetGridy();
	gPad->SetTickx();
	if (logScale) gPad->SetLogy();
	Hist_pass->SetLineColor(9);
	Hist_pass->SetTitle(newtitle.str().c_str());
	Hist_pass->SetLineWidth(2);

	gStyle->SetOptFit(1);
	//Hist_pass->SetStats(0);
	Hist_pass->Draw();
	//return;

	//do fittings exp and gaus
	/*float C_UPLIMIT = 0.04;
	float C_LOLIMIT = 0.02;
	if (jetBin.first == 2 && jetBin.second == 2)
	{
		C_UPLIMIT = 0.00235;
		C_LOLIMIT = 0.00232;
	} else if (jetBin.first == 3 && jetBin.second == 5)
	{
		C_UPLIMIT = 0.03;
		C_LOLIMIT = 0.025;
	} else if (jetBin.first == 6 && jetBin.second == 7)
	{
		C_UPLIMIT = 0.2;
		C_LOLIMIT = 0.17;
	} else if (jetBin.first == 8)
	{
		C_UPLIMIT = 0.4;
		C_LOLIMIT = 0.2;
	}
	*/

	const float mean_c_initial = GetAvgVal(Hist_pass, 350);

	//do fittings exp and gaus
	const float C_UPLIMIT = mean_c_initial+0.0001; //this only to get this values on the stat box
	const float C_LOLIMIT = mean_c_initial-0.0001;



	Hist_pass->SetMinimum(C_LOLIMIT/10);


	TF1 *expFit=new TF1("fit_1",expFitFunc,fitrange_xmin,fitrange_xmax,3);
	expFit->SetParameter(0,0.09);
	expFit->SetParameter(1,-0.0002);
	expFit->SetParameter(2,CONST_C);
	expFit->SetParLimits(2,C_LOLIMIT, C_UPLIMIT);
	Hist_pass->Fit(expFit,"E0","",fitrange_xmin, fitrange_xmax);
	gPad->Modified();
	gPad->Update();
	TPaveStats *e_stats = (TPaveStats*) Hist_pass->FindObject("stats");
	e_stats->SetTextColor(kRed);
	TPaveStats *exp_stats = (TPaveStats*) e_stats->Clone("exp_stats");

	TF1 *expFit2=new TF1("fit_2",expFitFunc,50,1000.0,3);
	expFit2->SetParameter(0,expFit->GetParameter(0));
	expFit2->SetParameter(1,expFit->GetParameter(1));
	expFit2->SetParameter(2,expFit->GetParameter(2));
	expFit2->SetLineColor(kRed+1);
	expFit2->SetLineWidth(2);

	//for unceratinty on c
	TF1 *expFit_sigma = new TF1("Exp_sigma",expFitFunc_Cup,50,1000.0,3);
	expFit_sigma->SetParameter(0,expFit->GetParameter(0));
	expFit_sigma->SetParameter(1,expFit->GetParameter(1));
	expFit_sigma->SetParameter(2,expFit->GetParameter(2)); //%100 error
	expFit_sigma->SetParLimits(2,C_LOLIMIT/2., C_UPLIMIT*2.);
	Hist_pass->Fit(expFit_sigma,"E0","",fitrange_xmin, fitrange_xmax);


	TF1 *gausFit=new TF1("fit_3",gausFitFunc,fitrange_xmin, fitrange_xmax,3);
	gausFit->SetParameter(0,0.09); 
	gausFit->SetParameter(1,-0.0002);
	gausFit->SetParameter(2,CONST_C);
	gausFit->SetParLimits(2,C_LOLIMIT,C_UPLIMIT);
	gausFit->SetLineColor(kGreen-2);
	Hist_pass->Fit(gausFit,"E0","", fitrange_xmin, fitrange_xmax);
	gPad->Modified();
	gPad->Update();
	TPaveStats *gaus_stats = (TPaveStats*) Hist_pass->FindObject("stats");
	gaus_stats->SetTextColor(kGreen);
	//TPaveStats *gaus_stats = (TPaveStats*) g_stats->Clone("gaus_stats");

	//TF1 *gausFit2=new TF1("fit_4",gausFitFunc,50,1000.0,2);
	TF1 *gausFit2=new TF1("fit_4",gausFitFunc,50,1000.0,3);
	gausFit2->SetParameter(0,gausFit->GetParameter(0)); 
	gausFit2->SetParameter(1,gausFit->GetParameter(1));
	gausFit2->SetParameter(2,gausFit->GetParameter(2));
	gausFit2->SetLineColor(kGreen);
	gausFit2->SetLineWidth(2);

	//for unceratinty on c
	TF1 *gausFit_sigma=new TF1("Gaus_sigma",gausFitFunc_Cup,50,1000.0,3);
	gausFit_sigma->SetParameter(0,gausFit->GetParameter(0)); 
	gausFit_sigma->SetParameter(1,gausFit->GetParameter(1));
	gausFit_sigma->SetParameter(2,gausFit->GetParameter(2) * 2); //100% error
	gausFit_sigma->SetParLimits(2,C_LOLIMIT/2., C_UPLIMIT*2.);
	Hist_pass->Fit(gausFit_sigma,"E0","", fitrange_xmin, fitrange_xmax);


	gausFit2->Draw("same");
	expFit2->Draw("same");
	/*gausFit_sigma->SetLineStyle(10);
	gausFit_sigma->SetLineColor(gausFit2->GetLineColor());
	expFit_sigma->SetLineStyle(10);
	expFit_sigma->SetLineWidth(2);
	expFit_sigma->SetLineColor(expFit2->GetLineColor());
	gausFit_sigma->Draw("same");
	expFit_sigma->Draw("same");
*/
	//TLegend *leg  = new TLegend(0.7,0.8,0.9,0.9);
	TLegend *leg  = new TLegend(0.7,0.7,0.9,0.9);
	leg->AddEntry(gausFit2,"Gaussian");
	leg->AddEntry(expFit2,"Exponential");
	leg->SetTextFont(42);
	leg->Draw();

	const float xmin=0.2, xmax=0.45, ymin=0.7, ymax=0.9;
	gaus_stats->SetX1NDC(xmin);
	gaus_stats->SetX2NDC(xmax);
	gaus_stats->SetY1NDC(ymin);
	gaus_stats->SetY2NDC(ymax);
	gaus_stats->Draw("same");
	exp_stats->SetX1NDC(xmax);
	exp_stats->SetX2NDC(xmax+0.25);
	exp_stats->SetY1NDC(ymin);
	exp_stats->SetY2NDC(ymax);
	exp_stats->Draw("same");

	//fit quality
	stringstream gaus_fit_res, exp_fit_res;
	const float gausFit_goodness =  gausFit->GetChisquare()/gausFit->GetNDF();
	gaus_fit_res << "#chi^{2}/ndof = " << gausFit->GetChisquare()
			 << "/"<< gausFit->GetNDF() << " = " << gausFit_goodness;
	const float expFit_goodness =  expFit->GetChisquare()/expFit->GetNDF();
	exp_fit_res << "#chi^{2}/ndof = " << expFit->GetChisquare()
			 << "/"<< expFit->GetNDF() << " = " << expFit_goodness;

	cout << gaus_fit_res.str() << endl;
	cout << exp_fit_res.str() << endl;

	TPaveText *pt1 = new TPaveText(0.5,0.8,0.7,0.9);
	pt1->AddText(gaus_fit_res.str().c_str());
	pt1->AddText(exp_fit_res.str().c_str());
//	pt1->Draw("same");

	//stringstream epsname;
	//epsname << "factnomht/HTbin" << HTbin << "_fitrange_" << fitrange_xmin << "to" << fitrange_xmax << ".eps";
	//epsname << "factnomht_" << HTbinlabel << ".eps";
	//gPad->Print(epsname.str().c_str());
	gPad->Print("ratios.eps");
	//return;

	 //make a predicion
	TH1 *sigHist      = GetHist(signalHistName, scaleTo);
	TH1 *controlHist  = GetHist(controlHistName, scaleTo);

	//temp hack to get # of bins the same for easy debugging
	sigHist->Rebin(2);

	cout << red << "sigHist/controlHist bins = " << sigHist->GetNbinsX() << "/" << controlHist->GetNbinsX() << clearatt << endl; 
//	new TCanvas();
//	sigHist->SetLineColor(kRed);
//	sigHist->Rebin(50);
//	controlHist->Rebin(50);
//	sigHist->Draw();
//	controlHist->Draw("same");


	//collect results
/*	Predictions_t pred_gaus       = GetPredictions(controlHist, gausFit2, sigHist); 
	Predictions_t pred_gaus_sigma = GetPredictions(controlHist, gausFit_sigma, sigHist); 
	Predictions_t pred_exp        = GetPredictions(controlHist, expFit2, sigHist); 
	Predictions_t pred_exp_sigma  = GetPredictions(controlHist, expFit_sigma, sigHist); 

//	PrintExclResults(pred_gaus);
//	PrintExclResults(pred_exp);
	PrintExclResults(pred_gaus, pred_exp, pred_gaus_sigma, pred_exp_sigma);
*/
	/*****************************************/
	// TEMP HACK TO GET RESULTS for all HT bins 
	// using these inclusive fits
	/*****************************************/
	vector<pair<float, float> > htBins_temp;
	pair<float, float> htbin1(500,750);	
	pair<float, float> htbin2(750,1000);	
	pair<float, float> htbin3(1000,1250);	
	pair<float, float> htbin4(1250,1500);	
	pair<float, float> htbin5(1500,8000);	

	htBins_temp.push_back(htbin1);
	htBins_temp.push_back(htbin2);
	htBins_temp.push_back(htbin3);
	htBins_temp.push_back(htbin4);
	htBins_temp.push_back(htbin5);

	TFile file("qcd_all.root");
	if (file.IsZombie()) 
	{ 
		cout << __FUNCTION__ << ":" << __LINE__ 
				<< "File to get exlcusive HT prediction is not found!" << endl;assert (false);
	}

	for (unsigned htbin=0; htbin<htBins_temp.size(); ++htbin)
	{
		stringstream folder, control_hist_name, signal_hist_name;
		folder << "Hist/Njet" << jetBin.first << "to" << jetBin.second 
			<< "HT"   << htBins_temp.at(htbin).first << "to" << htBins_temp.at(htbin).second 
			<< "MHT0to8000";
		control_hist_name << folder.str() << "/smeared_failFineBin1"; 
		signal_hist_name << folder.str() << "/smear_signalFineBin"; 
		TH1* control_hist = (TH1*) (file.Get(control_hist_name.str().c_str())); 
		if (control_hist == NULL) { 
			cout << __LINE__ << ": control hist " << control_hist_name.str() << " not found for htbin " << htBins_temp.at(htbin).first 
				<< "-" << htBins_temp.at(htbin).second << endl; 
			assert(false);		
		} 
		TH1* signal_hist = (TH1*) (file.Get(signal_hist_name.str().c_str())); 
		if (signal_hist == NULL) { cout << __LINE__ << ": signal hist not found for htbin " << htBins_temp.at(htbin).first << "-" << htBins_temp.at(htbin).second << endl; } 

		control_hist->Print();
		signal_hist->Print();

		//temp hack to get # of bins the same for easy debugging
		signal_hist->Rebin(2);

		Predictions_t pred_gaus       = GetPredictions(control_hist, gausFit2, signal_hist); 
		Predictions_t pred_gaus_sigma = GetPredictions(control_hist, gausFit_sigma, signal_hist); 
		Predictions_t pred_exp        = GetPredictions(control_hist, expFit2, signal_hist); 
		Predictions_t pred_exp_sigma  = GetPredictions(control_hist, expFit_sigma, signal_hist); 

		cout << ">>>>>>>>>>>>>>> PREDICTIONS FOR " << jetBin.first << "-" << jetBin.second 
					<< ", HT=" << htBins_temp.at(htbin).first << "-" << htBins_temp.at(htbin).second << endl;
		PrintExclResults(pred_gaus, pred_exp, pred_gaus_sigma, pred_exp_sigma);
	}

	file.Close();

}
TCanvas* overlay_Merged_RecoSmeared(const vector<string>& folders, 
								const hist_t& h
								)
{

	TLegend *leg  = new TLegend(0.6,0.65,0.9,0.9);
	leg->SetTextFont(42);
	vector<TH1*> hists;
	
	vector<string> jetcoll;
	jetcoll.push_back("reco");
	jetcoll.push_back("gen");
	jetcoll.push_back("smeared");

	stringstream title;
	const string njets("3-5");
	//const string eta("2.5");
	const string eta("5.0");
	title << njets
			<< " Jets, MHT from Jets with P_{T}>30 GeV, |#eta |<" 
			<< eta << ", L = 10 fb^{-1}" << ";" << h.title ;

	for (unsigned j=0; j< jetcoll.size(); ++j)
	{
		TH1* Hist = 0;
		for (unsigned i = 0; i < folders.size(); ++i)
		{
			stringstream histname;
			histname << folders.at(i) << "/" << jetcoll.at(j) << h.name;
			cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
			TH1* htemp = GetHist(histname.str());
			
			if (Hist == 0) Hist = htemp;
			else Hist->Add(htemp);
		}
		
		Hist->Rebin(h.rebin);
		Hist->SetTitle(title.str().c_str());
		Hist->SetMarkerStyle(20+j);
		Hist->SetLineWidth(2);
		Hist->SetStats(0);

		stringstream legname;
		if (j==0) 
		{
			legname << "Reco"; 
		} else if (j==1) 
		{
			legname << "Gen"; 
			Hist->SetLineColor(kBlue);
			Hist->SetMarkerColor(kBlue);
		} else if (j==2)
		{
			legname << "Smeared"; 
			Hist->SetLineColor(kRed);
			Hist->SetMarkerColor(kRed);
		}

		const double sum = Hist->Integral(); 
		legname << " (" << sum << ")";
		if (j!=1) leg->AddEntry(Hist, legname.str().c_str());

		hists.push_back(Hist);

	} //end jetcoll
	
	TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
	ratio->GetYaxis()->SetTitle("Smeared/Reco");
	ratio->SetTitle("");
	ratio->Divide(hists.at(0));
	ratio->GetYaxis()->SetRangeUser(-0.01,2.01);
	//ratio->SetTickLength (+0.01,"Y");

   //TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
   TCanvas *c1 = new TCanvas("c1");
   c1->Range(0,0,1,1);
   c1->SetBorderSize(2);
   c1->SetFrameFillColor(0);
  
// ------------>Primitives in pad: c1_1
   TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
   c1_1->Draw();
   c1_1->cd();
   c1_1->SetBorderSize(2);
   c1_1->SetTickx(1);
   c1_1->SetTicky(1);
   c1_1->SetTopMargin(0.1);
   c1_1->SetBottomMargin(0.0);
   //c1_1->SetFrameFillColor(3);
	c1_1->SetLogy();
   
	hists.at(0)->GetYaxis()->CenterTitle(1);
	hists.at(0)->SetLabelFont(42,"XYZ");
	hists.at(0)->SetTitleFont(42,"XYZ");
	hists.at(0)->GetYaxis()->SetTitleOffset(0.8);
	hists.at(0)->SetLabelSize(0.05,"XYZ");
	hists.at(0)->SetTitleSize(0.06,"XYZ");
   hists.at(0)->Draw("P");
   hists.at(2)->Draw("same P");
	leg->Draw();

   c1_1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: c1_2
   TPad *c1_2 = new TPad("c1_2", "c1_2",0.01,0.01,0.99,0.30);
   c1_2->Draw();
   c1_2->cd();
   c1_2->SetBorderSize(2);
   c1_2->SetTickx(1);
   c1_2->SetTicky(1);
   c1_2->SetTopMargin(0.0);
   c1_2->SetBottomMargin(0.24);
   c1_2->SetFrameFillColor(0);
	c1_2->SetGridx();
	c1_2->SetGridy();
   
	ratio->GetYaxis()->SetTitleOffset(0.4);
	ratio->GetXaxis()->SetTitleOffset(0.9);
	ratio->GetYaxis()->CenterTitle(1);
	ratio->GetXaxis()->CenterTitle(1);
	ratio->SetLabelSize(0.125,"XYZ");
	ratio->SetTitleSize(0.125,"XYZ");
//	ratio->SetLabelFont(labelfont,"XYZ");
//	ratio->SetTitleFont(titlefont,"XYZ");
   ratio->GetXaxis()->SetTickLength(0.07);
   ratio->Draw("");
   
   c1_2->Modified();
   c1->cd();
   //c1->Modified();
   //c1->cd();
   //c1->SetSelected(c1);
	return c1;

}
Example #14
0
void generatePlots(Files *inputs, const string &path)
{
    Files::const_iterator first_source = inputs->begin();
    TDirectory *folder = dynamic_cast<TDirectory *>(first_source->second->Get(path.c_str()));
    if (!folder)
    {
        cerr << "Failed to extract folder: " << path << endl;

        return;
    }
    //
    //gain time, do not add the objects in the list in memory
    //
    Bool_t status = TH1::AddDirectoryStatus();
    TH1::AddDirectory(kFALSE);

    // loop over all keys in this directory
    TIter nextkey(folder->GetListOfKeys() );

    for(TKey *key, *oldkey=0; key = (TKey*) nextkey(); )
    {
        //keep only the highest cycle number for each key
        if (oldkey
            && !strcmp(oldkey->GetName(), key->GetName()))

            continue;

        // read object from first source file
        //
        TObject *obj = key->ReadObj();

        if ( obj->IsA()->InheritsFrom(TH1::Class()))
        {
            cout << obj->GetName() << endl;

            TCanvas *canvas = new TCanvas();

            canvas->SetWindowSize(640, 480);

            THStack *stack = new THStack();
            TLegend  *legend = new TLegend(.6, .98, .98, .58);
            legend->SetBorderSize(1);
            legend->SetLineStyle(1);
            legend->SetTextFont(43);
            legend->SetTextSizePixels(12);
            legend->SetFillColor(0);

            TH1 *h1 = dynamic_cast<TH1*>(obj);
            legend->AddEntry(h1, style(h1, first_source->first).c_str(), "pl");
            h1->Scale(1.0 / h1->Integral());

            stack->Add(h1);

            // loop over all source files and add the content of the
            // correspondant histogram to the one pointed to by "h1"
            for(Files::const_iterator input = ++inputs->begin();
                    inputs->end() != input;
                    ++input)
            {
                TH1 *h2 = dynamic_cast<TH1*>(input->second->Get((path + "/" + obj->GetName()).c_str()));
                if (!h2)
                {
                    cerr << "Failed to extract plot from input: " << endl;

                    continue;
                }

                h2->Scale(1. / h2->Integral());
                legend->AddEntry(h2, style(h2, input->first).c_str(), "pl");
                stack->Add(h2);
            }

            stack->Draw("h nostack");
            legend->Draw();
            stack->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());

            canvas->Update();
        } else {
            // object is of no type that we know or can handle
            //
            cout << "Unknown object type, name: "
                << obj->GetName() << " title: " << obj->GetTitle() << endl;
        }
    }

    // save modifications to target file
    TH1::AddDirectory(status);
}
void plot_rcp_for_energy( string energy = "15", bool pannel = false ){

	RooPlotLib rpl;

	TH1 * master = new TH1D( "frame", "frame", 100, 0, 10 );
	master->Draw();

	if ( !pannel  ){
		gPad->SetLeftMargin( 0.15 );
		gPad->SetBottomMargin( 0.15 );
		gPad->SetRightMargin( 0.01 );
		gPad->SetTopMargin( 0.01 );
	}

	gStyle->SetTitleFontSize(0.1);

	vector<string> plcs = { "Ks0", "Lambda", "Xi" };

	if ( "19" == energy || "27" == energy || "39" == energy )
		plcs.push_back( "Omega" ); 


	TLegend * leg = new TLegend( 0.2, 0.5, 0.65, 0.85 );
	leg-> SetNColumns(2);
	leg->SetTextFont( 52 );
	leg->SetTextSize( 0.07 ); 

	int index = 0;
	for ( string plc : plcs){
		TGraphErrors * g = plot_single_rcp( energy, plc );

		rpl.style( g )
			.set( "color", colors[ index ] )
			.set( "markerstyle", markers[ index ] )
			.set( "markersize", 2 );

		rpl.style( g->GetHistogram() )
			.set( "titlesize", 0.25 );

		leg->AddEntry( g, legend_label(plc).c_str(), "pe" );


		index ++;
	}

	rpl.style( master )
		//.set( "title", energy + " GeV; p_{T} [GeV/c]; R_{CP} (0-5%) / (40-60%)" )
		.set( "title", energy_label( energy ) + " GeV; p_{T} [GeV/c]" )
		.set( "optstat", 0 )
		.set( "yr", 0.2, 4.2 )
		.set( "xr", 0.2, 5.2 )
		.set( "xls", 0.08 )
		.set( "yls", 0.08 )
		.set( "yts", 0.08 )
		.set( "xts", 0.08 );

	TLine * lUnity = new TLine( 0.2, 1, 5.2, 1 );
	rpl.style( lUnity )
		.set( "color", kBlack )
		.set( "linewidth", 4 )
		.set( "linestyle", kDashed )
		.set( "draw", "same" )
		.draw();

	if ( "39" == energy )
		leg->Draw("same");
	



}
void paraPull_alpha_FT_EFF_Eigen_Light_3_2TeV_2Lep_plots_All()
{
//=========Macro generated from canvas: c1/alpha_FT_EFF_Eigen_Light_3
//=========  (Sun Nov 22 20:18:27 2015) by ROOT version6.02/12
   TCanvas *c1 = new TCanvas("c1", "alpha_FT_EFF_Eigen_Light_3",0,22,1000,600);
   gStyle->SetOptStat(0);
   c1->Range(-4.125,-0.9750185,37.125,1.047039);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetGridx();
   c1->SetGridy();
   c1->SetFrameBorderMode(0);
   c1->SetFrameBorderMode(0);
   
   TH1F *NuisanceParameterFreed21 = new TH1F("NuisanceParameterFreed21","alpha_FT_EFF_Eigen_Light_3",33,0,33);
   NuisanceParameterFreed21->SetMinimum(-0.7728128);
   NuisanceParameterFreed21->SetMaximum(0.844833);
   NuisanceParameterFreed21->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   NuisanceParameterFreed21->SetLineColor(ci);
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(1,"XS_ttbar");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(2,"EG_SCALE_ALL");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(3,"FT_EFF_Eigen_C_0");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(4,"Luminosity");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(5,"XS_st");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(6,"FT_EFF_Eigen_B_1");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(7,"XS_Zc");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(8,"MUONS_ID");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(9,"FT_EFF_Eigen_C_1");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(10,"FT_EFF_Eigen_C_3");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(11,"MUON_EFF_TrigSystUncertainty");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(12,"XS_Zl");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(13,"EL_EFF_ID_TotalCorrUncertainty");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(14,"FT_EFF_Eigen_B_0");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(15,"FT_EFF_Eigen_B_2");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(16,"EL_EFF_Iso_TotalCorrUncertainty");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(17,"EL_EFF_Reco_TotalCorrUncertainty");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(18,"MUONS_SCALE");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(19,"MUON_ISO_STAT");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(20,"FT_EFF_extrapolation");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(21,"MUON_EFF_STAT");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(22,"MUON_EFF_SYS");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(23,"MUON_EFF_TrigStatUncertainty");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(24,"FT_EFF_Eigen_Light_1");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(25,"FT_EFF_Eigen_Light_2");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(26,"EG_RESOLUTION_ALL");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(27,"XS_diboson");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(28,"FT_EFF_Eigen_Light_4");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(29,"MUON_ISO_SYS");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(30,"XS_Zb");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(31,"MUONS_MS");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(32,"FT_EFF_Eigen_C_2");
   NuisanceParameterFreed21->GetXaxis()->SetBinLabel(33,"FT_EFF_Eigen_Light_0");
   NuisanceParameterFreed21->GetXaxis()->SetLabelFont(42);
   NuisanceParameterFreed21->GetXaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed21->GetXaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed21->GetXaxis()->SetTitleFont(42);
   NuisanceParameterFreed21->GetYaxis()->SetTitle("#theta_{fit} - #theta_{initial}/#Delta#theta");
   NuisanceParameterFreed21->GetYaxis()->SetLabelFont(42);
   NuisanceParameterFreed21->GetYaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed21->GetYaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed21->GetYaxis()->SetTitleFont(42);
   NuisanceParameterFreed21->GetZaxis()->SetLabelFont(42);
   NuisanceParameterFreed21->GetZaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed21->GetZaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed21->GetZaxis()->SetTitleFont(42);
   NuisanceParameterFreed21->Draw("hist");
   
   Double_t _fx1021[35] = {
   1.22802e-312,
   0.5,
   1.5,
   2.5,
   3.5,
   4.5,
   5.5,
   6.5,
   7.5,
   8.5,
   9.5,
   10.5,
   11.5,
   12.5,
   13.5,
   14.5,
   15.5,
   16.5,
   17.5,
   18.5,
   19.5,
   20.5,
   21.5,
   22.5,
   23.5,
   24.5,
   25.5,
   26.5,
   27.5,
   28.5,
   29.5,
   30.5,
   31.5,
   32.5,
   0};
   Double_t _fy1021[35] = {
   1.22802e-312,
   -0.7728128,
   -0.392439,
   -0.2896456,
   -0.2044598,
   -0.1826729,
   -0.1278127,
   -0.1244357,
   -0.1084962,
   -0.06597153,
   -0.05697221,
   -0.05334454,
   -0.04674538,
   -0.03708376,
   -0.0323209,
   -0.03105273,
   -0.0239497,
   -0.01695474,
   -0.001380053,
   0.0001641817,
   0.01054658,
   0.01060529,
   0.0181311,
   0.01996412,
   0.02024645,
   0.02030694,
   0.02702573,
   0.04004296,
   0.0427078,
   0.05119136,
   0.05487747,
   0.05566713,
   0.05764295,
   0.844833,
   0};
   Double_t _fex1021[35] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t _fey1021[35] = {
   0,
   0,
   0.6107568,
   1.073028,
   1.26786,
   0.9367263,
   0.991661,
   0.9863027,
   0.9269403,
   0.7691309,
   0.9864506,
   0.9937949,
   0.9917404,
   0.9970817,
   0.9817694,
   0.9376162,
   0.9926709,
   0.9931833,
   0.9925584,
   1.005014,
   0.9933467,
   0.9551241,
   0.9932275,
   0.9929661,
   0.9927886,
   0.9913142,
   0.9909897,
   1.098033,
   0.9870226,
   0.9931712,
   0.9855069,
   0.7542233,
   0.7380251,
   0.9909034,
   0.7857708};
   TGraphErrors *gre = new TGraphErrors(35,_fx1021,_fy1021,_fex1021,_fey1021);
   gre->SetName("");
   gre->SetTitle("");
   gre->SetFillColor(1);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(1.2);
   
   TH1F *Graph_Graph1021 = new TH1F("Graph_Graph1021","",100,0,35.75);
   Graph_Graph1021->SetMinimum(-1.803125);
   Graph_Graph1021->SetMaximum(2.166542);
   Graph_Graph1021->SetDirectory(0);
   Graph_Graph1021->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1021->SetLineColor(ci);
   Graph_Graph1021->GetXaxis()->SetLabelFont(42);
   Graph_Graph1021->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1021->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1021->GetXaxis()->SetTitleFont(42);
   Graph_Graph1021->GetYaxis()->SetLabelFont(42);
   Graph_Graph1021->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1021->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1021->GetYaxis()->SetTitleFont(42);
   Graph_Graph1021->GetZaxis()->SetLabelFont(42);
   Graph_Graph1021->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1021->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1021->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1021);
   
   gre->Draw("p");
   
   TLegend *leg = new TLegend(0.1,0.4,0.4,0.95,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(72);
   leg->SetTextSize(0.015);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.2831727,0.9341608,0.7168273,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("alpha_FT_EFF_Eigen_Light_3");
   pt->Draw();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
Example #17
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;
}
Example #18
0
void fillHisto(TString cut_mc, TString cut_data,  bool drawHistograms,  
  	     int nBins, float xLow, float xMax, TString var, bool writeoutput, TString fileName,TString title, TString Luminosity,Double_t extrascalefactor,Double_t wnorm,TString tag) {
  CMSStyle();
//  gStyle->SetOptLogy();
  TH1F* h_zjets = new TH1F("h_zjets","",nBins,xLow,xMax);
  TH1F* h_wjets = new TH1F("h_wjets","",nBins,xLow,xMax);
  TH1F* h_vvjets = new TH1F("h_vvjets","",nBins,xLow,xMax);
  TH1F* h_singtop = new TH1F("h_singtop","",nBins,xLow,xMax);
  TH1F* h_ttbar = new TH1F("h_ttbar","",nBins,xLow,xMax);
  TH1F* h_data = new TH1F("h_data","",nBins,xLow,xMax);
  TH1F* h_lq = new TH1F("h_lq","",nBins,xLow,xMax);


  zjets->Draw(var+">>h_zjets",cut_mc); 
  wjets->Draw(var+">>h_wjets",cut_mc);  
  ttbar->Draw(var+">>h_ttbar",cut_mc);  
  vvjets->Draw(var+">>h_vvjets",cut_mc);  
  singtop->Draw(var+">>h_singtop",cut_mc);  
  lq->Draw(var+">>h_lq",cut_mc);  

  data->Draw(+var+">>h_data",cut_data);

  TH1F* H_data  = new TH1F("H_data","",nBins,xLow,xMax);
  TH1F* H_zjets = new TH1F("H_zjets","",nBins,xLow,xMax);
  TH1F* H_wjets = new TH1F("H_wjets","",nBins,xLow,xMax);
  TH1F* H_singtop = new TH1F("H_singtop","",nBins,xLow,xMax);
  TH1F* H_ttbar = new TH1F("H_ttbar","",nBins,xLow,xMax);
  TH1F* H_vvjets = new TH1F("H_vvjets","",nBins,xLow,xMax);
  TH1F* H_bkg   = new TH1F("H_bkg","",nBins,xLow,xMax);
  TH1F* H_lq   = new TH1F("H_lq","",nBins,xLow,xMax);


  THStack* H_stack = new THStack("H_stack","");

	h_wjets->Scale(wnorm);
		Double_t Nd = h_data->Integral();
		Double_t Nmc = h_zjets->Integral()+h_ttbar->Integral()+h_vvjets->Integral()+h_wjets->Integral()+h_singtop->Integral();
		Double_t Nw = h_wjets->Integral();
		Double_t Nt = h_ttbar->Integral();
		Double_t Nz = h_zjets->Integral();
				Double_t Nlq = h_lq->Integral();

		std::cout<<"Data   : "<<Nd<<std::endl;
		std::cout<<"All MC : "<<Nmc<<std::endl;
    std::cout<<"tt   : "<<h_ttbar->Integral()<<"  +- "<<h_ttbar->Integral()*pow(1.0*(h_ttbar->GetEntries()),-0.5)<<std::endl;
    std::cout<<"w    : "<<h_wjets->Integral()<<"  +- "<<h_wjets->Integral()*pow(1.0*(h_wjets->GetEntries()),-0.5)<<std::endl;
    std::cout<<"LQ    : "<<h_lq->Integral()<<"  +- "<<h_lq->Integral()*pow(1.0*(h_lq->GetEntries()),-0.5)<<std::endl;

//		std::cout<<"Ratio  :"<<1.0*(Nd /Nmc)<<"  +-  "<<sqrt(Nd)/Nmc<<std::endl;

float fac =1.0*( ( Nd - (Nmc - Nw) )/Nw );
//float fac =1.0*( Nd/Nmc);
//fac = 1.0;
std::cout<<"MC Scale Factor:  "<<fac<<std::endl;
//	h_wjets->Scale(fac);
//	h_zjets->Scale(fac);
//	h_vvjets->Scale(fac);
//	h_ttbar->Scale(fac);

  H_bkg->Add(h_vvjets);

	H_data->Add(h_data);
	H_lq->Add(h_lq);
	H_wjets->Add(h_wjets);
	H_zjets->Add(h_zjets);
	H_ttbar->Add(h_ttbar);
	H_singtop->Add(h_singtop);

  H_zjets->SetFillStyle(3004);
  H_ttbar->SetFillStyle(3005);
  H_bkg->SetFillStyle(3008);
  H_wjets->SetFillStyle(3007);
  H_singtop->SetFillStyle(3006 );
  H_lq->SetFillStyle(0);

  H_zjets->SetFillColor(2);
  H_ttbar->SetFillColor(4);
	H_wjets->SetFillColor(6);
	H_singtop->SetFillColor(3);
  H_bkg->SetFillColor(9);
  
  H_zjets->SetLineColor(2);
  H_ttbar->SetLineColor(4);
  H_wjets->SetLineColor(6);
  H_singtop->SetLineColor(3);
  H_bkg->SetLineColor(9);

  H_lq->SetMarkerColor(0);    
  H_zjets->SetMarkerColor(2);
  H_wjets->SetMarkerColor(6);
  H_singtop->SetMarkerColor(3);
  H_ttbar->SetMarkerColor(4);
  H_bkg->SetMarkerColor(9);

	H_lq->SetMarkerSize(1);
	H_zjets->SetMarkerSize(.00000001);
	H_wjets->SetMarkerSize(.00000001);
	H_singtop->SetMarkerSize(.00000001);
	H_ttbar->SetMarkerSize(.00000001);
	H_bkg->SetMarkerSize(.00000001);

  H_lq->SetLineWidth(2);
  H_zjets->SetLineWidth(2);
  H_wjets->SetLineWidth(2);
  H_singtop->SetLineWidth(2);
  H_ttbar->SetLineWidth(2);
  H_bkg->SetLineWidth(2);
  H_data->SetLineWidth(2);

  H_stack->Add(H_bkg);
  H_stack->Add(H_zjets);
  H_stack->Add(H_singtop);
  H_stack->Add(H_ttbar);
  H_stack->Add(H_wjets);
//    H_stack->Add(H_lq);

  H_zjets->GetXaxis()->SetTitle(title);
  H_wjets->GetXaxis()->SetTitle(title);
  H_singtop->GetXaxis()->SetTitle(title);
  H_ttbar->GetXaxis()->SetTitle(title);
  H_data->GetXaxis()->SetTitle(title);
  H_data->GetYaxis()->SetTitle("Number of Events");
  H_data->GetXaxis()->SetTitleFont(132);
  H_data->GetYaxis()->SetTitleFont(132);


  gStyle->SetOptStat(0);
  H_data->Draw("E");

  H_stack->Draw("SAME");
    H_lq->Draw("SAME");
  H_data->Draw("SAMEE");
  TLegend* leg = new TLegend(0.6,0.63,0.91,0.91,"","brNDC");
  leg->SetTextFont(132);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
    leg->AddEntry(H_data,"Data 2011, "+Luminosity+" pb^{-1}");
  leg->AddEntry(H_zjets,"Z/#gamma* + jets");
  leg->AddEntry(H_wjets,"W + jets");
  leg->AddEntry(H_ttbar,"t#bar{t}");
  leg->AddEntry(H_singtop,"Single Top");
  leg->AddEntry(H_bkg,"Other backgrounds");
    leg->AddEntry(H_lq,"LQ M = 300");
  leg->Draw("SAME");
  c1->SetLogy();

	H_data->SetMinimum(.1);
	H_data->SetMaximum(1.2*extrascalefactor*(H_data->GetMaximum()));

  TLatex* txt =new TLatex((xMax-xLow)*.02+xLow,.3*H_data->GetMaximum(), "CMS 2011 Preliminary");  
  txt->SetTextFont(132); 
  txt->SetTextSize(0.06); 
  txt->Draw();
//  c1->RedrawAxis();

    string str = Luminosity;
    string searchString( "." ); 
    string replaceString( "_" );

    assert( searchString != replaceString );

    string::size_type pos = 0;
    while ( (pos = str.find(searchString, pos)) != string::npos ) {
        str.replace( pos, searchString.size(), replaceString );
        pos++;
    }

	TString varname = var;
	varname +="_";
	varname += str;
	std::cout<<varname<<std::endl;
//  c1->Print("GoodImages/"+varname+"March18_2011_"+tag+".pdf");
  c1->Print("PlotsMuNu/"+varname+"_"+tag+".png");

if (false){

  TH1F* h_bg = new TH1F("h_bg","",nBins,xLow,xMax);
  h_bg->Add(h_zjets);
  h_bg->Add(h_wjets);
  h_bg->Add(h_vvjets);
  h_bg->Add(h_ttbar);
  h_bg->Add(h_singtop);

  int nbinsx = h_bg->GetXaxis()->GetNbins(); 

  int ibin = 0;

  float chi2 = 0.0;
 
  float ndat = 0.0;
  float nbg = 0.0;

  float datmean = 0.0;
	float mcmean = 0.0;

 for (ibin=0;ibin<nbinsx;ibin++){

  ndat = 1.0*(h_data->GetBinContent(ibin));
  nbg = 1.0*(h_bg->GetBinContent(ibin));

  datmean += 1.0*(h_data->GetBinContent(ibin))*h_data->GetBinCenter(ibin);
  mcmean += 1.0*(h_bg->GetBinContent(ibin))*h_bg->GetBinCenter(ibin);

  if (ndat!=0)   chi2 += pow((ndat -nbg),2.0)/pow(ndat,0.5);

//   std::cout<<ndat<<"  "<<nbg<<"  "<<chi2<<std::endl;
    if (nbg>.0010) std::cout<<h_data->GetBinCenter(ibin)<<"   "<<nbg<<"  "<<"   "<<ndat/nbg<<"   "<<(ndat-nbg)/sqrt(ndat)<<std::endl;

}
	datmean = datmean/h_data->Integral();
	mcmean = mcmean/h_bg->Integral();
	std::cout<<datmean<<std::endl;
	std::cout<<mcmean<<std::endl;

  std::cout<<"Chi^2 for this distribution is:  "<< chi2<<std::endl;
  }

}
Example #19
0
void DrawQCDClosure(TString VAR,TString XTITLE)
{
  gROOT->ForceStyle();
  TString FileName[7] = {"QCD_HT200to300","QCD_HT300to500","QCD_HT500to700","QCD_HT700to1000","QCD_HT1000to1500","QCD_HT1500to2000","QCD_HT2000toInf"};
  float XSEC[7]       = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};
  TFile *inf[7];
  TH1F  *h[7],*h1[7];

  TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  can->SetRightMargin(0.15);

  for(int i=0;i<7;i++) {
    inf[i] = TFile::Open("Histo_"+FileName[i]+".root");
    TH1F *hTriggerPass = (TH1F*)inf[i]->Get("hadtopL/TriggerPass");
    h[i]   = (TH1F*)inf[i]->Get("hadtopL/h_"+VAR);
    h1[i]   = (TH1F*)inf[i]->Get("hadtop/h_"+VAR);
    h[i]->Sumw2();
    h1[i]->Sumw2();
    h[i]->Rebin(5);
    h1[i]->Rebin(5);
    h[i]->Scale(XSEC[i]/hTriggerPass->GetBinContent(1));
    h1[i]->Scale(XSEC[i]/hTriggerPass->GetBinContent(1));
    cout<<hTriggerPass->GetBinContent(1)<<endl;
  }

  TH1F *hQCD  = (TH1F*)h[0]->Clone("hQCD");
  TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
  for(int i=0;i<7;i++) {
    hQCD->Add(h[i]);
    hQCD1->Add(h1[i]);
  } 
  hQCD->SetFillColor(kGray);

  hQCD->Scale(1./hQCD->Integral());
  hQCD1->Scale(1./hQCD1->Integral());
  hQCD->GetXaxis()->SetLabelSize(0.0);
  double max = 1.1*TMath::Max(hQCD->GetBinContent(hQCD->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
  hQCD->SetMinimum(1e-5);
  hQCD->SetMaximum(max);
  hQCD->Draw("hist");
  hQCD1->Draw("sameE");
  gPad->RedrawAxis();

  TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->AddEntry(hQCD,"Control","F");
  leg->AddEntry(hQCD1,"Signal","LP");
  leg->Draw();

  TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio");
  hRatio->Divide(hQCD);

  TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
  pad->SetTopMargin(0.7);
  pad->SetRightMargin(0.15);
  pad->SetFillColor(0);
  pad->SetFillStyle(0);
  pad->Draw();
  pad->cd(0);
  gPad->SetGridy();
  hRatio->GetXaxis()->SetTitle(XTITLE);
  hRatio->GetYaxis()->SetNdivisions(505);
  hRatio->GetYaxis()->SetRangeUser(0,2);
  hRatio->GetYaxis()->SetLabelSize(0.04);
  hRatio->Draw();
}
Example #20
0
Resolutions() {

	float Ebeam[] = {2.0,3.0,4.0,6.0,8.0,12.0};
	float Ebeam_err[] = {0.,0.,0.,0.,0.,0.};
	float beam_spread[] = {.027,.027,0.023,0.023,0.023,0.023};
	//float beam_spread[] = {0.,0.,0.,0.,0.,0.};

	float Ebeam_no3[] = {2.0,4.0,6.0,8.0,12.0};
	float Ebeam_no3_err[] = {0.,0.,0.,0.,0.};
	float beam_no3_spread[] = {.027,.027,0.023,0.023,0.023};

	float ECal_mean[] = {270.5, 475.9, 586.8, 921.5, 1323., 3022.};
	float ECal_sigma[] = {24.69, 31.54, 35.64, 47.51, 55.71, 133.};

	float PbG_mean[] = {775.3, 1320., 1613., 2556., 3546., 1846.};
	float PbG_sigma[] = {49.63, 71.96, 81., 125.3, 137., 77.99};
	
	float OldPbG_mean[] = {601.5, 1105, 1622, 2074, 2901};
	float OldPbG_sigma[] = {25.07, 38.05, 49.33, 58.2, 77.18};
	float OldPbG_mean_err[] = {.8, .6, .8, .7, 1.1};
	float OldPbG_sigma_err[] = {.83, .53, .74, .6, .93};

	float ECal_res[6], ECal_res_err[6];
	float PbG_res[6], PbG_res_err[6];
	float OldPbG_res[6], OldPbG_res_err[6];
	for (int i=0; i<6; i++) {
		ECal_res[i] = sqrt(ECal_sigma[i]*ECal_sigma[i]/(ECal_mean[i]*ECal_mean[i]) - beam_spread[i]*beam_spread[i]);
		PbG_res[i] = sqrt(PbG_sigma[i]*PbG_sigma[i]/(PbG_mean[i]*PbG_mean[i]) - beam_spread[i]*beam_spread[i]);
		ECal_res_err[i] = 0.;
		PbG_res_err[i] = 0.;
	}
	for (int i=0; i<5; i++) {
		OldPbG_res[i] = sqrt(OldPbG_sigma[i]*OldPbG_sigma[i]/(OldPbG_mean[i]*OldPbG_mean[i]) - beam_no3_spread[i]*beam_no3_spread[i]);
		OldPbG_res_err[i] = 0.;
	}

	TGraphErrors *gECalRes = new TGraphErrors(6, Ebeam, ECal_res, Ebeam_err, ECal_res_err);
	TGraphErrors *gPbGRes = new TGraphErrors(6, Ebeam, PbG_res, Ebeam_err, PbG_res_err);
	TGraphErrors *gOldPbGRes = new TGraphErrors(5, Ebeam_no3, OldPbG_res, Ebeam_no3_err, OldPbG_res_err);
	TF1 *fResECal = new TF1("fResECal", "[1]/sqrt(x) + [0]", 2, 14);
	TF1 *fResPbG = new TF1("fResPbG", "[1]/sqrt(x) + [0]", 2, 14);
	TF1 *fResOldPbG = new TF1("fResOldPbG", "[1]/sqrt(x) + [0]", 2, 14);
	fResECal->SetLineStyle(2);
	fResECal->SetLineColor(kGreen+2);
	fResPbG->SetLineStyle(2);
	fResPbG->SetLineColor(kRed+1);
	fResOldPbG->SetLineStyle(2);
	fResOldPbG->SetLineColor(kMagenta+1);

	gECalRes->Fit(fResECal, "NR");
	gPbGRes->Fit(fResPbG, "NR");
	gOldPbGRes->Fit(fResOldPbG, "NR");

	gECalRes->SetMarkerStyle(20);
	gECalRes->SetMarkerSize(2.0);
	gECalRes->SetMarkerColor(kGreen+2);
	gECalRes->SetLineColor(kGreen+2);
	gPbGRes->SetMarkerStyle(21);
	gPbGRes->SetMarkerSize(2.0);
	gPbGRes->SetMarkerColor(kRed+1);
	gPbGRes->SetLineColor(kRed+1);
	gOldPbGRes->SetMarkerStyle(22);
	gOldPbGRes->SetMarkerSize(2.0);
	gOldPbGRes->SetMarkerColor(kMagenta+1);
	gOldPbGRes->SetLineColor(kMagenta+1);

	TLegend *lres = new TLegend(.45, .56, .93, .83);
	lres->AddEntry(fResECal, Form("ECAL: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResECal->GetParameter(1)*100.0, fResECal->GetParameter(0)*100.0), "L");
	lres->AddEntry(fResPbG, Form("2015 Lead Glass: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResPbG->GetParameter(1)*100.0, fResPbG->GetParameter(0)*100.0), "L");
	lres->AddEntry(fResOldPbG, Form("2014 Lead Glass: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResOldPbG->GetParameter(1)*100.0, fResOldPbG->GetParameter(0)*100.0), "L");
	lres->SetFillStyle(0);
	lres->SetTextSize(.035);
	lres->SetTextFont(42);

	TCanvas *cRes = new TCanvas("cRes", "Resolutions", 900, 700);
	cRes->cd();
	gECalRes->Draw("AP");
	gECalRes->GetXaxis()->SetTitle("Beam Energy (GeV)");
	gECalRes->GetYaxis()->SetTitle("Resolution");
	gPbGRes->Draw("Psame");
	gOldPbGRes->Draw("Psame");
	fResECal->Draw("same");
	fResPbG->Draw("same");
	fResOldPbG->Draw("same");
	gECalRes->GetYaxis()->SetRangeUser(0.0,0.11);
	lres->Draw("same");
	cRes->Update();

}
void makePlots_ttH_signal_strength( TString observedFileName = "", TString expectedFileName = "", TString prefix = "", double rMin=0, double rMax=6) {

  TFile* f_obs = new TFile( observedFileName );
  TFile* f_exp = new TFile( expectedFileName );

  TGraph* g_obs = (TGraph*)f_obs->Get("gr_r_tt_deltaNLL")->Clone("g_obs");
  TGraph* g_exp = (TGraph*)f_exp->Get("gr_r_tt_deltaNLL")->Clone("g_exp");

  g_obs->SetLineWidth(2.5); g_obs->SetLineStyle(1); 
  g_exp->SetLineWidth(2.5); g_exp->SetLineStyle(7); 

  g_obs->SetMarkerStyle(20);
  g_exp->SetMarkerStyle(20);


  double xMin = rMin, xMax = rMax-0.2;
  TH1D* hdummy = new TH1D("hdummy",";#mu_{t#bar{t}H};-2 #Delta ln L",100,xMin,xMax);



  // find minimum of obs
  int n_obs = g_obs->GetN();
  double minNLL_obs = 999;
  double best_obs = 999;
  for( int i=0; i<n_obs; i++ ){
    if( g_obs->GetY()[i]<minNLL_obs ){
      minNLL_obs = g_obs->GetY()[i];
      best_obs = g_obs->GetX()[i];
    }
  }

  // find minimum of exp
  int n_exp = g_exp->GetN();
  double minNLL_exp = 999;
  double best_exp = 999;
  for( int i=0; i<n_exp; i++ ){
    if( g_exp->GetY()[i]<minNLL_exp ){
      minNLL_exp = g_exp->GetY()[i];
      best_exp = g_exp->GetX()[i];
    }
  }



  // find 1 sig and 2 sig crossing
  double yThres_1sig = 1.;
  double yThres_2sig = 3.84;

  double obs_p1sig = -99;
  double obs_m1sig = -99;
  double obs_p2sig = -99;
  double obs_m2sig = -99;
  double last_y_obs = 0;
  double last_y_exp = 0;

  double exp_p1sig = -99;
  double exp_m1sig = -99;

    
  // fix obs
  for( int i=0; i<n_obs; i++ ){
    double newX = g_obs->GetX()[i];
    double newY = 2*(g_obs->GetY()[i] - minNLL_obs);
    g_obs->SetPoint(i,newX,newY);

    if( last_y_obs>yThres_1sig && newY<yThres_1sig ) obs_m1sig = newX;
    if( last_y_obs<yThres_1sig && newY>yThres_1sig ) obs_p1sig = newX;

    if( last_y_obs>yThres_2sig && newY<yThres_2sig ) obs_m2sig = newX;
    if( last_y_obs<yThres_2sig && newY>yThres_2sig ) obs_p2sig = newX;
    last_y_obs = newY;
  }

  // fix exp
  for( int i=0; i<n_exp; i++ ){
    double newX = g_exp->GetX()[i];
    double newY = 2*(g_exp->GetY()[i] - minNLL_exp);
    g_exp->SetPoint(i,newX,newY);

    if( last_y_exp>yThres_1sig && newY<yThres_1sig ) exp_m1sig = newX;
    if( last_y_exp<yThres_1sig && newY>yThres_1sig ) exp_p1sig = newX;
    last_y_exp = newY;
  }


  printf("\t Observed: best-fit mu = %.2f  +%.2f -%.2f \n", best_obs, obs_p1sig-best_obs, best_obs-obs_m1sig );
  printf("\t Expected: best-fit mu = %.2f  +%.2f -%.2f \n", best_exp, exp_p1sig-best_exp, best_exp-exp_m1sig );



  //std::string cmsinfo =    "CMS Preliminary, ttH, b#bar{b}, #tau#tau, #gamma#gamma, WW, ZZ  #sqrt{s} = 8 TeV, L = 19.7 fb^{-1} #sqrt{s} = 7 TeV, L = 19.7 fb^{-1}";
  TString cmsinfo =   "CMS                            #sqrt{s} = 8 TeV, L = 19.7 fb^{-1};  #sqrt{s} = 7 TeV, L = 5.0 fb^{-1}";
  //TString cmsinfo = "CMS Preliminary,    #sqrt{s} = 8 TeV, L = 19.7 fb^{-1};  #sqrt{s} = 7 TeV, L = 5.0 fb^{-1}";
  TLatex CMSInfoLatex(0.14, 0.92, cmsinfo);
  CMSInfoLatex.SetNDC(); CMSInfoLatex.SetTextFont(42);
  CMSInfoLatex.SetTextSize(0.03);

  TLegend *legend_fake = new TLegend(0.17,0.64,0.55,0.897);
  legend_fake->SetFillColor(kWhite);
  legend_fake->SetLineColor(kWhite);
  legend_fake->SetShadowColor(kWhite);

  //TString decayinfo = "t#bar{t}H, H #rightarrow b#bar{b},#tau#tau,#gamma#gamma,WW,ZZ";
  TString decayinfo = "t#bar{t}H, H #rightarrow b#bar{b}, #tau#tau, #gamma#gamma, WW, ZZ";
  TLatex DECAYInfoLatex(0.18, 0.84, decayinfo);
  DECAYInfoLatex.SetNDC(); DECAYInfoLatex.SetTextFont(42);
  DECAYInfoLatex.SetTextSize(0.04);
  TString massinfo = "m_{H} = 125.6 GeV/c^{2}";
  TLatex MASSInfoLatex(0.18, 0.76, massinfo);
  MASSInfoLatex.SetNDC(); MASSInfoLatex.SetTextFont(42);
  MASSInfoLatex.SetTextSize(0.04);
  TString resultinfo = Form("#mu_{t#bar{t}H} = %.2f ^{+%.2f}_{ -%.2f}",best_obs,obs_p1sig-best_obs,best_obs-obs_m1sig);
  TLatex RESULTInfoLatex(0.18, 0.68, resultinfo);
  RESULTInfoLatex.SetNDC(); RESULTInfoLatex.SetTextFont(42);
  RESULTInfoLatex.SetTextSize(0.04);



  //TLegend *legend = new TLegend(0.15,0.8,0.89,0.89);
  TLegend *legend = new TLegend(0.65,0.7,0.89,0.89);

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

  legend->AddEntry(g_obs,"Observed","l");
  legend->AddEntry(g_exp,"Expected","l");


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

  c1->SetLeftMargin(.12);
  c1->SetBottomMargin(.12);
  c1->SetRightMargin(.05);

  hdummy->SetStats(0);
  hdummy->GetYaxis()->SetTitleSize(0.05);
  hdummy->GetXaxis()->SetTitleSize(0.05);


  TLine* line_obs_1sig = new TLine(xMin,yThres_1sig,xMax,yThres_1sig);
  line_obs_1sig->SetLineStyle(7);
  line_obs_1sig->SetLineColor(kRed);

  TLine* line_obs_m1sig = new TLine(obs_m1sig,0,obs_m1sig,yThres_1sig);
  line_obs_m1sig->SetLineStyle(1);
  line_obs_m1sig->SetLineColor(kRed);

  TLine* line_obs_p1sig = new TLine(obs_p1sig,0,obs_p1sig,yThres_1sig);
  line_obs_p1sig->SetLineStyle(1);
  line_obs_p1sig->SetLineColor(kRed);



  TLine* line_obs_2sig = new TLine(xMin,yThres_2sig,xMax,yThres_2sig);
  line_obs_2sig->SetLineStyle(7);
  line_obs_2sig->SetLineColor(kRed);

  TLine* line_obs_m2sig = new TLine(obs_m2sig,0,obs_m2sig,yThres_2sig);
  line_obs_m2sig->SetLineStyle(1);
  line_obs_m2sig->SetLineColor(kRed);

  TLine* line_obs_p2sig = new TLine(obs_p2sig,0,obs_p2sig,yThres_2sig);
  line_obs_p2sig->SetLineStyle(1);
  line_obs_p2sig->SetLineColor(kRed);


  hdummy->GetYaxis()->SetRangeUser(0.,8.5);

  hdummy->Draw("axis");
  g_obs->Draw("Lsame");
  g_exp->Draw("Lsame");

  line_obs_1sig->Draw();
  line_obs_m1sig->Draw();
  line_obs_p1sig->Draw();

  line_obs_2sig->Draw();
  line_obs_m2sig->Draw();
  line_obs_p2sig->Draw();

  legend->Draw();
  legend_fake->Draw();
  CMSInfoLatex.Draw();
  DECAYInfoLatex.Draw();
  MASSInfoLatex.Draw();
  RESULTInfoLatex.Draw();

  //c1->RedrawAxis();

  c1->Print("ttH_signal_strength_scan_"+prefix+".png");
  c1->Print("ttH_signal_strength_scan_"+prefix+".pdf");



  f_obs->Close();
  f_exp->Close();
  std::cout << " Done!" << std::endl;

}
Example #22
0
void diffXsecZbb( TString inputFile1Name,
		  TString inputFile2Name,
		  TString inputFile3Name,
		  TString eventsNumberHistoName,
		  TString HistoName) {
  // general root setting
  gROOT->Reset(); 
  //  gROOT->SetBatch(kTRUE);
  gStyle->SetOptStat(0);
  gStyle->SetTitleSize(0.1);
  gStyle->SetLabelSize(0.04,"X");
  gStyle->SetLabelSize(0.04,"Y");
  gStyle->SetPadBorderMode(0);
  gStyle->SetPadColor(0);
  gStyle->SetCanvasBorderMode(0);
  gStyle->SetCanvasColor(0);

  const double xSec_Zbb0jets_  = 1.66; // in pb	  
  const double xSec_Zbb1jets_  = 0.29; // in pb	  
  const double xSec_Zbb2jets_  = 0.05; // in pb	  
  const double xSec_Zbb3jets_  = 0.01; // in pb	  

  const double leptonFactor = 2.0;

  const double luminosityFactor = 100000.; // 100fb^-1 of luminosity assumed in histograms

  TFile * inputFile1 = new TFile(inputFile1Name);
  TFile * inputFile2 = new TFile(inputFile2Name);
  TFile * inputFile3 = new TFile(inputFile3Name);
 
  TH1D * eventsNumberHisto1 = dynamic_cast<TH1D*>(inputFile1->Get(eventsNumberHistoName));
  TH1D * histo1 = dynamic_cast<TH1D*>(inputFile1->Get(HistoName));
  TH1D * histoirrBkg1 = dynamic_cast<TH1D*>(inputFile1->Get(HistoName+"irrBkg"));
  TH1D * eventsNumberHisto2 = dynamic_cast<TH1D*>(inputFile2->Get(eventsNumberHistoName));
  TH1D * histo2 = dynamic_cast<TH1D*>(inputFile2->Get(HistoName));
  TH1D * histoirrBkg2 = dynamic_cast<TH1D*>(inputFile2->Get(HistoName+"irrBkg"));
  TH1D * eventsNumberHisto3 = dynamic_cast<TH1D*>(inputFile3->Get(eventsNumberHistoName));
  TH1D * histo3 = dynamic_cast<TH1D*>(inputFile3->Get(HistoName));
  TH1D * histoirrBkg3 = dynamic_cast<TH1D*>(inputFile3->Get(HistoName+"irrBkg"));

  TString HistoTitle = histo1->GetTitle();
  int nbin = histo1->GetNbinsX();
  double xmin = histo1->GetXaxis()->GetXmin();
  double xmax = histo1->GetXaxis()->GetXmax();
  TH1D * histoTot       = new TH1D(HistoName+"TOT",      "inclusive "+HistoTitle,nbin,xmin,xmax);
  TH1D * histoirrBkgTot = new TH1D(HistoName+"irrBkgTOT","inclusive irrudicible background "+HistoTitle,nbin,xmin,xmax);

  histo1->SetTitle(HistoTitle+ " for Zbb 0 jets");
  histo2->SetTitle(HistoTitle+ " for Zbb 1 jets");
  histo3->SetTitle(HistoTitle+ " for Zbb 2 jets");
  histoirrBkg1->SetTitle("irriducible background "+HistoTitle+ " for Zbb 0 jets");
  histoirrBkg2->SetTitle("irriducible background "+HistoTitle+ " for Zbb 1 jets");
  histoirrBkg3->SetTitle("irriducible background "+HistoTitle+ " for Zbb 2 jets");

  double histo1Entries = histo1->GetEntries();
  double histo2Entries = histo2->GetEntries();
  double histo3Entries = histo3->GetEntries();
  double histoirrBkg1Entries = histoirrBkg1->GetEntries();
  double histoirrBkg2Entries = histoirrBkg2->GetEntries();
  double histoirrBkg3Entries = histoirrBkg3->GetEntries();
  double events1 = (double)eventsNumberHisto1->GetMaximum(); 
  double events2 = (double)eventsNumberHisto2->GetMaximum();
  double events3 = (double)eventsNumberHisto3->GetMaximum();
  double xSecEff1  = leptonFactor*xSec_Zbb0jets_;
  double xSecEff2  = leptonFactor*xSec_Zbb1jets_;
  double xSecEff3  = leptonFactor*xSec_Zbb2jets_;
  double invLuminosityEff1 = xSecEff1/events1;
  double invLuminosityEff2 = xSecEff2/events2;
  double invLuminosityEff3 = xSecEff3/events3;


  TLegend * legend1 = new TLegend(0.5,0.6,0.89,0.8);
  legend1->SetFillColor(0);
  legend1->SetBorderSize(0);  
  legend1->SetTextFont(72);
  legend1->SetTextSize(0.035);
  legend1->SetFillColor(0);
  TLegend * legend2 = new TLegend(0.5,0.6,0.89,0.8);
  legend2->SetFillColor(0);
  legend2->SetBorderSize(0);  
  legend2->SetTextFont(72);
  legend2->SetTextSize(0.035);
  legend2->SetFillColor(0);
  TLegend * legend3 = new TLegend(0.5,0.6,0.89,0.8);
  legend3->SetFillColor(0);
  legend3->SetBorderSize(0);  
  legend3->SetTextFont(72);
  legend3->SetTextSize(0.035);
  legend3->SetFillColor(0);
  TLegend * legendTot = new TLegend(0.7,0.65,0.89,0.85);
  legendTot->SetFillColor(0);
  legendTot->SetBorderSize(0);  
  legendTot->SetTextFont(72);
  legendTot->SetTextSize(0.035);
  legendTot->SetFillColor(0);
  char nev[50];

  TCanvas * canvas = new TCanvas ( "diffxSec", "differential xSec", 1200, 400 );
  gStyle->SetOptStat(0);
  //  canvas->UseCurrentStyle();
  canvas->Divide(3,1);
  canvas->cd(1);
  histo1->SetNormFactor(histo1Entries*invLuminosityEff1*luminosityFactor);
  histo1->Draw();
  sprintf(nev,"number of events in 100 fb^{-1}:");
  sprintf(nev,"%.2f",histo1Entries*invLuminosityEff1*luminosityFactor);
  legend1->AddEntry(histo1,nev,"");
  legend1->Draw();
  canvas->cd(2);
  histo2->SetNormFactor(histo2Entries*invLuminosityEff2*luminosityFactor);
  histo2->Draw();
  legend2->Clear();
  sprintf(nev,"number of events in 100 fb^{-1}:");
  sprintf(nev,"%.2f",histo2Entries*invLuminosityEff2*luminosityFactor);
  legend2->AddEntry(histo2,nev,"");
  legend2->Draw();
  canvas->cd(3);
  histo3->SetNormFactor(histo3Entries*invLuminosityEff3*luminosityFactor);
  histo3->Draw();
  legend3->Clear();
  sprintf(nev,"number of events in 100 fb^{-1}:");
  sprintf(nev,"%.2f",histo3Entries*invLuminosityEff3*luminosityFactor);
  legend3->AddEntry(histo3,nev,"");
  legend3->Draw();

  histoTot->Sumw2();
  histoTot->Add(histo1);
  histoTot->Add(histo2);
  histoTot->Add(histo3);

  TCanvas * canvasTot = new TCanvas ( "inclusivediffxSec", "differential xSec", 1200, 400 );
  gStyle->SetOptStat(0);
  canvasTot->UseCurrentStyle();
  canvasTot->cd();
  histo1->SetTitle("4-body mass (100 fb^{-1})");
  histo1->GetXaxis()->SetTitle("m_{llbb} (GeV)");
  histo1->GetYaxis()->SetTitle("d#sigma/dm_{llbb} events/10GeV");
  histo1->SetMinimum(0.001);
  histo1->SetLineColor(51);
  histo1->Draw();
  histo2->SetLineColor(56);
  histo2->Draw("same");
  histo3->SetLineColor(60);
  histo3->Draw("same");
  histoTot->Draw("same");

  legendTot->Clear();
  sprintf(nev,"Zb\\bar{b}+0jets");
  legendTot->AddEntry(histo1,nev,"l");
  sprintf(nev,"Zb\\bar{b}+1jets");
  legendTot->AddEntry(histo2,nev,"l");
  sprintf(nev,"Zb\\bar{b}+2jets");
  legendTot->AddEntry(histo3,nev,"l");
  sprintf(nev,"inclusive");
  legendTot->AddEntry(histoTot,nev,"l");
  legendTot->Draw();



  TCanvas * canvasirrBkg = new TCanvas ( "diffxSecirrbkg", "differential xSec for irriducible background", 1200, 400 );
  gStyle->SetOptStat(0);
  canvasirrBkg->UseCurrentStyle();
  canvasirrBkg->Divide(3,1);
  canvasirrBkg->cd(1);
  histoirrBkg1->SetNormFactor(histoirrBkg1Entries*invLuminosityEff1*luminosityFactor);
  histoirrBkg1->Draw();
  sprintf(nev,"number of events in 100 fb^{-1}:");
  sprintf(nev,"%.2f",histoirrBkg1Entries*invLuminosityEff1*luminosityFactor);
  legend1->AddEntry(histoirrBkg1,nev,"");
  legend1->Draw();
  canvasirrBkg->cd(2);
  histoirrBkg2->SetNormFactor(histoirrBkg2Entries*invLuminosityEff2*luminosityFactor);
  histoirrBkg2->Draw();
  legend2->Clear();
  sprintf(nev,"number of events in 100 fb^{-1}:");
  sprintf(nev,"%.2f",histoirrBkg2Entries*invLuminosityEff2*luminosityFactor);
  legend2->AddEntry(histoirrBkg2,nev,"");
  legend2->Draw();
  canvasirrBkg->cd(3);
  histoirrBkg3->SetNormFactor(histoirrBkg3Entries*invLuminosityEff3*luminosityFactor);
  histoirrBkg3->Draw();
  legend3->Clear();
  sprintf(nev,"number of events in 100 fb^{-1}:");
  sprintf(nev,"%.2f",histoirrBkg3Entries*invLuminosityEff3*luminosityFactor);
  legend3->AddEntry(histoirrBkg3,nev,"");
  legend3->Draw();

  histoirrBkgTot->Sumw2();
  histoirrBkgTot->Add(histoirrBkg1);
  histoirrBkgTot->Add(histoirrBkg2);
  histoirrBkgTot->Add(histoirrBkg3);

  TCanvas * canvasirrBkgTot = new TCanvas ( "inclusivediffxSecirrBkg", "differential xSec", 1200, 400 );
  gStyle->SetOptStat(0);
  canvasirrBkgTot->UseCurrentStyle();
  canvasirrBkgTot->cd();
  gPad->SetLogy();
  histoirrBkg1->SetTitle("4-body mass (100 fb^{-1})");
  histoirrBkg1->GetXaxis()->SetTitle("m_{llbb} (GeV)");
  histoirrBkg1->GetYaxis()->SetTitle("d#sigma/dm_{llbb} events/10GeV");
  histoirrBkg1->SetMinimum(0.001);
  histoirrBkg1->SetLineColor(51);
  histoirrBkg1->Draw();
  histoirrBkg2->SetLineColor(56);
  histoirrBkg2->Draw("same");
  histoirrBkg3->SetLineColor(60);
  histoirrBkg3->Draw("same");
  histoirrBkgTot->Draw("same");

  legendTot->Clear();
  sprintf(nev,"Zb\\bar{b}+0jets");
  legendTot->AddEntry(histoirrBkg1,nev,"l");
  sprintf(nev,"Zb\\bar{b}+1jets");
  legendTot->AddEntry(histoirrBkg2,nev,"l");
  sprintf(nev,"Zb\\bar{b}+2jets");
  legendTot->AddEntry(histoirrBkg3,nev,"l");
  sprintf(nev,"inclusive");
  legendTot->AddEntry(histoirrBkgTot,nev,"l");
  legendTot->Draw();

  canvas->Print("Zbb.jpg");
  canvasTot->Print("Zbbtot.jpg");
  canvasirrBkg->Print("ZbbIrr.jpg");
  canvasirrBkgTot->Print("ZbbIrrtot.jpg");

  TFile * outputFile = new TFile("diffXsecZbb.root","RECREATE");

  histo1->Write();
  histo2->Write();
  histo3->Write();
  histoTot->Write();
  histoirrBkg1->Write();
  histoirrBkg2->Write();
  histoirrBkg3->Write();
  histoirrBkgTot->Write();

  outputFile->Close();

}
Example #23
0
void test3()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//=========  (Fri May  6 10:50:13 2016) by ROOT version6.04/10
   TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,700,500);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   default_Canvas->SetHighLightColor(2);
   default_Canvas->Range(0,0,1,1);
   default_Canvas->SetFillColor(0);
   default_Canvas->SetBorderMode(0);
   default_Canvas->SetBorderSize(2);
   default_Canvas->SetTickx(1);
   default_Canvas->SetTicky(1);
   default_Canvas->SetLeftMargin(0.14);
   default_Canvas->SetRightMargin(0.05);
   default_Canvas->SetTopMargin(0.05);
   default_Canvas->SetBottomMargin(0.16);
   default_Canvas->SetFrameLineWidth(2);
   default_Canvas->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: upperPad
   TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
   upperPad->Draw();
   upperPad->cd();
   upperPad->Range(1.567901,0.02811051,4.654321,0.1367104);
   upperPad->SetFillColor(0);
   upperPad->SetFillStyle(4000);
   upperPad->SetBorderMode(0);
   upperPad->SetBorderSize(2);
   upperPad->SetTickx(1);
   upperPad->SetTicky(1);
   upperPad->SetLeftMargin(0.14);
   upperPad->SetRightMargin(0.05);
   upperPad->SetTopMargin(0.05);
   upperPad->SetBottomMargin(0.14);
   upperPad->SetFrameLineWidth(2);
   upperPad->SetFrameBorderMode(0);
   upperPad->SetFrameLineWidth(2);
   upperPad->SetFrameBorderMode(0);
   
   TH1F *test3_red_0_0_norm__1 = new TH1F("test3_red_0_0_norm__1","ETA",10,2,4.5);
   test3_red_0_0_norm__1->SetBinContent(1,0.1040398);
   test3_red_0_0_norm__1->SetBinContent(2,0.1186439);
   test3_red_0_0_norm__1->SetBinContent(3,0.1256071);
   test3_red_0_0_norm__1->SetBinContent(4,0.1229555);
   test3_red_0_0_norm__1->SetBinContent(5,0.118442);
   test3_red_0_0_norm__1->SetBinContent(6,0.1127067);
   test3_red_0_0_norm__1->SetBinContent(7,0.09951538);
   test3_red_0_0_norm__1->SetBinContent(8,0.08332527);
   test3_red_0_0_norm__1->SetBinContent(9,0.06651872);
   test3_red_0_0_norm__1->SetBinContent(10,0.0482457);
   test3_red_0_0_norm__1->SetBinError(1,0.001708584);
   test3_red_0_0_norm__1->SetBinError(2,0.001736969);
   test3_red_0_0_norm__1->SetBinError(3,0.001484444);
   test3_red_0_0_norm__1->SetBinError(4,0.001426268);
   test3_red_0_0_norm__1->SetBinError(5,0.001336676);
   test3_red_0_0_norm__1->SetBinError(6,0.00122978);
   test3_red_0_0_norm__1->SetBinError(7,0.00125216);
   test3_red_0_0_norm__1->SetBinError(8,0.00113555);
   test3_red_0_0_norm__1->SetBinError(9,0.0009819959);
   test3_red_0_0_norm__1->SetBinError(10,0.0009418311);
   test3_red_0_0_norm__1->SetEntries(58129);
   test3_red_0_0_norm__1->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm__1->SetFillColor(ci);
   test3_red_0_0_norm__1->SetFillStyle(0);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm__1->SetLineColor(ci);
   test3_red_0_0_norm__1->SetLineWidth(2);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm__1->SetMarkerColor(ci);
   test3_red_0_0_norm__1->SetMarkerStyle(20);
   test3_red_0_0_norm__1->GetXaxis()->SetTitle("#eta");
   test3_red_0_0_norm__1->GetXaxis()->SetNdivisions(1005);
   test3_red_0_0_norm__1->GetXaxis()->SetLabelFont(132);
   test3_red_0_0_norm__1->GetXaxis()->SetLabelOffset(0.02);
   test3_red_0_0_norm__1->GetXaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm__1->GetXaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm__1->GetXaxis()->SetTitleFont(132);
   test3_red_0_0_norm__1->GetYaxis()->SetNdivisions(505);
   test3_red_0_0_norm__1->GetYaxis()->SetLabelFont(132);
   test3_red_0_0_norm__1->GetYaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm__1->GetYaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm__1->GetYaxis()->SetTitleFont(132);
   test3_red_0_0_norm__1->GetZaxis()->SetLabelFont(132);
   test3_red_0_0_norm__1->GetZaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm__1->GetZaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm__1->GetZaxis()->SetTitleFont(132);
   test3_red_0_0_norm__1->Draw("");
   Double_t xAxis1[11] = {2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.25, 4.5}; 
   
   TH1F *test3_green_0_1_norm__2 = new TH1F("test3_green_0_1_norm__2","ETA",10, xAxis1);
   test3_green_0_1_norm__2->SetBinContent(1,0.1214835);
   test3_green_0_1_norm__2->SetBinContent(2,0.1235428);
   test3_green_0_1_norm__2->SetBinContent(3,0.1252758);
   test3_green_0_1_norm__2->SetBinContent(4,0.1207572);
   test3_green_0_1_norm__2->SetBinContent(5,0.1150848);
   test3_green_0_1_norm__2->SetBinContent(6,0.1056844);
   test3_green_0_1_norm__2->SetBinContent(7,0.09450962);
   test3_green_0_1_norm__2->SetBinContent(8,0.07910584);
   test3_green_0_1_norm__2->SetBinContent(9,0.06467657);
   test3_green_0_1_norm__2->SetBinContent(10,0.04987957);
   test3_green_0_1_norm__2->SetEntries(10);
   test3_green_0_1_norm__2->SetStats(0);

   ci = TColor::GetColor("#00ff00");
   test3_green_0_1_norm__2->SetFillColor(ci);
   test3_green_0_1_norm__2->SetFillStyle(0);

   ci = TColor::GetColor("#00ff00");
   test3_green_0_1_norm__2->SetLineColor(ci);
   test3_green_0_1_norm__2->SetLineWidth(2);

   ci = TColor::GetColor("#00ff00");
   test3_green_0_1_norm__2->SetMarkerColor(ci);
   test3_green_0_1_norm__2->SetMarkerStyle(20);
   test3_green_0_1_norm__2->GetXaxis()->SetTitle("#eta");
   test3_green_0_1_norm__2->GetXaxis()->SetNdivisions(1005);
   test3_green_0_1_norm__2->GetXaxis()->SetLabelFont(132);
   test3_green_0_1_norm__2->GetXaxis()->SetLabelOffset(0.02);
   test3_green_0_1_norm__2->GetXaxis()->SetLabelSize(0.05);
   test3_green_0_1_norm__2->GetXaxis()->SetTitleSize(0.06);
   test3_green_0_1_norm__2->GetXaxis()->SetTitleFont(132);
   test3_green_0_1_norm__2->GetYaxis()->SetNdivisions(505);
   test3_green_0_1_norm__2->GetYaxis()->SetLabelFont(132);
   test3_green_0_1_norm__2->GetYaxis()->SetLabelSize(0.05);
   test3_green_0_1_norm__2->GetYaxis()->SetTitleSize(0.06);
   test3_green_0_1_norm__2->GetYaxis()->SetTitleFont(132);
   test3_green_0_1_norm__2->GetZaxis()->SetLabelFont(132);
   test3_green_0_1_norm__2->GetZaxis()->SetLabelSize(0.05);
   test3_green_0_1_norm__2->GetZaxis()->SetTitleSize(0.06);
   test3_green_0_1_norm__2->GetZaxis()->SetTitleFont(132);
   test3_green_0_1_norm__2->Draw("same");
   
   TLegend *leg = new TLegend(0.2,0.7,0.4,0.85,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(132);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(2);
   leg->SetFillColor(10);
   leg->SetFillStyle(0);
   TLegendEntry *entry=leg->AddEntry("MuonTrackingMC2015RW_Sim09/ETA_tot","T&P","lep");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);

   ci = TColor::GetColor("#ff0000");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("MuonUbsTrackingMC2015/ETA_tot","Truth","lep");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);

   ci = TColor::GetColor("#00ff00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   leg->Draw();
   
   TH1F *test3_red_0_0_norm_copy__3 = new TH1F("test3_red_0_0_norm_copy__3","ETA",10,2,4.5);
   test3_red_0_0_norm_copy__3->SetBinContent(1,0.1040398);
   test3_red_0_0_norm_copy__3->SetBinContent(2,0.1186439);
   test3_red_0_0_norm_copy__3->SetBinContent(3,0.1256071);
   test3_red_0_0_norm_copy__3->SetBinContent(4,0.1229555);
   test3_red_0_0_norm_copy__3->SetBinContent(5,0.118442);
   test3_red_0_0_norm_copy__3->SetBinContent(6,0.1127067);
   test3_red_0_0_norm_copy__3->SetBinContent(7,0.09951538);
   test3_red_0_0_norm_copy__3->SetBinContent(8,0.08332527);
   test3_red_0_0_norm_copy__3->SetBinContent(9,0.06651872);
   test3_red_0_0_norm_copy__3->SetBinContent(10,0.0482457);
   test3_red_0_0_norm_copy__3->SetBinError(1,0.001708584);
   test3_red_0_0_norm_copy__3->SetBinError(2,0.001736969);
   test3_red_0_0_norm_copy__3->SetBinError(3,0.001484444);
   test3_red_0_0_norm_copy__3->SetBinError(4,0.001426268);
   test3_red_0_0_norm_copy__3->SetBinError(5,0.001336676);
   test3_red_0_0_norm_copy__3->SetBinError(6,0.00122978);
   test3_red_0_0_norm_copy__3->SetBinError(7,0.00125216);
   test3_red_0_0_norm_copy__3->SetBinError(8,0.00113555);
   test3_red_0_0_norm_copy__3->SetBinError(9,0.0009819959);
   test3_red_0_0_norm_copy__3->SetBinError(10,0.0009418311);
   test3_red_0_0_norm_copy__3->SetEntries(58129);
   test3_red_0_0_norm_copy__3->SetDirectory(0);
   test3_red_0_0_norm_copy__3->SetStats(0);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm_copy__3->SetFillColor(ci);
   test3_red_0_0_norm_copy__3->SetFillStyle(0);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm_copy__3->SetLineColor(ci);
   test3_red_0_0_norm_copy__3->SetLineWidth(2);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm_copy__3->SetMarkerColor(ci);
   test3_red_0_0_norm_copy__3->SetMarkerStyle(20);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetTitle("#eta");
   test3_red_0_0_norm_copy__3->GetXaxis()->SetNdivisions(1005);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetLabelFont(132);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetLabelOffset(0.02);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetTitleFont(132);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetNdivisions(505);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetLabelFont(132);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetTitleFont(132);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetLabelFont(132);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetTitleFont(132);
   test3_red_0_0_norm_copy__3->Draw("sameaxis");
   upperPad->Modified();
   default_Canvas->cd();
   default_Canvas->Modified();
   default_Canvas->cd();
   default_Canvas->SetSelected(default_Canvas);
}
void plotVBFVHReweighted(){
  gROOT->ProcessLine(".x tdrstyle.cc");
  gStyle->SetOptStat(0);

  TString INPUT_NAME = "HtoZZ4l_Phantom_125p6_VHDistributions_GenLevel.root";
  TString OUTPUT_NAME = "HtoZZ4l_Phantom_125p6_VHReweightingPlots_GenLevel.root";

  double mPOLE = 125.6;
  float ZZMass_PeakCut[2] ={ 125.1, 126.1 }; // Spin 0 analysis

  float templateWeight = 1;
  float GenDiJetMass;
  float MC_weight;
  float ZZMass = 0;

  TString coutput_common = user_TemplateswithTrees_dir + "../VHContributions/Plots/GenLevel/";
  gSystem->Exec("mkdir -p " + coutput_common);
  TString coutput = coutput_common + OUTPUT_NAME;
  TFile* foutput = new TFile(coutput, "recreate");

  const int kNumTemplates = 3;
  TString templatetitles[kNumTemplates] ={ "VBF Sig", "VBF Bkg", "VBF Int" };
  TString templatenames[kNumTemplates] ={ "VBF_Sig", "VBF_Bkg", "VBF_Int" };
  TH1F* hVBF_onshell_LC[kNumTemplates] ={ 0 };
  TH1F* hVBF_offshell_LC[kNumTemplates] ={ 0 };
  TH1F* hVBF_onshell_scaled[kNumTemplates] ={ 0 };
  TH1F* hVBF_offshell_scaled[kNumTemplates] ={ 0 };
  TH1F* hVBF_onshell_scaled_wVBF[kNumTemplates] ={ 0 };
  TH1F* hVBF_offshell_scaled_wVBF[kNumTemplates] ={ 0 };

  for (int erg_tev=7; erg_tev<=8; erg_tev++){
    for (int folder=0; folder<3; folder++){
      TString comstring;
      comstring.Form("%i", erg_tev);
      TString erg_dir;
      erg_dir.Form("LHC_%iTeV/", erg_tev);
      int EnergyIndex = 1;
      if (erg_tev == 7) EnergyIndex = 0;
      TString cinput_common = user_TemplateswithTrees_dir + "../VHContributions/" + erg_dir;
      cinput_common += user_folder[folder] + "/";
      TString cinput = cinput_common + INPUT_NAME;
      TFile* finput = new TFile(cinput, "read");
      if (finput->IsZombie()){
        delete finput;
        continue;
      }
      else if (finput==0) continue;

      cout << "Opened file " << finput->GetName() << endl;
      for (int tr=0; tr<kNumTemplates; tr++){
        TString templatename = "VBF_";
        templatename += templatenames[tr];

        TH1F* hVBF_onshell_LC_temp = (TH1F*)finput->Get(Form("%s_onshell_LC", templatename.Data()));
        TH1F* hVBF_offshell_LC_temp = (TH1F*)finput->Get(Form("%s_offshell_LC", templatename.Data()));
        TH1F* hVBF_onshell_scaled_temp = (TH1F*)finput->Get(Form("%s_onshell_scaled", templatename.Data()));
        TH1F* hVBF_offshell_scaled_temp = (TH1F*)finput->Get(Form("%s_offshell_scaled", templatename.Data()));
        TH1F* hVBF_onshell_scaled_wVBF_temp = (TH1F*)finput->Get(Form("%s_onshell_scaled_wVBF", templatename.Data()));
        TH1F* hVBF_offshell_scaled_wVBF_temp = (TH1F*)finput->Get(Form("%s_offshell_scaled_wVBF", templatename.Data()));

        foutput->cd();
        gStyle->SetOptStat(0);
        if (hVBF_onshell_LC[tr]==0) hVBF_onshell_LC[tr] = (TH1F*)hVBF_onshell_LC_temp->Clone(Form("%s_clone", hVBF_onshell_LC_temp->GetName()));
        else hVBF_onshell_LC[tr]->Add(hVBF_onshell_LC_temp);
        delete hVBF_onshell_LC_temp;

        if (hVBF_onshell_scaled[tr]==0) hVBF_onshell_scaled[tr] = (TH1F*)hVBF_onshell_scaled_temp->Clone(Form("%s_clone", hVBF_onshell_scaled_temp->GetName()));
        else hVBF_onshell_scaled[tr]->Add(hVBF_onshell_scaled_temp);
        delete hVBF_onshell_scaled_temp;

        if (hVBF_onshell_scaled_wVBF[tr]==0) hVBF_onshell_scaled_wVBF[tr] = (TH1F*)hVBF_onshell_scaled_wVBF_temp->Clone(Form("%s_clone", hVBF_onshell_scaled_wVBF_temp->GetName()));
        else hVBF_onshell_scaled_wVBF[tr]->Add(hVBF_onshell_scaled_wVBF_temp);
        delete hVBF_onshell_scaled_wVBF_temp;

        if (hVBF_offshell_LC[tr]==0) hVBF_offshell_LC[tr] = (TH1F*)hVBF_offshell_LC_temp->Clone(Form("%s_clone", hVBF_offshell_LC_temp->GetName()));
        else hVBF_offshell_LC[tr]->Add(hVBF_offshell_LC_temp);
        delete hVBF_offshell_LC_temp;

        if (hVBF_offshell_scaled[tr]==0) hVBF_offshell_scaled[tr] = (TH1F*)hVBF_offshell_scaled_temp->Clone(Form("%s_clone", hVBF_offshell_scaled_temp->GetName()));
        else hVBF_offshell_scaled[tr]->Add(hVBF_offshell_scaled_temp);
        delete hVBF_offshell_scaled_temp;

        if (hVBF_offshell_scaled_wVBF[tr]==0) hVBF_offshell_scaled_wVBF[tr] = (TH1F*)hVBF_offshell_scaled_wVBF_temp->Clone(Form("%s_clone", hVBF_offshell_scaled_wVBF_temp->GetName()));
        else hVBF_offshell_scaled_wVBF[tr]->Add(hVBF_offshell_scaled_wVBF_temp);
        delete hVBF_offshell_scaled_wVBF_temp;
      }
      finput->Close();
    }
  }

  TH1F* hVBF_sig[2][3]={
    { hVBF_onshell_LC[0], hVBF_onshell_scaled[0], hVBF_onshell_scaled_wVBF[0] },
    { hVBF_offshell_LC[0], hVBF_offshell_scaled[0], hVBF_offshell_scaled_wVBF[0] }
  };
  TH1F* hVBF_bkg[2][3]={
    { hVBF_onshell_LC[1], hVBF_onshell_scaled[1], hVBF_onshell_scaled_wVBF[1] },
    { hVBF_offshell_LC[1], hVBF_offshell_scaled[1], hVBF_offshell_scaled_wVBF[1] }
  };
  TH1F* hVBF_int[2][3]={
    { hVBF_onshell_LC[2], hVBF_onshell_scaled[2], hVBF_onshell_scaled_wVBF[2] },
    { hVBF_offshell_LC[2], hVBF_offshell_scaled[2], hVBF_offshell_scaled_wVBF[2] }
  };
  double max_plot[2][3] ={ { 0 } };
  double min_plot[2][3] ={ { 0 } };
//  TString strmzztitle[2]={ "105.6<m_{4l}<140.6 GeV", "220<m_{4l}<1600 GeV" };
  TString strmzztitle[2]={ "On-shell", "Off-shell" };
  TString strmzzname[2]={ "Onshell", "Offshell" };
  TString strBSItitle[3]={ "Signal", "Background", "Interference" };
  TString strBSIname[3]={ "Signal", "Background", "Interference" };
  TString strScaleSchemeTitle[3]={ " (Default Phantom)", " (VH Rescaling)", " (+VBF Rescaling)" };
  cout << "Set up canvas gadgets" << endl;
  for (int os=0; os<2; os++){
    cout << strmzzname[os] << endl;
    for (int sc=0; sc<3; sc++){
      cout << strBSItitle[0] << strScaleSchemeTitle[sc] << " mJJ>=130 GeV / mJJ<130 GeV: " << hVBF_sig[os][sc]->GetBinContent(hVBF_sig[os][sc]->GetNbinsX()) << " / " << (hVBF_sig[os][sc]->Integral() - hVBF_sig[os][sc]->GetBinContent(hVBF_sig[os][sc]->GetNbinsX())) << " = " << hVBF_sig[os][sc]->GetBinContent(hVBF_sig[os][sc]->GetNbinsX())/(hVBF_sig[os][sc]->Integral() - hVBF_sig[os][sc]->GetBinContent(hVBF_sig[os][sc]->GetNbinsX())) << endl;
      cout << strBSItitle[1] << strScaleSchemeTitle[sc] << " mJJ>=130 GeV / mJJ<130 GeV: " << hVBF_bkg[os][sc]->GetBinContent(hVBF_bkg[os][sc]->GetNbinsX()) << " / " << (hVBF_bkg[os][sc]->Integral() - hVBF_bkg[os][sc]->GetBinContent(hVBF_bkg[os][sc]->GetNbinsX())) << " = " << hVBF_bkg[os][sc]->GetBinContent(hVBF_bkg[os][sc]->GetNbinsX())/(hVBF_bkg[os][sc]->Integral() - hVBF_bkg[os][sc]->GetBinContent(hVBF_bkg[os][sc]->GetNbinsX())) << endl;
      cout << strBSItitle[2] << strScaleSchemeTitle[sc] << " mJJ>=130 GeV / mJJ<130 GeV: " << hVBF_int[os][sc]->GetBinContent(hVBF_int[os][sc]->GetNbinsX()) << " / " << (hVBF_int[os][sc]->Integral() - hVBF_int[os][sc]->GetBinContent(hVBF_int[os][sc]->GetNbinsX())) << " = " << hVBF_int[os][sc]->GetBinContent(hVBF_int[os][sc]->GetNbinsX())/(hVBF_int[os][sc]->Integral() - hVBF_int[os][sc]->GetBinContent(hVBF_int[os][sc]->GetNbinsX())) << endl;

      hVBF_sig[os][sc]->SetTitle("");
      hVBF_bkg[os][sc]->SetTitle("");
      hVBF_int[os][sc]->SetTitle("");
      hVBF_sig[os][sc]->GetXaxis()->SetRangeUser(22, 129.9);
      hVBF_bkg[os][sc]->GetXaxis()->SetRangeUser(22, 129.9);
      hVBF_int[os][sc]->GetXaxis()->SetRangeUser(22, 129.9);
      hVBF_sig[os][sc]->GetXaxis()->SetTitle("m^{true}_{jj} (GeV)");
      hVBF_bkg[os][sc]->GetXaxis()->SetTitle("m^{true}_{jj} (GeV)");
      hVBF_int[os][sc]->GetXaxis()->SetTitle("m^{true}_{jj} (GeV)");
      double binwidth = hVBF_sig[os][sc]->GetBinWidth(1);
      hVBF_sig[os][sc]->GetYaxis()->SetTitleOffset(1.5);
      hVBF_bkg[os][sc]->GetYaxis()->SetTitleOffset(1.5);
      hVBF_int[os][sc]->GetYaxis()->SetTitleOffset(1.5);
      hVBF_sig[os][sc]->GetYaxis()->SetTitle(Form("Events / %.0f GeV", binwidth));
      hVBF_bkg[os][sc]->GetYaxis()->SetTitle(Form("Events / %.0f GeV", binwidth));
      hVBF_int[os][sc]->GetYaxis()->SetTitle(Form("Events / %.0f GeV", binwidth));
      hVBF_sig[os][sc]->SetLineWidth(2);
      hVBF_bkg[os][sc]->SetLineWidth(2);
      hVBF_int[os][sc]->SetLineWidth(2);
      hVBF_sig[os][sc]->SetLineStyle(1);
      hVBF_bkg[os][sc]->SetLineStyle(1);
      hVBF_int[os][sc]->SetLineStyle(1);
      if (sc==0){
        hVBF_sig[os][sc]->SetLineColor(kRed);
        hVBF_bkg[os][sc]->SetLineColor(kRed);
        hVBF_int[os][sc]->SetLineColor(kRed);
      }
      if (sc==1){
        hVBF_sig[os][sc]->SetLineColor(kViolet);
        hVBF_bkg[os][sc]->SetLineColor(kViolet);
        hVBF_int[os][sc]->SetLineColor(kViolet);
      }
      else if (sc==2){
        hVBF_sig[os][sc]->SetLineColor(kBlue);
        hVBF_bkg[os][sc]->SetLineColor(kBlue);
        hVBF_int[os][sc]->SetLineColor(kBlue);
      }
      for (int bin=1; bin<hVBF_sig[os][sc]->GetNbinsX(); bin++){
        double bcsig = hVBF_sig[os][sc]->GetBinContent(bin);
        double bcbkg = hVBF_bkg[os][sc]->GetBinContent(bin);
        double bcint = hVBF_int[os][sc]->GetBinContent(bin);

        max_plot[os][0] = max(max_plot[os][0], bcsig);
        min_plot[os][0] = min(min_plot[os][0], bcsig);
        max_plot[os][1] = max(max_plot[os][1], bcbkg);
        min_plot[os][1] = min(min_plot[os][1], bcbkg);
        max_plot[os][2] = max(max_plot[os][2], bcint);
        min_plot[os][2] = min(min_plot[os][2], bcint);
      }
      cout << "Set up region " << os << " scheme " << sc << " complete." << endl;
    }
    for (int sc=0; sc<3; sc++){
      hVBF_sig[os][sc]->GetYaxis()->SetRangeUser(min_plot[os][0]*1.5, max_plot[os][0]*1.5);
      hVBF_bkg[os][sc]->GetYaxis()->SetRangeUser(min_plot[os][1]*1.5, max_plot[os][1]*1.5);
      hVBF_int[os][sc]->GetYaxis()->SetRangeUser(min_plot[os][2]*1.5, max_plot[os][2]*1.5);
    }
  }

  foutput->cd();

  for (int os=0; os<2; os++){
    for (int bsi=0; bsi<3; bsi++){
      cout << "Begin plot of region " << os << endl;

      TPaveText* pt = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC");
      pt->SetBorderSize(0);
      pt->SetFillStyle(0);
      pt->SetTextAlign(12);
      pt->SetTextFont(42);
      pt->SetTextSize(0.045);
      TText* text = pt->AddText(0.025, 0.45, "#font[61]{CMS}");
      text->SetTextSize(0.044);
      text = pt->AddText(0.165, 0.42, "#font[52]{Simulation}");
      text->SetTextSize(0.0315);
//      TString cErgTev = "#font[42]{19.7 fb^{-1} (8 TeV) + 5.1 fb^{-1} (7 TeV)}";
      TString cErgTev = "#font[42]{              2e+2#mu 19.7 fb^{-1} (8 TeV)}";
      text = pt->AddText(0.537, 0.45, cErgTev);
      text->SetTextSize(0.0315);

      TString appendName;
      appendName = "_";
      appendName += strmzzname[os];
      appendName += strBSIname[bsi];
      TString canvasname = "cCompareMJJ_GenLevel";
      canvasname.Append(appendName);
      TCanvas* cc = new TCanvas(canvasname, "", 8, 30, 800, 800);
      gStyle->SetOptStat(0);
      cc->cd();
      gStyle->SetOptStat(0);
      cc->SetFillColor(0);
      cc->SetBorderMode(0);
      cc->SetBorderSize(2);
      cc->SetTickx(1);
      cc->SetTicky(1);
      cc->SetLeftMargin(0.17);
      cc->SetRightMargin(0.05);
      cc->SetTopMargin(0.07);
      cc->SetBottomMargin(0.13);
      cc->SetFrameFillStyle(0);
      cc->SetFrameBorderMode(0);
      cc->SetFrameFillStyle(0);
      cc->SetFrameBorderMode(0);

      TLegend *ll;
      ll = new TLegend(0.22, 0.70, 0.60, 0.90);
      ll->SetBorderSize(0);
      ll->SetTextFont(42);
      ll->SetTextSize(0.03);
      ll->SetLineColor(1);
      ll->SetLineStyle(1);
      ll->SetLineWidth(1);
      ll->SetFillColor(0);
      ll->SetFillStyle(0);

      for (int sc=0; sc<3; sc++){
        if (bsi==0){
          TString legendLabel = strBSItitle[bsi] + strScaleSchemeTitle[sc];
          ll->AddEntry(hVBF_sig[os][sc], legendLabel, "l");
          if (sc==0) hVBF_sig[os][sc]->Draw("hist");
          else hVBF_sig[os][sc]->Draw("histsame");
        }
        else if (bsi==1){
          TString legendLabel = strBSItitle[bsi] + strScaleSchemeTitle[sc];
          ll->AddEntry(hVBF_bkg[os][sc], legendLabel, "l");
          if (sc==0) hVBF_bkg[os][sc]->Draw("hist");
          else hVBF_bkg[os][sc]->Draw("histsame");
        }
        else if (bsi==2){
          TString legendLabel = strBSItitle[bsi] + strScaleSchemeTitle[sc];
          ll->AddEntry(hVBF_int[os][sc], legendLabel, "l");
          if (sc==0) hVBF_int[os][sc]->Draw("hist");
          else hVBF_int[os][sc]->Draw("histsame");
        }
      }

      ll->Draw("same");
      pt->Draw();

      TPaveText *pt10 = new TPaveText(0.80, 0.86, 0.90, 0.90, "brNDC");
      pt10->SetBorderSize(0);
      pt10->SetTextAlign(12);
      pt10->SetTextSize(0.03);
      pt10->SetFillStyle(0);
      pt10->SetTextFont(42);
      TText* text10;
      text10 = pt10->AddText(0.01, 0.01, strmzztitle[os]);
      pt10->Draw();

      foutput->WriteTObject(cc);

      delete pt10;
      delete ll;
      cc->Close();
      delete pt;

      cout << "End plot of region " << os << endl;
    }
  }

  for (int tr = 0; tr < kNumTemplates; tr++){
    delete hVBF_onshell_LC[tr];
    delete hVBF_offshell_LC[tr];
    delete hVBF_onshell_scaled[tr];
    delete hVBF_offshell_scaled[tr];
    delete hVBF_onshell_scaled_wVBF[tr];
    delete hVBF_offshell_scaled_wVBF[tr];
  }
  foutput->Close();
}
Example #25
0
File: Draweff.C Project: 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()));	

}
void SegtoLCTY_2016B_June22all_sameYrange()
{
//=========Macro generated from canvas: SegtoLCTY/SegtoLCTY
//=========  (Fri Aug  5 08:12:16 2016) by ROOT version6.06/01
   TCanvas *SegtoLCTY = new TCanvas("SegtoLCTY", "SegtoLCTY",0,0,500,500);
   gStyle->SetOptStat(0);
   SegtoLCTY->SetHighLightColor(2);
   SegtoLCTY->Range(-50,-2.848556,50,2.626708);
   SegtoLCTY->SetFillColor(0);
   SegtoLCTY->SetBorderMode(0);
   SegtoLCTY->SetBorderSize(2);
   SegtoLCTY->SetLogy();
   SegtoLCTY->SetFrameBorderMode(0);
   SegtoLCTY->SetFrameBorderMode(0);
   
   TH1D *SegtoLCTY_1__37 = new TH1D("SegtoLCTY_1__37","SegtoLCTY",100,-40,40);
   SegtoLCTY_1__37->SetBinContent(0,1.898254);
   SegtoLCTY_1__37->SetBinContent(1,0.002442073);
   SegtoLCTY_1__37->SetBinContent(2,0.002136814);
   SegtoLCTY_1__37->SetBinContent(3,0.0009157775);
   SegtoLCTY_1__37->SetBinContent(4,0.002594703);
   SegtoLCTY_1__37->SetBinContent(5,0.002594703);
   SegtoLCTY_1__37->SetBinContent(6,0.002594703);
   SegtoLCTY_1__37->SetBinContent(7,0.002442073);
   SegtoLCTY_1__37->SetBinContent(8,0.001831555);
   SegtoLCTY_1__37->SetBinContent(9,0.002747332);
   SegtoLCTY_1__37->SetBinContent(10,0.003052592);
   SegtoLCTY_1__37->SetBinContent(11,0.00366311);
   SegtoLCTY_1__37->SetBinContent(12,0.001831555);
   SegtoLCTY_1__37->SetBinContent(13,0.003052592);
   SegtoLCTY_1__37->SetBinContent(14,0.004273628);
   SegtoLCTY_1__37->SetBinContent(15,0.003815739);
   SegtoLCTY_1__37->SetBinContent(16,0.003968369);
   SegtoLCTY_1__37->SetBinContent(17,0.002594703);
   SegtoLCTY_1__37->SetBinContent(18,0.002899962);
   SegtoLCTY_1__37->SetBinContent(19,0.005036776);
   SegtoLCTY_1__37->SetBinContent(20,0.004120999);
   SegtoLCTY_1__37->SetBinContent(21,0.003815739);
   SegtoLCTY_1__37->SetBinContent(22,0.005036776);
   SegtoLCTY_1__37->SetBinContent(23,0.004426258);
   SegtoLCTY_1__37->SetBinContent(24,0.005036776);
   SegtoLCTY_1__37->SetBinContent(25,0.006868331);
   SegtoLCTY_1__37->SetBinContent(26,0.007020961);
   SegtoLCTY_1__37->SetBinContent(27,0.006257813);
   SegtoLCTY_1__37->SetBinContent(28,0.006868331);
   SegtoLCTY_1__37->SetBinContent(29,0.007020961);
   SegtoLCTY_1__37->SetBinContent(30,0.01068407);
   SegtoLCTY_1__37->SetBinContent(31,0.006868331);
   SegtoLCTY_1__37->SetBinContent(32,0.01007355);
   SegtoLCTY_1__37->SetBinContent(33,0.009310404);
   SegtoLCTY_1__37->SetBinContent(34,0.01037881);
   SegtoLCTY_1__37->SetBinContent(35,0.01266826);
   SegtoLCTY_1__37->SetBinContent(36,0.01159985);
   SegtoLCTY_1__37->SetBinContent(37,0.01648399);
   SegtoLCTY_1__37->SetBinContent(38,0.01831555);
   SegtoLCTY_1__37->SetBinContent(39,0.01984185);
   SegtoLCTY_1__37->SetBinContent(40,0.01846818);
   SegtoLCTY_1__37->SetBinContent(41,0.02243655);
   SegtoLCTY_1__37->SetBinContent(42,0.02671018);
   SegtoLCTY_1__37->SetBinContent(43,0.03937843);
   SegtoLCTY_1__37->SetBinContent(44,0.03617321);
   SegtoLCTY_1__37->SetBinContent(45,0.04868884);
   SegtoLCTY_1__37->SetBinContent(46,0.05479402);
   SegtoLCTY_1__37->SetBinContent(47,0.07723057);
   SegtoLCTY_1__37->SetBinContent(48,0.1245457);
   SegtoLCTY_1__37->SetBinContent(49,1.805913);
   SegtoLCTY_1__37->SetBinContent(50,5.034181);
   SegtoLCTY_1__37->SetBinContent(51,85.83888);
   SegtoLCTY_1__37->SetBinContent(52,3.317862);
   SegtoLCTY_1__37->SetBinContent(53,1.832013);
   SegtoLCTY_1__37->SetBinContent(54,0.3237273);
   SegtoLCTY_1__37->SetBinContent(55,0.2254339);
   SegtoLCTY_1__37->SetBinContent(56,0.1320246);
   SegtoLCTY_1__37->SetBinContent(57,0.1472875);
   SegtoLCTY_1__37->SetBinContent(58,0.0799779);
   SegtoLCTY_1__37->SetBinContent(59,0.07280431);
   SegtoLCTY_1__37->SetBinContent(60,0.05342035);
   SegtoLCTY_1__37->SetBinContent(61,0.04533098);
   SegtoLCTY_1__37->SetBinContent(62,0.03724162);
   SegtoLCTY_1__37->SetBinContent(63,0.03479954);
   SegtoLCTY_1__37->SetBinContent(64,0.0257944);
   SegtoLCTY_1__37->SetBinContent(65,0.01663662);
   SegtoLCTY_1__37->SetBinContent(66,0.02258918);
   SegtoLCTY_1__37->SetBinContent(67,0.02106288);
   SegtoLCTY_1__37->SetBinContent(68,0.01419455);
   SegtoLCTY_1__37->SetBinContent(69,0.0190787);
   SegtoLCTY_1__37->SetBinContent(70,0.01465244);
   SegtoLCTY_1__37->SetBinContent(71,0.0175524);
   SegtoLCTY_1__37->SetBinContent(72,0.0108367);
   SegtoLCTY_1__37->SetBinContent(73,0.01144722);
   SegtoLCTY_1__37->SetBinContent(74,0.01419455);
   SegtoLCTY_1__37->SetBinContent(75,0.008852516);
   SegtoLCTY_1__37->SetBinContent(76,0.009157775);
   SegtoLCTY_1__37->SetBinContent(77,0.009768293);
   SegtoLCTY_1__37->SetBinContent(78,0.007784109);
   SegtoLCTY_1__37->SetBinContent(79,0.009615663);
   SegtoLCTY_1__37->SetBinContent(80,0.006410442);
   SegtoLCTY_1__37->SetBinContent(81,0.007936738);
   SegtoLCTY_1__37->SetBinContent(82,0.006105183);
   SegtoLCTY_1__37->SetBinContent(83,0.007020961);
   SegtoLCTY_1__37->SetBinContent(84,0.006868331);
   SegtoLCTY_1__37->SetBinContent(85,0.005494665);
   SegtoLCTY_1__37->SetBinContent(86,0.005494665);
   SegtoLCTY_1__37->SetBinContent(87,0.005342035);
   SegtoLCTY_1__37->SetBinContent(88,0.005494665);
   SegtoLCTY_1__37->SetBinContent(89,0.005647294);
   SegtoLCTY_1__37->SetBinContent(90,0.005036776);
   SegtoLCTY_1__37->SetBinContent(91,0.003052592);
   SegtoLCTY_1__37->SetBinContent(92,0.004273628);
   SegtoLCTY_1__37->SetBinContent(93,0.002899962);
   SegtoLCTY_1__37->SetBinContent(94,0.003357851);
   SegtoLCTY_1__37->SetBinContent(95,0.002899962);
   SegtoLCTY_1__37->SetBinContent(96,0.005647294);
   SegtoLCTY_1__37->SetBinContent(97,0.003052592);
   SegtoLCTY_1__37->SetBinContent(98,0.002594703);
   SegtoLCTY_1__37->SetBinContent(99,0.003052592);
   SegtoLCTY_1__37->SetBinContent(100,0.002594703);
   SegtoLCTY_1__37->SetBinContent(101,1.24912);
   SegtoLCTY_1__37->SetMinimum(0.005);
   SegtoLCTY_1__37->SetMaximum(120);
   SegtoLCTY_1__37->SetEntries(675802);
   SegtoLCTY_1__37->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ff00ff");
   SegtoLCTY_1__37->SetLineColor(ci);

   ci = TColor::GetColor("#ff00ff");
   SegtoLCTY_1__37->SetMarkerColor(ci);
   SegtoLCTY_1__37->GetXaxis()->SetTitle("cm");
   SegtoLCTY_1__37->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTY_1__37->Draw("H");
   
   TLegend *leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("SegtoLCTY_1","ME11A: mean:0.1cm;RMS:1.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_2","ME11B: mean:0.2cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_3","ME12+13: mean:0.5cm;RMS:1.6cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_4","ME2: mean:0.2cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_5","ME3: mean:-0.1cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_6","ME4: mean:-0.1cm;RMS:1.2cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *SegtoLCTY_2__38 = new TH1D("SegtoLCTY_2__38","SegtoLCTY",100,-40,40);
   SegtoLCTY_2__38->SetBinContent(0,0.6313823);
   SegtoLCTY_2__38->SetBinContent(1,0.002236199);
   SegtoLCTY_2__38->SetBinContent(2,0.002494222);
   SegtoLCTY_2__38->SetBinContent(3,0.001720153);
   SegtoLCTY_2__38->SetBinContent(4,0.001376123);
   SegtoLCTY_2__38->SetBinContent(5,0.002150192);
   SegtoLCTY_2__38->SetBinContent(6,0.002064184);
   SegtoLCTY_2__38->SetBinContent(7,0.00369833);
   SegtoLCTY_2__38->SetBinContent(8,0.003182284);
   SegtoLCTY_2__38->SetBinContent(9,0.003096276);
   SegtoLCTY_2__38->SetBinContent(10,0.003526314);
   SegtoLCTY_2__38->SetBinContent(11,0.003354299);
   SegtoLCTY_2__38->SetBinContent(12,0.001376123);
   SegtoLCTY_2__38->SetBinContent(13,0.00369833);
   SegtoLCTY_2__38->SetBinContent(14,0.004128368);
   SegtoLCTY_2__38->SetBinContent(15,0.002150192);
   SegtoLCTY_2__38->SetBinContent(16,0.002924261);
   SegtoLCTY_2__38->SetBinContent(17,0.003010268);
   SegtoLCTY_2__38->SetBinContent(18,0.004214376);
   SegtoLCTY_2__38->SetBinContent(19,0.004128368);
   SegtoLCTY_2__38->SetBinContent(20,0.005246468);
   SegtoLCTY_2__38->SetBinContent(21,0.005246468);
   SegtoLCTY_2__38->SetBinContent(22,0.003870345);
   SegtoLCTY_2__38->SetBinContent(23,0.005676506);
   SegtoLCTY_2__38->SetBinContent(24,0.005934529);
   SegtoLCTY_2__38->SetBinContent(25,0.006364568);
   SegtoLCTY_2__38->SetBinContent(26,0.00516046);
   SegtoLCTY_2__38->SetBinContent(27,0.00627856);
   SegtoLCTY_2__38->SetBinContent(28,0.006880614);
   SegtoLCTY_2__38->SetBinContent(29,0.006880614);
   SegtoLCTY_2__38->SetBinContent(30,0.008342744);
   SegtoLCTY_2__38->SetBinContent(31,0.00885879);
   SegtoLCTY_2__38->SetBinContent(32,0.009202821);
   SegtoLCTY_2__38->SetBinContent(33,0.01083697);
   SegtoLCTY_2__38->SetBinContent(34,0.01049294);
   SegtoLCTY_2__38->SetBinContent(35,0.01247111);
   SegtoLCTY_2__38->SetBinContent(36,0.01358921);
   SegtoLCTY_2__38->SetBinContent(37,0.01505134);
   SegtoLCTY_2__38->SetBinContent(38,0.01530937);
   SegtoLCTY_2__38->SetBinContent(39,0.01608343);
   SegtoLCTY_2__38->SetBinContent(40,0.02124389);
   SegtoLCTY_2__38->SetBinContent(41,0.02451219);
   SegtoLCTY_2__38->SetBinContent(42,0.02459819);
   SegtoLCTY_2__38->SetBinContent(43,0.03552117);
   SegtoLCTY_2__38->SetBinContent(44,0.03835942);
   SegtoLCTY_2__38->SetBinContent(45,0.0538408);
   SegtoLCTY_2__38->SetBinContent(46,0.07448264);
   SegtoLCTY_2__38->SetBinContent(47,0.07998713);
   SegtoLCTY_2__38->SetBinContent(48,0.1540397);
   SegtoLCTY_2__38->SetBinContent(49,3.500856);
   SegtoLCTY_2__38->SetBinContent(50,4.506716);
   SegtoLCTY_2__38->SetBinContent(51,79.10719);
   SegtoLCTY_2__38->SetBinContent(52,6.900309);
   SegtoLCTY_2__38->SetBinContent(53,3.7692);
   SegtoLCTY_2__38->SetBinContent(54,0.4788907);
   SegtoLCTY_2__38->SetBinContent(55,0.2770307);
   SegtoLCTY_2__38->SetBinContent(56,0.1499114);
   SegtoLCTY_2__38->SetBinContent(57,0.09228623);
   SegtoLCTY_2__38->SetBinContent(58,0.06829009);
   SegtoLCTY_2__38->SetBinContent(59,0.05237867);
   SegtoLCTY_2__38->SetBinContent(60,0.04240178);
   SegtoLCTY_2__38->SetBinContent(61,0.033629);
   SegtoLCTY_2__38->SetBinContent(62,0.02924261);
   SegtoLCTY_2__38->SetBinContent(63,0.02313606);
   SegtoLCTY_2__38->SetBinContent(64,0.02029781);
   SegtoLCTY_2__38->SetBinContent(65,0.01745956);
   SegtoLCTY_2__38->SetBinContent(66,0.01849165);
   SegtoLCTY_2__38->SetBinContent(67,0.01315917);
   SegtoLCTY_2__38->SetBinContent(68,0.01315917);
   SegtoLCTY_2__38->SetBinContent(69,0.00885879);
   SegtoLCTY_2__38->SetBinContent(70,0.01023491);
   SegtoLCTY_2__38->SetBinContent(71,0.00885879);
   SegtoLCTY_2__38->SetBinContent(72,0.007052629);
   SegtoLCTY_2__38->SetBinContent(73,0.007568675);
   SegtoLCTY_2__38->SetBinContent(74,0.008084721);
   SegtoLCTY_2__38->SetBinContent(75,0.006106545);
   SegtoLCTY_2__38->SetBinContent(76,0.006192552);
   SegtoLCTY_2__38->SetBinContent(77,0.006536583);
   SegtoLCTY_2__38->SetBinContent(78,0.005504491);
   SegtoLCTY_2__38->SetBinContent(79,0.003784337);
   SegtoLCTY_2__38->SetBinContent(80,0.005074453);
   SegtoLCTY_2__38->SetBinContent(81,0.004730422);
   SegtoLCTY_2__38->SetBinContent(82,0.004300384);
   SegtoLCTY_2__38->SetBinContent(83,0.003010268);
   SegtoLCTY_2__38->SetBinContent(84,0.003526314);
   SegtoLCTY_2__38->SetBinContent(85,0.003354299);
   SegtoLCTY_2__38->SetBinContent(86,0.002752245);
   SegtoLCTY_2__38->SetBinContent(87,0.003784337);
   SegtoLCTY_2__38->SetBinContent(88,0.00369833);
   SegtoLCTY_2__38->SetBinContent(89,0.004214376);
   SegtoLCTY_2__38->SetBinContent(90,0.003096276);
   SegtoLCTY_2__38->SetBinContent(91,0.003182284);
   SegtoLCTY_2__38->SetBinContent(92,0.00369833);
   SegtoLCTY_2__38->SetBinContent(93,0.003010268);
   SegtoLCTY_2__38->SetBinContent(94,0.002322207);
   SegtoLCTY_2__38->SetBinContent(95,0.002752245);
   SegtoLCTY_2__38->SetBinContent(96,0.001978176);
   SegtoLCTY_2__38->SetBinContent(97,0.00258023);
   SegtoLCTY_2__38->SetBinContent(98,0.002666238);
   SegtoLCTY_2__38->SetBinContent(99,0.002322207);
   SegtoLCTY_2__38->SetBinContent(100,0.002236199);
   SegtoLCTY_2__38->SetBinContent(101,1.317035);
   SegtoLCTY_2__38->SetEntries(1185341);
   SegtoLCTY_2__38->SetStats(0);

   ci = TColor::GetColor("#ff9999");
   SegtoLCTY_2__38->SetLineColor(ci);

   ci = TColor::GetColor("#ff9999");
   SegtoLCTY_2__38->SetMarkerColor(ci);
   SegtoLCTY_2__38->GetXaxis()->SetTitle("cm");
   SegtoLCTY_2__38->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTY_2__38->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("SegtoLCTY_1","ME11A: mean:0.1cm;RMS:1.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_2","ME11B: mean:0.2cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_3","ME12+13: mean:0.5cm;RMS:1.6cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_4","ME2: mean:0.2cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_5","ME3: mean:-0.1cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_6","ME4: mean:-0.1cm;RMS:1.2cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *SegtoLCTY_3__39 = new TH1D("SegtoLCTY_3__39","SegtoLCTY",100,-40,40);
   SegtoLCTY_3__39->SetBinContent(0,0.2784678);
   SegtoLCTY_3__39->SetBinContent(1,0.002072319);
   SegtoLCTY_3__39->SetBinContent(2,0.002072319);
   SegtoLCTY_3__39->SetBinContent(3,0.0007771195);
   SegtoLCTY_3__39->SetBinContent(4,0.002072319);
   SegtoLCTY_3__39->SetBinContent(5,0.002072319);
   SegtoLCTY_3__39->SetBinContent(6,0.003108478);
   SegtoLCTY_3__39->SetBinContent(7,0.002331359);
   SegtoLCTY_3__39->SetBinContent(8,0.002849438);
   SegtoLCTY_3__39->SetBinContent(9,0.002331359);
   SegtoLCTY_3__39->SetBinContent(10,0.002072319);
   SegtoLCTY_3__39->SetBinContent(11,0.001554239);
   SegtoLCTY_3__39->SetBinContent(12,0.001813279);
   SegtoLCTY_3__39->SetBinContent(13,0.001813279);
   SegtoLCTY_3__39->SetBinContent(14,0.001813279);
   SegtoLCTY_3__39->SetBinContent(15,0.002849438);
   SegtoLCTY_3__39->SetBinContent(16,0.002590398);
   SegtoLCTY_3__39->SetBinContent(17,0.001813279);
   SegtoLCTY_3__39->SetBinContent(18,0.001554239);
   SegtoLCTY_3__39->SetBinContent(19,0.002590398);
   SegtoLCTY_3__39->SetBinContent(20,0.004144637);
   SegtoLCTY_3__39->SetBinContent(21,0.002331359);
   SegtoLCTY_3__39->SetBinContent(22,0.002849438);
   SegtoLCTY_3__39->SetBinContent(23,0.002072319);
   SegtoLCTY_3__39->SetBinContent(24,0.003626558);
   SegtoLCTY_3__39->SetBinContent(25,0.001554239);
   SegtoLCTY_3__39->SetBinContent(26,0.003367518);
   SegtoLCTY_3__39->SetBinContent(27,0.003885598);
   SegtoLCTY_3__39->SetBinContent(28,0.002331359);
   SegtoLCTY_3__39->SetBinContent(29,0.003108478);
   SegtoLCTY_3__39->SetBinContent(30,0.004662717);
   SegtoLCTY_3__39->SetBinContent(31,0.006735036);
   SegtoLCTY_3__39->SetBinContent(32,0.004144637);
   SegtoLCTY_3__39->SetBinContent(33,0.004921757);
   SegtoLCTY_3__39->SetBinContent(34,0.004921757);
   SegtoLCTY_3__39->SetBinContent(35,0.006216956);
   SegtoLCTY_3__39->SetBinContent(36,0.006216956);
   SegtoLCTY_3__39->SetBinContent(37,0.006216956);
   SegtoLCTY_3__39->SetBinContent(38,0.009325434);
   SegtoLCTY_3__39->SetBinContent(39,0.008030235);
   SegtoLCTY_3__39->SetBinContent(40,0.009325434);
   SegtoLCTY_3__39->SetBinContent(41,0.01036159);
   SegtoLCTY_3__39->SetBinContent(42,0.01165679);
   SegtoLCTY_3__39->SetBinContent(43,0.01554239);
   SegtoLCTY_3__39->SetBinContent(44,0.01735567);
   SegtoLCTY_3__39->SetBinContent(45,0.02642206);
   SegtoLCTY_3__39->SetBinContent(46,0.03237998);
   SegtoLCTY_3__39->SetBinContent(47,0.04766333);
   SegtoLCTY_3__39->SetBinContent(48,0.07667579);
   SegtoLCTY_3__39->SetBinContent(49,1.295458);
   SegtoLCTY_3__39->SetBinContent(50,14.74714);
   SegtoLCTY_3__39->SetBinContent(51,54.13544);
   SegtoLCTY_3__39->SetBinContent(52,15.52219);
   SegtoLCTY_3__39->SetBinContent(53,7.625356);
   SegtoLCTY_3__39->SetBinContent(54,3.031284);
   SegtoLCTY_3__39->SetBinContent(55,2.189923);
   SegtoLCTY_3__39->SetBinContent(56,0.5009831);
   SegtoLCTY_3__39->SetBinContent(57,0.1761471);
   SegtoLCTY_3__39->SetBinContent(58,0.09325434);
   SegtoLCTY_3__39->SetBinContent(59,0.05517549);
   SegtoLCTY_3__39->SetBinContent(60,0.03807886);
   SegtoLCTY_3__39->SetBinContent(61,0.02460879);
   SegtoLCTY_3__39->SetBinContent(62,0.02719918);
   SegtoLCTY_3__39->SetBinContent(63,0.01631951);
   SegtoLCTY_3__39->SetBinContent(64,0.01165679);
   SegtoLCTY_3__39->SetBinContent(65,0.01476527);
   SegtoLCTY_3__39->SetBinContent(66,0.01010255);
   SegtoLCTY_3__39->SetBinContent(67,0.004921757);
   SegtoLCTY_3__39->SetBinContent(68,0.01036159);
   SegtoLCTY_3__39->SetBinContent(69,0.004921757);
   SegtoLCTY_3__39->SetBinContent(70,0.003626558);
   SegtoLCTY_3__39->SetBinContent(71,0.006994076);
   SegtoLCTY_3__39->SetBinContent(72,0.005698877);
   SegtoLCTY_3__39->SetBinContent(73,0.005698877);
   SegtoLCTY_3__39->SetBinContent(74,0.003626558);
   SegtoLCTY_3__39->SetBinContent(75,0.003108478);
   SegtoLCTY_3__39->SetBinContent(76,0.004144637);
   SegtoLCTY_3__39->SetBinContent(77,0.003108478);
   SegtoLCTY_3__39->SetBinContent(78,0.002331359);
   SegtoLCTY_3__39->SetBinContent(79,0.003108478);
   SegtoLCTY_3__39->SetBinContent(80,0.003885598);
   SegtoLCTY_3__39->SetBinContent(81,0.003367518);
   SegtoLCTY_3__39->SetBinContent(82,0.002331359);
   SegtoLCTY_3__39->SetBinContent(83,0.002072319);
   SegtoLCTY_3__39->SetBinContent(84,0.001813279);
   SegtoLCTY_3__39->SetBinContent(85,0.002331359);
   SegtoLCTY_3__39->SetBinContent(86,0.003367518);
   SegtoLCTY_3__39->SetBinContent(87,0.002849438);
   SegtoLCTY_3__39->SetBinContent(88,0.002072319);
   SegtoLCTY_3__39->SetBinContent(89,0.001813279);
   SegtoLCTY_3__39->SetBinContent(90,0.002849438);
   SegtoLCTY_3__39->SetBinContent(91,0.002072319);
   SegtoLCTY_3__39->SetBinContent(92,0.001554239);
   SegtoLCTY_3__39->SetBinContent(93,0.001036159);
   SegtoLCTY_3__39->SetBinContent(94,0.002849438);
   SegtoLCTY_3__39->SetBinContent(95,0.001295199);
   SegtoLCTY_3__39->SetBinContent(96,0.001554239);
   SegtoLCTY_3__39->SetBinContent(97,0.001813279);
   SegtoLCTY_3__39->SetBinContent(98,0.001554239);
   SegtoLCTY_3__39->SetBinContent(99,0.001295199);
   SegtoLCTY_3__39->SetBinContent(100,0.001295199);
   SegtoLCTY_3__39->SetBinContent(101,0.6424188);
   SegtoLCTY_3__39->SetEntries(389596);
   SegtoLCTY_3__39->SetStats(0);
   SegtoLCTY_3__39->GetXaxis()->SetTitle("cm");
   SegtoLCTY_3__39->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTY_3__39->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("SegtoLCTY_1","ME11A: mean:0.1cm;RMS:1.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_2","ME11B: mean:0.2cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_3","ME12+13: mean:0.5cm;RMS:1.6cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_4","ME2: mean:0.2cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_5","ME3: mean:-0.1cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_6","ME4: mean:-0.1cm;RMS:1.2cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *SegtoLCTY_4__40 = new TH1D("SegtoLCTY_4__40","SegtoLCTY",100,-40,40);
   SegtoLCTY_4__40->SetBinContent(0,0.8410274);
   SegtoLCTY_4__40->SetBinContent(1,0.0004816881);
   SegtoLCTY_4__40->SetBinContent(2,0.000535209);
   SegtoLCTY_4__40->SetBinContent(3,0.0006957717);
   SegtoLCTY_4__40->SetBinContent(4,0.0006957717);
   SegtoLCTY_4__40->SetBinContent(5,0.001016897);
   SegtoLCTY_4__40->SetBinContent(6,0.0009098553);
   SegtoLCTY_4__40->SetBinContent(7,0.0002140836);
   SegtoLCTY_4__40->SetBinContent(8,0.000535209);
   SegtoLCTY_4__40->SetBinContent(9,0.0006957717);
   SegtoLCTY_4__40->SetBinContent(10,0.000535209);
   SegtoLCTY_4__40->SetBinContent(11,0.0006957717);
   SegtoLCTY_4__40->SetBinContent(12,0.0006957717);
   SegtoLCTY_4__40->SetBinContent(13,0.0007492926);
   SegtoLCTY_4__40->SetBinContent(14,0.0007492926);
   SegtoLCTY_4__40->SetBinContent(15,0.0004816881);
   SegtoLCTY_4__40->SetBinContent(16,0.001016897);
   SegtoLCTY_4__40->SetBinContent(17,0.0007492926);
   SegtoLCTY_4__40->SetBinContent(18,0.0008028135);
   SegtoLCTY_4__40->SetBinContent(19,0.001123939);
   SegtoLCTY_4__40->SetBinContent(20,0.001338022);
   SegtoLCTY_4__40->SetBinContent(21,0.001284502);
   SegtoLCTY_4__40->SetBinContent(22,0.001498585);
   SegtoLCTY_4__40->SetBinContent(23,0.001284502);
   SegtoLCTY_4__40->SetBinContent(24,0.001605627);
   SegtoLCTY_4__40->SetBinContent(25,0.001819711);
   SegtoLCTY_4__40->SetBinContent(26,0.00117746);
   SegtoLCTY_4__40->SetBinContent(27,0.001230981);
   SegtoLCTY_4__40->SetBinContent(28,0.001498585);
   SegtoLCTY_4__40->SetBinContent(29,0.001712669);
   SegtoLCTY_4__40->SetBinContent(30,0.001445064);
   SegtoLCTY_4__40->SetBinContent(31,0.002676045);
   SegtoLCTY_4__40->SetBinContent(32,0.00235492);
   SegtoLCTY_4__40->SetBinContent(33,0.002676045);
   SegtoLCTY_4__40->SetBinContent(34,0.00240844);
   SegtoLCTY_4__40->SetBinContent(35,0.003211254);
   SegtoLCTY_4__40->SetBinContent(36,0.004121109);
   SegtoLCTY_4__40->SetBinContent(37,0.003907026);
   SegtoLCTY_4__40->SetBinContent(38,0.004121109);
   SegtoLCTY_4__40->SetBinContent(39,0.00776053);
   SegtoLCTY_4__40->SetBinContent(40,0.00711828);
   SegtoLCTY_4__40->SetBinContent(41,0.009098553);
   SegtoLCTY_4__40->SetBinContent(42,0.009633762);
   SegtoLCTY_4__40->SetBinContent(43,0.01081122);
   SegtoLCTY_4__40->SetBinContent(44,0.01546754);
   SegtoLCTY_4__40->SetBinContent(45,0.0163774);
   SegtoLCTY_4__40->SetBinContent(46,0.03163085);
   SegtoLCTY_4__40->SetBinContent(47,0.06224481);
   SegtoLCTY_4__40->SetBinContent(48,1.059553);
   SegtoLCTY_4__40->SetBinContent(49,1.844384);
   SegtoLCTY_4__40->SetBinContent(50,7.443151);
   SegtoLCTY_4__40->SetBinContent(51,76.64963);
   SegtoLCTY_4__40->SetBinContent(52,6.21854);
   SegtoLCTY_4__40->SetBinContent(53,2.206881);
   SegtoLCTY_4__40->SetBinContent(54,2.981221);
   SegtoLCTY_4__40->SetBinContent(55,0.782422);
   SegtoLCTY_4__40->SetBinContent(56,0.2253765);
   SegtoLCTY_4__40->SetBinContent(57,0.1047404);
   SegtoLCTY_4__40->SetBinContent(58,0.06138847);
   SegtoLCTY_4__40->SetBinContent(59,0.04115757);
   SegtoLCTY_4__40->SetBinContent(60,0.02788439);
   SegtoLCTY_4__40->SetBinContent(61,0.0179295);
   SegtoLCTY_4__40->SetBinContent(62,0.01525346);
   SegtoLCTY_4__40->SetBinContent(63,0.01107883);
   SegtoLCTY_4__40->SetBinContent(64,0.01038305);
   SegtoLCTY_4__40->SetBinContent(65,0.007599968);
   SegtoLCTY_4__40->SetBinContent(66,0.007225321);
   SegtoLCTY_4__40->SetBinContent(67,0.005833778);
   SegtoLCTY_4__40->SetBinContent(68,0.005405611);
   SegtoLCTY_4__40->SetBinContent(69,0.003639421);
   SegtoLCTY_4__40->SetBinContent(70,0.002676045);
   SegtoLCTY_4__40->SetBinContent(71,0.003157733);
   SegtoLCTY_4__40->SetBinContent(72,0.002676045);
   SegtoLCTY_4__40->SetBinContent(73,0.002194357);
   SegtoLCTY_4__40->SetBinContent(74,0.001819711);
   SegtoLCTY_4__40->SetBinContent(75,0.002301399);
   SegtoLCTY_4__40->SetBinContent(76,0.002087315);
   SegtoLCTY_4__40->SetBinContent(77,0.001926752);
   SegtoLCTY_4__40->SetBinContent(78,0.002140836);
   SegtoLCTY_4__40->SetBinContent(79,0.00176619);
   SegtoLCTY_4__40->SetBinContent(80,0.001552106);
   SegtoLCTY_4__40->SetBinContent(81,0.0009633762);
   SegtoLCTY_4__40->SetBinContent(82,0.001338022);
   SegtoLCTY_4__40->SetBinContent(83,0.00117746);
   SegtoLCTY_4__40->SetBinContent(84,0.001498585);
   SegtoLCTY_4__40->SetBinContent(85,0.00117746);
   SegtoLCTY_4__40->SetBinContent(86,0.000535209);
   SegtoLCTY_4__40->SetBinContent(87,0.001445064);
   SegtoLCTY_4__40->SetBinContent(88,0.001016897);
   SegtoLCTY_4__40->SetBinContent(89,0.00117746);
   SegtoLCTY_4__40->SetBinContent(90,0.00117746);
   SegtoLCTY_4__40->SetBinContent(91,0.0006422508);
   SegtoLCTY_4__40->SetBinContent(92,0.0008028135);
   SegtoLCTY_4__40->SetBinContent(93,0.0009633762);
   SegtoLCTY_4__40->SetBinContent(94,0.0005887299);
   SegtoLCTY_4__40->SetBinContent(95,0.0006957717);
   SegtoLCTY_4__40->SetBinContent(96,0.0009633762);
   SegtoLCTY_4__40->SetBinContent(97,0.001016897);
   SegtoLCTY_4__40->SetBinContent(98,0.0008028135);
   SegtoLCTY_4__40->SetBinContent(99,0.001123939);
   SegtoLCTY_4__40->SetBinContent(100,0.001016897);
   SegtoLCTY_4__40->SetBinContent(101,0.3512041);
   SegtoLCTY_4__40->SetEntries(1890705);
   SegtoLCTY_4__40->SetStats(0);

   ci = TColor::GetColor("#ff0000");
   SegtoLCTY_4__40->SetLineColor(ci);

   ci = TColor::GetColor("#ff0000");
   SegtoLCTY_4__40->SetMarkerColor(ci);
   SegtoLCTY_4__40->GetXaxis()->SetTitle("cm");
   SegtoLCTY_4__40->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTY_4__40->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("SegtoLCTY_1","ME11A: mean:0.1cm;RMS:1.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_2","ME11B: mean:0.2cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_3","ME12+13: mean:0.5cm;RMS:1.6cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_4","ME2: mean:0.2cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_5","ME3: mean:-0.1cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_6","ME4: mean:-0.1cm;RMS:1.2cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *SegtoLCTY_5__41 = new TH1D("SegtoLCTY_5__41","SegtoLCTY",100,-40,40);
   SegtoLCTY_5__41->SetBinContent(0,0.5244401);
   SegtoLCTY_5__41->SetBinContent(1,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(2,0.000289506);
   SegtoLCTY_5__41->SetBinContent(3,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(4,0.0005066355);
   SegtoLCTY_5__41->SetBinContent(5,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(6,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(7,0.000434259);
   SegtoLCTY_5__41->SetBinContent(8,0.0002171295);
   SegtoLCTY_5__41->SetBinContent(9,0.0007961415);
   SegtoLCTY_5__41->SetBinContent(10,0.000434259);
   SegtoLCTY_5__41->SetBinContent(11,0.000289506);
   SegtoLCTY_5__41->SetBinContent(12,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(13,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(14,0.000868518);
   SegtoLCTY_5__41->SetBinContent(15,0.0006513885);
   SegtoLCTY_5__41->SetBinContent(16,0.0006513885);
   SegtoLCTY_5__41->SetBinContent(17,0.0009408945);
   SegtoLCTY_5__41->SetBinContent(18,0.0009408945);
   SegtoLCTY_5__41->SetBinContent(19,0.0007961415);
   SegtoLCTY_5__41->SetBinContent(20,0.001085647);
   SegtoLCTY_5__41->SetBinContent(21,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(22,0.0012304);
   SegtoLCTY_5__41->SetBinContent(23,0.0009408945);
   SegtoLCTY_5__41->SetBinContent(24,0.001302777);
   SegtoLCTY_5__41->SetBinContent(25,0.002026542);
   SegtoLCTY_5__41->SetBinContent(26,0.0009408945);
   SegtoLCTY_5__41->SetBinContent(27,0.002098918);
   SegtoLCTY_5__41->SetBinContent(28,0.001809412);
   SegtoLCTY_5__41->SetBinContent(29,0.00144753);
   SegtoLCTY_5__41->SetBinContent(30,0.001664659);
   SegtoLCTY_5__41->SetBinContent(31,0.00267793);
   SegtoLCTY_5__41->SetBinContent(32,0.00267793);
   SegtoLCTY_5__41->SetBinContent(33,0.002098918);
   SegtoLCTY_5__41->SetBinContent(34,0.002967436);
   SegtoLCTY_5__41->SetBinContent(35,0.004197837);
   SegtoLCTY_5__41->SetBinContent(36,0.004632096);
   SegtoLCTY_5__41->SetBinContent(37,0.004776849);
   SegtoLCTY_5__41->SetBinContent(38,0.005717743);
   SegtoLCTY_5__41->SetBinContent(39,0.0135344);
   SegtoLCTY_5__41->SetBinContent(40,0.01179737);
   SegtoLCTY_5__41->SetBinContent(41,0.01150786);
   SegtoLCTY_5__41->SetBinContent(42,0.01331728);
   SegtoLCTY_5__41->SetBinContent(43,0.0193969);
   SegtoLCTY_5__41->SetBinContent(44,0.02258147);
   SegtoLCTY_5__41->SetBinContent(45,0.04031371);
   SegtoLCTY_5__41->SetBinContent(46,0.1180461);
   SegtoLCTY_5__41->SetBinContent(47,3.074409);
   SegtoLCTY_5__41->SetBinContent(48,3.030983);
   SegtoLCTY_5__41->SetBinContent(49,5.040154);
   SegtoLCTY_5__41->SetBinContent(50,10.08465);
   SegtoLCTY_5__41->SetBinContent(51,70.76684);
   SegtoLCTY_5__41->SetBinContent(52,3.508089);
   SegtoLCTY_5__41->SetBinContent(53,3.107702);
   SegtoLCTY_5__41->SetBinContent(54,0.5185776);
   SegtoLCTY_5__41->SetBinContent(55,0.1874551);
   SegtoLCTY_5__41->SetBinContent(56,0.1121836);
   SegtoLCTY_5__41->SetBinContent(57,0.06492172);
   SegtoLCTY_5__41->SetBinContent(58,0.04552482);
   SegtoLCTY_5__41->SetBinContent(59,0.03242467);
   SegtoLCTY_5__41->SetBinContent(60,0.02258147);
   SegtoLCTY_5__41->SetBinContent(61,0.01787699);
   SegtoLCTY_5__41->SetBinContent(62,0.0132449);
   SegtoLCTY_5__41->SetBinContent(63,0.008395674);
   SegtoLCTY_5__41->SetBinContent(64,0.006369132);
   SegtoLCTY_5__41->SetBinContent(65,0.00579012);
   SegtoLCTY_5__41->SetBinContent(66,0.003908331);
   SegtoLCTY_5__41->SetBinContent(67,0.004921602);
   SegtoLCTY_5__41->SetBinContent(68,0.002388424);
   SegtoLCTY_5__41->SetBinContent(69,0.003329319);
   SegtoLCTY_5__41->SetBinContent(70,0.002822683);
   SegtoLCTY_5__41->SetBinContent(71,0.002533177);
   SegtoLCTY_5__41->SetBinContent(72,0.001809412);
   SegtoLCTY_5__41->SetBinContent(73,0.002243671);
   SegtoLCTY_5__41->SetBinContent(74,0.001519906);
   SegtoLCTY_5__41->SetBinContent(75,0.00144753);
   SegtoLCTY_5__41->SetBinContent(76,0.001013271);
   SegtoLCTY_5__41->SetBinContent(77,0.0012304);
   SegtoLCTY_5__41->SetBinContent(78,0.000868518);
   SegtoLCTY_5__41->SetBinContent(79,0.001302777);
   SegtoLCTY_5__41->SetBinContent(80,0.000868518);
   SegtoLCTY_5__41->SetBinContent(81,0.001085647);
   SegtoLCTY_5__41->SetBinContent(82,0.001375153);
   SegtoLCTY_5__41->SetBinContent(83,0.0006513885);
   SegtoLCTY_5__41->SetBinContent(84,0.0007961415);
   SegtoLCTY_5__41->SetBinContent(85,0.0007961415);
   SegtoLCTY_5__41->SetBinContent(86,0.000579012);
   SegtoLCTY_5__41->SetBinContent(87,0.0007961415);
   SegtoLCTY_5__41->SetBinContent(88,0.001085647);
   SegtoLCTY_5__41->SetBinContent(89,0.0009408945);
   SegtoLCTY_5__41->SetBinContent(90,0.001085647);
   SegtoLCTY_5__41->SetBinContent(91,0.000434259);
   SegtoLCTY_5__41->SetBinContent(92,0.0006513885);
   SegtoLCTY_5__41->SetBinContent(93,0.000434259);
   SegtoLCTY_5__41->SetBinContent(94,0.0006513885);
   SegtoLCTY_5__41->SetBinContent(95,0.0006513885);
   SegtoLCTY_5__41->SetBinContent(96,0.000723765);
   SegtoLCTY_5__41->SetBinContent(97,0.000434259);
   SegtoLCTY_5__41->SetBinContent(98,0.0005066355);
   SegtoLCTY_5__41->SetBinContent(99,0.0003618825);
   SegtoLCTY_5__41->SetBinContent(100,0.000434259);
   SegtoLCTY_5__41->SetBinContent(101,0.4193494);
   SegtoLCTY_5__41->SetEntries(1394704);
   SegtoLCTY_5__41->SetStats(0);

   ci = TColor::GetColor("#00ff00");
   SegtoLCTY_5__41->SetLineColor(ci);

   ci = TColor::GetColor("#00ff00");
   SegtoLCTY_5__41->SetMarkerColor(ci);
   SegtoLCTY_5__41->GetXaxis()->SetTitle("cm");
   SegtoLCTY_5__41->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTY_5__41->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("SegtoLCTY_1","ME11A: mean:0.1cm;RMS:1.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_2","ME11B: mean:0.2cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_3","ME12+13: mean:0.5cm;RMS:1.6cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_4","ME2: mean:0.2cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_5","ME3: mean:-0.1cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_6","ME4: mean:-0.1cm;RMS:1.2cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *SegtoLCTY_6__42 = new TH1D("SegtoLCTY_6__42","SegtoLCTY",100,-40,40);
   SegtoLCTY_6__42->SetBinContent(0,0.2770893);
   SegtoLCTY_6__42->SetBinContent(1,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(2,0.0001826561);
   SegtoLCTY_6__42->SetBinContent(3,0.0003653122);
   SegtoLCTY_6__42->SetBinContent(4,9.132804e-05);
   SegtoLCTY_6__42->SetBinContent(5,0.0002739841);
   SegtoLCTY_6__42->SetBinContent(6,0.0001826561);
   SegtoLCTY_6__42->SetBinContent(7,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(8,0.0002739841);
   SegtoLCTY_6__42->SetBinContent(9,0.0005479682);
   SegtoLCTY_6__42->SetBinContent(10,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(11,0.0002739841);
   SegtoLCTY_6__42->SetBinContent(12,0.0005479682);
   SegtoLCTY_6__42->SetBinContent(13,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(14,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(15,0.0008219523);
   SegtoLCTY_6__42->SetBinContent(16,9.132804e-05);
   SegtoLCTY_6__42->SetBinContent(17,0.0002739841);
   SegtoLCTY_6__42->SetBinContent(18,0.0009132804);
   SegtoLCTY_6__42->SetBinContent(19,0.0005479682);
   SegtoLCTY_6__42->SetBinContent(20,0.0008219523);
   SegtoLCTY_6__42->SetBinContent(21,0.001004608);
   SegtoLCTY_6__42->SetBinContent(22,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(23,0.001278593);
   SegtoLCTY_6__42->SetBinContent(24,0.0009132804);
   SegtoLCTY_6__42->SetBinContent(25,0.001278593);
   SegtoLCTY_6__42->SetBinContent(26,0.001004608);
   SegtoLCTY_6__42->SetBinContent(27,0.0008219523);
   SegtoLCTY_6__42->SetBinContent(28,0.001552577);
   SegtoLCTY_6__42->SetBinContent(29,0.001369921);
   SegtoLCTY_6__42->SetBinContent(30,0.002009217);
   SegtoLCTY_6__42->SetBinContent(31,0.002009217);
   SegtoLCTY_6__42->SetBinContent(32,0.002465857);
   SegtoLCTY_6__42->SetBinContent(33,0.002465857);
   SegtoLCTY_6__42->SetBinContent(34,0.002922497);
   SegtoLCTY_6__42->SetBinContent(35,0.003379137);
   SegtoLCTY_6__42->SetBinContent(36,0.003470465);
   SegtoLCTY_6__42->SetBinContent(37,0.005844994);
   SegtoLCTY_6__42->SetBinContent(38,0.007032259);
   SegtoLCTY_6__42->SetBinContent(39,0.01324257);
   SegtoLCTY_6__42->SetBinContent(40,0.0104114);
   SegtoLCTY_6__42->SetBinContent(41,0.0126946);
   SegtoLCTY_6__42->SetBinContent(42,0.0120553);
   SegtoLCTY_6__42->SetBinContent(43,0.02164474);
   SegtoLCTY_6__42->SetBinContent(44,0.02803771);
   SegtoLCTY_6__42->SetBinContent(45,0.04338082);
   SegtoLCTY_6__42->SetBinContent(46,0.114708);
   SegtoLCTY_6__42->SetBinContent(47,3.722987);
   SegtoLCTY_6__42->SetBinContent(48,4.052682);
   SegtoLCTY_6__42->SetBinContent(49,4.146202);
   SegtoLCTY_6__42->SetBinContent(50,11.80935);
   SegtoLCTY_6__42->SetBinContent(51,66.46654);
   SegtoLCTY_6__42->SetBinContent(52,3.982907);
   SegtoLCTY_6__42->SetBinContent(53,4.192048);
   SegtoLCTY_6__42->SetBinContent(54,0.6763754);
   SegtoLCTY_6__42->SetBinContent(55,0.2176347);
   SegtoLCTY_6__42->SetBinContent(56,0.1273113);
   SegtoLCTY_6__42->SetBinContent(57,0.0788161);
   SegtoLCTY_6__42->SetBinContent(58,0.05004776);
   SegtoLCTY_6__42->SetBinContent(59,0.03607457);
   SegtoLCTY_6__42->SetBinContent(60,0.02538919);
   SegtoLCTY_6__42->SetBinContent(61,0.02146209);
   SegtoLCTY_6__42->SetBinContent(62,0.01397319);
   SegtoLCTY_6__42->SetBinContent(63,0.01159866);
   SegtoLCTY_6__42->SetBinContent(64,0.01013741);
   SegtoLCTY_6__42->SetBinContent(65,0.005844994);
   SegtoLCTY_6__42->SetBinContent(66,0.005388354);
   SegtoLCTY_6__42->SetBinContent(67,0.004018434);
   SegtoLCTY_6__42->SetBinContent(68,0.004840386);
   SegtoLCTY_6__42->SetBinContent(69,0.002374529);
   SegtoLCTY_6__42->SetBinContent(70,0.003379137);
   SegtoLCTY_6__42->SetBinContent(71,0.002465857);
   SegtoLCTY_6__42->SetBinContent(72,0.001826561);
   SegtoLCTY_6__42->SetBinContent(73,0.003013825);
   SegtoLCTY_6__42->SetBinContent(74,0.001552577);
   SegtoLCTY_6__42->SetBinContent(75,0.001187264);
   SegtoLCTY_6__42->SetBinContent(76,0.001187264);
   SegtoLCTY_6__42->SetBinContent(77,0.0009132804);
   SegtoLCTY_6__42->SetBinContent(78,0.0008219523);
   SegtoLCTY_6__42->SetBinContent(79,0.001004608);
   SegtoLCTY_6__42->SetBinContent(80,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(81,0.0009132804);
   SegtoLCTY_6__42->SetBinContent(82,0.0009132804);
   SegtoLCTY_6__42->SetBinContent(83,0.0005479682);
   SegtoLCTY_6__42->SetBinContent(84,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(85,0.0003653122);
   SegtoLCTY_6__42->SetBinContent(86,0.0007306243);
   SegtoLCTY_6__42->SetBinContent(87,0.001095936);
   SegtoLCTY_6__42->SetBinContent(88,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(89,0.0005479682);
   SegtoLCTY_6__42->SetBinContent(90,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(91,9.132804e-05);
   SegtoLCTY_6__42->SetBinContent(92,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(93,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(94,0.0003653122);
   SegtoLCTY_6__42->SetBinContent(95,0.0004566402);
   SegtoLCTY_6__42->SetBinContent(96,0.0005479682);
   SegtoLCTY_6__42->SetBinContent(97,0.001004608);
   SegtoLCTY_6__42->SetBinContent(98,0.0001826561);
   SegtoLCTY_6__42->SetBinContent(99,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(100,0.0006392963);
   SegtoLCTY_6__42->SetBinContent(101,0.3928932);
   SegtoLCTY_6__42->SetEntries(1102290);
   SegtoLCTY_6__42->SetStats(0);

   ci = TColor::GetColor("#0000ff");
   SegtoLCTY_6__42->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   SegtoLCTY_6__42->SetMarkerColor(ci);
   SegtoLCTY_6__42->GetXaxis()->SetTitle("cm");
   SegtoLCTY_6__42->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTY_6__42->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("SegtoLCTY_1","ME11A: mean:0.1cm;RMS:1.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_2","ME11B: mean:0.2cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_3","ME12+13: mean:0.5cm;RMS:1.6cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_4","ME2: mean:0.2cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_5","ME3: mean:-0.1cm;RMS:1.1cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("SegtoLCTY_6","ME4: mean:-0.1cm;RMS:1.2cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.01,0.9390678,0.2699194,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(1);
   pt->SetFillColor(0);
   TText *AText = pt->AddText("SegtoLCTY");
   pt->Draw();
   SegtoLCTY->Modified();
   SegtoLCTY->cd();
   SegtoLCTY->SetSelected(SegtoLCTY);
}
Example #27
0
int Mbb_reg(int type_int){
	gROOT->ProcessLine(".x /afs/cern.ch/work/n/nchernya/setTDRStyle.C");
	

//	int type_int; //double  =0; single=1
	
	TString type;
	if (type_int==0) type = "_double";
	if (type_int==1) type = "_single";
	TString text_type;
	if (type_int==0) text_type = "DoubleB";
	if (type_int==1) text_type = "SingleB";

	const int num_ss = 1;	

//	TString s_names[num_ss] = {"VBFHToBB_M-125_13TeV_powheg"};
	TString s_names[num_ss] = {"vbf_76"};
	TString tex_s_names[num_ss] = {"VBF powheg, m(H) = 125 GeV"};

	TFile *file_s1 =  new TFile("../output_hist/v14/golden/skimmed_tree_analysis"+type+s_names[0]+"_v14_final_74cmssw_woweight.root");
	TH1F *hist_Mbb = (TH1F*)file_s1->Get("hMbb");
	TH1F *hist_Mbb_reg = (TH1F*)file_s1->Get("hMbb_regVBF");
	TH1F *hist_Mbb_reg_fsr = (TH1F*)file_s1->Get("hMbb_regVBF_fsr");
	TF1 *gaus = new TF1("gaus","gaus",95,140);
	gaus->SetLineColor(4);
	gaus->SetLineWidth(1);
	
	hist_Mbb->Sumw2(kFALSE);
	hist_Mbb_reg->Sumw2(kFALSE);
	hist_Mbb_reg_fsr->Sumw2(kFALSE);
	hist_Mbb->Sumw2(kFALSE);


	hist_Mbb->Fit(gaus,"R");
	Float_t Mbb_mean = gaus->GetParameter(1);
	Float_t Mbb_rms = gaus->GetParameter(2);
	hist_Mbb_reg->Sumw2(kFALSE);
	gaus->SetLineColor(2);
	hist_Mbb_reg->Fit(gaus,"R");
	Float_t Mbb_reg_mean = gaus->GetParameter(1);
	Float_t Mbb_reg_rms = gaus->GetParameter(2);
	hist_Mbb_reg_fsr->Sumw2(kFALSE);
	gaus->SetLineColor(8);
	hist_Mbb_reg_fsr->Fit(gaus,"R");
	Float_t Mbb_reg_fsr_mean = gaus->GetParameter(1);
	Float_t Mbb_reg_fsr_rms = gaus->GetParameter(2);

/////
	/*
	Float_t Mbb_mean = hist_Mbb->GetMean(1);
	Float_t Mbb_rms = hist_Mbb->GetRMS(1);
	Float_t Mbb_reg_mean = hist_Mbb_reg->GetMean(1);
	Float_t Mbb_reg_rms = hist_Mbb_reg->GetRMS(1);
	Float_t Mbb_reg_fsr_mean = hist_Mbb_reg_fsr->GetMean(1);
	Float_t Mbb_reg_fsr_rms = hist_Mbb_reg_fsr->GetRMS(1);
*/
/////



	TCanvas *c1 = new TCanvas();
	c1->SetBottomMargin(.15);
	c1->SetRightMargin(.25);
	c1->cd();
	TH1F *frame2 = new TH1F("frame2","",50,0.,230.);
	frame2->SetMinimum(0.);
   frame2->SetMaximum(hist_Mbb->GetMaximum()*1.6);
//	if (type_int==1)  frame2->SetMaximum(0.005);
   frame2->SetStats(0);
	frame2->SetYTitle("Events / 5 GeV");
	frame2->SetXTitle("M_{bb} (GeV)");	
	frame2->GetYaxis()->SetNdivisions(505);
	frame2->GetXaxis()->SetLabelSize(0.0);
  	frame2->GetXaxis()->SetTitleSize(0.05);
  	frame2->GetXaxis()->SetLabelSize(0.04);
	frame2->Draw();
	TLatex* tex = new TLatex(0.75,0.95,"13 TeV");
   tex->SetNDC();
	tex->SetTextAlign(35);
   tex->SetTextFont(42);
   tex->SetTextSize(0.035);
   tex->SetLineWidth(2);
   TLatex *tex1 = new TLatex(0.17,0.95,"CMS");
   tex1->SetNDC();
   tex1->SetTextAlign(20);
   tex1->SetTextFont(61);
   tex1->SetTextSize(0.04);
   tex1->SetLineWidth(2);
   TLatex* tex2 = new TLatex(0.25,0.89,"Work in progress");
   tex2->SetNDC();
   tex2->SetTextAlign(20);
   tex2->SetTextFont(52);
   tex2->SetTextSize(0.035);
  	tex2->SetLineWidth(2);	
	TLatex* tex_file = new TLatex(0.36,0.95,text_type);
   tex_file->SetNDC();
	tex_file->SetTextAlign(35);
   tex_file->SetTextFont(42);
   tex_file->SetTextSize(0.04);
   tex_file->SetLineWidth(2);	
	tex->Draw();
	tex1->Draw();
	tex2->Draw();
//	tex_file->Draw();
	hist_Mbb->SetLineColor(4);
	hist_Mbb->SetLineWidth(2);
	hist_Mbb_reg->SetLineColor(2);
	hist_Mbb_reg->SetLineWidth(2);
	hist_Mbb_reg_fsr->SetLineColor(8);
	hist_Mbb_reg_fsr->SetLineWidth(2);
	hist_Mbb_reg->Draw("same");
	hist_Mbb_reg_fsr->Draw("same");
	hist_Mbb->Draw("same");

	TString leg_Mbb0 = "Nominal";
	TString leg_Mbb_reg0 = "Regressed";
	TString leg_Mbb_reg_fsr0 = "Regressed+FSR";
	TString leg_Mbb = "";
	TString leg_Mbb_reg = "";
	TString leg_Mbb_reg_fsr = "";
	TString leg_mean = "Mean=";
	TString leg_rms = ", RMS=";
	TString leg_mean = "#mu=";
	TString leg_rms = ", #sigma=";
	TString leg_ratio = ",#sigma/#mu=";
	TString temp_str;
	temp_str.Form("%2.1f",Mbb_mean);
	leg_Mbb.Append(leg_mean);
	leg_Mbb.Append(temp_str);
	leg_Mbb.Append(leg_rms);
	temp_str.Form("%2.1f",Mbb_rms);
	leg_Mbb.Append(temp_str);
	leg_Mbb.Append(leg_ratio);
	temp_str.Form("%2.2f",Mbb_rms/Mbb_mean);
	leg_Mbb.Append(temp_str);
///////
	temp_str.Form("%2.1f",Mbb_reg_mean);
	leg_Mbb_reg.Append(leg_mean);
	leg_Mbb_reg.Append(temp_str);
	leg_Mbb_reg.Append(leg_rms);
	temp_str.Form("%2.1f",Mbb_reg_rms);
	leg_Mbb_reg.Append(temp_str);
	leg_Mbb_reg.Append(leg_ratio);
	temp_str.Form("%2.2f",Mbb_reg_rms/Mbb_reg_mean);
	leg_Mbb_reg.Append(temp_str);
////////
	temp_str.Form("%2.1f",Mbb_reg_fsr_mean);
	leg_Mbb_reg_fsr.Append(leg_mean);
	leg_Mbb_reg_fsr.Append(temp_str);
	leg_Mbb_reg_fsr.Append(leg_rms);
	temp_str.Form("%2.1f",Mbb_reg_fsr_rms);
	leg_Mbb_reg_fsr.Append(temp_str);
	leg_Mbb_reg_fsr.Append(leg_ratio);
	temp_str.Form("%2.2f",Mbb_reg_fsr_rms/Mbb_reg_fsr_mean);
	leg_Mbb_reg_fsr.Append(temp_str);

	TLegend *leg = new TLegend(0.77,0.6,0.92,0.9);
	leg->SetFillColor(0);
	leg->SetBorderSize(0);
	leg->SetTextFont(42);
	leg->SetTextSize(0.025);
	leg->AddEntry(hist_Mbb,text_type,"");
	leg->AddEntry(hist_Mbb,leg_Mbb0,"L");
	leg->AddEntry(hist_Mbb,leg_Mbb,"");
	leg->AddEntry(hist_Mbb_reg,leg_Mbb_reg0,"L");
	leg->AddEntry(hist_Mbb_reg,leg_Mbb_reg,"");
	leg->AddEntry(hist_Mbb_reg_fsr,leg_Mbb_reg_fsr0,"L");
	leg->AddEntry(hist_Mbb_reg_fsr,leg_Mbb_reg_fsr,"");

	leg->Draw("same");
	c1->Print("plots/v14Mbb_regressed"+type+"_cmssw76.png");
		


	return 0;
}
//this makes Z(nunu) prediction vs. MC truth plots for the AN.
//at the moment all numbers are hard-coded and this code needs major revision, the mc truth numbers are loaded from a root file created by ZnunuNumbers.C
//furthermore the stored root file is used for both producing the final result plots/tables and also interpretation
void ZinvVisualization(){

    const int gNMT2bins_2j0b_hHT                      = 6;
    double  gMT2bins_2j0b_hHT[gNMT2bins_2j0b_hHT+1]   = {120, 150, 200, 260, 350, 550, 900};
    const int gNMT2bins_2j1b_hHT                      = 2;
    double  gMT2bins_2j1b_hHT[gNMT2bins_2j1b_hHT+1]   = {100, 180, 350};
    const int gNMT2bins_3j0b_hHT                      = 7;
    double  gMT2bins_3j0b_hHT[gNMT2bins_3j0b_hHT+1]   = {160, 185, 220, 270, 350, 450, 650, 1000};
    const int gNMT2bins_3j1b_hHT                      = 4;
    double  gMT2bins_3j1b_hHT[gNMT2bins_3j1b_hHT+1]   = {150, 180, 230, 350, 550};
    const int gNMT2bins_3j2b_hHT                      = 2;
    double  gMT2bins_3j2b_hHT[gNMT2bins_3j2b_hHT+1]   = {130, 200, 350};
    const int gNMT2bins_6j0b_hHT                      = 3;
    double  gMT2bins_6j0b_hHT[gNMT2bins_6j0b_hHT+1]   = {160, 200, 300, 500};
    const int gNMT2bins_6j1b_hHT                      = 3;
    double  gMT2bins_6j1b_hHT[gNMT2bins_6j1b_hHT+1]   = {150, 200, 300, 500};
    const int gNMT2bins_6j2b_hHT                      = 2;
    double  gMT2bins_6j2b_hHT[gNMT2bins_6j2b_hHT+1]   = {130, 200, 350};
    const int gNMT2bins_3b_hHT                        = 1;
    double  gMT2bins_3b_hHT[gNMT2bins_3b_hHT+1]       = {125, 300};

    // HT > 750 && HT < 1200
    const int gNMT2bins_2j0b_mHT                      = 9;
    double  gMT2bins_2j0b_mHT[gNMT2bins_2j0b_mHT+1]   = {125, 150, 180, 220, 270, 325, 425, 580, 780, 1000};
    const int gNMT2bins_2j1b_mHT                      = 5;
    double  gMT2bins_2j1b_mHT[gNMT2bins_2j1b_mHT+1]   = {100, 135, 170, 260, 450, 700};
    const int gNMT2bins_3j0b_mHT                      = 9;
    double  gMT2bins_3j0b_mHT[gNMT2bins_3j0b_mHT+1]   = {160, 185, 215, 250, 300, 370, 480, 640, 800, 1000};
    const int gNMT2bins_3j1b_mHT                      = 6;
    double  gMT2bins_3j1b_mHT[gNMT2bins_3j1b_mHT+1]   = {150, 175, 210, 270, 380, 600, 900};
    const int gNMT2bins_3j2b_mHT                      = 5;
    double  gMT2bins_3j2b_mHT[gNMT2bins_3j2b_mHT+1]   = {130, 160, 200, 270, 370, 500};
    const int gNMT2bins_6j0b_mHT                      = 5;
    double  gMT2bins_6j0b_mHT[gNMT2bins_6j0b_mHT+1]   = {160, 200, 250, 325, 425, 600};
    const int gNMT2bins_6j1b_mHT                      = 4;
    double  gMT2bins_6j1b_mHT[gNMT2bins_6j1b_mHT+1]   = {150, 190, 250, 350, 500};
    const int gNMT2bins_6j2b_mHT                      = 4;
    double  gMT2bins_6j2b_mHT[gNMT2bins_6j2b_mHT+1]   = {130, 170, 220, 300, 450};
    const int gNMT2bins_3b_mHT                        = 3;
    double  gMT2bins_3b_mHT[gNMT2bins_3b_mHT+1]       = {125, 175, 275, 450};

    // HT > 450 && HT < 750
    const int gNMT2bins_2j0b_lHT                      = 8;
    double  gMT2bins_2j0b_lHT[gNMT2bins_2j0b_lHT+1]   = {200, 240, 290, 350, 420, 490, 570, 650, 750};
    const int gNMT2bins_2j1b_lHT                      = 6;
    double  gMT2bins_2j1b_lHT[gNMT2bins_2j1b_lHT+1]   = {200, 250, 310, 380, 450, 550, 700};
    const int gNMT2bins_3j0b_lHT                      = 8;
    double  gMT2bins_3j0b_lHT[gNMT2bins_3j0b_lHT+1]   = {200, 240, 290, 350, 420, 490, 570, 650, 750};
    const int gNMT2bins_3j1b_lHT                      = 6;
    double  gMT2bins_3j1b_lHT[gNMT2bins_3j1b_lHT+1]   = {200, 250, 310, 380, 460, 550, 700};
    const int gNMT2bins_3j2b_lHT                      = 4;
    double  gMT2bins_3j2b_lHT[gNMT2bins_3j2b_lHT+1]   = {200, 250, 325, 425, 550};
    const int gNMT2bins_6j0b_lHT                      = 3;
    double  gMT2bins_6j0b_lHT[gNMT2bins_6j0b_lHT+1]   = {200, 280, 380, 520};
    const int gNMT2bins_6j1b_lHT                      = 3;
    double  gMT2bins_6j1b_lHT[gNMT2bins_6j1b_lHT+1]   = {200, 250, 325, 450};
    const int gNMT2bins_6j2b_lHT                      = 3;
    double  gMT2bins_6j2b_lHT[gNMT2bins_6j2b_lHT+1]   = {200, 250, 300, 400};
    const int gNMT2bins_3b_lHT                        = 2;
    double  gMT2bins_3b_lHT  [gNMT2bins_3b_lHT+1]     = {200, 280, 400};

const int signalregionsize = 9;
string signal_region[signalregionsize] = {"2j0b", "2j1to2b", "3to5j0b", "3to5j1b", "3to5j2b", "6j0b", "6j1b", "6j2b", "3b"};
const int HTbinsize = 3;
string HT_bin[HTbinsize] = {"lowHT", "mediumHT", "highHT"};

    	gROOT->SetStyle("Plain");
	gStyle->SetPalette(1);
	gStyle->SetOptStat(0);

    TLegend *leg = new TLegend(0.6551724,0.7299578,0.8706897,0.8987342,NULL,"brNDC");
    leg->SetBorderSize(0);
    leg->SetTextFont(62);
    leg->SetTextSize(0.04575163);
    leg->SetLineColor(1);
    leg->SetLineStyle(1);
    leg->SetLineWidth(1);
    leg->SetFillColor(0);
    leg->SetFillStyle(1001);

//load MC truth numbers
TFile *fmctruth = TFile::Open("../Results/Filtered/GammaJetsPrediction/20130617_test/ZnunuNumbers.root");

	//define all histograms
	map<string, TH1D*>    histos;
	for(int i3 = 0; i3<HTbinsize;        ++i3){
	for(int i2 = 0; i2<signalregionsize; ++i2){
		int NMT2bins;
		if(i3==0){
			if(signal_region[i2]=="2j0b")    NMT2bins = gNMT2bins_2j0b_lHT;
			if(signal_region[i2]=="2j1to2b") NMT2bins = gNMT2bins_2j1b_lHT;
			if(signal_region[i2]=="3to5j0b") NMT2bins = gNMT2bins_3j0b_lHT;
			if(signal_region[i2]=="3to5j1b") NMT2bins = gNMT2bins_3j1b_lHT;
			if(signal_region[i2]=="3to5j2b") NMT2bins = gNMT2bins_3j2b_lHT;
			if(signal_region[i2]=="6j0b")    NMT2bins = gNMT2bins_6j0b_lHT;
			if(signal_region[i2]=="6j1b")    NMT2bins = gNMT2bins_6j1b_lHT;
			if(signal_region[i2]=="6j2b")    NMT2bins = gNMT2bins_6j2b_lHT;
			if(signal_region[i2]=="3b")      NMT2bins = gNMT2bins_3b_lHT;
		} if(i3==1){
			if(signal_region[i2]=="2j0b")    NMT2bins = gNMT2bins_2j0b_mHT;
			if(signal_region[i2]=="2j1to2b") NMT2bins = gNMT2bins_2j1b_mHT;
			if(signal_region[i2]=="3to5j0b") NMT2bins = gNMT2bins_3j0b_mHT;
			if(signal_region[i2]=="3to5j1b") NMT2bins = gNMT2bins_3j1b_mHT;
			if(signal_region[i2]=="3to5j2b") NMT2bins = gNMT2bins_3j2b_mHT;
			if(signal_region[i2]=="6j0b")    NMT2bins = gNMT2bins_6j0b_mHT;
			if(signal_region[i2]=="6j1b")    NMT2bins = gNMT2bins_6j1b_mHT;
			if(signal_region[i2]=="6j2b")    NMT2bins = gNMT2bins_6j2b_mHT;
			if(signal_region[i2]=="3b")      NMT2bins = gNMT2bins_3b_mHT;
		} if(i3==2){
			if(signal_region[i2]=="2j0b")    NMT2bins = gNMT2bins_2j0b_hHT;
			if(signal_region[i2]=="2j1to2b") NMT2bins = gNMT2bins_2j1b_hHT;
			if(signal_region[i2]=="3to5j0b") NMT2bins = gNMT2bins_3j0b_hHT;
			if(signal_region[i2]=="3to5j1b") NMT2bins = gNMT2bins_3j1b_hHT;
			if(signal_region[i2]=="3to5j2b") NMT2bins = gNMT2bins_3j2b_hHT;
			if(signal_region[i2]=="6j0b")    NMT2bins = gNMT2bins_6j0b_hHT;
			if(signal_region[i2]=="6j1b")    NMT2bins = gNMT2bins_6j1b_hHT;
			if(signal_region[i2]=="6j2b")    NMT2bins = gNMT2bins_6j2b_hHT;
			if(signal_region[i2]=="3b")      NMT2bins = gNMT2bins_3b_hHT;
		}
  		double MT2bins[NMT2bins+1];
		if(i3==0){
			if(signal_region[i2]=="2j0b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_2j0b_lHT[i0]; }
			if(signal_region[i2]=="2j1to2b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_2j1b_lHT[i0]; }
			if(signal_region[i2]=="3to5j0b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j0b_lHT[i0]; }
			if(signal_region[i2]=="3to5j1b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j1b_lHT[i0]; }
			if(signal_region[i2]=="3to5j2b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j2b_lHT[i0]; }
			if(signal_region[i2]=="6j0b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j0b_lHT[i0]; }
			if(signal_region[i2]=="6j1b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j1b_lHT[i0]; }
			if(signal_region[i2]=="6j2b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j2b_lHT[i0]; }
			if(signal_region[i2]=="3b")      { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3b_lHT[i0];   }
		} if(i3==1){
			if(signal_region[i2]=="2j0b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_2j0b_mHT[i0];  }
			if(signal_region[i2]=="2j1to2b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_2j1b_mHT[i0];  }
			if(signal_region[i2]=="3to5j0b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j0b_mHT[i0];  }
			if(signal_region[i2]=="3to5j1b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j1b_mHT[i0];  }
			if(signal_region[i2]=="3to5j2b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j2b_mHT[i0];  }
			if(signal_region[i2]=="6j0b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j0b_mHT[i0];  }
			if(signal_region[i2]=="6j1b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j1b_mHT[i0];  }
			if(signal_region[i2]=="6j2b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j2b_mHT[i0];  }
			if(signal_region[i2]=="3b")      { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3b_mHT[i0];    }
		} if(i3==2){
			if(signal_region[i2]=="2j0b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_2j0b_hHT[i0];  }
			if(signal_region[i2]=="2j1to2b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_2j1b_hHT[i0];  }
			if(signal_region[i2]=="3to5j0b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j0b_hHT[i0];  }
			if(signal_region[i2]=="3to5j1b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j1b_hHT[i0];  }
			if(signal_region[i2]=="3to5j2b") { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3j2b_hHT[i0];  }
			if(signal_region[i2]=="6j0b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j0b_hHT[i0];  }
			if(signal_region[i2]=="6j1b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j1b_hHT[i0];  }
			if(signal_region[i2]=="6j2b")    { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_6j2b_hHT[i0];  }
			if(signal_region[i2]=="3b")      { for(int i0 = 0; i0<=NMT2bins; ++i0) MT2bins[i0] = gMT2bins_3b_hHT[i0];    }
		}

		string hs = string("_") + HT_bin[i3] + string("_") + signal_region[i2];// + string("_") + sample_type[i1];
		string mapname = "MT2" + hs;
		TH1D *h = (TH1D*)fmctruth->Get(mapname.c_str());
		mapname = "MT2truth" + hs;
		if(histos.count(mapname) == 0 ) histos[mapname] = (TH1D*)h->Clone(mapname.c_str());
		histos[mapname]->SetFillColor(kViolet-3); histos[mapname]->SetFillStyle(3001);
		//get MC truth histo style
		if(i3==0&&i2==0) leg->AddEntry(histos[mapname], "MC truth", "f");
			histos[mapname]->GetXaxis()->SetTitle("M_{T2} [GeV]");
			histos[mapname]->GetXaxis()->SetLabelFont(42);
			histos[mapname]->GetXaxis()->SetLabelSize(0.06);
			histos[mapname]->GetXaxis()->SetTitleSize(0.06);
			histos[mapname]->GetXaxis()->SetLabelOffset(0.01);
			histos[mapname]->GetXaxis()->SetTitleOffset(1.2);
			histos[mapname]->GetXaxis()->SetTitleFont(42);
			histos[mapname]->GetYaxis()->SetTitle("Z(#nu#nu) yield");
			histos[mapname]->GetYaxis()->SetLabelFont(42);
			histos[mapname]->GetYaxis()->SetLabelSize(0.06);
			histos[mapname]->GetYaxis()->SetTitleSize(0.06);
			histos[mapname]->GetYaxis()->SetLabelOffset(0.01);
			histos[mapname]->GetYaxis()->SetTitleOffset(1.2);
			histos[mapname]->GetYaxis()->SetTitleFont(42);
			histos[mapname]->GetZaxis()->SetLabelFont(42);
			histos[mapname]->GetZaxis()->SetLabelSize(0.035);
			histos[mapname]->GetZaxis()->SetTitleSize(0.035);
			histos[mapname]->GetZaxis()->SetTitleFont(42);
		mapname = "MT2pred" + hs;
		if(histos.count(mapname) == 0 ) histos[mapname] = new TH1D(mapname.c_str(), "", NMT2bins, MT2bins);
		histos[mapname]->SetMarkerStyle(20), histos[mapname]->SetMarkerColor(kBlack); histos[mapname]->SetLineWidth(3); histos[mapname]->SetLineColor(kBlack);
		//get prediction histo style
		if(i3==0&&i2==0) leg->AddEntry(histos[mapname], "data prediction", "lp");
			histos[mapname]->GetXaxis()->SetTitle("M_{T2} [GeV]");
			histos[mapname]->GetXaxis()->SetLabelFont(42);
			histos[mapname]->GetXaxis()->SetLabelSize(0.06);
			histos[mapname]->GetXaxis()->SetTitleSize(0.06);
			histos[mapname]->GetXaxis()->SetLabelOffset(0.01);
			histos[mapname]->GetXaxis()->SetTitleOffset(1.2);
			histos[mapname]->GetXaxis()->SetTitleFont(42);
			histos[mapname]->GetYaxis()->SetTitle("Z(#nu#nu) yield");
			histos[mapname]->GetYaxis()->SetLabelFont(42);
			histos[mapname]->GetYaxis()->SetLabelSize(0.06);
			histos[mapname]->GetYaxis()->SetTitleSize(0.06);
			histos[mapname]->GetYaxis()->SetLabelOffset(0.01);
			histos[mapname]->GetYaxis()->SetTitleOffset(1.2);
			histos[mapname]->GetYaxis()->SetTitleFont(42);
			histos[mapname]->GetZaxis()->SetLabelFont(42);
			histos[mapname]->GetZaxis()->SetLabelSize(0.035);
			histos[mapname]->GetZaxis()->SetTitleSize(0.035);
			histos[mapname]->GetZaxis()->SetTitleFont(42);
	}}

	//hard-coded numbers
	for(int i3 = 0; i3<HTbinsize;        ++i3){
	for(int i2 = 0; i2<signalregionsize; ++i2){
	   string hs = string("_") + HT_bin[i3] + string("_") + signal_region[i2];
	   string mapname = "MT2pred" + hs;
	   if(i3==0&&i2==0){//lHT,2j,0b
		histos[mapname]->SetBinContent(1,304.27); histos[mapname]->SetBinError(1,sqrt(pow(11.84,2)+pow(62.55,2)));
		histos[mapname]->SetBinContent(2,236.52); histos[mapname]->SetBinError(2,sqrt(pow(10.55,2)+pow(48.41,2)));
		histos[mapname]->SetBinContent(3,182.98); histos[mapname]->SetBinError(3,sqrt(pow( 9.30,2)+pow(37.50,2)));
		histos[mapname]->SetBinContent(4,160.92); histos[mapname]->SetBinError(4,sqrt(pow( 9.09,2)+pow(50.38,2)));
		histos[mapname]->SetBinContent(5,116.69); histos[mapname]->SetBinError(5,sqrt(pow( 7.46,2)+pow(35.07,2)));
		histos[mapname]->SetBinContent(6, 47.95); histos[mapname]->SetBinError(6,sqrt(pow( 4.86,2)+pow(14.57,2)));
		histos[mapname]->SetBinContent(7, 11.74); histos[mapname]->SetBinError(7,sqrt(pow( 2.39,2)+pow( 3.56,2)));
		histos[mapname]->SetBinContent(8,  3.28); histos[mapname]->SetBinError(8,sqrt(pow( 1.24,2)+pow( 0.98,2)));
	   } if(i3==0&&i2==2){//lHT,35j,0b
		histos[mapname]->SetBinContent(1,458.79); histos[mapname]->SetBinError(1,sqrt(pow(16.03,2)+pow(97.64,2)));
		histos[mapname]->SetBinContent(2,366.96); histos[mapname]->SetBinError(2,sqrt(pow(14.70,2)+pow(80.26,2)));
		histos[mapname]->SetBinContent(3,301.04); histos[mapname]->SetBinError(3,sqrt(pow(12.94,2)+pow(62.16,2)));
		histos[mapname]->SetBinContent(4,173.25); histos[mapname]->SetBinError(4,sqrt(pow(10.18,2)+pow(54.86,2)));
		histos[mapname]->SetBinContent(5, 93.60); histos[mapname]->SetBinError(5,sqrt(pow( 7.29,2)+pow(28.28,2)));
		histos[mapname]->SetBinContent(6, 41.36); histos[mapname]->SetBinError(6,sqrt(pow( 4.88,2)+pow(12.64,2)));
		histos[mapname]->SetBinContent(7,  9.80); histos[mapname]->SetBinError(7,sqrt(pow( 2.38,2)+pow( 3.01,2)));
		histos[mapname]->SetBinContent(8,  2.73); histos[mapname]->SetBinError(8,sqrt(pow( 1.22,2)+pow( 0.82,2)));
	   } if(i3==0&&i2==5){//lHT,6j,0b
		histos[mapname]->SetBinContent(1, 12.02); histos[mapname]->SetBinError(1,sqrt(pow( 2.76,2)+pow( 2.58,2)));
		histos[mapname]->SetBinContent(2,  5.13); histos[mapname]->SetBinError(2,sqrt(pow( 1.95,2)+pow( 1.29,2)));
		histos[mapname]->SetBinContent(3,  3.53); histos[mapname]->SetBinError(3,sqrt(pow( 1.77,2)+pow( 1.24,2)));
	   } if(i3==1&&i2==0){//mHT,2j,0b
		histos[mapname]->SetBinContent(1, 76.13); histos[mapname]->SetBinError(1,sqrt(pow( 5.38,2)+pow(15.32,2)));
		histos[mapname]->SetBinContent(2, 62.24); histos[mapname]->SetBinError(2,sqrt(pow( 4.92,2)+pow(12.55,2)));
		histos[mapname]->SetBinContent(3, 38.49); histos[mapname]->SetBinError(3,sqrt(pow( 3.95,2)+pow( 7.78,2)));
		histos[mapname]->SetBinContent(4, 40.84); histos[mapname]->SetBinError(4,sqrt(pow( 4.19,2)+pow( 8.26,2)));
		histos[mapname]->SetBinContent(5, 20.11); histos[mapname]->SetBinError(5,sqrt(pow( 3.00,2)+pow( 4.08,2)));
		histos[mapname]->SetBinContent(6, 30.21); histos[mapname]->SetBinError(6,sqrt(pow( 3.82,2)+pow( 9.14,2)));
		histos[mapname]->SetBinContent(7, 12.73); histos[mapname]->SetBinError(7,sqrt(pow( 2.44,2)+pow( 3.84,2)));
		histos[mapname]->SetBinContent(8, 15.96); histos[mapname]->SetBinError(8,sqrt(pow( 2.79,2)+pow( 4.83,2)));
		histos[mapname]->SetBinContent(9,  2.83); histos[mapname]->SetBinError(9,sqrt(pow( 1.15,2)+pow( 0.85,2)));
	   } if(i3==1&&i2==2){//mHT,35j,0b
		histos[mapname]->SetBinContent(1, 88.17); histos[mapname]->SetBinError(1,sqrt(pow( 6.50,2)+pow(17.75,2)));
		histos[mapname]->SetBinContent(2, 73.11); histos[mapname]->SetBinError(2,sqrt(pow( 6.38,2)+pow(14.78,2)));
		histos[mapname]->SetBinContent(3, 63.34); histos[mapname]->SetBinError(3,sqrt(pow( 5.72,2)+pow(12.78,2)));
		histos[mapname]->SetBinContent(4, 59.03); histos[mapname]->SetBinError(4,sqrt(pow( 5.71,2)+pow(11.95,2)));
		histos[mapname]->SetBinContent(5, 50.85); histos[mapname]->SetBinError(5,sqrt(pow( 5.36,2)+pow(10.32,2)));
		histos[mapname]->SetBinContent(6, 43.54); histos[mapname]->SetBinError(6,sqrt(pow( 4.88,2)+pow(13.11,2)));
		histos[mapname]->SetBinContent(7, 23.40); histos[mapname]->SetBinError(7,sqrt(pow( 3.63,2)+pow( 7.07,2)));
		histos[mapname]->SetBinContent(8,  6.43); histos[mapname]->SetBinError(8,sqrt(pow( 1.85,2)+pow( 1.93,2)));
		histos[mapname]->SetBinContent(9,  2.68); histos[mapname]->SetBinError(9,sqrt(pow( 1.20,2)+pow( 0.81,2)));
	  } if(i3==1&&i2==5){//mHT,6j,0b
		histos[mapname]->SetBinContent(1, 10.51); histos[mapname]->SetBinError(1,sqrt(pow( 2.84,2)+pow( 2.43,2)));
		histos[mapname]->SetBinContent(2,  3.03); histos[mapname]->SetBinError(2,sqrt(pow( 1.35,2)+pow( 0.68,2)));
		histos[mapname]->SetBinContent(3,  4.05); histos[mapname]->SetBinError(3,sqrt(pow( 1.65,2)+pow( 0.94,2)));
		histos[mapname]->SetBinContent(4,  2.61); histos[mapname]->SetBinError(4,sqrt(pow( 1.51,2)+pow( 0.88,2)));
		histos[mapname]->SetBinContent(5,  0.66); histos[mapname]->SetBinError(5,sqrt(pow( 0.66,2)+pow( 0.23,2)));
	   } if(i3==2&&i2==0){//hHT,2j,0b
		histos[mapname]->SetBinContent(1, 10.05); histos[mapname]->SetBinError(1,sqrt(pow( 1.99,2)+pow( 2.09,2)));
		histos[mapname]->SetBinContent(2, 10.34); histos[mapname]->SetBinError(2,sqrt(pow( 2.07,2)+pow( 2.14,2)));
		histos[mapname]->SetBinContent(3,  9.22); histos[mapname]->SetBinError(3,sqrt(pow( 2.06,2)+pow( 1.97,2)));
		histos[mapname]->SetBinContent(4,  3.52); histos[mapname]->SetBinError(4,sqrt(pow( 1.25,2)+pow( 0.76,2)));
		histos[mapname]->SetBinContent(5,  2.94); histos[mapname]->SetBinError(5,sqrt(pow( 1.20,2)+pow( 0.91,2)));
		histos[mapname]->SetBinContent(6,  2.45); histos[mapname]->SetBinError(6,sqrt(pow( 1.10,2)+pow( 0.76,2)));
	   } if(i3==2&&i2==2){//hHT,35j,0b
		histos[mapname]->SetBinContent(1,  8.73); histos[mapname]->SetBinError(1,sqrt(pow( 2.13,2)+pow( 1.86,2)));
		histos[mapname]->SetBinContent(2, 11.85); histos[mapname]->SetBinError(2,sqrt(pow( 2.42,2)+pow( 2.48,2)));
		histos[mapname]->SetBinContent(3, 10.16); histos[mapname]->SetBinError(3,sqrt(pow( 2.33,2)+pow( 2.13,2)));
		histos[mapname]->SetBinContent(4,  8.54); histos[mapname]->SetBinError(4,sqrt(pow( 2.20,2)+pow( 1.82,2)));
		histos[mapname]->SetBinContent(5,  4.85); histos[mapname]->SetBinError(5,sqrt(pow( 1.73,2)+pow( 1.52,2)));
		histos[mapname]->SetBinContent(6,  2.88); histos[mapname]->SetBinError(6,sqrt(pow( 1.29,2)+pow( 0.88,2)));
		histos[mapname]->SetBinContent(7,  2.88); histos[mapname]->SetBinError(7,sqrt(pow( 1.29,2)+pow( 0.88,2)));
	   } if(i3==2&&i2==5){//hHT,6j,0b
		histos[mapname]->SetBinContent(1,  2.80); histos[mapname]->SetBinError(1,sqrt(pow( 1.40,2)+pow( 0.80,2)));
		histos[mapname]->SetBinContent(2,  3.43); histos[mapname]->SetBinError(2,sqrt(pow( 1.98,2)+pow( 0.93,2)));
	//	histos[mapname]->SetBinContent(3,); histos[mapname]->SetBinError(3,sqrt(pow(,2)+pow(,2)));
	  } if(i3==0&&i2==1){//lHT,2j,1b
		histos[mapname]->SetBinContent(1, 33.99); histos[mapname]->SetBinError(1,sqrt(pow( 1.21,2)+pow(10.70,2)));
		histos[mapname]->SetBinContent(2, 22.83); histos[mapname]->SetBinError(2,sqrt(pow( 1.00,2)+pow( 7.19,2)));
		histos[mapname]->SetBinContent(3, 17.90); histos[mapname]->SetBinError(3,sqrt(pow( 0.91,2)+pow( 6.97,2)));
		histos[mapname]->SetBinContent(4, 13.92); histos[mapname]->SetBinError(4,sqrt(pow( 0.82,2)+pow( 5.44,2)));
		histos[mapname]->SetBinContent(5,  9.25); histos[mapname]->SetBinError(5,sqrt(pow( 0.65,2)+pow( 3.56,2)));
		histos[mapname]->SetBinContent(6,  1.91); histos[mapname]->SetBinError(6,sqrt(pow( 0.30,2)+pow( 0.74,2)));
	   } if(i3==0&&i2==3){//lHT,35j,1b
		histos[mapname]->SetBinContent(1, 87.24); histos[mapname]->SetBinError(1,sqrt(pow( 2.82,2)+pow(22.79,2)));
		histos[mapname]->SetBinContent(2, 64.63); histos[mapname]->SetBinError(2,sqrt(pow( 2.45,2)+pow(16.77,2)));
		histos[mapname]->SetBinContent(3, 42.61); histos[mapname]->SetBinError(3,sqrt(pow( 1.94,2)+pow(14.56,2)));
		histos[mapname]->SetBinContent(4, 23.77); histos[mapname]->SetBinError(4,sqrt(pow( 1.52,2)+pow( 8.25,2)));
		histos[mapname]->SetBinContent(5, 11.56); histos[mapname]->SetBinError(5,sqrt(pow( 1.04,2)+pow( 3.90,2)));
		histos[mapname]->SetBinContent(6,  2.66); histos[mapname]->SetBinError(6,sqrt(pow( 0.50,2)+pow( 0.91,2)));
	   } if(i3==0&&i2==6){//lHT,6j,1b
		histos[mapname]->SetBinContent(1,  2.12); histos[mapname]->SetBinError(1,sqrt(pow( 0.61,2)+pow( 1.40,2)));
		histos[mapname]->SetBinContent(2,  1.84); histos[mapname]->SetBinError(2,sqrt(pow( 0.53,2)+pow( 1.22,2)));
		histos[mapname]->SetBinContent(3,  1.55); histos[mapname]->SetBinError(3,sqrt(pow( 0.64,2)+pow( 1.11,2)));
	   } if(i3==1&&i2==1){//mHT,2j,1b
		histos[mapname]->SetBinContent(1, 12.04); histos[mapname]->SetBinError(1,sqrt(pow( 0.61,2)+pow( 6.91,2)));
		histos[mapname]->SetBinContent(2,  8.03); histos[mapname]->SetBinError(2,sqrt(pow( 0.54,2)+pow( 4.61,2)));
		histos[mapname]->SetBinContent(3,  8.67); histos[mapname]->SetBinError(3,sqrt(pow( 0.58,2)+pow( 4.97,2)));
		histos[mapname]->SetBinContent(4,  5.38); histos[mapname]->SetBinError(4,sqrt(pow( 0.49,2)+pow( 3.31,2)));
		histos[mapname]->SetBinContent(5,  2.65); histos[mapname]->SetBinError(5,sqrt(pow( 0.34,2)+pow( 1.63,2)));
	   } if(i3==1&&i2==3){//mHT,35j,1b
		histos[mapname]->SetBinContent(1, 16.86); histos[mapname]->SetBinError(1,sqrt(pow( 1.14,2)+pow( 3.89,2)));
		histos[mapname]->SetBinContent(2, 15.66); histos[mapname]->SetBinError(2,sqrt(pow( 1.16,2)+pow( 3.62,2)));
		histos[mapname]->SetBinContent(3, 16.99); histos[mapname]->SetBinError(3,sqrt(pow( 1.18,2)+pow( 3.92,2)));
		histos[mapname]->SetBinContent(4, 13.70); histos[mapname]->SetBinError(4,sqrt(pow( 1.13,2)+pow( 3.17,2)));
		histos[mapname]->SetBinContent(5,  8.91); histos[mapname]->SetBinError(5,sqrt(pow( 0.89,2)+pow( 2.87,2)));
		histos[mapname]->SetBinContent(6,  2.27); histos[mapname]->SetBinError(6,sqrt(pow( 0.45,2)+pow( 0.73,2)));
	   } if(i3==1&&i2==6){//mHT,6j,1b
		histos[mapname]->SetBinContent(1,  2.41); histos[mapname]->SetBinError(1,sqrt(pow( 0.70,2)+pow( 1.39,2)));
		histos[mapname]->SetBinContent(2,  1.55); histos[mapname]->SetBinError(2,sqrt(pow( 0.52,2)+pow( 0.89,2)));
		histos[mapname]->SetBinContent(3,  1.11); histos[mapname]->SetBinError(3,sqrt(pow( 0.45,2)+pow( 0.64,2)));
		histos[mapname]->SetBinContent(4,  0.85); histos[mapname]->SetBinError(4,sqrt(pow( 0.42,2)+pow( 0.53,2)));
	   } if(i3==2&&i2==1){//hHT,2j,1b
		histos[mapname]->SetBinContent(1,  2.69); histos[mapname]->SetBinError(1,sqrt(pow( 0.31,2)+pow( 1.80,2)));
		histos[mapname]->SetBinContent(2,  2.25); histos[mapname]->SetBinError(2,sqrt(pow( 0.31,2)+pow( 1.51,2)));
	   } if(i3==2&&i2==3){//hHT,35j,1b
		histos[mapname]->SetBinContent(1,  2.16); histos[mapname]->SetBinError(1,sqrt(pow( 0.41,2)+pow( 0.61,2)));
		histos[mapname]->SetBinContent(2,  2.40); histos[mapname]->SetBinError(2,sqrt(pow( 0.43,2)+pow( 0.67,2)));
		histos[mapname]->SetBinContent(3,  2.57); histos[mapname]->SetBinError(3,sqrt(pow( 0.49,2)+pow( 0.72,2)));
		histos[mapname]->SetBinContent(4,  1.70); histos[mapname]->SetBinError(4,sqrt(pow( 0.40,2)+pow( 0.61,2)));
	   } if(i3==2&&i2==6){//hHT,6j,1b
		histos[mapname]->SetBinContent(1,  1.06); histos[mapname]->SetBinError(1,sqrt(pow( 0.44,2)+pow( 0.84,2)));
		histos[mapname]->SetBinContent(2,  0.92); histos[mapname]->SetBinError(2,sqrt(pow( 0.53,2)+pow( 0.73,2)));
	//	histos[mapname]->SetBinContent(3,); histos[mapname]->SetBinError(3,sqrt(pow(,2)+pow(,2)));
	   }
	}}

	cout << "Saving." << endl;
    	TFile *fsavefile = new TFile("../Results/Filtered/GammaJetsPrediction/20130617_test/ZinvPredictionNumbers.root","RECREATE");
	fsavefile->cd();
	for(map<string,TH1D*>::iterator h=histos.begin(); h!=histos.end();++h){
		h->second->Write();
	}
	fsavefile->Close();
	cout << "Saved histograms in " << fsavefile->GetName() << endl;

	//make the plots - not TDR style
    TLatex TitleBox;
	TitleBox.SetNDC();
    TitleBox.SetNDC();
    TitleBox.SetTextAlign(12);
    TitleBox.SetTextFont(42);
    TitleBox.SetTextSize(0.04219409);
    TitleBox.SetLineWidth(2);
	TString text;
    string outname;
    double max = 0.;
    double max1,max2;
    string outputdir = "../Results/Filtered/GammaJetsPrediction/20130617_test/ZinvPredictionPlots/";
    	Util::MakeOutputDir(outputdir);

   TCanvas *c1 = new TCanvas("c1", "c1",485,220,700,504);
   c1->Range(82.71719,-0.4425771,532.9945,2.212885);
    c1->SetFillColor(0);
    c1->SetBorderMode(0);
    c1->SetBorderSize(2);
   c1->SetLeftMargin(0.1494253);
   c1->SetRightMargin(0.07327586);
   c1->SetTopMargin(0.08016878);
   c1->SetBottomMargin(0.1666667);
    c1->SetFrameBorderMode(0);
    c1->SetFrameBorderMode(0);
	for(int i3 = 0; i3<HTbinsize;        ++i3){
	for(int i2 = 0; i2<signalregionsize; ++i2){
	   string hs = string("_") + HT_bin[i3] + string("_") + signal_region[i2];// + string("_") + sample_type[i1];
	   string mapname   = "MT2pred"  + hs;
	   string mapnameMC = "MT2truth" + hs;
	   if(i3==0&&i2==0){//lHT,2j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "2 jets, 0 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "2 jets, 0 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==0&&i2==2){//lHT,35j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "3-5 jets, 0 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "3-5 jets, 0 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==0&&i2==5){//lHT,6j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "#geq6 jets, 0 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "#geq6 jets, 0 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==1&&i2==0){//mHT,2j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "2 jets, 0 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "2 jets, 0 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==1&&i2==2){//mHT,35j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "3-5 jets, 0 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "3-5 jets, 0 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==1&&i2==5){//mHT,6j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "#geq6 jets, 0 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.2);
		histos[mapnameMC]->SetMinimum(0.2);
		text = "#geq6 jets, 0 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==2&&i2==0){//hHT,2j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "2 jets, 0 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "2 jets, 0 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==2&&i2==2){//hHT,35j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "3-5 jets, 0 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "3-5 jets, 0 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==2&&i2==5){//hHT,6j,0b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
	//	max = 1.5*max;
		max = 5.5;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "#geq6 jets, 0 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "#geq6 jets, 0 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==0&&i2==1){//lHT,2j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "2 jets, #geq1 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "2 jets, #geq1 b-jets, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==0&&i2==3){//lHT,35j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "3-5 jets, 1 b-jet, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "3-5 jets, 1 b-jet, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==0&&i2==6){//lHT,6j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
	//	max = 1.5*max;
		max = 3.5;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "#geq6 jets, 1 b-jet, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.3);
		histos[mapnameMC]->SetMinimum(0.3);
		text = "#geq6 jets, 1 b-jet, low H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==1&&i2==1){//mHT,2j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "2 jets, #geq1 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "2 jets, #geq1 b-jets, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==1&&i2==3){//mHT,35j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "3-5 jets, 1 b-jet, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "3-5 jets, 1 b-jet, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==1&&i2==6){//mHT,6j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "#geq6 jets, 1 b-jet, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.3);
		histos[mapnameMC]->SetMinimum(0.3);
		text = "#geq6 jets, 1 b-jet, medium H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==2&&i2==1){//hHT,2j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
	//	max = 1.5*max;
		max = 6.5;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "2 jets, #geq1 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "2 jets, #geq1 b-jets, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==2&&i2==3){//hHT,35j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 1.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "3-5 jets, 1 b-jet, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(1.);
		histos[mapnameMC]->SetMinimum(1.);
		text = "3-5 jets, 1 b-jet, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
		c1->Clear();
	   } if(i3==2&&i2==6){//hHT,6j,1b
		c1->Clear();
		c1->cd();
    		gPad->SetLogy(0);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
	//	max = 1.5*max;
		max = 2.;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.);
		histos[mapnameMC]->SetMinimum(0.);
		text = "#geq6 jets, 1 b-jet, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + ".eps";
		c1->SaveAs(outname.c_str());

		c1->Clear();
		c1->cd();
    		gPad->SetLogy(1);
		max1=histos[mapname]  ->GetMaximum();
		max2=histos[mapnameMC]->GetMaximum();
		max  = (max1>max2)?max1:max2;
		max = 2.5*max;
		histos[mapname  ]->SetMaximum(max);
		histos[mapnameMC]->SetMaximum(max);
		histos[mapname  ]->SetMinimum(0.2);
		histos[mapnameMC]->SetMinimum(0.2);
		text = "#geq6 jets, 1 b-jet, high H_{T}";
		histos[mapnameMC]->Draw("E2");
		histos[mapname  ]->Draw("sameE1");
		leg->Draw();
		TitleBox.DrawLatex(0.1494253,0.9493671,text.Data());
		outname = histos[mapname  ]->GetName();outname = outputdir + outname + "_log.eps";
		c1->SaveAs(outname.c_str());
	//	c1->Clear();
	   }
	}}

}
void SUSY_m0_vs_m12_all_withBand_cls( TString fname0 = "mudat_list.root",// nominal
                                      TString fname1 = "",               // Up
                                      TString fname2 = "",               // Down  
                                      TString fname3 = "", // external expection
                                      const char* prefix="test",
                                      const float& lumi = 20,
                                      bool showsig = true,
                                      int discexcl = 1,
                                      int showtevatron = 0,
                                      int showcms = 0,
                                      int showOneSigmaExpBand = 0,
                                      int showfixSigXSecBand = 0,
                                      int channel = -1,
                                      TString hname0 = "sigp1clsf",
                                      TString hname1 = "sigp1expclsf",
                                      TString hname3 = "sigclsu1s",
                                      TString hname5 = "sigclsd1s",
                                      TString hname6 = "sigp1ref",
                                      TString fnameMass= "../../../HistFitterUser/common/mSugraGridtanbeta10_gluinoSquarkMasses.root")
{
   // set style and remove existing canvas'
   CombinationGlob::Initialize();
   
   cout << "--- Plotting m0 versus m12 " << endl;
   
   // --- prepare
   // open reference files, and retrieve histogram
   cout << "--- Reading root base file: " << fname0 << endl;
   TFile* f0 = TFile::Open( fname0, "READ" );
   if (!f0) {
      cout << "*** Error: could not retrieve histogram: " << hname0 << " in file: " << f0->GetName() 
           << " ==> abort macro execution" << endl;
      return;
   }
   
   TFile* f1;
   TFile* f2;
   if(showfixSigXSecBand){
      cout << "--- Reading root base file: " << fname1 << endl;
      f1 = TFile::Open( fname1, "READ" );
      cout << "--- Reading root base file: " << fname2 << endl;
      f2 = TFile::Open( fname2, "READ" );

      if(!f1 || !f2){
         cout << "*** Error: could not open in files: " << f1->GetName() <<" or "<< f2->GetName() 
              << " ==> abort macro execution" << endl;
         return;
      }
   }
   
   TH2F* histecls = (TH2F*)f0->Get( "sigp1expclsf" ); 
   TH2F* histocls = (TH2F*)f0->Get( "sigp1clsf" ); 
   if (histecls!=0) histecls->SetDirectory(0);
   if (histocls!=0) histocls->SetDirectory(0);
   
   // in case we use external expectation!
   TFile* f3 = TFile::Open( fname3, "READ" );
   TH2F* histe(0);
   if (f3) { histe = (TH2F*)f3->Get( hname0 ); }
   TH2F* histe_u1s(0);
   if (f3) { histe_u1s = (TH2F*)f3->Get( hname3 ); }
   TH2F* histe_d1s(0);
   if (f3) { histe_d1s = (TH2F*)f3->Get( hname5 ); }
   
   if (f3) {
      if (histecls!=0) { delete histecls; histecls=0; }
      histecls = (TH2F*)f3->Get( "sigp1expcls" );
      if (histecls!=0) histecls->SetDirectory(0);
      else {
        histecls = (TH2F*)f3->Get( "sigp1expclsf" );
        if (histecls!=0) histecls->SetDirectory(0);
      }
   }

   // check m0m12msqmgl
   //TFile* f6;
   //TString fname6="/afs/cern.ch/atlas/groups/susy/SignalCrossSectionsUncert/ModelSpecific/SignalUncertainties-MSUGRA-mc12.root";
   //cout << "--- Reading root base file: " << fname6 << endl;
   //f6 = TFile::Open( fname6, "READ" );

   //TTree *SignalUncertainties = (TTree*)f6->Get("SignalUncertainties");
   //SignalUncertainties->ls();
   //Int_t nmass =SignalUncertainties->GetEntries();
   //SignalUncertainties->Show(10);
   //Float_t mass1, mass2;
   //Float_t m0, m12;
   //Int_t finalState;
   //SignalUncertainties->SetBranchAddress("mass1",&mass1);
   //SignalUncertainties->SetBranchAddress("mass2",&mass2);
   //SignalUncertainties->SetBranchAddress("m0",&m0);
   //SignalUncertainties->SetBranchAddress("m12",&m12);
   //SignalUncertainties->SetBranchAddress("finalState",&finalState);
   //ofstream fout;
   //fout.open("test.data", ios::out);
   //for(Int_t i=0; i<nmass; i++){
      //SignalUncertainties->GetEntry(i);
      //SignalUncertainties->Scan("mass1:mass2:m0:m12","finalState==1");
      //if (finalState==1)      fout<<m0<<"  "<<m12 <<"  "<<mass1 <<"  "<<mass2<<endl;
   //}
   //fout.close();
   
   bool extExpectation = (f3!=0) ;
   
   TH2F* hist0 = (TH2F*)f0->Get( hname0 );
   TH2F* hist1 = (TH2F*)f0->Get( hname1 );
   TH2F* hist3 = (TH2F*)f0->Get( hname3 );
   TH2F* hist5 = (TH2F*)f0->Get( hname5 );
   TH2F* hist6 = (TH2F*)f0->Get( hname6 );
   
   if (hist0!=0) hist0->SetDirectory(0);
   if (hist1!=0) hist1->SetDirectory(0);
   if (hist3!=0) hist3->SetDirectory(0);
   if (hist5!=0) hist5->SetDirectory(0);
   if (hist6!=0) hist6->SetDirectory(0);
   f0->Close();

   TH2F* histe_esigxsp1s = (TH2F*)f1->Get( hname0 ); 
   TH2F* histe_esigxsm1s = (TH2F*)f2->Get( hname0 ); 

   if (histe_esigxsp1s!=0) histe_esigxsp1s->SetDirectory(0);
   if (histe_esigxsm1s!=0) histe_esigxsm1s->SetDirectory(0);

   TH2F* contour_esigxsp1s
      = ( histe_esigxsp1s!=0 ? FixAndSetBorders( *histe_esigxsp1s, "contour_esigxsp1s", "contour_esigxsp1s", 0 ) : 0);
   TH2F* contour_esigxsm1s
      = ( histe_esigxsm1s!=0 ? FixAndSetBorders( *histe_esigxsm1s, "contour_esigxsm1s", "contour_esigxsm1s", 0 ) : 0);
   
   TH2F* contour         = ( hist1!=0 ? FixAndSetBorders( *hist1, "contour", "contour", 0 ) : 0);
   TH2F* contour_obs     = ( hist0!=0 ? FixAndSetBorders( *hist0, "contour_obs", "contour_obs") : 0 );
   
   TH2F* contour_ep1s    = ( hist3!=0 ? FixAndSetBorders( *hist3, "contour", "contour", 0 ) : 0 );
   TH2F* contour_em1s    = ( hist5!=0 ? FixAndSetBorders( *hist5, "contour", "contour", 0 ) : 0 );

   // For Band
   TGraph* gr_contour_ep1s = ContourGraph( contour_ep1s )->Clone(); 
   TGraph* gr_contour_em1s = ContourGraph( contour_em1s )->Clone(); 
   
   TH2F* contour_exp(0);
   if (histe!=0)     { contour_exp     = FixAndSetBorders( *histe, "contour_exp", "contour_exp", 0 ); } 
   TH2F* contour_au1s(0);
   if (histe_u1s!=0) {  contour_au1s   = FixAndSetBorders( *histe_u1s, "contour", "contour", 0 ); }
   TH2F* contour_ad1s(0);
   if (histe_d1s!=0) {  contour_ad1s   = FixAndSetBorders( *histe_d1s, "contour", "contour", 0 ); }
   
   
   TH2F* contour_expcls(0);
   if (histecls!=0)     { contour_expcls     = FixAndSetBorders( *histecls, "contour_expcls", "contour_expcls", 0 ); }
   TH2F* contour_obscls(0);
   if (histocls!=0)     { contour_obscls     = FixAndSetBorders( *histocls, "contour_obscls", "contour_obscls", 0 ); }

   if (contour_obs==0) { 
      cout << "contour is zero" << endl;
      return;
   }


   
   // set text style
   gStyle->SetPaintTextFormat(".2g");
   if (hist1!=0) hist1->SetMarkerStyle(21);
   if (hist1!=0) hist1->SetMarkerSize(1.5);
   Float_t nsigmax(0)
      if (hist1!=0) nsigmax = hist1->GetMaximum();
   
   // --- draw
   
   // create canvas
   TCanvas* c = new TCanvas( "c", "A scan of m_{0} versus m_{12}", 0, 0, 
                             CombinationGlob::StandardCanvas[0], CombinationGlob::StandardCanvas[1] );  
  //c->SetGrayscale();
  
  // create and draw the frame
  //TH2F *frame = new TH2F("frame", "m_{0} vs m_{12} - ATLAS work in progress", 100, 100., 1400., 100, 115., 500. );
  TH2F *frame = new TH2F("frame", "m_{0} vs m_{12} - ATLAS work in progress", 100, 115., 3500., 100, 300., 800. );
  //TH2F *frame = new TH2F("frame", "m_{0} vs m_{12} - ATLAS work in progress", 100, 100., 600., 100, 240., 500. );
  
  // set common frame style
  CombinationGlob::SetFrameStyle2D( frame, 1.0 ); // the size (scale) is 1.0
  
  frame->SetXTitle( "m_{0} [GeV]" );
  frame->SetYTitle( "m_{1/2} [GeV]" );
  frame->GetYaxis()->SetTitleOffset(1.35);

  //frame->SetTextFont( 42 );
  frame->GetXaxis()->SetTitleFont( 42 );
  frame->GetYaxis()->SetTitleFont( 42 );
  frame->GetXaxis()->SetLabelFont( 42 );
  frame->GetYaxis()->SetLabelFont( 42 );

  frame->GetXaxis()->SetTitleSize( 0.04 );
  frame->GetYaxis()->SetTitleSize( 0.04 );
  frame->GetXaxis()->SetLabelSize( 0.04 );
  frame->GetYaxis()->SetLabelSize( 0.04 );

  frame->Draw();
    
  const int nsig(3);
  //TH2F *chist[3];
  // draw contours
  //!instead of printing sigma in 68% 95% 98% levels now printing +1 sigma deviations 
  //for (Int_t nsigma=1; nsigma<=nsig; nsigma++)
  //  DrawContourSameColor( contour, nsigma, "blue", kFALSE, (nsigma==1?inverse:0) ) ;

  TString basecolor="yellow";
  Int_t nsigma=2;

  //  TLegend *leg = new TLegend(0.7,0.77,0.95,0.915);
  TLegend *leg = new TLegend(0.64,0.52,0.92,0.915);//(0.565,0.47,0.925,0.915);//(0.59,0.47,0.92,0.915);

  leg->SetTextSize( CombinationGlob::DescriptionTextSize );
  leg->SetTextSize( 0.03 );
  leg->SetTextFont( 42 );
  leg->SetFillColor( 0 );
  leg->SetFillStyle(1001);
  
  // add squark, gluino mass contour lines HERE (TILL)
  TFile* f4 = TFile::Open( fnameMass, "READ" );
  TH2F* histSq = (TH2F*)f4->Get( "mSugraGrid_squarkMasses" );
  TH2F* histGl = (TH2F*)f4->Get( "mSugraGrid_gluinoMasses" );
  histSq->SetDirectory(0);
  histGl->SetDirectory(0);
  f4->Close();

  TH2F* histSquarkMass   = FixAndSetBorders( *histSq, "SquarkMass", "SquarkMass", 10000 );
  TH2F* histGluinoMass   = FixAndSetBorders( *histGl, "GluinoMass", "GluinoMass", 10000 );
  
//  DrawContourMassLine( histSquarkMass, 400.0 );
//  DrawContourMassLine( histSquarkMass, 500.0 );
  DrawContourMassLine( histSquarkMass, 600.0 );
//  DrawContourMassLine( histSquarkMass, 700.0 );
  DrawContourMassLine( histSquarkMass, 800.0 , 17);
//  DrawContourMassLine( histSquarkMass, 900.0 );
  DrawContourMassLine( histSquarkMass, 1000.0 );  
//  DrawContourMassLine( histSquarkMass, 1100.0 ); 
  DrawContourMassLine( histSquarkMass, 1200.0 , 17);
//  DrawContourMassLine( histSquarkMass, 1300.0 );    
  DrawContourMassLine( histSquarkMass, 1400.0 );
//  DrawContourMassLine( histSquarkMass, 1500.0 );
  DrawContourMassLine( histSquarkMass, 1600.0 , 17);
//  DrawContourMassLine( histSquarkMass, 1700.0 );
  DrawContourMassLine( histSquarkMass, 1800.0 );
//  DrawContourMassLine( histSquarkMass, 1900.0 );
  DrawContourMassLine( histSquarkMass, 2000.0 , 17);  
//  DrawContourMassLine( histSquarkMass, 2100.0 ); 
  DrawContourMassLine( histSquarkMass, 2200.0 );  
//  DrawContourMassLine( histSquarkMass, 2300.0 );     
  DrawContourMassLine( histSquarkMass, 2400.0 , 17);
//  DrawContourMassLine( histSquarkMass, 2500.0 );
  DrawContourMassLine( histSquarkMass, 2600.0 );
//  DrawContourMassLine( histSquarkMass, 2700.0 );
  DrawContourMassLine( histSquarkMass, 2800.0 , 17);
//  DrawContourMassLine( histSquarkMass, 2900.0 );
  DrawContourMassLine( histSquarkMass, 3000.0 );   
//  DrawContourMassLine( histSquarkMass, 3100.0 ); 
  DrawContourMassLine( histSquarkMass, 3200.0 , 17);  
//  DrawContourMassLine( histSquarkMass, 2300.0 );     
  DrawContourMassLine( histSquarkMass, 3400.0 );
//  DrawContourMassLine( histSquarkMass, 3500.0 );
//  DrawContourMassLine( histSquarkMass, 3600.0 , 17);
//  DrawContourMassLine( histSquarkMass, 3700.0 );
//  DrawContourMassLine( histSquarkMass, 3800.0 );
//  DrawContourMassLine( histSquarkMass, 3900.0 );
//  DrawContourMassLine( histSquarkMass, 4000.0 );        

  DrawContourMassLine( histGluinoMass, 400.0 );
  DrawContourMassLine( histGluinoMass, 500.0 , 17);
  DrawContourMassLine( histGluinoMass, 600.0 );
  DrawContourMassLine( histGluinoMass, 700.0 , 17);
  DrawContourMassLine( histGluinoMass, 800.0 );
  DrawContourMassLine( histGluinoMass, 900.0 , 17);
  DrawContourMassLine( histGluinoMass, 1000.0 );  
  DrawContourMassLine( histGluinoMass, 1100.0 , 17);  
  DrawContourMassLine( histGluinoMass, 1200.0 );  
  DrawContourMassLine( histGluinoMass, 1300.0 , 17);      
  DrawContourMassLine( histGluinoMass, 1400.0 );
  DrawContourMassLine( histGluinoMass, 1500.0 , 17);
  DrawContourMassLine( histGluinoMass, 1600.0 );
//  DrawContourMassLine( histGluinoMass, 1700.0 );
//  DrawContourMassLine( histGluinoMass, 1800.0 );
//  DrawContourMassLine( histGluinoMass, 1900.0 );
//  DrawContourMassLine( histGluinoMass, 2000.0 );  
//  DrawContourMassLine( histGluinoMass, 2100.0 ); 

  // find gluino ~ squark mass exclusion limit
  //DrawContourMassLine( histSquarkMass, 820.0 );
  //DrawContourMassLine( histGluinoMass, 820.0 );

/*  TLatex * s400 = new TLatex( 140, 167 , "#tilde{q} (400 GeV)" );
  s400->SetTextAlign( 11 );
  s400->SetTextSize( 0.025 );
  s400->SetTextColor( TColor::GetColor("#dddddd") );
  s400->Draw();*/
/*  TLatex * s500 = new TLatex( 150, 220, "#tilde{q} (500 GeV)" );
  s500->SetTextAlign( 11 );
  s500->SetTextSize( 0.025 );
  s500->SetTextColor( TColor::GetColor("#dddddd") );
  s500->Draw();*/
/*
  TLatex * s600 = new TLatex( 340, 230, "#tilde{q} (600 GeV)" );
  s600->SetTextAlign( 11 );
  s600->SetTextAngle(-60);
  s600->SetTextSize( 0.025 );
  s600->SetTextColor( 16 ); //12
  s600->Draw();
*/
  /*TLatex * s700 = new TLatex( 545, 315, "#tilde{q} (700 GeV)" );
  s700->SetTextAlign( 11 );
  s700->SetTextSize( 0.025 );
  s700->SetTextColor( TColor::GetColor("#dddddd") );
  s700->Draw();*/
  /*TLatex * s800 = new TLatex( 250, 270, "#tilde{q} (800 GeV)" );
  s800->SetTextAlign( 11 );
  s800->SetTextSize( 0.025 );
  s800->SetTextColor( 203 );
  s800->Draw();*/
  /*
  TLatex * s900 = new TLatex( 330, 400, "#tilde{q} (900 GeV)" );
  s900->SetTextAlign( 11 );
  s900->SetTextSize( 0.025 );
  s900->SetTextColor( TColor::GetColor("#dddddd") );
  s900->Draw();*/
   TLatex * s1000 = new TLatex( 550, 408, "#tilde{q} (1000 GeV)" );
  s1000->SetTextAlign( 11 );
  s1000->SetTextAngle(-60);
  s1000->SetTextSize( 0.025 );
  s1000->SetTextColor( 16 );
  s1000->Draw(); 
   TLatex * s1400 = new TLatex( 790, 580, "#tilde{q} (1400 GeV)" );
  s1400->SetTextAlign( 11 );
  s1400->SetTextAngle(-60);
  s1400->SetTextSize( 0.025 );
  s1400->SetTextColor( 16 );
  s1400->Draw();   

  /*TLatex * g400 = new TLatex( 1100, 140, "#tilde{g} (400 GeV)" );
  g400->SetTextAlign( 11 );
  g400->SetTextSize( 0.025 );
  g400->SetTextColor( 203 );
  g400->Draw();*/
  /*TLatex * g500 = new TLatex( 1000, 185, "#tilde{g} (500 GeV)" );
  g500->SetTextAlign( 11 );
  g500->SetTextSize( 0.025 );
  g500->SetTextColor( TColor::GetColor("#dddddd") );
  g500->Draw();*/
  TLatex * g600 = new TLatex( 1100, 225, "#tilde{g} (600 GeV)" );
  g600->SetTextAlign( 11 );
  g600->SetTextAngle(-4);
  g600->SetTextSize( 0.025 );
  g600->SetTextColor( 16 );
  g600->Draw();
  /*TLatex * g900 = new TLatex( 550, 380, "#tilde{g} (900 GeV)" );
  g900->SetTextAlign( 11 );
  g900->SetTextSize( 0.025 );
  g900->SetTextColor( TColor::GetColor("#dddddd") );
  g900->Draw();*/
  TLatex * g800 = new TLatex( 690, 330, "#tilde{g} (800 GeV)" );
  g800->SetTextAlign( 11 );
  g800->SetTextSize( 0.025 );
  g800->SetTextColor( 16 );
  //g800->Draw();
  TLatex * g1000 = new TLatex( 1400, 399, "#tilde{g} (1000 GeV)" );
  g1000->SetTextAlign( 11 );
  g1000->SetTextAngle(-5); 
  g1000->SetTextSize( 0.025 );
  g1000->SetTextColor( 16 );
  g1000->Draw();
  TLatex * g1200 = new TLatex( 1550, 489, "#tilde{g} (1200 GeV)" );
  g1200->SetTextAlign( 11 );
  g1200->SetTextAngle(-6); 
  g1200->SetTextSize( 0.025 );
  g1200->SetTextColor( 16 );
  //g1200->Draw();  
  TLatex * g1400 = new TLatex( 1650, 582, "#tilde{g} (1400 GeV)" );
  g1400->SetTextAlign( 11 );
  g1400->SetTextAngle(-6); 
  g1400->SetTextSize( 0.025 );
  g1400->SetTextColor( 16 );
  g1400->Draw();
  
  // island hacks
  if (true && channel==4) { // muon fixes 
    cout << "removing islands in muon channel ..." << endl;
    // contour line is drawn for values at 1.64485
    TAxis* ax = contour_obs->GetXaxis();
    TAxis* ay = contour_obs->GetYaxis();

    TH2F* contour_fix = contour_em1s;

    for (int xbin = 1; xbin <= contour_fix->GetNbinsX(); xbin++) {
      for (int ybin = 1; ybin <= contour_fix->GetNbinsY(); ybin++) {
	// island 1
	if ( ax->GetBinCenter( xbin) > 1350.  && ax->GetBinCenter( xbin) < 1500. && ay->GetBinCenter( ybin) < 130. && ay->GetBinCenter( ybin) > 89. ) {
	  cout << "Found spot here: " << xbin << " (" << ax->GetBinCenter( xbin)  << "), "
	       << ybin << " (" << ay->GetBinCenter( ybin) << "), "
	       << " value: " << contour_fix->GetBinContent(xbin,ybin) <<   endl;
	  cout << "   HACK : Setting above point by hand to 1.65 (!)" << endl;
	  if (contour_fix->GetBinContent(xbin,ybin)<1.65) contour_fix->SetBinContent(xbin, ybin, 1.66);
	}

      }
    }

  } 
  if (false && channel==1) { // electron

    cout << "removing islands in electron channel ..." << endl;
    // contour line is drawn for values at 1.64485
    TAxis* ax = contour_obs->GetXaxis();
    TAxis* ay = contour_obs->GetYaxis();

    contour_em1s

    for (int xbin = 1; xbin <= contour_obs->GetNbinsX(); xbin++) {
      for (int ybin = 1; ybin <= contour_obs->GetNbinsY(); ybin++) {
	// island 2
	if ( ax->GetBinCenter( xbin) > 420. && ax->GetBinCenter( xbin) < 480. &&
	     ay->GetBinCenter( ybin) > 140. && ay->GetBinCenter( ybin) < 160. ) {
	  cout << "Found spot here: " << xbin << " (" << ax->GetBinCenter( xbin)  << "), "
	       << ybin << " (" << ay->GetBinCenter( ybin) << "), "
	       << " value: " << contour->GetBinContent(xbin,ybin) <<   endl;
	  cout << "   HACK : Setting above point by hand to 1.50 (!)" << endl;
	  contour->SetBinContent(xbin, ybin, 1.50);
	}
      }
    }

  }
void makePlots (string configFilePath){
  if ((  inputRootFileNum.size() > 0 )) 
    {
      for (int i=0; i<numHistos; i++) 
        {
          double y_max = 0.0;	 
          TCanvas *c = new TCanvas(theHistNameStrings.at(i).c_str(), "", 81,58,500,602);
 
          TH1* h_num;        // histograms for Numerator
          TH1* h_den;        // histohrams for Denominator
          int whichHisto = 0;

	  TMultiGraph *mg = new TMultiGraph();
          for (int j=0;j<inputRootFileNum.size();j++)
	    {
             whichHisto=j*numHistos; 
	      
	      int a = 0;
	      bool foundHisto = false;
	      if (theHistNameStrings.at(i) == theHistNameStrings.at(i+whichHisto)) 
		{
		  foundHisto=true; 
		  a=i;
		}
	      else 
		{
		  for (a = 0; a < numHistos; a++)
		    {
		      if (theHistNameStrings.at(i) == theHistNameStrings.at(a+whichHisto))
			{
			  foundHisto = true;
			  break;
			}
		    }
		}
	      //-----------------------------------------------------------
	      string hist2name = listHistosNum->At(a+whichHisto)->GetName();
	      if (foundHisto == true)
		{
                  h_num = (TH1*)listHistosNum->At(i+whichHisto);
                  h_den = (TH1*)listHistosDen->At(a+whichHisto);

                  TH1F* H_bins_num;
                  TH1F* H_bins_den;
                  int id = 0;
                  for (int k = 0; k < inputXtitle.size(); k++)
                   {
                     if (hist2name == inputHistoName.at(k)){
                      id=k;
                    }
                   }
                  if (inputdifferentBinSize.at(id)==1){
                     int Nbins = h_num->GetXaxis()->GetNbins();
                     int arrayD = (int*)inputNbins.at(id);
                     float *BINS = new float [arrayD];
                     for (int b = 0; b <= arrayD; b++ )
                       {
                          if (b < (arrayD-1))
                           {
                             BINS[b] = (float)b*(h_num->GetXaxis()->GetBinWidth(b));
                           }
                          else {
                             BINS[b] = (float)inputBinSize.at(id);
                          }
                       }
                     H_bins_num = new TH1F("h_NUM", "h_NUM", inputNbinMax.at(id), BINS);
                     H_bins_den = new TH1F("h_DEN", "h_DEN", inputNbinMax.at(id), BINS);
                     for (int b = 0; b <= (Nbins+1); b++ )
                       {
                         H_bins_num->SetBinContent(b, h_num->GetBinContent(b));
                         H_bins_den->SetBinContent(b, h_den->GetBinContent(b));
                       }
                  }

                  if (inputdifferentBinSize.at(id)==1){
                     TGraphAsymmErrors* gr1 = new TGraphAsymmErrors( H_bins_num, H_bins_den, "b(1,1) mode" );
                  } else{
                    cout << "h_num "<<h_num->GetXaxis()->GetNbins() << "  h_den "<<h_den->GetXaxis()->GetNbins()<<endl;
                    cout << "h_num "<<h_num->Integral() << "  h_den "<<h_den->Integral()<<endl;
                    TGraphAsymmErrors* gr1 = new TGraphAsymmErrors( h_num, h_den, "b(1,1) mode" );
                  }
		  int setcolor = inputColor.at(j);
		  int marker   = inputMarkerStyle.at(j);
                  string processlegend = (inputLegend.at(j)).c_str();
                  gr1->SetMarkerStyle(marker);
                  gr1->SetMarkerColor(setcolor);
                  gr1->SetTitle(processlegend.c_str());
                  gr1->SetFillStyle(0);
                  mg->SetTitle(hist2name.c_str());
                  mg->Add(gr1);
		}// close if (foundHisto)
 
	      c->cd();
 	      c->SetGrid(); 
	    } // close for loop inputRootFile

          mg->Draw("APsame");
          for (int k = 0; k < inputXtitle.size(); k++)
           {
              if (hist2name == inputHistoName.at(k))
               {
                 mg->GetXaxis()->SetTitle((inputXtitle.at(k)).c_str());
                 mg->GetYaxis()->SetTitle((inputYtitle.at(k)).c_str());
                 mg->GetXaxis()->SetTitleSize(0.05);
                 mg->GetYaxis()->SetTitleSize(0.05);
                 mg->SetMaximum((float)inputYrangeMax.at(k));
               }
           }
          c->Update();
          TLegend* legend = c->BuildLegend(0.55,0.8,0.90,0.94);
          //TLegend *legend = new TLegend(0.2, 0.85-.035*inputLegend.size(), 0.5, 0.90,NULL,"brNDC");
          legend->SetTextFont(42);
          legend->SetLineColor(1);
          legend->SetLineStyle(1);
          legend->SetLineWidth(1);
          legend->SetFillColor(0);
          legend->SetFillStyle(1001);
          legend->SetBorderSize(0);
          legend->SetFillColor(kWhite);

	  TFile *hfile = (TFile*)gROOT->FindObject(HistosOutputRootFile.c_str());
	  if (hfile) {hfile->Close();}
	  hfile = new TFile(HistosOutputRootFile.c_str(),"UPDATE");

          for (int o = 0; o < inputHistoName.size(); o++)
             {
                if ( c->GetName() == inputHistoName.at(o) )
                  {
                     string save = configFilePath+"/"+inputHistoName.at(o)+".pdf";  
                     c->SaveAs(save.c_str());
                     c->Write();    
                     break;
                  }
             }

	  hfile->Close();
          c->Close();
	  
	}  // close foor loop numHistos     
      
    } // close if numHistos % inputRootFile.size() == 0
} // close  makePlots function