示例#1
0
// Draw statistics info above plot
void DrawCMSLabels(double lumi, double energy, double textSize) {

  //const char *text = "%2.1f #times 10^{6} clusters (fiducial) (%1.1f GeV)";
  const char *text;
  if(lumi > 10000000) {
    lumi /= 10000000;
    text = "%2.1f #times 10^{7} tracks (%1.1f GeV)";
  }
  else {
    lumi /= 1000000;
    text = "%2.1f #times 10^{6} tracks (%1.1f GeV)";
  }
    
  TPaveText *label = new TPaveText();
  label->SetX1NDC(gStyle->GetPadLeftMargin());
  label->SetY1NDC(1.0-gStyle->GetPadTopMargin());
  label->SetX2NDC(1.0-gStyle->GetPadRightMargin());
  label->SetY2NDC(1.0);
  label->SetTextFont(42);
  label->AddText(Form(text, lumi, energy));
  label->SetFillStyle(0);
  label->SetBorderSize(0);
  if (textSize!=0) label->SetTextSize(textSize);
  label->SetTextAlign(32);
  label->Draw("same");
}
示例#2
0
void drawMassPlot( const std::string& dirName, const std::string& category, TH1D* h1_data, TH1D* h1_thq, TH1D* h1_ggh, TH1D* h1_vbf, TH1D* h1_wzh, TH1D* h1_tth, const std::string& suffix ) {

  DrawBase* db = new DrawBase("mgg");
  db->set_lumi(19700.);
  TFile* dummyFile = TFile::Open("dummy.root", "recreate");
  db->add_dataFile(dummyFile, "Data");


  TGraphAsymmErrors* gr_data = fitTools::getGraphPoissonErrors( h1_data, false );
  gr_data->SetMarkerStyle(20);  
  gr_data->SetMarkerSize(1.3);  

  
  h1_thq->SetFillColor(kWhite);
  h1_tth->SetFillColor(kGray);
  h1_wzh->SetFillColor(28);
  h1_vbf->SetFillColor(90);
  h1_ggh->SetFillColor(46);

  h1_thq->SetLineColor(kBlack);
  h1_tth->SetLineColor(kBlack);
  h1_wzh->SetLineColor(kBlack);
  h1_vbf->SetLineColor(kBlack);
  h1_ggh->SetLineColor(kBlack);


  TString category_tstr(category);
  bool isLeptonic = category_tstr.Contains("leptonic");

  THStack stack;
  if( !isLeptonic ) {
    stack.Add(h1_ggh);
    stack.Add(h1_vbf);
  }
  stack.Add(h1_wzh);
  stack.Add(h1_tth);
  stack.Add(h1_thq);



  std::string channelName_legend = (isLeptonic) ? "Leptonic Channel" : "Hadronic Channel";

  float yMin_leg = (isLeptonic) ? 0.9-4.*0.07 : 0.9-6.*0.07;
  TLegend* legend = new TLegend( 0.62, yMin_leg, 0.9, 0.92, channelName_legend.c_str() );
  legend->SetTextFont(42);
  legend->SetFillColor(kWhite);
  legend->SetTextSize(0.038);
  legend->SetTextColor(kBlack);
  if( useCS )
    legend->AddEntry( gr_data, "Data CS", "P" );
  else
    legend->AddEntry( gr_data, "Data", "P" );
  legend->AddEntry( h1_thq, "tHq (Ct = -1)", "F" );
  legend->AddEntry( h1_tth, "ttH (125)", "F" );
  legend->AddEntry( h1_wzh, "VH (125)", "F" );
  if( !isLeptonic ) {
    legend->AddEntry( h1_vbf, "VBF H (125)", "F" );
    legend->AddEntry( h1_ggh, "ggF H (125)", "F" );
  }


  float yMax = 0.;
  float yMax_data = h1_data->GetMaximum();
  if( yMax_data>0. ) {
    if( yMax_data < 1.5 ) yMax=3.5;
    else if( yMax_data < 2.5 ) yMax=6.;
    else                       yMax=yMax_data*2.;
  } else {
    float yMax_mc = h1_thq->GetMaximum()*1.2;
    yMax = 1.8*yMax_mc;
  }


  TH2D* h2_axes = new TH2D( "axes", "", 10, 100., 180., 10, 0., yMax);
  h2_axes->SetXTitle( "Diphoton Mass [GeV]");
  h2_axes->SetYTitle( "Events / (1 GeV)");

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


  TPaveText* labelTop = db->get_labelTop();

  h2_axes->Draw();
  legend->Draw("same");   
  labelTop->Draw("same");
  stack.Draw("histo same");

  if( BLINDED ) {
    TLine* lineBlind_low = new TLine( 115., 0., 115., yMax );
    TLine* lineBlind_hi  = new TLine( 135., 0., 135., yMax );
    lineBlind_low->SetLineColor(46);
    lineBlind_hi ->SetLineColor(46);
    lineBlind_low->SetLineStyle(2);
    lineBlind_hi ->SetLineStyle(2);
    lineBlind_low->SetLineWidth(2);
    lineBlind_hi ->SetLineWidth(2);
    lineBlind_low->Draw("same");
    lineBlind_hi ->Draw("same");
  }

  gr_data->Draw("p same");

  gPad->RedrawAxis();


  std::string canvasName = dirName + "/" + category + "/mggPlot_" + category;
  if( suffix!="" ) canvasName = canvasName + "_" + suffix;
  std::string canvasName_eps = canvasName + ".eps";
  std::string canvasName_png = canvasName + ".png";

  c1->SaveAs(canvasName_eps.c_str());
  c1->SaveAs(canvasName_png.c_str());

  delete c1;
  delete h2_axes;
  delete legend;

}
void plotBuilding(TCanvas *canvas, TH1F **s, TH1F **r, int n,TText* te,
		  char * option, double startingY, double startingX = .1,bool fit = false, unsigned int logx=0){
  canvas->Divide(2,(n+1)/2); //this should work also for odd n
  for(int i=0; i<n;i++){
    s[i]->SetMarkerStyle(20);
    r[i]->SetMarkerStyle(21);
    s[i]->SetMarkerColor(2);
    r[i]->SetMarkerColor(4);
    s[i]->SetMarkerSize(0.7);
    r[i]->SetMarkerSize(0.7);
    s[i]->SetLineColor(1);
    r[i]->SetLineColor(1);
    s[i]->SetLineWidth(1);
    r[i]->SetLineWidth(1);

    TPad *pad=(TPad*)canvas->cd(i+1);
    setStats(s[i],r[i], -1, 0, false);
    if((logx>>i)&1)pad->SetLogx();
    // mov histo title for steps histos // this didn't work
    //if(startingY == -69) {
    //  gROOT->ForceStyle();
    //  if(i==2 || i==3) {
    //    gStyle->SetTitleX(0.91);
    //    gStyle->SetTitleY(0.01);
    //  } else {
    //    gStyle->SetTitleX(0.01);
    //    gStyle->SetTitleY(0.99);
    //  }
    //}
    r[i]->Draw();
    // mov histo title for steps histos
    if(startingY == -69 && (i==2 || i==3)) {
      if (i==2) TPaveText *pt = new TPaveText(0.01,0.00,0.7,0.06,"NDC");
      else      TPaveText *pt = new TPaveText(0.01,0.00,0.6,0.06,"NDC");
      pt->SetName("title");  // This tells the histogram to NOT display its title at all
      pt->SetBorderSize(1);
      pt->SetFillColor(0);
      text = pt->AddText(r[i]->GetTitle());
      pt->Draw();
    }
    s[i]->Draw("sames");
  }

//   //setStats(r1,s1, startingY, startingX, fit);
//   canvas->cd(1);
//   setStats(s1,r1, -1, 0, false);
//   r1->Draw();
//   s1->Draw("sames");

//   canvas->cd(2);
//   setStats(s2,r2, -1, 0, false);
//   r2->Draw();
//   s2->Draw("sames");

//   canvas->cd(3);
//   setStats(r3,s3, -1, 0, false);
//   r3->Draw();
//   s3->Draw("sames");

//   canvas->cd(4);
//   if(logx)gPad->SetLogx();
//   setStats(s4,r4, 0.6, 0.65, false);
//   r4->Draw();
//   s4->Draw("sames");

//   canvas->cd(5);
//   setStats(r5,s5, -1, 0, false);
//   r5->Draw();
//   s5->Draw("sames");


//   canvas->cd(6);
//   setStats(s6,r6, 0.6, 0.65, false);
//   r6->Draw();
//   s6->Draw("sames");
}
示例#4
0
文件: style.C 项目: renqgl90/Seeding
void style()
{
  ////////////////////////////////////////////////////////////////////
  // PURPOSE:
  //
  // This macro defines a reasonable style for (black-and-white)
  // "publication quality" ROOT plots. The default settings contain
  // many features that are either not desirable for printing on white
  // paper or impair the general readibility of plots.
  //
  // USAGE:
  //
  // Simply include the line
  //   gROOT->ProcessLine(".x $LHCBSTYLE/root/lhcbstyle.C");
  // at the beginning of your root macro.
  //
  // SOME COMMENTS:
  //
  // Statistics and fit boxes:
  //
  // "Decorative" items around the histogram are kept to a minimum.
  // In particular there is no box with statistics or fit information.
  // You can easily change this either by editing your private copy
  // of this style file or by calls to "gStyle" in your macro.
  // For example,
  //   gStyle->SetOptFit(1011);
  // will add some fit information.
  //
  // Font:
  //
  // The font is chosen to be 62, i.e.helvetica-bold-r-normal with
  // precision 2. Font is of course a matter of taste, but most people
  // will probably agree that Helvetica bold gives close to optimal
  // readibility in presentations. It appears to be the ROOT default,
  // and since there are still some features in ROOT that simply won't
  // respond to any font requests, it is the wise choice to avoid
  // ugly font mixtures on the same plot... The precision of the font (2)
  // is chosen in order to have a rotatable and scalable font. Be sure
  // to use true-type fonts! I.e.
  // Unix.*.Root.UseTTFonts: true  in your .rootrc file.
  //
  // "Landscape histograms":
  //
  // The style here is designed for more or less quadratic plots.
  // For very long histograms, adjustements are needed. For instance,
  // for a canvas with 1x5 histograms:
  //  TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
  //  c1->Divide(1,5);
  // adaptions like the following will be needed:
  //  gStyle->SetTickLength(0.05,"x");
  //  gStyle->SetTickLength(0.01,"y");
  //  gStyle->SetLabelSize(0.15,"x");
  //  gStyle->SetLabelSize(0.1,"y");
  //  gStyle->SetStatW(0.15);
  //  gStyle->SetStatH(0.5);
  //
  ////////////////////////////////////////////////////////////////////
  /*cout << "executing lhcbStyle.C:" << endl;
    cout << "                      " << endl;
    cout << "                      " << endl;
    cout << "                         $      $   $   $$$   $    " << endl;
    cout << "                         $      $   $  $      $    " << endl;
    cout << "                         $      $$$$$  $      $$$  " << endl;
    cout << "                         $      $   $  $      $  $ " << endl;
    cout << "                         $$$$$  $   $   $$$   $$$  " << endl;
    cout << " " << endl;
    cout << "                           LHCb ROOT style file " << endl;
    cout << " " << endl;
    cout <<
    "     Problems, suggestions, contributions to [email protected]" << endl;
    cout << " " << endl;*/
  //gROOT->Reset();
  TStyle *lhcbStyle= new TStyle("lhcbStyle","Thomas personal plots style");
  // use helvetica-bold-r-normal, precision 2 (rotatable)
  Int_t lhcbFont = 62;
  // line thickness
  Double_t lhcbWidth = 3.00;
  // use plain black on white colors
  lhcbStyle->SetFrameBorderMode(0);
  lhcbStyle->SetCanvasBorderMode(0);
  lhcbStyle->SetPadBorderMode(0);
  lhcbStyle->SetPadColor(0);
  lhcbStyle->SetCanvasColor(0);
  lhcbStyle->SetStatColor(0);
  lhcbStyle->SetPalette(1);
  //lhcbStyle->SetTitleColor(0);
  //lhcbStyle->SetFillColor(0);
  // set the paper & margin sizes
  lhcbStyle->SetPaperSize(20,26);
  lhcbStyle->SetPadTopMargin(0.05);
  lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots!!
  lhcbStyle->SetPadBottomMargin(0.16);
  lhcbStyle->SetPadLeftMargin(0.14);
  // use large fonts
  lhcbStyle->SetTextFont(lhcbFont);
  lhcbStyle->SetTextSize(0.08);
  lhcbStyle->SetLabelFont(lhcbFont,"x");
  lhcbStyle->SetLabelFont(lhcbFont,"y");
  lhcbStyle->SetLabelFont(lhcbFont,"z");
  lhcbStyle->SetLabelSize(0.03,"x");
  lhcbStyle->SetLabelSize(0.03,"y");
  lhcbStyle->SetLabelSize(0.03,"z");
  lhcbStyle->SetTitleFont(lhcbFont);
  lhcbStyle->SetTitleSize(0.06,"x");
  lhcbStyle->SetTitleSize(0.06,"y");
  lhcbStyle->SetTitleSize(0.06,"z");
  // use bold lines and markers
  lhcbStyle->SetLineWidth(lhcbWidth);
  lhcbStyle->SetFrameLineWidth(lhcbWidth);
  lhcbStyle->SetHistLineWidth(lhcbWidth);
  lhcbStyle->SetFuncWidth(lhcbWidth);
  lhcbStyle->SetGridWidth(lhcbWidth);
  lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
  //lhcbStyle->SetMarkerStyle(15);
  lhcbStyle->SetMarkerStyle(20);
  lhcbStyle->SetMarkerSize(1.2);
  // label offsets
  lhcbStyle->SetLabelOffset(0.020);
  // by default, do not display histogram decorations:
  lhcbStyle->SetOptStat(0);
  lhcbStyle->SetOptStat(1110);  // show only nent, mean, rms
  //lhcbStyle->SetOptTitle(0);
  lhcbStyle->SetOptFit(0);
  //lhcbStyle->SetOptFit(1011); // show probability, parameters and errors
  // look of the statistics box:
  lhcbStyle->SetStatBorderSize(1);
  lhcbStyle->SetStatFont(lhcbFont);
  lhcbStyle->SetStatFontSize(0.05);
  lhcbStyle->SetStatX(0.9);
  lhcbStyle->SetStatY(0.9);
  lhcbStyle->SetStatW(0.25);
  lhcbStyle->SetStatH(0.15);
  // put tick marks on top and RHS of plots
  lhcbStyle->SetPadTickX(1);
  lhcbStyle->SetPadTickY(1);
  // histogram divisions: only 5 in x to avoid label overlaps
  lhcbStyle->SetNdivisions(505,"x");
  lhcbStyle->SetNdivisions(510,"y");
  TPaveText *lhcbName = new TPaveText(0.65,0.8,0.9,0.9,"BRNDC");
  lhcbName->SetFillColor(0);
  lhcbName->SetTextAlign(12);
  lhcbName->SetBorderSize(0);
  lhcbName->AddText("LHCb");
  // TPaveText *lhcbPrelimR = new TPaveText(0.70 - lhcbStyle->GetPadRightMargin(),
  //                                        0.80 - lhcbStyle->GetPadTopMargin(),
  //                                        0.95 - lhcbStyle->GetPadRightMargin(),
  //                                        0.85 - lhcbStyle->GetPadTopMargin(),
  //                                        "BRNDC");
  // lhcbPrelimR->SetFillColor(0);
  // lhcbPrelimR->SetTextAlign(12);
  // lhcbPrelimR->SetBorderSize(0);
  // lhcbPrelimR->AddText("#splitline{LHCb}{#scale[1.0]{Preliminary}}");
  // TPaveText *lhcbPrelimL = new TPaveText(lhcbStyle->GetPadLeftMargin() + 0.05,
  //                                        0.87 - lhcbStyle->GetPadTopMargin(),
  //                                        lhcbStyle->GetPadLeftMargin() + 0.30,
  //                                        0.95 - lhcbStyle->GetPadTopMargin(),
  //                                        "BRNDC");
  // lhcbPrelimL->SetFillColor(0);
  // lhcbPrelimL->SetTextAlign(12);
  // lhcbPrelimL->SetBorderSize(0);
  // lhcbPrelimL->AddText("#splitline{LHCb}{#scale[1.0]{Preliminary}}");
  // TPaveText *lhcb7TeVPrelimR = new TPaveText(0.70 - lhcbStyle->GetPadRightMargin(),
  //                                            0.75 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            0.95 - lhcbStyle->GetPadRightMargin(),
  //                                            0.85 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            "BRNDC");
  // lhcb7TeVPrelimR->SetFillColor(0);
  // lhcb7TeVPrelimR->SetTextAlign(12);
  // lhcb7TeVPrelimR->SetBorderSize(0);
  // lhcb7TeVPrelimR->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 7 TeV Data}}");
  // TPaveText *lhcb7TeVPrelimL = new TPaveText(lhcbStyle->GetPadLeftMargin() + 0.05,
  //                                            0.78 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            lhcbStyle->GetPadLeftMargin() + 0.30,
  //                                            0.88 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            "BRNDC");
  // lhcb7TeVPrelimL->SetFillColor(0);
  // lhcb7TeVPrelimL->SetTextAlign(12);
  // lhcb7TeVPrelimL->SetBorderSize(0);
  // lhcb7TeVPrelimL->SetTextSize(0.06);
  // lhcb7TeVPrelimL->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 7 TeV Data}}");
  // TPaveText *lhcb7TeVPrelimR = new TPaveText(0.70 - lhcbStyle->GetPadRightMargin(),
  //                                            0.75 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            0.95 - lhcbStyle->GetPadRightMargin(),
  //                                            0.85 - lhcbStyle->SetPadTopMargin(0.05),
  //                                            "BRNDC");
  // lhcb7TeVPrelimR->SetFillColor(0);
  // lhcb7TeVPrelimR->SetTextAlign(12);
  // lhcb7TeVPrelimR->SetBorderSize(0);
  // lhcb7TeVPrelimR->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 900 eV Data}}");
  // TPaveText *lhcb0_9TeVPrelimL = new TPaveText(lhcbStyle->GetPadLeftMargin() + 0.05,
  //                                              0.78 - lhcbStyle->SetPadTopMargin(0.05),
  //                                              lhcbStyle->GetPadLeftMargin() + 0.30,
  //                                              0.88 - lhcbStyle->SetPadTopMargin(0.05),
  //                                              "BRNDC");
  // lhcb0_9TeVPrelimL->SetFillColor(0);
  // lhcb0_9TeVPrelimL->SetTextAlign(12);
  // lhcb0_9TeVPrelimL->SetBorderSize(0);
  // lhcb0_9TeVPrelimL->SetTextSize(0.06);
  // lhcb0_9TeVPrelimL->AddText("#splitline{#splitline{LHCb}{Preliminary}}{#scale[0.7]{#sqrt{s} = 900 GeV Data}}");
  TText *lhcbLabel = new TText();
  lhcbLabel->SetTextFont(lhcbFont);
  lhcbLabel->SetTextColor(1);
  lhcbLabel->SetTextSize(0.04);
  lhcbLabel->SetTextAlign(12);
  TLatex *lhcbLatex = new TLatex();
  lhcbLatex->SetTextFont(lhcbFont);
  lhcbLatex->SetTextColor(1);
  lhcbLatex->SetTextSize(0.04);
  lhcbLatex->SetTextAlign(12);
  gROOT->SetStyle("lhcbStyle");
  gROOT->ForceStyle();
}
示例#5
0
void PlotField2D( const TString &sim, Int_t time, Int_t index = 0, Int_t zoom=2, const TString &options="") {
  
  PlasmaGlob::Initialize();

  TString opt = options;
 
  // Palettes!
  gROOT->Macro("PlasmaPalettes.C");

  if(opt.Contains("grid")) {
    gStyle->SetPadGridX(1);
    gStyle->SetPadGridY(1);
  }

  gStyle->SetPadRightMargin(0.20);   // Margin for palettes in 2D histos
  gStyle->SetLabelFont(42,"xyz");

  // Load PData
  PData *pData = PData::Get(sim.Data());
  pData->LoadFileNames(time);
  if(!pData->IsInit()) return;


  Bool_t CYL = kFALSE;
  if(sim.Contains("cyl")) CYL = kTRUE; 
    
  Bool_t ThreeD = kFALSE;
  if(sim.Contains("3D")) ThreeD = kTRUE; 

  // Some plasma constants
  Double_t n0 = pData->GetPlasmaDensity();
  Double_t kp = pData->GetPlasmaK();
  Double_t skindepth = 1.;
  if(kp!=0.0) skindepth = 1/kp;
  Double_t E0 = pData->GetPlasmaE0();

  // Some beam properties:
  Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV;
  Float_t gamma = Ebeam / PConst::ElectronMassE;
  Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma));
  // cout << Form(" - Bunch gamma      = %8.4f", gamma ) << endl;
  // cout << Form(" - Bunch velocity   = %8.4f c", vbeam ) << endl;
  
  // Time in OU
  Float_t Time = pData->GetRealTime();
  // z start of the plasma in normalized units.
  Float_t zStartPlasma = pData->GetPlasmaStart()*kp;
  // z start of the beam in normalized units.
  Float_t zStartBeam = pData->GetBeamStart()*kp;
  
  if(opt.Contains("center")) {
    Time -= zStartPlasma;
    if(opt.Contains("comov"))      // Centers on the head of the beam.
      Time += zStartBeam;
  } 

  // Get field histos
  const Int_t Nfields = 3;
  TH2F **hE2D = new TH2F*[Nfields];
  for(Int_t i=0;i<Nfields;i++) {
    hE2D[i] = NULL;

    if(i!=index) continue;

    if(!pData->GetEfieldFileName(i))
      continue;
    
    char hName[24];
    sprintf(hName,"hE2D_%i",i);
    hE2D[i] = (TH2F*) gROOT->FindObject(hName);
    if(hE2D[i]) delete hE2D[i];

    if(!ThreeD)
      hE2D[i] = pData->GetEField(i,opt);
    else
      hE2D[i] = pData->GetEField2DSliceZY(i,-1,1);
    
    hE2D[i]->SetName(hName);   
    hE2D[i]->GetXaxis()->CenterTitle();
    hE2D[i]->GetYaxis()->CenterTitle();
    hE2D[i]->GetZaxis()->CenterTitle();
    if(opt.Contains("comov"))
      hE2D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]");
    else
      hE2D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]");
    
    if(CYL) 
      hE2D[i]->GetYaxis()->SetTitle("r [c/#omega_{p}]");
    else
      hE2D[i]->GetYaxis()->SetTitle("y [c/#omega_{p}]");
    
    if(i==0)
      hE2D[i]->GetZaxis()->SetTitle("E_{z} [E_{0}]");
    else if(i==1)
      hE2D[i]->GetZaxis()->SetTitle("E_{y} [E_{0}]");
    else if(i==2)
      hE2D[i]->GetZaxis()->SetTitle("E_{x} [E_{0}]");
  }
  
  // Tunning the Histograms
  // ---------------------
  
  // Chaning to user units: 
  // --------------------------
  
  if(opt.Contains("units") && n0) {
    
    for(Int_t i=0;i<Nfields;i++) {

      if(i!=index) continue;

      Int_t NbinsX = hE2D[i]->GetNbinsX();
      Float_t xMin = skindepth * hE2D[i]->GetXaxis()->GetXmin() / PUnits::mm;
      Float_t xMax = skindepth * hE2D[i]->GetXaxis()->GetXmax() / PUnits::mm;
      Int_t NbinsY = hE2D[i]->GetNbinsY();
      Float_t yMin = skindepth * hE2D[i]->GetYaxis()->GetXmin() / PUnits::mm;
      Float_t yMax = skindepth * hE2D[i]->GetYaxis()->GetXmax() / PUnits::mm;
      hE2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax);
      for(Int_t j=0;j<hE2D[i]->GetNbinsX();j++) {
	for(Int_t k=0;k<hE2D[i]->GetNbinsY();k++) {
	  hE2D[i]->SetBinContent(j,k, hE2D[i]->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) );
	}
      }
      
      if(CYL)
	hE2D[i]->GetYaxis()->SetTitle("r [mm]");      
      else
	hE2D[i]->GetYaxis()->SetTitle("y [mm]");      
 
      if(opt.Contains("comov"))
	hE2D[i]->GetXaxis()->SetTitle("#zeta [mm]");
      else
	hE2D[i]->GetXaxis()->SetTitle("z [mm]");
      
      if(i==0)
	hE2D[i]->GetZaxis()->SetTitle("E_{z} [GV/m]");
      else if(i==1)
	hE2D[i]->GetZaxis()->SetTitle("E_{y} [GV/m]");
      else if(i==2)
	hE2D[i]->GetZaxis()->SetTitle("E_{x} [GV/m]");
    }
    
  }


  // Change the range of z axis for the fields to be symmetric.
  Float_t Emax = hE2D[index]->GetMaximum();
  Float_t Emin = hE2D[index]->GetMinimum();
  if(Emax > TMath::Abs(Emin))
    Emin = -Emax;
  else
    Emax = -Emin;
  hE2D[index]->GetZaxis()->SetRangeUser(Emin,Emax); 

  // Plotting
  // -----------------------------------------------

  // Canvas setup
  TCanvas *C;
  if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain grahics output.
    C = new TCanvas("C","2D Electric field",1000,625);
  else
    C = new TCanvas("C","2D Electric field",800,500);

  // Palettes setup
  TExec *exField  = new TExec("exField","rbowgrayPalette->cd();");
  
  // Text objects
  TPaveText *textTime = new TPaveText(0.50,0.85,0.77,0.9,"NDC");
  PlasmaGlob::SetPaveTextStyle(textTime,32); 
  char ctext[128];
  if(opt.Contains("units") && pData->GetPlasmaDensity()) 
    sprintf(ctext,"Z = %5.1f mm", 1e3 * pData->GetPlasmaSkinDepth() * Time);
  else
    sprintf(ctext,"T = %5.1f #omega_{p}^{-1}",Time);
  textTime->AddText(ctext);
 
  TPaveText *textDen = new TPaveText(0.15,0.85,0.48,0.9,"NDC");
  PlasmaGlob::SetPaveTextStyle(textDen,12); 
  textDen->SetTextColor(kOrange+10);
  if(opt.Contains("units") && pData->GetPlasmaDensity())
    sprintf(ctext,"n_{0} = %5.2f x 10^{15} / cc", 1e-6 * 1e-15 * pData->GetPlasmaDensity());
  else if(pData->GetBeamDensity() && pData->GetPlasmaDensity())
    sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/pData->GetPlasmaDensity());
  textDen->AddText(ctext);

  TPaveText *textWav = new TPaveText(0.12,0.78,0.45,0.83,"NDC");
  PlasmaGlob::SetPaveTextStyle(textWav,12); 
  textWav->SetTextColor(kGray+2);
  sprintf(ctext,"#lambda_{p} = %5.3f mm", 1e3 * pData->GetPlasmaWaveLength());
  textWav->AddText(ctext);

  
  // Actual Plotting!
  // ------------------------------------------------------------

  // Output file
  TString fOutName = Form("./%s/Plots/Field2D/Field2D",sim.Data());
  fOutName += Form("-%s_%i",sim.Data(),time);

  C->cd();
 
  gPad->SetFrameLineWidth(3);  

  TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1");
  if(hFrame) delete hFrame;
  hFrame = (TH2F*) hE2D[index]->Clone("hFrame1");
  hFrame->Reset();
 
  hFrame->Draw("col");
  exField->Draw();
  hE2D[index]->Draw("colz same");
  
  gPad->Update();
  
  textTime->Draw();
  textDen->Draw();
  if(opt.Contains("units"))
    textWav->Draw();
  
  gPad->RedrawAxis(); 

  C->cd();

  // Print to a file
  PlasmaGlob::imgconv(C,fOutName,opt);
  // ---------------------------------------------------------

}
示例#6
0
void FindSections(TH1D* h_rate, vector<double> &sectionBegin, vector<double> &sectionEnd, const double& begin, const double& end, const double offset, const double skip)
{
  if(begin < h_rate->GetBinLowEdge(1) || end > h_rate->GetBinLowEdge(h_rate->GetNbinsX()+1))
    {
      cerr << "Borders outside of histogram " << begin << " " <<  h_rate->GetBinLowEdge(1) << " " << end << " " << h_rate->GetBinLowEdge(h_rate->GetNbinsX()+1) << endl;
      exit(-1);
    }
  
  //Get Median
  int n = h_rate->GetXaxis()->GetNbins(); 
  //std::vector<double>  x(n);
  //h_rate->GetXaxis()->GetCenter(&x[0]);
  double * y = h_rate->GetArray();
  // exclude underflow/overflows from bin content array y
  double median = TMath::Median(n, &y[0]);

  //Define cut values (this is a bit arbitrary)
  const double cut_up = median * 1.2;
  const double cut_down = median * 0.5;
  cout << "Using cut values = " << cut_down << " < " << median << " < " << cut_up << endl;

  //Search in histogram
  const double step = h_rate->GetBinWidth(1) / 100.;
  bool in_section = false;

  for(double current = begin; current < end; current += step)
    {
      const double value = h_rate->Interpolate(current);

      //Start a section
      if (!in_section && (cut_down <= value && value <= cut_up))
        {
          sectionBegin.push_back(current+offset);
          in_section = true;
        }

      //End a section
      if (in_section && (value < cut_down || cut_up < value))
        {
          in_section = false;
          sectionEnd.push_back(current-offset);
        }
    }

  if(in_section)
    sectionEnd.push_back(end);
    
  if(sectionBegin.size() != sectionEnd.size())
    {
      cerr << "sections size error" << endl;
      exit(-1);
    }

  ostringstream name; name << "rate_" << begin << "_" << end;
  TH1D* draw = (TH1D*)(h_rate->Clone(name.str().c_str()));
  draw->GetXaxis()->SetRangeUser(begin,end);
  draw->Draw("HIST L");
  for (int i=0; i < int(sectionBegin.size()); ++i)
    {
      TBox* boxskip = new TBox(sectionBegin[i],cut_down/2.,sectionBegin[i]+skip,cut_down);
      boxskip->SetFillColor(kRed);
      boxskip->SetFillStyle(3001);
      boxskip->DrawClone();
//       TBox* box = new TBox(sectionBegin[i]+skip,cut_down/2.,sectionEnd[i],cut_down);
//       box->SetFillColor(kGreen-2);
//       box->SetFillStyle(3001);
//       box->DrawClone();
      TPaveText* txt = new TPaveText(sectionBegin[i]+skip,cut_down/2.,sectionEnd[i],cut_down,"b t l");
      ostringstream text; text << i;
      txt->AddText(text.str().c_str());
      txt->SetFillStyle(3001);
      txt->SetFillColor(kGreen-2);
      txt->Draw("SAME");
    }
  return;
}
示例#7
0
void ZinvEstimate(){//main programme
     //Set Canvas Style
     TStyle *gStyle = new TStyle("gStyle","Style for P-TDR");
     SetStyle st;
     st.SetPars(gStyle);
     //finished setting canvas style
     DataMC plot;
     //Important
     //In kevins v3 production due to a bug puWeight is divided to all standard MC weights ...this should be removed 
     //from the code if you are using it for version otherthan V3
     TString InputFilePathV4="/eos/uscms/store/user/pedrok/SUSY2015/Analysis/Skims/Run2ProductionV4/";

     TString InputFilePathV3="/eos/uscms/store/user/pedrok/SUSY2015/Analysis/Skims/Run2ProductionV3/";

     TString InputFilePathV2="/eos/uscms/store/user/pedrok/SUSY2015/Analysis/Skims/Run2ProductionV2/";

     


     TChain* tZinv = new TChain("tree");
     tZinv->Add(InputFilePathV4+"tree_signal/tree_ZJetsToNuNu_HT*.root");
     ReadTree Zinv(tZinv);


     //reading the GJets MC
     TChain* tGJets = new TChain("tree");
     tGJets->Add(InputFilePathV4+"tree_GJet_CleanVars/tree_GJets_HT-*.root");
     ReadTree GJets(tGJets);





     //reading QCD MC
     TChain* tQCD = new TChain("tree");
     tQCD->Add(InputFilePathV4+"tree_GJet_CleanVars/tree_QCD_HT*.root");
     ReadTree QCD(tQCD);

     //reading Single photon Data
     TChain* tData = new TChain("tree");
     tData->Add(InputFilePathV4+"tree_GJet_CleanVars/tree_SinglePhoton_*.root");
     ReadTree Data(tData);

     double Lumi=1280.23;


     int nBinsHT=13;
     int nBinsMHT=7;
     int nBinsPt=8;
     int nBinsNJ=6;
     int nBinsS=25;
     double HTbins[14]={500.,600.,700,800,900,1000.,1100,1200.,1300,1400,1500,1700,2000,3000};
     double MHTbins[8]={200.,300,400,500.,600,750.,1000,1500.};
     double Ptbins[9]={100,200.,300,400,500.,600,750.,1000,1500.};
     double NJetsbins[7]={4,5,6,7,8,9,12};

    /////////Three MHT Bins
    double MHTbin1Min=200;
    double MHTbin1Max=350;
    double MHTbin2Min=350;
    double MHTbin2Max=500;
    double MHTbin3Min=500;
    double MHTbin3Max=1500;



    ///////////Three MHT Bins

     

     int nBinAN=18;
     double nBinANmax=18.5;

     /////////////////////////////////////////////////////////////////////////////All user input changes above 
     TH1F *hHT_Zinv=new TH1F("hHT_Zinv","hHT_Zinv",nBinsHT,HTbins);
     TH1F *hMHT_Zinv=new TH1F("hMHT_Zinv","hMHT_Zinv",nBinsMHT,MHTbins);
     TH1F *hNJets_Zinv=new TH1F("hNJets_Zinv","hNJets_Zinv",nBinsNJ,NJetsbins);
     


     TH1F *hHT_GJets=new TH1F("hHT_GJets","hHT_GJets",nBinsHT,HTbins);
     TH1F *hMHT_GJets=new TH1F("hMHT_GJets","hMHT_GJets",nBinsMHT,MHTbins);
     TH1F *hNJets_GJets=new TH1F("hNJets_GJets","hNJets_GJets",nBinsNJ,NJetsbins);

     TH1F *hSieta_GJetsEB=new TH1F("hSieta_GJetsEB","hSieta_GJetsEB",nBinsS,0.006,0.0107);
     TH1F *hSieta_GJetsEC=new TH1F("hSieta_GJetsEC","hSieta_GJetsEC",nBinsS,0.01,0.0272);


     TH1F *hSieta_GJetsEBLow=new TH1F("hSieta_GJetsEBLow","hSieta_GJetsEBLow",nBinsS,0.006,0.0107);
     TH1F *hSieta_GJetsECLow=new TH1F("hSieta_GJetsECLow","hSieta_GJetsECLow",nBinsS,0.01,0.0272);

     TH1F *hSieta_GJetsEBMed=new TH1F("hSieta_GJetsEBMed","hSieta_GJetsEBMed",nBinsS,0.006,0.0107);
     TH1F *hSieta_GJetsECMed=new TH1F("hSieta_GJetsECMed","hSieta_GJetsECMed",nBinsS,0.01,0.0272);

     TH1F *hSieta_GJetsEBHigh=new TH1F("hSieta_GJetsEBHigh","hSieta_GJetsEBHigh",nBinsS,0.006,0.0107);
     TH1F *hSieta_GJetsECHigh=new TH1F("hSieta_GJetsECHigh","hSieta_GJetsECHigh",nBinsS,0.01,0.0272);
  

     TH1F *hPhPt_GJetsEB=new TH1F("hPhPt_GJetsEB","hPhPt_GJetsEB",nBinsPt,Ptbins);
     TH1F *hPhPt_GJetsEC=new TH1F("hPhPt_GJetsEC","hPhPt_GJetsEC",nBinsPt,Ptbins);




     TH1F *hHT_QCD=new TH1F("hHT_QCD","hHT_QCD",nBinsHT,HTbins);
     TH1F *hMHT_QCD=new TH1F("hMHT_QCD","hMHT_QCD",nBinsMHT,MHTbins);
     TH1F *hNJets_QCD=new TH1F("hNJets_QCD","hNJets_QCD",nBinsNJ,NJetsbins);

     TH1F *hSieta_QCDEB=new TH1F("hSieta_QCDEB","hSieta_QCDEB",nBinsS,0.006,0.0107);
     TH1F *hSieta_QCDEC=new TH1F("hSieta_QCDEC","hSieta_QCDEC",nBinsS,0.01,0.0272);     



     TH1F *hSieta_QCDEBLow=new TH1F("hSieta_QCDEBLow","hSieta_QCDEBLow",nBinsS,0.006,0.0107);
     TH1F *hSieta_QCDECLow=new TH1F("hSieta_QCDECLow","hSieta_QCDECLow",nBinsS,0.01,0.0272);

     TH1F *hSieta_QCDEBMed=new TH1F("hSieta_QCDEBMed","hSieta_QCDEBMed",nBinsS,0.006,0.0107);
     TH1F *hSieta_QCDECMed=new TH1F("hSieta_QCDECMed","hSieta_QCDECMed",nBinsS,0.01,0.0272);

     TH1F *hSieta_QCDEBHigh=new TH1F("hSieta_QCDEBHigh","hSieta_QCDEBHigh",nBinsS,0.006,0.0107);
     TH1F *hSieta_QCDECHigh=new TH1F("hSieta_QCDECHigh","hSieta_QCDECHigh",nBinsS,0.01,0.0272);

     TH1F *hPhPt_QCDEB=new TH1F("hPhPt_QCDEB","hPhPt_QCDEB",nBinsPt,Ptbins);
     TH1F *hPhPt_QCDEC=new TH1F("hPhPt_QCDEC","hPhPt_QCDEC",nBinsPt,Ptbins);
    



     TH1F *hHT_Data=new TH1F("hHT_Data","hHT_Data",nBinsHT,HTbins);
     TH1F *hMHT_Data=new TH1F("hMHT_Data","hMHT_Data",nBinsMHT,MHTbins);
     TH1F *hNJets_Data=new TH1F("hNJets_Data","hNJets_Data",nBinsNJ,NJetsbins);

     TH1F *hSieta_DataEB=new TH1F("hSieta_DataEB","hSieta_DataEB",nBinsS,0.006,0.0107);
     TH1F *hSieta_DataEC=new TH1F("hSieta_DataEC","hSieta_DataEC",nBinsS,0.01,0.0272);;


     TH1F *hSieta_DataEBLow=new TH1F("hSieta_DataEBLow","hSieta_DataEBLow",nBinsS,0.006,0.0107);
     TH1F *hSieta_DataECLow=new TH1F("hSieta_DataECLow","hSieta_DataECLow",nBinsS,0.01,0.0272);

     TH1F *hSieta_DataEBMed=new TH1F("hSieta_DataEBMed","hSieta_DataEBMed",nBinsS,0.006,0.0107);
     TH1F *hSieta_DataECMed=new TH1F("hSieta_DataECMed","hSieta_DataECMed",nBinsS,0.01,0.0272);

     TH1F *hSieta_DataEBHigh=new TH1F("hSieta_DataEBHigh","hSieta_DataEBHigh",nBinsS,0.006,0.0107);
     TH1F *hSieta_DataECHigh=new TH1F("hSieta_DataECHigh","hSieta_DataECHigh",nBinsS,0.01,0.0272);
    
     TH1F *hPhPt_DataEB=new TH1F("hPhPt_DataEB","hPhPt_DataEB",nBinsPt,Ptbins);
     TH1F *hPhPt_DataEC=new TH1F("hPhPt_DataEC","hPhPt_DataEC",nBinsPt,Ptbins);
    



     TH1F *h_NZinv18bin=new TH1F("h_NZinv18bin","h_NZinv18bin",nBinAN,0.5,nBinANmax); 
     //
     TH1F *h_NZinv18binC=new TH1F("h_NZinv18binC","h_NZinv18binC",nBinAN,0.5,nBinANmax);   

     //TH1F *EBestimate=new TH1F("EBestimate","EBestimate",18,0.5,18.5);
     //TH1F *ECestimate=new TH1F("ECestimate","ECestimate",18,0.5,18.5);

     TH1F *ZinvEstimate=new TH1F("ZinvEstimate","ZinvEstimate",nBinAN,0.5,nBinANmax);

     TH1F  *h_NGJets18bin=new TH1F("h_NGJets18binC","h_NGJets18binC",nBinAN,0.5,nBinANmax); 

     TH1F *h_NGJets18binEB=new TH1F("h_NGJets18binEB","h_NGJets18binEB",nBinAN,0.5,nBinANmax);
  
     TH1F *h_NGJets18binEC=new TH1F("h_NGJets18binEC","h_NGJets18binEC",nBinAN,0.5,nBinANmax);     


     TH1F *h_NQCD18binEB=new TH1F("h_NQCD18binEB","h_NQCD18binEB",nBinAN,0.5,nBinANmax);
  
     TH1F *h_NQCD18binEC=new TH1F("h_NQCD18binEC","h_NQCD18binEC",nBinAN,0.5,nBinANmax); 



     TH1F *h_Ndata18binEB=new TH1F("h_Ndata18binEB","h_Ndata18binEB",nBinAN,0.5,nBinANmax);
   
     TH1F *h_Ndata18binEC=new TH1F("h_Ndata18binEC","h_Ndata18binEC",nBinAN,0.5,nBinANmax);



     TH1F *h_ZgammaR18bin=new TH1F("h_ZgammaR18bin","h_ZgammmaR18bin",nBinAN,0.5,nBinANmax);

     
     TH1F *h_ZgammaRWSF=new TH1F("h_ZgammaRWSF","h_ZgammmaRWSF",nBinAN,0.5,nBinANmax);

 
        


     int maxEvents_Zinv=tZinv->GetEntries();
     cout<<"maxEventsZinv: "<<maxEvents_Zinv<<endl;

     for(int iEv=0;iEv<maxEvents_Zinv;iEv++){//Looping over Zinv MC///////////////////////////////////////
     tZinv->GetEntry(iEv);
     if(iEv % 1000000==0){cout<<"Event no Zinv : "<<iEv<<endl;}
     
     int binNumber_Zinv = computeBin( Zinv.MHTclean, Zinv.HTclean, Zinv.NJetsclean, k13TeV);

     double weight=0;
     if(binNumber_Zinv >-1  && Zinv.BTagsclean==0){//Filling Yield(N_Obsereved) in Zinv
                     
         

          h_NZinv18bin->Fill(binNumber_Zinv,(Lumi*Zinv.Weight));      
          h_NZinv18binC->Fill(binNumber_Zinv,(Lumi*Zinv.Weight));


       }

     
     }//Lopping over Zinv MC//////////////////////////////////////////////////////////


      cout<<"Zinv Observed MC: "<<h_NZinv18bin->Integral()<<endl;
      cout<<"First bin: "<<h_NZinv18bin->GetBinContent(0)<<endl;

      for(int i=1;i<19;i++){
      cout<<"Zinv Bin Content: "<<h_NZinv18bin->GetBinContent(i)<<endl;
           }


     int maxEvents_GJets=tGJets->GetEntries();
     cout<<"maxEventsGJets: "<<maxEvents_GJets<<endl;
     for(int iEv=0;iEv<maxEvents_GJets;iEv++){//Looping over GJets MC///////////////////////////////////////
     tGJets->GetEntry(iEv);
     if(iEv % 1000000==0){cout<<"Event no GJets : "<<iEv<<endl;}
     
      

     int binNumber_GJets = computeBin( GJets.MHTclean, GJets.HTclean, GJets.NJetsclean, k13TeV);
     int index=GJets.photonIndex();
    

     if(binNumber_GJets >-1 && GJets.BTagsclean==0 && index !=-1 && GJets.photon_nonPrompt->at(index) !=1){//Filling Yield(N_Obsereved) in GJets MC
         
 
         hHT_GJets->Fill(GJets.HTclean,Lumi*GJets.Weight);
         hMHT_GJets->Fill(GJets.MHTclean,Lumi*GJets.Weight);
         hNJets_GJets->Fill(GJets.NJetsclean,Lumi*GJets.Weight);  
         h_NGJets18bin->Fill(binNumber_GJets,Lumi*GJets.Weight);
       


         if(fabs(GJets.bestPhoton->at(0).Eta())< 1.4442){//barrel
         hSieta_GJetsEB->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
         h_NGJets18binEB->Fill(binNumber_GJets,Lumi*GJets.Weight);
         hPhPt_GJetsEB->Fill(GJets.photonCands->at(index).Pt(),Lumi*GJets.Weight);
         ////////////////////////////////////Sieta in MHT bins
         if(GJets.MHTclean >MHTbin1Min && GJets.MHTclean< MHTbin1Max){
         hSieta_GJetsEBLow->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
             }


         if(GJets.MHTclean >MHTbin2Min && GJets.MHTclean< MHTbin2Max){
         hSieta_GJetsEBMed->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
             }


         if(GJets.MHTclean >MHTbin3Min && GJets.MHTclean< MHTbin3Max){
         hSieta_GJetsEBHigh->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
             }
          

         /////////////////////////Sieta in MHT bins




              }//barrel
         if(fabs(GJets.bestPhoton->at(0).Eta())> 1.566 && fabs(GJets.bestPhoton->at(0).Eta())< 2.5){//endcap
         hSieta_GJetsEC->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
         h_NGJets18binEC->Fill(binNumber_GJets,Lumi*GJets.Weight);
         hPhPt_GJetsEC->Fill(GJets.photonCands->at(index).Pt(),Lumi*GJets.Weight);


         ////////////////////////////////////Sieta in MHT bins
         if(GJets.MHTclean >MHTbin1Min && GJets.MHTclean< MHTbin1Max){
         hSieta_GJetsECLow->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
             }


         if(GJets.MHTclean >MHTbin2Min && GJets.MHTclean< MHTbin2Max){
         hSieta_GJetsECMed->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
             }


         if(GJets.MHTclean >MHTbin3Min && GJets.MHTclean< MHTbin3Max){
         hSieta_GJetsECHigh->Fill(GJets.photon_sigmaIetaIeta->at(index),Lumi*GJets.Weight);
             }
          

         /////////////////////////Sieta in MHT bins










             }//endcap





         }//Filling Yield(N_Obsereved) in GJets MC





     }//Looping over GJets MC//////////////////////////////////////////////////////////////////////////


     cout<<"Total GJets Events:  "<<hHT_GJets->Integral();


     int maxEvents_QCD=tQCD->GetEntries();
     cout<<"maxEventsQCD: "<<maxEvents_QCD<<endl;
     for(int iEv=0;iEv<maxEvents_QCD;iEv++){//Looping over QCD MC
     tQCD->GetEntry(iEv);
     if(iEv % 1000000==0){cout<<"Event no QCD : "<<iEv<<endl;}
     int binNumber_QCD = computeBin( QCD.MHTclean, QCD.HTclean, QCD.NJetsclean, k13TeV);
     int index=QCD.photonIndex();
     if(binNumber_QCD >-1 && QCD.BTagsclean==0 && index !=-1 && QCD.photon_nonPrompt->at(index) ==1 ){//Filling Yield(N_Obsereved) in QCD MC
         
         hHT_QCD->Fill(QCD.HTclean,Lumi*QCD.Weight);
         hMHT_QCD->Fill(QCD.MHTclean,Lumi*QCD.Weight);
         hNJets_QCD->Fill(QCD.NJetsclean,Lumi*QCD.Weight);
         


         if(fabs(QCD.bestPhoton->at(0).Eta())< 1.4442){//barrel
         hSieta_QCDEB->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
         h_NQCD18binEB->Fill(binNumber_QCD,Lumi*QCD.Weight);
         hPhPt_QCDEB->Fill(QCD.photonCands->at(index).Pt(),Lumi*QCD.Weight);


         ////////////////////////////////////Sieta in MHT bins
         if(QCD.MHTclean >MHTbin1Min && QCD.MHTclean< MHTbin1Max){
         hSieta_QCDEBLow->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
             }


         if(QCD.MHTclean >MHTbin2Min && QCD.MHTclean< MHTbin2Max){
         hSieta_QCDEBMed->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
             }


         if(QCD.MHTclean >MHTbin3Min && QCD.MHTclean< MHTbin3Max){
         hSieta_QCDEBHigh->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
             }
          

         /////////////////////////Sieta in MHT bins











              }//barrel
         if(fabs(QCD.bestPhoton->at(0).Eta())> 1.566 && abs(QCD.bestPhoton->at(0).Eta()) <2.5 ){//endcap
         hSieta_QCDEC->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
         h_NQCD18binEC->Fill(binNumber_QCD,Lumi*QCD.Weight);
         hPhPt_QCDEC->Fill(QCD.photonCands->at(index).Pt(),Lumi*QCD.Weight);
             }//endcap


         ////////////////////////////////////Sieta in MHT bins
         if(QCD.MHTclean >MHTbin1Min && QCD.MHTclean< MHTbin1Max){
         hSieta_QCDECLow->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
             }


         if(QCD.MHTclean >MHTbin2Min && QCD.MHTclean< MHTbin2Max){
         hSieta_QCDECMed->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
             }


         if(QCD.MHTclean >MHTbin3Min && QCD.MHTclean< MHTbin3Max){
         hSieta_QCDECHigh->Fill(QCD.photon_sigmaIetaIeta->at(index),Lumi*QCD.Weight);
             }
          

         /////////////////////////Sieta in MHT bins





         }//Filling Yield(N_Obsereved) in QCD MC




     }//Looping over QCD MC
 

     

     int maxEvents_Data=tData->GetEntries();
     //cout<<"maxEvents in Single Photon Data: "<<maxEvents_Data<<endl;
     for(int iEv=0;iEv<maxEvents_Data;iEv++){//Data
     tData->GetEntry(iEv);
     if(iEv % 1000000==0){cout<<"Event no Data : "<<iEv<<endl;}
     
      //cout<<"Event no: "<<iEv<<endl;
     int binNumber_Data = computeBin( Data.MHTclean, Data.HTclean, Data.NJetsclean, k13TeV);
     int index=Data.photonIndex();

     if(binNumber_Data >-1 && Data.BTagsclean==0 && index !=-1){//Filling Yield(N_Obsereved) in Data
            bool PassTrigger=false;
          
         for(int itr=0;itr<Data.TriggerNames->size();itr++){
             //cout<<"trigger size: "<<Data.TriggerNames->at(itr)<<endl;
             if(Data.TriggerNames->at(itr)=="HLT_Photon90_CaloIdL_PFHT500_v3" && Data.TriggerPass->at(itr)==1){
                PassTrigger=true;


               }

              }


         

         if(PassTrigger==true){//trigger pass
         
         hHT_Data->Fill(Data.HTclean);
         hMHT_Data->Fill(Data.MHTclean);
         hNJets_Data->Fill(Data.NJetsclean);



         if(fabs(Data.bestPhoton->at(0).Eta())< 1.4442){//barrel
         

         h_Ndata18binEB->Fill(binNumber_Data);
         hSieta_DataEB->Fill(Data.photon_sigmaIetaIeta->at(index));
         hPhPt_DataEB->Fill(Data.photonCands->at(index).Pt());


         ////////////////////////////////////Sieta in MHT bins
         if(Data.MHTclean >MHTbin1Min && Data.MHTclean< MHTbin1Max){
         hSieta_DataEBLow->Fill(Data.photon_sigmaIetaIeta->at(index));
             }


         if(Data.MHTclean >MHTbin2Min && Data.MHTclean< MHTbin2Max){
         hSieta_DataEBMed->Fill(Data.photon_sigmaIetaIeta->at(index));
             }


         if(Data.MHTclean >MHTbin3Min && Data.MHTclean< MHTbin3Max){
         hSieta_DataEBHigh->Fill(Data.photon_sigmaIetaIeta->at(index));
             }
          

         /////////////////////////Sieta in MHT bins










              }//barrel
         if(fabs(Data.bestPhoton->at(0).Eta())> 1.566 && fabs(Data.bestPhoton->at(0).Eta())< 2.5 ){//endcap
         h_Ndata18binEC->Fill(binNumber_Data);
         hSieta_DataEC->Fill(Data.photon_sigmaIetaIeta->at(index));
         hPhPt_DataEC->Fill(Data.photonCands->at(index).Pt());


         ////////////////////////////////////Sieta in MHT bins
         if(Data.MHTclean >MHTbin1Min && Data.MHTclean< MHTbin1Max){
         hSieta_DataECLow->Fill(Data.photon_sigmaIetaIeta->at(index));
             }


         if(Data.MHTclean >MHTbin2Min && Data.MHTclean< MHTbin2Max){
         hSieta_DataECMed->Fill(Data.photon_sigmaIetaIeta->at(index));
             }


         if(Data.MHTclean >MHTbin3Min && Data.MHTclean< MHTbin3Max){
         hSieta_DataECHigh->Fill(Data.photon_sigmaIetaIeta->at(index));
             }
          

         /////////////////////////Sieta in MHT bins










             }//endcap
             

         
         }//trigger pass 

         }//Filling Yield(N_Obsereved) in Data




     

     }//Data 


     //trigger efficiency
     



     ///////////////////////////defining legend
    char Legname1[100];
    TLegend *leg[24];
    for(int k0=0;k0<24;k0++){
    sprintf(Legname1,"leg_1D%i",k0);
    leg[k0]=new TLegend(0.5,0.7,0.80,0.89);
    leg[k0]->SetTextFont(62);
    leg[k0]->SetLineColor(1);
    leg[k0]->SetLineStyle(1);
    leg[k0]->SetLineWidth(3);
    leg[k0]->SetFillColor(0);
    leg[k0]->SetFillStyle(1001);
    leg[k0]->SetShadowColor(0);
    leg[k0]->SetDrawOption(0);
    leg[k0]->SetBorderSize(0);
    leg[k0]->SetTextSize(0.03);
    }


     ///////////////////////////////ZinvMC Yield

     //TCanvas *ZinvMCYield=new TCanvas("ZinvMC","ZinvMC");
     //ZinvMCYield->SetLogy();
     h_NZinv18bin->Sumw2();
     h_NZinv18bin->SetFillColor(1);
     h_NZinv18bin->SetFillStyle(1000);
     h_NZinv18bin->GetXaxis()->SetTitle("bin Number");
     h_NZinv18bin->GetYaxis()->SetTitle("Z/Gamma Ratio");
     //h_NZinv18bin->Draw("hist");

   //////////////////////////////////////////////Calculating Zgamma Ratio start
      TPaveText *tpav1 = new TPaveText(0.1956522,0.6247818,0.729097,0.8970332,"brNDC");

    tpav1->SetBorderSize(0);
    tpav1->SetFillStyle(0);
    tpav1->SetTextAlign(11);
    tpav1->SetTextFont(42);
    tpav1->SetTextSize(0.04);
    tpav1->AddText("HT >500");
    tpav1->AddText("#gamma p_{T} > 100 ");
    tpav1->AddText("NJets >=4");
    tpav1->AddText("MHT>200");
    tpav1->AddText("Btags=0");
    tpav1->AddText("#Delta #Phi_{1,2,3,4}>(0.5,0.5,0.3,0.3)");

    TPaveText *pCMS1 = new TPaveText(0.132107,0.9308003,0.8327759,0.9923583,"brNDC");

    pCMS1->SetBorderSize(0);
    pCMS1->SetFillStyle(0);
    pCMS1->SetTextAlign(11);
    pCMS1->SetTextFont(42);
    pCMS1->SetTextSize(0.04);
    pCMS1->AddText("CMS #it{Preliminary}                      #sqrt{s}= 13 TeV");

    
    
     TCanvas *cZgammaR=new TCanvas("cZGammaR","cZGammaR");
     TH1F *h_ZgR = (TH1F*)h_NZinv18bin->Clone("h_ZgR");

     h_ZgR->Divide(h_NGJets18bin);


     cZgammaR->cd();
     h_ZgR->Draw("E2");
     tpav1->Draw();
     pCMS1->Draw();
    
     cZgammaR->SaveAs("ZgammaRatioWOSF.png");
     cZgammaR->SaveAs("ZgammaRatioWOSF.pdf");
     cZgammaR->SaveAs("ZgammaRatioWOSF.gif");
     
     ///////////////////////////////////Calculating ZGamma ratio end




     
    /////////////////////////////////////////////////////Dealing with Data barrel

   



     TH1F *h_DataSimEB = (TH1F*)h_Ndata18binEB->Clone("h_DataSimEB");
     
     TH1F *h_DataSimEC = (TH1F*)h_Ndata18binEC->Clone("h_DataSimEC");
   

     TH1F *h_DataSimEBforErr = (TH1F*)h_NGJets18binEB->Clone("h_DataSimEBforErr");
     
     TH1F *h_DataSimECforErr = (TH1F*)h_NGJets18binEB->Clone("h_DataSimECforErr");
     
     h_DataSimEBforErr->Scale((1/h_DataSimEBforErr->Integral())*h_Ndata18binEB->Integral());
     h_DataSimECforErr->Scale((1/h_DataSimECforErr->Integral())*h_Ndata18binEC->Integral());
     
     /////////////////////Fill the empty bins with simulated data
        
     for(int i=1;i<(nBinAN+1);i++){//loop over bins

        h_DataSimEB->SetBinError(i,0.);
        h_DataSimEC->SetBinError(i,0.);

        


        }//loop over bins 
        


     

     TH1F *hEBPurity=new TH1F("hEBPurity","hEBPurity",nBinAN,0.5,nBinANmax);
     TH1F *hECPurity=new TH1F("hECPurity","hECPurity",nBinAN,0.5,nBinANmax);
     
     TH1F *hEBfrag=new TH1F("hEBfrag","hEBfrag",nBinAN,0.5,nBinANmax);
     TH1F *hECfrag=new TH1F("hECfrag","hECfrag",nBinAN,0.5,nBinANmax);    
                         //uncorel      //corel
     double ebpErr=sqrt((0.009*0.009)+(0.03*0.03));
     double ecpErr=sqrt((0.016*0.016)+(0.046*0.046));

     double ebpErrCorel=0.03;
     double ebpErrUnCorel=0.009;

     double ecpErrCorel=0.046;
     double ecpErrUnCorel=0.016;


     for(int i=1;i<(nBinAN+1);i++){//set purity stuff
          hEBPurity->SetBinContent(i,0.967);
          hEBPurity->SetBinError(i,ebpErr);
          hECPurity->SetBinContent(i,0.956);
          hECPurity->SetBinError(i,ecpErr);
          
          hEBfrag->SetBinContent(i,0.92);
          hEBfrag->SetBinError(i,0.04);
          hECfrag->SetBinContent(i,0.92);
          hECfrag->SetBinError(i,0.04);


         }//set purity stuff     


    

    const Int_t NumBins= nBinAN;
    double binNumber[nBinAN];
    double YieldEstimated[nBinAN];
    double YieldErrUp_Estimated[nBinAN];
    double YieldErrLow_Estimated[nBinAN];

    double YieldPredMC[nBinAN];
    double YieldErrUp_PredMC[nBinAN];
    double YieldErrLow_PredMC[nBinAN];

    double XErrLow[nBinAN];
    double XErrUp[nBinAN];


    double ZgRwSF[nBinAN];
    double ZgRwSF_sys_ErrUp[nBinAN];
    double ZgRwSF_sys_ErrLow[nBinAN];
    double ZgRwSF_stat_Err[nBinAN];



    for(int ibin=1;ibin<(nBinAN+1);ibin++){//loop over bin error calculation


       double SF=0.98;
       double SFup=1.03;
       double SFlow=0.93;
       double ZgRcentral=h_ZgR->GetBinContent(ibin)/0.98;
       double ZgRup=h_ZgR->GetBinContent(ibin)/1.03;
       double ZgRlow=h_ZgR->GetBinContent(ibin)/0.93;

       double ZgRcorelErrup=fabs(ZgRcentral-ZgRlow);
       double ZgRcorelErrlow=fabs(ZgRcentral-ZgRup);

       double ZgRsymErr=0.5*(sqrt((ZgRcorelErrup*ZgRcorelErrup)+(ZgRcorelErrlow*ZgRcorelErrlow)));
       double ZgRcorel_Rel_Errup=ZgRcorelErrup/ZgRcentral;
       double ZgRcorel_Rel_Errlow=ZgRcorelErrlow/ZgRcentral;

       

       //double ZgRcorelErr=sqrt((ZgRcorelErrup*ZgRcorelErrup)+(ZgRcorelErrlow*ZgRcorelErrlow));

       double ZgRuncorelErr=h_ZgR->GetBinError(ibin)/SF;

       double ZgRuncorel_Rel_Err=ZgRuncorelErr/ZgRcentral;
   
       double ZgRsymErrStat=h_ZgR->GetBinError(ibin)/SF;//h_ZgR->GetBinError(ibin);
       
       double ZgRallSymErr=sqrt((ZgRsymErr*ZgRsymErr)+(ZgRsymErrStat*ZgRsymErrStat));

       

       
       //important lines to be changed
       double ZgR=ZgRcentral;
       
       double ZgRerr=ZgRallSymErr;
   
       double ZgRerrUp=sqrt((ZgRcorelErrup*ZgRcorelErrup)+(ZgRuncorelErr*ZgRuncorelErr));
       double ZgRerrLow=sqrt((ZgRcorelErrlow*ZgRcorelErrlow)+(ZgRuncorelErr*ZgRuncorelErr));
     

       ////////////////////////////////////barrel starts
       int EBobs=h_DataSimEB->GetBinContent(ibin);
       double EBobsErr=h_DataSimEB->GetBinError(ibin);     

       double pEB=hEBPurity->GetBinContent(ibin);
       double pEBerr=hEBPurity->GetBinError(ibin);
       double pEB_Rel_err=pEBerr/pEB;


       int ECobs=h_DataSimEC->GetBinContent(ibin);
       double ECobsErr=h_DataSimEC->GetBinError(ibin);

       double pEC=hECPurity->GetBinContent(ibin);
       double pECerr=hECPurity->GetBinError(ibin);       
       double pEC_Rel_err=pECerr/pEC;

       double f=0.92;
       double ferr=0.04;
       double f_Rel_err=ferr/f;

       double YieldTotal=ZgR*(EBobs*pEB+ECobs*pEC)*f;
       double YieldTotalErr=0;
       double YieldTotal_Rel_Err=0;

       double YieldTotalErrUp=0;
       double YieldTotal_Rel_ErrUp=0;

       double YieldTotalErrLow=0;
       double YieldTotal_Rel_ErrLow=0;


       int Nobserved=EBobs+ECobs;

       
       double totalPurity=0;
       double totalPurityErr=0;
       double totalPurity_Rel_Err=0;
       
       double ZinvMCYield=h_NZinv18binC->GetBinContent(ibin);
       double ZinvMCYieldErr=h_NZinv18binC->GetBinError(ibin);
       double ZinvMCYield_Rel_Err=ZinvMCYieldErr/ZinvMCYield;


       if(Nobserved !=0){
          totalPurity=((EBobs*pEB+ECobs*pEC)*f)/Nobserved;
          double totalPurityErr1=(EBobs*pEBerr+ECobs*pECerr)/Nobserved;
          double totalPurityErr2=ferr;
          totalPurityErr=sqrt((totalPurityErr1*totalPurityErr1)+(totalPurityErr2*totalPurityErr2));
          totalPurity_Rel_Err=totalPurityErr/totalPurity;


          YieldTotalErr=Nobserved*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerr*ZgRerr)));

          YieldTotal_Rel_Err=YieldTotalErr/YieldTotal; 


          YieldTotalErrUp=Nobserved*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrUp*ZgRerrUp)));

          YieldTotal_Rel_ErrUp=YieldTotalErrUp/YieldTotal;
          

          YieldTotalErrLow=Nobserved*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrLow*ZgRerrLow)));

          YieldTotal_Rel_ErrLow=YieldTotalErrLow/YieldTotal;



           }
        if(Nobserved ==0){

          double NobservedNew=h_DataSimEBforErr->GetBinContent(ibin)+h_DataSimECforErr->GetBinContent(ibin);
          double EBobsNew=h_DataSimEBforErr->GetBinContent(ibin);
          double ECobsNew=h_DataSimECforErr->GetBinContent(ibin);
          totalPurity=((EBobsNew*pEB+ECobsNew*pEC)*f)/NobservedNew;
          
          double totalPurityErr1=(EBobsNew*pEBerr+ECobsNew*pECerr)/NobservedNew;
          double totalPurityErr2=ferr;
          totalPurityErr=sqrt((totalPurityErr1*totalPurityErr1)+(totalPurityErr2*totalPurityErr2));
          totalPurity_Rel_Err=totalPurityErr/totalPurity;

          YieldTotalErr=NobservedNew*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerr*ZgRerr)));

          double YieldTotalNew=ZgR*(EBobsNew*pEB+ECobsNew*pEC)*f;

          YieldTotal_Rel_Err=YieldTotalErr/YieldTotalNew;


          YieldTotalErrUp=NobservedNew*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrUp*ZgRerrUp)));

          YieldTotal_Rel_ErrUp=YieldTotalErrUp/YieldTotalNew;
          

          YieldTotalErrLow=NobservedNew*(sqrt((ZgR*ZgR*totalPurityErr*totalPurityErr)+(totalPurity*totalPurity*ZgRerrLow*ZgRerrLow)));

          YieldTotal_Rel_ErrLow=YieldTotalErrLow/YieldTotalNew;







           }


        

          double YieldErrWithStat=0;
          double YieldErrWithStatUp=0;
          double YieldErrWithStatLow=0;
          double NobsErr=sqrt(Nobserved);
          YieldErrWithStat=sqrt((ZgR*totalPurity*NobsErr)*(ZgR*totalPurity*NobsErr) + (Nobserved*totalPurity*ZgRerr)*(Nobserved*totalPurity*ZgRerr) + (Nobserved*ZgR*totalPurityErr)*(Nobserved*ZgR*totalPurityErr));
         
          YieldErrWithStatUp=sqrt((ZgR*totalPurity*NobsErr)*(ZgR*totalPurity*NobsErr) + (Nobserved*totalPurity*ZgRerrUp)*(Nobserved*totalPurity*ZgRerrUp) + (Nobserved*ZgR*totalPurityErr)*(Nobserved*ZgR*totalPurityErr));
         

          YieldErrWithStatLow=sqrt((ZgR*totalPurity*NobsErr)*(ZgR*totalPurity*NobsErr) + (Nobserved*totalPurity*ZgRerrLow)*(Nobserved*totalPurity*ZgRerrLow) + (Nobserved*ZgR*totalPurityErr)*(Nobserved*ZgR*totalPurityErr));
      
      
     ZgRwSF[ibin-1]=ZgR;
     ZgRwSF_sys_ErrUp[ibin-1]=ZgRcorelErrup;
     ZgRwSF_sys_ErrLow[ibin-1]=ZgRcorelErrlow;
     ZgRwSF_stat_Err[ibin-1]=ZgRuncorelErr;




      
      
      binNumber[ibin-1]=ibin;
      YieldEstimated[ibin-1]=YieldTotal;
      YieldErrUp_Estimated[ibin-1]=YieldErrWithStatUp;
      YieldErrLow_Estimated[ibin-1]=YieldErrWithStatLow;
  
      YieldPredMC[ibin-1]=ZinvMCYield;
      YieldErrUp_PredMC[ibin-1]=ZinvMCYieldErr;
      YieldErrLow_PredMC[ibin-1]=ZinvMCYieldErr;
      XErrLow[ibin-1]=0.5;
      XErrUp[ibin-1]=0.5;    






printf(" %i :%i |%i| %4.3f(%4.3f) |%i| %4.3f(%4.3f) |%4.3f(%4.3f,+%4.3f-%4.3f)| %4.3f(%4.3f) |%4.3f(%4.3f)| %4.3f(+%4.3f-%4.3f) |%4.3f(%4.3f)",ibin,Nobserved, EBobs,pEB,pEB_Rel_err,ECobs,pEC,pEC_Rel_err, ZgR,ZgRuncorel_Rel_Err,ZgRcorel_Rel_Errup,ZgRcorel_Rel_Errlow,f,f_Rel_err,totalPurity,totalPurity_Rel_Err,YieldTotal,YieldTotal_Rel_ErrUp,YieldTotal_Rel_ErrLow,ZinvMCYield,ZinvMCYield_Rel_Err);
//printf("%4.3f",ZinvMCYield);

      //printf("bin %i :%i | %4.3f(%4.3f) | %4.3f(%4.3f)  | %4.2f(%4.3f) ",ibin,Nobserved,ZgR,ZgRerr,totalPurity,totalPurityErr,YieldTotal,YieldTotalErr);

   //printf("bin %i :%i | %4.3f(%4.3f,+%4.3f-%4.3f) | %4.3f(%4.3f)  | %4.2f(+%4.3f-%4.3f) ",ibin,Nobserved,ZgR,ZgRuncorel_Rel_Err,ZgRcorel_Rel_Errup,ZgRcorel_Rel_Errlow,totalPurity,totalPurity_Rel_Err,YieldTotal,YieldTotal_Rel_ErrUp,YieldTotal_Rel_ErrLow);

     cout<<endl;
     

      
      double Percent=(int)round(100*(YieldTotalErr/YieldTotal));

      
      double maxErrorYield=max(YieldErrWithStatUp,YieldErrWithStatLow);
      ZinvEstimate->SetBinContent(ibin,YieldTotal);
      ZinvEstimate->SetBinError(ibin,maxErrorYield);

       /////////////////endcap ends

        

       }//loop over bin error calculation



      ////////////////////////Pred vs Estimated



     TPaveText *tpa = new TPaveText(0.5056522,0.6247818,0.829097,0.8970332,"brNDC");

      tpa->SetBorderSize(0);
      tpa->SetFillStyle(0);
      tpa->SetTextAlign(11);
      tpa->SetTextFont(42);
      tpa->SetTextSize(0.04);
      tpa->AddText("HT >500");
      tpa->AddText("N_{jets} >=4");
      tpa->AddText("MHT>200");
      tpa->AddText("Btags=0");
      tpa->AddText("#Delta #Phi_{1,2,3,4}>(0.5,0.5,0.3,0.3)");



      TPaveText *pCMS = new TPaveText(0.132107,0.9308003,0.8327759,0.9923583,"brNDC");

      pCMS->SetBorderSize(0);
      pCMS->SetFillStyle(0);
      pCMS->SetTextAlign(11);
      pCMS->SetTextFont(42);
      pCMS->SetTextSize(0.04);
      pCMS->AddText("CMS #it{Preliminary}       1.3 fb^{-1} #sqrt{s}= 13 TeV");

      


       TLegend *legP = new TLegend(0.2173913,0.2478185,0.5167224,0.4363002,NULL,"brNDC");
      legP->SetBorderSize(0);
      legP->SetTextFont(62);
      legP->SetTextSize(0.03);
      legP->SetLineColor(1);
      legP->SetLineStyle(1);
      legP->SetLineWidth(3);
      legP->SetFillColor(0);
      legP->SetFillStyle(1001);

      cout<<"Est: "<<ZinvEstimate->Integral()<<endl;
      cout<<"Pred: "<<h_NZinv18binC->Integral()<<endl;

     
     //////////////////////////////////ZGammaRatio

     c_ZgRwSF = new TCanvas("c_ZgRwSF","c_ZgRwSF");
     c_ZgRwSF->cd();
     
     

     gr_ZgRwSFsys = new TGraphAsymmErrors(NumBins,binNumber,ZgRwSF,XErrLow,XErrUp,ZgRwSF_sys_ErrLow,ZgRwSF_sys_ErrUp);
     gr_ZgRwSFsys->SetTitle("ZgammaRatio");
     gr_ZgRwSFsys->SetMarkerColor(4);
     gr_ZgRwSFsys->SetLineColor(4);
     gr_ZgRwSFsys->SetMarkerStyle(21);

     gr_ZgRwSFstat = new TGraphAsymmErrors(NumBins,binNumber,ZgRwSF,XErrLow,XErrUp,ZgRwSF_stat_Err,ZgRwSF_stat_Err);
     gr_ZgRwSFstat->SetTitle("ZgammaRatio");
     gr_ZgRwSFstat->SetMarkerColor(2);
     gr_ZgRwSFstat->SetLineColor(2);
     gr_ZgRwSFstat->SetMarkerStyle(21);

     TLegend *legPZgR = new TLegend(0.2173913,0.7478185,0.5167224,0.8563002,NULL,"brNDC");
      legPZgR->SetBorderSize(0);
      legPZgR->SetTextFont(62);
      legPZgR->SetTextSize(0.03);
      legPZgR->SetLineColor(1);
      legPZgR->SetLineStyle(1);
      legPZgR->SetLineWidth(3);
      legPZgR->SetFillColor(0);
      legPZgR->SetFillStyle(1001);

      legPZgR->AddEntry(gr_ZgRwSFsys,"Sys Error","l");
      legPZgR->AddEntry(gr_ZgRwSFstat,"Stat Error","l");

     TMultiGraph *mgZgR=new TMultiGraph();
     mgZgR->SetTitle(" ;ith Bin ; Z/#gamma Ratio ");
     
     mgZgR->Add(gr_ZgRwSFstat);
     mgZgR->Add(gr_ZgRwSFsys);

     mgZgR->Draw("AP");
     tpa->Draw();
     pCMS->Draw();
     legPZgR->Draw();

     c_ZgRwSF->SaveAs("ZGammaRatioWSF.png");
     c_ZgRwSF->SaveAs("ZGammaRatioWSF.pdf");
     c_ZgRwSF->SaveAs("ZGammaRatioWSF.gif");



     ///////////////////////////////ZGammaRatio







     cPredVsEstimated = new TCanvas("estvspred","estvspred");
     
       TPad *pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0);
       pad1->SetBottomMargin(0); // Upperand lower plot are joined
       pad1->Draw();             // Draw the upper pad: pad1
       gPad->Update();
       pad1->cd();               // pad1 becomes the current pad
       gPad->DrawFrame(0.5, 0.01, 18.5, 2000, "PredVsEst;ith Bin;Events");
       gPad->SetLogy();
     
     gr_estimated = new TGraphAsymmErrors(NumBins,binNumber,YieldEstimated,XErrLow,XErrUp,YieldErrLow_Estimated,YieldErrUp_Estimated);
     gr_estimated->SetTitle("Estimated");
     gr_estimated->SetMarkerColor(4);
     gr_estimated->SetLineColor(4);
     gr_estimated->SetMarkerStyle(21);
     

     gr_mcPred = new TGraphAsymmErrors(NumBins,binNumber,YieldPredMC,XErrLow,XErrUp,YieldErrLow_PredMC,YieldErrUp_PredMC);
     gr_mcPred->SetTitle("MC predicted");
     gr_mcPred->SetMarkerColor(2);
     gr_mcPred->SetLineColor(2);
     gr_mcPred->SetMarkerStyle(8);


      legP->AddEntry(gr_mcPred,"Zinv MC Pred ","P");
      
      legP->AddEntry(gr_estimated,"Estimated(from #gamma +Jets)","P");

    


     char TMgname1[100];
     TMultiGraph *TMg_1D[2];
     for(int k0=0;k0<2;k0++){
     sprintf(TMgname1,"TMg_1D%i",k0);
     TMg_1D[k0]=new TMultiGraph();
      }
     for(int j0=0;j0<2;j0++){
     TMg_1D[j0]->SetMinimum(0.01);
     TMg_1D[j0]->SetMaximum(2000);
      }
      
    TMg_1D[0]->SetTitle(" ;ith Bin ; Events ");

    TMg_1D[0]->Add(gr_mcPred);
    TMg_1D[0]->Add(gr_estimated);


    
    TMg_1D[0]->Draw("AP");
    TMg_1D[0]->GetXaxis()->SetLimits(0.5,18.5); 
   
    tpa->Draw();
    pCMS->Draw();
    legP->Draw();


   TGaxis *axis = new TGaxis( -5, 20, -5, 220, 20,220,510,"");
       axis->SetLabelFont(43); // Absolute font size in pixel (precision 3)
       axis->SetLabelSize(15);
       axis->Draw();



  cPredVsEstimated->cd();

      TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3);
      pad2->SetTopMargin(0);
      pad2->SetBottomMargin(0.2);
      pad2->SetGridy(); // vertical grid
      pad2->Draw();
      pad2->cd();       // pad2 becomes the current pad


   TH1F *h3 = (TH1F*)h_NZinv18binC->Clone("h3");
   h3->SetLineColor(kBlack);
   h3->SetMinimum(-1);  // Define Y ..
   h3->SetMaximum(3); // .. range
   h3->Sumw2();
   h3->SetStats(0);      // No statistics on lower plot
   h3->Divide(ZinvEstimate);
   h3->SetMarkerStyle(21);
   h3->SetMarkerColor(1);
   h3->Draw("ep");       // Draw the r
   h3->GetXaxis()->SetTitle("ith Bin"); // Remove the ratio title

   // Y axis ratio plot settings
   h3->GetYaxis()->SetTitle("Pred/Est");
   h3->GetYaxis()->SetNdivisions(505);

   h3->GetYaxis()->SetTitleSize(20);
   h3->GetYaxis()->SetTitleFont(43);
   h3->GetYaxis()->SetTitleOffset(1.55);
   h3->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   h3->GetYaxis()->SetLabelSize(15);

   // X axis ratio plot settings
   h3->GetXaxis()->SetTitleSize(20);
   h3->GetXaxis()->SetTitleFont(43);
   h3->GetXaxis()->SetTitleOffset(3.);
   h3->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   h3->GetXaxis()->SetLabelSize(15);


     cPredVsEstimated->SaveAs("PredVsEstimated.png");
     cPredVsEstimated->SaveAs("PredVsEstimated.gif");
     cPredVsEstimated->SaveAs("ZPredVsEstimated.pdf");



   

     
      
      
      






    /////////////////////////////Fill the empty bins with simulated data
     


       TCanvas *c[20];
   int a;

  double promptfrac=hSieta_GJetsEB->Integral()/(hSieta_GJetsEB->Integral()+hSieta_QCDEB->Integral());

  cout<<"prompt fraction: "<<promptfrac<<endl;

  
  
   plot.plotHist(hHT_Data,hHT_GJets,hHT_QCD,c[0],"","Data","MC","HT");
   
   plot.plotHist(hMHT_Data,hMHT_GJets,hMHT_QCD,c[1],"","Data","MC","MHT");
   
   plot.plotHist(hNJets_Data,hNJets_GJets,hNJets_QCD,c[2],"","Data","MC","Njets");
   
   plot.plotHist(hSieta_DataEB,hSieta_GJetsEB,hSieta_QCDEB,c[3],"EB","Data","MC","SigmaIetaIeta_EB");
   
   plot.plotHist(hSieta_DataEBLow,hSieta_GJetsEBLow,hSieta_QCDEBLow,c[4],"Low-MHT-EB","Data","MC","SigmaIetaIeta_EB");
   
   plot.plotHist(hSieta_DataEBMed,hSieta_GJetsEBMed,hSieta_QCDEBMed,c[5],"Med-MHT-EB","Data","MC","SigmaIetaIeta_EB");
   
   plot.plotHist(hSieta_DataEBHigh,hSieta_GJetsEBHigh,hSieta_QCDEBHigh,c[6],"High-MHT-EB","Data","MC","SigmaIetaIeta_EB");
   

   plot.plotHist(hSieta_DataEC,hSieta_GJetsEC,hSieta_QCDEC,c[7],"EE","Data","MC","SigmaIetaIeta_EE");
   
   plot.plotHist(hSieta_DataECLow,hSieta_GJetsECLow,hSieta_QCDECLow,c[8],"Low-MHT-EE","Data","MC","SigmaIetaIeta_EE");
   
   plot.plotHist(hSieta_DataECMed,hSieta_GJetsECMed,hSieta_QCDECMed,c[9],"Med-MHT-EE","Data","MC","SigmaIetaIeta_EE");
   
   plot.plotHist(hSieta_DataECHigh,hSieta_GJetsECHigh,hSieta_QCDECHigh,c[10],"High-MHT-EE","Data","MC","SigmaIetaIeta_EE");   


   
   
   plot.plotHist(hPhPt_DataEB,hPhPt_GJetsEB,hPhPt_QCDEB,c[11],"EB","Data","MC","PhotonPt_EB");

   

   plot.plotHist(hPhPt_DataEC,hPhPt_GJetsEC,hPhPt_QCDEC,c[12],"EE","Data","MC","PhotonPt_EE");

   

   plot.plotHist(h_Ndata18binEB,h_NGJets18binEB,h_NQCD18binEB,c[13],"EB","Data","MC","ith-Bin-EB");
   
   plot.plotHist(h_Ndata18binEC,h_NGJets18binEC,h_NQCD18binEC,c[14],"EE","Data","MC","ith-Bin-EE");

   

  
  

     
   







}//main programme
示例#8
0
int main( int argc, char* argv[] ) {


  DrawTools::setStyle();
  std::vector<float> energies;
  std::vector<float> reso;
  std::vector<float> resoErr;
  std::vector<int> runs;

  energies.push_back(20);
  energies.push_back(50);
  energies.push_back(100);
  energies.push_back(150);
  energies.push_back(200);
  energies.push_back(250);

  //HV 1450
  runs.push_back(2851);
  runs.push_back(2801);
  runs.push_back(2778);
  runs.push_back(2822);
  runs.push_back(2872);
  runs.push_back(2894);


//HV 1050
//  runs.push_back(2864);
//  runs.push_back(2814);
//  runs.push_back(2795);
//  runs.push_back(2849);
//  runs.push_back(2885);
//  runs.push_back(2907);
  
  std::string tag = "V00";
  if( argc>1 ) {
    std::string tag_str(argv[1]);
    tag = tag_str;
  }

  TGraphErrors* gr_reso_vs_energy[5];
  TGraphErrors* gr_resoMaxAmplFit_vs_energy[5];
  for(int i=0;i<5;++i) {
    gr_reso_vs_energy[i]= new TGraphErrors(0);
    gr_resoMaxAmplFit_vs_energy[i]= new TGraphErrors(0);
  }

  std::string outdir = "plots_reso_" + tag;
  system( Form("mkdir -p %s", outdir.c_str()) );

  float sigma_noise[5];//sigma of maxAmpl in pedestal events
//  sigma_noise[0]=2.47;
//  sigma_noise[1]=2.54;
//  sigma_noise[2]=2.19;
//  sigma_noise[3]=2.15;
  sigma_noise[0]=1.78;
  sigma_noise[1]=1.24;
  sigma_noise[2]=1.66;
  sigma_noise[3]=1.05;
  sigma_noise[4]=sqrt(2.49*2.49*sigma_noise[0]*sigma_noise[0]+0.81*0.81*sigma_noise[1]*sigma_noise[1]+16.8*16.8*sigma_noise[2]*sigma_noise[2]+0.73*0.73*sigma_noise[3]*sigma_noise[3]);//weighted mean of sigmas with intercalib of V03 //FIXME, don't do it hardcoded
  bool subtract_noise=true;

  for (int i=0;i<runs.size();++i){
    TString run;
    run.Form("%d",runs[i]); 
    
       

    TFile *inputFile=TFile::Open("CherenkovPlots_"+run+"_"+tag.c_str()+".root");
    TVectorD* res=(TVectorD*)inputFile->Get("resValueMaxAmpl");
    TVectorD* resErr=(TVectorD*)inputFile->Get("resErrValueMaxAmpl");

    TVectorD* meanValuemaxAmpl_fit=(TVectorD*)inputFile->Get("meanValuemaxAmpl_fit");

    TVectorD* resMaxAmplFit=(TVectorD*)inputFile->Get("resValuemaxAmpl_fit");
    TVectorD* resErrMaxAmplFit=(TVectorD*)inputFile->Get("resErrValuemaxAmpl_fit");

    for(int j=0;j<5;++j){
      gr_reso_vs_energy[j]->SetPoint( i, energies[i], (*res)[j] );
      gr_reso_vs_energy[j]->SetPointError( i, 0, (*resErr)[j] );

      if(!subtract_noise){
	gr_resoMaxAmplFit_vs_energy[j]->SetPoint( i, energies[i], (*resMaxAmplFit)[j] );
	gr_resoMaxAmplFit_vs_energy[j]->SetPointError( i, 0, (*resErrMaxAmplFit)[j] );
      }else{
	std::cout<<"run:"<<runs[i]<<" res_original:"<<(*resMaxAmplFit)[j]<<" sigma_noise:"<<sigma_noise[j]<<" final:"<<sqrt((*resMaxAmplFit)[j]*(*resMaxAmplFit)[j]-100*sigma_noise[j]/(*meanValuemaxAmpl_fit)[j]*100*sigma_noise[j]/(*meanValuemaxAmpl_fit)[j])<<" mean:"<<(*meanValuemaxAmpl_fit)[j]<<std::endl;
	gr_resoMaxAmplFit_vs_energy[j]->SetPoint( i, energies[i], sqrt((*resMaxAmplFit)[j]*(*resMaxAmplFit)[j]-100*sigma_noise[j]/(*meanValuemaxAmpl_fit)[j]*100*sigma_noise[j]/(*meanValuemaxAmpl_fit)[j]) );
	gr_resoMaxAmplFit_vs_energy[j]->SetPointError( i, 0, (*resErrMaxAmplFit)[j] );
      }

    }
  }

  for(int i=0;i<5;++i){
    TString fibre;
    fibre.Form("%d",i); 

    if(gr_reso_vs_energy[i]){
      TCanvas* c1 = new TCanvas( "c1", "", 600, 600 );
      c1->cd();
      TH2D* h2_axes2 = new TH2D( "axes", "", 100, -0.0, 305. , 10, 0.0, 25 );
      h2_axes2->SetXTitle("Beam Energy [GeV]");
      h2_axes2->SetYTitle("Energy Resolution [%]");
      h2_axes2->Draw("");
      
      gr_reso_vs_energy[i]->SetMarkerStyle(20);
      gr_reso_vs_energy[i]->SetMarkerSize(1.6);
      gr_reso_vs_energy[i]->SetMarkerColor(kBlue);
      gr_reso_vs_energy[i]->Draw("p same");

      //              TF1 *fun= new TF1("fun","sqrt([0]*[0]/(x*x)+[1]*[1])",1, 250.+15.);
      //            TF1 *fun= new TF1("fun","sqrt([0]*[0]/x+[1]*[1])",1, 250.+15.);
            TF1 *fun= new TF1("fun",  "sqrt([0]*[0]/x+[1]*[1]+ [2]*[2]/(x*x))",1, 250+5.);
      fun->SetParameter(1, 4.);
      fun->SetParameter(0, 20.);
      fun->SetParameter(2, 20.);
      gr_reso_vs_energy[i]->Fit(fun,"RN");
      fun->SetLineWidth(1.);
      fun->SetLineColor(kBlue+2);
      fun->Draw("L same");

      TLegend* leg_neat = new TLegend(0.4, 0.92-0.06*5 , 0.8, 0.92);
      leg_neat->SetTextSize(0.038);
      std::string ene="Data fibre ";
      //  ene+=Form("%.0f",energies[i]);
      //    ene+=" GeV";
      ene+=fibre;
      if(i!=4)    leg_neat->AddEntry(gr_reso_vs_energy[i],ene.c_str(),"p");
      else leg_neat->AddEntry(gr_reso_vs_energy[i],"Data CeF_{3}","p");
      //      leg_neat->AddEntry((TObject*)0 ,Form("S =  %.2f\n%s #pm %.2f / #sqrt{E [GeV]}",fun->GetParameter(0),"%",fun->GetParError(0) ),"");
      leg_neat->AddEntry((TObject*)0 ,Form("S =  %.2f\n%s #pm %.2f",fun->GetParameter(0),"%",fun->GetParError(0) ),"");
      leg_neat->AddEntry( (TObject*)0 ,Form("C =  %.2f\n%s  #pm %.2f",(fun->GetParameter(1)) ,"%",fun->GetParError(1) ),"");
      leg_neat->AddEntry( (TObject*)0 ,Form("N =  %.2f\n%s #pm %.2f",(fun->GetParameter(2))/100 ," GeV" ,fun->GetParError(2)/100),"");
      leg_neat->SetFillColor(0);
      leg_neat->Draw("same");
      std::cout<<"parameters: S="<<fun->GetParameter(0)<<" C="<<fun->GetParameter(1)<<" N="<<fun->GetParameter(2)<<std::endl;


      c1->SaveAs(outdir+"/reso_HV1450_"+fibre+".png");
      c1->SaveAs(outdir+"/reso_HV1450_"+fibre+".pdf");
    }

    if(gr_resoMaxAmplFit_vs_energy[i]){
      TCanvas* c1 = new TCanvas( "c1", "", 600, 600 );
      c1->cd();
      TH2D* h2_axes2 = new TH2D( "axes", "", 100, -0.0, 305. , 10, 0.0, 25 );
      h2_axes2->SetXTitle("Beam Energy [GeV]");
      h2_axes2->SetYTitle("Energy Resolution [%]");
      h2_axes2->Draw("");
      
      gr_resoMaxAmplFit_vs_energy[i]->SetMarkerStyle(20);
      gr_resoMaxAmplFit_vs_energy[i]->SetMarkerSize(1.6);
      gr_resoMaxAmplFit_vs_energy[i]->SetMarkerColor(kBlue);
      gr_resoMaxAmplFit_vs_energy[i]->Draw("p same");

      //              TF1 *fun= new TF1("fun","sqrt([0]*[0]/(x*x)+[1]*[1])",1, 250.+15.);
                  TF1 *fun= new TF1("fun","sqrt([0]*[0]/x+[1]*[1])",1, 250.+15.);
      //      TF1 *fun= new TF1("fun",  "sqrt([0]*[0]/x+[1]*[1]+ [2]*[2]/(x*x))",1, 250+5.);
      fun->SetParameter(1, 4.);
      fun->SetParameter(0, 20.);
      fun->SetParameter(2, 20.);
      gr_resoMaxAmplFit_vs_energy[i]->Fit(fun,"RN");
      fun->SetLineWidth(1.);
      fun->SetLineColor(kBlue+2);
      fun->Draw("L same");


      TLegend* leg_neat = new TLegend(0.42, 0.89-0.06*3.5 , 0.85, 0.89);
      leg_neat->SetTextSize(0.038);
      std::string ene="Data fibre ";
      //  ene+=Form("%.0f",energies[i]);
      //    ene+=" GeV";
      ene+=fibre;
      if(i!=4)    leg_neat->AddEntry(gr_resoMaxAmplFit_vs_energy[i],ene.c_str(),"p");
      else leg_neat->AddEntry(gr_resoMaxAmplFit_vs_energy[i],"Data CeF_{3}","p");
      //leg_neat->AddEntry((TObject*)0 ,Form("S =  %.2f\n%s / #sqrt{E [GeV]}",fun->GetParameter(0),"%" ),"");
      leg_neat->AddEntry((TObject*)0 ,Form("S =  %.2f\n%s #pm %.2f",fun->GetParameter(0),"%",fun->GetParError(0) ),"");
      leg_neat->AddEntry( (TObject*)0 ,Form("C =  %.2f\n%s  #pm %.2f",(fun->GetParameter(1)) ,"%",fun->GetParError(1) ),"");
      //      leg_neat->AddEntry( (TObject*)0 ,Form("N =  %.2f\n%s #pm %.2f",(fun->GetParameter(2))/100 ," GeV" ,fun->GetParError(2)/100),"");

      leg_neat->SetFillColor(0);
      leg_neat->Draw("same");
      std::cout<<"parameters: S="<<fun->GetParameter(0)<<" C="<<fun->GetParameter(1)<<" N="<<fun->GetParameter(2)<<std::endl;
      TPaveText* pave = DrawTools::getLabelTop_expOnXaxis("Electron Beam");
      pave->Draw("same");

      c1->SaveAs(outdir+"/reso_maxAmplFit_HV1450_"+fibre+".png");
      c1->SaveAs(outdir+"/reso_maxAmplFit_HV1450_"+fibre+".pdf");
    }

  }
  return 0;
}
void paraPull_alpha_FT_EFF_extrapolation_2TeV_2Lep_plots_All()
{
//=========Macro generated from canvas: c1/alpha_FT_EFF_extrapolation
//=========  (Sun Nov 22 20:19:02 2015) by ROOT version6.02/12
   TCanvas *c1 = new TCanvas("c1", "alpha_FT_EFF_extrapolation",0,22,1000,600);
   gStyle->SetOptStat(0);
   c1->Range(-4.125,-0.9756589,37.125,1.048929);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetGridx();
   c1->SetGridy();
   c1->SetFrameBorderMode(0);
   c1->SetFrameBorderMode(0);
   
   TH1F *NuisanceParameterFreed23 = new TH1F("NuisanceParameterFreed23","alpha_FT_EFF_extrapolation",33,0,33);
   NuisanceParameterFreed23->SetMinimum(-0.7732002);
   NuisanceParameterFreed23->SetMaximum(0.84647);
   NuisanceParameterFreed23->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   NuisanceParameterFreed23->SetLineColor(ci);
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(1,"XS_ttbar");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(2,"EG_SCALE_ALL");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(3,"FT_EFF_Eigen_C_0");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(4,"Luminosity");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(5,"XS_st");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(6,"FT_EFF_Eigen_B_1");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(7,"XS_Zc");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(8,"MUONS_ID");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(9,"FT_EFF_Eigen_C_1");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(10,"FT_EFF_Eigen_C_3");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(11,"MUON_EFF_TrigSystUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(12,"XS_Zl");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(13,"EL_EFF_ID_TotalCorrUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(14,"FT_EFF_Eigen_B_0");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(15,"FT_EFF_Eigen_B_2");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(16,"EL_EFF_Iso_TotalCorrUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(17,"EL_EFF_Reco_TotalCorrUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(18,"MUONS_SCALE");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(19,"MUON_ISO_STAT");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(20,"MUON_EFF_STAT");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(21,"MUON_EFF_SYS");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(22,"MUON_EFF_TrigStatUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(23,"FT_EFF_Eigen_Light_1");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(24,"FT_EFF_Eigen_Light_2");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(25,"EG_RESOLUTION_ALL");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(26,"XS_diboson");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(27,"FT_EFF_Eigen_Light_4");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(28,"FT_EFF_Eigen_Light_3");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(29,"MUON_ISO_SYS");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(30,"XS_Zb");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(31,"MUONS_MS");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(32,"FT_EFF_Eigen_C_2");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(33,"FT_EFF_Eigen_Light_0");
   NuisanceParameterFreed23->GetXaxis()->SetLabelFont(42);
   NuisanceParameterFreed23->GetXaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed23->GetXaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed23->GetXaxis()->SetTitleFont(42);
   NuisanceParameterFreed23->GetYaxis()->SetTitle("#theta_{fit} - #theta_{initial}/#Delta#theta");
   NuisanceParameterFreed23->GetYaxis()->SetLabelFont(42);
   NuisanceParameterFreed23->GetYaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed23->GetYaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed23->GetYaxis()->SetTitleFont(42);
   NuisanceParameterFreed23->GetZaxis()->SetLabelFont(42);
   NuisanceParameterFreed23->GetZaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed23->GetZaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed23->GetZaxis()->SetTitleFont(42);
   NuisanceParameterFreed23->Draw("hist");
   
   Double_t _fx1023[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 _fy1023[35] = {
   1.22802e-312,
   -0.7732002,
   -0.3921591,
   -0.2934756,
   -0.2062307,
   -0.1826562,
   -0.1278773,
   -0.1247963,
   -0.108241,
   -0.06582277,
   -0.05689324,
   -0.05334169,
   -0.04681761,
   -0.03773949,
   -0.03194355,
   -0.03107318,
   -0.02396662,
   -0.01713834,
   -0.001377884,
   0.0001640769,
   0.01059417,
   0.01807268,
   0.01971767,
   0.02015498,
   0.02031121,
   0.0264387,
   0.04025057,
   0.04268968,
   0.0458893,
   0.05072166,
   0.05322667,
   0.05659235,
   0.05743463,
   0.84647,
   0};
   Double_t _fex1023[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 _fey1023[35] = {
   0,
   0,
   0.6107108,
   1.073202,
   1.262649,
   0.9362982,
   0.9916356,
   0.9862464,
   0.9262906,
   0.7691235,
   0.9864321,
   0.9937945,
   0.9917446,
   0.9970094,
   0.9817783,
   0.9372476,
   0.9926669,
   0.9931837,
   0.9925578,
   1.005003,
   0.9933467,
   0.9932277,
   0.9929663,
   0.9927589,
   0.9912906,
   0.9909611,
   1.097757,
   0.9869836,
   0.993171,
   0.9930564,
   0.9854803,
   0.753601,
   0.7380864,
   0.9908989,
   0.785308};
   TGraphErrors *gre = new TGraphErrors(35,_fx1023,_fy1023,_fex1023,_fey1023);
   gre->SetName("");
   gre->SetTitle("");
   gre->SetFillColor(1);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(1.2);
   
   TH1F *Graph_Graph1023 = new TH1F("Graph_Graph1023","",100,0,35.75);
   Graph_Graph1023->SetMinimum(-1.799504);
   Graph_Graph1023->SetMaximum(2.167994);
   Graph_Graph1023->SetDirectory(0);
   Graph_Graph1023->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1023->SetLineColor(ci);
   Graph_Graph1023->GetXaxis()->SetLabelFont(42);
   Graph_Graph1023->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1023->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1023->GetXaxis()->SetTitleFont(42);
   Graph_Graph1023->GetYaxis()->SetLabelFont(42);
   Graph_Graph1023->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1023->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1023->GetYaxis()->SetTitleFont(42);
   Graph_Graph1023->GetZaxis()->SetLabelFont(42);
   Graph_Graph1023->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1023->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1023->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1023);
   
   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.2917068,0.9341608,0.7082932,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_extrapolation");
   pt->Draw();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
void SegtoLCTX_2015all_sameYrange_fullIntegral_10k9k()
{
//=========Macro generated from canvas: SegtoLCTX/SegtoLCTX
//=========  (Fri Aug  5 09:25:13 2016) by ROOT version6.06/01
   TCanvas *SegtoLCTX = new TCanvas("SegtoLCTX", "SegtoLCTX",0,0,500,500);
   gStyle->SetOptStat(0);
   SegtoLCTX->SetHighLightColor(2);
   SegtoLCTX->Range(-50,-2.848556,50,2.626708);
   SegtoLCTX->SetFillColor(0);
   SegtoLCTX->SetBorderMode(0);
   SegtoLCTX->SetBorderSize(2);
   SegtoLCTX->SetLogy();
   SegtoLCTX->SetFrameBorderMode(0);
   SegtoLCTX->SetFrameBorderMode(0);
   
   TH1D *SegtoLCTX_1__91 = new TH1D("SegtoLCTX_1__91","SegtoLCTX",100,-40,40);
   SegtoLCTX_1__91->SetBinContent(0,1.179704);
   SegtoLCTX_1__91->SetBinContent(5,0.0002658189);
   SegtoLCTX_1__91->SetBinContent(13,0.0002658189);
   SegtoLCTX_1__91->SetBinContent(14,0.0002658189);
   SegtoLCTX_1__91->SetBinContent(16,0.0005316378);
   SegtoLCTX_1__91->SetBinContent(17,0.0002658189);
   SegtoLCTX_1__91->SetBinContent(18,0.001329094);
   SegtoLCTX_1__91->SetBinContent(19,0.001594913);
   SegtoLCTX_1__91->SetBinContent(20,0.0007974566);
   SegtoLCTX_1__91->SetBinContent(21,0.001594913);
   SegtoLCTX_1__91->SetBinContent(22,0.001860732);
   SegtoLCTX_1__91->SetBinContent(23,0.003721464);
   SegtoLCTX_1__91->SetBinContent(24,0.002126551);
   SegtoLCTX_1__91->SetBinContent(25,0.00478474);
   SegtoLCTX_1__91->SetBinContent(26,0.003189827);
   SegtoLCTX_1__91->SetBinContent(27,0.004253102);
   SegtoLCTX_1__91->SetBinContent(28,0.003189827);
   SegtoLCTX_1__91->SetBinContent(29,0.004253102);
   SegtoLCTX_1__91->SetBinContent(30,0.006911291);
   SegtoLCTX_1__91->SetBinContent(31,0.006379653);
   SegtoLCTX_1__91->SetBinContent(32,0.009835299);
   SegtoLCTX_1__91->SetBinContent(33,0.01488586);
   SegtoLCTX_1__91->SetBinContent(34,0.01063276);
   SegtoLCTX_1__91->SetBinContent(35,0.01302513);
   SegtoLCTX_1__91->SetBinContent(36,0.0140884);
   SegtoLCTX_1__91->SetBinContent(37,0.01648077);
   SegtoLCTX_1__91->SetBinContent(38,0.02046805);
   SegtoLCTX_1__91->SetBinContent(39,0.0225946);
   SegtoLCTX_1__91->SetBinContent(40,0.02857553);
   SegtoLCTX_1__91->SetBinContent(41,0.02565152);
   SegtoLCTX_1__91->SetBinContent(42,0.03269572);
   SegtoLCTX_1__91->SetBinContent(43,0.03987283);
   SegtoLCTX_1__91->SetBinContent(44,0.04864486);
   SegtoLCTX_1__91->SetBinContent(45,0.06220162);
   SegtoLCTX_1__91->SetBinContent(46,0.08399877);
   SegtoLCTX_1__91->SetBinContent(47,0.1031377);
   SegtoLCTX_1__91->SetBinContent(48,0.1176249);
   SegtoLCTX_1__91->SetBinContent(49,0.1503206);
   SegtoLCTX_1__91->SetBinContent(50,9.226308);
   SegtoLCTX_1__91->SetBinContent(51,89.06594);
   SegtoLCTX_1__91->SetBinContent(52,0.1847441);
   SegtoLCTX_1__91->SetBinContent(53,0.1108465);
   SegtoLCTX_1__91->SetBinContent(54,0.08958096);
   SegtoLCTX_1__91->SetBinContent(55,0.06951164);
   SegtoLCTX_1__91->SetBinContent(56,0.0576827);
   SegtoLCTX_1__91->SetBinContent(57,0.04864486);
   SegtoLCTX_1__91->SetBinContent(58,0.03854374);
   SegtoLCTX_1__91->SetBinContent(59,0.03721464);
   SegtoLCTX_1__91->SetBinContent(60,0.02498697);
   SegtoLCTX_1__91->SetBinContent(61,0.02631607);
   SegtoLCTX_1__91->SetBinContent(62,0.02206297);
   SegtoLCTX_1__91->SetBinContent(63,0.02126551);
   SegtoLCTX_1__91->SetBinContent(64,0.01807568);
   SegtoLCTX_1__91->SetBinContent(65,0.01462004);
   SegtoLCTX_1__91->SetBinContent(66,0.0183415);
   SegtoLCTX_1__91->SetBinContent(67,0.01010112);
   SegtoLCTX_1__91->SetBinContent(68,0.009835299);
   SegtoLCTX_1__91->SetBinContent(69,0.006911291);
   SegtoLCTX_1__91->SetBinContent(70,0.004518921);
   SegtoLCTX_1__91->SetBinContent(71,0.007442929);
   SegtoLCTX_1__91->SetBinContent(72,0.003721464);
   SegtoLCTX_1__91->SetBinContent(73,0.002658189);
   SegtoLCTX_1__91->SetBinContent(74,0.003987283);
   SegtoLCTX_1__91->SetBinContent(75,0.003189827);
   SegtoLCTX_1__91->SetBinContent(76,0.003455645);
   SegtoLCTX_1__91->SetBinContent(77,0.001594913);
   SegtoLCTX_1__91->SetBinContent(78,0.001860732);
   SegtoLCTX_1__91->SetBinContent(79,0.001063276);
   SegtoLCTX_1__91->SetBinContent(80,0.0002658189);
   SegtoLCTX_1__91->SetBinContent(81,0.0005316378);
   SegtoLCTX_1__91->SetBinContent(83,0.0005316378);
   SegtoLCTX_1__91->SetBinContent(84,0.0005316378);
   SegtoLCTX_1__91->SetBinContent(86,0.0002658189);
   SegtoLCTX_1__91->SetBinContent(87,0.0005316378);
   SegtoLCTX_1__91->SetBinContent(101,0.9853906);
   SegtoLCTX_1__91->SetMinimum(0.005);
   SegtoLCTX_1__91->SetMaximum(120);
   SegtoLCTX_1__91->SetEntries(768682);
   SegtoLCTX_1__91->SetStats(0);

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

   ci = TColor::GetColor("#ff00ff");
   SegtoLCTX_1__91->SetMarkerColor(ci);
   SegtoLCTX_1__91->GetXaxis()->SetTitle("cm");
   SegtoLCTX_1__91->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTX_1__91->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("SegtoLCTX_1","ME11A: mean:-0.0cm;RMS:0.9cm","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("SegtoLCTX_2","ME11B: mean:0.0cm;RMS:1.0cm","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("SegtoLCTX_3","ME12+13: mean:-0.0cm;RMS:1.3cm","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("SegtoLCTX_4","ME2: mean:-0.0cm;RMS:1.0cm","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("SegtoLCTX_5","ME3: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX_6","ME4: mean:-0.0cm;RMS:0.8cm","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 *SegtoLCTX_2__92 = new TH1D("SegtoLCTX_2__92","SegtoLCTX",100,-40,40);
   SegtoLCTX_2__92->SetBinContent(0,0.3984608);
   SegtoLCTX_2__92->SetBinContent(8,0.0005783176);
   SegtoLCTX_2__92->SetBinContent(9,0.0001445794);
   SegtoLCTX_2__92->SetBinContent(11,0.000722897);
   SegtoLCTX_2__92->SetBinContent(12,0.0008674764);
   SegtoLCTX_2__92->SetBinContent(13,0.0004337382);
   SegtoLCTX_2__92->SetBinContent(14,0.0001445794);
   SegtoLCTX_2__92->SetBinContent(15,0.000722897);
   SegtoLCTX_2__92->SetBinContent(16,0.000722897);
   SegtoLCTX_2__92->SetBinContent(17,0.002024112);
   SegtoLCTX_2__92->SetBinContent(18,0.000722897);
   SegtoLCTX_2__92->SetBinContent(19,0.00231327);
   SegtoLCTX_2__92->SetBinContent(20,0.001879532);
   SegtoLCTX_2__92->SetBinContent(21,0.001879532);
   SegtoLCTX_2__92->SetBinContent(22,0.002747008);
   SegtoLCTX_2__92->SetBinContent(23,0.003469905);
   SegtoLCTX_2__92->SetBinContent(24,0.002747008);
   SegtoLCTX_2__92->SetBinContent(25,0.003759064);
   SegtoLCTX_2__92->SetBinContent(26,0.003759064);
   SegtoLCTX_2__92->SetBinContent(27,0.004554251);
   SegtoLCTX_2__92->SetBinContent(28,0.005710886);
   SegtoLCTX_2__92->SetBinContent(29,0.008096446);
   SegtoLCTX_2__92->SetBinContent(30,0.008674764);
   SegtoLCTX_2__92->SetBinContent(31,0.007662708);
   SegtoLCTX_2__92->SetBinContent(32,0.006650652);
   SegtoLCTX_2__92->SetBinContent(33,0.009975978);
   SegtoLCTX_2__92->SetBinContent(34,0.009397661);
   SegtoLCTX_2__92->SetBinContent(35,0.009975978);
   SegtoLCTX_2__92->SetBinContent(36,0.0140242);
   SegtoLCTX_2__92->SetBinContent(37,0.02009654);
   SegtoLCTX_2__92->SetBinContent(38,0.01590373);
   SegtoLCTX_2__92->SetBinContent(39,0.02212065);
   SegtoLCTX_2__92->SetBinContent(40,0.02327728);
   SegtoLCTX_2__92->SetBinContent(41,0.02450621);
   SegtoLCTX_2__92->SetBinContent(42,0.02732551);
   SegtoLCTX_2__92->SetBinContent(43,0.033687);
   SegtoLCTX_2__92->SetBinContent(44,0.03939788);
   SegtoLCTX_2__92->SetBinContent(45,0.04684372);
   SegtoLCTX_2__92->SetBinContent(46,0.0680246);
   SegtoLCTX_2__92->SetBinContent(47,0.08927778);
   SegtoLCTX_2__92->SetBinContent(48,0.1164587);
   SegtoLCTX_2__92->SetBinContent(49,0.1485553);
   SegtoLCTX_2__92->SetBinContent(50,12.67036);
   SegtoLCTX_2__92->SetBinContent(51,85.70218);
   SegtoLCTX_2__92->SetBinContent(52,0.1682181);
   SegtoLCTX_2__92->SetBinContent(53,0.1254949);
   SegtoLCTX_2__92->SetBinContent(54,0.09390432);
   SegtoLCTX_2__92->SetBinContent(55,0.06860292);
   SegtoLCTX_2__92->SetBinContent(56,0.05081966);
   SegtoLCTX_2__92->SetBinContent(57,0.04084368);
   SegtoLCTX_2__92->SetBinContent(58,0.03614485);
   SegtoLCTX_2__92->SetBinContent(59,0.02602429);
   SegtoLCTX_2__92->SetBinContent(60,0.02428934);
   SegtoLCTX_2__92->SetBinContent(61,0.02320499);
   SegtoLCTX_2__92->SetBinContent(62,0.01785556);
   SegtoLCTX_2__92->SetBinContent(63,0.01648205);
   SegtoLCTX_2__92->SetBinContent(64,0.01532542);
   SegtoLCTX_2__92->SetBinContent(65,0.01315672);
   SegtoLCTX_2__92->SetBinContent(66,0.01012056);
   SegtoLCTX_2__92->SetBinContent(67,0.01236154);
   SegtoLCTX_2__92->SetBinContent(68,0.01113261);
   SegtoLCTX_2__92->SetBinContent(69,0.009759109);
   SegtoLCTX_2__92->SetBinContent(70,0.01040972);
   SegtoLCTX_2__92->SetBinContent(71,0.008096446);
   SegtoLCTX_2__92->SetBinContent(72,0.006361493);
   SegtoLCTX_2__92->SetBinContent(73,0.005494017);
   SegtoLCTX_2__92->SetBinContent(74,0.005638596);
   SegtoLCTX_2__92->SetBinContent(75,0.006216914);
   SegtoLCTX_2__92->SetBinContent(76,0.004192802);
   SegtoLCTX_2__92->SetBinContent(77,0.00477112);
   SegtoLCTX_2__92->SetBinContent(78,0.002602429);
   SegtoLCTX_2__92->SetBinContent(79,0.003903644);
   SegtoLCTX_2__92->SetBinContent(80,0.00231327);
   SegtoLCTX_2__92->SetBinContent(81,0.003325326);
   SegtoLCTX_2__92->SetBinContent(82,0.002168691);
   SegtoLCTX_2__92->SetBinContent(83,0.0004337382);
   SegtoLCTX_2__92->SetBinContent(84,0.001156635);
   SegtoLCTX_2__92->SetBinContent(85,0.001445794);
   SegtoLCTX_2__92->SetBinContent(86,0.000722897);
   SegtoLCTX_2__92->SetBinContent(87,0.0005783176);
   SegtoLCTX_2__92->SetBinContent(88,0.0002891588);
   SegtoLCTX_2__92->SetBinContent(89,0.001301215);
   SegtoLCTX_2__92->SetBinContent(90,0.000722897);
   SegtoLCTX_2__92->SetBinContent(91,0.0002891588);
   SegtoLCTX_2__92->SetBinContent(92,0.0004337382);
   SegtoLCTX_2__92->SetBinContent(93,0.0001445794);
   SegtoLCTX_2__92->SetBinContent(95,0.0001445794);
   SegtoLCTX_2__92->SetBinContent(96,0.0001445794);
   SegtoLCTX_2__92->SetBinContent(97,0.0005783176);
   SegtoLCTX_2__92->SetBinContent(101,0.9159105);
   SegtoLCTX_2__92->SetEntries(1401505);
   SegtoLCTX_2__92->SetStats(0);

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

   ci = TColor::GetColor("#ff9999");
   SegtoLCTX_2__92->SetMarkerColor(ci);
   SegtoLCTX_2__92->GetXaxis()->SetTitle("cm");
   SegtoLCTX_2__92->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTX_2__92->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("SegtoLCTX_1","ME11A: mean:-0.0cm;RMS:0.9cm","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("SegtoLCTX_2","ME11B: mean:0.0cm;RMS:1.0cm","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("SegtoLCTX_3","ME12+13: mean:-0.0cm;RMS:1.3cm","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("SegtoLCTX_4","ME2: mean:-0.0cm;RMS:1.0cm","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("SegtoLCTX_5","ME3: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX_6","ME4: mean:-0.0cm;RMS:0.8cm","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 *SegtoLCTX_3__93 = new TH1D("SegtoLCTX_3__93","SegtoLCTX",100,-40,40);
   SegtoLCTX_3__93->SetBinContent(0,0.4377169);
   SegtoLCTX_3__93->SetBinContent(1,0.001323741);
   SegtoLCTX_3__93->SetBinContent(2,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(4,0.001323741);
   SegtoLCTX_3__93->SetBinContent(5,0.001764988);
   SegtoLCTX_3__93->SetBinContent(6,0.001323741);
   SegtoLCTX_3__93->SetBinContent(7,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(8,0.0004412469);
   SegtoLCTX_3__93->SetBinContent(9,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(10,0.001764988);
   SegtoLCTX_3__93->SetBinContent(11,0.001323741);
   SegtoLCTX_3__93->SetBinContent(12,0.002206234);
   SegtoLCTX_3__93->SetBinContent(13,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(14,0.003971222);
   SegtoLCTX_3__93->SetBinContent(15,0.004853716);
   SegtoLCTX_3__93->SetBinContent(16,0.002647481);
   SegtoLCTX_3__93->SetBinContent(17,0.002647481);
   SegtoLCTX_3__93->SetBinContent(18,0.002647481);
   SegtoLCTX_3__93->SetBinContent(19,0.002647481);
   SegtoLCTX_3__93->SetBinContent(20,0.003529975);
   SegtoLCTX_3__93->SetBinContent(21,0.004412469);
   SegtoLCTX_3__93->SetBinContent(22,0.005294963);
   SegtoLCTX_3__93->SetBinContent(23,0.001764988);
   SegtoLCTX_3__93->SetBinContent(24,0.005736209);
   SegtoLCTX_3__93->SetBinContent(25,0.004853716);
   SegtoLCTX_3__93->SetBinContent(26,0.004853716);
   SegtoLCTX_3__93->SetBinContent(27,0.003971222);
   SegtoLCTX_3__93->SetBinContent(28,0.006618703);
   SegtoLCTX_3__93->SetBinContent(29,0.00639808);
   SegtoLCTX_3__93->SetBinContent(30,0.007942444);
   SegtoLCTX_3__93->SetBinContent(31,0.006177456);
   SegtoLCTX_3__93->SetBinContent(32,0.006177456);
   SegtoLCTX_3__93->SetBinContent(33,0.01147242);
   SegtoLCTX_3__93->SetBinContent(34,0.01058993);
   SegtoLCTX_3__93->SetBinContent(35,0.01235491);
   SegtoLCTX_3__93->SetBinContent(36,0.007942444);
   SegtoLCTX_3__93->SetBinContent(37,0.00705995);
   SegtoLCTX_3__93->SetBinContent(38,0.01014868);
   SegtoLCTX_3__93->SetBinContent(39,0.01323741);
   SegtoLCTX_3__93->SetBinContent(40,0.02117985);
   SegtoLCTX_3__93->SetBinContent(41,0.01279616);
   SegtoLCTX_3__93->SetBinContent(42,0.01544364);
   SegtoLCTX_3__93->SetBinContent(43,0.02382733);
   SegtoLCTX_3__93->SetBinContent(44,0.02779855);
   SegtoLCTX_3__93->SetBinContent(45,0.02868105);
   SegtoLCTX_3__93->SetBinContent(46,0.03353476);
   SegtoLCTX_3__93->SetBinContent(47,0.03176978);
   SegtoLCTX_3__93->SetBinContent(48,0.05427337);
   SegtoLCTX_3__93->SetBinContent(49,0.2001055);
   SegtoLCTX_3__93->SetBinContent(50,27.26685);
   SegtoLCTX_3__93->SetBinContent(51,71.44162);
   SegtoLCTX_3__93->SetBinContent(52,0.2241534);
   SegtoLCTX_3__93->SetBinContent(53,0.06442204);
   SegtoLCTX_3__93->SetBinContent(54,0.03882973);
   SegtoLCTX_3__93->SetBinContent(55,0.03750598);
   SegtoLCTX_3__93->SetBinContent(56,0.02426858);
   SegtoLCTX_3__93->SetBinContent(57,0.02382733);
   SegtoLCTX_3__93->SetBinContent(58,0.02250359);
   SegtoLCTX_3__93->SetBinContent(59,0.01610551);
   SegtoLCTX_3__93->SetBinContent(60,0.01345803);
   SegtoLCTX_3__93->SetBinContent(61,0.01522302);
   SegtoLCTX_3__93->SetBinContent(62,0.01367865);
   SegtoLCTX_3__93->SetBinContent(63,0.01191367);
   SegtoLCTX_3__93->SetBinContent(64,0.01191367);
   SegtoLCTX_3__93->SetBinContent(65,0.007501197);
   SegtoLCTX_3__93->SetBinContent(66,0.01367865);
   SegtoLCTX_3__93->SetBinContent(67,0.01103117);
   SegtoLCTX_3__93->SetBinContent(68,0.008824938);
   SegtoLCTX_3__93->SetBinContent(69,0.006177456);
   SegtoLCTX_3__93->SetBinContent(70,0.008383691);
   SegtoLCTX_3__93->SetBinContent(71,0.006618703);
   SegtoLCTX_3__93->SetBinContent(72,0.006177456);
   SegtoLCTX_3__93->SetBinContent(73,0.003529975);
   SegtoLCTX_3__93->SetBinContent(74,0.006618703);
   SegtoLCTX_3__93->SetBinContent(75,0.006618703);
   SegtoLCTX_3__93->SetBinContent(76,0.004853716);
   SegtoLCTX_3__93->SetBinContent(77,0.005736209);
   SegtoLCTX_3__93->SetBinContent(78,0.002206234);
   SegtoLCTX_3__93->SetBinContent(79,0.004853716);
   SegtoLCTX_3__93->SetBinContent(80,0.003529975);
   SegtoLCTX_3__93->SetBinContent(81,0.003088728);
   SegtoLCTX_3__93->SetBinContent(82,0.001764988);
   SegtoLCTX_3__93->SetBinContent(83,0.002868105);
   SegtoLCTX_3__93->SetBinContent(84,0.003088728);
   SegtoLCTX_3__93->SetBinContent(85,0.003971222);
   SegtoLCTX_3__93->SetBinContent(86,0.003088728);
   SegtoLCTX_3__93->SetBinContent(87,0.002206234);
   SegtoLCTX_3__93->SetBinContent(88,0.002647481);
   SegtoLCTX_3__93->SetBinContent(89,0.001323741);
   SegtoLCTX_3__93->SetBinContent(90,0.002647481);
   SegtoLCTX_3__93->SetBinContent(91,0.002206234);
   SegtoLCTX_3__93->SetBinContent(92,0.003088728);
   SegtoLCTX_3__93->SetBinContent(93,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(94,0.002206234);
   SegtoLCTX_3__93->SetBinContent(95,0.003529975);
   SegtoLCTX_3__93->SetBinContent(96,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(97,0.0004412469);
   SegtoLCTX_3__93->SetBinContent(98,0.0008824938);
   SegtoLCTX_3__93->SetBinContent(99,0.001764988);
   SegtoLCTX_3__93->SetBinContent(100,0.0004412469);
   SegtoLCTX_3__93->SetBinContent(101,0.5866377);
   SegtoLCTX_3__93->SetEntries(457904);
   SegtoLCTX_3__93->SetStats(0);
   SegtoLCTX_3__93->GetXaxis()->SetTitle("cm");
   SegtoLCTX_3__93->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTX_3__93->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("SegtoLCTX_1","ME11A: mean:-0.0cm;RMS:0.9cm","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("SegtoLCTX_2","ME11B: mean:0.0cm;RMS:1.0cm","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("SegtoLCTX_3","ME12+13: mean:-0.0cm;RMS:1.3cm","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("SegtoLCTX_4","ME2: mean:-0.0cm;RMS:1.0cm","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("SegtoLCTX_5","ME3: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX_6","ME4: mean:-0.0cm;RMS:0.8cm","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 *SegtoLCTX_4__94 = new TH1D("SegtoLCTX_4__94","SegtoLCTX",100,-40,40);
   SegtoLCTX_4__94->SetBinContent(0,0.9253629);
   SegtoLCTX_4__94->SetBinContent(1,0.001083457);
   SegtoLCTX_4__94->SetBinContent(2,0.001354322);
   SegtoLCTX_4__94->SetBinContent(3,0.001083457);
   SegtoLCTX_4__94->SetBinContent(4,0.001309178);
   SegtoLCTX_4__94->SetBinContent(5,0.0009028811);
   SegtoLCTX_4__94->SetBinContent(6,0.0009931693);
   SegtoLCTX_4__94->SetBinContent(7,0.001534898);
   SegtoLCTX_4__94->SetBinContent(8,0.0006320168);
   SegtoLCTX_4__94->SetBinContent(9,0.000812593);
   SegtoLCTX_4__94->SetBinContent(10,0.001354322);
   SegtoLCTX_4__94->SetBinContent(11,0.001264034);
   SegtoLCTX_4__94->SetBinContent(12,0.001083457);
   SegtoLCTX_4__94->SetBinContent(13,0.0009028811);
   SegtoLCTX_4__94->SetBinContent(14,0.001534898);
   SegtoLCTX_4__94->SetBinContent(15,0.001264034);
   SegtoLCTX_4__94->SetBinContent(16,0.001083457);
   SegtoLCTX_4__94->SetBinContent(17,0.001083457);
   SegtoLCTX_4__94->SetBinContent(18,0.00144461);
   SegtoLCTX_4__94->SetBinContent(19,0.001083457);
   SegtoLCTX_4__94->SetBinContent(20,0.001986339);
   SegtoLCTX_4__94->SetBinContent(21,0.00144461);
   SegtoLCTX_4__94->SetBinContent(22,0.001986339);
   SegtoLCTX_4__94->SetBinContent(23,0.001264034);
   SegtoLCTX_4__94->SetBinContent(24,0.002212059);
   SegtoLCTX_4__94->SetBinContent(25,0.00189605);
   SegtoLCTX_4__94->SetBinContent(26,0.001625186);
   SegtoLCTX_4__94->SetBinContent(27,0.002166915);
   SegtoLCTX_4__94->SetBinContent(28,0.002798932);
   SegtoLCTX_4__94->SetBinContent(29,0.00288922);
   SegtoLCTX_4__94->SetBinContent(30,0.002437779);
   SegtoLCTX_4__94->SetBinContent(31,0.003160084);
   SegtoLCTX_4__94->SetBinContent(32,0.003160084);
   SegtoLCTX_4__94->SetBinContent(33,0.003430948);
   SegtoLCTX_4__94->SetBinContent(34,0.002708643);
   SegtoLCTX_4__94->SetBinContent(35,0.005056134);
   SegtoLCTX_4__94->SetBinContent(36,0.006500744);
   SegtoLCTX_4__94->SetBinContent(37,0.00478527);
   SegtoLCTX_4__94->SetBinContent(38,0.007539058);
   SegtoLCTX_4__94->SetBinContent(39,0.008577371);
   SegtoLCTX_4__94->SetBinContent(40,0.008712803);
   SegtoLCTX_4__94->SetBinContent(41,0.009028811);
   SegtoLCTX_4__94->SetBinContent(42,0.01209861);
   SegtoLCTX_4__94->SetBinContent(43,0.01688388);
   SegtoLCTX_4__94->SetBinContent(44,0.02252688);
   SegtoLCTX_4__94->SetBinContent(45,0.026951);
   SegtoLCTX_4__94->SetBinContent(46,0.03444492);
   SegtoLCTX_4__94->SetBinContent(47,0.0474464);
   SegtoLCTX_4__94->SetBinContent(48,0.05909357);
   SegtoLCTX_4__94->SetBinContent(49,0.4176728);
   SegtoLCTX_4__94->SetBinContent(50,16.77192);
   SegtoLCTX_4__94->SetBinContent(51,81.90057);
   SegtoLCTX_4__94->SetBinContent(52,0.2206642);
   SegtoLCTX_4__94->SetBinContent(53,0.06676806);
   SegtoLCTX_4__94->SetBinContent(54,0.04735612);
   SegtoLCTX_4__94->SetBinContent(55,0.04202912);
   SegtoLCTX_4__94->SetBinContent(56,0.03462549);
   SegtoLCTX_4__94->SetBinContent(57,0.02690586);
   SegtoLCTX_4__94->SetBinContent(58,0.01787705);
   SegtoLCTX_4__94->SetBinContent(59,0.01390437);
   SegtoLCTX_4__94->SetBinContent(60,0.01155688);
   SegtoLCTX_4__94->SetBinContent(61,0.009209388);
   SegtoLCTX_4__94->SetBinContent(62,0.009299676);
   SegtoLCTX_4__94->SetBinContent(63,0.006861897);
   SegtoLCTX_4__94->SetBinContent(64,0.00622988);
   SegtoLCTX_4__94->SetBinContent(65,0.005146422);
   SegtoLCTX_4__94->SetBinContent(66,0.005056134);
   SegtoLCTX_4__94->SetBinContent(67,0.005552719);
   SegtoLCTX_4__94->SetBinContent(68,0.003611525);
   SegtoLCTX_4__94->SetBinContent(69,0.003430948);
   SegtoLCTX_4__94->SetBinContent(70,0.002798932);
   SegtoLCTX_4__94->SetBinContent(71,0.003656669);
   SegtoLCTX_4__94->SetBinContent(72,0.002528067);
   SegtoLCTX_4__94->SetBinContent(73,0.002528067);
   SegtoLCTX_4__94->SetBinContent(74,0.002708643);
   SegtoLCTX_4__94->SetBinContent(75,0.002257203);
   SegtoLCTX_4__94->SetBinContent(76,0.001354322);
   SegtoLCTX_4__94->SetBinContent(77,0.00144461);
   SegtoLCTX_4__94->SetBinContent(78,0.002437779);
   SegtoLCTX_4__94->SetBinContent(79,0.001534898);
   SegtoLCTX_4__94->SetBinContent(80,0.001625186);
   SegtoLCTX_4__94->SetBinContent(81,0.00144461);
   SegtoLCTX_4__94->SetBinContent(82,0.00144461);
   SegtoLCTX_4__94->SetBinContent(83,0.001264034);
   SegtoLCTX_4__94->SetBinContent(84,0.001805762);
   SegtoLCTX_4__94->SetBinContent(85,0.0009028811);
   SegtoLCTX_4__94->SetBinContent(86,0.001083457);
   SegtoLCTX_4__94->SetBinContent(87,0.0009931693);
   SegtoLCTX_4__94->SetBinContent(88,0.0007223049);
   SegtoLCTX_4__94->SetBinContent(89,0.0004514406);
   SegtoLCTX_4__94->SetBinContent(90,0.0006320168);
   SegtoLCTX_4__94->SetBinContent(91,0.0009931693);
   SegtoLCTX_4__94->SetBinContent(92,0.001083457);
   SegtoLCTX_4__94->SetBinContent(93,0.001805762);
   SegtoLCTX_4__94->SetBinContent(94,0.000812593);
   SegtoLCTX_4__94->SetBinContent(95,0.001173745);
   SegtoLCTX_4__94->SetBinContent(96,0.0009028811);
   SegtoLCTX_4__94->SetBinContent(97,0.0009931693);
   SegtoLCTX_4__94->SetBinContent(98,0.001534898);
   SegtoLCTX_4__94->SetBinContent(99,0.001264034);
   SegtoLCTX_4__94->SetBinContent(100,0.0009480252);
   SegtoLCTX_4__94->SetBinContent(101,0.2922626);
   SegtoLCTX_4__94->SetEntries(2242103);
   SegtoLCTX_4__94->SetStats(0);

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

   ci = TColor::GetColor("#ff0000");
   SegtoLCTX_4__94->SetMarkerColor(ci);
   SegtoLCTX_4__94->GetXaxis()->SetTitle("cm");
   SegtoLCTX_4__94->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTX_4__94->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("SegtoLCTX_1","ME11A: mean:-0.0cm;RMS:0.9cm","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("SegtoLCTX_2","ME11B: mean:0.0cm;RMS:1.0cm","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("SegtoLCTX_3","ME12+13: mean:-0.0cm;RMS:1.3cm","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("SegtoLCTX_4","ME2: mean:-0.0cm;RMS:1.0cm","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("SegtoLCTX_5","ME3: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX_6","ME4: mean:-0.0cm;RMS:0.8cm","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 *SegtoLCTX_5__95 = new TH1D("SegtoLCTX_5__95","SegtoLCTX",100,-40,40);
   SegtoLCTX_5__95->SetBinContent(0,0.2342298);
   SegtoLCTX_5__95->SetBinContent(1,0.0005990531);
   SegtoLCTX_5__95->SetBinContent(2,0.0008386744);
   SegtoLCTX_5__95->SetBinContent(3,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(4,0.0008386744);
   SegtoLCTX_5__95->SetBinContent(5,0.0004792425);
   SegtoLCTX_5__95->SetBinContent(6,0.0003594319);
   SegtoLCTX_5__95->SetBinContent(7,0.0003594319);
   SegtoLCTX_5__95->SetBinContent(8,0.000958485);
   SegtoLCTX_5__95->SetBinContent(9,0.0003594319);
   SegtoLCTX_5__95->SetBinContent(10,0.000958485);
   SegtoLCTX_5__95->SetBinContent(11,0.001198106);
   SegtoLCTX_5__95->SetBinContent(12,0.000958485);
   SegtoLCTX_5__95->SetBinContent(13,0.0005990531);
   SegtoLCTX_5__95->SetBinContent(14,0.000958485);
   SegtoLCTX_5__95->SetBinContent(15,0.001677349);
   SegtoLCTX_5__95->SetBinContent(16,0.000958485);
   SegtoLCTX_5__95->SetBinContent(17,0.0004792425);
   SegtoLCTX_5__95->SetBinContent(18,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(19,0.0003594319);
   SegtoLCTX_5__95->SetBinContent(20,0.0008386744);
   SegtoLCTX_5__95->SetBinContent(21,0.001317917);
   SegtoLCTX_5__95->SetBinContent(22,0.001677349);
   SegtoLCTX_5__95->SetBinContent(23,0.001258012);
   SegtoLCTX_5__95->SetBinContent(24,0.0008985797);
   SegtoLCTX_5__95->SetBinContent(25,0.001078296);
   SegtoLCTX_5__95->SetBinContent(26,0.001317917);
   SegtoLCTX_5__95->SetBinContent(27,0.001557538);
   SegtoLCTX_5__95->SetBinContent(28,0.002036781);
   SegtoLCTX_5__95->SetBinContent(29,0.001078296);
   SegtoLCTX_5__95->SetBinContent(30,0.001677349);
   SegtoLCTX_5__95->SetBinContent(31,0.002755644);
   SegtoLCTX_5__95->SetBinContent(32,0.002156591);
   SegtoLCTX_5__95->SetBinContent(33,0.002875455);
   SegtoLCTX_5__95->SetBinContent(34,0.001677349);
   SegtoLCTX_5__95->SetBinContent(35,0.002396213);
   SegtoLCTX_5__95->SetBinContent(36,0.003174982);
   SegtoLCTX_5__95->SetBinContent(37,0.003474508);
   SegtoLCTX_5__95->SetBinContent(38,0.004792425);
   SegtoLCTX_5__95->SetBinContent(39,0.006589585);
   SegtoLCTX_5__95->SetBinContent(40,0.005870721);
   SegtoLCTX_5__95->SetBinContent(41,0.00958485);
   SegtoLCTX_5__95->SetBinContent(42,0.01042352);
   SegtoLCTX_5__95->SetBinContent(43,0.01485652);
   SegtoLCTX_5__95->SetBinContent(44,0.01994847);
   SegtoLCTX_5__95->SetBinContent(45,0.02851493);
   SegtoLCTX_5__95->SetBinContent(46,0.0372012);
   SegtoLCTX_5__95->SetBinContent(47,0.04942188);
   SegtoLCTX_5__95->SetBinContent(48,0.07296467);
   SegtoLCTX_5__95->SetBinContent(49,0.5354936);
   SegtoLCTX_5__95->SetBinContent(50,19.93439);
   SegtoLCTX_5__95->SetBinContent(51,78.62812);
   SegtoLCTX_5__95->SetBinContent(52,0.2550768);
   SegtoLCTX_5__95->SetBinContent(53,0.07859577);
   SegtoLCTX_5__95->SetBinContent(54,0.05996522);
   SegtoLCTX_5__95->SetBinContent(55,0.04421012);
   SegtoLCTX_5__95->SetBinContent(56,0.02971304);
   SegtoLCTX_5__95->SetBinContent(57,0.0214461);
   SegtoLCTX_5__95->SetBinContent(58,0.01767207);
   SegtoLCTX_5__95->SetBinContent(59,0.01198106);
   SegtoLCTX_5__95->SetBinContent(60,0.008147123);
   SegtoLCTX_5__95->SetBinContent(61,0.007428259);
   SegtoLCTX_5__95->SetBinContent(62,0.006230153);
   SegtoLCTX_5__95->SetBinContent(63,0.005391478);
   SegtoLCTX_5__95->SetBinContent(64,0.005151857);
   SegtoLCTX_5__95->SetBinContent(65,0.003534414);
   SegtoLCTX_5__95->SetBinContent(66,0.003714129);
   SegtoLCTX_5__95->SetBinContent(67,0.002396213);
   SegtoLCTX_5__95->SetBinContent(68,0.003414603);
   SegtoLCTX_5__95->SetBinContent(69,0.001797159);
   SegtoLCTX_5__95->SetBinContent(70,0.002276402);
   SegtoLCTX_5__95->SetBinContent(71,0.001677349);
   SegtoLCTX_5__95->SetBinContent(72,0.002156591);
   SegtoLCTX_5__95->SetBinContent(73,0.001437728);
   SegtoLCTX_5__95->SetBinContent(74,0.002396213);
   SegtoLCTX_5__95->SetBinContent(75,0.00191697);
   SegtoLCTX_5__95->SetBinContent(76,0.0005990531);
   SegtoLCTX_5__95->SetBinContent(77,0.001317917);
   SegtoLCTX_5__95->SetBinContent(78,0.000958485);
   SegtoLCTX_5__95->SetBinContent(79,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(80,0.001198106);
   SegtoLCTX_5__95->SetBinContent(81,0.0001198106);
   SegtoLCTX_5__95->SetBinContent(82,0.0003594319);
   SegtoLCTX_5__95->SetBinContent(83,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(84,0.0004792425);
   SegtoLCTX_5__95->SetBinContent(85,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(86,0.0005990531);
   SegtoLCTX_5__95->SetBinContent(87,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(88,0.0002396213);
   SegtoLCTX_5__95->SetBinContent(89,0.000958485);
   SegtoLCTX_5__95->SetBinContent(90,0.0004792425);
   SegtoLCTX_5__95->SetBinContent(91,0.0008386744);
   SegtoLCTX_5__95->SetBinContent(92,0.0003594319);
   SegtoLCTX_5__95->SetBinContent(93,0.0007188638);
   SegtoLCTX_5__95->SetBinContent(94,0.0008386744);
   SegtoLCTX_5__95->SetBinContent(95,0.001078296);
   SegtoLCTX_5__95->SetBinContent(96,0.0004193372);
   SegtoLCTX_5__95->SetBinContent(97,0.0004792425);
   SegtoLCTX_5__95->SetBinContent(98,0.0004792425);
   SegtoLCTX_5__95->SetBinContent(99,0.0002396213);
   SegtoLCTX_5__95->SetBinContent(100,0.0008386744);
   SegtoLCTX_5__95->SetBinContent(101,0.2956327);
   SegtoLCTX_5__95->SetEntries(1678146);
   SegtoLCTX_5__95->SetStats(0);

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

   ci = TColor::GetColor("#00ff00");
   SegtoLCTX_5__95->SetMarkerColor(ci);
   SegtoLCTX_5__95->GetXaxis()->SetTitle("cm");
   SegtoLCTX_5__95->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTX_5__95->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("SegtoLCTX_1","ME11A: mean:-0.0cm;RMS:0.9cm","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("SegtoLCTX_2","ME11B: mean:0.0cm;RMS:1.0cm","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("SegtoLCTX_3","ME12+13: mean:-0.0cm;RMS:1.3cm","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("SegtoLCTX_4","ME2: mean:-0.0cm;RMS:1.0cm","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("SegtoLCTX_5","ME3: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX_6","ME4: mean:-0.0cm;RMS:0.8cm","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 *SegtoLCTX_6__96 = new TH1D("SegtoLCTX_6__96","SegtoLCTX",100,-40,40);
   SegtoLCTX_6__96->SetBinContent(0,0.2894917);
   SegtoLCTX_6__96->SetBinContent(1,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(2,0.000151487);
   SegtoLCTX_6__96->SetBinContent(3,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(4,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(5,0.001363383);
   SegtoLCTX_6__96->SetBinContent(6,0.0007574352);
   SegtoLCTX_6__96->SetBinContent(7,0.0003029741);
   SegtoLCTX_6__96->SetBinContent(8,0.0004544611);
   SegtoLCTX_6__96->SetBinContent(9,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(10,0.001211896);
   SegtoLCTX_6__96->SetBinContent(11,0.001211896);
   SegtoLCTX_6__96->SetBinContent(12,0.0004544611);
   SegtoLCTX_6__96->SetBinContent(13,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(14,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(15,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(16,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(17,0.001060409);
   SegtoLCTX_6__96->SetBinContent(18,0.001363383);
   SegtoLCTX_6__96->SetBinContent(19,0.001060409);
   SegtoLCTX_6__96->SetBinContent(20,0.00151487);
   SegtoLCTX_6__96->SetBinContent(21,0.0007574352);
   SegtoLCTX_6__96->SetBinContent(22,0.001666357);
   SegtoLCTX_6__96->SetBinContent(23,0.001817844);
   SegtoLCTX_6__96->SetBinContent(24,0.001817844);
   SegtoLCTX_6__96->SetBinContent(25,0.001211896);
   SegtoLCTX_6__96->SetBinContent(26,0.001363383);
   SegtoLCTX_6__96->SetBinContent(27,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(28,0.001211896);
   SegtoLCTX_6__96->SetBinContent(29,0.001666357);
   SegtoLCTX_6__96->SetBinContent(30,0.002272306);
   SegtoLCTX_6__96->SetBinContent(31,0.001666357);
   SegtoLCTX_6__96->SetBinContent(32,0.00257528);
   SegtoLCTX_6__96->SetBinContent(33,0.002726767);
   SegtoLCTX_6__96->SetBinContent(34,0.003332715);
   SegtoLCTX_6__96->SetBinContent(35,0.003938663);
   SegtoLCTX_6__96->SetBinContent(36,0.004241637);
   SegtoLCTX_6__96->SetBinContent(37,0.005150559);
   SegtoLCTX_6__96->SetBinContent(38,0.004999072);
   SegtoLCTX_6__96->SetBinContent(39,0.003332715);
   SegtoLCTX_6__96->SetBinContent(40,0.006816917);
   SegtoLCTX_6__96->SetBinContent(41,0.01060409);
   SegtoLCTX_6__96->SetBinContent(42,0.009392196);
   SegtoLCTX_6__96->SetBinContent(43,0.01696655);
   SegtoLCTX_6__96->SetBinContent(44,0.02257157);
   SegtoLCTX_6__96->SetBinContent(45,0.03075187);
   SegtoLCTX_6__96->SetBinContent(46,0.04862734);
   SegtoLCTX_6__96->SetBinContent(47,0.05877697);
   SegtoLCTX_6__96->SetBinContent(48,0.08150002);
   SegtoLCTX_6__96->SetBinContent(49,0.6594988);
   SegtoLCTX_6__96->SetBinContent(50,22.10741);
   SegtoLCTX_6__96->SetBinContent(51,76.21744);
   SegtoLCTX_6__96->SetBinContent(52,0.2957784);
   SegtoLCTX_6__96->SetBinContent(53,0.08346936);
   SegtoLCTX_6__96->SetBinContent(54,0.06438199);
   SegtoLCTX_6__96->SetBinContent(55,0.05173282);
   SegtoLCTX_6__96->SetBinContent(56,0.03650838);
   SegtoLCTX_6__96->SetBinContent(57,0.02537408);
   SegtoLCTX_6__96->SetBinContent(58,0.01802696);
   SegtoLCTX_6__96->SetBinContent(59,0.01348235);
   SegtoLCTX_6__96->SetBinContent(60,0.01060409);
   SegtoLCTX_6__96->SetBinContent(61,0.008483274);
   SegtoLCTX_6__96->SetBinContent(62,0.007271378);
   SegtoLCTX_6__96->SetBinContent(63,0.005302046);
   SegtoLCTX_6__96->SetBinContent(64,0.004241637);
   SegtoLCTX_6__96->SetBinContent(65,0.003484202);
   SegtoLCTX_6__96->SetBinContent(66,0.002726767);
   SegtoLCTX_6__96->SetBinContent(67,0.003029741);
   SegtoLCTX_6__96->SetBinContent(68,0.002120818);
   SegtoLCTX_6__96->SetBinContent(69,0.001817844);
   SegtoLCTX_6__96->SetBinContent(70,0.00257528);
   SegtoLCTX_6__96->SetBinContent(71,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(72,0.002878254);
   SegtoLCTX_6__96->SetBinContent(73,0.001666357);
   SegtoLCTX_6__96->SetBinContent(74,0.001363383);
   SegtoLCTX_6__96->SetBinContent(75,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(76,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(77,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(78,0.001363383);
   SegtoLCTX_6__96->SetBinContent(79,0.0004544611);
   SegtoLCTX_6__96->SetBinContent(80,0.001211896);
   SegtoLCTX_6__96->SetBinContent(81,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(82,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(83,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(84,0.0004544611);
   SegtoLCTX_6__96->SetBinContent(85,0.0007574352);
   SegtoLCTX_6__96->SetBinContent(87,0.0004544611);
   SegtoLCTX_6__96->SetBinContent(88,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(89,0.001060409);
   SegtoLCTX_6__96->SetBinContent(90,0.0006059481);
   SegtoLCTX_6__96->SetBinContent(91,0.001060409);
   SegtoLCTX_6__96->SetBinContent(92,0.0003029741);
   SegtoLCTX_6__96->SetBinContent(93,0.001211896);
   SegtoLCTX_6__96->SetBinContent(94,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(95,0.0007574352);
   SegtoLCTX_6__96->SetBinContent(96,0.0003029741);
   SegtoLCTX_6__96->SetBinContent(97,0.0009089222);
   SegtoLCTX_6__96->SetBinContent(98,0.001060409);
   SegtoLCTX_6__96->SetBinContent(99,0.0003029741);
   SegtoLCTX_6__96->SetBinContent(100,0.0007574352);
   SegtoLCTX_6__96->SetBinContent(101,0.3356953);
   SegtoLCTX_6__96->SetEntries(1328499);
   SegtoLCTX_6__96->SetStats(0);

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

   ci = TColor::GetColor("#0000ff");
   SegtoLCTX_6__96->SetMarkerColor(ci);
   SegtoLCTX_6__96->GetXaxis()->SetTitle("cm");
   SegtoLCTX_6__96->GetYaxis()->SetTitle("scaled number of entries");
   SegtoLCTX_6__96->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("SegtoLCTX_1","ME11A: mean:-0.0cm;RMS:0.9cm","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("SegtoLCTX_2","ME11B: mean:0.0cm;RMS:1.0cm","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("SegtoLCTX_3","ME12+13: mean:-0.0cm;RMS:1.3cm","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("SegtoLCTX_4","ME2: mean:-0.0cm;RMS:1.0cm","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("SegtoLCTX_5","ME3: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX_6","ME4: mean:-0.0cm;RMS:0.8cm","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("SegtoLCTX");
   pt->Draw();
   SegtoLCTX->Modified();
   SegtoLCTX->cd();
   SegtoLCTX->SetSelected(SegtoLCTX);
}
示例#11
0
void InclusiveJets_2010(){

//general root settings
gROOT->SetStyle("Plain");
gStyle->SetOptStat(0); //get rid of statistics box

TH1::SetDefaultSumw2() ;

//Ranges for plots
Float_t xmin=17.5 , ymin = 0.00001, xmax = 1684.0, ymax = 10000000000000000.;

//for the linecolor and linestyle
Int_t icol[8]={8,kViolet,7,4,12,46,6,7};
Int_t isty[8]={1,1,1,1,1,1,1,1};
Int_t imark[5] = {21,22,25,26,3};

//get the root files
TFile *f[3]; // POWHEG + Pythia
TFile *g[1]; //Herwig
TFile *p[1]; //Pythia
f[0] = new TFile("out_aida_40times900kevents_errorcut50/Z2MPIHADONbornkt5ktsupp250_errorcut.root");
f[1] = new TFile("out_aida_40times900kevents_errorcut50/Z2MPIHADOFFbornkt5ktsupp250_errorcut.root");
f[2] = new TFile("out_aida_40times900kevents_errorcut50/NOTUNEbornkt5ktsupp250_errorcut.root");

g[0] = new TFile("out_aida_40times900kevents_errorcut50/HERWIGMPIHADONbornkt5ktsupp250_1.root"); // from POWHEG and HERWIG

//files from Paolo ---- only Pythia Z2
p[0] = new TFile("FromPaolo/2010PYTHIA.root");


//get the Tgraph and convert into histo
TH1F _histotmp[6][3];
TH1F _histotmp_pyth[6][1];
TH1F _histotmp_herw[6][1];

_histotmp_herw[0][0] = Gr2Hi((TGraph*) g[0]->Get("d01_x01_y01;1")); // |y| < 0.5
_histotmp_herw[1][0] = Gr2Hi((TGraph*) g[0]->Get("d02_x01_y01;1")); // 0.5 < |y| < 1.0
_histotmp_herw[2][0] = Gr2Hi((TGraph*) g[0]->Get("d03_x01_y01;1")); // 1.0 < |y| < 1.5
_histotmp_herw[3][0] = Gr2Hi((TGraph*) g[0]->Get("d04_x01_y01;1")); // 1.5 < |y| < 2.0
_histotmp_herw[4][0] = Gr2Hi((TGraph*) g[0]->Get("d05_x01_y01;1")); // 2.0 < |y| < 2.5
_histotmp_herw[5][0] = Gr2Hi((TGraph*) g[0]->Get("d06_x01_y01;1")); //  2.5 < |y| < 3.0

_histotmp_pyth[0][0] = Gr2Hi((TGraph*) p[0]->Get("d01_x01_y01;1")); // |y| < 0.5
_histotmp_pyth[1][0] = Gr2Hi((TGraph*) p[0]->Get("d02_x01_y01;1")); // 0.5 < |y| < 1.0
_histotmp_pyth[2][0] = Gr2Hi((TGraph*) p[0]->Get("d03_x01_y01;1")); // 1.0 < |y| < 1.5
_histotmp_pyth[3][0] = Gr2Hi((TGraph*) p[0]->Get("d04_x01_y01;1")); // 1.5 < |y| < 2.0
_histotmp_pyth[4][0] = Gr2Hi((TGraph*) p[0]->Get("d05_x01_y01;1")); // 2.0 < |y| < 2.5
_histotmp_pyth[5][0] = Gr2Hi((TGraph*) p[0]->Get("d06_x01_y01;1")); //  2.5 < |y| < 3.0

Int_t n = 3; //number of files
Int_t nh = 6; // number of histograms = number of y bins

for(const int ifile = 0; ifile < n; ifile++){

  _histotmp[0][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d01_x01_y01;1")); // |y| <0.5
  _histotmp[1][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d02_x01_y01;2")); // 0.5 < |y| < 1.0
  _histotmp[2][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d03_x01_y01;2")); // 1.0 < |y| < 1.5
  _histotmp[3][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d04_x01_y01;2")); // 1.5 < |y| < 2.0
  _histotmp[4][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d05_x01_y01;1")); // 2.0 < |y| < 2.5
  _histotmp[5][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d06_x01_y01;1")); // 2.5 < |y| < 3.0
/*
  _histotmp[0][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d01_x01_y01;1")); // |y| <0.5
  _histotmp[1][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d02_x01_y01;1")); // 0.5 < |y| < 1.0
  _histotmp[2][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d03_x01_y01;1")); // 1.0 < |y| < 1.5
  _histotmp[3][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d04_x01_y01;1")); // 1.5 < |y| < 2.0
  _histotmp[4][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d05_x01_y01;1")); // 2.0 < |y| < 2.5
  _histotmp[5][ifile] = Gr2Hi((TGraph*) f[ifile]->Get("d06_x01_y01;1")); // 2.5 < |y| < 3.0
*/
  for(const int ihisto = 0; ihisto < nh; ihisto++){
    _histotmp_herw[ihisto][0].SetName("");
    _histotmp_pyth[ihisto][0].SetName("");
    _histotmp[ihisto][ifile].SetName("");
  }
}

//change the histo so that I can plot it and do the ratio
 TH1F *_histo[6][3];

 TH1F *_histo_herw[6][1];
 TH1F *_histo_pyth[6][1];

for(const int ifile = 0; ifile < n; ifile++){
  for(const int ihisto = 0; ihisto < nh; ihisto++){

    TH1F *_histo[ihisto][ifile]= (TH1F*)_histotmp[ihisto][ifile].Clone("");
/*
  _histo[ihisto][ifile]->Divide((TH1*)_histo[ihisto][1]);  //histo 0 / hsito 1
  TH1F *_ratio1[ihisto]= (TH1F*)_ratiotmp1[ihisto]->Clone("");
  _ratiotmp2[ihisto]->Divide((TH1*)_histo[ihisto][2]);  //histo 0 / hsito 2
  TH1F *_ratio2[ihisto]= (TH1F*)_ratiotmp2[ihisto]->Clone("");
*/
    _histo[ihisto][ifile]->SetLineWidth(2);
    _histo[ihisto][ifile]->SetLineColor(icol[ihisto]);
    _histo[ihisto][ifile]->SetMarkerStyle(2);
    _histo[ihisto][ifile]->SetMarkerColor(icol[ihisto]);

 TH1F *_histo_herw[ihisto][0] = (TH1F*) _histotmp_herw[ihisto][0].Clone("");
 _histo_herw[ihisto][0]->SetLineWidth(2);
 _histo_herw[ihisto][0]->SetLineColor(1);
 _histo_herw[ihisto][0]->SetMarkerStyle(2);
 _histo_herw[ihisto][0]->SetMarkerColor(1);

 TH1F *_histo_pyth[ihisto][0] = (TH1F*) _histotmp_pyth[ihisto][0].Clone("");
 _histo_pyth[ihisto][0]->SetLineWidth(2);
 _histo_pyth[ihisto][0]->SetLineStyle(3);
 _histo_pyth[ihisto][0]->SetLineColor(icol[ihisto]);
 _histo_pyth[ihisto][0]->SetMarkerStyle(2);
 _histo_pyth[ihisto][0]->SetMarkerColor(icol[ihisto]);
  }

//scale the histos that it fits in one histogram
_histo[0][ifile]->Scale(10000);
_histo[1][ifile]->Scale(1000);
_histo[2][ifile]->Scale(100);
_histo[3][ifile]->Scale(10);
_histo[4][ifile]->Scale(1);

}

_histo_herw[0][0]->Scale(10000);
_histo_herw[1][0]->Scale(1000);
_histo_herw[2][0]->Scale(100);
_histo_herw[3][0]->Scale(10);
_histo_herw[4][0]->Scale(1);

_histo_pyth[0][0]->Scale(10000);
_histo_pyth[1][0]->Scale(1000);
_histo_pyth[2][0]->Scale(100);
_histo_pyth[3][0]->Scale(10);
_histo_pyth[4][0]->Scale(1);

//get the data 2010
//data =  new TFile("out_aida/CMS_2011_S9086218.root");

//TH1F _histodata1 = Gr2Hi((TGraph*)data->Get("d01_x01_y01;1")); // |y| <0.5
//TH1F _histodata2 = Gr2Hi((TGraph*)data->Get("d02_x01_y01;1")); // 0.5 < |y| < 1.0
//TH1F _histodata3 = Gr2Hi((TGraph*)data->Get("d03_x01_y01;1")); // 1.0 < |y| < 1.5
//TH1F _histodata4 = Gr2Hi((TGraph*)data->Get("d04_x01_y01;1")); // 1.5 < |y| < 2.0
//TH1F _histodata5 = Gr2Hi((TGraph*)data->Get("d05_x01_y01;1")); // 2.0 < |y| < 2.5
//TH1F _histodata6 = Gr2Hi((TGraph*)data->Get("d06_x01_y01;1")); // 2.5 < |y| < 3.0


   Double_t xAxis1[35] = {18, 21, 24, 28, 32, 37, 43, 49, 56, 64, 74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 330, 362, 395, 430, 468, 507, 548, 592, 638, 686, 737, 846, 1684}; 

   TH1F *d01_x01_y01_histo = new TH1F("d01_x01_y01_histo","d01_x01_y01_histo",34, xAxis1);
   d01_x01_y01_histo->SetBinContent(1,1.97e+11);
   d01_x01_y01_histo->SetBinContent(2,1.02e+11);
   d01_x01_y01_histo->SetBinContent(3,5.14e+10);
   d01_x01_y01_histo->SetBinContent(4,2.66e+10);
   d01_x01_y01_histo->SetBinContent(5,1.38e+10);
   d01_x01_y01_histo->SetBinContent(6,6.53e+09);
   d01_x01_y01_histo->SetBinContent(7,3.35e+09);
   d01_x01_y01_histo->SetBinContent(8,1.8e+09);
   d01_x01_y01_histo->SetBinContent(9,9.2e+08);
   d01_x01_y01_histo->SetBinContent(10,4.66e+08);
   d01_x01_y01_histo->SetBinContent(11,2.37e+08);
   d01_x01_y01_histo->SetBinContent(12,1.18e+08);
   d01_x01_y01_histo->SetBinContent(13,5.43e+07);
   d01_x01_y01_histo->SetBinContent(14,2.39e+07);
   d01_x01_y01_histo->SetBinContent(15,1.08e+07);
   d01_x01_y01_histo->SetBinContent(16,5240000);
   d01_x01_y01_histo->SetBinContent(17,2610000);
   d01_x01_y01_histo->SetBinContent(18,1360000);
   d01_x01_y01_histo->SetBinContent(19,716000);
   d01_x01_y01_histo->SetBinContent(20,381000);
   d01_x01_y01_histo->SetBinContent(21,207000);
   d01_x01_y01_histo->SetBinContent(22,117000);
   d01_x01_y01_histo->SetBinContent(23,66800);
   d01_x01_y01_histo->SetBinContent(24,37900);
   d01_x01_y01_histo->SetBinContent(25,22000);
   d01_x01_y01_histo->SetBinContent(26,12900);
   d01_x01_y01_histo->SetBinContent(27,7540);
   d01_x01_y01_histo->SetBinContent(28,4410);
   d01_x01_y01_histo->SetBinContent(29,2770);
   d01_x01_y01_histo->SetBinContent(30,1450);
   d01_x01_y01_histo->SetBinContent(31,846);

   d01_x01_y01_histo->SetBinContent(32,499);
   d01_x01_y01_histo->SetBinContent(33,205);

   d01_x01_y01_histo->SetBinContent(34,20.2);

   d01_x01_y01_histo->SetBinError(1,2.547782e+10);
   d01_x01_y01_histo->SetBinError(2,1.24325e+10);
   d01_x01_y01_histo->SetBinError(3,6.016764e+09);
   d01_x01_y01_histo->SetBinError(4,3.005329e+09);
   d01_x01_y01_histo->SetBinError(5,1.530463e+09);
   d01_x01_y01_histo->SetBinError(6,7.056178e+08);
   d01_x01_y01_histo->SetBinError(7,3.617535e+08);
   d01_x01_y01_histo->SetBinError(8,1.96072e+08);
   d01_x01_y01_histo->SetBinError(9,9.919588e+07);
   d01_x01_y01_histo->SetBinError(10,5.102008e+07);
   d01_x01_y01_histo->SetBinError(11,2.639067e+07);
   d01_x01_y01_histo->SetBinError(12,1.335539e+07);
   d01_x01_y01_histo->SetBinError(13,6258885);
   d01_x01_y01_histo->SetBinError(14,2836105);
   d01_x01_y01_histo->SetBinError(15,1319900);
   d01_x01_y01_histo->SetBinError(16,663920.6);
   d01_x01_y01_histo->SetBinError(17,342646.4);
   d01_x01_y01_histo->SetBinError(18,184642.2);
   d01_x01_y01_histo->SetBinError(19,100845.5);
   d01_x01_y01_histo->SetBinError(20,55764.14);
   d01_x01_y01_histo->SetBinError(21,31565.29);
   d01_x01_y01_histo->SetBinError(22,18614.95);
   d01_x01_y01_histo->SetBinError(23,11075.51);
   d01_x01_y01_histo->SetBinError(24,6579.499);
   d01_x01_y01_histo->SetBinError(25,4015.708);
   d01_x01_y01_histo->SetBinError(26,2479.083);
   d01_x01_y01_histo->SetBinError(27,1527.99);
   d01_x01_y01_histo->SetBinError(28,943.6936);
   d01_x01_y01_histo->SetBinError(29,627.92);
   d01_x01_y01_histo->SetBinError(30,350.3168);
   d01_x01_y01_histo->SetBinError(31,219.1467);
   d01_x01_y01_histo->SetBinError(32,139.7467);
   d01_x01_y01_histo->SetBinError(33,62.02427);
   d01_x01_y01_histo->SetBinError(34,7.233998);
   d01_x01_y01_histo->SetEntries(34);
   d01_x01_y01_histo->SetStats(0);

   //d01_x01_y01_histo->Scale(10000);
   d01_x01_y01_histo->SetLineWidth(2);
   d01_x01_y01_histo->SetMarkerStyle(21);
   d01_x01_y01_histo->SetMarkerSize(0.7);
   d01_x01_y01_histo->SetFillColor(kGray);

   Double_t xAxis2[34] = {18, 21, 24, 28, 32, 37, 43, 49, 56, 64, 74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 330, 362, 395, 430, 468, 507, 548, 592, 638, 686, 790, 1684}; 

   TH1F *d02_x01_y01_histo = new TH1F("d02_x01_y01_histo","d02_x01_y01_histo",33, xAxis2);
   d02_x01_y01_histo->SetBinContent(1,1.89e+10);
   d02_x01_y01_histo->SetBinContent(2,9.74e+09);
   d02_x01_y01_histo->SetBinContent(3,4.99e+09);
   d02_x01_y01_histo->SetBinContent(4,2.49e+09);
   d02_x01_y01_histo->SetBinContent(5,1.31e+09);
   d02_x01_y01_histo->SetBinContent(6,6.28e+08);
   d02_x01_y01_histo->SetBinContent(7,3.23e+08);
   d02_x01_y01_histo->SetBinContent(8,1.71e+08);
   d02_x01_y01_histo->SetBinContent(9,8.84e+07);
   d02_x01_y01_histo->SetBinContent(10,4.42e+07);
   d02_x01_y01_histo->SetBinContent(11,2.22e+07);
   d02_x01_y01_histo->SetBinContent(12,1.13e+07);
   d02_x01_y01_histo->SetBinContent(13,5130000);
   d02_x01_y01_histo->SetBinContent(14,2230000);
   d02_x01_y01_histo->SetBinContent(15,1010000);
   d02_x01_y01_histo->SetBinContent(16,482000);
   d02_x01_y01_histo->SetBinContent(17,238000);
   d02_x01_y01_histo->SetBinContent(18,122000);
   d02_x01_y01_histo->SetBinContent(19,64200);
   d02_x01_y01_histo->SetBinContent(20,34100);
   d02_x01_y01_histo->SetBinContent(21,18700);
   d02_x01_y01_histo->SetBinContent(22,10100);
   d02_x01_y01_histo->SetBinContent(23,5720);
   d02_x01_y01_histo->SetBinContent(24,3420);
   d02_x01_y01_histo->SetBinContent(25,1890);
   d02_x01_y01_histo->SetBinContent(26,1130);
   d02_x01_y01_histo->SetBinContent(27,590);
   d02_x01_y01_histo->SetBinContent(28,376);
   d02_x01_y01_histo->SetBinContent(29,196);
   d02_x01_y01_histo->SetBinContent(30,130);

   d02_x01_y01_histo->SetBinContent(31,62.4);
   d02_x01_y01_histo->SetBinContent(32,30.1);
   d02_x01_y01_histo->SetBinContent(33,2.14);

   d02_x01_y01_histo->SetBinError(1,2.47211e+09);
   d02_x01_y01_histo->SetBinError(2,1.196891e+09);
   d02_x01_y01_histo->SetBinError(3,5.890842e+08);
   d02_x01_y01_histo->SetBinError(4,2.837945e+08);
   d02_x01_y01_histo->SetBinError(5,1.465766e+08);
   d02_x01_y01_histo->SetBinError(6,6.848512e+07);
   d02_x01_y01_histo->SetBinError(7,3.536592e+07);
   d02_x01_y01_histo->SetBinError(8,1.879562e+07);
   d02_x01_y01_histo->SetBinError(9,9619569);
   d02_x01_y01_histo->SetBinError(10,4860292);
   d02_x01_y01_histo->SetBinError(11,2483524);
   d02_x01_y01_histo->SetBinError(12,1278948);
   d02_x01_y01_histo->SetBinError(13,596427.3);
   d02_x01_y01_histo->SetBinError(14,266851);
   d02_x01_y01_histo->SetBinError(15,124973);
   d02_x01_y01_histo->SetBinError(16,61551.8);
   d02_x01_y01_histo->SetBinError(17,31482.64);
   d02_x01_y01_histo->SetBinError(18,16749.58);
   d02_x01_y01_histo->SetBinError(19,9172.852);
   d02_x01_y01_histo->SetBinError(20,5077.065);
   d02_x01_y01_histo->SetBinError(21,2898.771);
   d02_x01_y01_histo->SetBinError(22,1633.017);
   d02_x01_y01_histo->SetBinError(23,965.8504);
   d02_x01_y01_histo->SetBinError(24,606.0352);
   d02_x01_y01_histo->SetBinError(25,351.8168);
   d02_x01_y01_histo->SetBinError(26,221.2594);
   d02_x01_y01_histo->SetBinError(27,122.0002);
   d02_x01_y01_histo->SetBinError(28,82.34314);
   d02_x01_y01_histo->SetBinError(29,45.69701);
   d02_x01_y01_histo->SetBinError(30,32.27314);
   d02_x01_y01_histo->SetBinError(31,16.82748);
   d02_x01_y01_histo->SetBinError(32,8.687436);
   d02_x01_y01_histo->SetBinError(33,0.745178);
   d02_x01_y01_histo->SetEntries(33);
   d02_x01_y01_histo->SetStats(0);

   d02_x01_y01_histo->SetLineStyle(0);
   d02_x01_y01_histo->SetLineWidth(2);
   d02_x01_y01_histo->SetMarkerStyle(22);
   d02_x01_y01_histo->SetMarkerSize(0.7);
   d02_x01_y01_histo->SetFillColor(kGray);


   Double_t xAxis3[33] = {18, 21, 24, 28, 32, 37, 43, 49, 56, 64, 74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 330, 362, 395, 430, 468, 507, 548, 592, 638, 686, 1410}; 

   TH1F *d03_x01_y01_histo = new TH1F("d03_x01_y01_histo","d03_x01_y01_histo",32, xAxis3);
   d03_x01_y01_histo->SetBinContent(1,1.84e+09);
   d03_x01_y01_histo->SetBinContent(2,9.24e+08);
   d03_x01_y01_histo->SetBinContent(3,4.64e+08);
   d03_x01_y01_histo->SetBinContent(4,2.34e+08);
   d03_x01_y01_histo->SetBinContent(5,1.19e+08);
   d03_x01_y01_histo->SetBinContent(6,5.88e+07);
   d03_x01_y01_histo->SetBinContent(7,2.92e+07);
   d03_x01_y01_histo->SetBinContent(8,1.57e+07);
   d03_x01_y01_histo->SetBinContent(9,8090000);
   d03_x01_y01_histo->SetBinContent(10,4090000);
   d03_x01_y01_histo->SetBinContent(11,2050000);
   d03_x01_y01_histo->SetBinContent(12,994000);
   d03_x01_y01_histo->SetBinContent(13,452000);
   d03_x01_y01_histo->SetBinContent(14,192000);
   d03_x01_y01_histo->SetBinContent(15,86200);
   d03_x01_y01_histo->SetBinContent(16,40500);
   d03_x01_y01_histo->SetBinContent(17,20100);
   d03_x01_y01_histo->SetBinContent(18,10000);
   d03_x01_y01_histo->SetBinContent(19,5210);
   d03_x01_y01_histo->SetBinContent(20,2720);
   d03_x01_y01_histo->SetBinContent(21,1470);
   d03_x01_y01_histo->SetBinContent(22,803);
   d03_x01_y01_histo->SetBinContent(23,435);
   d03_x01_y01_histo->SetBinContent(24,252);
   d03_x01_y01_histo->SetBinContent(25,138);
   d03_x01_y01_histo->SetBinContent(26,75.7);
   d03_x01_y01_histo->SetBinContent(27,43.1);
   d03_x01_y01_histo->SetBinContent(28,23.5);
   d03_x01_y01_histo->SetBinContent(29,13.1);

   d03_x01_y01_histo->SetBinContent(30,6.96);
   d03_x01_y01_histo->SetBinContent(31,3.31);
   d03_x01_y01_histo->SetBinContent(32,0.263);

   d03_x01_y01_histo->SetBinError(1,3.267438e+08);
   d03_x01_y01_histo->SetBinError(2,1.460402e+08);
   d03_x01_y01_histo->SetBinError(3,6.756898e+07);
   d03_x01_y01_histo->SetBinError(4,3.169167e+07);
   d03_x01_y01_histo->SetBinError(5,1.534246e+07);
   d03_x01_y01_histo->SetBinError(6,7206299);
   d03_x01_y01_histo->SetBinError(7,3487964);
   d03_x01_y01_histo->SetBinError(8,1852766);
   d03_x01_y01_histo->SetBinError(9,937690);
   d03_x01_y01_histo->SetBinError(10,474695.6);
   d03_x01_y01_histo->SetBinError(11,239744.8);
   d03_x01_y01_histo->SetBinError(12,117028.5);
   d03_x01_y01_histo->SetBinError(13,54375.43);
   d03_x01_y01_histo->SetBinError(14,23751.81);
   d03_x01_y01_histo->SetBinError(15,11010.17);
   d03_x01_y01_histo->SetBinError(16,5355.962);
   d03_x01_y01_histo->SetBinError(17,2760.221);
   d03_x01_y01_histo->SetBinError(18,1428.408);
   d03_x01_y01_histo->SetBinError(19,775.8965);
   d03_x01_y01_histo->SetBinError(20,422.7916);
   d03_x01_y01_histo->SetBinError(21,238.9779);
   d03_x01_y01_histo->SetBinError(22,137.1344);
   d03_x01_y01_histo->SetBinError(23,78.10703);
   d03_x01_y01_histo->SetBinError(24,47.62767);
   d03_x01_y01_histo->SetBinError(25,27.54976);
   d03_x01_y01_histo->SetBinError(26,16.01829);
   d03_x01_y01_histo->SetBinError(27,9.722084);
   d03_x01_y01_histo->SetBinError(28,5.653863);
   d03_x01_y01_histo->SetBinError(29,3.37332);
   d03_x01_y01_histo->SetBinError(30,1.948179);
   d03_x01_y01_histo->SetBinError(31,1.026618);
   d03_x01_y01_histo->SetBinError(32,0.09205037);
   d03_x01_y01_histo->SetEntries(32);
   d03_x01_y01_histo->SetStats(0);

   d03_x01_y01_histo->SetLineStyle(0);
   d03_x01_y01_histo->SetLineWidth(2);
   d03_x01_y01_histo->SetMarkerStyle(25);
   d03_x01_y01_histo->SetMarkerSize(0.7);
   d03_x01_y01_histo->SetFillColor(kGray);

   Double_t xAxis4[30] = {18, 21, 24, 28, 32, 37, 43, 49, 56, 64, 74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 330, 362, 395, 430, 468, 507, 548, 1032}; 

   TH1F *d04_x01_y01_histo = new TH1F("d04_x01_y01_histo","d04_x01_y01_histo",29, xAxis4);
   d04_x01_y01_histo->SetBinContent(1,1.44e+08);
   d04_x01_y01_histo->SetBinContent(2,7.35e+07);
   d04_x01_y01_histo->SetBinContent(3,3.8e+07);
   d04_x01_y01_histo->SetBinContent(4,1.89e+07);
   d04_x01_y01_histo->SetBinContent(5,9700000);
   d04_x01_y01_histo->SetBinContent(6,4670000);
   d04_x01_y01_histo->SetBinContent(7,2280000);
   d04_x01_y01_histo->SetBinContent(8,1220000);
   d04_x01_y01_histo->SetBinContent(9,629000);
   d04_x01_y01_histo->SetBinContent(10,305000);
   d04_x01_y01_histo->SetBinContent(11,151000);
   d04_x01_y01_histo->SetBinContent(12,73400);
   d04_x01_y01_histo->SetBinContent(13,32900);
   d04_x01_y01_histo->SetBinContent(14,13900);
   d04_x01_y01_histo->SetBinContent(15,6160);
   d04_x01_y01_histo->SetBinContent(16,2860);
   d04_x01_y01_histo->SetBinContent(17,1400);
   d04_x01_y01_histo->SetBinContent(18,711);
   d04_x01_y01_histo->SetBinContent(19,356);
   d04_x01_y01_histo->SetBinContent(20,186);
   d04_x01_y01_histo->SetBinContent(21,94.5);
   d04_x01_y01_histo->SetBinContent(22,50.9);
   d04_x01_y01_histo->SetBinContent(23,25.6);
   d04_x01_y01_histo->SetBinContent(24,13.3);
   d04_x01_y01_histo->SetBinContent(25,7);
   d04_x01_y01_histo->SetBinContent(26,3.45);
   d04_x01_y01_histo->SetBinContent(27,1.73);

   d04_x01_y01_histo->SetBinContent(28,0.796);
   d04_x01_y01_histo->SetBinContent(29,0.066);

   d04_x01_y01_histo->SetBinError(1,3.637846e+07);
   d04_x01_y01_histo->SetBinError(2,1.67099e+07);
   d04_x01_y01_histo->SetBinError(3,7851714);
   d04_x01_y01_histo->SetBinError(4,3568673);
   d04_x01_y01_histo->SetBinError(5,1703586);
   d04_x01_y01_histo->SetBinError(6,750723.4);
   d04_x01_y01_histo->SetBinError(7,343490.2);
   d04_x01_y01_histo->SetBinError(8,173448.2);
   d04_x01_y01_histo->SetBinError(9,84294.21);
   d04_x01_y01_histo->SetBinError(10,39082.27);
   d04_x01_y01_histo->SetBinError(11,18979.5);
   d04_x01_y01_histo->SetBinError(12,9119.636);
   d04_x01_y01_histo->SetBinError(13,4140.893);
   d04_x01_y01_histo->SetBinError(14,1810.098);
   d04_x01_y01_histo->SetBinError(15,830.3785);
   d04_x01_y01_histo->SetBinError(16,399.9657);
   d04_x01_y01_histo->SetBinError(17,204.9602);
   d04_x01_y01_histo->SetBinError(18,109.8075);
   d04_x01_y01_histo->SetBinError(19,59.1287);
   d04_x01_y01_histo->SetBinError(20,33.42105);
   d04_x01_y01_histo->SetBinError(21,18.47046);
   d04_x01_y01_histo->SetBinError(22,10.88183);
   d04_x01_y01_histo->SetBinError(23,6.000047);
   d04_x01_y01_histo->SetBinError(24,3.41489);
   d04_x01_y01_histo->SetBinError(25,1.994767);
   d04_x01_y01_histo->SetBinError(26,1.086542);
   d04_x01_y01_histo->SetBinError(27,0.610451);
   d04_x01_y01_histo->SetBinError(28,0.3130872);
   d04_x01_y01_histo->SetBinError(29,0.03211142);
   d04_x01_y01_histo->SetEntries(29);
   d04_x01_y01_histo->SetStats(0);

   d04_x01_y01_histo->SetLineStyle(0);
   d04_x01_y01_histo->SetLineWidth(2);
   d04_x01_y01_histo->SetMarkerStyle(26);
   d04_x01_y01_histo->SetMarkerSize(0.7);
   d04_x01_y01_histo->SetFillColor(kGray);

   Double_t xAxis5[27] = {18, 21, 24, 28, 32, 37, 43, 49, 56, 64, 74, 84, 97, 114, 133, 153, 174, 196, 220, 245, 272, 300, 330, 362, 395, 430, 737};

   TH1F *d05_x01_y01_histo = new TH1F("d05_x01_y01_histo","d05_x01_y01_histo",26, xAxis5);
   d05_x01_y01_histo->SetBinContent(1,1.05e+07);
   d05_x01_y01_histo->SetBinContent(2,5520000);
   d05_x01_y01_histo->SetBinContent(3,2720000);
   d05_x01_y01_histo->SetBinContent(4,1440000);
   d05_x01_y01_histo->SetBinContent(5,738000);
   d05_x01_y01_histo->SetBinContent(6,348000);
   d05_x01_y01_histo->SetBinContent(7,168000);
   d05_x01_y01_histo->SetBinContent(8,89800);
   d05_x01_y01_histo->SetBinContent(9,43800);
   d05_x01_y01_histo->SetBinContent(10,21800);
   d05_x01_y01_histo->SetBinContent(11,10300);
   d05_x01_y01_histo->SetBinContent(12,5030);
   d05_x01_y01_histo->SetBinContent(13,2180);
   d05_x01_y01_histo->SetBinContent(14,896);
   d05_x01_y01_histo->SetBinContent(15,384);
   d05_x01_y01_histo->SetBinContent(16,170);
   d05_x01_y01_histo->SetBinContent(17,78.5);
   d05_x01_y01_histo->SetBinContent(18,35.8);
   d05_x01_y01_histo->SetBinContent(19,16.5);
   d05_x01_y01_histo->SetBinContent(20,7.25);
   d05_x01_y01_histo->SetBinContent(21,3.27);
   d05_x01_y01_histo->SetBinContent(22,1.38);
   d05_x01_y01_histo->SetBinContent(23,0.579);
   d05_x01_y01_histo->SetBinContent(24,0.22);

   d05_x01_y01_histo->SetBinContent(25,0.0808);
   d05_x01_y01_histo->SetBinContent(26,0.00548);

   d05_x01_y01_histo->SetBinError(1,1978672);
   d05_x01_y01_histo->SetBinError(2,935188);
   d05_x01_y01_histo->SetBinError(3,421635.1);
   d05_x01_y01_histo->SetBinError(4,206618.7);
   d05_x01_y01_histo->SetBinError(5,100557.7);
   d05_x01_y01_histo->SetBinError(6,44514.08);
   d05_x01_y01_histo->SetBinError(7,20942.13);
   d05_x01_y01_histo->SetBinError(8,11048.87);
   d05_x01_y01_histo->SetBinError(9,5260.105);
   d05_x01_y01_histo->SetBinError(10,2634.555);
   d05_x01_y01_histo->SetBinError(11,1278.591);
   d05_x01_y01_histo->SetBinError(12,627.8137);
   d05_x01_y01_histo->SetBinError(13,282.1732);
   d05_x01_y01_histo->SetBinError(14,121.6466);
   d05_x01_y01_histo->SetBinError(15,55.24865);
   d05_x01_y01_histo->SetBinError(16,25.82574);
   d05_x01_y01_histo->SetBinError(17,12.76174);
   d05_x01_y01_histo->SetBinError(18,6.253124);
   d05_x01_y01_histo->SetBinError(19,3.142438);
   d05_x01_y01_histo->SetBinError(20,1.508923);
   d05_x01_y01_histo->SetBinError(21,0.7510828);
   d05_x01_y01_histo->SetBinError(22,0.3514478);
   d05_x01_y01_histo->SetBinError(23,0.1646418);
   d05_x01_y01_histo->SetBinError(24,0.071108);
   d05_x01_y01_histo->SetBinError(25,0.02988224);
   d05_x01_y01_histo->SetBinError(26,0.002567773);
   d05_x01_y01_histo->SetEntries(26);
   d05_x01_y01_histo->SetStats(0);

   d05_x01_y01_histo->SetLineStyle(0);
   d05_x01_y01_histo->SetLineWidth(2);
   d05_x01_y01_histo->SetMarkerStyle(3);
   d05_x01_y01_histo->SetMarkerSize(0.7);
   d05_x01_y01_histo->SetFillColor(kGray);

// MC / Data
TH1F *_ratio[6][3];
TH1F *_ratio_pyth[6][1];

for(const int ifile = 0; ifile < n; ifile++){
  for(const int ihisto = 0; ihisto < nh; ihisto++){

    TH1F *_ratio[ihisto][ifile]= (TH1F*)_histo[ihisto][ifile]->Clone("");
    TH1F *_ratio_pyth[ihisto][0]= (TH1F*)_histo_pyth[ihisto][0]->Clone("");

    _ratio[ihisto][ifile]->SetLineWidth(1);
    _ratio[ihisto][ifile]->SetLineColor(icol[ihisto]);
    _ratio[ihisto][ifile]->SetMarkerStyle(imark[ihisto]);
    _ratio[ihisto][ifile]->SetMarkerSize(0.5);
    _ratio[ihisto][ifile]->SetMarkerColor(icol[ihisto]);

    _ratio_pyth[ihisto][0]->SetLineWidth(1);
    _ratio_pyth[ihisto][0]->SetLineColor(icol[ihisto]);
    _ratio_pyth[ihisto][0]->SetLineStyle(3);
    _ratio_pyth[ihisto][0]->SetMarkerStyle(imark[ihisto]);
    _ratio_pyth[ihisto][0]->SetMarkerSize(0.5);
    _ratio_pyth[ihisto][0]->SetMarkerColor(icol[ihisto]);
 }

  _ratio[0][ifile]->Divide((TH1*)d01_x01_y01_histo);  
  _ratio[1][ifile]->Divide((TH1*)d02_x01_y01_histo);  
  _ratio[2][ifile]->Divide((TH1*)d03_x01_y01_histo);  
  _ratio[3][ifile]->Divide((TH1*)d04_x01_y01_histo);  
  _ratio[4][ifile]->Divide((TH1*)d05_x01_y01_histo);  


//  TH1F *_ratio[ihisto]= (TH1F*)_ratiotmp1[ihisto]->Clone("");
// _ratiotmp2[ihisto]->Divide((TH1*)_histo[ihisto][2]);  //histo 0 / hsito 2
//  TH1F *_ratio2[ihisto]= (TH1F*)_ratiotmp2[ihisto]->Clone("");

}

  _ratio_pyth[0][0]->Divide((TH1*)d01_x01_y01_histo);  
  _ratio_pyth[1][0]->Divide((TH1*)d02_x01_y01_histo);  
  _ratio_pyth[2][0]->Divide((TH1*)d03_x01_y01_histo);  
  _ratio_pyth[3][0]->Divide((TH1*)d04_x01_y01_histo);  
  _ratio_pyth[4][0]->Divide((TH1*)d05_x01_y01_histo);  

// Data / MC
TH1F *_ratio_datamc[6][3];
TH1F *_ratio_pyth_datamc[6][1];

    TH1F *_ratio_pyth_datamc[0][0]= (TH1F*)d01_x01_y01_histo->Clone("");
    TH1F *_ratio_pyth_datamc[1][0]= (TH1F*)d02_x01_y01_histo->Clone("");
    TH1F *_ratio_pyth_datamc[2][0]= (TH1F*)d03_x01_y01_histo->Clone("");
    TH1F *_ratio_pyth_datamc[3][0]= (TH1F*)d04_x01_y01_histo->Clone("");
    TH1F *_ratio_pyth_datamc[4][0]= (TH1F*)d05_x01_y01_histo->Clone("");


for(const int ifile = 0; ifile < n; ifile++){

    TH1F *_ratio_datamc[0][ifile]= (TH1F*)d01_x01_y01_histo->Clone("");
    TH1F *_ratio_datamc[1][ifile]= (TH1F*)d02_x01_y01_histo->Clone("");
    TH1F *_ratio_datamc[2][ifile]= (TH1F*)d03_x01_y01_histo->Clone("");
    TH1F *_ratio_datamc[3][ifile]= (TH1F*)d04_x01_y01_histo->Clone("");
    TH1F *_ratio_datamc[4][ifile]= (TH1F*)d05_x01_y01_histo->Clone("");


  for(const int ihisto = 0; ihisto < 5; ihisto++){ 
    _ratio_datamc[ihisto][ifile]->Divide((TH1F*)_histo[ihisto][ifile]); 
	
    _ratio_datamc[ihisto][ifile]->SetLineWidth(1);
    _ratio_datamc[ihisto][ifile]->SetLineColor(icol[ihisto]);
    _ratio_datamc[ihisto][ifile]->SetMarkerStyle(imark[ihisto]);
    _ratio_datamc[ihisto][ifile]->SetMarkerSize(0.5);
    _ratio_datamc[ihisto][ifile]->SetMarkerColor(icol[ihisto]);
    _ratio_datamc[ihisto][ifile]->SetFillColor(0);

    _ratio_pyth_datamc[ihisto][0]->Divide((TH1F*)_histo_pyth[ihisto][0]); 
	
    _ratio_pyth_datamc[ihisto][0]->SetLineWidth(1);
    _ratio_pyth_datamc[ihisto][0]->SetLineColor(icol[ihisto]);
    _ratio_pyth_datamc[ihisto][0]->SetLineStyle(3);
    _ratio_pyth_datamc[ihisto][0]->SetMarkerStyle(imark[ihisto]);
    _ratio_pyth_datamc[ihisto][0]->SetMarkerSize(0.5);
    _ratio_pyth_datamc[ihisto][0]->SetMarkerColor(icol[ihisto]);
    _ratio_pyth_datamc[ihisto][0]->SetFillColor(0);
  }
}

//create a canvas to draw TGraph and TH1F

TCanvas *c1 = new TCanvas("c1", "c1",369,0,680,550);

    //pads (inclusive jet cross section, MC / data )
   Pad_inclJet = new TPad("Pad_inclJet","xs",0.01,0.01,1.0,1.0);
   Pad_inclJet->Draw();

// first pad style
   Pad_inclJet->cd();
   gStyle->SetOptStat(0);
   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLogy();
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.03);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

//empty histo for border and style

   TH1F *shape = new TH1F("","",1, xmin, xmax);
   shape->SetMinimum(ymin);
   shape->SetMaximum(ymax); 
   shape->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
   shape->GetXaxis()->SetLabelSize(0.03);
   shape->GetXaxis()->SetTitleSize(0.03);
   shape->GetXaxis()->SetNdivisions(508);
   shape->GetXaxis()->SetTitleOffset(1.3);
   shape->GetXaxis()->SetMoreLogLabels();
   shape->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T}d|y|} (pb/GeV)");
   shape->GetYaxis()->SetLabelSize(0.03);
   shape->GetYaxis()->SetTitleSize(0.03);
   shape->GetYaxis()->SetTitleOffset(1.6);
   shape->Draw("e");

  gPad->SetLogy();
  gPad->SetLogx();

  //data
  d01_x01_y01_histo->Draw("E2same");
  d02_x01_y01_histo->Draw("E2same");
  d03_x01_y01_histo->Draw("E2same");
  d04_x01_y01_histo->Draw("E2same");
  d05_x01_y01_histo->Draw("E2same");

	_histo[0][0]->Draw("E1same");
	_histo[1][0]->Draw("E1same");
	_histo[2][0]->Draw("E1same");
	_histo[3][0]->Draw("E1same");
	_histo[4][0]->Draw("E1same");

//	_histo_herw[0][0]->Draw("E1same");
//	_histo_herw[1][0]->Draw("E1same");
//	_histo_herw[2][0]->Draw("E1same");
//	_histo_herw[3][0]->Draw("E1same");
//	_histo_herw[4][0]->Draw("E1same");


	_histo_pyth[0][0]->Draw("E1same");
	_histo_pyth[1][0]->Draw("E1same");
	_histo_pyth[2][0]->Draw("E1same");
	_histo_pyth[3][0]->Draw("E1same");
	_histo_pyth[4][0]->Draw("E1same");



   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.17,0.79,0.37,0.95,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.03);
   text = pt->AddText("CMS 2010");
   text = pt->AddText("#sqrt{s} = 7 TeV");
   text = pt->AddText("anti-k_{T} R = 0.5");
   pt->Draw();

TLegend *leg = new TLegend(0.68,0.70,0.83,0.928);
   leg->SetBorderSize(1);
   leg->SetTextSize(0.025);
   leg->SetLineColor(0);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);

   leg->AddEntry((TH1F*)_histo[0][0],"POWHEG & Pythia6 Z2","pfl");
   leg->AddEntry((TH1F*)_histo_pyth[0][0]," Pythia6 Z2","pfl");
   leg->AddEntry((TH1F*)  d01_x01_y01_histo, "|y| <0.5 (x 10^{4})","pfl");
   leg->AddEntry((TH1F*)  d02_x01_y01_histo, "0.5 < |y| < 1.0 (x 10^{3})","pfl");
   leg->AddEntry((TH1F*)  d03_x01_y01_histo, "1.0 < |y| < 1.5 (x 10^{2})","pfl");
   leg->AddEntry((TH1F*)  d04_x01_y01_histo, "1.5 < |y| < 2.0 (x 10^{1})","pfl");
   leg->AddEntry((TH1F*)  d05_x01_y01_histo, "2.0 < |y| < 2.5 (x 10^{0})","pfl");

   leg->Draw();

//write in png file
mysubpad1 =(TPad*)c1->GetPad(0);
mysubpad1->Print("pics/InclusiveJets_xs_10.png");
mysubpad1->Print("~/DESY/ANALYSIS_NOTES/JetCrossSectionsWithPOWHEG/notes/AN-12-236/trunk/plots/InclusiveJets_xs_10.pdf");


// MC / Data 

//create a canvas to draw TGraph and TH1F

TCanvas *c2 = new TCanvas("c2", "c2",369,0,680,550);

   Pad_MCdata1 = new TPad("Pad_MCdata1","ratio",0.01,0.78,1.0,0.95);
   Pad_MCdata1->Draw();
   Pad_MCdata2 = new TPad("Pad_MCdata2","ratio",0.01,0.60,1.0,0.76);
   Pad_MCdata2->Draw();
   Pad_MCdata3 = new TPad("Pad_MCdata3","ratio",0.01,0.42,1.0,0.58);
   Pad_MCdata3->Draw();
   Pad_MCdata4 = new TPad("Pad_MCdata4","ratio",0.01,0.24,1.0,0.40);
   Pad_MCdata4->Draw();
   Pad_MCdata5 = new TPad("Pad_MCdata5","ratio",0.01,0.06,1.0,0.22);
   Pad_MCdata5->Draw();

   Pad_MCdata1->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   //AK Empty histo for style and borders
   TH1F *shape_MCdata = new TH1F("","",1, xmin, xmax);
   shape_MCdata->SetMinimum(0.5);
   shape_MCdata->SetMaximum(2.0);
   shape_MCdata->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
   shape_MCdata->GetXaxis()->SetLabelSize(0.1);
   shape_MCdata->GetXaxis()->SetTitleSize(0.1);
   shape_MCdata->GetXaxis()->SetTitleOffset(0.6);
   shape_MCdata->GetXaxis()->SetMoreLogLabels();
   shape_MCdata->GetYaxis()->SetTitle("MC/Data");
   shape_MCdata->GetYaxis()->SetLabelSize(0.1);
   shape_MCdata->GetYaxis()->SetTitleSize(0.15);
   shape_MCdata->GetYaxis()->SetTitleOffset(0.2);
   shape_MCdata->GetYaxis()->SetNdivisions(108, kTRUE);   
   shape_MCdata->Draw("e");   

// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.89,0.7,0.94,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("|y| <0.5");
   pt->Draw();

	_ratio[0][0]->Draw("EhistSame");
	_ratio_pyth[0][0]->Draw("EhistSame");

   Pad_MCdata2->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_MCdata->Draw("e");   



// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("0.5 < |y| < 1.0");
   pt->Draw();

	_ratio[1][0]->Draw("EhistSame");
	_ratio_pyth[1][0]->Draw("EhistSame");

   Pad_MCdata3->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_MCdata->Draw("e");   
// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("1.0 < |y| < 1.5");
   pt->Draw();
	_ratio[2][0]->Draw("EhistSame");
	_ratio_pyth[2][0]->Draw("EhistSame");

   Pad_MCdata4->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_MCdata->Draw("e");   
// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("1.5 < |y| < 2.0");
   pt->Draw();
	_ratio[3][0]->Draw("EhistSame");
	_ratio_pyth[3][0]->Draw("EhistSame");

   Pad_MCdata5->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_MCdata->Draw("e");   
// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("2.0 < |y| < 2.5");
   pt->Draw();
	_ratio[4][0]->Draw("EhistSame");
	_ratio_pyth[4][0]->Draw("EhistSame");

//write in png file
mysubpad2 =(TPad*)c2->GetPad(0);
mysubpad2->Print("pics/InclusiveJets_mcdataRatio_10.png");
mysubpad2->Print("~/DESY/ANALYSIS_NOTES/JetCrossSectionsWithPOWHEG/notes/AN-12-236/trunk/plots/InclusiveJets_mcdataRatio_10.pdf");

// Data / MC 

//create a canvas to draw TGraph and TH1F

TCanvas *c3 = new TCanvas("c3", "c3",369,0,680,550);

   Pad_DataMC1 = new TPad("Pad_DataMC1","ratio",0.01,0.78,1.0,0.95);
   Pad_DataMC1->Draw();
   Pad_DataMC2 = new TPad("Pad_DataMC2","ratio",0.01,0.60,1.0,0.76);
   Pad_DataMC2->Draw();
   Pad_DataMC3 = new TPad("Pad_DataMC3","ratio",0.01,0.42,1.0,0.58);
   Pad_DataMC3->Draw();
   Pad_DataMC4 = new TPad("Pad_DataMC4","ratio",0.01,0.24,1.0,0.40);
   Pad_DataMC4->Draw();
   Pad_DataMC5 = new TPad("Pad_DataMC5","ratio",0.01,0.06,1.0,0.22);
   Pad_DataMC5->Draw();

   Pad_DataMC1->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   //AK Empty histo for style and borders
   TH1F *shape_DataMC = new TH1F("","",1, xmin, xmax);
   shape_DataMC->SetMinimum(0.5);
   shape_DataMC->SetMaximum(2.0);
   shape_DataMC->GetXaxis()->SetTitle("Jet p_{T} (GeV/c)");
   shape_DataMC->GetXaxis()->SetLabelSize(0.1);
   shape_DataMC->GetXaxis()->SetTitleSize(0.1);
   shape_DataMC->GetXaxis()->SetTitleOffset(0.6);
   shape_DataMC->GetXaxis()->SetMoreLogLabels();
   shape_DataMC->GetYaxis()->SetTitle("Data/MC");
   shape_DataMC->GetYaxis()->SetLabelSize(0.1);
   shape_DataMC->GetYaxis()->SetTitleSize(0.15);
   shape_DataMC->GetYaxis()->SetTitleOffset(0.2);
   shape_DataMC->GetYaxis()->SetNdivisions(108, kTRUE);   
   shape_DataMC->Draw("e");   

// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.89,0.7,0.94,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("|y| <0.5");
   pt->Draw();

	_ratio_datamc[0][0]->Draw("EhistSame");
	_ratio_pyth_datamc[0][0]->Draw("EhistSame");

   Pad_DataMC2->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_DataMC->Draw("e");   



// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("0.5 < |y| < 1.0");
   pt->Draw();

	_ratio_datamc[1][0]->Draw("EhistSame");
	_ratio_pyth_datamc[1][0]->Draw("EhistSame");

   Pad_DataMC3->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_DataMC->Draw("e");   
// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("1.0 < |y| < 1.5");
   pt->Draw();
	_ratio_datamc[2][0]->Draw("EhistSame");
	_ratio_pyth_datamc[2][0]->Draw("EhistSame");

   Pad_DataMC4->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_DataMC->Draw("e");   
// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("1.5 < |y| < 2.0");
   pt->Draw();
	_ratio_datamc[3][0]->Draw("EhistSame");
	_ratio_pyth_datamc[3][0]->Draw("EhistSame");

   Pad_DataMC5->cd();

   gPad->SetFillColor(0);
   gPad->SetBorderMode(0);
   gPad->SetBorderSize(2);
   gPad->SetLeftMargin(0.14);
   gPad->SetRightMargin(0.03);
   gPad->SetTopMargin(0.0);
   gPad->SetFrameBorderMode(0);
   gPad->SetFrameBorderMode(0);

  gPad->SetLogx();

   shape_DataMC->Draw("e");   
// horizontal line at y = 1
   TLine *line = new TLine(xmin,1,xmax,1);
   line->SetLineStyle(2);
   line->Draw();

   TPaveText *pt = new TPaveText(0.84,0.7,0.89,0.8,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.15);
   text = pt->AddText("2.0 < |y| < 2.5");
   pt->Draw();
	_ratio_datamc[4][0]->Draw("EhistSame");
	_ratio_pyth_datamc[4][0]->Draw("EhistSame");

//write in png file
mysubpad3 =(TPad*)c3->GetPad(0);
mysubpad3->Print("pics/InclusiveJets_DataMCRatio_10.png");
mysubpad3->Print("~/DESY/ANALYSIS_NOTES/JetCrossSectionsWithPOWHEG/notes/AN-12-236/trunk/plots/InclusiveJets_DataMCRatio_10.pdf");

c1->Print("InclusiveJets_2010.pdf(");
c2->Print("InclusiveJets_2010.pdf");
c3->Print("InclusiveJets_2010.pdf)");
} 
示例#12
0
void makeplot(){

    
    gStyle->SetOptStat(0);
    TFile * file_1 = TFile::Open("CorrelationPlotsPerugia0PtDstarfromB5To8_ptAssall1.0to99.0_DeltaEta10.root");//file->ls();
    
    TCanvas * c = (TCanvas*)file_1->Get("cDeltaPhi");
    TH1D * h_Perugia0 = (TH1D*)c->FindObject("hCorrDeltaPhi");
    h_Perugia0->SetName("h_Perugia0");
    
    
    TFile * file_2 = TFile::Open("CorrelationPlotsPerugia2010PtDstarfromB5To8_ptAssall1.0to99.0_DeltaEta10.root");//file->ls();
    
    c = (TCanvas*)file_2->Get("cDeltaPhi");
    TH1D * h_Perugia2010 = (TH1D*)c->FindObject("hCorrDeltaPhi");
    h_Perugia2010->SetName("h_Perugia2010");
    
    
    TFile * file_3 = TFile::Open("CorrelationPlotsPerugia2011PtDstarfromB5To8_ptAssall1.0to99.0_DeltaEta10.root");//file->ls();
    
    c = (TCanvas*)file_3->Get("cDeltaPhi");
    TH1D * h_Perugia2011 = (TH1D*)c->FindObject("hCorrDeltaPhi");
    h_Perugia2011->SetName("h_Perugia2011");
    
    
    TPaveText * PaveText = new TPaveText(0.5,0.55,0.8,0.85,"NDC");
    PaveText->SetBorderSize(0);
    PaveText->SetFillColor(0);
    PaveText->SetName("pave");
    PaveText->AddText("THIS THESIS");
    PaveText->AddText(" ");
    PaveText->AddText("Comparison of Pythia templates, pp #sqrt{s} = 7 TeV");
    PaveText->AddText(" ");
    PaveText->AddText("(B #rightarrow D*^{+}) - charged particle correlations");
    
    
    
    h_Perugia0->SetMarkerStyle(20); h_Perugia2010->SetMarkerStyle(20); h_Perugia2011->SetMarkerStyle(20);
    h_Perugia0->SetMarkerColor(1); h_Perugia2010->SetMarkerColor(2); h_Perugia2011->SetMarkerColor(4);
    h_Perugia0->SetLineColor(1); h_Perugia2010->SetLineColor(2); h_Perugia2011->SetLineColor(4);
    
    
    
    TCanvas * c = new TCanvas("c","c",0,0,1000,1000);
    c->cd();
    h_Perugia0->SetTitle(";#Delta#varphi;#frac{1}{N_{D}}#frac{dN}{d#Delta#varphi}");
    h_Perugia0->GetYaxis()->SetRangeUser(0,4);
    h_Perugia0->Draw("ep");
    h_Perugia2010->Draw("sameep");
    h_Perugia2011->Draw("sameep");
    
    TLegend * legend = new TLegend(0.1,0.6,0.4,0.85);
    //  TLegend * legend = new TLegend(0.1, 1.2*DStarPeak->GetBinContent(DStarPeak->GetMaximumBin()),0.4, 1.6*DStarPeak->GetBinContent(DStarPeak->GetMaximumBin()));
    legend->SetFillColor(0);
    legend->SetTextSize(0.02);
    legend->AddEntry(h_Perugia0,"Pythia, Perugia 0 tune","lep");
    legend->AddEntry(h_Perugia2010,"Pythia, Perugia 2010 tune","lep");
    legend->AddEntry(h_Perugia2011,"Pythia, Perugia 2011 tune","lep");
    
    legend->Draw("same");
    PaveText->Draw("same");
    
    
    return;
    c->SaveAs("templates_pp.png");
   
}
void phimuphij1b2()
{
//=========Macro generated from canvas: b2/phimuphij1b2/b2/phimuphij1b2
//=========  (Tue Nov 24 14:26:24 2015) by ROOT version6.02/05
   TCanvas *b2/phimuphij1b2 = new TCanvas("b2/phimuphij1b2", "b2/phimuphij1b2",0,22,700,700);
   b2/phimuphij1b2->Range(-3.926991,-5.768034,3.926991,-0.6435428);
   b2/phimuphij1b2->SetFillColor(0);
   b2/phimuphij1b2->SetBorderMode(0);
   b2/phimuphij1b2->SetBorderSize(2);
   b2/phimuphij1b2->SetLogy();
   b2/phimuphij1b2->SetFrameBorderMode(0);
   b2/phimuphij1b2->SetFrameBorderMode(0);
   
   THStack *b2/phimuphij1b2 = new THStack();
   b2/phimuphij1b2->SetName("b2/phimuphij1b2");
   b2/phimuphij1b2->SetTitle("b2/phimuphij1b2");
   
   TH1F *b2/phimuphij1b2_stack_1 = new TH1F("b2/phimuphij1b2_stack_1","b2/phimuphij1b2",20,-3.141593,3.141593);
   b2/phimuphij1b2_stack_1->SetMinimum(5.551561e-06);
   b2/phimuphij1b2_stack_1->SetMaximum(0.06982454);
   b2/phimuphij1b2_stack_1->SetDirectory(0);
   b2/phimuphij1b2_stack_1->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   b2/phimuphij1b2_stack_1->SetLineColor(ci);
   b2/phimuphij1b2_stack_1->GetXaxis()->SetTitle("b2/phimuphij1b2");
   b2/phimuphij1b2_stack_1->GetXaxis()->SetLabelFont(42);
   b2/phimuphij1b2_stack_1->GetXaxis()->SetLabelSize(0.035);
   b2/phimuphij1b2_stack_1->GetXaxis()->SetTitleSize(0.035);
   b2/phimuphij1b2_stack_1->GetXaxis()->SetTitleFont(42);
   b2/phimuphij1b2_stack_1->GetYaxis()->SetTitle("Events/pb");
   b2/phimuphij1b2_stack_1->GetYaxis()->SetLabelFont(42);
   b2/phimuphij1b2_stack_1->GetYaxis()->SetLabelSize(0.035);
   b2/phimuphij1b2_stack_1->GetYaxis()->SetTitleSize(0.035);
   b2/phimuphij1b2_stack_1->GetYaxis()->SetTitleFont(42);
   b2/phimuphij1b2_stack_1->GetZaxis()->SetLabelFont(42);
   b2/phimuphij1b2_stack_1->GetZaxis()->SetLabelSize(0.035);
   b2/phimuphij1b2_stack_1->GetZaxis()->SetTitleSize(0.035);
   b2/phimuphij1b2_stack_1->GetZaxis()->SetTitleFont(42);
   b2/phimuphij1b2->SetHistogram(b2/phimuphij1b2_stack_1);
   
   
   TH1D *phimuphij1b21 = new TH1D("phimuphij1b21"," #Delta_{#phi}[#mu,jet_{1}]",20,-3.141593,3.141593);
   phimuphij1b21->SetBinContent(1,0.00068069);
   phimuphij1b21->SetBinContent(2,0.01036084);
   phimuphij1b21->SetBinContent(3,0.00136138);
   phimuphij1b21->SetBinContent(4,0.00204207);
   phimuphij1b21->SetBinContent(5,0.00968015);
   phimuphij1b21->SetBinContent(6,0.01663754);
   phimuphij1b21->SetBinContent(7,0.00136138);
   phimuphij1b21->SetBinContent(8,0.01731823);
   phimuphij1b21->SetBinContent(9,0.00272276);
   phimuphij1b21->SetBinContent(10,0.00136138);
   phimuphij1b21->SetBinContent(11,0.01104153);
   phimuphij1b21->SetBinContent(12,0.00831877);
   phimuphij1b21->SetBinContent(15,0.00831877);
   phimuphij1b21->SetBinContent(16,0.00272276);
   phimuphij1b21->SetBinContent(17,0.01731823);
   phimuphij1b21->SetBinContent(18,0.00340345);
   phimuphij1b21->SetBinContent(19,0.00899946);
   phimuphij1b21->SetBinContent(20,0.00831877);
   phimuphij1b21->SetBinError(1,0.00068069);
   phimuphij1b21->SetBinError(2,0.008401902);
   phimuphij1b21->SetBinError(3,0.000962641);
   phimuphij1b21->SetBinError(4,0.00117899);
   phimuphij1b21->SetBinError(5,0.008374283);
   phimuphij1b21->SetBinError(6,0.01176452);
   phimuphij1b21->SetBinError(7,0.000962641);
   phimuphij1b21->SetBinError(8,0.01178419);
   phimuphij1b21->SetBinError(9,0.00136138);
   phimuphij1b21->SetBinError(10,0.000962641);
   phimuphij1b21->SetBinError(11,0.00842943);
   phimuphij1b21->SetBinError(12,0.00831877);
   phimuphij1b21->SetBinError(15,0.00831877);
   phimuphij1b21->SetBinError(16,0.00136138);
   phimuphij1b21->SetBinError(17,0.01178419);
   phimuphij1b21->SetBinError(18,0.001522069);
   phimuphij1b21->SetBinError(19,0.008346573);
   phimuphij1b21->SetBinError(20,0.00831877);
   phimuphij1b21->SetEntries(48);

   ci = TColor::GetColor("#00cc00");
   phimuphij1b21->SetFillColor(ci);

   ci = TColor::GetColor("#00cc00");
   phimuphij1b21->SetLineColor(ci);

   ci = TColor::GetColor("#00cc00");
   phimuphij1b21->SetMarkerColor(ci);
   phimuphij1b21->SetMarkerStyle(22);
   phimuphij1b21->GetXaxis()->SetTitle("phimuphij1b2");
   phimuphij1b21->GetXaxis()->SetLabelFont(42);
   phimuphij1b21->GetXaxis()->SetLabelSize(0.035);
   phimuphij1b21->GetXaxis()->SetTitleSize(0.035);
   phimuphij1b21->GetXaxis()->SetTitleFont(42);
   phimuphij1b21->GetYaxis()->SetTitle("Events/pb");
   phimuphij1b21->GetYaxis()->SetLabelFont(42);
   phimuphij1b21->GetYaxis()->SetLabelSize(0.035);
   phimuphij1b21->GetYaxis()->SetTitleSize(0.035);
   phimuphij1b21->GetYaxis()->SetTitleFont(42);
   phimuphij1b21->GetZaxis()->SetLabelFont(42);
   phimuphij1b21->GetZaxis()->SetLabelSize(0.035);
   phimuphij1b21->GetZaxis()->SetTitleSize(0.035);
   phimuphij1b21->GetZaxis()->SetTitleFont(42);
   b2/phimuphij1b2->Add(phimuphij1b2,"");
   
   TH1D *phimuphij1b22 = new TH1D("phimuphij1b22"," #Delta_{#phi}[#mu,jet_{1}]",20,-3.141593,3.141593);
   phimuphij1b22->SetBinContent(1,0.04137542);
   phimuphij1b22->SetBinContent(2,0.03986725);
   phimuphij1b22->SetBinContent(3,0.03273531);
   phimuphij1b22->SetBinContent(4,0.03105146);
   phimuphij1b22->SetBinContent(5,0.03641875);
   phimuphij1b22->SetBinContent(6,0.03455958);
   phimuphij1b22->SetBinContent(7,0.02910451);
   phimuphij1b22->SetBinContent(8,0.02077217);
   phimuphij1b22->SetBinContent(9,0.01778479);
   phimuphij1b22->SetBinContent(10,0.01732303);
   phimuphij1b22->SetBinContent(11,0.0180287);
   phimuphij1b22->SetBinContent(12,0.01852663);
   phimuphij1b22->SetBinContent(13,0.01948645);
   phimuphij1b22->SetBinContent(14,0.02574106);
   phimuphij1b22->SetBinContent(15,0.03613609);
   phimuphij1b22->SetBinContent(16,0.03646323);
   phimuphij1b22->SetBinContent(17,0.0361111);
   phimuphij1b22->SetBinContent(18,0.03276386);
   phimuphij1b22->SetBinContent(19,0.03615144);
   phimuphij1b22->SetBinContent(20,0.04006042);
   phimuphij1b22->SetBinError(1,0.002009439);
   phimuphij1b22->SetBinError(2,0.002377916);
   phimuphij1b22->SetBinError(3,0.002001171);
   phimuphij1b22->SetBinError(4,0.001746659);
   phimuphij1b22->SetBinError(5,0.002172329);
   phimuphij1b22->SetBinError(6,0.002945802);
   phimuphij1b22->SetBinError(7,0.002553361);
   phimuphij1b22->SetBinError(8,0.002145404);
   phimuphij1b22->SetBinError(9,0.001656662);
   phimuphij1b22->SetBinError(10,0.00245249);
   phimuphij1b22->SetBinError(11,0.001906121);
   phimuphij1b22->SetBinError(12,0.002110143);
   phimuphij1b22->SetBinError(13,0.001699056);
   phimuphij1b22->SetBinError(14,0.002615756);
   phimuphij1b22->SetBinError(15,0.002701343);
   phimuphij1b22->SetBinError(16,0.002685858);
   phimuphij1b22->SetBinError(17,0.002120004);
   phimuphij1b22->SetBinError(18,0.001791061);
   phimuphij1b22->SetBinError(19,0.002092237);
   phimuphij1b22->SetBinError(20,0.00198632);
   phimuphij1b22->SetEntries(12325);

   ci = TColor::GetColor("#00ffff");
   phimuphij1b22->SetFillColor(ci);

   ci = TColor::GetColor("#00ffff");
   phimuphij1b22->SetLineColor(ci);

   ci = TColor::GetColor("#00ffff");
   phimuphij1b22->SetMarkerColor(ci);
   phimuphij1b22->SetMarkerStyle(20);
   phimuphij1b22->GetXaxis()->SetTitle("phimuphij1b2");
   phimuphij1b22->GetXaxis()->SetLabelFont(42);
   phimuphij1b22->GetXaxis()->SetLabelSize(0.035);
   phimuphij1b22->GetXaxis()->SetTitleSize(0.035);
   phimuphij1b22->GetXaxis()->SetTitleFont(42);
   phimuphij1b22->GetYaxis()->SetTitle("Events/pb");
   phimuphij1b22->GetYaxis()->SetLabelFont(42);
   phimuphij1b22->GetYaxis()->SetLabelSize(0.035);
   phimuphij1b22->GetYaxis()->SetTitleSize(0.035);
   phimuphij1b22->GetYaxis()->SetTitleFont(42);
   phimuphij1b22->GetZaxis()->SetLabelFont(42);
   phimuphij1b22->GetZaxis()->SetLabelSize(0.035);
   phimuphij1b22->GetZaxis()->SetTitleSize(0.035);
   phimuphij1b22->GetZaxis()->SetTitleFont(42);
   b2/phimuphij1b2->Add(phimuphij1b2,"");
   
   TH1D *phimuphij1b23 = new TH1D("phimuphij1b23"," #Delta_{#phi}[#mu,jet_{1}]",20,-3.141593,3.141593);
   phimuphij1b23->SetBinContent(1,0.006649729);
   phimuphij1b23->SetBinContent(2,0.007444725);
   phimuphij1b23->SetBinContent(3,0.007888234);
   phimuphij1b23->SetBinContent(4,0.007265599);
   phimuphij1b23->SetBinContent(5,0.006848077);
   phimuphij1b23->SetBinContent(6,0.007819311);
   phimuphij1b23->SetBinContent(7,0.007051546);
   phimuphij1b23->SetBinContent(8,0.008439558);
   phimuphij1b23->SetBinContent(9,0.007995002);
   phimuphij1b23->SetBinContent(10,0.00688144);
   phimuphij1b23->SetBinContent(11,0.007371811);
   phimuphij1b23->SetBinContent(12,0.007197418);
   phimuphij1b23->SetBinContent(13,0.008005155);
   phimuphij1b23->SetBinContent(14,0.007279188);
   phimuphij1b23->SetBinContent(15,0.007343546);
   phimuphij1b23->SetBinContent(16,0.007613491);
   phimuphij1b23->SetBinContent(17,0.006703878);
   phimuphij1b23->SetBinContent(18,0.006361762);
   phimuphij1b23->SetBinContent(19,0.006790305);
   phimuphij1b23->SetBinContent(20,0.007526583);
   phimuphij1b23->SetBinError(1,0.0004008747);
   phimuphij1b23->SetBinError(2,0.0004462735);
   phimuphij1b23->SetBinError(3,0.0004314751);
   phimuphij1b23->SetBinError(4,0.0004424609);
   phimuphij1b23->SetBinError(5,0.0004042449);
   phimuphij1b23->SetBinError(6,0.0004355879);
   phimuphij1b23->SetBinError(7,0.0004038257);
   phimuphij1b23->SetBinError(8,0.0004607381);
   phimuphij1b23->SetBinError(9,0.00046367);
   phimuphij1b23->SetBinError(10,0.0004097207);
   phimuphij1b23->SetBinError(11,0.0004188017);
   phimuphij1b23->SetBinError(12,0.00042797);
   phimuphij1b23->SetBinError(13,0.0004395045);
   phimuphij1b23->SetBinError(14,0.0004170824);
   phimuphij1b23->SetBinError(15,0.0003964381);
   phimuphij1b23->SetBinError(16,0.0004612123);
   phimuphij1b23->SetBinError(17,0.0004092152);
   phimuphij1b23->SetBinError(18,0.0003934027);
   phimuphij1b23->SetBinError(19,0.0004066076);
   phimuphij1b23->SetBinError(20,0.0004388505);
   phimuphij1b23->SetEntries(19290);

   ci = TColor::GetColor("#ffcc00");
   phimuphij1b23->SetFillColor(ci);

   ci = TColor::GetColor("#ffcc00");
   phimuphij1b23->SetLineColor(ci);

   ci = TColor::GetColor("#ffcc00");
   phimuphij1b23->SetMarkerColor(ci);
   phimuphij1b23->SetMarkerStyle(21);
   phimuphij1b23->GetXaxis()->SetTitle("phimuphij1b2");
   phimuphij1b23->GetXaxis()->SetLabelFont(42);
   phimuphij1b23->GetXaxis()->SetLabelSize(0.035);
   phimuphij1b23->GetXaxis()->SetTitleSize(0.035);
   phimuphij1b23->GetXaxis()->SetTitleFont(42);
   phimuphij1b23->GetYaxis()->SetTitle("Events/pb");
   phimuphij1b23->GetYaxis()->SetLabelFont(42);
   phimuphij1b23->GetYaxis()->SetLabelSize(0.035);
   phimuphij1b23->GetYaxis()->SetTitleSize(0.035);
   phimuphij1b23->GetYaxis()->SetTitleFont(42);
   phimuphij1b23->GetZaxis()->SetLabelFont(42);
   phimuphij1b23->GetZaxis()->SetLabelSize(0.035);
   phimuphij1b23->GetZaxis()->SetTitleSize(0.035);
   phimuphij1b23->GetZaxis()->SetTitleFont(42);
   b2/phimuphij1b2->Add(phimuphij1b2,"");
   
   TH1D *phimuphij1b24 = new TH1D("phimuphij1b24"," #Delta_{#phi}[#mu,jet_{1}]",20,-3.141593,3.141593);
   phimuphij1b24->SetBinContent(1,0.001326514);
   phimuphij1b24->SetBinContent(2,0.001372787);
   phimuphij1b24->SetBinContent(3,0.001048871);
   phimuphij1b24->SetBinContent(4,0.00091005);
   phimuphij1b24->SetBinContent(5,0.0006632568);
   phimuphij1b24->SetBinContent(6,0.0007249551);
   phimuphij1b24->SetBinContent(7,0.0004935864);
   phimuphij1b24->SetBinContent(8,0.0004781619);
   phimuphij1b24->SetBinContent(9,0.0004781619);
   phimuphij1b24->SetBinContent(10,0.000401039);
   phimuphij1b24->SetBinContent(11,0.0003084915);
   phimuphij1b24->SetBinContent(12,0.0003393407);
   phimuphij1b24->SetBinContent(13,0.0004935864);
   phimuphij1b24->SetBinContent(14,0.0007866534);
   phimuphij1b24->SetBinContent(15,0.0006324076);
   phimuphij1b24->SetBinContent(16,0.0007712288);
   phimuphij1b24->SetBinContent(17,0.0008483517);
   phimuphij1b24->SetBinContent(18,0.00107972);
   phimuphij1b24->SetBinContent(19,0.001295664);
   phimuphij1b24->SetBinContent(20,0.001480759);
   phimuphij1b24->SetBinError(1,0.0001430416);
   phimuphij1b24->SetBinError(2,0.0001455152);
   phimuphij1b24->SetBinError(3,0.0001271943);
   phimuphij1b24->SetBinError(4,0.0001184784);
   phimuphij1b24->SetBinError(5,0.0001011457);
   phimuphij1b24->SetBinError(6,0.0001057456);
   phimuphij1b24->SetBinError(7,8.725458e-05);
   phimuphij1b24->SetBinError(8,8.58804e-05);
   phimuphij1b24->SetBinError(9,8.58804e-05);
   phimuphij1b24->SetBinError(10,7.865021e-05);
   phimuphij1b24->SetBinError(11,6.89808e-05);
   phimuphij1b24->SetBinError(12,7.234767e-05);
   phimuphij1b24->SetBinError(13,8.725458e-05);
   phimuphij1b24->SetBinError(14,0.0001101535);
   phimuphij1b24->SetBinError(15,9.876548e-05);
   phimuphij1b24->SetBinError(16,0.0001090682);
   phimuphij1b24->SetBinError(17,0.0001143917);
   phimuphij1b24->SetBinError(18,0.0001290513);
   phimuphij1b24->SetBinError(19,0.0001413686);
   phimuphij1b24->SetBinError(20,0.0001511294);
   phimuphij1b24->SetEntries(1033);

   ci = TColor::GetColor("#ff0000");
   phimuphij1b24->SetFillColor(ci);

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

   ci = TColor::GetColor("#ff0000");
   phimuphij1b24->SetMarkerColor(ci);
   phimuphij1b24->SetMarkerStyle(20);
   phimuphij1b24->GetXaxis()->SetTitle("phimuphij1b2");
   phimuphij1b24->GetXaxis()->SetLabelFont(42);
   phimuphij1b24->GetXaxis()->SetLabelSize(0.035);
   phimuphij1b24->GetXaxis()->SetTitleSize(0.035);
   phimuphij1b24->GetXaxis()->SetTitleFont(42);
   phimuphij1b24->GetYaxis()->SetTitle("Events/pb");
   phimuphij1b24->GetYaxis()->SetLabelFont(42);
   phimuphij1b24->GetYaxis()->SetLabelSize(0.035);
   phimuphij1b24->GetYaxis()->SetTitleSize(0.035);
   phimuphij1b24->GetYaxis()->SetTitleFont(42);
   phimuphij1b24->GetZaxis()->SetLabelFont(42);
   phimuphij1b24->GetZaxis()->SetLabelSize(0.035);
   phimuphij1b24->GetZaxis()->SetTitleSize(0.035);
   phimuphij1b24->GetZaxis()->SetTitleFont(42);
   b2/phimuphij1b2->Add(phimuphij1b2,"");
   
   TH1D *phimuphij1b25 = new TH1D("phimuphij1b25"," #Delta_{#phi}[#mu,jet_{1}]",20,-3.141593,3.141593);
   phimuphij1b25->SetBinContent(18,1.677165e-05);
   phimuphij1b25->SetBinError(18,1.677165e-05);
   phimuphij1b25->SetEntries(1);

   ci = TColor::GetColor("#0000ff");
   phimuphij1b25->SetFillColor(ci);

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

   ci = TColor::GetColor("#0000ff");
   phimuphij1b25->SetMarkerColor(ci);
   phimuphij1b25->SetMarkerStyle(21);
   phimuphij1b25->GetXaxis()->SetTitle("phimuphij1b2");
   phimuphij1b25->GetXaxis()->SetLabelFont(42);
   phimuphij1b25->GetXaxis()->SetLabelSize(0.035);
   phimuphij1b25->GetXaxis()->SetTitleSize(0.035);
   phimuphij1b25->GetXaxis()->SetTitleFont(42);
   phimuphij1b25->GetYaxis()->SetTitle("Events/pb");
   phimuphij1b25->GetYaxis()->SetLabelFont(42);
   phimuphij1b25->GetYaxis()->SetLabelSize(0.035);
   phimuphij1b25->GetYaxis()->SetTitleSize(0.035);
   phimuphij1b25->GetYaxis()->SetTitleFont(42);
   phimuphij1b25->GetZaxis()->SetLabelFont(42);
   phimuphij1b25->GetZaxis()->SetLabelSize(0.035);
   phimuphij1b25->GetZaxis()->SetTitleSize(0.035);
   phimuphij1b25->GetZaxis()->SetTitleFont(42);
   b2/phimuphij1b2->Add(phimuphij1b2,"");
   b2/phimuphij1b2->Draw("nostack");
   
   TPaveText *pt = new TPaveText(0.2910057,0.9342857,0.7089943,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("b2/phimuphij1b2");
   pt->Draw();
   
   TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextSize(0.034965);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("phimuphij1b2","b2/phimuphij1b2_QCD_b2/","lp");

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

   ci = TColor::GetColor("#00cc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("phimuphij1b2","b2/phimuphij1b2_WJetsToLNu_b2/","lp");

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

   ci = TColor::GetColor("#00ffff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("phimuphij1b2","b2/phimuphij1b2_ZJetsToNuNu_b2/","lp");

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

   ci = TColor::GetColor("#ffcc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("phimuphij1b2","b2/phimuphij1b2_signal_b2/","lp");

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

   ci = TColor::GetColor("#ff0000");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("phimuphij1b2","b2/phimuphij1b2_ttbar_b2/","lp");

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

   ci = TColor::GetColor("#0000ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   b2/phimuphij1b2->Modified();
   b2/phimuphij1b2->cd();
   b2/phimuphij1b2->SetSelected(b2/phimuphij1b2);
}
示例#14
0
void DrawFreeCMSLabels(char* text, double textSize) {

  //const char *text = "%2.1f #times 10^{6} clusters (fiducial) (%1.1f GeV)";
  //char *text = "%2.1f #times 10^{6} clusters (fiducial)";
    
  TPaveText *label = new TPaveText();
  label->SetX1NDC(gStyle->GetPadLeftMargin());
  label->SetY1NDC(1.0-gStyle->GetPadTopMargin());
  label->SetX2NDC(1.0-gStyle->GetPadRightMargin());
  label->SetY2NDC(1.0);
  label->SetTextFont(42);
  label->AddText(text);
  label->SetFillStyle(0);
  label->SetBorderSize(0);
  if (textSize!=0) label->SetTextSize(textSize);
  label->SetTextAlign(32);
  label->Draw("same");
}
示例#15
0
文件: track_pt.C 项目: d4space/KoSMP
void track_pt(const int charge)
{
  if (charge==1)
  char  ch[20] = "plus"; 
  else if (charge==-1)
  char ch[20] = "minus";
  ofstream txtfile;
  char txtfname[100];
  char histfname[100];
  sprintf(txtfname,"pt_%s.txt",ch);
  sprintf(histfname,"pt_%s.png",ch);
  txtfile.open(txtfname);
  txtfile << fixed << setprecision(4);
  TCanvas *myCan=new TCanvas("myCan","myCan",800,600);
  gStyle->SetLineWidth(2.);
  gStyle->SetLabelSize(0.04,"xy");
  gStyle->SetTitleSize(0.05,"xy");
  gStyle->SetTitleOffset(1.1,"x");
  gStyle->SetTitleOffset(1.2,"y");
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadRightMargin(0.1);
  gStyle->SetPadBottomMargin(0.16);
  gStyle->SetPadLeftMargin(0.12);

  myCan->SetGrid();
  TLegend* Lgd = new TLegend(.8, .25,.9,.35);
  if (charge==1){
    TFile *f_MC= new TFile("TnP_Tracking_dr030e030_MCptplus.root","read");
    TFile *f_RD= new TFile("TnP_Tracking_dr030e030_RDptplus.root","read");
  }else if (charge==-1){
    TFile *f_MC= new TFile("TnP_Tracking_dr030e030_MCptminus.root","read");
    TFile *f_RD= new TFile("TnP_Tracking_dr030e030_RDptminus.root","read");
  }
  line = new TLine(15,1,80,1);
  line->SetLineStyle(2);
  line->SetLineWidth(3);
  
  TPaveText *title = new TPaveText(.1,1,.95,.95,"NDC");
  title->SetFillStyle(0);
  title->SetBorderSize(0);
  title->SetTextSize(0.04);
  title->AddText("CMS Preliminary, 18.9 pb^{-1} at #sqrt{s}=8 TeV");

  RooDataSet *datasetMC = (RooDataSet*)f_MC->Get("tpTreeSta/eff_pt_dr030e030/fit_eff");
  cout<<"ntry: "<<datasetMC->numEntries()<<endl;
  double XMC[Nbin],XMCerrL[Nbin],XMCerrH[Nbin],YMC[Nbin],YMCerrLo[Nbin],YMCerrHi[Nbin],ErrMC[Nbin];
  for(int i(0); i<datasetMC->numEntries();i++)
  {
    const RooArgSet &pointMC=*datasetMC->get(i);
    RooRealVar &ptMC=pointMC["pt"],&effMC = pointMC["efficiency"];
    XMC[i]=ptMC.getVal();
    XMCerrL[i]=-ptMC.getAsymErrorLo();
    XMCerrH[i]=ptMC.getAsymErrorHi();
    YMC[i]=effMC.getVal();
    YMCerrLo[i]=-effMC.getAsymErrorLo();
    YMCerrHi[i]=effMC.getAsymErrorHi();
    ErrMC[i]=TMath::Max(YMCerrLo[i],YMCerrHi[i]);
  }
  grMC=new TGraphAsymmErrors(Nbin,XMC,YMC,XMCerrL,XMCerrH,YMCerrLo,YMCerrHi);
  grMC->SetLineColor(kRed);
  grMC->SetMarkerColor(kRed);
  grMC->SetMarkerStyle(21);
  grMC->SetMinimum(0.7);
  grMC->SetMaximum(1.11);
  grMC->GetXaxis()->SetNdivisions(505);
  grMC->GetXaxis()->SetTitle("Muon p_{T} [GeV/c]");
  grMC->GetYaxis()->SetTitle("Tracking Efficiency");
  grMC->Draw("AP");

  RooDataSet *datasetRD = (RooDataSet*)f_RD->Get("tpTreeSta/eff_pt_dr030e030/fit_eff");
  double XRD[Nbin],XRDerrL[Nbin],XRDerrH[Nbin],YRD[Nbin],YRDerrLo[Nbin],YRDerrHi[Nbin],ErrRD[Nbin];
  for(int i(0); i<datasetRD->numEntries();i++)
  {
    const RooArgSet &pointRD=*datasetRD->get(i);
    RooRealVar &ptRD=pointRD["pt"],&effRD = pointRD["efficiency"];
    XRD[i]=ptRD.getVal();
    XRDerrL[i]=-ptRD.getAsymErrorLo();
    XRDerrH[i]=ptRD.getAsymErrorHi();
    YRD[i]=effRD.getVal();
    YRDerrLo[i]=-effRD.getAsymErrorLo();
    YRDerrHi[i]=effRD.getAsymErrorHi();
    ErrRD[i]=TMath::Max(YRDerrLo[i],YRDerrHi[i]);
  }

  double SF[Nbin],SFerr[Nbin],SFerrL[Nbin],SFerrH[Nbin];
  for(int i(0); i<datasetRD->numEntries();i++)
  {
    SF[i]=YRD[i]/YMC[i];
    SFerrL[i]=YRD[i]*sqrt(YMCerrLo[i]*YMCerrLo[i]/(YMC[i]*YMC[i])+YRDerrLo[i]*YRDerrLo[i]/(YRD[i]*YRD[i]))/YMC[i];
    SFerrH[i]=YRD[i]*sqrt(YMCerrHi[i]*YMCerrHi[i]/(YMC[i]*YMC[i])+YRDerrHi[i]*YRDerrHi[i]/(YRD[i]*YRD[i]))/YMC[i];
    SFerr[i]=TMath::Max(SFerrL[i],SFerrH[i]);
    txtfile << i << "\t" << YMC[i] << "\t" << ErrMC[i] << "\t" << YRD[i] << "\t" << ErrRD[i] << "\t" << SF[i] << "\t" << SFerr[i] << endl;
  }

  grRD=new TGraphAsymmErrors(Nbin,XRD,YRD,XRDerrL,XRDerrH,YRDerrLo,YRDerrHi);
  grRD->SetLineColor(kBlack);
  grRD->SetMarkerColor(kBlack);
  
  grSF=new TGraphAsymmErrors(Nbin,XRD,SF,0,0,SFerrL,SFerrH);
  grSF->SetLineColor(8);
  grSF->SetMarkerStyle(25);
  grSF->SetMarkerColor(8);
  
  Lgd->AddEntry(grMC,"MC","pl");
  Lgd->AddEntry(grRD,"RD","pl");
  Lgd->SetFillStyle(0);
  Lgd->Draw();
  grRD->Draw("PSAME");
  grSF->Draw("PSAME");
  line->Draw();
  title->Draw();

  myCan->SaveAs(histfname);
  txtfile.close();
}
示例#16
0
文件: h1draw.C 项目: davidlt/root
void h1draw()
{
   TString dir = gROOT->GetTutorialDir();
   dir.Append("/hsimple.C");
   dir.ReplaceAll("/./","/");
   if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data());
   TFile *example = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
   if (!example) return;

   example->ls();
   TH1 *hpx = (TH1*)example->Get("hpx");

   TCanvas *c1 = new TCanvas("c1","Histogram Drawing Options",200,10,700,900);
   TPad *pad1 = new TPad("pad1",
      "The pad with the function",0.03,0.62,0.50,0.92);
   TPad *pad2 = new TPad("pad2",
      "The pad with the histogram",0.51,0.62,0.98,0.92);
   TPad *pad3 = new TPad("pad3",
      "The pad with the histogram",0.03,0.02,0.97,0.57);
   pad1->Draw();
   pad2->Draw();
   pad3->Draw();

   // Draw a global picture title
   TPaveLabel *title = new TPaveLabel(0.1,0.94,0.9,0.98,
                    "Drawing options for one dimensional histograms");
   title->SetTextFont(52);
   title->Draw();

   // Draw histogram hpx in first pad with the default option.
   pad1->cd();
   pad1->GetFrame()->SetFillColor(18);
   hpx->SetFillColor(45);
   hpx->DrawCopy();
   TPaveLabel *label1 = new TPaveLabel(-3.5,700,-1,800,"Default option");
   label1->Draw();

   // Draw hpx as a lego. Clicking on the lego area will show
   // a "transparent cube" to guide you rotating the lego in real time.
   pad2->cd();
   hpx->DrawCopy("lego1");
   TPaveLabel *label2 = new TPaveLabel(-0.72,0.74,-0.22,0.88,"option Lego1");
   label2->Draw();
   TPaveLabel *label2a = new TPaveLabel(-0.93,-1.08,0.25,-0.92,
      "Click on lego to rotate");
   label2a->Draw();

   // Draw hpx with its errors and a marker.
   pad3->cd();
   pad3->SetGridx();
   pad3->SetGridy();
   hpx->SetMarkerStyle(21);
   hpx->Draw("e1p");
   TPaveLabel *label3 = new TPaveLabel(2,600,3.5,650,"option e1p");
   label3->Draw();

   // The following illustrates how to add comments using a PaveText.
   // Attributes of text/lines/boxes added to a PaveText can be modified.
   // The AddText function returns a pointer to the added object.
   TPaveText *pave = new TPaveText(-3.78,500,-1.2,750);
   TText *t1=pave->AddText("You can move");
   t1->SetTextColor(4);
   t1->SetTextSize(0.05);
   pave->AddText("Title and Stats pads");
   pave->AddText("X and Y axis");
   pave->AddText("You can modify bin contents");
   pave->Draw();
   c1->Update();
}
示例#17
0
void makePlots_vdm_ls(double skip = 10.*11246.)
{
  gROOT->ProcessLine(" .L style.cc+");
#ifdef __CINT__
  style();
#endif

  TFile* file = TFile::Open("histos_vdmpp.root");
  TH1D* h_rate = (TH1D*)file->Get((string("pp/h_rate_ls")).c_str());
  h_rate->Scale(1./h_rate->GetBinWidth(1));
  h_rate->SetTitle(";orbitNb;dN/dT_{Orbit}");
  h_rate->GetXaxis()->SetNdivisions(505);
  h_rate->GetYaxis()->SetTitleOffset(h_rate->GetYaxis()->GetTitleOffset()*0.7);

  canFind = new TCanvas;
  canFind->Divide(1,2);

  vector<string> type;
  type.push_back("X");
  type.push_back("Y");

  vector<double> sectionXBegin;
  vector<double> sectionXEnd;
  vector<double> sectionXTruth;
  vector<double> sectionXMean;
  vector<double> sectionXMeanE;
  vector<TGraphErrors*> sectionXChi;

//   sectionXTruth.push_back(100); //0
//   sectionXTruth.push_back(50);  //1
//   sectionXTruth.push_back(0);   //2
//   sectionXTruth.push_back(-50); //3
//   sectionXTruth.push_back(-100);//4
//   sectionXTruth.push_back(-50); //5
//   sectionXTruth.push_back(0);   //6
//   sectionXTruth.push_back(50);  //7
//   sectionXTruth.push_back(100); //8
//   sectionXTruth.push_back(0);   //9

  //sectionXTruth.push_back(-70); //0
  sectionXTruth.push_back(-370);  //1
  sectionXTruth.push_back(-220);   //2
  sectionXTruth.push_back(-70); //3
  sectionXTruth.push_back(80);//4
  sectionXTruth.push_back(230); //5
  sectionXTruth.push_back(80);   //6
  sectionXTruth.push_back(-70);  //7
  sectionXTruth.push_back(-220); //8
  sectionXTruth.push_back(-370);   //9
  canFind->cd(1);
  FindSections(h_rate,sectionXBegin, sectionXEnd, BEGINX,ENDX,3.*11246.,skip);
  //FindSections(h_rate,sectionXBegin, sectionXEnd, 1.932e8,2.025e8,3.*11246.,skip);
#ifdef __CINT__
  CMSText(1,1,1,string("#DeltaX length scale"),"","pp, #sqrt{s}=2.76 TeV");
#endif
  if(sectionXTruth.size() != sectionXBegin.size())
    {
      cerr << "Sections error: not same size. Truth/Found: " << sectionXTruth.size() << " " <<  sectionXBegin.size() << endl;
      //exit(-1);
    }

  vector<double> sectionYBegin;
  vector<double> sectionYEnd;
  vector<double> sectionYTruth;
  vector<double> sectionYMean;
  vector<double> sectionYMeanE;
  vector<TGraphErrors*> sectionYChi;

//   sectionYTruth.push_back(100);
//   sectionYTruth.push_back(50); 
//   sectionYTruth.push_back(0);  
//   sectionYTruth.push_back(-50);
//   sectionYTruth.push_back(-100);
//   sectionYTruth.push_back(-50);
//   sectionYTruth.push_back(0);  
//   sectionYTruth.push_back(50); 
//   sectionYTruth.push_back(100);
//   sectionYTruth.push_back(0);


  //sectionYTruth.push_back(70); //0
  sectionYTruth.push_back(-370);  //1
  sectionYTruth.push_back(-220);   //2
  sectionYTruth.push_back(-70); //3
  sectionYTruth.push_back(80);//4
  sectionYTruth.push_back(230); //5
  sectionYTruth.push_back(80);   //6
  sectionYTruth.push_back(-70);  //7
  sectionYTruth.push_back(-220); //8
  sectionYTruth.push_back(-370);   //9
  canFind->cd(2);
  //FindSections(h_rate,sectionYBegin, sectionYEnd, 2.038e8,2.12e8,3.*11246.,skip);
  FindSections(h_rate,sectionYBegin, sectionYEnd, BEGINY,ENDY,3.*11246.,skip);
#ifdef __CINT__
  CMSText(1,1,1,string("#DeltaY length scale"),"","pp, #sqrt{s}=2.76 TeV");
#endif
  if(sectionYTruth.size() != sectionYBegin.size())
    {
      cerr << "Sections error: not same size. Truth/Found: " << sectionYTruth.size() << " " <<  sectionYBegin.size() << endl;
      //exit(-1);
    }
  


  TCanvas* can1 = new TCanvas;
  can1->Divide(1,2);

  //GENERAL LOOP OVER SECTIONS
  for(int n=0; n<int(type.size()); n++)
    {
      can1->cd(type[n]=="X"?1:2);
      
      vector<double>& sectionBegin      = type[n]=="X"?sectionXBegin:sectionYBegin;
      vector<double>& sectionEnd        = type[n]=="X"?sectionXEnd:sectionYEnd;
      vector<double>& sectionTruth      = type[n]=="X"?sectionXTruth:sectionYTruth;
      vector<double>& sectionMean       = type[n]=="X"?sectionXMean:sectionYMean;
      vector<double>& sectionMeanE      = type[n]=="X"?sectionXMeanE:sectionYMeanE;
      vector<TGraphErrors*>& sectionChi = type[n]=="X"?sectionXChi:sectionYChi;
        
      const int nSec = int(sectionBegin.size());

      sectionMean.resize(nSec);
      sectionMeanE.resize(nSec);

      TH2D* h_length_scale = (TH2D*)file->Get((string("pp/h_length_scale_") + type[n]).c_str());
      //      for(int i= 0; i<h_length_scale->GetNbinsX()+1;i++) cout << h_length_scale->Print
      TGraphErrors* h_truth_fit_up = new TGraphErrors(0);
      TGraphErrors* h_truth_fit_down = new TGraphErrors(0);
      TGraphErrors* h_truth_fit_crosscheck_up = new TGraphErrors(0);
      TGraphErrors* h_truth_fit_crosscheck_down = new TGraphErrors(0);
      ostringstream profiletitle; profiletitle << "truth_fit_" << type[n];
      ostringstream crosschecktitle; crosschecktitle << "truth_fit_crosscheck_" << type[n];
      h_truth_fit_down->SetName(profiletitle.str().c_str());
      h_truth_fit_crosscheck_down->SetName(crosschecktitle.str().c_str());
      profiletitle << "_down";
      crosschecktitle << "_down";
      h_truth_fit_up->SetName(profiletitle.str().c_str());
      h_truth_fit_crosscheck_up->SetName(crosschecktitle.str().c_str());

      vector<TF1*> sectionFunc; sectionFunc.resize(nSec);
      vector<TFitResultPtr> sectionFuncPtr; sectionFuncPtr.resize(nSec);

      ostringstream histotitle; histotitle << ";orbit number; vertex " << type[n] << " position [cm]";
      h_length_scale->SetTitle(histotitle.str().c_str());
      h_length_scale->SetMarkerSize(0.5);
      h_length_scale->GetXaxis()->SetNdivisions(505);
      h_length_scale->GetYaxis()->SetTitleOffset(h_length_scale->GetYaxis()->GetTitleOffset()*0.7);
      if(type[n]=="X")
        h_length_scale->GetXaxis()->SetRangeUser(BEGINX,ENDX);
      else
        h_length_scale->GetXaxis()->SetRangeUser(BEGINY,ENDY);
//       if(type[n]=="X")
//         h_length_scale->GetXaxis()->SetRangeUser(193000000,202000000);
//       else
//         h_length_scale->GetXaxis()->SetRangeUser(203000000,211000000);
//      h_length_scale->GetYaxis()->SetRangeUser(0.00,0.15);
      h_length_scale->Draw("COLZ");

#ifdef __CINT__
      CMSText(1,1,1,string("#Delta")+type[n]+string(" length scale"),"","pp, #sqrt{s}=2.76 TeV");
#endif
      //FIT EACH SECTION
      TCanvas* canFit = new TCanvas;
      canFit->Divide(TMath::Nint(nSec/2.),2);
      for (int i=0; i<nSec; i++)
        {
          int binStartNotSkipped,binStart, binEnd, helper;
          double x1,x2,xend;

          h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionBegin[i]),binStartNotSkipped,helper,helper); binStartNotSkipped++;
          h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionBegin[i]+skip),binStart,helper,helper); binStart++;
          h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionEnd[i]),binEnd,helper,helper); binEnd--;
          x1=h_length_scale->GetBinLowEdge(binStartNotSkipped);
          x2=h_length_scale->GetBinLowEdge(binStart);
          xend=h_length_scale->GetBinLowEdge(binEnd+1);

          if(binStart >= binEnd)
            {
              cerr << "MAJOR WARNING Chosen skipping value too large for section " << i << "(" << binStart << "," << binEnd << ")" << endl;
            }

          ostringstream funcTitle;
          funcTitle << "section" << type[n] << "Func_" << i;
          sectionFunc[i] = new TF1(funcTitle.str().c_str(),"gaus");
          sectionFunc[i]->SetLineWidth(2);
          sectionFunc[i]->SetLineColor(kRed);
          sectionFunc[i]->SetLineStyle(1);

          funcTitle << "_Prof";
          TH1D* helperProfile = h_length_scale->ProjectionY(funcTitle.str().c_str(),binStart,binEnd);
          canFit->cd(i+1);
          helperProfile->Draw();
          sectionFuncPtr[i] = helperProfile->Fit(sectionFunc[i],"QS");


          if(Int_t(sectionFuncPtr[i]) !=0)
            {
              cerr << " !!! MAJOR WARNING." << endl
                   << "in section " << i << " fit did not converge: " << gMinuit->fCstatu.Data() << endl;
            }

          sectionFunc[i]->SetLineWidth(2);
          sectionFunc[i]->Draw("SAME");

          sectionMean[i] = helperProfile->GetMean();
          sectionMeanE[i] = helperProfile->GetMeanError();

          if(x1<x2)
            {
              //can1->cd();
              TBox* box1 = new TBox(x1,0.1,x2,0.105);
              box1->SetFillColor(kRed);
              box1->SetFillStyle(3001);
              box1->DrawClone();
              TBox* box2 = new TBox(x2,0.1,xend,0.105);
              box2->SetFillColor(kGreen);
              box2->SetFillStyle(3001);
              box2->DrawClone();
            }
        }
      
//       //DETERMINE THE MEAN WHERE TRUTH IS AT NOMINAL POSITION -> now done below
//       double xw = 0;
//       double w = 0;
//       for(int i=0; i<nSec; i++)
//         {
//           if(sectionTruth[i]==70 || sectionTruth[i]==-70)
//             {
//               double weight = 1./pow(sectionFuncPtr[i]->ParError(1),2);
//               xw += sectionFuncPtr[i]->Parameter(1) * weight;
//               w += weight;
//               //cout << sectionFuncPtr[i]->Parameter(1) << " weight: " << weight << endl;
//             }
//         }
//       double sigma = sqrt(1./w);
//       double y0 = xw/w;
//       cout << "y0 = " << y0 << "+-" << sigma << endl;

      //CHECK CHI2 OPTIMISATION
      TCanvas* can3 = new TCanvas;
      sectionChi.resize(nSec);
      string drawoption("AL");
      TLegend* legchi = new TLegend(0.55,0.5,0.85,0.9);
      for(int i=0; i<nSec; i++)
        {
          if(i<1 || i >8)
            continue;
          
          const int nSkipBins=10;
          ostringstream graphTitle;
          graphTitle << "section_" << type[n] << "_chi2_Graph_" << i;
          sectionChi[i] = (new TGraphErrors(0));
          sectionChi[i]->SetName(graphTitle.str().c_str());
          for (int skipBin=0; skipBin<nSkipBins; skipBin++)
            {
              int binStart, binEnd, helper;
              h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionBegin[i]),binStart,helper,helper); binStart++;
              h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionEnd[i]),binEnd,helper,helper); binEnd--;

              binStart += skipBin;

              if(binStart >= binEnd)
                continue;

              double x = double(h_length_scale->GetBinLowEdge(binStart) - h_length_scale->GetBinLowEdge(binStart-skipBin)) / 11246.;
              //cout << "skip bin: " << skipBin << "(" << binStart << ")" << endl;

              ostringstream funcTitle;
              funcTitle << "section" << type[n] << "Func_" << i << "_" << skipBin;

              TF1* helperFunc = new TF1(funcTitle.str().c_str(),"gaus");
              funcTitle << "_Prof";
              TH1D* helperProfile = h_length_scale->ProjectionY(funcTitle.str().c_str(),binStart,binEnd);
              TFitResultPtr helperPtr = helperProfile->Fit(helperFunc,"QSN");

              if(Int_t(helperPtr) !=0)
                {
                  cout << "fit failed" << endl;
                  cout << "skip bin: " << skipBin << "(" << binStart << ")" << endl;
                  continue;
                }
              
              double chi2 = helperPtr->Chi2()/double(helperPtr->Ndf());
              sectionChi[i]->SetPoint(sectionChi[i]->GetN(),x,chi2);
              //cout << skipBin << " " << x << " " << chi2 << endl;
            }
          //sectionChi[i]->Print("ALL");
          sectionChi[i]->SetTitle(";skip interval [s]; #chi^{2}/NDF");
          sectionChi[i]->GetYaxis()->SetRangeUser(0,6);
          sectionChi[i]->GetXaxis()->SetLimits(0,30);
          sectionChi[i]->SetLineWidth(2);
          sectionChi[i]->SetLineColor(i);
          sectionChi[i]->Draw(drawoption.c_str());
          drawoption = string("L");
          
          ostringstream legtext ; legtext << "Section " << i << " (" << sectionTruth[i] << " µm)";
          legchi->AddEntry(sectionChi[i],legtext.str().c_str(),"l");

        }
#ifdef __CINT__
      CMSText(1,1,1,string("#Delta")+type[n]+string(" length scale"),"","pp, #sqrt{s}=2.76 TeV");
      SetLegAtt(legchi);
#endif
      legchi->Draw("SAME");
      TLine* line = new TLine(skip/11246.,0,skip/11246.,2.5);
      line->SetLineWidth(2);
      line->SetLineStyle(2);
      line->Draw("SAME");
      can3->SaveAs((string("plots/vdm_length_scale_")+type[n]+string("_3_pp.pdf")).c_str());
          
      //Determine reference value y0 to subtract from plotting
      TGraph helperGraph(nSec);
      double y0=0;
      for (int i=0; i<nSec; i++)
        {
          double y = sectionFuncPtr[i]->Parameter(1);
          helperGraph.SetPoint(i,sectionTruth[i]*(type[n]=="X"?-1:1), y);
          y0 = helperGraph.Eval(0);
        }
      cout << "y0 = " << y0 << endl;

      //TRUTH VS TRACKER PLOT
      for (int i=0; i<nSec; i++)
        {
          ostringstream text;
          double size = 0.01;
          double y = sectionFuncPtr[i]->Parameter(1);
          double y_cc = sectionMean[i]; //just used for cross checking (cc) the gaussian fit
          double yum = (y-y0)*1e4; //cm -> µm => 1e-2 -> 1e-6 => 1e4
          double yum_cc = (y_cc-y0)*1e4; //cm -> µm => 1e-2 -> 1e-6 => 1e4
          double yumerror = (sectionFuncPtr[i]->ParError(1))*10000.;
          double yumerror_cc = sectionMeanE[i] * 10000;
          text << "#Delta" << type[n] << "_{Fit}=" << fixed << setprecision(1) << yum;
          TPaveText* txt = new TPaveText(sectionBegin[i],y+1.5*size,sectionEnd[i],y+2.5*size,"b t l");
          txt->SetTextFont(62);
          txt->SetFillStyle(0);
          txt->SetTextColor(kRed);
          txt->SetTextSize(0.04);
          txt->SetBorderSize(0);
          txt->AddText(text.str().c_str());
          txt->Draw("SAME");
          if(i>=1 && i<=4) //WARNING also setpoint needs to be changed
            {
              cout << "up " << i << " " << sectionTruth[i]*(type[n]=="X"?-1:1) << " " << yum << "+-" << yumerror << endl;
              h_truth_fit_up->SetPoint(i-1,sectionTruth[i]*(type[n]=="X"?-1:1), yum); // Coordinate Sys different z? X has to be inverted.
              h_truth_fit_up->SetPointError(i-1,0, yumerror);
              h_truth_fit_crosscheck_up->SetPoint(i-1,sectionTruth[i]*(type[n]=="X"?-1:1), yum_cc); // Coordinate Sys different z? X has to be inverted.
              h_truth_fit_crosscheck_up->SetPointError(i-1,0, yumerror_cc);
            }
          if(i>=5 && i<=8) //anti hysteresis //WARNING also setpoint needs to be changed
            {
              cout << "down " << i << " " << sectionTruth[i]*(type[n]=="X"?-1:1) << " " << yum << "+-" << yumerror << endl;
              h_truth_fit_down->SetPoint(i-5,sectionTruth[i]*(type[n]=="X"?-1:1), yum); // Coordinate Sys different z? X has to be inverted.
              h_truth_fit_down->SetPointError(i-5,0, yumerror);
              h_truth_fit_crosscheck_down->SetPoint(i-5,sectionTruth[i]*(type[n]=="X"?-1:1), yum_cc); // Coordinate Sys different z? X has to be inverted.
              h_truth_fit_crosscheck_down->SetPointError(i-5,0, yumerror_cc);
            }
        }
      canFit->SaveAs((string("plots/vdm_length_scale_")+type[n]+string("_Fits_pp.pdf")).c_str());
      
      TCanvas* can2 = new TCanvas;
      ostringstream titleup; titleup << ";#Delta" << type[n] << " (LHC) [#mum]; #Delta" << type[n] << " (CMS) [#mum]";
      h_truth_fit_up->SetTitle(titleup.str().c_str());
      h_truth_fit_up->SetMarkerSize(1.3);
      h_truth_fit_up->SetMarkerColor(kRed);
      h_truth_fit_up->SetLineColor(kRed);
      h_truth_fit_up->SetLineWidth(2);
      h_truth_fit_up->GetXaxis()->SetLimits(-400,400);
      h_truth_fit_up->GetYaxis()->SetRangeUser(-400,400);
      h_truth_fit_up->Draw("AP");
      TFitResultPtr fit_up = h_truth_fit_up->Fit("pol1","QS");
      TFitResultPtr fit_crosscheck_up = h_truth_fit_crosscheck_up->Fit("pol1","QNS");
      h_truth_fit_up->GetFunction("pol1")->SetLineWidth(2);
      h_truth_fit_up->GetFunction("pol1")->SetLineColor(kRed);
      h_truth_fit_down->SetMarkerColor(kBlue);
      h_truth_fit_down->SetMarkerStyle(25);
      h_truth_fit_down->SetMarkerSize(1.3);
      h_truth_fit_down->SetLineColor(kBlue);
      h_truth_fit_down->SetLineWidth(2);
      h_truth_fit_down->Draw("P");
      TFitResultPtr fit_down = h_truth_fit_down->Fit("pol1","QS");
      TFitResultPtr fit_crosscheck_down = h_truth_fit_crosscheck_down->Fit("pol1","QNS");
      h_truth_fit_down->GetFunction("pol1")->SetLineWidth(2);
      h_truth_fit_down->GetFunction("pol1")->SetLineColor(kBlue);
      TLegend* leg = new TLegend(0.22,0.72,0.6,0.82);
      ostringstream legup,legdown;
      legup   << "#Delta" << type[n] << " low-to-high (Slope:" << fixed << setprecision(3) << fit_up  ->Parameter(1) << " )";
      legdown << "#Delta" << type[n] << " high-to-low (Slope:" << fixed << setprecision(3) << fit_down->Parameter(1) << " )";
      leg->AddEntry(h_truth_fit_up  ,legup  .str().c_str(),"lp");
      leg->AddEntry(h_truth_fit_down,legdown.str().c_str(),"lp");
#ifdef __CINT__
      SetLegAtt(leg);
      CMSText(1,1,1,"","","pp, #sqrt{s}=2.76 TeV");
#endif
      leg->Draw("SAME");
      can2->SaveAs((string("plots/vdm_length_scale_")+type[n]+string("_2_pp.pdf")).c_str());

      double average = (fit_up->Parameter(1) + fit_down->Parameter(1)) / 2.;
      double average_cc = (fit_crosscheck_up->Parameter(1) + fit_crosscheck_down->Parameter(1)) / 2.;
      double stat = sqrt( pow(fit_up->Parameter(1)/2.,2) * pow(fit_down->ParError(1),2) + pow(fit_down->Parameter(1)/2.,2) * pow(fit_up->ParError(1),2));
      double sysupdown = fabs(fit_up->Parameter(1) - fit_down->Parameter(1))/ 2.;
      double sysfit = fabs(average_cc - average) / 2.;
      double sysskip = (type[n]=="X"?0.001:0.003);
      double sys = sqrt ( sysfit*sysfit + sysupdown*sysupdown + sysskip*sysskip);

      cout << endl << endl << endl;
      cout << fixed << setprecision(3)
           << "        Δ" << type[n] << endl
           << "--Correction Factor: " << average << endl
           << "up: " << fit_up->Parameter(1) << endl
           << "down: " << fit_down->Parameter(1) << endl
           << "--Stat: " << stat << endl
           << "--Sys Combined: " << sys << endl
           << "Sys. Up Down: " << sysupdown << endl
           << "Sys. Fitting: " << sysfit << endl
           << "Sys. Skipping: " << sysskip << endl;
      cout << endl << endl << endl;
    }

  can1->SaveAs((string("plots/vdm_length_scale")+string("_1_pp.pdf")).c_str());
  canFind->SaveAs((string("plots/vdm_length_scale")+string("_sections_pp.pdf")).c_str());
}
void TracktoSegX_2015all_sameYrange()
{
//=========Macro generated from canvas: TracktoSegX/TracktoSegX
//=========  (Fri Aug  5 08:13:37 2016) by ROOT version6.06/01
   TCanvas *TracktoSegX = new TCanvas("TracktoSegX", "TracktoSegX",0,0,500,500);
   gStyle->SetOptStat(0);
   TracktoSegX->SetHighLightColor(2);
   TracktoSegX->Range(-50,-2.848556,50,2.626708);
   TracktoSegX->SetFillColor(0);
   TracktoSegX->SetBorderMode(0);
   TracktoSegX->SetBorderSize(2);
   TracktoSegX->SetLogy();
   TracktoSegX->SetFrameBorderMode(0);
   TracktoSegX->SetFrameBorderMode(0);
   
   TH1D *TracktoSegX_1__97 = new TH1D("TracktoSegX_1__97","TracktoSegX",100,-40,40);
   TracktoSegX_1__97->SetBinContent(0,375.4342);
   TracktoSegX_1__97->SetBinContent(12,0.001237011);
   TracktoSegX_1__97->SetBinContent(15,0.001237011);
   TracktoSegX_1__97->SetBinContent(16,0.002474023);
   TracktoSegX_1__97->SetBinContent(18,0.001237011);
   TracktoSegX_1__97->SetBinContent(19,0.0105146);
   TracktoSegX_1__97->SetBinContent(20,0.006185057);
   TracktoSegX_1__97->SetBinContent(21,0.01608115);
   TracktoSegX_1__97->SetBinContent(22,0.02968827);
   TracktoSegX_1__97->SetBinContent(23,0.03958436);
   TracktoSegX_1__97->SetBinContent(24,0.0222662);
   TracktoSegX_1__97->SetBinContent(25,0.05319149);
   TracktoSegX_1__97->SetBinContent(26,0.05813953);
   TracktoSegX_1__97->SetBinContent(27,0.08164275);
   TracktoSegX_1__97->SetBinContent(28,0.1292677);
   TracktoSegX_1__97->SetBinContent(29,0.1373083);
   TracktoSegX_1__97->SetBinContent(30,0.1688521);
   TracktoSegX_1__97->SetBinContent(31,0.1929738);
   TracktoSegX_1__97->SetBinContent(32,0.2554429);
   TracktoSegX_1__97->SetBinContent(33,0.3284265);
   TracktoSegX_1__97->SetBinContent(34,0.3698664);
   TracktoSegX_1__97->SetBinContent(35,0.3958436);
   TracktoSegX_1__97->SetBinContent(36,0.494186);
   TracktoSegX_1__97->SetBinContent(37,0.4997526);
   TracktoSegX_1__97->SetBinContent(38,0.5745918);
   TracktoSegX_1__97->SetBinContent(39,0.5838694);
   TracktoSegX_1__97->SetBinContent(40,0.7119);
   TracktoSegX_1__97->SetBinContent(41,0.8040574);
   TracktoSegX_1__97->SetBinContent(42,0.8640524);
   TracktoSegX_1__97->SetBinContent(43,0.8832261);
   TracktoSegX_1__97->SetBinContent(44,1.021153);
   TracktoSegX_1__97->SetBinContent(45,1.113929);
   TracktoSegX_1__97->SetBinContent(46,1.229589);
   TracktoSegX_1__97->SetBinContent(47,1.442355);
   TracktoSegX_1__97->SetBinContent(48,1.804181);
   TracktoSegX_1__97->SetBinContent(49,3.077684);
   TracktoSegX_1__97->SetBinContent(50,32.86739);
   TracktoSegX_1__97->SetBinContent(51,32.61009);
   TracktoSegX_1__97->SetBinContent(52,2.986764);
   TracktoSegX_1__97->SetBinContent(53,1.827684);
   TracktoSegX_1__97->SetBinContent(54,1.49431);
   TracktoSegX_1__97->SetBinContent(55,1.259278);
   TracktoSegX_1__97->SetBinContent(56,1.081148);
   TracktoSegX_1__97->SetBinContent(57,1.019297);
   TracktoSegX_1__97->SetBinContent(58,0.8819891);
   TracktoSegX_1__97->SetBinContent(59,0.8257051);
   TracktoSegX_1__97->SetBinContent(60,0.7174666);
   TracktoSegX_1__97->SetBinContent(61,0.6729342);
   TracktoSegX_1__97->SetBinContent(62,0.650668);
   TracktoSegX_1__97->SetBinContent(63,0.5523256);
   TracktoSegX_1__97->SetBinContent(64,0.5411925);
   TracktoSegX_1__97->SetBinContent(65,0.3983177);
   TracktoSegX_1__97->SetBinContent(66,0.4063582);
   TracktoSegX_1__97->SetBinContent(67,0.329045);
   TracktoSegX_1__97->SetBinContent(68,0.2845126);
   TracktoSegX_1__97->SetBinContent(69,0.2467838);
   TracktoSegX_1__97->SetBinContent(70,0.2523503);
   TracktoSegX_1__97->SetBinContent(71,0.1571004);
   TracktoSegX_1__97->SetBinContent(72,0.1261752);
   TracktoSegX_1__97->SetBinContent(73,0.103909);
   TracktoSegX_1__97->SetBinContent(74,0.07422068);
   TracktoSegX_1__97->SetBinContent(75,0.05999505);
   TracktoSegX_1__97->SetBinContent(76,0.03834735);
   TracktoSegX_1__97->SetBinContent(77,0.0321623);
   TracktoSegX_1__97->SetBinContent(78,0.02350322);
   TracktoSegX_1__97->SetBinContent(79,0.02102919);
   TracktoSegX_1__97->SetBinContent(80,0.01731816);
   TracktoSegX_1__97->SetBinContent(81,0.007422068);
   TracktoSegX_1__97->SetBinContent(82,0.007422068);
   TracktoSegX_1__97->SetBinContent(83,0.007422068);
   TracktoSegX_1__97->SetBinContent(84,0.003711034);
   TracktoSegX_1__97->SetBinContent(85,0.004948046);
   TracktoSegX_1__97->SetBinContent(86,0.001237011);
   TracktoSegX_1__97->SetBinContent(87,0.002474023);
   TracktoSegX_1__97->SetMinimum(0.005);
   TracktoSegX_1__97->SetMaximum(120);
   TracktoSegX_1__97->SetEntries(768682);
   TracktoSegX_1__97->SetStats(0);

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

   ci = TColor::GetColor("#ff00ff");
   TracktoSegX_1__97->SetMarkerColor(ci);
   TracktoSegX_1__97->GetXaxis()->SetTitle("cm");
   TracktoSegX_1__97->GetYaxis()->SetTitle("scaled number of entries");
   TracktoSegX_1__97->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("TracktoSegX_1","ME11A: mean:-0.0cm;RMS:4.5cm","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("TracktoSegX_2","ME11B: mean:0.0cm;RMS:4.7cm","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("TracktoSegX_3","ME12+13: mean:-0.0cm;RMS:3.5cm","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("TracktoSegX_4","ME2: mean:-0.0cm;RMS:3.8cm","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("TracktoSegX_5","ME3: mean:0.0cm;RMS:2.8cm","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("TracktoSegX_6","ME4: mean:-0.0cm;RMS:2.4cm","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 *TracktoSegX_2__98 = new TH1D("TracktoSegX_2__98","TracktoSegX",100,-40,40);
   TracktoSegX_2__98->SetBinContent(0,259.1199);
   TracktoSegX_2__98->SetBinContent(4,0.0005124775);
   TracktoSegX_2__98->SetBinContent(5,0.001024955);
   TracktoSegX_2__98->SetBinContent(6,0.001537433);
   TracktoSegX_2__98->SetBinContent(7,0.00204991);
   TracktoSegX_2__98->SetBinContent(8,0.002562388);
   TracktoSegX_2__98->SetBinContent(9,0.003843582);
   TracktoSegX_2__98->SetBinContent(10,0.003587343);
   TracktoSegX_2__98->SetBinContent(11,0.006662208);
   TracktoSegX_2__98->SetBinContent(12,0.01127451);
   TracktoSegX_2__98->SetBinContent(13,0.01281194);
   TracktoSegX_2__98->SetBinContent(14,0.01793671);
   TracktoSegX_2__98->SetBinContent(15,0.01896167);
   TracktoSegX_2__98->SetBinContent(16,0.02383021);
   TracktoSegX_2__98->SetBinContent(17,0.0297237);
   TracktoSegX_2__98->SetBinContent(18,0.03382352);
   TracktoSegX_2__98->SetBinContent(19,0.04048573);
   TracktoSegX_2__98->SetBinContent(20,0.04663546);
   TracktoSegX_2__98->SetBinContent(21,0.05150399);
   TracktoSegX_2__98->SetBinContent(22,0.05406638);
   TracktoSegX_2__98->SetBinContent(23,0.06867199);
   TracktoSegX_2__98->SetBinContent(24,0.09480835);
   TracktoSegX_2__98->SetBinContent(25,0.09942064);
   TracktoSegX_2__98->SetBinContent(26,0.1086452);
   TracktoSegX_2__98->SetBinContent(27,0.1314505);
   TracktoSegX_2__98->SetBinContent(28,0.1450311);
   TracktoSegX_2__98->SetBinContent(29,0.1563057);
   TracktoSegX_2__98->SetBinContent(30,0.1883355);
   TracktoSegX_2__98->SetBinContent(31,0.1965351);
   TracktoSegX_2__98->SetBinContent(32,0.1924353);
   TracktoSegX_2__98->SetBinContent(33,0.216778);
   TracktoSegX_2__98->SetBinContent(34,0.2395833);
   TracktoSegX_2__98->SetBinContent(35,0.2705881);
   TracktoSegX_2__98->SetBinContent(36,0.2711006);
   TracktoSegX_2__98->SetBinContent(37,0.2977495);
   TracktoSegX_2__98->SetBinContent(38,0.3202985);
   TracktoSegX_2__98->SetBinContent(39,0.3223484);
   TracktoSegX_2__98->SetBinContent(40,0.3574531);
   TracktoSegX_2__98->SetBinContent(41,0.3817958);
   TracktoSegX_2__98->SetBinContent(42,0.4087008);
   TracktoSegX_2__98->SetBinContent(43,0.4412432);
   TracktoSegX_2__98->SetBinContent(44,0.5106839);
   TracktoSegX_2__98->SetBinContent(45,0.5993425);
   TracktoSegX_2__98->SetBinContent(46,0.7343803);
   TracktoSegX_2__98->SetBinContent(47,0.9708887);
   TracktoSegX_2__98->SetBinContent(48,1.494897);
   TracktoSegX_2__98->SetBinContent(49,3.267044);
   TracktoSegX_2__98->SetBinContent(50,37.33783);
   TracktoSegX_2__98->SetBinContent(51,36.97833);
   TracktoSegX_2__98->SetBinContent(52,3.26192);
   TracktoSegX_2__98->SetBinContent(53,1.436987);
   TracktoSegX_2__98->SetBinContent(54,0.9283531);
   TracktoSegX_2__98->SetBinContent(55,0.7395051);
   TracktoSegX_2__98->SetBinContent(56,0.5714125);
   TracktoSegX_2__98->SetBinContent(57,0.5099152);
   TracktoSegX_2__98->SetBinContent(58,0.4555925);
   TracktoSegX_2__98->SetBinContent(59,0.4151068);
   TracktoSegX_2__98->SetBinContent(60,0.3835894);
   TracktoSegX_2__98->SetBinContent(61,0.3664214);
   TracktoSegX_2__98->SetBinContent(62,0.3364415);
   TracktoSegX_2__98->SetBinContent(63,0.2885249);
   TracktoSegX_2__98->SetBinContent(64,0.3154299);
   TracktoSegX_2__98->SetBinContent(65,0.2769941);
   TracktoSegX_2__98->SetBinContent(66,0.2685382);
   TracktoSegX_2__98->SetBinContent(67,0.2621323);
   TracktoSegX_2__98->SetBinContent(68,0.2265151);
   TracktoSegX_2__98->SetBinContent(69,0.2298462);
   TracktoSegX_2__98->SetBinContent(70,0.1893605);
   TracktoSegX_2__98->SetBinContent(71,0.1616867);
   TracktoSegX_2__98->SetBinContent(72,0.1775735);
   TracktoSegX_2__98->SetBinContent(73,0.1460561);
   TracktoSegX_2__98->SetBinContent(74,0.1224821);
   TracktoSegX_2__98->SetBinContent(75,0.1260695);
   TracktoSegX_2__98->SetBinContent(76,0.09147724);
   TracktoSegX_2__98->SetBinContent(77,0.09275844);
   TracktoSegX_2__98->SetBinContent(78,0.0799465);
   TracktoSegX_2__98->SetBinContent(79,0.06098483);
   TracktoSegX_2__98->SetBinContent(80,0.06175354);
   TracktoSegX_2__98->SetBinContent(81,0.06098483);
   TracktoSegX_2__98->SetBinContent(82,0.03536095);
   TracktoSegX_2__98->SetBinContent(83,0.02562388);
   TracktoSegX_2__98->SetBinContent(84,0.02459892);
   TracktoSegX_2__98->SetBinContent(85,0.02101158);
   TracktoSegX_2__98->SetBinContent(86,0.0204991);
   TracktoSegX_2__98->SetBinContent(87,0.01229946);
   TracktoSegX_2__98->SetBinContent(88,0.01383689);
   TracktoSegX_2__98->SetBinContent(89,0.01076203);
   TracktoSegX_2__98->SetBinContent(90,0.006149731);
   TracktoSegX_2__98->SetBinContent(91,0.006149731);
   TracktoSegX_2__98->SetBinContent(92,0.005637253);
   TracktoSegX_2__98->SetBinContent(93,0.001537433);
   TracktoSegX_2__98->SetBinContent(94,0.00204991);
   TracktoSegX_2__98->SetBinContent(95,0.00204991);
   TracktoSegX_2__98->SetBinContent(96,0.001024955);
   TracktoSegX_2__98->SetBinContent(97,0.001024955);
   TracktoSegX_2__98->SetBinContent(98,0.0005124775);
   TracktoSegX_2__98->SetEntries(1401505);
   TracktoSegX_2__98->SetStats(0);

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

   ci = TColor::GetColor("#ff9999");
   TracktoSegX_2__98->SetMarkerColor(ci);
   TracktoSegX_2__98->GetXaxis()->SetTitle("cm");
   TracktoSegX_2__98->GetYaxis()->SetTitle("scaled number of entries");
   TracktoSegX_2__98->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("TracktoSegX_1","ME11A: mean:-0.0cm;RMS:4.5cm","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("TracktoSegX_2","ME11B: mean:0.0cm;RMS:4.7cm","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("TracktoSegX_3","ME12+13: mean:-0.0cm;RMS:3.5cm","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("TracktoSegX_4","ME2: mean:-0.0cm;RMS:3.8cm","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("TracktoSegX_5","ME3: mean:0.0cm;RMS:2.8cm","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("TracktoSegX_6","ME4: mean:-0.0cm;RMS:2.4cm","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 *TracktoSegX_3__99 = new TH1D("TracktoSegX_3__99","TracktoSegX",100,-40,40);
   TracktoSegX_3__99->SetBinContent(0,87.29437);
   TracktoSegX_3__99->SetBinContent(1,0.006549083);
   TracktoSegX_3__99->SetBinContent(2,0.01309817);
   TracktoSegX_3__99->SetBinContent(3,0.02292179);
   TracktoSegX_3__99->SetBinContent(4,0.008186354);
   TracktoSegX_3__99->SetBinContent(5,0.006549083);
   TracktoSegX_3__99->SetBinContent(6,0.009823625);
   TracktoSegX_3__99->SetBinContent(7,0.01800998);
   TracktoSegX_3__99->SetBinContent(8,0.01555407);
   TracktoSegX_3__99->SetBinContent(9,0.01473544);
   TracktoSegX_3__99->SetBinContent(10,0.01882861);
   TracktoSegX_3__99->SetBinContent(11,0.01555407);
   TracktoSegX_3__99->SetBinContent(12,0.01719134);
   TracktoSegX_3__99->SetBinContent(13,0.01555407);
   TracktoSegX_3__99->SetBinContent(14,0.0139168);
   TracktoSegX_3__99->SetBinContent(15,0.02292179);
   TracktoSegX_3__99->SetBinContent(16,0.02210316);
   TracktoSegX_3__99->SetBinContent(17,0.02128452);
   TracktoSegX_3__99->SetBinContent(18,0.01800998);
   TracktoSegX_3__99->SetBinContent(19,0.01800998);
   TracktoSegX_3__99->SetBinContent(20,0.03438269);
   TracktoSegX_3__99->SetBinContent(21,0.02210316);
   TracktoSegX_3__99->SetBinContent(22,0.03151746);
   TracktoSegX_3__99->SetBinContent(23,0.03438269);
   TracktoSegX_3__99->SetBinContent(24,0.03151746);
   TracktoSegX_3__99->SetBinContent(25,0.0392945);
   TracktoSegX_3__99->SetBinContent(26,0.02210316);
   TracktoSegX_3__99->SetBinContent(27,0.0392945);
   TracktoSegX_3__99->SetBinContent(28,0.04175041);
   TracktoSegX_3__99->SetBinContent(29,0.0253777);
   TracktoSegX_3__99->SetBinContent(30,0.0392945);
   TracktoSegX_3__99->SetBinContent(31,0.03683859);
   TracktoSegX_3__99->SetBinContent(32,0.03847586);
   TracktoSegX_3__99->SetBinContent(33,0.04502495);
   TracktoSegX_3__99->SetBinContent(34,0.05280198);
   TracktoSegX_3__99->SetBinContent(35,0.05730448);
   TracktoSegX_3__99->SetBinContent(36,0.06057902);
   TracktoSegX_3__99->SetBinContent(37,0.05935107);
   TracktoSegX_3__99->SetBinContent(38,0.07203992);
   TracktoSegX_3__99->SetBinContent(39,0.07981695);
   TracktoSegX_3__99->SetBinContent(40,0.09496171);
   TracktoSegX_3__99->SetBinContent(41,0.1015108);
   TracktoSegX_3__99->SetBinContent(42,0.1530848);
   TracktoSegX_3__99->SetBinContent(43,0.217757);
   TracktoSegX_3__99->SetBinContent(44,0.3307287);
   TracktoSegX_3__99->SetBinContent(45,0.6188884);
   TracktoSegX_3__99->SetBinContent(46,1.039258);
   TracktoSegX_3__99->SetBinContent(47,2.144415);
   TracktoSegX_3__99->SetBinContent(48,4.776738);
   TracktoSegX_3__99->SetBinContent(49,12.08347);
   TracktoSegX_3__99->SetBinContent(50,27.23887);
   TracktoSegX_3__99->SetBinContent(51,27.20489);
   TracktoSegX_3__99->SetBinContent(52,12.24515);
   TracktoSegX_3__99->SetBinContent(53,4.901989);
   TracktoSegX_3__99->SetBinContent(54,2.116991);
   TracktoSegX_3__99->SetBinContent(55,0.9835905);
   TracktoSegX_3__99->SetBinContent(56,0.5615839);
   TracktoSegX_3__99->SetBinContent(57,0.3331846);
   TracktoSegX_3__99->SetBinContent(58,0.2050682);
   TracktoSegX_3__99->SetBinContent(59,0.1690482);
   TracktoSegX_3__99->SetBinContent(60,0.1268885);
   TracktoSegX_3__99->SetBinContent(61,0.09086853);
   TracktoSegX_3__99->SetBinContent(62,0.08186354);
   TracktoSegX_3__99->SetBinContent(63,0.05976039);
   TracktoSegX_3__99->SetBinContent(64,0.05607653);
   TracktoSegX_3__99->SetBinContent(65,0.06385356);
   TracktoSegX_3__99->SetBinContent(66,0.04829949);
   TracktoSegX_3__99->SetBinContent(67,0.04666222);
   TracktoSegX_3__99->SetBinContent(68,0.05566721);
   TracktoSegX_3__99->SetBinContent(69,0.04093177);
   TracktoSegX_3__99->SetBinContent(70,0.03274542);
   TracktoSegX_3__99->SetBinContent(71,0.02947087);
   TracktoSegX_3__99->SetBinContent(72,0.03765723);
   TracktoSegX_3__99->SetBinContent(73,0.03028951);
   TracktoSegX_3__99->SetBinContent(74,0.02578702);
   TracktoSegX_3__99->SetBinContent(75,0.02947087);
   TracktoSegX_3__99->SetBinContent(76,0.02374043);
   TracktoSegX_3__99->SetBinContent(77,0.02660565);
   TracktoSegX_3__99->SetBinContent(78,0.02742429);
   TracktoSegX_3__99->SetBinContent(79,0.02865224);
   TracktoSegX_3__99->SetBinContent(80,0.02374043);
   TracktoSegX_3__99->SetBinContent(81,0.02455906);
   TracktoSegX_3__99->SetBinContent(82,0.02455906);
   TracktoSegX_3__99->SetBinContent(83,0.02455906);
   TracktoSegX_3__99->SetBinContent(84,0.03028951);
   TracktoSegX_3__99->SetBinContent(85,0.0278336);
   TracktoSegX_3__99->SetBinContent(86,0.01473544);
   TracktoSegX_3__99->SetBinContent(87,0.01432612);
   TracktoSegX_3__99->SetBinContent(88,0.01719134);
   TracktoSegX_3__99->SetBinContent(89,0.01637271);
   TracktoSegX_3__99->SetBinContent(90,0.01473544);
   TracktoSegX_3__99->SetBinContent(91,0.0114609);
   TracktoSegX_3__99->SetBinContent(92,0.02046589);
   TracktoSegX_3__99->SetBinContent(93,0.01309817);
   TracktoSegX_3__99->SetBinContent(94,0.0114609);
   TracktoSegX_3__99->SetBinContent(95,0.0114609);
   TracktoSegX_3__99->SetBinContent(96,0.01227953);
   TracktoSegX_3__99->SetBinContent(97,0.01064226);
   TracktoSegX_3__99->SetBinContent(98,0.009823625);
   TracktoSegX_3__99->SetBinContent(99,0.01227953);
   TracktoSegX_3__99->SetBinContent(100,0.008186354);
   TracktoSegX_3__99->SetBinContent(101,0.1338469);
   TracktoSegX_3__99->SetEntries(457904);
   TracktoSegX_3__99->SetStats(0);
   TracktoSegX_3__99->GetXaxis()->SetTitle("cm");
   TracktoSegX_3__99->GetYaxis()->SetTitle("scaled number of entries");
   TracktoSegX_3__99->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("TracktoSegX_1","ME11A: mean:-0.0cm;RMS:4.5cm","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("TracktoSegX_2","ME11B: mean:0.0cm;RMS:4.7cm","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("TracktoSegX_3","ME12+13: mean:-0.0cm;RMS:3.5cm","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("TracktoSegX_4","ME2: mean:-0.0cm;RMS:3.8cm","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("TracktoSegX_5","ME3: mean:0.0cm;RMS:2.8cm","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("TracktoSegX_6","ME4: mean:-0.0cm;RMS:2.4cm","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 *TracktoSegX_4__100 = new TH1D("TracktoSegX_4__100","TracktoSegX",100,-40,40);
   TracktoSegX_4__100->SetBinContent(0,206.7981);
   TracktoSegX_4__100->SetBinContent(1,0.01644545);
   TracktoSegX_4__100->SetBinContent(2,0.021105);
   TracktoSegX_4__100->SetBinContent(3,0.02439409);
   TracktoSegX_4__100->SetBinContent(4,0.01795295);
   TracktoSegX_4__100->SetBinContent(5,0.02055682);
   TracktoSegX_4__100->SetBinContent(6,0.02439409);
   TracktoSegX_4__100->SetBinContent(7,0.01836409);
   TracktoSegX_4__100->SetBinContent(8,0.01863818);
   TracktoSegX_4__100->SetBinContent(9,0.02069386);
   TracktoSegX_4__100->SetBinContent(10,0.02247545);
   TracktoSegX_4__100->SetBinContent(11,0.02507932);
   TracktoSegX_4__100->SetBinContent(12,0.02576454);
   TracktoSegX_4__100->SetBinContent(13,0.02247545);
   TracktoSegX_4__100->SetBinContent(14,0.01918636);
   TracktoSegX_4__100->SetBinContent(15,0.02165318);
   TracktoSegX_4__100->SetBinContent(16,0.02165318);
   TracktoSegX_4__100->SetBinContent(17,0.02754613);
   TracktoSegX_4__100->SetBinContent(18,0.02384591);
   TracktoSegX_4__100->SetBinContent(19,0.02686091);
   TracktoSegX_4__100->SetBinContent(20,0.02466818);
   TracktoSegX_4__100->SetBinContent(21,0.02439409);
   TracktoSegX_4__100->SetBinContent(22,0.02740909);
   TracktoSegX_4__100->SetBinContent(23,0.03124636);
   TracktoSegX_4__100->SetBinContent(24,0.02823136);
   TracktoSegX_4__100->SetBinContent(25,0.03124636);
   TracktoSegX_4__100->SetBinContent(26,0.02576454);
   TracktoSegX_4__100->SetBinContent(27,0.02987591);
   TracktoSegX_4__100->SetBinContent(28,0.02891659);
   TracktoSegX_4__100->SetBinContent(29,0.03645409);
   TracktoSegX_4__100->SetBinContent(30,0.03823568);
   TracktoSegX_4__100->SetBinContent(31,0.03371318);
   TracktoSegX_4__100->SetBinContent(32,0.03563181);
   TracktoSegX_4__100->SetBinContent(33,0.03672818);
   TracktoSegX_4__100->SetBinContent(34,0.03960613);
   TracktoSegX_4__100->SetBinContent(35,0.04714363);
   TracktoSegX_4__100->SetBinContent(36,0.05125499);
   TracktoSegX_4__100->SetBinContent(37,0.05344772);
   TracktoSegX_4__100->SetBinContent(38,0.06071113);
   TracktoSegX_4__100->SetBinContent(39,0.0766084);
   TracktoSegX_4__100->SetBinContent(40,0.07647135);
   TracktoSegX_4__100->SetBinContent(41,0.1047027);
   TracktoSegX_4__100->SetBinContent(42,0.1488313);
   TracktoSegX_4__100->SetBinContent(43,0.208035);
   TracktoSegX_4__100->SetBinContent(44,0.3062966);
   TracktoSegX_4__100->SetBinContent(45,0.494597);
   TracktoSegX_4__100->SetBinContent(46,0.8903842);
   TracktoSegX_4__100->SetBinContent(47,1.721017);
   TracktoSegX_4__100->SetBinContent(48,3.799996);
   TracktoSegX_4__100->SetBinContent(49,10.21386);
   TracktoSegX_4__100->SetBinContent(50,31.05148);
   TracktoSegX_4__100->SetBinContent(51,30.66679);
   TracktoSegX_4__100->SetBinContent(52,10.2155);
   TracktoSegX_4__100->SetBinContent(53,3.816167);
   TracktoSegX_4__100->SetBinContent(54,1.748974);
   TracktoSegX_4__100->SetBinContent(55,0.919986);
   TracktoSegX_4__100->SetBinContent(56,0.4989824);
   TracktoSegX_4__100->SetBinContent(57,0.2987591);
   TracktoSegX_4__100->SetBinContent(58,0.1892597);
   TracktoSegX_4__100->SetBinContent(59,0.1403345);
   TracktoSegX_4__100->SetBinContent(60,0.1081289);
   TracktoSegX_4__100->SetBinContent(61,0.08688681);
   TracktoSegX_4__100->SetBinContent(62,0.07277113);
   TracktoSegX_4__100->SetBinContent(63,0.05892954);
   TracktoSegX_4__100->SetBinContent(64,0.05317363);
   TracktoSegX_4__100->SetBinContent(65,0.04426568);
   TracktoSegX_4__100->SetBinContent(66,0.04399159);
   TracktoSegX_4__100->SetBinContent(67,0.03686522);
   TracktoSegX_4__100->SetBinContent(68,0.04056545);
   TracktoSegX_4__100->SetBinContent(69,0.03357613);
   TracktoSegX_4__100->SetBinContent(70,0.0316575);
   TracktoSegX_4__100->SetBinContent(71,0.02946477);
   TracktoSegX_4__100->SetBinContent(72,0.03398727);
   TracktoSegX_4__100->SetBinContent(73,0.02631272);
   TracktoSegX_4__100->SetBinContent(74,0.0328909);
   TracktoSegX_4__100->SetBinContent(75,0.02631272);
   TracktoSegX_4__100->SetBinContent(76,0.0328909);
   TracktoSegX_4__100->SetBinContent(77,0.02768318);
   TracktoSegX_4__100->SetBinContent(78,0.02631272);
   TracktoSegX_4__100->SetBinContent(79,0.02466818);
   TracktoSegX_4__100->SetBinContent(80,0.02220136);
   TracktoSegX_4__100->SetBinContent(81,0.02398295);
   TracktoSegX_4__100->SetBinContent(82,0.02658681);
   TracktoSegX_4__100->SetBinContent(83,0.02521636);
   TracktoSegX_4__100->SetBinContent(84,0.02247545);
   TracktoSegX_4__100->SetBinContent(85,0.02494227);
   TracktoSegX_4__100->SetBinContent(86,0.02165318);
   TracktoSegX_4__100->SetBinContent(87,0.02192727);
   TracktoSegX_4__100->SetBinContent(88,0.01726773);
   TracktoSegX_4__100->SetBinContent(89,0.02494227);
   TracktoSegX_4__100->SetBinContent(90,0.02192727);
   TracktoSegX_4__100->SetBinContent(91,0.01987159);
   TracktoSegX_4__100->SetBinContent(92,0.01987159);
   TracktoSegX_4__100->SetBinContent(93,0.02028272);
   TracktoSegX_4__100->SetBinContent(94,0.01630841);
   TracktoSegX_4__100->SetBinContent(95,0.02192727);
   TracktoSegX_4__100->SetBinContent(96,0.01480091);
   TracktoSegX_4__100->SetBinContent(97,0.01863818);
   TracktoSegX_4__100->SetBinContent(98,0.02165318);
   TracktoSegX_4__100->SetBinContent(99,0.01534909);
   TracktoSegX_4__100->SetBinContent(100,0.01603432);
   TracktoSegX_4__100->SetBinContent(101,0.4718474);
   TracktoSegX_4__100->SetEntries(2242103);
   TracktoSegX_4__100->SetStats(0);

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

   ci = TColor::GetColor("#ff0000");
   TracktoSegX_4__100->SetMarkerColor(ci);
   TracktoSegX_4__100->GetXaxis()->SetTitle("cm");
   TracktoSegX_4__100->GetYaxis()->SetTitle("scaled number of entries");
   TracktoSegX_4__100->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("TracktoSegX_1","ME11A: mean:-0.0cm;RMS:4.5cm","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("TracktoSegX_2","ME11B: mean:0.0cm;RMS:4.7cm","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("TracktoSegX_3","ME12+13: mean:-0.0cm;RMS:3.5cm","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("TracktoSegX_4","ME2: mean:-0.0cm;RMS:3.8cm","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("TracktoSegX_5","ME3: mean:0.0cm;RMS:2.8cm","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("TracktoSegX_6","ME4: mean:-0.0cm;RMS:2.4cm","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 *TracktoSegX_5__101 = new TH1D("TracktoSegX_5__101","TracktoSegX",100,-40,40);
   TracktoSegX_5__101->SetBinContent(0,158.14);
   TracktoSegX_5__101->SetBinContent(1,0.008312923);
   TracktoSegX_5__101->SetBinContent(2,0.008312923);
   TracktoSegX_5__101->SetBinContent(3,0.007081379);
   TracktoSegX_5__101->SetBinContent(4,0.008005037);
   TracktoSegX_5__101->SetBinContent(5,0.01016024);
   TracktoSegX_5__101->SetBinContent(6,0.007697151);
   TracktoSegX_5__101->SetBinContent(7,0.01046813);
   TracktoSegX_5__101->SetBinContent(8,0.008928695);
   TracktoSegX_5__101->SetBinContent(9,0.008312923);
   TracktoSegX_5__101->SetBinContent(10,0.008928695);
   TracktoSegX_5__101->SetBinContent(11,0.009544467);
   TracktoSegX_5__101->SetBinContent(12,0.005541949);
   TracktoSegX_5__101->SetBinContent(13,0.009852353);
   TracktoSegX_5__101->SetBinContent(14,0.009544467);
   TracktoSegX_5__101->SetBinContent(15,0.007851094);
   TracktoSegX_5__101->SetBinContent(16,0.009236581);
   TracktoSegX_5__101->SetBinContent(17,0.007081379);
   TracktoSegX_5__101->SetBinContent(18,0.01077601);
   TracktoSegX_5__101->SetBinContent(19,0.008620809);
   TracktoSegX_5__101->SetBinContent(20,0.0100063);
   TracktoSegX_5__101->SetBinContent(21,0.01139178);
   TracktoSegX_5__101->SetBinContent(22,0.009852353);
   TracktoSegX_5__101->SetBinContent(23,0.01570219);
   TracktoSegX_5__101->SetBinContent(24,0.0110839);
   TracktoSegX_5__101->SetBinContent(25,0.01462459);
   TracktoSegX_5__101->SetBinContent(26,0.01570219);
   TracktoSegX_5__101->SetBinContent(27,0.009852353);
   TracktoSegX_5__101->SetBinContent(28,0.0175495);
   TracktoSegX_5__101->SetBinContent(29,0.01385487);
   TracktoSegX_5__101->SetBinContent(30,0.01447064);
   TracktoSegX_5__101->SetBinContent(31,0.01693373);
   TracktoSegX_5__101->SetBinContent(32,0.01601007);
   TracktoSegX_5__101->SetBinContent(33,0.0175495);
   TracktoSegX_5__101->SetBinContent(34,0.02678609);
   TracktoSegX_5__101->SetBinContent(35,0.02463088);
   TracktoSegX_5__101->SetBinContent(36,0.02555454);
   TracktoSegX_5__101->SetBinContent(37,0.03032677);
   TracktoSegX_5__101->SetBinContent(38,0.04064096);
   TracktoSegX_5__101->SetBinContent(39,0.05603526);
   TracktoSegX_5__101->SetBinContent(40,0.05896018);
   TracktoSegX_5__101->SetBinContent(41,0.08959484);
   TracktoSegX_5__101->SetBinContent(42,0.1319292);
   TracktoSegX_5__101->SetBinContent(43,0.1904275);
   TracktoSegX_5__101->SetBinContent(44,0.3146595);
   TracktoSegX_5__101->SetBinContent(45,0.5404939);
   TracktoSegX_5__101->SetBinContent(46,1.014023);
   TracktoSegX_5__101->SetBinContent(47,2.059758);
   TracktoSegX_5__101->SetBinContent(48,4.638611);
   TracktoSegX_5__101->SetBinContent(49,11.94228);
   TracktoSegX_5__101->SetBinContent(50,28.39679);
   TracktoSegX_5__101->SetBinContent(51,28.52657);
   TracktoSegX_5__101->SetBinContent(52,11.97584);
   TracktoSegX_5__101->SetBinContent(53,4.541473);
   TracktoSegX_5__101->SetBinContent(54,2.031432);
   TracktoSegX_5__101->SetBinContent(55,1.039731);
   TracktoSegX_5__101->SetBinContent(56,0.5401861);
   TracktoSegX_5__101->SetBinContent(57,0.3011125);
   TracktoSegX_5__101->SetBinContent(58,0.1990483);
   TracktoSegX_5__101->SetBinContent(59,0.1333147);
   TracktoSegX_5__101->SetBinContent(60,0.1006787);
   TracktoSegX_5__101->SetBinContent(61,0.07173745);
   TracktoSegX_5__101->SetBinContent(62,0.04926177);
   TracktoSegX_5__101->SetBinContent(63,0.05003148);
   TracktoSegX_5__101->SetBinContent(64,0.03355958);
   TracktoSegX_5__101->SetBinContent(65,0.03263592);
   TracktoSegX_5__101->SetBinContent(66,0.02309145);
   TracktoSegX_5__101->SetBinContent(67,0.02463088);
   TracktoSegX_5__101->SetBinContent(68,0.024323);
   TracktoSegX_5__101->SetBinContent(69,0.01200756);
   TracktoSegX_5__101->SetBinContent(70,0.01785739);
   TracktoSegX_5__101->SetBinContent(71,0.01724162);
   TracktoSegX_5__101->SetBinContent(72,0.01631796);
   TracktoSegX_5__101->SetBinContent(73,0.01370093);
   TracktoSegX_5__101->SetBinContent(74,0.01570219);
   TracktoSegX_5__101->SetBinContent(75,0.01293121);
   TracktoSegX_5__101->SetBinContent(76,0.01570219);
   TracktoSegX_5__101->SetBinContent(77,0.01200756);
   TracktoSegX_5__101->SetBinContent(78,0.01354699);
   TracktoSegX_5__101->SetBinContent(79,0.008620809);
   TracktoSegX_5__101->SetBinContent(80,0.01231544);
   TracktoSegX_5__101->SetBinContent(81,0.01169967);
   TracktoSegX_5__101->SetBinContent(82,0.01077601);
   TracktoSegX_5__101->SetBinContent(83,0.01062207);
   TracktoSegX_5__101->SetBinContent(84,0.01477853);
   TracktoSegX_5__101->SetBinContent(85,0.009544467);
   TracktoSegX_5__101->SetBinContent(86,0.009544467);
   TracktoSegX_5__101->SetBinContent(87,0.009544467);
   TracktoSegX_5__101->SetBinContent(88,0.01139178);
   TracktoSegX_5__101->SetBinContent(89,0.01016024);
   TracktoSegX_5__101->SetBinContent(90,0.008312923);
   TracktoSegX_5__101->SetBinContent(91,0.01200756);
   TracktoSegX_5__101->SetBinContent(92,0.01231544);
   TracktoSegX_5__101->SetBinContent(93,0.008620809);
   TracktoSegX_5__101->SetBinContent(94,0.008928695);
   TracktoSegX_5__101->SetBinContent(95,0.006465607);
   TracktoSegX_5__101->SetBinContent(96,0.008774752);
   TracktoSegX_5__101->SetBinContent(97,0.006773493);
   TracktoSegX_5__101->SetBinContent(98,0.007081379);
   TracktoSegX_5__101->SetBinContent(99,0.007389265);
   TracktoSegX_5__101->SetBinContent(100,0.008312923);
   TracktoSegX_5__101->SetBinContent(101,0.1988944);
   TracktoSegX_5__101->SetEntries(1678146);
   TracktoSegX_5__101->SetStats(0);

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

   ci = TColor::GetColor("#00ff00");
   TracktoSegX_5__101->SetMarkerColor(ci);
   TracktoSegX_5__101->GetXaxis()->SetTitle("cm");
   TracktoSegX_5__101->GetYaxis()->SetTitle("scaled number of entries");
   TracktoSegX_5__101->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("TracktoSegX_1","ME11A: mean:-0.0cm;RMS:4.5cm","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("TracktoSegX_2","ME11B: mean:0.0cm;RMS:4.7cm","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("TracktoSegX_3","ME12+13: mean:-0.0cm;RMS:3.5cm","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("TracktoSegX_4","ME2: mean:-0.0cm;RMS:3.8cm","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("TracktoSegX_5","ME3: mean:0.0cm;RMS:2.8cm","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("TracktoSegX_6","ME4: mean:-0.0cm;RMS:2.4cm","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 *TracktoSegX_6__102 = new TH1D("TracktoSegX_6__102","TracktoSegX",100,-40,40);
   TracktoSegX_6__102->SetBinContent(0,132.0754);
   TracktoSegX_6__102->SetBinContent(1,0.002446693);
   TracktoSegX_6__102->SetBinContent(2,0.003844803);
   TracktoSegX_6__102->SetBinContent(3,0.006291495);
   TracktoSegX_6__102->SetBinContent(4,0.006291495);
   TracktoSegX_6__102->SetBinContent(5,0.00559244);
   TracktoSegX_6__102->SetBinContent(6,0.006291495);
   TracktoSegX_6__102->SetBinContent(7,0.006990551);
   TracktoSegX_6__102->SetBinContent(8,0.00279622);
   TracktoSegX_6__102->SetBinContent(9,0.00559244);
   TracktoSegX_6__102->SetBinContent(10,0.003844803);
   TracktoSegX_6__102->SetBinContent(11,0.007340078);
   TracktoSegX_6__102->SetBinContent(12,0.007165314);
   TracktoSegX_6__102->SetBinContent(13,0.005242913);
   TracktoSegX_6__102->SetBinContent(14,0.00419433);
   TracktoSegX_6__102->SetBinContent(15,0.00559244);
   TracktoSegX_6__102->SetBinContent(16,0.006641023);
   TracktoSegX_6__102->SetBinContent(17,0.004543858);
   TracktoSegX_6__102->SetBinContent(18,0.004543858);
   TracktoSegX_6__102->SetBinContent(19,0.006291495);
   TracktoSegX_6__102->SetBinContent(20,0.008388661);
   TracktoSegX_6__102->SetBinContent(21,0.006291495);
   TracktoSegX_6__102->SetBinContent(22,0.008388661);
   TracktoSegX_6__102->SetBinContent(23,0.01048583);
   TracktoSegX_6__102->SetBinContent(24,0.007340078);
   TracktoSegX_6__102->SetBinContent(25,0.009437243);
   TracktoSegX_6__102->SetBinContent(26,0.01258299);
   TracktoSegX_6__102->SetBinContent(27,0.009087716);
   TracktoSegX_6__102->SetBinContent(28,0.009087716);
   TracktoSegX_6__102->SetBinContent(29,0.008039133);
   TracktoSegX_6__102->SetBinContent(30,0.01083535);
   TracktoSegX_6__102->SetBinContent(31,0.01258299);
   TracktoSegX_6__102->SetBinContent(32,0.01747638);
   TracktoSegX_6__102->SetBinContent(33,0.01957354);
   TracktoSegX_6__102->SetBinContent(34,0.01642779);
   TracktoSegX_6__102->SetBinContent(35,0.01747638);
   TracktoSegX_6__102->SetBinContent(36,0.01992307);
   TracktoSegX_6__102->SetBinContent(37,0.02901078);
   TracktoSegX_6__102->SetBinContent(38,0.03250606);
   TracktoSegX_6__102->SetBinContent(39,0.03827326);
   TracktoSegX_6__102->SetBinContent(40,0.05959444);
   TracktoSegX_6__102->SetBinContent(41,0.08685759);
   TracktoSegX_6__102->SetBinContent(42,0.1153441);
   TracktoSegX_6__102->SetBinContent(43,0.2154837);
   TracktoSegX_6__102->SetBinContent(44,0.3350221);
   TracktoSegX_6__102->SetBinContent(45,0.6326448);
   TracktoSegX_6__102->SetBinContent(46,1.145402);
   TracktoSegX_6__102->SetBinContent(47,2.402652);
   TracktoSegX_6__102->SetBinContent(48,5.45228);
   TracktoSegX_6__102->SetBinContent(49,12.95646);
   TracktoSegX_6__102->SetBinContent(50,26.20111);
   TracktoSegX_6__102->SetBinContent(51,26.48021);
   TracktoSegX_6__102->SetBinContent(52,12.97551);
   TracktoSegX_6__102->SetBinContent(53,5.350393);
   TracktoSegX_6__102->SetBinContent(54,2.323659);
   TracktoSegX_6__102->SetBinContent(55,1.102585);
   TracktoSegX_6__102->SetBinContent(56,0.5847596);
   TracktoSegX_6__102->SetBinContent(57,0.3282063);
   TracktoSegX_6__102->SetBinContent(58,0.1943373);
   TracktoSegX_6__102->SetBinContent(59,0.1286261);
   TracktoSegX_6__102->SetBinContent(60,0.08458566);
   TracktoSegX_6__102->SetBinContent(61,0.0622159);
   TracktoSegX_6__102->SetBinContent(62,0.03844803);
   TracktoSegX_6__102->SetBinContent(63,0.03495275);
   TracktoSegX_6__102->SetBinContent(64,0.02184547);
   TracktoSegX_6__102->SetBinContent(65,0.02306882);
   TracktoSegX_6__102->SetBinContent(66,0.01642779);
   TracktoSegX_6__102->SetBinContent(67,0.01433063);
   TracktoSegX_6__102->SetBinContent(68,0.0178259);
   TracktoSegX_6__102->SetBinContent(69,0.01817543);
   TracktoSegX_6__102->SetBinContent(70,0.01188394);
   TracktoSegX_6__102->SetBinContent(71,0.01048583);
   TracktoSegX_6__102->SetBinContent(72,0.0101363);
   TracktoSegX_6__102->SetBinContent(73,0.01083535);
   TracktoSegX_6__102->SetBinContent(74,0.01083535);
   TracktoSegX_6__102->SetBinContent(75,0.008039133);
   TracktoSegX_6__102->SetBinContent(76,0.006116732);
   TracktoSegX_6__102->SetBinContent(77,0.0101363);
   TracktoSegX_6__102->SetBinContent(78,0.008039133);
   TracktoSegX_6__102->SetBinContent(79,0.006641023);
   TracktoSegX_6__102->SetBinContent(80,0.00559244);
   TracktoSegX_6__102->SetBinContent(81,0.00559244);
   TracktoSegX_6__102->SetBinContent(82,0.006291495);
   TracktoSegX_6__102->SetBinContent(83,0.006291495);
   TracktoSegX_6__102->SetBinContent(84,0.004893385);
   TracktoSegX_6__102->SetBinContent(85,0.003145748);
   TracktoSegX_6__102->SetBinContent(86,0.00419433);
   TracktoSegX_6__102->SetBinContent(87,0.005242913);
   TracktoSegX_6__102->SetBinContent(88,0.005242913);
   TracktoSegX_6__102->SetBinContent(89,0.004543858);
   TracktoSegX_6__102->SetBinContent(90,0.00559244);
   TracktoSegX_6__102->SetBinContent(91,0.004543858);
   TracktoSegX_6__102->SetBinContent(92,0.003495275);
   TracktoSegX_6__102->SetBinContent(93,0.006466259);
   TracktoSegX_6__102->SetBinContent(94,0.002446693);
   TracktoSegX_6__102->SetBinContent(95,0.002446693);
   TracktoSegX_6__102->SetBinContent(96,0.00559244);
   TracktoSegX_6__102->SetBinContent(97,0.00419433);
   TracktoSegX_6__102->SetBinContent(98,0.00419433);
   TracktoSegX_6__102->SetBinContent(99,0.003495275);
   TracktoSegX_6__102->SetBinContent(100,0.00559244);
   TracktoSegX_6__102->SetBinContent(101,0.09804247);
   TracktoSegX_6__102->SetEntries(1328499);
   TracktoSegX_6__102->SetStats(0);

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

   ci = TColor::GetColor("#0000ff");
   TracktoSegX_6__102->SetMarkerColor(ci);
   TracktoSegX_6__102->GetXaxis()->SetTitle("cm");
   TracktoSegX_6__102->GetYaxis()->SetTitle("scaled number of entries");
   TracktoSegX_6__102->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("TracktoSegX_1","ME11A: mean:-0.0cm;RMS:4.5cm","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("TracktoSegX_2","ME11B: mean:0.0cm;RMS:4.7cm","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("TracktoSegX_3","ME12+13: mean:-0.0cm;RMS:3.5cm","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("TracktoSegX_4","ME2: mean:-0.0cm;RMS:3.8cm","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("TracktoSegX_5","ME3: mean:0.0cm;RMS:2.8cm","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("TracktoSegX_6","ME4: mean:-0.0cm;RMS:2.4cm","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.3021774,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(1);
   pt->SetFillColor(0);
   TText *AText = pt->AddText("TracktoSegX");
   pt->Draw();
   TracktoSegX->Modified();
   TracktoSegX->cd();
   TracktoSegX->SetSelected(TracktoSegX);
}
示例#19
0
void drawGraphs_vs_pt( const std::string& varY, const std::string& canvasName, TGraphErrors* gr_resoReco_cutOn2ndJet, TGraphErrors* gr_intrReso_vs_pt, TGraphErrors* gr_extrapReso_vs_pt, TGraphErrors* gr_trueReso_vs_pt) {

  Float_t yMin, yMax;
  
  if( varY=="Response" ) {
    yMin = (RECOTYPE_=="pf") ? 0.75 : 0.2;
    yMax = 1.05;
  } else {
    yMin = 0.03;
    yMax = (RECOTYPE_=="pf") ? 0.4 : 0.7;
  }

  TH2D* h2_axes = new TH2D("axes", "", 10, 20., 2200., 10, yMin, yMax);
  h2_axes->GetXaxis()->SetTitleOffset(1.1);
  h2_axes->GetYaxis()->SetTitleOffset(1.2);
  h2_axes->SetYTitle(varY.c_str());
  h2_axes->SetXTitle("p_{T}^{#gamma} [GeV/c]");
  h2_axes->GetXaxis()->SetMoreLogLabels();
  h2_axes->GetXaxis()->SetNoExponent();
  
  std::string legendTitle = "   |#eta^{jet}| < 1.4";

  Float_t leg_xMin = (varY=="Response") ? 0.5 : 0.5;
  Float_t leg_yMin = (varY=="Response") ? 0.15: 0.55;
  Float_t leg_xMax = (varY=="Response") ? 0.88: 0.88;
  Float_t leg_yMax = (varY=="Response") ? 0.45 : 0.88;

  TLegend* legend = new TLegend(leg_xMin, leg_yMin, leg_xMax, leg_yMax, legendTitle.c_str());
  legend->SetFillColor(kWhite);
  //legend->SetFillStyle(1);
  //legend->SetBorderSize(0.5);
  legend->AddEntry(gr_intrReso_vs_pt, "Intrinsic", "P");
  legend->AddEntry(gr_resoReco_cutOn2ndJet, "#gamma+Jet, cut on 2^{nd} Jet", "P");
  if( gr_trueReso_vs_pt != 0 )
    legend->AddEntry(gr_trueReso_vs_pt, "MC Truth", "P");
  if( gr_extrapReso_vs_pt != 0 )
    legend->AddEntry(gr_extrapReso_vs_pt, "#gamma+Jet, p_{T}^{2nd Jet} #rightarrow 0", "P");


  Float_t lab_yMin = (varY=="Response") ? 0.8 : 0.15;
  Float_t lab_yMax = (varY=="Response") ? 0.88 : 0.2;
  TPaveText* label = new TPaveText(0.15, lab_yMin, 0.3, lab_yMax, "brNDC");
  label->SetFillColor(kWhite);
  label->SetTextSize(0.04);
  label->AddText("Anti-kt 0.5");
  
  TCanvas* c1 = new TCanvas("c1", "c1", 800, 600);
  c1->cd();
  c1->SetLogx();
  if( varY=="Resolution" )
    c1->SetLogy();
  c1->SetGridx();
  c1->SetGridy();
  h2_axes->Draw();
  gr_resoReco_cutOn2ndJet->Draw("Psame");
  if( gr_trueReso_vs_pt != 0 )
    gr_trueReso_vs_pt->Draw("Psame");
  gr_intrReso_vs_pt->Draw("P same");
  if( gr_extrapReso_vs_pt != 0 )
    gr_extrapReso_vs_pt->Draw("P same");
  legend->Draw("same");
  label->Draw("same");
  c1->SaveAs(canvasName.c_str()); 
 
  delete c1;
  delete h2_axes;

} //drawGraphs_vs_pt
示例#20
0
void compareThreeVersions(TimeInfoAllSteps TIAS_1,TimeInfoAllSteps TIAS_2,TimeInfoAllSteps TIAS_3,TString file_postfix) {

    gStyle->SetOptStat(0);

    TPaveText* labelcms  = new TPaveText(0.20,0.79,0.54,0.92,"NDCBR");
    labelcms->SetTextAlign(12);
    labelcms->SetTextSize(0.04);
    labelcms->SetFillColor(kWhite);
    labelcms->AddText("CMS Preliminary Simulation");
    //labelcms->AddText("CMS Preliminary");
    //labelcms->AddText("Simulation");
    labelcms->AddText("#sqrt{s} = 8 TeV, t#bar{t}+PU");
    labelcms->SetBorderSize(0);
    labelcms->SetTextFont(42);
    labelcms->SetLineWidth(2);

    TH1F *htime_iter_1 = new TH1F("time_iter_1"+file_postfix,"time_iter_1",8,0,8);
    timingTestPerIter(TIAS_1,htime_iter_1);
    htime_iter_1->SetLineStyle(TIAS_1.style());
    htime_iter_1->SetLineColor(TIAS_1.color());
    TH1F *htime_iter_2 = new TH1F("time_iter_2"+file_postfix,"time_iter_2",8,0,8);
    timingTestPerIter(TIAS_2,htime_iter_2);
    htime_iter_2->SetLineStyle(TIAS_2.style());
    htime_iter_2->SetLineColor(TIAS_2.color());
    TH1F *htime_iter_3 = new TH1F("time_iter_3"+file_postfix,"time_iter_3",8,0,8);
    timingTestPerIter(TIAS_3,htime_iter_3);
    htime_iter_3->SetLineStyle(TIAS_3.style());
    htime_iter_3->SetLineColor(TIAS_3.color());
    float iter_Iter0PU20 = htime_iter_1->GetBinContent(1);
    htime_iter_1->Scale(1./iter_Iter0PU20);
    htime_iter_2->Scale(1./iter_Iter0PU20);
    htime_iter_3->Scale(1./iter_Iter0PU20);
    htime_iter_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_iter_1->GetBinContent(htime_iter_1->GetMaximumBin()),TMath::Max(htime_iter_2->GetBinContent(htime_iter_2->GetMaximumBin()),htime_iter_3->GetBinContent(htime_iter_3->GetMaximumBin()))));
    TLegend* leg = new TLegend(0.2,0.59,0.45,0.79);
    leg->SetNColumns(1);
    leg->SetFillColor(kWhite);
    leg->SetLineColor(kWhite);
    leg->SetBorderSize(0);
    leg->SetTextSize(0.04);
    leg->SetTextFont(42);
    leg->AddEntry(htime_iter_1,TIAS_1.legend(),"L");
    leg->AddEntry(htime_iter_2,TIAS_2.legend(),"L");
    leg->AddEntry(htime_iter_3,TIAS_3.legend(),"L");
    htime_iter_1->GetYaxis()->SetTitleOffset(1.2);
    htime_iter_1->GetXaxis()->SetRangeUser(0,7);
    htime_iter_1->GetYaxis()->SetTitle("time [1/iter0@<PU>=20]");
    htime_iter_1->GetYaxis()->SetTitleSize(0.04);
    htime_iter_1->GetXaxis()->SetTitleSize(0.04);
    htime_iter_1->GetYaxis()->SetLabelSize(0.04);
    TCanvas c0;
    c0.SetTicks(1,1);
    htime_iter_1->Draw("H");
    htime_iter_2->Draw("H,same");
    htime_iter_3->Draw("H,same");
    leg->Draw();
    labelcms->Draw();
    c0.SetGridy();
    c0.SaveAs("timingNew_iter_"+file_postfix+".png");

    TH1F *htime_step_1 = new TH1F("time_step_1"+file_postfix,"time_step_1",5,0,5);
    timingTestPerStep(TIAS_1,htime_step_1);
    htime_step_1->SetLineStyle(TIAS_1.style());
    htime_step_1->SetLineColor(TIAS_1.color());
    htime_step_1->GetYaxis()->SetTitle("time [1/building@<PU>=20]");
    TH1F *htime_step_2 = new TH1F("time_step_2"+file_postfix,"time_step_2",5,0,5);
    timingTestPerStep(TIAS_2,htime_step_2);
    htime_step_2->SetLineStyle(TIAS_2.style());
    htime_step_2->SetLineColor(TIAS_2.color());
    TH1F *htime_step_3 = new TH1F("time_step_3"+file_postfix,"time_step_3",5,0,5);
    timingTestPerStep(TIAS_3,htime_step_3);
    htime_step_3->SetLineStyle(TIAS_3.style());
    htime_step_3->SetLineColor(TIAS_3.color());
    float step_BuildPU20 = htime_step_1->GetBinContent(3);
    htime_step_1->Scale(1./step_BuildPU20);
    htime_step_2->Scale(1./step_BuildPU20);
    htime_step_3->Scale(1./step_BuildPU20);
    htime_step_1->GetYaxis()->SetTitleOffset(1.2);
    htime_step_1->GetXaxis()->SetRangeUser(0,7);
    htime_step_1->GetYaxis()->SetTitleSize(0.04);
    htime_step_1->GetXaxis()->SetTitleSize(0.04);
    htime_step_1->GetYaxis()->SetLabelSize(0.04);
    TCanvas c1;
    c1.SetTicks(1,1);
    //htime_step_1->Scale(1./htime_step_1->Integral());
    //htime_step_2->Scale(1./htime_step_2->Integral());
    //htime_step_3->Scale(1./htime_step_3->Integral());
    htime_step_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_step_1->GetBinContent(htime_step_1->GetMaximumBin()),TMath::Max(htime_step_2->GetBinContent(htime_step_2->GetMaximumBin()),htime_step_3->GetBinContent(htime_step_3->GetMaximumBin()))));
    htime_step_1->GetXaxis()->SetRangeUser(1,5);
    htime_step_1->Draw("H");
    htime_step_2->Draw("H,same");
    htime_step_3->Draw("H,same");
    leg->SetX1NDC(0.60);
    leg->SetX2NDC(0.85);
    labelcms->SetX1NDC(0.60);
    labelcms->SetX2NDC(0.94);
    leg->Draw();
    labelcms->Draw();
    c1.SetGridy();
    c1.SaveAs("timingNew_step_"+file_postfix+".png");

    TH1F *htime_track_1 = (TH1F*) htime_iter_1->Clone("time_track_1"+file_postfix);
    htime_track_1->Reset();
    makeTimePerTrackPlot(htime_track_1,htime_iter_1,TIAS_1.mtvfile());
    TH1F *htime_track_2 = (TH1F*) htime_iter_2->Clone("time_track_2"+file_postfix);
    htime_track_2->Reset();
    makeTimePerTrackPlot(htime_track_2,htime_iter_2,TIAS_2.mtvfile());
    TH1F *htime_track_3 = (TH1F*) htime_iter_3->Clone("time_track_3"+file_postfix);
    htime_track_3->Reset();
    makeTimePerTrackPlot(htime_track_3,htime_iter_3,TIAS_3.mtvfile());
    float track_Iter0PU20 = htime_track_1->GetBinContent(1);
    htime_track_1->Scale(1./track_Iter0PU20);
    htime_track_2->Scale(1./track_Iter0PU20);
    htime_track_3->Scale(1./track_Iter0PU20);
    htime_track_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_track_1->GetBinContent(htime_track_1->GetMaximumBin()),TMath::Max(htime_track_2->GetBinContent(htime_track_2->GetMaximumBin()),htime_track_3->GetBinContent(htime_track_3->GetMaximumBin()))));
    TCanvas c2;
    c2.SetTicks(1,1);
    htime_track_1->GetYaxis()->SetTitleOffset(1.2);
    htime_track_1->GetXaxis()->SetRangeUser(0,7);
    htime_track_1->GetYaxis()->SetTitle("time/track [1/iter0@<PU>=20]");
    htime_track_1->GetYaxis()->SetTitleSize(0.04);
    htime_track_1->GetXaxis()->SetTitleSize(0.04);
    htime_track_1->GetYaxis()->SetLabelSize(0.04);
    htime_track_1->Draw("H");
    htime_track_2->Draw("H,same");
    htime_track_3->Draw("H,same");
    leg->SetX1NDC(0.2);
    leg->SetX2NDC(0.45);
    labelcms->SetX1NDC(0.2);
    labelcms->SetX2NDC(0.54);
    leg->Draw();
    labelcms->Draw();
    c2.SetGridy();
    c2.SaveAs("timingNew_track_"+file_postfix+".png");

}
void
HTT_MM_X(bool scaled=true, bool log=true, float min=0.1, float max=-1., string inputfile="root/$HISTFILE", const char* directory="mumu_$CATEGORY")
{
    // define common canvas, axes pad styles
    SetStyle();
    gStyle->SetLineStyleString(11,"20 10");

    // determine category tag
    const char* category = "";
    const char* category_extra = "";
    const char* category_extra2 = "";
    if(std::string(directory) == std::string("mumu_0jet_low"             )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_0jet_low"             )) {
        category_extra = "0-jet low p_{T}^{#mu}";
    }
    if(std::string(directory) == std::string("mumu_0jet_high"            )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_0jet_high"            )) {
        category_extra = "0-jet high p_{T}^{#mu}";
    }
    if(std::string(directory) == std::string("mumu_1jet_low"          )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_1jet_low"          )) {
        category_extra = "1-jet low p_{T}^{#mu}";
    }
    if(std::string(directory) == std::string("mumu_1jet_high"          )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_1jet_high"          )) {
        category_extra = "1-jet high p_{T}^{#mu}";
    }
    if(std::string(directory) == std::string("mumu_vbf"            )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_vbf"            )) {
        category_extra = "2-jet";
    }
    if(std::string(directory) == std::string("mumu_nobtag"               )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_nobtag"               )) {
        category_extra = "no b-tag";
    }
    if(std::string(directory) == std::string("mumu_btag"                 )) {
        category = "#mu#mu";
    }
    if(std::string(directory) == std::string("mumu_btag"                 )) {
        category_extra = "b-tag";
    }

    const char* dataset;
#ifdef MSSM
    if(std::string(inputfile).find("7TeV")!=std::string::npos) {
        dataset = "#scale[1.5]{CMS}  h,H,A#rightarrow#tau#tau                                 4.9 fb^{-1} (7 TeV)";
    }
    if(std::string(inputfile).find("8TeV")!=std::string::npos) {
        dataset = "#scale[1.5]{CMS}  h,H,A#rightarrow#tau#tau                                19.7 fb^{-1} (8 TeV)";
    }
#else
    if(std::string(inputfile).find("7TeV")!=std::string::npos) {
        dataset = "CMS, 4.9 fb^{-1} at 7 TeV";
    }
    if(std::string(inputfile).find("8TeV")!=std::string::npos) {
        dataset = "CMS, 19.7 fb^{-1} at 8 TeV";
    }
#endif

    TFile* input = new TFile(inputfile.c_str());
#ifdef MSSM
    TFile* input2 = new TFile((inputfile+"_$MA_$TANB").c_str());
#endif
    TH1F* ZTT      = refill((TH1F*)input ->Get(TString::Format("%s/ZTT"     , directory)), "ZTT"     );
    InitHist(ZTT     , "", "", TColor::GetColor(248,206,104), 1001);
    TH1F* ZMM      = refill((TH1F*)input ->Get(TString::Format("%s/ZMM"     , directory)), "ZMM"     );
    InitHist(ZMM     , "", "", TColor::GetColor(100,182,232), 1001);
    TH1F* TTJ      = refill((TH1F*)input ->Get(TString::Format("%s/TTJ"     , directory)), "TTJ"     );
    InitHist(TTJ     , "", "", TColor::GetColor(155,152,204), 1001);
    TH1F* QCD      = refill((TH1F*)input ->Get(TString::Format("%s/QCD"     , directory)), "QCD"     );
    InitHist(QCD     , "", "", TColor::GetColor(250,202,255), 1001);
    TH1F* Dibosons = refill((TH1F*)input ->Get(TString::Format("%s/Dibosons", directory)), "Dibosons");
    InitHist(Dibosons, "", "", TColor::GetColor(222,90,106), 1001);
    TH1F* WJets    = 0;
    if(!(std::string("mumu_nobtag") == std::string(directory))) {
        // template has been removed from nobtag categories
        WJets = refill((TH1F*)input ->Get(TString::Format("%s/WJets"   , directory)), "WJets"   );
        InitHist(WJets   , "", "", kGreen -4 , 1001);
    }
#ifdef MSSM
    TH1F* ggH      = refill((TH1F*)input2->Get(TString::Format("%s/ggH$MA"  , directory)), "ggH"     );
    InitSignal(ggH);
    ggH->Scale($TANB);
    TH1F* bbH      = refill((TH1F*)input2->Get(TString::Format("%s/bbH$MA"  , directory)), "bbH"     );
    InitSignal(bbH);
    bbH->Scale($TANB);
    // TH1F* ggH_SM125= refill((TH1F*)input->Get(TString::Format("%s/ggH_SM125"  , directory)), "ggH_SM125"); InitHist(ggH_SM125, "", "", kGreen+2, 1001);
//   TH1F* qqH_SM125= refill((TH1F*)input->Get(TString::Format("%s/qqH_SM125"  , directory)), "qqH_SM125"); InitHist(qqH_SM125, "", "", kGreen+2, 1001);
//   TH1F* VH_SM125 = refill((TH1F*)input->Get(TString::Format("%s/VH_SM125"   , directory)), "VH_SM125" ); InitHist(VH_SM125, "", "", kGreen+2, 1001);
    TH1F* ggH_SM125= refill((TH1F*)input->Get(TString::Format("%s/ggH125"  , directory)), "ggH_SM125");
    InitHist(ggH_SM125, "", "", kGreen+2, 1001);
    if(std::string(inputfile).find("7TeV")!=std::string::npos) ggH_SM125->Scale((15.13+1.222+0.3351+0.08632)*0.0632);
    if(std::string(inputfile).find("8TeV")!=std::string::npos) ggH_SM125->Scale((19.27+1.578+0.7046+0.4153)*0.0632);
#else
#ifndef DROP_SIGNAL
    TH1F* ggH      = refill((TH1F*)input ->Get(TString::Format("%s/ggH125"  , directory)), "ggH"     );
    InitSignal(ggH);
    ggH->Scale(SIGNAL_SCALE);
    TH1F* qqH      = refill((TH1F*)input ->Get(TString::Format("%s/qqH125"  , directory)), "qqH"     );
    InitSignal(qqH);
    qqH->Scale(SIGNAL_SCALE);
    TH1F* VH       = refill((TH1F*)input ->Get(TString::Format("%s/VH125"   , directory)), "VH"      );
    InitSignal(VH );
    VH ->Scale(SIGNAL_SCALE);
#endif
#endif
#ifdef ASIMOV
    TH1F* data   = refill((TH1F*)input->Get(TString::Format("%s/data_obs_asimov", directory)), "data", true);
#else
    TH1F* data   = refill((TH1F*)input->Get(TString::Format("%s/data_obs", directory)), "data", true);
#endif
#ifdef MSSM
    InitHist(data, "#bf{m_{#tau#tau} [GeV]}" , "#bf{dN/dm_{#tau#tau} [1/GeV]}");
    InitData(data);
#else
    InitHist(data, "#bf{D}", "#bf{dN/dD}"     );
    InitData(data);
#endif

    TH1F* ref=(TH1F*)ZTT->Clone("ref");
    ref->Add(ZMM);
    ref->Add(TTJ);
    ref->Add(QCD);
    ref->Add(Dibosons);
    if(WJets) {
        ref->Add(WJets);
    }
    double unscaled[9];
    unscaled[0] = ZTT->Integral();
    unscaled[1] = ZMM->Integral();
    unscaled[2] = TTJ->Integral();
    unscaled[3] = QCD->Integral();
    unscaled[4] = Dibosons->Integral();
    unscaled[5] = 0;
    if(WJets) {
        unscaled[5] = WJets->Integral();
    }
#ifdef MSSM
    unscaled[6] = ggH->Integral();
    unscaled[7] = bbH->Integral();
    unscaled[8] = 0;
#else
#ifndef DROP_SIGNAL
    unscaled[6] = ggH->Integral();
    unscaled[7] = qqH->Integral();
    unscaled[8] = VH ->Integral();
#endif
#endif

    if(scaled) {
        rescale(ZTT,  1);
        rescale(ZMM,  2);
        rescale(TTJ,  3);
        rescale(QCD,  4);
        rescale(Dibosons, 5);
        if(WJets) {
            rescale(WJets,  6);
        }
#ifdef MSSM
        rescale(ggH,  7);
        rescale(bbH,  8);
#else
#ifndef DROP_SIGNAL
        rescale(ggH,  7);
        rescale(qqH,  8);
        rescale(VH,   9);
#endif
#endif
    }

    TH1F* scales[9];
    scales[0] = new TH1F("scales-ZTT", "", 9, 0, 9);
    scales[0]->SetBinContent(1, unscaled[0]>0 ? (ZTT->Integral()/unscaled[0]-1.)      : 0.);
    scales[1] = new TH1F("scales-ZMM"  , "", 9, 0, 9);
    scales[1]->SetBinContent(2, unscaled[1]>0 ? (ZMM->Integral()/unscaled[1]-1.)      : 0.);
    scales[2] = new TH1F("scales-TTJ", "", 9, 0, 9);
    scales[2]->SetBinContent(3, unscaled[2]>0 ? (TTJ->Integral()/unscaled[2]-1.)      : 0.);
    scales[3] = new TH1F("scales-QCD"  , "", 9, 0, 9);
    scales[3]->SetBinContent(4, unscaled[3]>0 ? (QCD->Integral()/unscaled[3]-1.)      : 0.);
    scales[4] = new TH1F("scales-Dibosons", "", 9, 0, 9);
    scales[4]->SetBinContent(5, unscaled[4]>0 ? (Dibosons->Integral()/unscaled[4]-1.) : 0.);
    scales[5] = new TH1F("scales-WJets"  , "", 9, 0, 9);
    scales[5]->SetBinContent(6, 0.);
    if(WJets) {
        scales[5]->SetBinContent(6, unscaled[5]>0 ? (WJets->Integral()/unscaled[5]-1.)  : 0.);
    }
#ifdef MSSM
    scales[6] = new TH1F("scales-ggH"  , "", 9, 0, 9);
    scales[6]->SetBinContent(7, unscaled[6]>0 ? (ggH->Integral()/unscaled[6]-1.)      : 0.);
    scales[7] = new TH1F("scales-bbH"  , "", 9, 0, 9);
    scales[7]->SetBinContent(8, unscaled[7]>0 ? (bbH->Integral()/unscaled[7]-1.)      : 0.);
    scales[8] = new TH1F("scales-NONE" , "", 9, 0, 9);
    scales[8]->SetBinContent(9, 0.);
#else
#ifndef DROP_SIGNAL
    scales[6] = new TH1F("scales-ggH"  , "", 9, 0, 9);
    scales[6]->SetBinContent(7, unscaled[6]>0 ? (ggH->Integral()/unscaled[6]-1.)      : 0.);
    scales[7] = new TH1F("scales-qqH"  , "", 9, 0, 9);
    scales[7]->SetBinContent(8, unscaled[7]>0 ? (qqH->Integral()/unscaled[7]-1.)      : 0.);
    scales[8] = new TH1F("scales-VH"   , "", 9, 0, 9);
    scales[8]->SetBinContent(9, unscaled[8]>0 ? (VH ->Integral()/unscaled[8]-1.)      : 0.);
#endif
#endif

#ifdef MSSM
    // qqH_SM125->Add(ggH_SM125);
//   VH_SM125->Add(qqH_SM125);
//   Dibosons->Add(VH_SM125);
    Dibosons->Add(ggH_SM125);
#endif
    if(WJets) {
        Dibosons->Add(WJets);
    }
    QCD->Add(Dibosons);
    TTJ->Add(QCD);
    ZTT->Add(TTJ);
    ZMM->Add(ZTT);
    if(log) {
#ifdef MSSM
        ggH  ->Add(bbH);
#else
#ifndef DROP_SIGNAL
        qqH  ->Add(VH );
        ggH  ->Add(qqH);
#endif
#endif
    }
    else {
#ifdef MSSM
        bbH  ->Add(ZMM);
        ggH  ->Add(bbH);
#else
#ifndef DROP_SIGNAL
        VH   ->Add(ZMM);
        qqH  ->Add(VH );
        ggH  ->Add(qqH);
#endif
#endif
    }


    /*
      mass plot before and after fit
    */
    TCanvas* canv = MakeCanvas("canv", "histograms", 600, 600);
    canv->cd();
    if(log) {
        canv->SetLogy(1);
    }
#if defined MSSM
    if(!log) {
        data->GetXaxis()->SetRange(0, data->FindBin(345));
    }
    else {
        data->GetXaxis()->SetRange(0, data->FindBin(UPPER_EDGE));
    };
#else
    data->GetXaxis()->SetRange(0, data->FindBin(345));
#endif
    data->SetNdivisions(505);
    data->SetMinimum(min);
#ifndef DROP_SIGNAL
    data->SetMaximum(max>0 ? max : std::max(std::max(maximum(data, log), maximum(ZMM, log)), maximum(ggH, log)));
#else
    data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(ZMM, log)));
#endif
    data->Draw("e");

    TH1F* errorBand = (TH1F*)ZMM->Clone("errorBand");
    errorBand->SetMarkerSize(0);
    errorBand->SetFillColor(13);
    errorBand->SetFillStyle(3013);
    errorBand->SetLineWidth(1);
    for(int idx=0; idx<errorBand->GetNbinsX(); ++idx) {
        if(errorBand->GetBinContent(idx)>0) {
            std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl;
            break;
        }
    }
    if(log) {
        ZMM->Draw("histsame");
        ZTT->Draw("histsame");
        TTJ->Draw("histsame");
        QCD->Draw("histsame");
        Dibosons->Draw("histsame");
#ifdef MSSM
        //VH_SM125->Draw("histsame");
        ggH_SM125->Draw("histsame");
#endif
        $DRAW_ERROR
#ifndef DROP_SIGNAL
        ggH->Draw("histsame");
#endif

    }
    else {
#ifndef DROP_SIGNAL
        ggH  ->Draw("histsame");
#endif
        ZMM->Draw("histsame");
        ZTT->Draw("histsame");
        TTJ->Draw("histsame");
        QCD->Draw("histsame");
        Dibosons->Draw("histsame");
#ifdef MSSM
        //VH_SM125->Draw("histsame");
        ggH_SM125->Draw("histsame");
#endif
        $DRAW_ERROR
    }
    data->Draw("esame");
    canv->RedrawAxis();

    //CMSPrelim(dataset, "#tau_{#mu}#tau_{#mu}", 0.17, 0.835);
    CMSPrelim(dataset, "", 0.16, 0.835);
#if defined MSSM
    TPaveText* chan     = new TPaveText(0.20, 0.74+0.061, 0.32, 0.74+0.161, "tlbrNDC");
#else
    TPaveText* chan     = new TPaveText(0.22, (category_extra2 && category_extra2[0]=='\0') ? 0.65+0.061 : 0.65+0.061, 0.34, 0.75+0.161, "tlbrNDC");
#endif
    chan->SetBorderSize(   0 );
    chan->SetFillStyle(    0 );
    chan->SetTextAlign(   12 );
    chan->SetTextSize ( 0.05 );
    chan->SetTextColor(    1 );
    chan->SetTextFont (   62 );
    chan->AddText(category);
    chan->AddText(category_extra);
#if defined MSSM
#else
    chan->AddText(category_extra2);
#endif
    chan->Draw();

    /*  TPaveText* cat      = new TPaveText(0.20, 0.71+0.061, 0.32, 0.71+0.161, "NDC");
      cat->SetBorderSize(   0 );
      cat->SetFillStyle(    0 );
      cat->SetTextAlign(   12 );
      cat->SetTextSize ( 0.05 );
      cat->SetTextColor(    1 );
      cat->SetTextFont (   62 );
      cat->AddText(category_extra);
      cat->Draw();
    */
#ifdef MSSM
    TPaveText* massA      = new TPaveText(0.53, 0.44+0.061, 0.95, 0.44+0.151, "NDC");
    massA->SetBorderSize(   0 );
    massA->SetFillStyle(    0 );
    massA->SetTextAlign(   12 );
    massA->SetTextSize ( 0.03 );
    massA->SetTextColor(    1 );
    massA->SetTextFont (   62 );
    massA->AddText("MSSM m^{h}_{mod+} scenario");
    massA->AddText("m_{A}=$MA GeV, tan#beta=$TANB");
    massA->Draw();
#endif

#ifdef MSSM
    TLegend* leg = new TLegend(0.53, 0.60, 0.95, 0.90);
    SetLegendStyle(leg);
    leg->AddEntry(ggH  , "h,H,A#rightarrow#tau#tau" , "L" );
#else
    TLegend* leg = new TLegend(0.52, 0.58, 0.92, 0.89);
    SetLegendStyle(leg);
#ifndef DROP_SIGNAL
    if(SIGNAL_SCALE!=1) {
        leg->AddEntry(ggH  , TString::Format("%.0f#timesH(125 GeV)#rightarrow#tau#tau", SIGNAL_SCALE) , "L" );
    }
    else {
        leg->AddEntry(ggH  , "SM H(125 GeV)#rightarrow#tau#tau" , "L" );
    }
#endif
#endif
#ifdef ASIMOV
    leg->AddEntry(data    , "sum(bkg) + H(125)"           , "LP");
#else
    leg->AddEntry(data    , "Observed"                    , "LP");
#endif
    leg->AddEntry(ZMM     , "Z#rightarrow#mu#mu"          , "F" );
    leg->AddEntry(ZTT     , "Z#rightarrow#tau#tau"        , "F" );
    leg->AddEntry(TTJ     , "t#bar{t}"                    , "F" );
    leg->AddEntry(QCD     , "QCD"                         , "F" );
    leg->AddEntry(Dibosons, "Electroweak"                 , "F" );
#ifdef MSSM
    leg->AddEntry(ggH_SM125, "SM H(125 GeV) #rightarrow #tau#tau", "F" );
#endif
    $ERROR_LEGEND
    leg->Draw();

    /*
      Ratio Data over MC
    */
    TCanvas *canv0 = MakeCanvas("canv0", "histograms", 600, 400);
    canv0->SetGridx();
    canv0->SetGridy();
    canv0->cd();

    TH1F* model = (TH1F*)ZMM ->Clone("model");
    TH1F* test1 = (TH1F*)data->Clone("test1");
    for(int ibin=0; ibin<test1->GetNbinsX(); ++ibin) {
        //the small value in case of 0 entries in the model is added to prevent the chis2 test from failing
        model->SetBinContent(ibin+1, model->GetBinContent(ibin+1)>0 ? model->GetBinContent(ibin+1)*model->GetBinWidth(ibin+1) : 0.01);
        model->SetBinError  (ibin+1, CONVERVATIVE_CHI2 ? 0. : model->GetBinError  (ibin+1)*model->GetBinWidth(ibin+1));
        test1->SetBinContent(ibin+1, test1->GetBinContent(ibin+1)*test1->GetBinWidth(ibin+1));
        test1->SetBinError  (ibin+1, test1->GetBinError  (ibin+1)*test1->GetBinWidth(ibin+1));
    }
    double chi2prob = test1->Chi2Test      (model,"PUW");
    std::cout << "chi2prob:" << chi2prob << std::endl;
    double chi2ndof = test1->Chi2Test      (model,"CHI2/NDFUW");
    std::cout << "chi2ndf :" << chi2ndof << std::endl;
    double ksprob   = test1->KolmogorovTest(model);
    std::cout << "ksprob  :" << ksprob   << std::endl;
    double ksprobpe = test1->KolmogorovTest(model,"DX");
    std::cout << "ksprobpe:" << ksprobpe << std::endl;

    std::vector<double> edges;
    TH1F* zero = (TH1F*)ref ->Clone("zero");
    zero->Clear();
    TH1F* rat1 = (TH1F*)data->Clone("rat1");
    rat1->Reset("ICES");
    for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin) {
        if(data->GetBinContent(ibin+1) > 0) {
            rat1->SetBinContent(ibin+1, ZMM->GetBinContent(ibin+1)>0 ? data->GetBinContent(ibin+1)/ZMM->GetBinContent(ibin+1) : 0);
            rat1->SetBinError  (ibin+1, ZMM->GetBinContent(ibin+1)>0 ? data->GetBinError  (ibin+1)/ZMM->GetBinContent(ibin+1) : 0);
        }
        zero->SetBinContent(ibin+1, 0.);
        zero->SetBinError  (ibin+1, ZMM->GetBinContent(ibin+1)>0 ? ZMM ->GetBinError  (ibin+1)/ZMM->GetBinContent(ibin+1) : 0);
    }
    for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin) {
        if(rat1->GetBinContent(ibin+1)>0) {
            edges.push_back(TMath::Abs(rat1->GetBinContent(ibin+1)-1.)+TMath::Abs(rat1->GetBinError(ibin+1)));
            // catch cases of 0 bins, which would lead to 0-alpha*0-1
            rat1->SetBinContent(ibin+1, rat1->GetBinContent(ibin+1)-1.);
        }
    }
    float range = 0.1;
    std::sort(edges.begin(), edges.end());
    if (edges[edges.size()-2]>0.1) {
        range = 0.2;
    }
    if (edges[edges.size()-2]>0.2) {
        range = 0.5;
    }
    if (edges[edges.size()-2]>0.5) {
        range = 1.0;
    }
    if (edges[edges.size()-2]>1.0) {
        range = 1.5;
    }
    if (edges[edges.size()-2]>1.5) {
        range = 2.0;
    }
    rat1->SetLineColor(kBlack);
    rat1->SetFillColor(kGray );
    rat1->SetMaximum(+range);
    rat1->SetMinimum(-range);
    rat1->GetYaxis()->CenterTitle();
    rat1->GetYaxis()->SetTitle("#bf{Data/MC-1}");
#ifdef MSSM
    rat1->GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]}");
#else
    rat1->GetXaxis()->SetTitle("#bf{D}");
#endif
    rat1->Draw("E0");
    zero->SetFillStyle(  3013);
    zero->SetFillColor(kBlack);
    zero->SetLineColor(kBlack);
    zero->SetMarkerSize(0.1);
    zero->Draw("e2histsame");
    canv0->RedrawAxis();

    TPaveText* stat1 = new TPaveText(0.20, 0.76+0.061, 0.32, 0.76+0.161, "NDC");
    stat1->SetBorderSize(   0 );
    stat1->SetFillStyle(    0 );
    stat1->SetTextAlign(   12 );
    stat1->SetTextSize ( 0.05 );
    stat1->SetTextColor(    1 );
    stat1->SetTextFont (   62 );
    stat1->AddText(TString::Format("#chi^{2}/ndf=%.3f,  P(#chi^{2})=%.3f", chi2ndof, chi2prob));
    //stat1->AddText(TString::Format("#chi^{2}/ndf=%.3f,  P(#chi^{2})=%.3f, P(KS)=%.3f", chi2ndof, chi2prob, ksprob));
    stat1->Draw();

    /*
      Ratio After fit over Prefit
    */
    TCanvas *canv1 = MakeCanvas("canv1", "histograms", 600, 400);
    canv1->SetGridx();
    canv1->SetGridy();
    canv1->cd();

    edges.clear();
    TH1F* rat2 = (TH1F*) ZMM->Clone("rat2");
    for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin) {
        rat2->SetBinContent(ibin+1, ref->GetBinContent(ibin+1)>0 ? ZMM->GetBinContent(ibin+1)/ref->GetBinContent(ibin+1) : 0);
        rat2->SetBinError  (ibin+1, ref->GetBinContent(ibin+1)>0 ? ZMM->GetBinError  (ibin+1)/ref->GetBinContent(ibin+1) : 0);
    }
    for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin) {
        if(rat2->GetBinContent(ibin+1)>0) {
            edges.push_back(TMath::Abs(rat2->GetBinContent(ibin+1)-1.)+TMath::Abs(rat2->GetBinError(ibin+1)));
            // catch cases of 0 bins, which would lead to 0-alpha*0-1
            rat2 ->SetBinContent(ibin+1, rat2->GetBinContent(ibin+1)-1.);
        }
    }
    range = 0.1;
    std::sort(edges.begin(), edges.end());
    if (edges[edges.size()-2]>0.1) {
        range = 0.2;
    }
    if (edges[edges.size()-2]>0.2) {
        range = 0.5;
    }
    if (edges[edges.size()-2]>0.5) {
        range = 1.0;
    }
    if (edges[edges.size()-2]>1.0) {
        range = 1.5;
    }
    if (edges[edges.size()-2]>1.5) {
        range = 2.0;
    }
#if defined MSSM
    if(!log) {
        rat2->GetXaxis()->SetRange(0, rat2->FindBin(345));
    }
    else {
        rat2->GetXaxis()->SetRange(0, rat2->FindBin(UPPER_EDGE));
    };
#else
    rat2->GetXaxis()->SetRange(0, rat2->FindBin(345));
#endif
    rat2->SetNdivisions(505);
    rat2->SetLineColor(kRed+3);
    rat2->SetMarkerColor(kRed+3);
    rat2->SetMarkerSize(1.1);
    rat2->SetMaximum(+range);
    rat2->SetMinimum(-range);
    rat2->GetYaxis()->SetTitle("#bf{Postfit/Prefit-1}");
    rat2->GetYaxis()->CenterTitle();
#if defined MSSM
    rat2->GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]}");
#else
    rat2->GetXaxis()->SetTitle("#bf{D}");
#endif
    rat2->Draw();
    zero->SetFillStyle(  3013);
    zero->SetFillColor(kBlack);
    zero->SetLineColor(kBlack);
    zero->Draw("e2histsame");
    canv1->RedrawAxis();

    /*
      Relative shift per sample
    */
    TCanvas *canv2 = MakeCanvas("canv2", "histograms", 600, 400);
    canv2->SetGridx();
    canv2->SetGridy();
    canv2->cd();

    InitHist  (scales[0], "", "", TColor::GetColor(248,206,104), 1001);
    InitHist  (scales[1], "", "", TColor::GetColor(100,182,232), 1001);
    InitHist  (scales[2], "", "", TColor::GetColor(155,152,204), 1001);
    InitHist  (scales[3], "", "", TColor::GetColor(250,202,255), 1001);
    InitHist  (scales[4], "", "", TColor::GetColor(222,90,106), 1001);
    InitHist  (scales[5], "", "", kGreen   -  4, 1001);
#ifndef DROP_SIGNAL
    InitSignal(scales[6]);
    InitSignal(scales[7]);
    InitSignal(scales[8]);
#endif
    scales[0]->GetXaxis()->SetBinLabel(1, "#bf{ZTT}");
    scales[0]->GetXaxis()->SetBinLabel(2, "#bf{ZMM}"  );
    scales[0]->GetXaxis()->SetBinLabel(3, "#bf{TTJ}");
    scales[0]->GetXaxis()->SetBinLabel(4, "#bf{QCD}"  );
    scales[0]->GetXaxis()->SetBinLabel(5, "#bf{Dibosons}");
    scales[0]->GetXaxis()->SetBinLabel(6, "#bf{WJets}"  );
#ifdef MSSM
    scales[0]->GetXaxis()->SetBinLabel(7, "#bf{ggH}"  );
    scales[0]->GetXaxis()->SetBinLabel(8, "#bf{bbH}"  );
    scales[0]->GetXaxis()->SetBinLabel(9, "#bf{NONE}" );
#else
    scales[0]->GetXaxis()->SetBinLabel(7, "#bf{ggH}"  );
    scales[0]->GetXaxis()->SetBinLabel(8, "#bf{qqH}"  );
    scales[0]->GetXaxis()->SetBinLabel(9, "#bf{VH}"   );
#endif
    scales[0]->SetMaximum(+0.5);
    scales[0]->SetMinimum(-0.5);
    scales[0]->GetYaxis()->CenterTitle();
    scales[0]->GetYaxis()->SetTitle("#bf{Postfit/Prefit-1}");
    scales[0]->Draw();
    scales[1]->Draw("same");
    scales[2]->Draw("same");
    scales[3]->Draw("same");
    scales[4]->Draw("same");
    scales[5]->Draw("same");
#ifndef DROP_SIGNAL
    scales[6]->Draw("same");
    scales[7]->Draw("same");
    scales[8]->Draw("same");
#endif
    TH1F* zero_samples = (TH1F*)scales[0]->Clone("zero_samples");
    zero_samples->Clear();
    zero_samples->SetBinContent(1,0.);
    zero_samples->Draw("same");
    canv2->RedrawAxis();

    /*
      prepare output
    */
    bool isSevenTeV = std::string(inputfile).find("7TeV")!=std::string::npos;
    canv   ->Print(TString::Format("%s_%sfit_%s_%s.png"       , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
    canv   ->Print(TString::Format("%s_%sfit_%s_%s.pdf"       , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
    canv   ->Print(TString::Format("%s_%sfit_%s_%s.eps"       , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
    if(log || FULLPLOTS)
    {
        canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
    }
    if((log && scaled) || FULLPLOTS)
    {
        canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
        canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"));
    }

    TFile* output = new TFile(TString::Format("%s_%sfit_%s_%s.root", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"), "update");
    output->cd();
    data ->Write("data_obs");
    ZTT->Write("Ztt"  );
    ZMM->Write("Zmm"  );
    TTJ->Write("ttbar");
    QCD->Write("Fakes");
    Dibosons->Write("EWK");
    if(WJets) {
        WJets->Write("WJets");
    }
#ifdef MSSM
    ggH  ->Write("ggH");
    bbH  ->Write("bbH");
    ggH_SM125->Write("ggH_SM125");
    //qqH_SM125->Write("qqH_SM125");
    //VH_SM125 ->Write("VH_SM125");
#else
#ifndef DROP_SIGNAL
    ggH  ->Write("ggH");
    qqH  ->Write("qqH");
    VH   ->Write("VH" );
#endif
#endif
    if(errorBand) {
        errorBand->Write("errorBand");
    }
    output->Close();

    delete errorBand;
    delete model;
    delete test1;
    delete zero;
    delete rat1;
    delete rat2;
    delete zero_samples;
    delete ref;
}
示例#22
0
void ProcessingTime(const char *inputFile)
{
  TChain *chain = new TChain("Delphes");
  chain->Add(inputFile);

  TH1F hist("time", "time", 50, 0, 0.01);
  Int_t i;

  TDirectory *currentDirectory = gDirectory;

  // Graphics style parameters to avoid grey background on figures
  gStyle->SetCanvasColor(kExRootBackgroundColor);
  gStyle->SetStatColor(kExRootBackgroundColor);
  //  gStyle->SetTitleColor(kExRootBackgroundColor);
  gStyle->SetPadColor(kExRootBackgroundColor);

  gStyle->SetPadTopMargin(0.10);
  gStyle->SetPadRightMargin(0.10);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetPadLeftMargin(0.15);

  gStyle->SetStatFont(kExRootFont);
  gStyle->SetStatFontSize(kExRootFontSize);

  gStyle->SetTitleFont(kExRootFont, "");
  gStyle->SetTitleFont(kExRootFont, "X");
  gStyle->SetTitleFont(kExRootFont, "Y");
  gStyle->SetTitleFont(kExRootFont, "Z");
  gStyle->SetTitleSize(kExRootFontSize, "");
  gStyle->SetTitleSize(kExRootFontSize, "X");
  gStyle->SetTitleSize(kExRootFontSize, "Y");
  gStyle->SetTitleSize(kExRootFontSize, "Z");

  gStyle->SetLabelFont(kExRootFont, "X");
  gStyle->SetLabelFont(kExRootFont, "Y");
  gStyle->SetLabelFont(kExRootFont, "Z");
  gStyle->SetLabelSize(kExRootFontSize, "X");
  gStyle->SetLabelSize(kExRootFontSize, "Y");
  gStyle->SetLabelSize(kExRootFontSize, "Z");

  gStyle->SetPadTickX(1);
  gStyle->SetPadTickY(1);

  gStyle->SetTextFont(kExRootFont);
  gStyle->SetTextSize(kExRootFontSize);

  gStyle->SetOptStat(111110);
  // gStyle->SetOptFit(101);

  canvas = static_cast<TCanvas*>(gROOT->FindObject("c1"));
  if(canvas)
  {
    canvas->Clear();
    canvas->UseCurrentStyle();
    canvas->SetWindowSize(800, 650);
  }
  else
  {
    canvas = new TCanvas("c1", "c1", 800, 650);
  }
  canvas->SetGrid();
  canvas->SetHighLightColor(kExRootBackgroundColor);

  currentDirectory->cd();

  for(i = 0; i < 9; ++i)
  {
    chain->Draw("Event.ProcTime >> time", TString::Format("Jet_size == %d", i+2));
    gr.SetPoint(i, i+2, hist.GetMean()*1000);
    grerr.SetPoint(i, i+2, hist.GetMean()*1000);
    grerr.SetPointError(i, 0, hist.GetRMS()*1000);
  }

  grerr.GetXaxis()->SetLimits(1.0, 11.0);
  grerr.GetXaxis()->SetTitleOffset(1.5);
  grerr.GetYaxis()->SetTitleOffset(1.75);
  grerr.GetXaxis()->SetTitle("jet multiplicity");
  grerr.GetYaxis()->SetTitle("processing time per event, ms");
  gr.SetMarkerStyle(kFullCircle);
  gr.SetMarkerColor(kBlack);
  gr.SetMarkerSize(1);
  gr.SetLineColor(kBlack);
  gr.SetLineWidth(2);
  grerr.SetFillStyle(1001);
  grerr.SetFillColor(17);
  grerr.Draw("A3");
  gr.Draw("P");

  comment.SetTextSize(kExRootFontSize);
  comment.SetTextFont(kExRootFont);
  comment.SetTextAlign(22);
  comment.SetFillColor(kExRootBackgroundColor);
  comment.SetBorderSize(0);
  comment.AddText("ttbar + jets events");
  comment.Draw();
}
示例#23
0
void PlotPotential2D( const TString &sim, Int_t time, Int_t zoom=2, Int_t Nbins=2, const TString &options="") {

#ifdef __CINT__
    gSystem->Load("libplasma.so");
#endif

    PlasmaGlob::Initialize();

    // Palettes!
    gROOT->Macro("PlasmaPalettes.C");

    // Init Units table
    PUnits::UnitsTable::Get();

    // Load PData
    PData *pData = PData::Get(sim.Data());
    pData->LoadFileNames(time);
    if(!pData->IsInit()) return;

    TString opt = options;

    // More makeup
    gStyle->SetPadGridY(0);
    if(opt.Contains("gridx")) {
        gStyle->SetPadGridX(1);
    }
    if(opt.Contains("gridy")) {
        gStyle->SetPadGridY(1);
    }


    // Some plasma constants
    Double_t n0 = pData->GetPlasmaDensity();
    Double_t omegap = pData->GetPlasmaFrequency();
    Double_t timedepth = 1.;
    if(omegap!=0.0) timedepth = 1/omegap;
    Double_t kp = pData->GetPlasmaK();
    Double_t skindepth = 1.;
    if(kp!=0.0) skindepth = 1/kp;
    Double_t E0 = pData->GetPlasmaE0();

    // Some beam properties:
    Double_t Ebeam = pData->GetBeamEnergy();
    Double_t gamma = pData->GetBeamGamma();
    Double_t vbeam = pData->GetBeamVelocity();

    cout << Form(" - Bunch gamma      = %8.4f", gamma ) << endl;
    cout << Form(" - Bunch velocity   = %8.4f c", vbeam ) << endl;

    // Other parameters
    Float_t trapPotential = 1.0 - (1.0/gamma);
    cout << Form(" - Trap. potential  = %8.4f mc2/e",trapPotential) << endl;
    cout << endl;

    // Time in OU
    Float_t Time = pData->GetRealTime();
    // z start of the plasma in normalized units.
    Float_t zStartPlasma = pData->GetPlasmaStart()*kp;
    // z start of the beam in normalized units.
    Float_t zStartBeam = pData->GetBeamStart()*kp;
    // z start of the neutral in normalized units.
    Float_t zStartNeutral = pData->GetNeutralStart()*kp;
    // z end of the neutral in normalized units.
    Float_t zEndNeutral = pData->GetNeutralEnd()*kp;

    if(opt.Contains("center")) {
        Time -= zStartPlasma;
        if(opt.Contains("comov"))      // Centers on the head of the beam.
            Time += zStartBeam;
    }
    Float_t shiftz = pData->Shift(opt);
    //  cout << "Shift = " << shiftz << endl;


    // Calculate the "axis range" in number of bins. If Nbins==0 a RMS width is taken.
    Double_t rms0 = pData->GetBeamRmsY() * kp;
    if(pData->IsCyl())  rms0  = pData->GetBeamRmsR() * kp;

    Int_t FirstyBin = 0;
    Int_t LastyBin = 0;
    if(Nbins==0) {
        if(rms0>0.0)
            Nbins =  TMath::Nint(rms0 / pData->GetDX(1));
        else
            Nbins = 1;
    }

    // Slice width limits.
    if(!pData->IsCyl()) {
        FirstyBin = pData->GetNX(1)/2 + 1 - Nbins;
        LastyBin =  pData->GetNX(1)/2 + Nbins;
    } else {
        FirstyBin = 1;
        LastyBin  = Nbins;
    }
    // ----------------------------------------------------------------------------------


    // Get charge density histos
    Int_t Nspecies = pData->NSpecies();
    TH2F **hDen2D = new TH2F*[Nspecies];
    // Get charge density on-axis
    TH1F **hDen1D = new TH1F*[Nspecies];
    // And electric current (integrated)
    TH1F **hCur1D = new TH1F*[Nspecies];
    for(Int_t i=0; i<Nspecies; i++) {

        hDen2D[i] = NULL;

        if(!pData->GetChargeFileName(i))
            continue;

        cout << Form(" Getting charge density of specie: ") << i << endl;


        char hName[24];
        sprintf(hName,"hDen2D_%i",i);
        hDen2D[i] = (TH2F*) gROOT->FindObject(hName);
        if(hDen2D[i]) delete hDen2D[i];

        if(!pData->Is3D())
            hDen2D[i] = pData->GetCharge(i,opt);
        else
            hDen2D[i] = pData->GetCharge2DSliceZY(i,-1,Nbins,opt+"avg");

        hDen2D[i]->SetName(hName);
        hDen2D[i]->GetXaxis()->CenterTitle();
        hDen2D[i]->GetYaxis()->CenterTitle();
        hDen2D[i]->GetZaxis()->CenterTitle();

        if(opt.Contains("comov"))
            hDen2D[i]->GetXaxis()->SetTitle("k_{p} #zeta");
        else
            hDen2D[i]->GetXaxis()->SetTitle("k_{p} z");

        if(pData->IsCyl())
            hDen2D[i]->GetYaxis()->SetTitle("k_{p} r");
        else
            hDen2D[i]->GetYaxis()->SetTitle("k_{p} y");

        hDen2D[i]->GetZaxis()->SetTitle("n [n_{0}]");


        hDen1D[i] = NULL;
        hCur1D[i] = NULL;

        if(!pData->GetEfieldFileName(i))
            continue;

        sprintf(hName,"hDen1D_%i",i);
        hDen1D[i] = (TH1F*) gROOT->FindObject(hName);
        if(hDen1D[i]) delete hDen1D[i];

        // 1D histograms
        if(pData->Is3D()) {
            hDen1D[i] = pData->GetH1SliceZ3D(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,-1,Nbins,opt+"avg");
        } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0).
            hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",1,Nbins,opt+"avg");
        } else { // 2D cartesian
            hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,opt+"avg");
        }
        hDen1D[i]->SetName(hName);

        // if(hDen1D[i]) delete hDen1D[i];
        // hDen1D[i] = (TH1F*) hE2D[i]->ProjectionX(hName,FirstyBin,LastyBin);
        // hDen1D[i]->Scale(1.0/(LastyBin-FirstyBin+1));

        if(opt.Contains("comov"))
            hDen1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]");
        else
            hDen1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]");

        if(i==0)
            hDen1D[i]->GetYaxis()->SetTitle("n/n_{0}");
        else if(i==1)
            hDen1D[i]->GetYaxis()->SetTitle("n_{b}/n_{0}");
        else
            hDen1D[i]->GetYaxis()->SetTitle("n_{i}/n_{0}");

        // Get the current:
        if(i==0) continue;

        sprintf(hName,"hCur1D_%i",i);
        hCur1D[i] = (TH1F*) gROOT->FindObject(hName);
        if(hCur1D[i]) delete hCur1D[i];

        if(opt.Contains("curr")) {
            // To get the current is needed to read in a wider transverse range which includes all the charge.
            Int_t NbinsT = 100;
            if(pData->Is3D()) {
                hCur1D[i] = pData->GetH1SliceZ3D(pData->GetChargeFileName(i)->c_str(),"charge",-1,NbinsT,-1,NbinsT,opt+"int");
            } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0).
                hCur1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",1,NbinsT,opt+"int");
            } else { // 2D cartesian
                hCur1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",-1,NbinsT,opt+"int");
            }
            hCur1D[i]->SetName(hName);

            if(opt.Contains("comov")) {
                hCur1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]");
                hCur1D[i]->GetYaxis()->SetTitle("dn/d#zeta [(n_{0}/k_{p}^{3}) (#omega_{p}/c)]");
            } else {
                hCur1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]");
                hCur1D[i]->GetYaxis()->SetTitle("dn/dz [(n_{0}/k_{p}^{3}) (#omega_{p}/c)]");
            }

            Int_t NB = hCur1D[i]->GetNbinsX();
            Float_t dx = (hCur1D[i]->GetBinLowEdge(1)-hCur1D[i]->GetBinLowEdge(NB+1))/NB;

            // hCur1D[i]->Scale(dx);
            Float_t Charge = hCur1D[i]->Integral() * dx;

            cout << Form(" Integrated charge of specie %3i = %8.4f n0 * kp^-3",i,Charge) << endl;
        }
    }


    // Get electric fields 2D
    const Int_t Nfields = 3;
    TH2F **hE2D = new TH2F*[Nfields];
    TH1F **hE1D = new TH1F*[Nfields];
    TH2F *hV2D = NULL;
    TH1F *hV1D = NULL;
    for(Int_t i=0; i<Nfields; i++) {
        hE2D[i] = NULL;
        hE1D[i] = NULL;

        if(!pData->GetEfieldFileName(i))
            continue;

        cout << Form(" Getting electric field number ") << i+1 << endl;

        char hName[24];
        sprintf(hName,"hE2D_%i",i);
        hE2D[i] = (TH2F*) gROOT->FindObject(hName);
        if(hE2D[i]) delete hE2D[i];

        if(!pData->Is3D())
            hE2D[i] = pData->GetEField(i,opt);
        else
            hE2D[i] = pData->GetEField2DSliceZY(i,-1,Nbins,opt+"avg");

        hE2D[i]->SetName(hName);
        hE2D[i]->GetXaxis()->CenterTitle();
        hE2D[i]->GetYaxis()->CenterTitle();
        hE2D[i]->GetZaxis()->CenterTitle();
        if(opt.Contains("comov"))
            hE2D[i]->GetXaxis()->SetTitle("k_{p} #zeta");
        else
            hE2D[i]->GetXaxis()->SetTitle("k_{p} z");

        if(pData->IsCyl())
            hE2D[i]->GetYaxis()->SetTitle("k_{p} r");
        else
            hE2D[i]->GetYaxis()->SetTitle("k_{p} y");

        if(i==0)
            hE2D[i]->GetZaxis()->SetTitle("E_{z}/E_{0}");
        else if(i==1)
            hE2D[i]->GetZaxis()->SetTitle("E_{y}/E_{0}");
        else if(i==2)
            hE2D[i]->GetZaxis()->SetTitle("E_{x}/E_{0}");

        sprintf(hName,"hE1D_%i",i);
        hE1D[i] = (TH1F*) gROOT->FindObject(hName);
        if(hE1D[i]) delete hE1D[i];

        // 1D histograms
        char nam[3];
        sprintf(nam,"e%i",i+1);
        if(pData->Is3D()) {

            if(i==0)
                hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins,opt+"avg");
            else
                hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins,opt+"avg");

        } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0).

            hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opt+"avg");

        } else { // 2D cartesian

            if(i==0)
                hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opt+"avg");
            else
                hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opt+"avg");
        }

        hE1D[i]->SetName(hName);
        if(opt.Contains("comov"))
            hE1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]");
        else
            hE1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]");

        if(i==0)
            hE1D[i]->GetYaxis()->SetTitle("E_{z} [E_{0}]");
        else if(i==1)
            hE1D[i]->GetYaxis()->SetTitle("E_{y} [E_{0}]");
        else if(i==2)
            hE1D[i]->GetYaxis()->SetTitle("E_{x} [E_{0}]");

        // Alternative
        // if(hE1D[i]) delete hE1D[i];
        // hE1D[i] = (TH1F*) hE2D[i]->ProjectionX(hName,FirstyBin,LastyBin);
        // hE1D[i]->Scale(1.0/(LastyBin-FirstyBin+1));

        if(i==0) {
            Int_t   NbinsX = hE2D[i]->GetNbinsX();
            Int_t   NbinsY = hE2D[i]->GetNbinsY();

            Float_t dx = pData->GetDX(0);

            sprintf(hName,"hV2D");
            hV2D = (TH2F*) hE2D[i]->Clone(hName);
            hV2D->Reset();

            sprintf(hName,"hV1D");
            hV1D = (TH1F*) hE1D[i]->Clone(hName);
            hV1D->Reset();

            for(Int_t j=NbinsY; j>0; j--) {
                Double_t integral = 0.0;
                for(Int_t k=NbinsX; k>0; k--) {
                    integral += hE2D[i]->GetBinContent(k,j) * dx;
                    hV2D->SetBinContent(k,j,integral);
                }
            }

            Double_t integral = 0.0;
            for(Int_t k=NbinsX; k>0; k--) {
                integral += hE1D[i]->GetBinContent(k) * dx;
                hV1D->SetBinContent(k,integral);
            }

        }

    }

    // Now, combine the electric field components into the total |E|
    // and calculate ionization probability for He:
    // Outter Helium electron
    Double_t Eion0 = 24.59 * PUnits::eV;
    Double_t Z     = 1;

    TH2F *hETotal2D = (TH2F*) hE2D[0]->Clone("hETotal2D");
    hETotal2D->Reset();
    TH2F *hIonProb2D = (TH2F*) hE2D[0]->Clone("hIonProb2D");
    hIonProb2D->Reset();
    TH1F *hETotal1D = (TH1F*) hE1D[0]->Clone("hETotal1D");
    hETotal1D->Reset();
    TH1F *hIonProb1D = (TH1F*) hE1D[0]->Clone("hIonProb1D");
    hIonProb1D->Reset();
    {
        Int_t NbinsX = hE2D[0]->GetNbinsX();
        Int_t NbinsY = hE2D[0]->GetNbinsY();
        for(Int_t j=0; j<NbinsX; j++) {
            for(Int_t k=0; k<NbinsY; k++) {
                Double_t E1 = hE2D[0]->GetBinContent(j,k);
                Double_t E2 = hE2D[1]->GetBinContent(j,k);
                Double_t E3 = hE2D[2]->GetBinContent(j,k);
                Double_t E  = TMath::Sqrt(E1*E1+E2*E2+E3*E3);

                hETotal2D->SetBinContent(j,k,E);

                E *= E0;

                // Double_t IonProb = (PFunc::ADK(E,Eion0,Z,l,m)/PUnits::atomictime)*PUnits::femtosecond;
                Double_t IonProb = PFunc::ADK_ENG(E,Eion0,Z) * PUnits::femtosecond;
                // if(IonProb>1) IonProb = 1.0;
                // cout << "Ion prob = " << IonProb << endl;
                hIonProb2D->SetBinContent(j,k,IonProb);
            }
            Double_t E1 = hE1D[0]->GetBinContent(j);
            Double_t E2 = hE1D[1]->GetBinContent(j);
            Double_t E3 = hE1D[2]->GetBinContent(j);
            Double_t E  = TMath::Sqrt(E1*E1+E2*E2+E3*E3);

            hETotal1D->SetBinContent(j,E);

            E *= E0;

            // Double_t IonProb = (PFunc::ADK(E,Eion0,Z,l,m)/PUnits::atomictime)*PUnits::femtosecond;
            Double_t IonProb = PFunc::ADK_ENG(E,Eion0,Z) * PUnits::femtosecond;
            // cout << "Ion prob = " << IonProb << endl;

            hIonProb1D->SetBinContent(j,IonProb);


        }
    }
    hETotal2D->GetZaxis()->SetTitle("E [E_{0}]");
    hIonProb2D->GetZaxis()->SetTitle("W_{ADK} [fs^{-1}]");
    hETotal1D->GetYaxis()->SetTitle("E [E_{0}]");
    hIonProb1D->GetYaxis()->SetTitle("W_{ADK} [fs^{-1}]");



    // Tunning the Histograms
    // ---------------------

    // Chaning to user units:
    // --------------------------

    if(opt.Contains("units") && n0) {

        for(Int_t i=0; i<Nspecies; i++) {

            if(!hDen2D[i]) continue;

            Int_t NbinsX = hDen2D[i]->GetNbinsX();
            Float_t xMin = skindepth * hDen2D[i]->GetXaxis()->GetXmin() / PUnits::um;
            Float_t xMax = skindepth * hDen2D[i]->GetXaxis()->GetXmax() / PUnits::um;
            Int_t NbinsY = hDen2D[i]->GetNbinsY();
            Float_t ymin = skindepth * hDen2D[i]->GetYaxis()->GetXmin() / PUnits::um;
            Float_t ymax = skindepth * hDen2D[i]->GetYaxis()->GetXmax() / PUnits::um;
            hDen2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax);
            // for(Int_t j=0;j<hDen2D[i]->GetNbinsX();j++) {
            // 	for(Int_t k=0;k<hDen2D[i]->GetNbinsY();k++) {
            // 	  hDen2D[i]->SetBinContent(j,k, hDen2D[i]->GetBinContent(j,k) * n0 / (1e17/PUnits::cm3) );
            // 	}
            // }

            if(pData->IsCyl())
                hDen2D[i]->GetYaxis()->SetTitle("r [#mum]");
            else
                hDen2D[i]->GetYaxis()->SetTitle("y [#mum]");

            if(opt.Contains("comov"))
                hDen2D[i]->GetXaxis()->SetTitle("#zeta [#mum]");
            else
                hDen2D[i]->GetXaxis()->SetTitle("z [#mum]");

            // if(i==0)
            // 	hDen2D[i]->GetZaxis()->SetTitle("n_{e} [10^{17}/cm^{3}]");
            // else if(i==1)
            // 	hDen2D[i]->GetZaxis()->SetTitle("n_{b} [10^{17}/cm^{3}]");
            // else
            // 	hDen2D[i]->GetZaxis()->SetTitle("n_{i} [10^{17}/cm^{3}]");

            hDen1D[i]->SetBins(NbinsX,xMin,xMax);
            // for(Int_t j=0;j<hDen1D[i]->GetNbinsX();j++) {
            // 	hDen1D[i]->SetBinContent(j, hDen1D[i]->GetBinContent(j) * n0 / (1e17/PUnits::cm3) );
            // }


            if(opt.Contains("comov"))
                hDen1D[i]->GetXaxis()->SetTitle("#zeta [#mum]");
            else
                hDen1D[i]->GetXaxis()->SetTitle("z [#mum]");

            if(hCur1D[i]) {

                hCur1D[i]->SetBins(NbinsX,xMin,xMax);
                Double_t binSize = (xMax - xMin)/NbinsX;  // bin size in um.

                Double_t dV = skindepth * skindepth * skindepth;
                Double_t lightspeed =  PConst::c_light / (PUnits::um/PUnits::femtosecond);

                hCur1D[i]->Scale(TMath::Abs(n0 * dV * (PConst::ElectronCharge/PUnits::picocoulomb) * (kp * PConst::c_light * PUnits::femtosecond)));

                hCur1D[i]->GetYaxis()->SetTitle("I[kA]");
                hCur1D[i]->GetYaxis()->SetTitle("");
                if(opt.Contains("comov"))
                    hCur1D[i]->GetXaxis()->SetTitle("#zeta [#mum]");
                else
                    hCur1D[i]->GetXaxis()->SetTitle("z [#mum]");


                Float_t Charge = hCur1D[i]->Integral() * (binSize / lightspeed);
                cout << Form(" Integrated charge of specie %3i = %8f pC",i,Charge) << endl;
            }
        }


        for(Int_t i=0; i<Nfields; i++) {
            Int_t NbinsX = hE2D[i]->GetNbinsX();
            Float_t xMin = skindepth * hE2D[i]->GetXaxis()->GetXmin() / PUnits::um;
            Float_t xMax = skindepth * hE2D[i]->GetXaxis()->GetXmax() / PUnits::um;
            Int_t NbinsY = hE2D[i]->GetNbinsY();
            Float_t ymin = skindepth * hE2D[i]->GetYaxis()->GetXmin() / PUnits::um;
            Float_t ymax = skindepth * hE2D[i]->GetYaxis()->GetXmax() / PUnits::um;
            hE2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax);
            hE1D[i]->SetBins(NbinsX,xMin,xMax);

            for(Int_t j=0; j<hE2D[i]->GetNbinsX(); j++) {
                for(Int_t k=0; k<hE2D[i]->GetNbinsY(); k++) {
                    hE2D[i]->SetBinContent(j,k, hE2D[i]->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) );
                }
                hE1D[i]->SetBinContent(j, hE1D[i]->GetBinContent(j) * ( E0 / (PUnits::GV/PUnits::m) ) );
            }

            if(pData->IsCyl())
                hE2D[i]->GetYaxis()->SetTitle("r [#mum]");
            else
                hE2D[i]->GetYaxis()->SetTitle("y [#mum]");

            if(opt.Contains("comov"))
                hE2D[i]->GetXaxis()->SetTitle("#zeta [#mum]");
            else
                hE2D[i]->GetXaxis()->SetTitle("z [#mum]");

            if(i==0)
                hE2D[i]->GetZaxis()->SetTitle("E_{z} [GV/m]");
            else if(i==1)
                hE2D[i]->GetZaxis()->SetTitle("E_{y} [GV/m]");
            else if(i==2)
                hE2D[i]->GetZaxis()->SetTitle("E_{x} [GV/m]");


            if(opt.Contains("comov"))
                hE1D[i]->GetXaxis()->SetTitle("#zeta [mm]");
            else
                hE1D[i]->GetXaxis()->SetTitle("z [mm]");

            if(i==0)
                hE1D[i]->GetYaxis()->SetTitle("E_{z} [GV/m]");
            else if(i==1)
                hE1D[i]->GetYaxis()->SetTitle("E_{y} [GV/m]");
            else if(i==2)
                hE1D[i]->GetYaxis()->SetTitle("E_{x} [GV/m]");


            if(i==0) {
                hV2D->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax);
                hETotal2D->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax);
                hIonProb2D->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax);
                hV1D->SetBins(NbinsX,xMin,xMax);
                hETotal1D->SetBins(NbinsX,xMin,xMax);
                hIonProb1D->SetBins(NbinsX,xMin,xMax);
                for(Int_t j=0; j<NbinsX; j++) {
                    for(Int_t k=0; k<NbinsY; k++) {
                        hV2D->SetBinContent(j,k, hV2D->GetBinContent(j,k) * E0 * skindepth / (PUnits::MV));
                        hETotal2D->SetBinContent(j,k, hETotal2D->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) );
                    }
                    hV1D->SetBinContent(j, hV1D->GetBinContent(j) * ( E0 * skindepth / (PUnits::MV) ) );
                    hETotal1D->SetBinContent(j, hETotal1D->GetBinContent(j) * ( E0 / (PUnits::GV/PUnits::m) ) );
                }

                if(pData->IsCyl()) {
                    hV2D->GetYaxis()->SetTitle("r [#mum]");
                    hETotal2D->GetYaxis()->SetTitle("r [#mum]");
                } else {
                    hV2D->GetYaxis()->SetTitle("y [#mum]");
                    hETotal2D->GetYaxis()->SetTitle("y [#mum]");

                }

                if(opt.Contains("comov")) {
                    hV2D->GetXaxis()->SetTitle("#zeta [#mum]");
                    hV1D->GetXaxis()->SetTitle("#zeta [#mum]");
                    hETotal2D->GetXaxis()->SetTitle("#zeta [#mum]");
                    hETotal1D->GetXaxis()->SetTitle("#zeta [#mum]");
                } else {
                    hV2D->GetXaxis()->SetTitle("z [#mum]");
                    hV2D->GetXaxis()->SetTitle("z [#mum]");
                    hETotal2D->GetXaxis()->SetTitle("z [#mum]");
                    hETotal1D->GetXaxis()->SetTitle("z [#mum]");
                }

                hV2D->GetZaxis()->SetTitle("#Psi-#Psi_{t} [MV]");
                hV1D->GetYaxis()->SetTitle("#Psi-#Psi_{t} [MV]");
                hETotal2D->GetZaxis()->SetTitle("E [GV/m]");
                hETotal1D->GetYaxis()->SetTitle("E [GV/m]");
            }
        }
    }


    // --------------------------------------------------- Vertical Zoom ------------

    Float_t yRange    = (hDen2D[0]->GetYaxis()->GetXmax() - hDen2D[0]->GetYaxis()->GetXmin())/zoom;
    Float_t midPoint = (hDen2D[0]->GetYaxis()->GetXmax() + hDen2D[0]->GetYaxis()->GetXmin())/2.;
    Float_t yMin = midPoint-yRange/2;
    Float_t yMax = midPoint+yRange/2;
    if(pData->IsCyl()) {
        yMin = pData->GetXMin(1);
        yMax = yRange;
    }

    for(Int_t i=0; i<Nspecies; i++) {
        if(!hDen2D[i]) continue;
        hDen2D[i]->GetYaxis()->SetRangeUser(yMin,yMax);
    }

    for(Int_t i=0; i<Nfields; i++) {
        if(!hE2D[i]) continue;
        hE2D[i]->GetYaxis()->SetRangeUser(yMin,yMax);
    }

    hETotal2D->GetYaxis()->SetRangeUser(yMin,yMax);

    Float_t xMin = hDen2D[0]->GetXaxis()->GetXmin();
    Float_t xMax = hDen2D[0]->GetXaxis()->GetXmax();
    Float_t xRange = xMax - xMin;

    // ------------- z Zoom --------------------------------- Plasma palette -----------
    // Set the range of the plasma charge density histogram for maximum constrast
    // using a dynamic palette wich adjust the nominal value to a certain color.


    Float_t density = 1;
    Float_t Base  = density;

    Float_t *Max = new Float_t[Nspecies];
    Float_t *Min = new Float_t[Nspecies];

    for(Int_t i=0; i<Nspecies; i++) {
        if(!hDen2D[i]) continue;

        Max[i] = hDen2D[i]->GetMaximum();
        Min[i] = 1.01E-1 * Base;
        if(i==1) Min[i] = 1.01E-1 * Base;
        if(i==2) Min[i] = 1.01E-4 * Base;
        hDen2D[i]->GetZaxis()->SetRangeUser(Min[i],Max[i]);
    }

    // Dynamic plasma palette
    const Int_t plasmaDNRGBs = 3;
    const Int_t plasmaDNCont = 64;
    Float_t basePos = 0.5;
    if(Max[0]!=Min[0]) {
        if(opt.Contains("logz")) {
            Float_t a = 1.0/(TMath::Log10(Max[0])-TMath::Log10(Min[0]));
            Float_t b = TMath::Log10(Min[0]);
            basePos = a*(TMath::Log10(Base) - b);

        } else {
            basePos = (1.0/(Max[0]-Min[0]))*(Base - Min[0]);
        }
    }

    Double_t plasmaDStops[plasmaDNRGBs] = { 0.00, basePos, 1.00 };
    Double_t plasmaDRed[plasmaDNRGBs]   = { 0.99, 0.90, 0.00 };
    Double_t plasmaDGreen[plasmaDNRGBs] = { 0.99, 0.90, 0.00 };
    Double_t plasmaDBlue[plasmaDNRGBs]  = { 0.99, 0.90, 0.00 };

    PPalette * plasmaPalette = (PPalette*) gROOT->FindObject("plasma");
    plasmaPalette->CreateGradientColorTable(plasmaDNRGBs, plasmaDStops,
                                            plasmaDRed, plasmaDGreen, plasmaDBlue, plasmaDNCont);
    // Change the range of z axis for the fields to be symmetric.
    Float_t *Emax = new Float_t[Nfields];
    Float_t *Emin = new Float_t[Nfields];
    for(Int_t i=0; i<Nfields; i++) {
        Emax[i] = hE2D[i]->GetMaximum();
        Emin[i] = hE2D[i]->GetMinimum();
        if(Emax[i] > TMath::Abs(Emin[i]))
            Emin[i] = -Emax[i];
        else
            Emax[i] = -Emin[i];
        hE2D[i]->GetZaxis()->SetRangeUser(Emin[i],Emax[i]);
    }


    // Potential
    if(opt.Contains("units")) {
        trapPotential *=  ( E0 * skindepth / (PUnits::MV) );
    }

    Float_t Vmin = hV1D->GetMinimum();
    {   // Shift potential
        Int_t   NbinsX = hV2D->GetNbinsX();
        Int_t   NbinsY = hV2D->GetNbinsY();
        for(Int_t j=0; j<NbinsX; j++) {
            for(Int_t k=0; k<NbinsY; k++) {
                hV2D->SetBinContent(j,k, hV2D->GetBinContent(j,k) - Vmin -trapPotential);
            }
            hV1D->SetBinContent(j, hV1D->GetBinContent(j) - Vmin -trapPotential);
        }
    }

    Vmin = hV1D->GetMinimum();
    Float_t Vmax = hV1D->GetMaximum();

    // Dynamic potential palette
    const Int_t potPNRGBs = 5;
    const Int_t potPNCont = 64;
    Float_t zeroPos = -Vmin/(Vmax-Vmin);

    Double_t potPStops[potPNRGBs] = { 0.00, zeroPos-3.0/potPNCont,zeroPos, zeroPos+3.0/potPNCont, 1.00 };
    Double_t potPRed[potPNRGBs]   = { 0.518, 0.965, 0.90, 0.498, 0.106 };
    Double_t potPGreen[potPNRGBs] = { 0.078, 0.925, 0.90, 0.718, 0.078 };
    Double_t potPBlue[potPNRGBs]  = { 0.106, 0.353, 0.90, 0.780, 0.518 };

    PPalette * potentialPalette = (PPalette*) gROOT->FindObject("rbow2inv");
    potentialPalette->CreateGradientColorTable(potPNRGBs, potPStops,
            potPRed, potPGreen, potPBlue, potPNCont);

    // Extract contours
    TCanvas* c = new TCanvas("c","Contour List",0,0,600,600);
    c->cd();

    // Potential
    TH2F *hV2Dc = (TH2F*) hV2D->Clone("hV2Dc");
    const Int_t Ncontours = 25;
    Double_t contours[Ncontours];
    for(Int_t i=0; i<Ncontours; i++) {
        contours[i] = i*(trapPotential/5.0) - trapPotential;
    }
    hV2Dc->SetContour(Ncontours, contours);
    hV2Dc->Draw("cont list");

    c->Update();
    TObjArray *contsV2D = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
    TClonesArray graphsV2D("TGraph",Ncontours);
    {
        Int_t ncontours = contsV2D->GetSize();
        TList* clist = NULL;
        Int_t nGraphs = 0;
        TGraph *gr = NULL;
        for(Int_t i = 0; i < ncontours; i++) {
            if(i==0) continue;

            clist = (TList*) contsV2D->At(i);

            for(Int_t j = 0 ; j < clist->GetSize(); j++) {
                gr = (TGraph*) clist->At(j);
                if(!gr) continue;

                gr->SetLineWidth(1);
                gr->SetLineColor(kGray+1);

                if( !((i)%5) ) {
                    gr->SetLineWidth(2);
                    gr->SetLineColor(kGray+2);
                }
                new(graphsV2D[nGraphs]) TGraph(*gr) ;
                nGraphs++;
            }
        }
    }

    // Ion probability
    hIonProb2D->GetZaxis()->SetRangeUser(0.00501,80);

    TH2F *hIonProb2Dc = (TH2F*) hIonProb2D->Clone("hIonProb2Dc");
    const Int_t NcontI = 4;
    Double_t contI[NcontI] = {0.01,0.1,1.0,10.0};
    hIonProb2Dc->SetContour(NcontI, contI);
    hIonProb2Dc->Draw("cont list");

    c->Update();
    TObjArray *contsI2D = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
    TClonesArray graphsI2D("TGraph",NcontI);
    {
        Int_t ncontours = contsI2D->GetSize();
        TList* clist = NULL;
        Int_t nGraphs = 0;
        TGraph *gr = NULL;
        for(Int_t i = 0; i < ncontours; i++) {
            clist = (TList*) contsI2D->At(i);

            for(Int_t j = 0 ; j < clist->GetSize(); j++) {
                gr = (TGraph*) clist->At(j);
                if(!gr) continue;

                if( !(i%2) ) {
                    gr->SetLineWidth(1);
                    gr->SetLineStyle(2);
                    gr->SetLineColor(kOrange-3);
                } else {
                    gr->SetLineWidth(1);
                    gr->SetLineStyle(1);
                    gr->SetLineColor(kOrange-3);
                }

                new(graphsI2D[nGraphs]) TGraph(*gr) ;
                nGraphs++;
            }
        }
    }




    // "Axis range" in Osiris units:
    Double_t ylow  = hDen2D[0]->GetYaxis()->GetBinLowEdge(FirstyBin);
    Double_t yup = hDen2D[0]->GetYaxis()->GetBinUpEdge(LastyBin);
    Double_t xmin = hDen2D[0]->GetXaxis()->GetXmin();
    Double_t xmax = hDen2D[0]->GetXaxis()->GetXmax();

    TLine *lineYzero = new TLine(xmin,0.0,xmax,0.0);
    lineYzero->SetLineColor(kGray+2);
    lineYzero->SetLineStyle(2);

    TLine *lineYup = new TLine(xmin,yup,xmax,yup);
    lineYup->SetLineColor(kGray+1);
    lineYup->SetLineStyle(2);

    TLine *lineYdown = new TLine(xmin,ylow,xmax,ylow);
    lineYdown->SetLineColor(kGray+1);
    lineYdown->SetLineStyle(2);

    zStartPlasma -= shiftz;
    zStartNeutral -= shiftz;
    zEndNeutral -= shiftz;

    if(opt.Contains("units")) {
        zStartPlasma *= skindepth / PUnits::um;
        zStartNeutral *= skindepth / PUnits::um;
        zEndNeutral *= skindepth / PUnits::um;
    }

    //  cout << "Start plasma = " << zStartPlasma << endl;
    TLine *lineStartPlasma = new TLine(zStartPlasma,yMin,zStartPlasma,yMax);
    lineStartPlasma->SetLineColor(kGray+2);
    lineStartPlasma->SetLineStyle(2);
    lineStartPlasma->SetLineWidth(3);

    //  cout << "Start plasma = " << zStartNeutral << endl;
    TLine *lineStartNeutral = new TLine(zStartNeutral,yMin,zStartNeutral,yMax);
    lineStartNeutral->SetLineColor(kGray+1);
    lineStartNeutral->SetLineStyle(2);
    lineStartNeutral->SetLineWidth(3);

    //  cout << "End plasma = " << zEndNeutral << endl;
    TLine *lineEndNeutral = new TLine(zEndNeutral,yMin,zEndNeutral,yMax);
    lineEndNeutral->SetLineColor(kGray+1);
    lineEndNeutral->SetLineStyle(2);
    lineEndNeutral->SetLineWidth(3);


    // Plotting
    // -----------------------------------------------

    // Canvas setup
    TCanvas *C = new TCanvas("C","2D Charge density and Electric field",750,666);

    // Palettes setup
    TExec *exPlasma = new TExec("exPlasma","plasmaPalette->cd();");
    TExec *exElec   = new TExec("exElec","redelectronPalette->cd();");
    TExec *exHot    = new TExec("exHot","hotPalette->cd();");
    TExec *exField  = new TExec("exField","rbow2Palette->cd();");
    TExec *exFieldT = new TExec("exFieldT","redPalette->cd();");
    TExec *exIonP   = new TExec("exIonP","redPalette->cd();");
    TExec *exPot    = new TExec("exPot","rbow2invPalette->cd();");

    // Actual Plotting!
    // ------------------------------------------------------------

    // Output file
    TString fOutName = Form("./%s/Plots/Potential2D/Potential2D",pData->GetPath().c_str());
    fOutName += Form("-%s_%i",pData->GetName(),time);

    // Setup Pad layout:
    Float_t lMargin = 0.15;
    Float_t rMargin = 0.18;
    Float_t bMargin = 0.15;
    Float_t tMargin = 0.04;
    Float_t factor = 1.0;
    PlasmaGlob::CanvasAsymPartition(C,2,lMargin,rMargin,bMargin,tMargin,factor);

    TPad *pad[2];
    TString sLabels[] = {"(a)","(b)"};
    // Text objects
    TPaveText **textLabel = new TPaveText*[2];

    C->cd(0);
    char pname[16];
    sprintf(pname,"pad_%i",1);
    pad[0] = (TPad*) gROOT->FindObject(pname);
    pad[0]->Draw();
    pad[0]->cd(); // <---------------------------------------------- Top Plot ---------
    if(opt.Contains("logz")) {
        pad[0]->SetLogz(1);
    } else {
        pad[0]->SetLogz(0);
    }
    pad[0]->SetFrameLineWidth(3);
    pad[0]->SetTickx(1);

    // Re-range:
    for(Int_t i=0; i<Nspecies; i++) {
        if(!hDen2D[i]) continue;
        hDen2D[i]->GetYaxis()->SetRangeUser(yMin -(factor-1)*yRange, yMax);
    }


    TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1");
    if(hFrame) delete hFrame;
    hFrame = (TH2F*) hDen2D[0]->Clone("hFrame1");
    hFrame->Reset();

    hFrame->SetLabelFont(42,"xyz");
    hFrame->SetTitleFont(42,"xyz");

    hFrame->GetYaxis()->SetNdivisions(505);
    hFrame->GetYaxis()->SetLabelSize(0.085);
    hFrame->GetYaxis()->SetTitleSize(0.09);
    hFrame->GetYaxis()->SetTitleOffset(0.7);
    hFrame->GetYaxis()->SetTickLength(0.02);

    hFrame->GetXaxis()->SetLabelOffset(999.);
    hFrame->GetXaxis()->SetTitleOffset(999.);
    hFrame->GetXaxis()->SetTickLength(0.04);

    // Frame asymmetry:
    hFrame->Draw("col");

    // hDen2D[0]->GetZaxis()->SetNdivisions(505);

    // Injected electrons if any
    if(Nspecies>=3) {
        if(hDen2D[2]) {
            exHot->Draw();
            hDen2D[2]->Draw("colz same");
        }
    }

    // Plasma
    hDen2D[0]->GetZaxis()->SetTitleFont(42);
    exPlasma->Draw();
    hDen2D[0]->Draw("colz same");

    // Beam driver.
    if(hDen2D[1]) {
        //    hDen2D[1]->GetZaxis()->SetNdivisions(505);
        exElec->Draw();
        hDen2D[1]->Draw("colz same");
    }

    {
        TGraph *gr = (TGraph*) graphsV2D.At(4);
        gr->Draw("C");
    }

    {
        TGraph *gr = (TGraph*) graphsI2D.At(1);
        gr->Draw("C");
    }


    if(opt.Contains("1dline")) {
        lineYzero->Draw();
        lineYdown->Draw();
        lineYup->Draw();
    }

    if(opt.Contains("sline")) {
        if(zStartPlasma>xmin && zStartPlasma<xmax)
            lineStartPlasma->Draw();
        if(zStartNeutral>xmin && zStartNeutral<xmax)
            lineStartNeutral->Draw();
        if(zEndNeutral>xmin && zEndNeutral<xmax)
            lineEndNeutral->Draw();
    }

    // lineYdown->Draw();
    // lineYup->Draw();

    // Palettes re-arrangement
    pad[0]->Update();
    Float_t y1 = pad[0]->GetBottomMargin();
    Float_t y2 = 1 - pad[0]->GetTopMargin();
    Float_t x1 = pad[0]->GetLeftMargin();
    Float_t x2 = 1 - pad[0]->GetRightMargin();

    TPaletteAxis *palette = NULL;
    if(Nspecies>=3) {
        if(hDen2D[2]) {
            palette = (TPaletteAxis*)hDen2D[2]->GetListOfFunctions()->FindObject("palette");
        }
    }
    if(palette) {
        palette->SetY2NDC(y2 - 0.00);
        palette->SetY1NDC(0.66*(y1+y2) + 0.00);
        palette->SetX1NDC(x2 + 0.005);
        palette->SetX2NDC(x2 + 0.03);
        //  palette->SetTitleFont(42);
        //  palette->SetTitleOffset(0.85);
        palette->SetTitleOffset(999.9);
        palette->SetTitleSize(0.075);
        palette->SetLabelFont(42);
        palette->SetLabelSize(0.075);
        palette->SetLabelOffset(0.001);
        palette->SetBorderSize(2);
        palette->SetLineColor(1);
    }

    palette = (TPaletteAxis*)hDen2D[0]->GetListOfFunctions()->FindObject("palette");
    if(palette) {
        palette->SetY2NDC(0.66*(y1+y2) - 0.00);
        palette->SetY1NDC(0.33*(y1+y2) + 0.00);
        palette->SetX1NDC(x2 + 0.005);
        palette->SetX2NDC(x2 + 0.03);
        // palette->SetTitleFont(42);
        palette->SetTitleOffset(0.80);
        palette->SetTitleSize(0.075);
        palette->SetLabelFont(42);
        palette->SetLabelSize(0.075);
        palette->SetLabelOffset(0.001);
        palette->SetBorderSize(2);
        palette->SetLineColor(1);
    }

    palette = (TPaletteAxis*)hDen2D[1]->GetListOfFunctions()->FindObject("palette");
    if(palette) {
        palette->SetY2NDC(0.33*(y1+y2) - 0.00);
        palette->SetY1NDC(y1 + 0.00);
        palette->SetX1NDC(x2 + 0.005);
        palette->SetX2NDC(x2 + 0.03);
        //palette->SetTitleFont(42);
        //palette->SetTitleOffset(0.85);
        palette->SetTitleOffset(999.9);
        palette->SetTitleSize(0.075);
        palette->SetLabelFont(42);
        palette->SetLabelSize(0.075);
        palette->SetLabelOffset(0.001);
        palette->SetBorderSize(2);
        palette->SetLineColor(1);
    }


    // 1D charge density plots:
    Float_t yaxismin  =  pad[0]->GetUymin();
    Float_t yaxismax  =  pad[0]->GetUymin() + 0.33*(pad[0]->GetUymax() - pad[0]->GetUymin()) - 0.00;
    Float_t denmin = Min[1];
    Float_t denmax = Max[1];
    if(opt.Contains("logz")) {
        denmin = TMath::Log10(denmin);
        denmax = TMath::Log10(denmax);
    }

    Float_t curmin = 0.0;
    Float_t curmax = 0.0;
    if(opt.Contains("curr")) {
        curmin = 0.0;
        curmax = hCur1D[1]->GetMaximum();

        cout << Form(" Maximum driver  current = %6.2f kA ", curmax) << endl ;
        if(Nspecies>=3)
            if(hCur1D[2])
                cout << Form(" Maximum witness current = %6.2f kA ", hCur1D[2]->GetMaximum()) << endl ;

        // Round for better plotting
        curmax = 0.1*TMath::Nint(curmax*10);
    }

    for(Int_t i=0; i<Nspecies; i++) {
        if(!hDen1D[i]) continue;

        Float_t slope = (yaxismax - yaxismin)/(denmax - denmin);

        for(Int_t j=0; j<hDen1D[i]->GetNbinsX(); j++) {
            Float_t content = hDen1D[i]->GetBinContent(j+1);
            if(opt.Contains("logz")) content = TMath::Log10(content);

            if(content<denmin)
                hDen1D[i]->SetBinContent(j+1,yaxismin);
            else
                hDen1D[i]->SetBinContent(j+1,(content - denmin) * slope + yaxismin);


        }

        if(hCur1D[i]) {
            slope = (yaxismax - yaxismin)/(curmax - curmin);

            for(Int_t j=0; j<hCur1D[i]->GetNbinsX(); j++) {
                Float_t content = hCur1D[i]->GetBinContent(j+1);

                if(content<curmin)
                    hCur1D[i]->SetBinContent(j+1,yaxismin);
                else
                    hCur1D[i]->SetBinContent(j+1,(content - curmin) * slope + yaxismin);
            }

        }

    }

    // Plasma on-axis density:
    // hDen1D[0]->SetLineWidth(2);
    // hDen1D[0]->SetLineColor(kGray+1);
    // // // PlasmaGlob::SetH1Style(hDen1D[0],1);
    // hDen1D[0]->Draw("same C");


    if(opt.Contains("curr")) {
        hCur1D[1]->SetLineWidth(2);
        hCur1D[1]->SetLineColor(PlasmaGlob::elecLine);
        hCur1D[1]->Draw("same C");
    } else {
        hDen1D[1]->SetLineWidth(2);
        hDen1D[1]->SetLineColor(PlasmaGlob::elecLine);
        //    hDen1D[1]->Draw("same C");
    }

    if(Nspecies>=3) {
        if(hDen1D[2]) {
            if(opt.Contains("curr")) {
                hCur1D[2]->SetLineWidth(2);
                hCur1D[2]->SetLineColor(kOrange+8);
                hCur1D[2]->Draw("same C");
            } else {
                hDen1D[2]->SetLineWidth(2);
                hDen1D[2]->SetLineColor(kOrange+8);
                //   hDen1D[2]->Draw("same C");
            }
        }
    }

    // Current axis
    TGaxis *axis = NULL;
    if(opt.Contains("curr")) {
        axis = new TGaxis(xMax-xRange/6.0,yMin - (factor-1)*yRange,
                          xMax-xRange/6.0,yaxismax,
                          0.001,curmax,503,"+LS");

        axis->SetLineWidth(1);
        axis->SetLineColor(kGray+3);//PlasmaGlob::elecLine);
        axis->SetLabelColor(kGray+3);//PlasmaGlob::elecLine);
        axis->SetLabelSize(0.06);
        axis->SetLabelOffset(0.01);
        axis->SetLabelFont(42);
        axis->SetTitleColor(kGray+3);//PlasmaGlob::elecLine);
        axis->SetTitleSize(0.06);
        axis->SetTitleOffset(0.6);
        axis->SetTitleFont(42);
        axis->SetTickSize(0.03);
        axis->SetTitle("I [kA]");
        axis->CenterTitle();
        axis->SetNdivisions(505);

        axis->Draw();
    }


    TPaveText *textTime = new TPaveText(xMax - 0.3*xRange, yMax-0.15*yRange, xMax-0.1, yMax-0.05*yRange);
    //x2-0.17,y2-0.12,x2-0.02,y2-0.02,"NDC");
    PlasmaGlob::SetPaveTextStyle(textTime,32);
    char ctext[128];
    if(opt.Contains("units") && n0)
        sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um);
    else
        sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time);
    textTime->SetTextFont(42);
    textTime->AddText(ctext);

    textTime->Draw();
    // textDen->Draw();
    // if(opt.Contains("units"))
    //   textWav->Draw();

    textLabel[0] = new TPaveText(xMin + 0.02*xRange, yMax-0.2*yRange, xMin+0.30*xRange, yMax-0.05*yRange);
    PlasmaGlob::SetPaveTextStyle(textLabel[0],12);
    textLabel[0]->SetTextFont(42);
    textLabel[0]->AddText(sLabels[0]);
    textLabel[0]->Draw();


    pad[0]->RedrawAxis();

    C->cd(0);
    sprintf(pname,"pad_%i",0);
    pad[1] = (TPad*) gROOT->FindObject(pname);
    pad[1]->Draw();
    pad[1]->cd(); // <--------------------------------------------------------- Bottom Plot
    pad[1]->SetFrameLineWidth(3);
    pad[1]->SetTickx(1);

    hFrame = (TH2F*) gROOT->FindObject("hFrame2");
    if(hFrame) delete hFrame;
    hFrame = (TH2F*) hDen2D[0]->Clone("hFrame2");
    hFrame->Reset();

    Float_t yFactor = pad[0]->GetAbsHNDC()/pad[1]->GetAbsHNDC();


    hFrame->GetYaxis()->SetLabelSize(yFactor*0.085);
    hFrame->GetYaxis()->SetTitleSize(yFactor*0.09);
    hFrame->GetYaxis()->SetTitleOffset(0.7/yFactor);
    hFrame->GetYaxis()->SetTickLength(0.02/yFactor);

    hFrame->GetXaxis()->SetTitleSize(0.10);
    hFrame->GetXaxis()->SetLabelSize(0.08);
    hFrame->GetXaxis()->SetLabelOffset(0.02);
    hFrame->GetXaxis()->SetTitleOffset(1.0);
    hFrame->GetXaxis()->SetTickLength(0.04*yFactor);

    hFrame->SetLabelFont(42,"xyz");
    hFrame->SetTitleFont(42,"xyz");

    hFrame->Draw("col");

    //  hE2D[0]->GetZaxis()->SetNdivisions(505);
    hV2D->GetZaxis()->SetTitleFont(42);
    hV2D->GetZaxis()->SetTickLength(0.02/yFactor);


    exPot->Draw();

    hV2D->Draw("col z same");

    for(Int_t i=0; i<graphsV2D.GetEntriesFast(); i++) {
        TGraph *gr = (TGraph*) graphsV2D.At(i);
        if(!gr) continue;
        gr->Draw("C");
    }

    for(Int_t i=0; i<graphsI2D.GetEntriesFast(); i++) {
        //if(i!=2) continue;
        TGraph *gr = (TGraph*) graphsI2D.At(i);
        if(!gr) continue;
        gr->Draw("C");
    }


    if(opt.Contains("1dline")) {
        lineYzero->Draw();
        lineYdown->Draw();
        lineYup->Draw();
    }

    if(opt.Contains("sline")) {
        if(zStartPlasma>xmin && zStartPlasma<xmax)
            lineStartPlasma->Draw();
        if(zStartNeutral>xmin && zStartNeutral<xmax)
            lineStartNeutral->Draw();
        if(zEndNeutral>xmin && zEndNeutral<xmax)
            lineEndNeutral->Draw();
    }


    pad[1]->Update();

    y1 = pad[1]->GetBottomMargin();
    y2 = 1 - pad[1]->GetTopMargin();
    x1 = pad[1]->GetLeftMargin();
    x2 = 1 - pad[1]->GetRightMargin();

    palette = (TPaletteAxis*)hV2D->GetListOfFunctions()->FindObject("palette");
    if(palette) {
        palette->SetY2NDC(y2 - 0.00);
        palette->SetY1NDC(y1 + 0.00);
        palette->SetX1NDC(x2 + 0.005);
        palette->SetX2NDC(x2 + 0.03);
        // palette->SetTitleFont(42);
        palette->SetTitleSize(yFactor*0.075);
        palette->SetTitleOffset(0.80/yFactor);
        palette->SetLabelSize(yFactor*0.075);
        palette->SetLabelFont(42);
        palette->SetLabelOffset(0.01/yFactor);
        palette->SetBorderSize(2);
        palette->SetLineColor(1);
    }



    pad[1]->RedrawAxis();

    textLabel[1] = new TPaveText(xMin + 0.02*xRange, yMax-0.2*yRange, xMin+0.30*xRange, yMax-0.05*yRange);
    PlasmaGlob::SetPaveTextStyle(textLabel[1],12);
    textLabel[1]->SetTextFont(42);
    textLabel[1]->AddText(sLabels[1]);
    textLabel[1]->Draw();

    C->cd();

    // Print to a file
    PlasmaGlob::imgconv(C,fOutName,opt);
    // ---------------------------------------------------------

    PlasmaGlob::DestroyCanvases();
}
// The actual job
void backgroundFits_qqzz_1Dw(int channel, int sqrts)
{
  TString schannel;
  if      (channel == 1) schannel = "4mu";
  else if (channel == 2) schannel = "4e";
  else if (channel == 3) schannel = "2e2mu";
  else cout << "Not a valid channel: " << schannel << endl;

  TString ssqrts = (long) sqrts + TString("TeV");

  cout << "schannel = " << schannel << "  sqrts = " << sqrts << endl;

  TString outfile = "CardFragments/qqzzBackgroundFit_" + ssqrts + "_" + schannel + ".txt";
  ofstream of(outfile,ios_base::out);
  of << "### background functions ###" << endl;


  gSystem->AddIncludePath("-I$ROOFITSYS/include");
  gROOT->ProcessLine(".L ../CreateDatacards/include/tdrstyle.cc");
  setTDRStyle(false);
  gStyle->SetPadLeftMargin(0.16);

  TString filepath;
  if (sqrts==7) {
    filepath = filePath7TeV;
  } else if (sqrts==8) {
    filepath = filePath8TeV;
  }

  TChain* tree = new TChain("SelectedTree");
  tree->Add( filepath+ "/" + (schannel=="2e2mu"?"2mu2e":schannel) + "/HZZ4lTree_ZZTo*.root");


  RooRealVar* MC_weight = new RooRealVar("MC_weight","MC_weight",0.,2.) ; 
  RooRealVar* ZZMass = new RooRealVar("ZZMass","ZZMass",100.,1000.);
  RooRealVar* ZZLD = new RooRealVar("ZZLD","ZZLD",0.,1.);
  
  char cut[10];
  sprintf(cut,"ZZLD>0.5");
  //RooDataSet* set = new RooDataSet("set","set",tree,RooArgSet(*ZZMass,*MC_weight,*ZZLD),cut,"MC_weight");
  RooDataSet* set = new RooDataSet("set","set",tree,RooArgSet(*ZZMass,*MC_weight),0,"MC_weight");

  double totalweight = 0.;
  double totalweight_z = 0.;
  for (int i=0 ; i<set->numEntries() ; i++) { 
    //set->get(i) ; 
    RooArgSet* row = set->get(i) ;
    //row->Print("v");
    totalweight += set->weight();
    if (row->getRealValue("ZZMass") < 200) totalweight_z += set->weight();
  } 
  cout << "nEntries: " << set->numEntries() << ", totalweight: " << totalweight << ", totalweight_z: " << totalweight_z << endl;
	
  gSystem->Load("libHiggsAnalysisCombinedLimit.so");
	
  //// ---------------------------------------
  //Background
  RooRealVar CMS_qqzzbkg_a0("CMS_qqzzbkg_a0","CMS_qqzzbkg_a0",115.3,0.,200.);
  RooRealVar CMS_qqzzbkg_a1("CMS_qqzzbkg_a1","CMS_qqzzbkg_a1",21.96,0.,200.);
  RooRealVar CMS_qqzzbkg_a2("CMS_qqzzbkg_a2","CMS_qqzzbkg_a2",122.8,0.,200.);
  RooRealVar CMS_qqzzbkg_a3("CMS_qqzzbkg_a3","CMS_qqzzbkg_a3",0.03479,0.,1.);
  RooRealVar CMS_qqzzbkg_a4("CMS_qqzzbkg_a4","CMS_qqzzbkg_a4",185.5,0.,200.);
  RooRealVar CMS_qqzzbkg_a5("CMS_qqzzbkg_a5","CMS_qqzzbkg_a5",12.67,0.,200.);
  RooRealVar CMS_qqzzbkg_a6("CMS_qqzzbkg_a6","CMS_qqzzbkg_a6",34.81,0.,100.);
  RooRealVar CMS_qqzzbkg_a7("CMS_qqzzbkg_a7","CMS_qqzzbkg_a7",0.1393,0.,1.);
  RooRealVar CMS_qqzzbkg_a8("CMS_qqzzbkg_a8","CMS_qqzzbkg_a8",66.,0.,200.);
  RooRealVar CMS_qqzzbkg_a9("CMS_qqzzbkg_a9","CMS_qqzzbkg_a9",0.07191,0.,1.);
  RooRealVar CMS_qqzzbkg_a10("CMS_qqzzbkg_a10","CMS_qqzzbkg_a10",94.11,0.,200.);
  RooRealVar CMS_qqzzbkg_a11("CMS_qqzzbkg_a11","CMS_qqzzbkg_a11",-5.111,-100.,100.);
  RooRealVar CMS_qqzzbkg_a12("CMS_qqzzbkg_a12","CMS_qqzzbkg_a12",4834,0.,10000.);
  RooRealVar CMS_qqzzbkg_a13("CMS_qqzzbkg_a13","CMS_qqzzbkg_a13",0.2543,0.,1.);
	
  if (channel == 1){
    ///* 4mu
    CMS_qqzzbkg_a0.setVal(103.854);
    CMS_qqzzbkg_a1.setVal(10.0718);
    CMS_qqzzbkg_a2.setVal(117.551);
    CMS_qqzzbkg_a3.setVal(0.0450287);
    CMS_qqzzbkg_a4.setVal(185.262);
    CMS_qqzzbkg_a5.setVal(7.99428);
    CMS_qqzzbkg_a6.setVal(39.7813);
    CMS_qqzzbkg_a7.setVal(0.0986891);
    CMS_qqzzbkg_a8.setVal(49.1325);
    CMS_qqzzbkg_a9.setVal(0.0389984);
    CMS_qqzzbkg_a10.setVal(98.6645);
    CMS_qqzzbkg_a11.setVal(-7.02043);
    CMS_qqzzbkg_a12.setVal(5694.66);
    CMS_qqzzbkg_a13.setVal(0.0774525);
    //*/
  }
  else if (channel == 2){
    ///* 4e
    CMS_qqzzbkg_a0.setVal(111.165);
    CMS_qqzzbkg_a1.setVal(19.8178);
    CMS_qqzzbkg_a2.setVal(120.89);
    CMS_qqzzbkg_a3.setVal(0.0546639);
    CMS_qqzzbkg_a4.setVal(184.878);
    CMS_qqzzbkg_a5.setVal(11.7041);
    CMS_qqzzbkg_a6.setVal(33.2659);
    CMS_qqzzbkg_a7.setVal(0.140858);
    CMS_qqzzbkg_a8.setVal(56.1226);
    CMS_qqzzbkg_a9.setVal(0.0957699);
    CMS_qqzzbkg_a10.setVal(98.3662);
    CMS_qqzzbkg_a11.setVal(-6.98701);
    CMS_qqzzbkg_a12.setVal(10.0536);
    CMS_qqzzbkg_a13.setVal(0.110576);
    //*/
  }
  else if (channel == 3){
    ///* 2e2mu
    CMS_qqzzbkg_a0.setVal(110.293);
    CMS_qqzzbkg_a1.setVal(11.8334);
    CMS_qqzzbkg_a2.setVal(116.91);
    CMS_qqzzbkg_a3.setVal(0.0433151);
    CMS_qqzzbkg_a4.setVal(185.817);
    CMS_qqzzbkg_a5.setVal(10.5945);
    CMS_qqzzbkg_a6.setVal(29.6208);
    CMS_qqzzbkg_a7.setVal(0.0826);
    CMS_qqzzbkg_a8.setVal(53.1346);
    CMS_qqzzbkg_a9.setVal(0.0882081);
    CMS_qqzzbkg_a10.setVal(85.3776);
    CMS_qqzzbkg_a11.setVal(-13.3836);
    CMS_qqzzbkg_a12.setVal(7587.95);
    CMS_qqzzbkg_a13.setVal(0.325621);
    //*/
  }
  else {
    cout << "disaster" << endl;
  }
    
  RooqqZZPdf_v2* bkg_qqzz = new RooqqZZPdf_v2("bkg_qqzz","bkg_qqzz",*ZZMass,
					      CMS_qqzzbkg_a0,CMS_qqzzbkg_a1,CMS_qqzzbkg_a2,CMS_qqzzbkg_a3,CMS_qqzzbkg_a4,
					      CMS_qqzzbkg_a5,CMS_qqzzbkg_a6,CMS_qqzzbkg_a7,CMS_qqzzbkg_a8,
					      CMS_qqzzbkg_a9,CMS_qqzzbkg_a10,CMS_qqzzbkg_a11,CMS_qqzzbkg_a12,CMS_qqzzbkg_a13);
  RooArgSet myASet(*ZZMass, CMS_qqzzbkg_a0,CMS_qqzzbkg_a1,CMS_qqzzbkg_a2,CMS_qqzzbkg_a3,CMS_qqzzbkg_a4,
		   CMS_qqzzbkg_a5,CMS_qqzzbkg_a6,CMS_qqzzbkg_a7);
  myASet.add(CMS_qqzzbkg_a8);
  myASet.add(CMS_qqzzbkg_a9);
  myASet.add(CMS_qqzzbkg_a10);
  myASet.add(CMS_qqzzbkg_a11);
  myASet.add(CMS_qqzzbkg_a12);
  myASet.add(CMS_qqzzbkg_a13);
 
  RooFitResult *r1 = bkg_qqzz->fitTo( *set, Save(kTRUE), SumW2Error(kTRUE) );//, Save(kTRUE), SumW2Error(kTRUE)) ;

  cout << endl;
  cout << "------- Parameters for " << schannel << " sqrts=" << sqrts << endl;
  cout << "  a0_bkgd = " << CMS_qqzzbkg_a0.getVal() << endl;
  cout << "  a1_bkgd = " << CMS_qqzzbkg_a1.getVal() << endl;
  cout << "  a2_bkgd = " << CMS_qqzzbkg_a2.getVal() << endl;
  cout << "  a3_bkgd = " << CMS_qqzzbkg_a3.getVal() << endl;
  cout << "  a4_bkgd = " << CMS_qqzzbkg_a4.getVal() << endl;
  cout << "  a5_bkgd = " << CMS_qqzzbkg_a5.getVal() << endl;
  cout << "  a6_bkgd = " << CMS_qqzzbkg_a6.getVal() << endl;
  cout << "  a7_bkgd = " << CMS_qqzzbkg_a7.getVal() << endl;
  cout << "  a8_bkgd = " << CMS_qqzzbkg_a8.getVal() << endl;
  cout << "  a9_bkgd = " << CMS_qqzzbkg_a9.getVal() << endl;
  cout << "  a10_bkgd = " << CMS_qqzzbkg_a10.getVal() << endl;
  cout << "  a11_bkgd = " << CMS_qqzzbkg_a11.getVal() << endl;
  cout << "  a12_bkgd = " << CMS_qqzzbkg_a12.getVal() << endl;
  cout << "  a13_bkgd = " << CMS_qqzzbkg_a13.getVal() << endl;
  cout << "}" << endl;
  cout << "---------------------------" << endl;


  of << "qqZZshape a0_bkgd   " << CMS_qqzzbkg_a0.getVal() << endl;
  of << "qqZZshape a1_bkgd   " << CMS_qqzzbkg_a1.getVal() << endl;
  of << "qqZZshape a2_bkgd   " << CMS_qqzzbkg_a2.getVal() << endl;
  of << "qqZZshape a3_bkgd   " << CMS_qqzzbkg_a3.getVal() << endl;
  of << "qqZZshape a4_bkgd   " << CMS_qqzzbkg_a4.getVal() << endl;
  of << "qqZZshape a5_bkgd   " << CMS_qqzzbkg_a5.getVal() << endl;
  of << "qqZZshape a6_bkgd   " << CMS_qqzzbkg_a6.getVal() << endl;
  of << "qqZZshape a7_bkgd   " << CMS_qqzzbkg_a7.getVal() << endl;
  of << "qqZZshape a8_bkgd   " << CMS_qqzzbkg_a8.getVal() << endl;
  of << "qqZZshape a9_bkgd   " << CMS_qqzzbkg_a9.getVal() << endl;
  of << "qqZZshape a10_bkgd  " << CMS_qqzzbkg_a10.getVal() << endl;
  of << "qqZZshape a11_bkgd  " << CMS_qqzzbkg_a11.getVal() << endl;
  of << "qqZZshape a12_bkgd  " << CMS_qqzzbkg_a12.getVal() << endl;
  of << "qqZZshape a13_bkgd  " << CMS_qqzzbkg_a13.getVal() << endl;
  of << endl << endl;
  of.close();

  cout << endl << "Output written to: " << outfile << endl;
  
    
  double qqzznorm;
  if (channel == 1) qqzznorm = 20.5836;
  else if (channel == 2) qqzznorm = 13.8871;
  else if (channel == 3) qqzznorm = 32.9883;
  else { cout << "disaster!" << endl; }

  ZZMass->setRange("fullrange",100.,1000.);
  ZZMass->setRange("largerange",100.,600.);
  ZZMass->setRange("zoomrange",100.,200.);
    
  double rescale = qqzznorm/totalweight;
  double rescale_z = qqzznorm/totalweight_z;
  cout << "rescale: " << rescale << ", rescale_z: " << rescale_z << endl;


  // Plot m4l and
  RooPlot* frameM4l = ZZMass->frame(Title("M4L"),Range(100,600),Bins(250)) ;
  set->plotOn(frameM4l, MarkerStyle(20), Rescale(rescale)) ;
  
  //set->plotOn(frameM4l) ;
  RooPlot* frameM4lz = ZZMass->frame(Title("M4L"),Range(100,200),Bins(100)) ;
  set->plotOn(frameM4lz, MarkerStyle(20), Rescale(rescale)) ;


  int iLineColor = 1;
  string lab = "blah";
  if (channel == 1) { iLineColor = 2; lab = "4#mu"; }
  if (channel == 3) { iLineColor = 4; lab = "2e2#mu"; }
  if (channel == 2) { iLineColor = 6; lab = "4e"; }

  bkg_qqzz->plotOn(frameM4l,LineColor(iLineColor),NormRange("largerange")) ;
  bkg_qqzz->plotOn(frameM4lz,LineColor(iLineColor),NormRange("zoomrange")) ;
    
//second shape to compare with (if previous comparison code unceommented)
  //bkg_qqzz_bkgd->plotOn(frameM4l,LineColor(1),NormRange("largerange")) ;
  //bkg_qqzz_bkgd->plotOn(frameM4lz,LineColor(1),NormRange("zoomrange")) ;
    
  
  double normalizationBackground_qqzz = bkg_qqzz->createIntegral( RooArgSet(*ZZMass), Range("fullrange") )->getVal();
  cout << "Norm all = " << normalizationBackground_qqzz << endl;
    
  frameM4l->GetXaxis()->SetTitle("m_{4l} [GeV]");
  frameM4l->GetYaxis()->SetTitle("a.u.");
  frameM4lz->GetXaxis()->SetTitle("m_{4l} [GeV]");
  frameM4lz->GetYaxis()->SetTitle("a.u.");

  char lname[192];
  sprintf(lname,"qq #rightarrow ZZ #rightarrow %s", lab.c_str() );
  char lname2[192];
  sprintf(lname2,"Shape Model, %s", lab.c_str() );
  // dummy!
  TF1* dummyF = new TF1("dummyF","1",0.,1.);
  TH1F* dummyH = new TH1F("dummyH","",1, 0.,1.);
  dummyF->SetLineColor( iLineColor );
  dummyF->SetLineWidth( 2 );

  dummyH->SetLineColor( kBlue );
  TLegend * box2 = new TLegend(0.4,0.70,0.80,0.90);
  box2->SetFillColor(0);
  box2->SetBorderSize(0);
  box2->AddEntry(dummyH,"Simulation (POWHEG+Pythia)  ","pe");
  box2->AddEntry(dummyH,lname,"");
  box2->AddEntry(dummyH,"","");
  box2->AddEntry(dummyF,lname2,"l");
    
  TPaveText *pt = new TPaveText(0.15,0.955,0.4,0.99,"NDC");
  pt->SetFillColor(0);
  pt->SetBorderSize(0);
  pt->AddText("CMS Preliminary 2012");
  TPaveText *pt2 = new TPaveText(0.84,0.955,0.99,0.99,"NDC");
  pt2->SetFillColor(0);
  pt2->SetBorderSize(0);
  pt2->AddText("#sqrt{s} = 7 TeV"); 		

  TCanvas *c = new TCanvas("c","c",800,600);
  c->cd();
  frameM4l->Draw();
  frameM4l->GetYaxis()->SetRangeUser(0,0.4);
  if(channel == 3)frameM4l->GetYaxis()->SetRangeUser(0,0.6);
  box2->Draw();
  pt->Draw();
  pt2->Draw();
  TString outputPath = "bkgFigs";
  outputPath = outputPath+ (long) sqrts + "TeV/";
  outputName =  outputPath + "bkgqqzz_" + schannel;
  c->SaveAs(outputName + ".eps");
  c->SaveAs(outputName + ".png");
    
  TCanvas *c2 = new TCanvas("c2","c2",1000,500);
  c2->Divide(2,1);
  c2->cd(1);
  frameM4l->Draw();
  box2->Draw("same");
  c2->cd(2);
  frameM4lz->Draw();
  box2->Draw("same");
  
  outputName = outputPath + "bkgqqzz_" + schannel + "_z";
  c2->SaveAs(outputName + ".eps");
  c2->SaveAs(outputName + ".png");

  /* TO make the ratio btw 2 shapes, if needed for compairson
  TCanvas *c3 = new TCanvas("c3","c3",1000,500);
   if(sqrts==7)
    sprintf(outputName, "bkgFigs7TeV/bkgqqzz_%s_ratio.eps",schannel.c_str());
  else if(sqrts==8)
    sprintf(outputName, "bkgFigs8TeV/bkgqqzz_%s_ratio.eps",schannel.c_str());

   const int nPoints = 501.;
  double masses[nPoints] ;
  int j=0;
  for (int i=100; i<601; i++){
    masses[j] = i;
    j++;
  }
  cout<<j<<endl;
  double effDiff[nPoints];
  for (int i = 0; i < nPoints; i++){
    ZZMass->setVal(masses[i]);
    double eval = (bkg_qqzz_bkgd->getVal(otherASet)-bkg_qqzz->getVal(myASet))/(bkg_qqzz->getVal(myASet));
    //cout<<bkg_qqzz_bkgd->getVal(otherASet)<<" "<<bkg_qqzz->getVal(myASet)<<" "<<eval<<endl;
    effDiff[i]=eval;
  }
  TGraph* grEffDiff = new TGraph( nPoints, masses, effDiff );
  grEffDiff->SetMarkerStyle(20);
  grEffDiff->Draw("AL");

  //c3->SaveAs(outputName);
  */

  outputName = outputPath + "bkgqqzz_" + schannel + "_z.root";
  TFile* outF = new TFile(outputName,"RECREATE");
  outF->cd();
  c2->Write();
  frameM4l->Write();
  frameM4lz->Write();	
  outF->Close();


  delete c;
  delete c2;
}
示例#25
0
void compareSystVariable( const std::string& dirName, const std::string& channel, const std::string& dataset, TTree* tree_central, TFile* file_systUp, TFile* file_systDown, const std::string& fullSelection, const std::string& systName, const std::string& varName, const std::string& axisTitle, const std::string& units, int nBins, float xMin, float xMax, const std::string& suffix) {


  DrawBase* db = new DrawBase("syst" );

  TTree* tree_systUp = (TTree*)file_systUp->Get(dataset.c_str());
  TTree* tree_systDown = (file_systDown!=0) ? (TTree*)file_systDown->Get(dataset.c_str()) : 0;

  TH1D* h1_central = new TH1D("central", "", nBins, xMin, xMax);
  TH1D* h1_systUp = new TH1D("systUp", "", nBins, xMin, xMax);
  TH1D* h1_systDown = new TH1D("systDown", "", nBins, xMin, xMax);

  h1_central->Sumw2();
  h1_systUp->Sumw2();
  h1_systDown->Sumw2();

  tree_central->Project( "central", varName.c_str(), fullSelection.c_str() );
  tree_systUp->Project( "systUp", varName.c_str(), fullSelection.c_str() );
  if( tree_systDown!=0 )
    tree_systDown->Project( "systDown", varName.c_str(), fullSelection.c_str() );

  h1_central ->SetLineColor(kBlack);
  h1_systUp  ->SetLineColor(kGreen);
  h1_systDown->SetLineColor(kRed);

  h1_central ->SetLineWidth(2);
  h1_systUp  ->SetLineWidth(2);
  h1_systDown->SetLineWidth(2);

  //h1_systUp  ->SetLineStyle(2);
  //h1_systDown->SetLineStyle(2);


  TLegend* legend = new TLegend( 0.6, 0.66, 0.9, 0.92, dataset.c_str() );
  legend->SetTextFont(42);
  legend->SetFillColor(kWhite);
  legend->SetTextSize(0.038);
  legend->SetTextColor(kBlack);
  legend->AddEntry( h1_central, "Central", "L" );
  std::string systUp_text = systName + " +1#sigma";
  std::string systDown_text = systName + " -1#sigma";
  legend->AddEntry( h1_systUp, systUp_text.c_str(), "L" );
  if( tree_systDown!=0 )
    legend->AddEntry( h1_systDown, systDown_text.c_str(), "L" );


  float yMax = 1.6*h1_central->GetMaximum();


  TH2D* h2_axes = new TH2D( "axes", "", 10, xMin, xMax, 10, 0., yMax);
  std::string xTitle = axisTitle;
  if( units!="" ) xTitle = xTitle + " [" + units + "]";
  h2_axes->SetXTitle(xTitle.c_str());
  h2_axes->SetYTitle( "Events" );

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


  TPaveText* labelTop = db->get_labelTop();

  h2_axes->Draw();
  legend->Draw("same");   
  labelTop->Draw("same");
  h1_central->Draw("h same");
  h1_systUp->Draw("h same");
  if( tree_systDown!=0 )
    h1_systDown->Draw("h same");


  gPad->RedrawAxis();

  std::string canvasName = dirName + "/" + channel + "/syst" + systName + "_" + varName + "_" + dataset + "_" + channel;
  if( suffix!="" ) canvasName = canvasName + "_" + suffix;
  std::string canvasName_eps = canvasName + ".eps";
  std::string canvasName_png = canvasName + ".png";

  c1->SaveAs(canvasName_eps.c_str());
  c1->SaveAs(canvasName_png.c_str());


  delete db;

  delete h1_central;
  delete h1_systUp;
  delete h1_systDown;

  delete h2_axes;

  delete legend;
  delete c1;



}
void Overlay_NeutralEnergyMeanNeutralEfficient()
{
   std::string canvasName = "canvas";
   std::string canvasTitle = "Neutral energy mean, N_{n} != 0";
   int canvasX1 = 200;
   int canvasY1 = 52;
   int canvasX2 = 700;
   int canvasY2 = 650;
   int nPoints = 6;
   int nGraphs = 5;
   int neutralEnergy = 10;

   double zero [] = {0, 0, 0, 0, 0, 0, 0, 0};
   double energies[] = {10, 20, 30, 40, 50};
   double distances[] = {5, 10, 15, 20, 25, 30};

   std::string graphXTitle = "Distance between showers [cm]";
   std::string graphYTitle = "<E_{neutral}> with N_{n}!=0";
   double rangeUserXMin = 0;
   double rangeUserXMax = 35;
   double rangeUserYMin = 0.0001;
   double rangeUserYMax = 20;

   TCanvas *pCanvas = new TCanvas(canvasName.c_str(), canvasTitle.c_str(), canvasX1, canvasY1, canvasX2, canvasY2);
   pCanvas->SetFillColor(0);
   pCanvas->SetBorderMode(0);
   pCanvas->SetBorderSize(2);
   pCanvas->SetTickx(1);
   pCanvas->SetTicky(1);
   pCanvas->SetLeftMargin(0.15);
   pCanvas->SetRightMargin(0.03);
   pCanvas->SetTopMargin(0.05);
   pCanvas->SetBottomMargin(0.14);
   pCanvas->SetFrameBorderMode(0);
   pCanvas->SetFrameBorderMode(0);

   TH1F *pH = new TH1F("pouette", "", rangeUserXMax-rangeUserXMin, rangeUserXMin, rangeUserXMax);
   pH->SetMinimum(rangeUserYMin);
   pH->SetMaximum(rangeUserYMax);
   pH->Draw();
   gStyle->SetOptStat(0);
   pH->GetYaxis()->SetTitle(graphYTitle.c_str());
   pH->GetXaxis()->SetTitle(graphXTitle.c_str());
   pH->GetYaxis()->SetLabelFont(42);
   pH->GetYaxis()->SetTitleSize(0.05);
   pH->GetYaxis()->SetTitleOffset(1);
   pH->GetYaxis()->SetTitleFont(42);
   pH->GetYaxis()->SetLabelSize(0.045);

   TLegend *leg = new TLegend(0.3,0.55,0.8,0.8,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(0);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetTextSize(0.03);

   int currentColor = 1;

   for(unsigned int e=0 ; e<nGraphs ; e++)
   {
     int energy = energies[e];
  
     double *data = new double[nPoints];
     double *dataError = zero;//new double[nPoints];

     std::stringstream fileName;
     fileName << "data_neutralERecNeutralEfficient_ArborPFA_Test\ Beam_" << energy << "Gev.txt";
     readData(fileName.str(), data, nPoints);
     
     // fileName.str("");
     // fileName << "fichier_data_error_energy_" << energy << "GeV.txt";
     // readData(fileName.str(), dataError, nPoints);
   
     TGraphErrors *gre = 0;
     std::stringstream graphName;
     graphName << "Charged particle energy = " << energy << " GeV";
     gre = new TGraphErrors(nPoints, distances, data, zero, dataError);
     gre->SetName(graphName.str().c_str());
     gre->SetTitle(graphName.str().c_str());
     gre->SetLineColor(currentColor);
     gre->SetMarkerColor(currentColor);
     gre->SetMarkerStyle(23);
     gre->SetMarkerSize(1.2);
     gre->Draw("lp same");
   
     TLegendEntry *entry = 0;
     entry=leg->AddEntry(gre, graphName.str().c_str(), "lp");
     entry->SetFillStyle(1001);
     entry->SetMarkerColor(currentColor);
     entry->SetMarkerStyle(23);
     entry->SetMarkerSize(1);

     currentColor++;
   }

   TPaveText *pt = new TPaveText(0.55, 0.2, 0.93, 0.3, "tbNDC");
   pt->SetTextSize(0.05);
   pt->SetTextColor(kGray+2);
   pt->SetFillColor(0);
   pt->SetLineWidth(0);
   pt->SetBorderSize(0);
   pt->AddText("CALICE Preliminary");
   pt->SetTextFont(62);
   pt->Draw();
   
   leg->Draw();

   pCanvas->Modified();
   pCanvas->cd();
   pCanvas->SetSelected(pCanvas);
}
示例#27
0
void drawSignalBGData( const std::string& dirName, const std::string& channel, const std::string& var, const std::string& varName, const std::string& units, int nBins, float xMin, float xMax, TTree* tree_sig, TTree* tree_bg, TTree* tree_data, const std::string& fullSelection, const std::string& fullSelection_sidebands, const std::string& suffix ) {


  DrawBase* db = new DrawBase("sigbfdata" );

  TH1D* h1_data = new TH1D("data", "", nBins, xMin, xMax ); 
  TH1D* h1_sig = new TH1D("sig", "", nBins, xMin, xMax ); 
  TH1D* h1_bg = new TH1D("bg", "", nBins, xMin, xMax ); 

  h1_data->Sumw2();
  h1_sig->Sumw2();
  h1_bg->Sumw2();

  h1_sig->SetFillColor(46);
  h1_bg->SetFillColor(38);
  h1_sig->SetLineColor(46);
  h1_bg->SetLineColor(38);

  h1_sig->SetFillStyle(3004);
  h1_bg->SetFillStyle(3005);


  if( BLINDED )
    tree_data->Project( "data", var.c_str(), fullSelection_sidebands.c_str() );
  else
    tree_data->Project( "data", var.c_str(), fullSelection.c_str() );
  tree_sig->Project(  "sig",  var.c_str(), fullSelection.c_str() );
  tree_bg ->Project(  "bg",   var.c_str(), fullSelection.c_str() );


  float data_integral = h1_data->Integral();
  if( data_integral < 2 ) data_integral=3.;
  h1_sig->Scale( data_integral/h1_sig->Integral() );
  h1_bg->Scale( data_integral/h1_bg->Integral() );
  


  TGraphAsymmErrors* gr_data = fitTools::getGraphPoissonErrors( h1_data, false );
  gr_data->SetMarkerStyle(20);  
  gr_data->SetMarkerSize(1.3);  
   

  TString category_tstr(channel);
  bool isLeptonic = category_tstr.Contains("leptonic");

  std::string channelName_legend = (isLeptonic) ? "Leptonic Channel" : "Hadronic Channel";


  TLegend* legend = new TLegend( 0.55, 0.66, 0.9, 0.92, channelName_legend.c_str() );
  legend->SetTextFont(42);
  legend->SetFillColor(kWhite);
  legend->SetTextSize(0.038);
  legend->SetTextColor(kBlack);
  if( useCS )
    legend->AddEntry( gr_data, "Data Control Sample", "P" );
  else {
    if( BLINDED ) {
      legend->AddEntry( gr_data, "Sidebands Data", "P" );
    } else {
      legend->AddEntry( gr_data, "Sidebands Data", "P" );
    }
  }
  legend->AddEntry( h1_sig, "tHq (125)", "F" );
  legend->AddEntry( h1_bg, "ttH (125)", "F" );


  float yMax = 0.;
  float yMax_data = h1_data->GetMaximum();
  if( yMax_data>0. ) {
    if( yMax_data < 1.5 ) yMax=3.5;
    else if( yMax_data < 2.5 ) yMax=6.;
    else                       yMax=yMax_data*2.;
  } else {
    float yMax_mc = h1_sig->GetMaximum()*1.2;
    yMax = 1.8*yMax_mc;
  }


  TH2D* h2_axes = new TH2D( "axes", "", 10, xMin, xMax, 10, 0., yMax);
  std::string xTitle = varName;
  if( units!="" ) xTitle = xTitle + " [" + units + "]";
  h2_axes->SetXTitle(xTitle.c_str());
  h2_axes->SetYTitle( "Arbitrary Units" );

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


  TPaveText* labelTop = db->get_labelTop();

  h2_axes->Draw();
  legend->Draw("same");   
  labelTop->Draw("same");
  h1_bg->Draw("h same");
  h1_sig->Draw("h same");
  gr_data->Draw("p same");


  gPad->RedrawAxis();

  std::string canvasName = dirName + "/" + channel + "/" + var + "_SignalBGData_" + channel;
  if( suffix!="" ) canvasName = canvasName + "_" + suffix;
  std::string canvasName_eps = canvasName + ".eps";
  std::string canvasName_png = canvasName + ".png";

  c1->SaveAs(canvasName_eps.c_str());
  c1->SaveAs(canvasName_png.c_str());

  delete h1_data;
  delete h1_sig;
  delete h1_bg;

  delete h2_axes;

  delete legend;
  delete c1;

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

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

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

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


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

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

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

  blurb->Draw();

  canvas->RedrawAxis();

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

  plots.calculateIntercepts();
  
}
void para_12TeV_2Lep_plots_All()
{
//=========Macro generated from canvas: c1/Parameter1
//=========  (Sun Nov 22 20:05:00 2015) by ROOT version6.02/12
    TCanvas *c1 = new TCanvas("c1", "Parameter1",0,22,1000,600);
    gStyle->SetOptStat(0);
    c1->Range(-4.375,-0.2745458,39.375,2.490986);
    c1->SetFillColor(0);
    c1->SetBorderMode(0);
    c1->SetBorderSize(2);
    c1->SetGridx();
    c1->SetGridy();
    c1->SetFrameBorderMode(0);
    c1->SetFrameBorderMode(0);

    TH1F *NuisanceParameterFreed2 = new TH1F("NuisanceParameterFreed2","Mu",35,0,35);
    NuisanceParameterFreed2->SetMinimum(0.00200744);
    NuisanceParameterFreed2->SetMaximum(2.214433);
    NuisanceParameterFreed2->SetStats(0);

    Int_t ci;      // for color index setting
    TColor *color; // for color definition with alpha
    ci = TColor::GetColor("#000099");
    NuisanceParameterFreed2->SetLineColor(ci);
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(1,"MUONS_MS");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(2,"Luminosity");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(3,"XS_Zb");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(4,"FT_EFF_Eigen_C_2");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(5,"MUON_EFF_TrigStatUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(6,"FT_EFF_Eigen_C_3");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(7,"FT_EFF_Eigen_B_0");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(8,"MUON_EFF_SYS");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(9,"MUON_EFF_STAT");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(10,"FT_EFF_Eigen_Light_3");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(11,"FT_EFF_Eigen_Light_4");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(12,"global");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(13,"MUONS_SCALE");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(14,"MUON_ISO_STAT");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(15,"FT_EFF_Eigen_C_0");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(16,"EL_EFF_Iso_TotalCorrUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(17,"FT_EFF_Eigen_B_1");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(18,"XS_diboson");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(19,"XS_st");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(20,"MUON_EFF_TrigSystUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(21,"EG_RESOLUTION_ALL");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(22,"FT_EFF_Eigen_B_2");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(23,"MUONS_ID");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(24,"EL_EFF_Reco_TotalCorrUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(25,"EG_SCALE_ALL");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(26,"FT_EFF_extrapolation");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(27,"FT_EFF_Eigen_Light_1");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(28,"FT_EFF_Eigen_Light_2");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(29,"FT_EFF_Eigen_C_1");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(30,"MUON_ISO_SYS");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(31,"FT_EFF_Eigen_Light_0");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(32,"EL_EFF_ID_TotalCorrUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(33,"XS_Zl");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(34,"XS_Zc");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(35,"XS_ttbar");
    NuisanceParameterFreed2->GetXaxis()->SetLabelFont(42);
    NuisanceParameterFreed2->GetXaxis()->SetLabelSize(0.035);
    NuisanceParameterFreed2->GetXaxis()->SetTitleSize(0.035);
    NuisanceParameterFreed2->GetXaxis()->SetTitleFont(42);
    NuisanceParameterFreed2->GetYaxis()->SetTitle("#mu_{best}");
    NuisanceParameterFreed2->GetYaxis()->SetLabelFont(42);
    NuisanceParameterFreed2->GetYaxis()->SetLabelSize(0.035);
    NuisanceParameterFreed2->GetYaxis()->SetTitleSize(0.035);
    NuisanceParameterFreed2->GetYaxis()->SetTitleFont(42);
    NuisanceParameterFreed2->GetZaxis()->SetLabelFont(42);
    NuisanceParameterFreed2->GetZaxis()->SetLabelSize(0.035);
    NuisanceParameterFreed2->GetZaxis()->SetTitleSize(0.035);
    NuisanceParameterFreed2->GetZaxis()->SetTitleFont(42);
    NuisanceParameterFreed2->Draw("hist");

    Double_t _fx1002[37] = {
        0,
        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,
        33.5,
        34.5,
        0
    };
    Double_t _fy1002[37] = {
        0,
        0.00200744,
        2.065197,
        2.090439,
        2.097085,
        2.102307,
        2.102459,
        2.103994,
        2.109032,
        2.110826,
        2.110827,
        2.110944,
        2.111107,
        2.111297,
        2.111303,
        2.111389,
        2.11147,
        2.1115,
        2.112008,
        2.112152,
        2.112174,
        2.112884,
        2.113456,
        2.113847,
        2.114265,
        2.114548,
        2.11588,
        2.116422,
        2.117402,
        2.123061,
        2.129504,
        2.131184,
        2.133743,
        2.13776,
        2.138737,
        2.214433,
        0
    };
    Double_t _fex1002[37] = {
        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,
        0,
        0
    };
    Double_t _fey1002[37] = {
        0,
        0,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10
    };
    TGraphErrors *gre = new TGraphErrors(37,_fx1002,_fy1002,_fex1002,_fey1002);
    gre->SetName("");
    gre->SetTitle("");
    gre->SetFillColor(1);
    gre->SetMarkerStyle(20);
    gre->SetMarkerSize(1.2);

    TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","",100,0,37.95);
    Graph_Graph1002->SetMinimum(-12.22144);
    Graph_Graph1002->SetMaximum(14.43588);
    Graph_Graph1002->SetDirectory(0);
    Graph_Graph1002->SetStats(0);

    ci = TColor::GetColor("#000099");
    Graph_Graph1002->SetLineColor(ci);
    Graph_Graph1002->GetXaxis()->SetLabelFont(42);
    Graph_Graph1002->GetXaxis()->SetLabelSize(0.035);
    Graph_Graph1002->GetXaxis()->SetTitleSize(0.035);
    Graph_Graph1002->GetXaxis()->SetTitleFont(42);
    Graph_Graph1002->GetYaxis()->SetLabelFont(42);
    Graph_Graph1002->GetYaxis()->SetLabelSize(0.035);
    Graph_Graph1002->GetYaxis()->SetTitleSize(0.035);
    Graph_Graph1002->GetYaxis()->SetTitleFont(42);
    Graph_Graph1002->GetZaxis()->SetLabelFont(42);
    Graph_Graph1002->GetZaxis()->SetLabelSize(0.035);
    Graph_Graph1002->GetZaxis()->SetTitleSize(0.035);
    Graph_Graph1002->GetZaxis()->SetTitleFont(42);
    gre->SetHistogram(Graph_Graph1002);

    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);
    TLegendEntry *entry=leg->AddEntry("","global","P");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(20);
    entry->SetMarkerSize(1.2);
    entry->SetTextFont(72);
    leg->Draw();

    TPaveText *pt = new TPaveText(0.4694177,0.94,0.5305823,0.995,"blNDC");
    pt->SetName("title");
    pt->SetBorderSize(0);
    pt->SetFillColor(0);
    pt->SetFillStyle(0);
    pt->SetTextFont(42);
    TText *AText = pt->AddText("Mu");
    pt->Draw();
    c1->Modified();
    c1->cd();
    c1->SetSelected(c1);
}
示例#30
0
// Draw label for Decay Channel in upper left corner of plot
void DrawPrelimLabel(int cmsprelim, double textSize) {

    TPaveText *cms = new TPaveText();
    cms->AddText("CMS");

    cms->SetX1NDC(      gStyle->GetPadLeftMargin() + gStyle->GetTickLength()        );
    cms->SetY1NDC(1.0 - gStyle->GetPadTopMargin()  - gStyle->GetTickLength() - 0.05 );
    cms->SetX2NDC(      gStyle->GetPadLeftMargin() + gStyle->GetTickLength() + 0.15 );
    cms->SetY2NDC(1.0 - gStyle->GetPadTopMargin()  - gStyle->GetTickLength()        );

    cms->SetFillStyle(0);
    cms->SetBorderSize(0);
    if (textSize!=0) cms->SetTextSize(textSize*1.1);
    cms->SetTextAlign(12);
    cms->SetTextFont(61);
    cms->Draw("same");

    if(cmsprelim > 0) {
      TPaveText *extra = new TPaveText();
      if(cmsprelim == 2) { extra->AddText("Private Work"); }
      else { extra->AddText("Preliminary"); }

      extra->SetX1NDC(      gStyle->GetPadLeftMargin() + gStyle->GetTickLength()        );
      extra->SetY1NDC(1.0 - gStyle->GetPadTopMargin()  - gStyle->GetTickLength() - 0.10 );
      extra->SetX2NDC(      gStyle->GetPadLeftMargin() + gStyle->GetTickLength() + 0.15 );
      extra->SetY2NDC(1.0 - gStyle->GetPadTopMargin()  - gStyle->GetTickLength() - 0.05 );

      extra->SetFillStyle(0);
      extra->SetBorderSize(0);
      if (textSize!=0) extra->SetTextSize(textSize);
      extra->SetTextAlign(12);
      extra->SetTextFont(52);
      extra->Draw("same");
    }
}