Beispiel #1
0
TH1* makehist(TString hist){
  TH1* hn_40 = makeHist("40",hist, 414,0);
  TH1* hn_50 = makeHist("50",hist,402,0);
  TH1* hn_60 = makeHist("60",hist,616,0);
  TH1* hn_70 = makeHist("70",hist,432,0);
  TH1* hn_80 = makeHist("80",hist,600,0);
  /*TH1* hn_90 = makeHist("90",hist,600,0);
  TH1* hn_100 = makeHist("100",hist,600,0);
  TH1* hn_200 = makeHist("200",hist,600,0);
  TH1* hn_300 = makeHist("300",hist,600,0);
  TH1* hn_500 = makeHist("500",hist,600,0);*/

  TH1* href_40 = makeRefHist("40");
  TH1* href_50 = makeRefHist("50");
  TH1* href_60 = makeRefHist("60");
  TH1* href_70 = makeRefHist("70");
  TH1* href_80 = makeRefHist("80");
  /*  TH1* href_90 = makeRefHist("90");
  TH1* href_100 = makeRefHist("100");
  TH1* href_200 = makeRefHist("200");
  TH1* href_300 = makeRefHist("300");
  TH1* href_500 = makeRefHist("500");*/

  TH1F* heff = new TH1F("heff","heff", 10, 0., 10.);
  heff->SetBinContent(1, (hn_40->GetBinContent(2)/href_40->GetBinContent(2)));
  heff->SetBinContent(2, (hn_50->GetBinContent(2)/href_50->GetBinContent(2)));
  heff->SetBinContent(3, (hn_60->GetBinContent(2)/href_60->GetBinContent(2)));
  heff->SetBinContent(4, (hn_70->GetBinContent(2)/href_70->GetBinContent(2)));
  heff->SetBinContent(5, (hn_80->GetBinContent(2)/href_80->GetBinContent(2)));
  /*heff->SetBinContent(6, (hn_90->GetBinContent(2)/href_90->GetBinContent(2)));
  heff->SetBinContent(7, (hn_100->GetBinContent(2)/href_100->GetBinContent(2)));
  heff->SetBinContent(8, (hn_200->GetBinContent(2)/href_200->GetBinContent(2)));
  heff->SetBinContent(9, (hn_300->GetBinContent(2)/href_300->GetBinContent(2)));
  heff->SetBinContent(10, (hn_500->GetBinContent(2)/href_500->GetBinContent(2)));*/

  heff->GetXaxis()->SetBinLabel(1,"40");
  heff->GetXaxis()->SetBinLabel(2,"50");
  heff->GetXaxis()->SetBinLabel(3,"60");
  heff->GetXaxis()->SetBinLabel(4,"70");
  heff->GetXaxis()->SetBinLabel(5,"80");
  /*heff->GetXaxis()->SetBinLabel(6,"90");
  heff->GetXaxis()->SetBinLabel(7,"100");
  heff->GetXaxis()->SetBinLabel(8,"200");
  heff->GetXaxis()->SetBinLabel(9,"300");*/

  
  return heff;
}
void LLGAnalysis::SetupGenHTAnalysis() {

    // setup the cutflow

    // and the histograms
    makeHist( "GenLevel_HT", 48, 390, 610, "Gen Level HT", "Number of Events" );
    return;
}
Beispiel #3
0
//------------------------------------//
// Main
//------------------------------------//
void AnaEField()
{

  // Make Canvas 
  TCanvas* can = makeCanvas("can");
  can->SetLogy();
  can->SetGridx();
  can->SetGridy();

  // Define the function here with parameters:
  // [0] = L
  // [1] = freq
  // [2] = k
  // [3] = n
  // [4] = sqrt(2pi) * mu * mu0
  TString func = "[4]*[0]*[1]*sin(x/57.2957)*exp(-pow([2]*[0],2)*pow(cos(x/57.2957)-1/[3],2)/2)";
  //TString func = "[4]*[1]*sin(x/57.2957)*exp(-pow([2]*[0],2)*pow(cos(x/57.2957)-1/[3],2)/2)";
  //TString func = "[4]*[0]*[1]*exp(-pow([2]*[0],2)*pow(cos(x/57.2957)-1/[3],2)/2)";

  // Now fix some of the variables:
  double freq = 1e9; //600e6; // Hz
  double c    = 3e8;   // m/s
  double n    = 1.3; //1.78;
  double k    = 2*TMath::Pi() * n * freq/c; // 1/m
  double Const= sqrt(2*TMath::Pi()) * 4 * TMath::Pi() * 1e-7 * 1;

  // Make a dummy histogram
  TH1F* h = makeHist("h",100,0,90,"Angle [deg]", "Field Strength",kBlack,0);
  h->Fill(1e10);
  h->SetMinimum(10);
  h->SetMaximum(3000);
  h->Draw();

  // Make two instances of the function
  TF1* f0 = new TF1("f0",func.Data(),0,90);
  setParam(f0,1.2,freq,k,n,Const,kBlack);

  TF1* f1 = new TF1("f1",func.Data(),0,90);
  setParam(f1,0.1,freq,k,n,Const,kBlue);
 
  // Draw
  f0->Draw("same");
  f1->Draw("same");
  
  // Add Legend
  TLegend* leg = makeLegend(0.15,0.3,0.7,0.9);
  leg->SetHeader("f = 600 MHz");
  leg->AddEntry(f0,"L = 1.2m","l");
  leg->AddEntry(f1,"L = 0.1m","l");
  leg->Draw("same");
  
  //can->SaveAs("../plots/quickAnalytic_600MHz.png");

}
Beispiel #4
0
bool UVarLog::setReplay(bool doOpen, const char * preName, const char * varName, UReplay * parent)
{
  if (not hasHist())
    makeHist(1, getElementCnt2(), 200.0);
  if (hasHist())
  {
    if (doOpen)
    {
      hist->replaySetBaseFileName(varName, preName);
      hist->setParent(parent);
    }
    hist->setReplay(doOpen);
    return hist->isReplayFileOpen();
  }
  else
    return false;
}
Beispiel #5
0
bool UVarLog::openLog(bool doOpen, const char * preName, const char * name)
{
  bool result = false;
  if (not hasHist())
    makeHist(1, getElementCnt2(), 200.0);
  if (hasHist())
  { // open or close log as needed
    bool hasUnloggedHist = hist->rowCnt > 0 and not hist->isLogOpen();
    if (preName != NULL and doOpen)
      hist->makeLogName(preName, name);
    hist->openLog(doOpen);
    // when log is opened and there is unloged data, then put history into log.
    if (hasUnloggedHist and hist->isLogOpen())
      hist->logAll();
    result = hist->isLogOpen();
  }
  return result;
};
void LLGAnalysis::SetupMETTriggerEfficiencyDetermination() {

    // setup the cutflow
    _cutFlow.insert(pair<string,int>("01_MuonTrigger", 0) );
    _cutFlow.insert(pair<string,int>("02_MuonMultiplicity", 0 ) );
    _cutFlow.insert(pair<string,int>("03_MuonTriggerMatching", 0) );
  
    // and the histograms
    makeHist("allEvents_MET_MHT", 1000, 0., 1000., 30, 0., 1000., "MET [GeV]", "MHT [GeV]", "Number of Events", "COLZ", 1.5, 1.5, 1.0 );
    makeHist("passedEvents_MET_MHT", 100, 0., 1000., 30, 0., 1000., "MET [GeV]", "MHT [GeV]", "Number of Events", "COLZ", 1.5, 1.5, 1.0 );
    makeHist("allEvents_MET", 100, 0., 1000., "MET [GeV]", "Number of Events");
    makeHist("passedEvents_MET", 100, 0., 1000., "MET [GeV]", "Number of Events");
    makeHist("allEvents_MHT", 100, 0., 1000., "MHT [GeV]", "Number of Events");
    makeHist("passedEvents_MHT", 100, 0., 1000., "MHT [GeV]", "Number of Events");

    return;
}
Beispiel #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    Load = new LoadImg;
    brightn = new bright;
    grayScale = new long [256];
    grayCumulativeScale = new long[256];

    for(int i = 0; i < 256; i++)
        grayScale[i] = 0;


    Img = &Load->lImg;
    copyImg = &Load->oImg;
    labelImg = Load->Img;

    labelImg->adjustSize();
    ui->scrollArea->setWidget(labelImg);

    //CustomPlot adjustments

    ui->customPlot->xAxis->setLabel("Scale");
    ui->customPlot->yAxis->setLabel("Number");
    ui->customPlot->xAxis->setRange(0, 255);
    ui->customPlot->yAxis->setRange(0, 1000);
    ui->customPlot->QCustomPlot::setInteractions(QCP::iRangeZoom);
    ui->customPlot->setInteraction(QCP::iRangeDrag, true);
    average = 0.0;

    connect(ui->LoadButton, SIGNAL(released()), Load, SLOT(Load()));
    connect(ui->slider, SIGNAL(valueChanged(int)), this, SLOT(applyS(int)));
    connect(ui->histBt, SIGNAL(released()), this, SLOT(makeHist()));



}
  p8766_d1x1y1->SetMarkerColor(2);
  p8766_d1x1y1->SetMarkerSize(1.0);

  void SetHistStyle(){
    gPad->SetTicks();
    gPad->SetLeftMargin(0.14);
    gPad->SetBottomMargin(0.16);
    gPad->SetTopMargin(0.02);
    gPad->SetRightMargin(0.02);
    gPad->SetLogx(1);
    gPad->SetLogy(1);
  }

  vandyStyle();
  TCanvas* c1 = makeMultiCanvas("c1","c1", true, true);
  TH1D *htemp = makeHist("htemp", "", "p_{T} (GeV/c)", "Yield", 200, 0.3, 150, kBlack);
  htemp->SetAxisRange(1e-13,950,"Y");
  fixedFontHist1D(htemp, 1.1, 1.1);
  SetHistStyle();
  htemp->Draw();
  p8766_d1x1y1->Draw("Psame");

/*
  TCanvas* c1 = makeMultiCanvas("c1","c1",2,2);
  TH1D *htemp = makeHist("htemp", "", "p_{T} (GeV/c)", "Yield", 200, 0.3, 150, kBlack);
  htemp->SetAxisRange(1e-13,950,"Y");
  fixedFontHist1D(htemp, 2.5, 2.5);
  c1->cd(1);  
  SetHistStyle();
  htemp->Draw();
  p8766_d1x1y1->Draw("Psame");
void LLGAnalysis::SetupWJetsTestRegion() {

    // setup the cutflow
    _cutFlow.insert(pair<string,int>("0_NoCut", 0) );
    _cutFlow.insert(pair<string,int>("1_Trigger", 0) );
    _cutFlow.insert(pair<string,int>("2_MuonVeto", 0) );
    _cutFlow.insert(pair<string,int>("3_ElectronVeto", 0) );
    _cutFlow.insert(pair<string,int>("4_HasPVJet", 0) );
    _cutFlow.insert(pair<string,int>("5_HasSV20", 0) );
    _cutFlow.insert(pair<string,int>("6_MET", 0) );
    _cutFlow.insert(pair<string,int>("6a_SVJetPT", 0 ) );
    _cutFlow.insert(pair<string,int>("7_DiJetMass", 0 ) );
    _cutFlow.insert(pair<string,int>("8_BVeto", 0) );
    _cutFlow.insert(pair<string,int>("9_SVPVDistance", 0) );
    
    // and the histograms 
    makeHist( "nBjetAtSV", 5, -0.5, 4.5, "Number of b-jets associated to SV", "Number of SV" );
    makeHist( "mJJSV", 100, 0., 500., "DiJet mass at SV", "Number of Jet Pairs" );
    makeHist( "nJetsSV", 7, -0.5, 6.5, "Number of Jets associated to SV", "Number of SV" );
    makeHist( "SVJet1Pt", 50, 0., 500., "SV Leading Jet pT [GeV]", "Number of SV" );
    makeHist( "SVJet2Pt", 50, 0., 500., "SV 2^{nd} Leading Jet pT [GeV]", "Number of SV" );
    makeHist( "SVJet3Pt", 50, 0., 500., "SV 3^{rd} Leading Jet pT [GeV]", "Number of SV" );
    makeHist( "SVJet4Pt", 50, 0., 500., "SV 4^{th} Leading Jet pT [GeV]", "Number of SV" );
    makeHist( "PVJet1Pt", 50, 0., 1000., "PV Leading Jet pT [GeV]", "Number of Events" );
    makeHist( "PVJet2Pt", 50, 0., 500., "PV 2^{nd} Leading Jet pT [GeV]", "Number of Events" );
    makeHist( "PVJet3Pt", 50, 0., 500., "PV 3^{rd} Leading Jet pT [GeV]", "Number of Events" );
    makeHist( "PVJet4Pt", 50, 0., 500., "PV 4^{th} Leading Jet pT [GeV]", "Number of Events" );
    makeHist( "nJetsTotal", 26, -0.5, 25.5, "Number of Jets with p_{T} > 30 GeV", "Number of Events" );
    makeHist( "BJet1Pt", 50, 0., 500., "Leading B-tagged Jet p_{T} [GeV]", "Number of Events" );
    makeHist( "BJet2Pt", 50, 0., 500., "Subleading B-tagged Jet p_{T} [GeV]", "Number of Events" );
    makeHist( "BJet3Pt", 50, 0., 500., "3^{rd} leading B-tagged Jet p_{T} [GeV]", "Number of Events" );
    makeHist( "BJet4Pt", 50, 0., 500., "4^{th} leading B-tagged Jet p_{T} [GeV]", "Number of Events" );
    makeHist( "JetLeptonDr", 50, 0., 6., "#DeltaR(jet, electron)", "# Jet-Electron Pairs" ); 
    makeHist( "nPVWithJet75", 10, -0.5, 9.5, "Number of PV with >= 1 Jet > 75 GeV", "# events" );
    makeHist( "nSVWith2Jets30", 10, -0.5, 9.5, "Number of SV with >= 2 Jets > 30 GeV", "# events" );
    makeHist( "mjjvsleadingjetpt", 100, 0., 500., 100, 0., 500., "DiJet Mass at SV [GeV]", "Leading Jet p_{T} at SV [GeV]", "Number of Events", "COLZ" );
    makeHist( "distancePVSV", 40, 0., 40., "Distance between leading PV and SV [mm]", "Number of PV-SV pairs" );

    for( double jptpv = 30.; jptpv <= 401.; jptpv += 5. ) {
      std::vector<double> yield;
      //for( double jptsv = 40.; jptsv <= 401.; jptsv += 10. ) {
      //for( double jptsv = 15.; jptsv <= 201.; jptsv += 5. ) {
      for( double jptsv = 0.; jptsv <= 50.; jptsv += 2. ) {
        yield.push_back( 0. );
      }
      _yields2DOptimisation.push_back( yield );
    }

    passedLogFile.open( "passedEvents.log", ios::out );
    return;
}
Beispiel #10
0
TH1F* makehist(TString hist){
  TH1F* hn_40 = makeHist("40",hist, 414,0);

  TH1F* hn_50 = makeHist("50",hist,402,0);
  TH1F* hn_60 = makeHist("60",hist,616,0);
  TH1F* hn_70 = makeHist("70",hist,432,0);
  TH1F* hn_80 = makeHist("80",hist,600,0);
  TH1F* hn_90 = makeHist("90",hist,600,0);
  /*TH1F* hn_100 = makeHist("100",hist,600,0);
  TH1F* hn_200 = makeHist("200",hist,600,0);
  TH1F* hn_300 = makeHist("300",hist,600,0);
  TH1F* hn_500 = makeHist("500",hist,600,0);*/

  TH1F* href_40 = makeRefHist("40");
  cout << "Details on 40 GeV hist: " << hist << " bin content = " << hn_40->GetBinContent(2) << " / " <<  href_40->GetBinContent(2)<< " = " <<  hn_40->GetBinContent(2)/href_40->GetBinContent(2)   << endl;
  TH1F* href_50 = makeRefHist("50");
  TH1F* href_60 = makeRefHist("60");
  TH1F* href_70 = makeRefHist("70");
  TH1F* href_80 = makeRefHist("80");
    TH1F* href_90 = makeRefHist("90");
    /*TH1F* href_100 = makeRefHist("100");
  TH1F* href_200 = makeRefHist("200");
  TH1F* href_300 = makeRefHist("300");
  TH1F* href_500 = makeRefHist("500");*/


    TH1F* np_40 = makenpHist(hist, 414,0);
    TH1F* np_50 = makenpHist(hist,402,0);
    TH1F* np_60 = makenpHist(hist,616,0);
    TH1F* np_70 = makenpHist(hist,432,0);
    TH1F* np_80 = makenpHist(hist,600,0);
    TH1F* np_90 = makenpHist(hist,600,0);


    TH1F* cf_40 = makecfHist(hist, 414,0);
    TH1F* cf_50 = makecfHist(hist,402,0);
    TH1F* cf_60 = makecfHist(hist,616,0);
    TH1F* cf_70 = makecfHist(hist,432,0);
    TH1F* cf_80 = makecfHist(hist,600,0);
    TH1F* cf_90 = makecfHist(hist,600,0);

    TH1F* mc_40 = makemcHist(hist, 414,0);
    TH1F* mc_50 = makemcHist(hist,402,0);
    TH1F* mc_60 = makemcHist(hist,616,0);
    TH1F* mc_70 = makemcHist(hist,432,0);
    TH1F* mc_80 = makemcHist(hist,600,0);
    TH1F* mc_90 = makemcHist(hist,600,0);
    
    
  TH1F* heff = new TH1F("heff","heff", 10, 0., 10.);
  heff->SetBinContent(1, (hn_40->GetBinContent(2)/href_40->GetBinContent(2))/ (1 + sqrt(np_40->GetBinContent(2) + cf_40->GetBinContent(2) + mc_40->GetBinContent(2)+ (0.28*np_40->GetBinContent(2))*(0.28*np_40->GetBinContent(2)))));
  heff->SetBinContent(2, (hn_50->GetBinContent(2)/href_50->GetBinContent(2))/ (1 + sqrt(np_50->GetBinContent(2) + cf_50->GetBinContent(2) + mc_50->GetBinContent(2)+ (0.28*np_50->GetBinContent(2))*(0.28*np_50->GetBinContent(2)))));
  heff->SetBinContent(3, (hn_60->GetBinContent(2)/href_60->GetBinContent(2))/ (1 + sqrt(np_60->GetBinContent(2) + cf_60->GetBinContent(2) + mc_60->GetBinContent(2)+ (0.28*np_60->GetBinContent(2))*(0.28*np_60->GetBinContent(2)))));
  heff->SetBinContent(4, (hn_70->GetBinContent(2)/href_70->GetBinContent(2))/ (1 + sqrt(np_70->GetBinContent(2) + cf_70->GetBinContent(2) + mc_70->GetBinContent(2)+ (0.28*np_70->GetBinContent(2))*(0.28*np_70->GetBinContent(2)))));
  heff->SetBinContent(5, (hn_80->GetBinContent(2)/href_80->GetBinContent(2))/ (1 + sqrt(np_80->GetBinContent(2) + cf_80->GetBinContent(2) + mc_80->GetBinContent(2)+ (0.28*np_80->GetBinContent(2))*(0.28*np_80->GetBinContent(2)))));
  heff->SetBinContent(6, (hn_90->GetBinContent(2)/href_90->GetBinContent(2))/ (1 + sqrt(np_90->GetBinContent(2) + cf_90->GetBinContent(2) + mc_90->GetBinContent(2)+ (0.28*np_90->GetBinContent(2))*(0.28*np_90->GetBinContent(2)))));

  /*heff->SetBinContent(7, (hn_100->GetBinContent(2)/href_100->GetBinContent(2)));
  heff->SetBinContent(8, (hn_200->GetBinContent(2)/href_200->GetBinContent(2)));
  heff->SetBinContent(9, (hn_300->GetBinContent(2)/href_300->GetBinContent(2)));
  heff->SetBinContent(10, (hn_500->GetBinContent(2)/href_500->GetBinContent(2)));*/

  heff->GetXaxis()->SetBinLabel(1,"40");
  heff->GetXaxis()->SetBinLabel(2,"50");
  heff->GetXaxis()->SetBinLabel(3,"60");
  heff->GetXaxis()->SetBinLabel(4,"70");
  heff->GetXaxis()->SetBinLabel(5,"80");
  heff->GetXaxis()->SetBinLabel(6,"90");
  /*heff->GetXaxis()->SetBinLabel(7,"100");
  heff->GetXaxis()->SetBinLabel(8,"200");
  heff->GetXaxis()->SetBinLabel(9,"300");*/

  
  return heff;
}
void LLGAnalysis::SetupTTJetsCR() {

    // setup the cutflow
    _cutFlow.insert(pair<string,int>("0_NoCut", 0) );
    _cutFlow.insert(pair<string,int>("1_Trigger", 0) );
    _cutFlow.insert(pair<string,int>("2_AtLeastOneLepton", 0) );
    _cutFlow.insert(pair<string,int>("3_MET", 0) );
    _cutFlow.insert(pair<string,int>("4_NJets", 0) );
    _cutFlow.insert(pair<string,int>("5_NBJets_CSVv2L", 0) );
    _cutFlow.insert(pair<string,int>("5_NBJets_CSVv2M", 0) );
    _cutFlow.insert(pair<string,int>("5_NBJets_CSVv2T", 0) );
    _cutFlow.insert(pair<string,int>("5_NBJets_JPL", 0) );
    _cutFlow.insert(pair<string,int>("5_NBJets_JPM", 0) );
    _cutFlow.insert(pair<string,int>("5_NBJets_JPT", 0) );

    makeHist( "met", 600, 0., 600., "MET [GeV]", "Number of Events" );
    makeHist( "nJet", 40, 0, 40, "# Jets", "Number of Events" ); 
    makeHist( "nBJet_CSVv2L", 10, 0, 10, "# B-Jets", "Number of Events" ); 
    makeHist( "nBJet_CSVv2M", 10, 0, 10, "# B-Jets", "Number of Events" );
    makeHist( "nBJet_CSVv2T", 10, 0, 10, "# B-Jets", "Number of Events" );
    makeHist( "nBJet_JPL", 10, 0, 10, "# B-Jets", "Number of Events" ); 
    makeHist( "nBJet_JPM", 10, 0, 10, "# B-Jets", "Number of Events" );
    makeHist( "nBJet_JPT", 10, 0, 10, "# B-Jets", "Number of Events" );

    makeHist( "AtLeastOneLepton_met", 600, 0., 600, "MET [GeV]", "Number of Events" );
    makeHist( "AtLeastOneLepton_nJet", 40, 0, 40, "# Jets", "Number of Events" );

    makeHist( "NJets_met", 600, 0., 600, "MET [GeV]", "Number of Events" );
    makeHist( "NJets_nJet", 40, 0, 40, "# Jets", "Number of Events" );

    makeHist( "MET_met", 600, 0., 600, "MET [GeV]", "Number of Events" );
    makeHist( "MET_nJet", 40, 0, 40, "# Jets", "Number of Events" );
    
    makeHist( "NBJets_CSVv2L_met", 600, 0., 600, "MET [GeV]", "Number of Events" );     
    makeHist( "NBJets_CSVv2L_nJet", 40, 0, 40, "# Jets", "Number of Events"); 
    
    makeHist( "NBJets_CSVv2M_met", 600, 0., 600, "MET [GeV]", "Number of Events" );     
    makeHist( "NBJets_CSVv2M_nJet", 40, 0, 40, "# Jets", "Number of Events");  
    
    makeHist( "NBJets_CSVv2T_met", 600, 0., 600, "MET [GeV]", "Number of Events" );     
    makeHist( "NBJets_CSVv2T_nJet", 40, 0, 40, "# Jets", "Number of Events"); 
    
    makeHist( "NBJets_JPL_met", 600, 0., 600, "MET [GeV]", "Number of Events" );     
    makeHist( "NBJets_JPL_nJet", 40, 0, 40, "# Jets", "Number of Events"); 
    
    makeHist( "NBJets_JPM_met", 600, 0., 600, "MET [GeV]", "Number of Events" );     
    makeHist( "NBJets_JPM_nJet", 40, 0, 40, "# Jets", "Number of Events"); 
    
    makeHist( "NBJets_JPT_met", 600, 0., 600, "MET [GeV]", "Number of Events" );     
    makeHist( "NBJets_JPT_nJet", 40, 0, 40, "# Jets", "Number of Events"); 
    
    return;

}
Beispiel #12
0
//----------------------------------------//
// Plot the peak of a few values
//----------------------------------------//
void plotPeakComp()
{

  // Make Canvas
  TCanvas* c = makeCanvas("c");
  c->SetLogy();
  //c->SetLogx();

  // G4 and ZHS plots
  TString g4pname = "A_AntNum_0_pos_827.371_0_561.656";
  TString zhspname = "VP_avg_55.829616";

  // Specify the G4 plots
  TString g4dir = "efieldroot/";
  vector<TString> g4files;
  g4files.push_back(g4dir+"Output_50Evt_1GeV_1Prim_HardCodedAntenna_R1000m_newV.root");
  g4files.push_back(g4dir+"Output_50Evt_10GeV_1Prim_HardCodedAntenna_R1000m_newV.root");
  g4files.push_back(g4dir+"Output_50Evt_100GeV_1Prim_HardCodedAntenna_R1000m_newV.root");
  g4files.push_back(g4dir+"Output_20Evt_1TeV_1Prim_HardCodedAntenna_R1000m_newV.root");
  //g4files.push_back(g4dir+"Output_20Evt_10TeV_1Prim_HardCodedAntenna_R1000m_newV.root");

  // Specify the G4 plots
  TString zhsdir = "../ZHS_ELSEnergy/rootfiles/";
  vector<TString> zhsfiles;
  zhsfiles.push_back(zhsdir+"beam1e3MeV_1Prim_50NEvt_Angular.root");
  zhsfiles.push_back(zhsdir+"beam10e3MeV_1Prim_50NEvt_Angular.root");
  zhsfiles.push_back(zhsdir+"beam100e3MeV_1Prim_50NEvt_Angular.root");
  zhsfiles.push_back(zhsdir+"beam1e6MeV_1Prim_20NEvt_Angular.root");


  // What energies correspond to file [GeV]
  vector<double> NRG;
  NRG.push_back(1);
  NRG.push_back(10);
  NRG.push_back(100);
  NRG.push_back(1000);
  NRG.push_back(10000);

  // Specify some histogram shiz
  TString xtitle = "log(Energy/GeV)";
  TString ytitle = "Max(A) [Vm/s]";
  TH1F* frame = makeHist("frame",1,-1,5,xtitle,ytitle,kBlack,20);

  // Now loop over files and get points
  int npoints = 0;
  double E[1000];
  double g4_max[1000];
  double zhs_max[1000];
  double maximum = -999;
  for(unsigned int i=0; i<g4files.size(); ++i){

    // Store energy 
    E[i] = log10(NRG.at(i));

    // Get G4 result
    TFile* f_g4 = new TFile(g4files.at(i).Data());
    TProfile* prof = getProfile(f_g4, g4pname,"","",kBlack,20);
    //g4_max[i] = prof->GetMaximum();
    g4_max[i] = getMax(prof);
    if( maximum < g4_max[i] ) maximum = g4_max[i];

    // Get G4 result
    TFile* f_zhs = new TFile(zhsfiles.at(i).Data());
    TProfile* prof = getProfile(f_zhs, zhspname,"","",kBlack,20);
    //zhs_max[i] = prof->GetMaximum() / 1000.;
    //zhs_max[i] = prof->GetMaximum() /1000. ;
    zhs_max[i] = getMax(prof) / 1000.;
    if( maximum < zhs_max[i] ) maximum = zhs_max[i];

    // Increment points
    npoints++;

  }

  // Make TGraph
  TGraph* gr_g4 = new TGraph(npoints, E, g4_max);
  gr_g4->SetLineWidth(1);
  gr_g4->SetMarkerSize(1);
  gr_g4->SetMarkerStyle(20);
  gr_g4->SetLineColor(kBlue);
  gr_g4->SetMarkerColor(kBlue);

  // Make TGraph
  TGraph* gr_zhs = new TGraph(npoints, E, zhs_max);
  gr_zhs->SetLineWidth(1);
  gr_zhs->SetMarkerSize(1);
  gr_zhs->SetMarkerStyle(20);
  gr_zhs->SetLineColor(kRed);
  gr_zhs->SetMarkerColor(kRed);

  // Draw graph
  frame->SetMaximum(5*maximum);
  frame->SetMinimum(1e-5*maximum);
  frame->Draw();
  gr_g4->Draw("samelp");
  gr_zhs->Draw("samelp");

  // Add some legend
  TLegend* leg = makeLegend(0.2,0.4,0.8,0.9);
  leg->AddEntry(gr_g4,"Geant4","lp");  
  leg->AddEntry(gr_zhs,"ZHS","lp");
  leg->Draw("same");

}
bool LLGAnalysis::Init() {
    
    gROOT->ProcessLine(".L Loader.C+");
    gROOT->ProcessLine("#include <vector>");
    gSystem->Load("Loader_C.so");
    setStyle(1.0,true,0.15);
   
    _inputTree = new TChain(_inputTreeName.c_str());
    for( vector<string>::iterator itr = _inputFileNames.begin(); itr != _inputFileNames.end(); ++itr ) {
        _inputTree -> Add( (*itr).c_str() );  
    }

    // create the histograms and add them to the list
    makeHist( "MET_allEvents", 50, 0., 2000., "MET [GeV]", "Number of Events" );
    makeHist( "MET_HLT_PFMET170_NoiseCleaned_v1", 50, 0., 2000., "MET [GeV]", "Number of Events" );
    makeHist( "jet1_pt_allEvents", 50, 0., 1000., "Leading Jet p_{T} [GeV]", "Number of Events");
    makeHist( "jet1_pt_HLT_PFJet260_v1", 50, 0., 1000., "Leading Jet p_{T} [GeV]", "Number of Events");

    // allocate memory for all the variables
    recoJet_pt = new vector<double>;
    recoJet_phi = new vector<double>;
    recoJet_eta = new vector<double>;
    recoJet_btag_combinedInclusiveSecondaryVertexV2BJetTags = new vector<double>;
    recoJet_vertex_x = new vector<double>;
    recoJet_vertex_y = new vector<double>;
    recoJet_vertex_z = new vector<double>;

    muon_px = new vector<double>;
    muon_py = new vector<double>;
    muon_pz = new vector<double>;
    muon_phi = new vector<double>;
    muon_eta = new vector<double>;
    muon_iso = new vector<double>;
    muon_isTightMuon = new vector<bool>;
    muon_isLooseMuon = new vector<bool>;
    
    electron_px = new vector<double>;
    electron_py = new vector<double>;
    electron_pz = new vector<double>;
    electron_phi = new vector<double>;
    electron_eta = new vector<double>;
    electron_iso = new vector<double>;
    electron_isVeto = new vector<bool>;
    electron_isLoose = new vector<bool>;
    electron_isMedium = new vector<bool>;
    electron_isTight = new vector<bool>;
    electron_isHEEP = new vector<bool>;

    triggerBits = new vector<int>;
    triggerNames = new vector<string>;
    /* 
    recoJet_constVertex_x = new vector<vector<double> >;
    recoJet_constVertex_y = new vector<vector<double> >;
    recoJet_constVertex_z = new vector<vector<double> >;
    recoJet_const_pt = new vector<vector<double> >;
    recoJet_const_closestVertex_dxy = new vector<vector<double> >;
    recoJet_const_closestVertex_dz = new vector<vector<double> >;
    recoJet_const_closestVertex_d = new vector<vector<double> >;
    recoJet_const_charge = new vector<vector<int> >;
    */
    recoJet_isLeptonLike = new vector<bool>;
    vertex_x = new vector<double>;
    vertex_y = new vector<double>;
    vertex_z = new vector<double>;
    vertex_dx = new vector<double>;
    vertex_dy = new vector<double>;
    vertex_dz = new vector<double>;
    vertex_nTracks = new vector<double>;
    vertex_pt = new vector<double>;
    vertex_ndof = new vector<double>;
    secVertex_x = new vector<double>;
    secVertex_y = new vector<double>;
    secVertex_z = new vector<double>;
    secVertex_dx = new vector<double>;
    secVertex_dy = new vector<double>;
    secVertex_dz = new vector<double>;
    secVertex_pt = new vector<double>;
    secVertex_ndof = new vector<double>;
    
    // and set the branch addresses
    _inputTree->SetBranchAddress("RecoMuon_px", &muon_px );
    _inputTree->SetBranchAddress("RecoMuon_py", &muon_py );
    _inputTree->SetBranchAddress("RecoMuon_pz", &muon_pz );
    _inputTree->SetBranchAddress("RecoMuon_eta", &muon_eta );
    _inputTree->SetBranchAddress("RecoMuon_phi", &muon_phi );
    _inputTree->SetBranchAddress("RecoMuon_iso", &muon_iso );
    _inputTree->SetBranchAddress("RecoMuon_isLooseMuon", &muon_isLooseMuon );
    _inputTree->SetBranchAddress("RecoMuon_isTightMuon", &muon_isTightMuon );
    _inputTree->SetBranchAddress("RecoElectron_px", &electron_px );
    _inputTree->SetBranchAddress("RecoElectron_py", &electron_py );
    _inputTree->SetBranchAddress("RecoElectron_pz", &electron_pz );
    _inputTree->SetBranchAddress("RecoElectron_eta", &electron_eta );
    _inputTree->SetBranchAddress("RecoElectron_phi", &electron_phi );
    _inputTree->SetBranchAddress("RecoElectron_iso", &electron_iso );
    _inputTree->SetBranchAddress("RecoElectron_isVeto", &electron_isVeto );
    _inputTree->SetBranchAddress("RecoElectron_isLoose", &electron_isLoose );
    _inputTree->SetBranchAddress("RecoElectron_isMedium", &electron_isMedium );
    _inputTree->SetBranchAddress("RecoElectron_isTight", &electron_isTight );
    _inputTree->SetBranchAddress("RecoElectron_isHEEP", &electron_isHEEP );
    _inputTree->SetBranchAddress("TriggerNames", &triggerNames );
    _inputTree->SetBranchAddress("TriggerBits", &triggerBits );
    _inputTree->SetBranchAddress("RecoJet_pt", &recoJet_pt );
    _inputTree->SetBranchAddress("RecoJet_eta", &recoJet_eta );
    _inputTree->SetBranchAddress("RecoJet_phi", &recoJet_phi );
    _inputTree->SetBranchAddress("RecoJet_btag_pfCombinedInclusiveSecondaryVertexV2BJetTags", &recoJet_btag_combinedInclusiveSecondaryVertexV2BJetTags );
    _inputTree->SetBranchAddress("RecoJet_btag_pfJetBProbabilityBJetTags", &recoJet_btag_jetBProbabilityBJetTags );
    _inputTree->SetBranchAddress("RecoJet_btag_pfJetProbabilityBJetTags", &recoJet_btag_jetProbabilityBJetTags );
    _inputTree->SetBranchAddress("RecoJet_btag_pfTrackCountingHighPurBJetTags", &recoJet_btag_trackCountingHighPurBJetTags );
    _inputTree->SetBranchAddress("RecoJet_btag_pfTrackCountingHighEffBJetTags", &recoJet_btag_trackCountingHighEffBJetTags );
    _inputTree->SetBranchAddress("RecoJet_Vertex_x", &recoJet_vertex_x );
    _inputTree->SetBranchAddress("RecoJet_Vertex_y", &recoJet_vertex_y );
    _inputTree->SetBranchAddress("RecoJet_Vertex_z", &recoJet_vertex_z );
    /*
    _inputTree->SetBranchAddress("RecoJet_constVertex_x", &recoJet_constVertex_x );
    _inputTree->SetBranchAddress("RecoJet_constVertex_y", &recoJet_constVertex_y );
    _inputTree->SetBranchAddress("RecoJet_constVertex_z", &recoJet_constVertex_z );
    _inputTree->SetBranchAddress("RecoJet_const_pt", &recoJet_const_pt );
    _inputTree->SetBranchAddress("RecoJet_const_charge", &recoJet_const_charge );
    _inputTree->SetBranchAddress("RecoJet_const_closestVertex_dxy", &recoJet_const_closestVertex_dxy );
    _inputTree->SetBranchAddress("RecoJet_const_closestVertex_dz", &recoJet_const_closestVertex_dz );
    _inputTree->SetBranchAddress("RecoJet_const_closestVertex_d", &recoJet_const_closestVertex_d );
    */
    _inputTree->SetBranchAddress("RecoVertex_x", &vertex_x );
    _inputTree->SetBranchAddress("RecoVertex_y", &vertex_y );
    _inputTree->SetBranchAddress("RecoVertex_z", &vertex_z );
    _inputTree->SetBranchAddress("RecoVertex_xError", &vertex_dx );
    _inputTree->SetBranchAddress("RecoVertex_yError", &vertex_dy );
    _inputTree->SetBranchAddress("RecoVertex_zError", &vertex_dz );
    _inputTree->SetBranchAddress("RecoVertex_nTracks", &vertex_nTracks );
    _inputTree->SetBranchAddress("RecoVertex_pt", &vertex_pt );
    _inputTree->SetBranchAddress("RecoVertex_ndof", &vertex_ndof );
    _inputTree->SetBranchAddress("RecoSecVertex_x", &secVertex_x );
    _inputTree->SetBranchAddress("RecoSecVertex_y", &secVertex_y );
    _inputTree->SetBranchAddress("RecoSecVertex_z", &secVertex_z );
    _inputTree->SetBranchAddress("RecoSecVertex_xError", &secVertex_dx );
    _inputTree->SetBranchAddress("RecoSecVertex_yError", &secVertex_dy );
    _inputTree->SetBranchAddress("RecoSecVertex_zError", &secVertex_dz );
    _inputTree->SetBranchAddress("RecoSecVertex_pt", &secVertex_pt );
    _inputTree->SetBranchAddress("RecoSecVertex_ndof", &secVertex_ndof );
    _inputTree->SetBranchAddress("MET", &met );
    _inputTree->SetBranchAddress("MET_x", &met_x );
    _inputTree->SetBranchAddress("MET_y", &met_y );
    
    _outputTree->Branch("RecoMuon_px", &muon_px );
    _outputTree->Branch("RecoMuon_py", &muon_py );
    _outputTree->Branch("RecoMuon_pz", &muon_pz );
    _outputTree->Branch("RecoMuon_eta", &muon_eta );
    _outputTree->Branch("RecoMuon_phi", &muon_phi );
    _outputTree->Branch("RecoMuon_iso", &muon_iso );
    _outputTree->Branch("RecoMuon_isLooseMuon", &muon_isLooseMuon );
    _outputTree->Branch("RecoMuon_isTightMuon", &muon_isTightMuon );
    _outputTree->Branch("RecoElectron_px", &electron_px );
    _outputTree->Branch("RecoElectron_py", &electron_py );
    _outputTree->Branch("RecoElectron_pz", &electron_pz );
    _outputTree->Branch("RecoElectron_eta", &electron_eta );
    _outputTree->Branch("RecoElectron_phi", &electron_phi );
    _outputTree->Branch("RecoElectron_iso", &electron_iso );
    _outputTree->Branch("RecoElectron_isVeto", &electron_isVeto );
    _outputTree->Branch("RecoElectron_isLoose", &electron_isLoose );
    _outputTree->Branch("RecoElectron_isMedium", &electron_isMedium );
    _outputTree->Branch("RecoElectron_isTight", &electron_isTight );
    _outputTree->Branch("RecoElectron_isHEEP", &electron_isHEEP );
    _outputTree->Branch("TriggerNames", &triggerNames );
    _outputTree->Branch("TriggerBits", &triggerBits );
    _outputTree->Branch("RecoJet_pt", &recoJet_pt );
    _outputTree->Branch("RecoJet_eta", &recoJet_eta );
    _outputTree->Branch("RecoJet_phi", &recoJet_phi );
    _outputTree->Branch("RecoJet_btag_combinedInclusiveSecondaryVertexV2BJetTags", &recoJet_btag_combinedInclusiveSecondaryVertexV2BJetTags );
    _outputTree->Branch("RecoJet_btag_jetBProbabilityBJetTags", &recoJet_btag_jetBProbabilityBJetTags );
    _outputTree->Branch("RecoJet_btag_jetProbabilityBJetTags", &recoJet_btag_jetProbabilityBJetTags );
    _outputTree->Branch("RecoJet_btag_trackCountingHighPurBJetTags", &recoJet_btag_trackCountingHighPurBJetTags );
    _outputTree->Branch("RecoJet_btag_trackCountingHighEffBJetTags", &recoJet_btag_trackCountingHighEffBJetTags );
    /*
    _outputTree->Branch("RecoJet_constVertex_x", &recoJet_constVertex_x );
    _outputTree->Branch("RecoJet_constVertex_y", &recoJet_constVertex_y );
    _outputTree->Branch("RecoJet_constVertex_z", &recoJet_constVertex_z );
    _outputTree->Branch("RecoJet_const_pt", &recoJet_const_pt );
    _outputTree->Branch("RecoJet_const_charge", &recoJet_const_charge );
    _outputTree->Branch("RecoJet_const_closestVertex_dxy", &recoJet_const_closestVertex_dxy );
    _outputTree->Branch("RecoJet_const_closestVertex_dz", &recoJet_const_closestVertex_dz );
    _outputTree->Branch("RecoJet_const_closestVertex_d", &recoJet_const_closestVertex_d );
    */
    _outputTree->Branch("RecoVertex_x", &vertex_x );
    _outputTree->Branch("RecoVertex_y", &vertex_y );
    _outputTree->Branch("RecoVertex_z", &vertex_z );
    _outputTree->Branch("RecoVertex_dx", &vertex_dx );
    _outputTree->Branch("RecoVertex_dy", &vertex_dy );
    _outputTree->Branch("RecoVertex_dz", &vertex_dz );
    _outputTree->Branch("RecoVertex_nTracks", &vertex_nTracks );
    _outputTree->Branch("RecoVertex_pt", &vertex_pt );
    _outputTree->Branch("RecoVertex_ndof", &vertex_ndof );
    _outputTree->Branch("RecoSecVertex_x", &secVertex_x );
    _outputTree->Branch("RecoSecVertex_y", &secVertex_y );
    _outputTree->Branch("RecoSecVertex_z", &secVertex_z );
    _outputTree->Branch("RecoSecVertex_pt", &secVertex_pt );
    _outputTree->Branch("RecoSecVertex_ndof", &secVertex_ndof );
    _outputTree->Branch("RecoSecVertex_dx", &secVertex_dx );
    _outputTree->Branch("RecoSecVertex_dy", &secVertex_dy );
    _outputTree->Branch("RecoSecVertex_dz", &secVertex_dz );
    _outputTree->Branch("MET", &met );
    _outputTree->Branch("MET_x", &met_x );
    _outputTree->Branch("MET_y", &met_y );
  

    // crate eps, png and pdf in the end
    //_plotFormats.push_back(".eps");
    //_plotFormats.push_back(".png");
    //_plotFormats.push_back(".pdf");

    // finally set the style
    setStyle();

    return true;
}
//I would recommend to use the other version of the fit code
void addVarBinNuisance(std::string iFileName,std::string iChannel,std::string iBkg,std::string iEnergy,std::string iName,std::string iDir,bool iRebin=true,int iFitModel=0,double iFirst=200,double iLast=1500) { 
  std::cout << "======> " << iDir << "/" << iBkg << " -- " << iFileName << std::endl;  
  TFile *lFile = new TFile(iFileName.c_str());
  TH1F  *lH0   = (TH1F*) lFile->Get((iDir+"/"+iBkg).c_str());
  TH1F  *lData = (TH1F*) lFile->Get((iDir+"/data_obs").c_str());
  
  for(int i0 = 0; i0 < lH0->GetNbinsX()+1; i0++) lH0->SetBinContent(i0,lH0->GetBinContent(i0)/lH0->GetXaxis()->GetBinWidth(i0));
  for(int i0 = 0; i0 < lH0->GetNbinsX()+1; i0++) lH0->SetBinError  (i0,lH0->GetBinError  (i0)/lH0->GetXaxis()->GetBinWidth(i0));
  //Define the fit function
  double lFirst = iFirst;
  double lLast  = iLast;
  //TF1 *lFit = new TF1("Fit","[2]*exp(-x/([0]+[1]*x))",0,5000);
  TF1 *lFit = new TF1("expspec","[2]*exp(-x/([0]+[1]*x))",0,5000);
  if(iFitModel == 1) lFit  = new TF1("expspec","[2]*exp(-[0]*pow(x,[1]))",0,5000);
  lFit->SetParLimits(2,0,10000000); lFit->SetParameter(2,lH0->Integral()); 
  lFit->SetParLimits(0,  0,100);    lFit->SetParameter(0,20);
  lFit->SetParLimits(1,-10,10);     lFit->SetParameter(1,0);
  if(iFitModel == 1) lFit->SetParameter(0,0.3);
  if(iFitModel == 2) lFit->SetParameter(1,0.5);
  
  //TFitResultPtr  lFitPtr = lH0->Fit("expspec","SEWL","IR",lFirst,lLast);
  TFitResultPtr  lFitPtr = lH0->Fit("expspec","SER","R",lFirst,lLast);
  TMatrixDSym lCovMatrix   = lFitPtr->GetCovarianceMatrix();
  TMatrixD  lEigVecs(3,3);    lEigVecs = TMatrixDSymEigen(lCovMatrix).GetEigenVectors();
  TVectorD  lEigVals(3);      lEigVals = TMatrixDSymEigen(lCovMatrix).GetEigenValues();
  double lACentral = lFit->GetParameter(0); 
  double lBCentral = lFit->GetParameter(1);
  lEigVals(0) = sqrt(lEigVals(1));
  lEigVals(1) = sqrt(lEigVals(2));

  for(int i0 = 0; i0 < lH0->GetNbinsX()+1; i0++) lH0->SetBinContent(i0,lH0->GetBinContent(i0)*lH0->GetXaxis()->GetBinWidth(i0));
  for(int i0 = 0; i0 < lH0->GetNbinsX()+1; i0++) lH0->SetBinError  (i0,lH0->GetBinError  (i0)*lH0->GetXaxis()->GetBinWidth(i0));

  lEigVecs(0,0) = lEigVecs(0,1);
  lEigVecs(1,0) = lEigVecs(1,1);
  lEigVecs(0,1) = lEigVecs(0,2);
  lEigVecs(1,1) = lEigVecs(1,2);
  
  TH1F* lH     = makeHist(lFit,lH0,"Def");
  lFit->SetParameter(0,lACentral + lEigVals(0)*lEigVecs(0,0));
  lFit->SetParameter(1,lBCentral + lEigVals(0)*lEigVecs(1,0));
  TH1F* lHUp   = makeHist(lFit,lH0,"Up");
  lFit->SetParameter(0,lACentral - lEigVals(0)*lEigVecs(0,0));
  lFit->SetParameter(1,lBCentral - lEigVals(0)*lEigVecs(1,0));
  TH1F* lHDown = makeHist(lFit,lH0,"Down");

  lFit->SetParameter(0,lACentral + lEigVals(1)*lEigVecs(0,1));
  lFit->SetParameter(1,lBCentral + lEigVals(1)*lEigVecs(1,1));
  TH1F* lHUp1   = makeHist(lFit,lH0,"Up1");
  lFit->SetParameter(0,lACentral - lEigVals(1)*lEigVecs(0,1));
  lFit->SetParameter(1,lBCentral - lEigVals(1)*lEigVecs(1,1));
  TH1F* lHDown1 = makeHist(lFit,lH0,"Down1");
  
  //lFirst = 200;
  std::string lNuisance1 =  iBkg+"_"+"CMS_"+iName+"1_" + iChannel + "_" + iEnergy;
  std::string lNuisance2 =  iBkg+"_"+"CMS_"+iName+"2_" + iChannel + "_" + iEnergy;
  lHUp    = merge(lNuisance1 + "Up"   ,lFirst,lH0,lHUp);
  lHDown  = merge(lNuisance1 + "Down" ,lFirst,lH0,lHDown);
  lHUp1   = merge(lNuisance2 + "Up"   ,lFirst,lH0,lHUp1);
  lHDown1 = merge(lNuisance2 + "Down" ,lFirst,lH0,lHDown1);
  lH      = merge(lH0->GetName()      ,lFirst,lH0,lH);  
  if(iRebin) { 
    const int lNBins = lData->GetNbinsX();
    double *lAxis    = getAxis(lData);
    lH0     = rebin(lH0    ,lNBins,lAxis);
    lH      = rebin(lH     ,lNBins,lAxis);
    lHUp    = rebin(lHUp   ,lNBins,lAxis);
    lHDown  = rebin(lHDown ,lNBins,lAxis);
    lHUp1   = rebin(lHUp1  ,lNBins,lAxis);
    lHDown1 = rebin(lHDown1,lNBins,lAxis);
  }
  TFile *lOutFile =new TFile("Output.root","RECREATE");
  cloneFile(lOutFile,lFile,iDir+"/"+iBkg);
  lOutFile->cd(iDir.c_str());
  lH     ->Write();
  lHUp   ->Write(); 
  lHDown ->Write(); 
  lHUp1  ->Write(); 
  lHDown1->Write(); 

  // Debug Plots
  lH0    ->SetLineWidth(1); lH0->SetMarkerStyle(kFullCircle);
  lH     ->SetLineColor(kGreen);
  lHUp   ->SetLineColor(kRed);
  lHDown ->SetLineColor(kRed);
  lHUp1  ->SetLineColor(kBlue);
  lHDown1->SetLineColor(kBlue);
  TCanvas *lC0 = new TCanvas("Can","Can",800,600);
  lC0->Divide(1,2); lC0->cd();  lC0->cd(1)->SetPad(0,0.2,1.0,1.0); gPad->SetLeftMargin(0.2) ;  
  lH0->Draw();
  lH     ->Draw("hist sames");
  lHUp   ->Draw("hist sames");
  lHDown ->Draw("hist sames");
  lHUp1  ->Draw("hist sames");
  lHDown1->Draw("hist sames");
  gPad->SetLogy();
  lC0->cd(2)->SetPad(0,0,1.0,0.2); gPad->SetLeftMargin(0.2) ;
  drawDifference(lH0,lH,lHUp,lHDown,lHUp1,lHDown1);
  lC0->SaveAs((iBkg+"_"+"CMS_"+iName+"1_" + iDir + "_" + iEnergy+".png").c_str());
  //lFile->Close();
  return;
}