void tagAndProbePlotsRun2011A_MCdataCom_IsoEle25_27_32_TaP_and_subtrigger(bool save=false)
{
  /// set style
  // ============================
  //  Set ROOT Style
  // ============================
 
  gROOT->Reset();
//   gROOT->SetStyle("Plain");
  //   
//   TStyle myStyle("HHStyle","HHStyle");
//   setHHStyle(myStyle);
//   TGaxis::SetMaxDigits(2);
//   myStyle.cd();
//   gROOT->SetStyle("HHStyle");
//   gROOT->ForceStyle();  
  
  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetLegendBorderSize(0);
  gStyle->SetPadBottomMargin(0.11);
  gStyle->SetLabelSize(0.05,"XY");
  gStyle->SetTitleSize(0.05,"XY");
  gStyle->SetFillColor(0);
  gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  gStyle->SetPadTickY(1);
  
//   const int fontstyle1=62;
  const int fontstyle1=42;
  gStyle->SetTitleFont(fontstyle1);
  gStyle->SetTitleFont(fontstyle1, "XYZ");
  gStyle->SetLabelFont(fontstyle1, "XYZ");
  gStyle->SetTextFont(fontstyle1);
  
  /// path where input files are stored
  TString inputPathScratch  ="/scratch/hh/current/cms/user/jlange/output_4_2_4/fullLeptonic";
  TString inputPath42       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_4/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  TString inputPath428       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_8_patch7/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  
  TString outputFolder   = "/afs/desy.de/user/j/jlange/analysis/tagAndProbe/plots/2011/singleEle/Fall11/DataMCcomp_IsoEle25subTrigger";
  TString outputFileName = "/IsoEle25subTrigger_WP70_CiCcomp_";
//   TString outputFileName = "/IsoEle27-32_5GeVaboveThresholdInclCombinedData";
  //TString outputFileName = "/IsoEle27-32_5GeVaboveThreshold";
  //TString outputFileName = "/IsoEle27-32_";

  TString fileFormatArr []= {"root", "png", "eps"};
  std::vector<TString> fileFormat(fileFormatArr, fileFormatArr + sizeof(fileFormatArr)/sizeof(TString));
  
  /// if set to 0: all plots (probe, test, eff) are drawn; to 1: only eff plots
  int onlyEffPlots =0;
  /// method ID of MC file to normalise scale factors to
  TString mIDnorm = "refTr1MCJet110";
  std::cout<< "Efficiency wrt. which SF is supposed to be normalized " <<  mIDnorm << std::endl;

  
   /// map with structure that keeps features of methods, like file, filename, legend etc.
  std::map<TString, method*> method_;
  
  //TString mIDarr []= {"m1","m2"};
  //TString mIDarr []= {"m1", "m1noPU", "m1PUEPS", "m1PUup", "m1PUdown","m2"};
//   TString mIDarr []= {"m1","m2", "m2-27", "m2-32EPS", "m2-32ApostEPS", "m2-32B", "m2-32WP70B"};
//    TString mIDarr []= {"m1", "refTr1MCJet110", "refTr1MCAll", "refTr1", "refTr2"};
  TString mIDarr []= {"refTr1MCJet110", "refTr1MCJet110WP70", "m1", "refTr2EPSnew", "refTr2EPSnewWP70"};
  //TString mIDarr []= {"m1", "refTr1MCJet110", "refTr1MCAll", "refTr1", "refTr1424"};
//  TString mIDarr []= {"refTr1", "refTr2"};
  //TString mIDarr []= {"m1"};
  std::vector<TString> mID(mIDarr, mIDarr + sizeof(mIDarr)/sizeof(TString));
  int mIDNum = mID.size();
  std::cout<< "Number of considered methods (i.e. files): " <<  mIDNum << std::endl;
  
  // check if mIDnorm is in vector and give error if not
  bool inVector=false;
  for(int i=0; i< mIDNum; i++) if(mID[i]==mIDnorm) inVector=true;
  if(!inVector) {
    std::cout<<"ERROR!!!! Efficiency wrt. which SF is supposed to be normalized is not in mID vector!!! "<<std::endl; 
    return;
  }
  
  TString fileName ;
  
    /// Define histo and legend styles and options
//   int lineStyle   []= {1,1,1,1,1,1};
//   int lineColor   []= {2,1,4,kGreen+2,kGray+2,3};
//   int markerStyle []={1,21,22,20,22,23};
//   int markerColor []= {2,1,4,kGreen+2,kGray+2,3};
//   TString drawOpt []= {"","E X0 P same","E X0 P same","E X0 same","E X0 same","E same"};
//   TString legOpt  []= {"L","P","P","P","P","P"};
//   bool legOnPlot = false;
  
  /// Constructor for struct method(TString iniFileName, TString iniLegName, int iniLineStyle, int iniLineColor, int iniMarkerStyle, int iniMarkerColor, TString iniDrawOpt, TString iniLepOpt, TString source)
  
   /// Fall11 MC
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet.root";
  method_["m1"] = new method(fileName, "Simulation IsoEle32", 3, 2, 1, 1, "E", "L", "treeV2","probePt>37. && TMath::Abs(probeEta)<2.1","eventWeightPUeventWeightPU");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet.root";
  method_["m1noPU"] = new method(fileName, "Fall11 IsoEle32 no PUrew", 2, 2, 1, 1, "E", "L", "treeV2","probePt>37. && TMath::Abs(probeEta)<2.1","");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet.root";
  method_["m1PUEPS"] = new method(fileName, "Fall11 IsoEle32 PUrew EPS", 3, 8, 1, 1, "E", "L", "treeV2","probePt>37.","eventWeightPUEPSeventWeightPUEPS");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet.root";
  method_["m1PUup"] = new method(fileName, "Fall11 IsoEle32 PUrew UP", 2, 4, 1, 1, "E", "L", "treeV2","probePt>37.","eventWeightPUsysUpeventWeightPUUp");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet.root";
  method_["m1PUdown"] = new method(fileName, "Fall11 IsoEle32 PUrew DOWN", 2, 7, 1, 1, "E", "L", "treeV2","probePt>37.","eventWeightPUsysDowneventWeightPUDown");
  
  /// data
//   fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
//   method_["m2"] = new method(fileName, "2011 Data IsoEle27/32", 1, 1, 21, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run<=178380");
//   
//   fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
//   method_["m2-27"] = new method(fileName, "2011 Data IsoEle27, run<=161176", 1, 1, 22, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run<=161176");
//   
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2-32EPS"] = new method(fileName, "2011 Data IsoEle32 EPS", 1, 1, 23, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>161176 && run<=167913");
//   
//   fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
//   method_["m2-32ApostEPS"] = new method(fileName, "2011 Data IsoEle32 A post EPS", 1, 1, 24, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>167913 && run<=175570");
//   
//   fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
//   method_["m2-32B"] = new method(fileName, "2011 Data IsoEle32 B", 1, 1, 25, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>175570 && run<=178380");
//   
//   fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
//   method_["m2-32WP70B"] = new method(fileName, "2011 Data IsoEle32WP70 B", 1, 1, 26, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>178380");
  
  
  /// subtrigger method on jet PD:
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_Jet110_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosMCFall11_Jet110_IsoEle25.root";
  method_["refTr1MCJet110"] = new method(fileName, "MC ttbar Jet110 CiC IsoEle25", 1, 2, 1, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_Fall11MC_Jet_IsoEle25SubBit_OldWP70eID/analyzeCrossTriggerRatiosMCFall11_Jet110_IsoEle25.root";
  method_["refTr1MCJet110WP70"] = new method(fileName, "MC ttbar Jet110 WP70 IsoEle25", 2, 2, 1, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_Fall11MC_Jet_IsoEle25SubBit_OldWP70eID_TrigMatch/analyzeCrossTriggerRatiosMCFall11_Jet110_IsoEle25.root";
  method_["refTr1MCJet110WP70TrigMatch"] = new method(fileName, "MC ttbar Jet110 WP70 TrigMatch IsoEle25", 4, 2, 1, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_Fall11MC_Jet_IsoEle25SubBit_CiCeID_TrigMatch/analyzeCrossTriggerRatiosMCFall11_Jet110_IsoEle25.root";
  method_["refTr1MCJet110CiCTrigMatch"] = new method(fileName, "MC ttbar Jet110 CiC TrigMatch IsoEle25", 5, 2, 1, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_All_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosMCFall11_All_IsoEle25TriJet.root";
  method_["refTr1MCAll"] = new method(fileName, "MC ttbar all IsoEle25", 3, 2, 1, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosRun2011APromptRecoV4_Jet_Ele25SubBit_cfg/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165088_165633_Trig1_Jet_Ele25TriJet.root";
  method_["refTr1"] = new method(fileName, "Run PromptV4 Ele25", 2, 4, 20, 4, "E same", "LP","treeV2","","");
  
  fileName=inputPath42+"/naf_analyzeCrossTriggerRatiosRun2011APromptRecoV4_Jet_Ele25SubBit_cfg/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165088_165633_Trig1_Jet_Ele25TriJet.root";
  method_["refTr1424"] = new method(fileName, "Run PromptV4 Ele25", 2, 4, 21, 4, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosRun2011All_Jet_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosRun2011All_165970_180252_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2"] = new method(fileName, "2011 all IsoEle25", 2, 8, 21, 8, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosRun2011All_Jet_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosRun2011All_165970_180252_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2EPS"] = new method(fileName, "2011 EPS IsoEle25", 2, 8, 22, 8, "E same", "LP","treeV2","runNumber<=167913 && runNumber>=165970","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosRun2011APromptRecoV4_Jet_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165970_167913_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2EPSnew"] = new method(fileName, "2011 EPS CiC IsoEle25", 1, 8, 21, 8, "E same", "LP","treeV2","runNumber<=167913 && runNumber>=165970","");
  
  fileName=inputPath428+"/naf_Jet_IsoEle25SubBit_OldWP70eID/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165970_167913_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2EPSnewWP70"] = new method(fileName, "2011 EPS WP70 IsoEle25", 1, 1, 22, 1, "E same", "LP","treeV2","runNumber<=167913 && runNumber>=165970","");
  
  fileName=inputPath428+"/naf_Jet_IsoEle25SubBit_OldWP70eID_TrigMatch/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165970_167913_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2EPSnewWP70TrigMatch"] = new method(fileName, "2011 EPS new WP70 TrigMatch IsoEle25", 2, 1, 21, 1, "E same", "LP","treeV2","runNumber<=167913 && runNumber>=165970","");
  
  fileName=inputPath428+"/naf_Jet_IsoEle25SubBit_CiCeID_TrigMatch/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165970_167913_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2EPSCiCTrigMatch"] = new method(fileName, "2011 EPS CiC TrigMatch IsoEle25", 2, 1, 22, 1, "E same", "LP","treeV2","runNumber<=167913 && runNumber>=165970","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosRun2011All_Jet_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosRun2011All_165970_180252_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2postEPS"] = new method(fileName, "2011 postEPS IsoEle25", 2, 8, 23, 8, "E same", "LP","treeV2","runNumber>167913","");
  
  fileName=inputPath42+"/naf_analyzeCrossTriggerRatiosRun2011APromptRecoV4_Jet_IsoEle25SubBit_cfg/analyzeCrossTriggerRatiosRun2011APromptRecoV4_165970_167913_Trig2_Jet_IsoEle25TriJet.root";
  method_["refTr2EPS424"] = new method(fileName, "Run PromptV4 IsoEle25", 2, 8, 25, 8, "E same", "LP","treeV2","TMath::Abs(eta)<2.1","");
  

  
  /// different tap studies (different efficiencies)

//    const int folderNum=6;
//    TString folderID[]={"tapTrkQEle", "tapIDEle", "tapIsoEle", "tapConvRejEle", "tapTotalSelectionEle", "tapTriggerEle"};
//    TString foldersTitle[]={"Track Quality", "ID", "Isolation", "Conversion Rejection", "Overall Selection", "Trigger"};
   
//    const int folderNum=2;
//    TString folderID[]={"tapTotalSelectionEle", "tapTriggerEle"};
//    TString foldersTitle[]={"Overall Selection", "Trigger"};
  
//   const int folderNum=1;
//   TString folderID[]={"tapTotalSelectionEle"};
//   TString foldersTitle[]={"Overall Selection"};
  
  const int folderNum=1;
  TString folderID[]={"tapTriggerEle"};
  TString foldersTitle[]={"Trigger"};
  
//   const int folderNum=1;
//     /// to combine selection and trigger efficiencies use tapAll:
//   TString folderID[]={"tapAllEle"};
//   TString foldersTitle[]={"Combined Selection and Trigger"};
  
//   const int folderNum=1;
//   TString folderID[]={"tapTrigger"};
//   TString foldersTitle[]={"Trigger"};
  
  /// for reference trigger method:
  TString folderIDrefTriggerPass="******";
  TString folderIDrefTriggerAll="analyzeElectronKinematicsTrig1";


  /// effName = name of the effHisto; variables: corresponding variable to effName; cuts: corresponding cut to effName

  //TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR","lepLepMass"};
  //TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "PtEta0to1p5", "PtEta1p5to2p1"};
  //TString effIDarr[]      = {"Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR"};
  //TString effIDarr[]      = {"Pt"};
  TString effIDarr[]      = {"Pt", "Eta"};
  std::vector<TString> effID(effIDarr, effIDarr + sizeof(effIDarr)/sizeof(TString));
  int effIDNum = effID.size();
  std::cout<< "Number of considered plots: " <<  effIDNum << std::endl;
  
  
  TString effIDarr2[]      = {};
  //TString effIDarr2[]      = {"PtEta0to1p2", "PtEta1p2to2p1", "EtaPt30to45", "EtaPt45to60", "EtaPtGreater60", "PtMedian", "Pt3bins"};
  std::vector<TString> effID2(effIDarr2, effIDarr2 + sizeof(effIDarr2)/sizeof(TString));
  int effIDNum2 = effID2.size();
  std::cout<< "Number of considered plots 2: " <<  effIDNum2 << std::endl;
    
  /// map with structure that keeps features of histograms
  std::map<TString, std::map<TString, eff*> > eff_;
  
  /// title for histo, x and y axis (separated by "/")
  TString title0 ="";
  TString title ="";
  
  /// axis range
  //double yLo = 0.5, yHi = 1.1;
  double yLo = 0.8, yHi = 1.;
  double yLoSF = 0.9, yHiSF = 1.1;
  
  /// Constructor for struct eff(TString iniVar, T  iniCuts, TString iniBins, TString iniTitles, double iniYLo=-9999., double iniYHi=-9999., double iniXLo=-9999., double iniXHi=-9999.)
  TCut cutPt  = ""; /*"(probePt>30. || testPt>30. )";*/
  TCut cutEta = ""; /*"(TMath::Abs(probeEta)<2.1 || TMath::Abs(testEta)<2.1)";*/
  TCut cutPtEta = cutPt && cutEta;
  for(int iFolder=0; iFolder < folderNum; iFolder++){
    title = foldersTitle[iFolder]+" Efficiency/ / ";
    eff_["Control"][folderID[iFolder]]        =new eff("Control", cutPtEta, mBinsControl, binsControl_, title, yLo, yHi, -9999.,-9999.);
    title = foldersTitle[iFolder]+" Efficiency/p_{T} [GeV]/ ";
    eff_["Pt"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtAN_, title, yLo, yHi, 30.,200.);
//     eff_["Pt"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPt_, title, yLo, yHi, 30.,200.);
    title = foldersTitle[iFolder]+" Efficiency/#eta/ ";
    eff_["Eta"][folderID[iFolder]]             =new eff("Eta", cutPt, mBinsEta, binsEta_, title, yLo, yHi);
//     eff_["Eta"][folderID[iFolder]]             =new eff("Eta", cutPt, mBinsEta, binsEtaEle_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/relIso/ ";
    eff_["RelIso"][folderID[iFolder]]          =new eff("RelIso", cutPtEta, mBinsRelIso, binsRelIso_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/absIso/ ";
    eff_["AbsIso"][folderID[iFolder]]          =new eff("AbsIso", cutPtEta, mBinsAbsIso, binsAbsIso_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Primary Vertices/ ";
    eff_["PVMult"][folderID[iFolder]]          =new eff("PVMult", cutPtEta, mBinsPVMult, binsPVMult_, title, yLo, yHi,0.,20.);
    title = foldersTitle[iFolder]+" Efficiency/N_{jet}/ ";
    eff_["Mult"][folderID[iFolder]]            =new eff("Mult", cutPtEta, mBinsMult, binsMult_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Minimum #DeltaR(#mu,jet)/ ";
    eff_["MinDR"][folderID[iFolder]]            =new eff("MinDR", cutPtEta, mBinsMinDR, binsMinDR_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Minimum M_{lep,lep}/ ";
    eff_["lepLepMass"][folderID[iFolder]]            =new eff("lepLepMass", cutPtEta, mBinsLepLepMass, binsLepLepMass_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 0<#eta<1.2/p_{T} [GeV]/ ";
    eff_["PtEta0to1p2"][folderID[iFolder]]             =new eff("Pt", "TMath::Abs(probeEta)<1.2", mBinsPt, binsPt_, title, yLo, yHi, 30.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency 1.2<#eta<2.1/p_{T} [GeV]/ ";
    eff_["PtEta1p2to2p1"][folderID[iFolder]]             =new eff("Pt", "TMath::Abs(probeEta)>1.2 && TMath::Abs(probeEta)<2.1", mBinsPt, binsPt_, title, yLo, yHi, 30.,200.,true);
    
    title = foldersTitle[iFolder]+" Efficiency, 30<p_{T}<45/#eta/ ";
    eff_["EtaPt30to45"][folderID[iFolder]]             =new eff("Eta", "probePt>30. && probePt<45.", mBinsEta, binsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 45<p_{T}<60/#eta/ ";
    eff_["EtaPt45to60"][folderID[iFolder]]             =new eff("Eta", "probePt>45. && probePt<60.", mBinsEta, binsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 60<p_{T}/#eta/ ";
    eff_["EtaPtGreater60"][folderID[iFolder]]             =new eff("Eta", "probePt>60.", mBinsEta, binsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency AN/p_{T} [GeV]/ ";
    eff_["PtAN"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtAN_, title, yLo, yHi, 30.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency Median/p_{T} [GeV]/ ";
    eff_["PtMedian"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtMedian_, title, yLo, yHi, 30.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency 3 bins/p_{T} [GeV]/ ";
    eff_["Pt3bins"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPt3bins_, title, yLo, yHi, 30.,200.);
  }

  /// ---
  /// get efficiencies from tree or histo
  ///  ---
  for(int iMethod=0; iMethod<mIDNum; iMethod++){
    for(int iEff=0; iEff<effIDNum; iEff++){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	if(!mID[iMethod].Contains("refTr")) getEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder]);
	else                               getEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderIDrefTriggerPass, folderIDrefTriggerAll);
      }
    }
      
    for(int iEff=0; iEff<effIDNum2; iEff++){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	getEfficiencies(eff_[effID2[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder]);
      }
	
    }
  }

 /// Draw one Canvas for each folder comparing different methods.
 /// Each canvas shows test (1st row) and probe collection (2nd) and efficiency (3rd) for different variables (columns)
  TCanvas* CanvComp [folderNum];
  TCanvas* CanvSFComp [folderNum];
  TCanvas* CanvEvtsComp [folderNum];
  TCanvas* CanvEvtsNormComp [folderNum];
  TCanvas* CanvLeg = new TCanvas("CanvLeg", "CanvLeg", 350,200);
  
  TCanvas* CanvComp2 [folderNum];
  TCanvas* CanvSFComp2 [folderNum];

  std::cout<< "Drawing eff. and SF"<<std::endl;
  for(int iFolder=0; iFolder<folderNum; iFolder++) {

    CanvComp[iFolder] = new TCanvas("Comparison"+folderID[iFolder], "Comparison"+folderID[iFolder], 1700,1000);
    CanvSFComp[iFolder] = new TCanvas("ComparisonSF"+folderID[iFolder], "ComparisonSF"+folderID[iFolder], 1700,1000);
    CanvEvtsComp[iFolder] = new TCanvas("ComparisonEvts"+folderID[iFolder], "ComparisonEvts"+folderID[iFolder], 1700,1000);
    CanvEvtsNormComp[iFolder] = new TCanvas("ComparisonEvtsNorm"+folderID[iFolder], "ComparisonEvtsNorm"+folderID[iFolder], 1700,1000);
    
    CanvComp2[iFolder] = new TCanvas("Comparison2"+folderID[iFolder], "Comparison2"+folderID[iFolder], 1700,1000);
    CanvSFComp2[iFolder] = new TCanvas("ComparisonSF2"+folderID[iFolder], "ComparisonSF2"+folderID[iFolder], 1700,1000);
    
    CanvComp[iFolder]->Divide(4,2);
    CanvSFComp[iFolder]->Divide(4,2);
    CanvEvtsComp[iFolder]->Divide(4,2);
    CanvEvtsNormComp[iFolder]->Divide(4,2);
    
    CanvComp2[iFolder]->Divide(4,2);
    CanvSFComp2[iFolder]->Divide(4,2);
  
    for(int iEff=0; iEff<effIDNum; iEff++){
      CanvComp[iFolder]->cd(iEff+1);
//       CanvComp[iFolder]->cd(iEff+1)->SetGrid(1,1);
      std::cout<< "Drawing eff."<<std::endl;
      drawEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
      CanvSFComp[iFolder]->cd(iEff+1);
      std::cout<< "Drawing SF"<<std::endl;
      drawSF          (eff_[effID[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID[iEff]][folderID[iFolder]]->xLo, eff_[effID[iEff]][folderID[iFolder]]->xHi);
    // if desired plot also raw event number histos
      if(onlyEffPlots!=1) {
	std::cout<< "Drawing event numbers"<<std::endl;
	CanvEvtsComp[iFolder]->cd(iEff+1);
	drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
	CanvEvtsNormComp[iFolder]->cd(iEff+1);
	drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend,"normInt");
      }
    }
    
    for(int iEff=0; iEff<effIDNum2; iEff++){
      CanvComp2[iFolder]->cd(iEff+1);
//       CanvComp[iFolder]->cd(iEff+1)->SetGrid(1,1);
      std::cout<< "Drawing eff. 2"<<std::endl;
      drawEfficiencies(eff_[effID2[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend);
      CanvSFComp2[iFolder]->cd(iEff+1);
      std::cout<< "Drawing SF"<<std::endl;
      drawSF          (eff_[effID2[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.15,0.15,0.9,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID2[iEff]][folderID[iFolder]]->xLo, eff_[effID2[iEff]][folderID[iFolder]]->xHi);
    }
    
    
  // draw legend
    CanvLeg->cd();
    if(iFolder==0) drawLegend(eff_[effID[0]][folderID[0]], method_, mID, 0.,0.,1.,1.);
  
//   effControl[iMethod][iFolder]->GetXaxis()->SetNdivisions(0);
//   effRelIso[iMethod][iFolder]->GetXaxis()->SetNdivisions(505);
 
    if(save){
      for(unsigned int iFileFormat=0; iFileFormat < fileFormat.size(); iFileFormat++){
	CanvComp[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_overview."+fileFormat[iFileFormat]);
	for(int iEff=0; iEff<effIDNum; iEff++){
	  CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	  CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	}
	
	for(int iEff=0; iEff<effIDNum2; iEff++){
	  CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
	  CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
	}
	
	if(iFolder==0) CanvLeg->Print(outputFolder+outputFileName+"_Legend."+fileFormat[iFileFormat]);
	std::cout<<"Canvas with plots is saved in "<<outputFolder<<std::endl;
      }
      /// save graph in root file
//       TFile f("MuonEffSF2011.root", "new");
//       eff_["Eta"]["tapAll"]->graphSF["m2"]->SetName("tapAllSFeta");
//       //eff_["Eta"]["tapAll"]->graphSF["m2"]->SetTitle("tapAllSFeta");
//       eff_["Eta"]["tapAll"]->graphSF["m2"]->Write();
//       std::cout<<"MuonEffSF.root with TGraphErrors is saved in "<<outputFolder<<std::endl;
    }
  }
  std::cout<< "Done"<<std::endl;
}
void tagAndProbePlotsRun2011_IsoMu17_IsoMu24_differentRunRanges(bool save=false)
{
  /// set style
  // ============================
  //  Set ROOT Style
  // ============================
 
  gROOT->Reset();
//   gROOT->SetStyle("Plain");
//   
//   TStyle myStyle("HHStyle","HHStyle");
//   setHHStyle(myStyle);
//   TGaxis::SetMaxDigits(2);
//   myStyle.cd();
//   gROOT->SetStyle("HHStyle");
//   gROOT->ForceStyle();  
  
  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetLegendBorderSize(0);
  gStyle->SetPadBottomMargin(0.11);
  gStyle->SetLabelSize(0.05,"XY");
  gStyle->SetTitleSize(0.05,"XY");
  gStyle->SetFillColor(0);
  gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  gStyle->SetPadTickY(1);
  
//   const int fontstyle1=62;
  const int fontstyle1=42;
  gStyle->SetTitleFont(fontstyle1);
  gStyle->SetTitleFont(fontstyle1, "XYZ");
  gStyle->SetLabelFont(fontstyle1, "XYZ");
  gStyle->SetTextFont(fontstyle1);
  
  /// path where input files are stored
  TString inputPathScratch  ="/scratch/hh/current/cms/user/jlange/output_4_2_4/fullLeptonic";
  TString inputPath42       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_4/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  TString inputPath428       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_8_patch7/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  
  TString outputFolder   = "/afs/desy.de/user/j/jlange/analysis/tagAndProbe/plots/2011/singleMu/Fall11/DataMCcomp_IsoMu17-24_DifferentRunRanges";
  TString outputFileName = "/DataMCcomp_IsoMu17-24_DifferentRunRanges_";

  TString fileFormatArr []= {"root", "png", "eps"};
  std::vector<TString> fileFormat(fileFormatArr, fileFormatArr + sizeof(fileFormatArr)/sizeof(TString));
  
  /// if set to 0: all plots (probe, test, eff) are drawn; to 1: only eff plots
  int onlyEffPlots =0;
  /// method ID of MC file to normalise scale factors to
  TString mIDnorm = "mfull";
  std::cout<< "Efficiency wrt. which SF is supposed to be normalized " <<  mIDnorm << std::endl;

  
   /// map with structure that keeps features of methods, like file, filename, legend etc.
  std::map<TString, method*> method_;
  
  //TString mIDarr []= {"m1","m2"};
  TString mIDarr []= {"mfull", "m5e32", "m1e33", "m2e33", "m3e33A", "m3e33B", "m5e33"};
  std::vector<TString> mID(mIDarr, mIDarr + sizeof(mIDarr)/sizeof(TString));
  int mIDNum = mID.size();
  std::cout<< "Number of considered methods (i.e. files): " <<  mIDNum << std::endl;
  
  // check if mIDnorm is in vector and give error if not
  bool inVector=false;
  for(int i=0; i< mIDNum; i++) if(mID[i]==mIDnorm) inVector=true;
  if(!inVector) {
    std::cout<<"ERROR!!!! Efficiency wrt. which SF is supposed to be normalized is not in mID vector!!! "<<std::endl; 
    return;
  }
  
  TString fileName ;
  
    /// Define histo and legend styles and options
//   int lineStyle   []= {1,1,1,1,1,1};
//   int lineColor   []= {2,1,4,kGreen+2,kGray+2,3};
//   int markerStyle []={1,21,22,20,22,23};
//   int markerColor []= {2,1,4,kGreen+2,kGray+2,3};
//   TString drawOpt []= {"","E X0 P same","E X0 P same","E X0 same","E X0 same","E same"};
//   TString legOpt  []= {"L","P","P","P","P","P"};
//   bool legOnPlot = false;
  
  /// Constructor for struct method(TString iniFileName, TString iniLegName, int iniLineStyle, int iniLineColor, int iniMarkerStyle, int iniMarkerColor, TString iniDrawOpt, TString iniLepOpt, TString source)
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeMCFall11_HLT_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeMCFall11_HLT_IsoMu24_eta2p1_IsoMu17eta2p1TriJet.root";
  method_["m1"] = new method(fileName, "Simulation IsoMu24eta2p1", 1, 2, 1, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1","eventWeightPUeventWeightPU");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeMCFall11_HLT_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeMCFall11_HLT_IsoMu24_eta2p1_IsoMu17eta2p1TriJet.root";
  method_["m1b"] = new method(fileName, "Fall11 IsoMu24eta2p1 no PUrew", 2, 2, 1, 1, "E", "L", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1","");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["mfull"] = new method(fileName, "Data All IsoMu17(24)(eta2p1)", 1, 1, 21, 1, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m5e32"] = new method(fileName, "Data 5e32 IsoMu17", 1, 4, 23, 4, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run<=163869");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m1e33"] = new method(fileName, "Data 1e33 IsoMu17", 1, 4, 25, 4, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>163869 &&run<=167913");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2e33"] = new method(fileName, "Data 2e33 IsoMu24", 1, 8, 20, 8, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>167913 &&run<=173198");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m3e33A"] = new method(fileName, "Data 3e33A IsoMu24eta2p1", 1, 6, 22, 6, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>173198 &&run<=175770");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m3e33B"] = new method(fileName, "Data 3e33B IsoMu24eta2p1", 1, 6, 21, 6, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>175770 &&run<=178380");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m5e33"] = new method(fileName, "Data 5e33 IsoMu24eta2p1", 1, 6, 24, 6, "E", "LP", "treeV2","probePt>30. && TMath::Abs(probeEta)<2.1 && run>178380 &&run<=180252");
  

  
  
  /// different tap studies (different efficiencies)
//    const int folderNum=5;
//    TString folderID[]={"tapTrkQ", "tapIso", "tapMinDR", "tapTotalSelection", "tapTrigger"};
//    TString foldersTitle[]={"ID", "Isolation", "#DeltaR (after Iso Cut)","Overall Selection", "Trigger"};
  
//   const int folderNum=3;
//   TString folderID[]={"tapTotalSelection", "tapTrigger", "tapAll"};
//   TString foldersTitle[]={"Overall Selection", "Trigger", "Combined Selection and Trigger"};
  
    const int folderNum=2;
  TString folderID[]={"tapTotalSelection", "tapTrigger"};
  TString foldersTitle[]={"Muon Selection", "Muon Trigger"};
  
//     const int folderNum=1;
//     /// to combine selection and trigger efficiencies use tapAll:
//   TString folderID[]={"tapAll"};
//   TString foldersTitle[]={"Combined Selection and Trigger"};
  
//   const int folderNum=1;
//   TString folderID[]={"tapTrigger"};
//   TString foldersTitle[]={"Trigger"};


  /// effName = name of the effHisto; variables: corresponding variable to effName; cuts: corresponding cut to effName

   TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR","lepLepMass"};
  //TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "PtEta0to1p5", "PtEta1p5to2p1"};
  //TString effIDarr[]      = {"Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR"};
  //TString effIDarr[]      = {"Pt"};
  std::vector<TString> effID(effIDarr, effIDarr + sizeof(effIDarr)/sizeof(TString));
  int effIDNum = effID.size();
  std::cout<< "Number of considered plots: " <<  effIDNum << std::endl;
  
  
   TString effIDarr2[]      = {};
  //TString effIDarr2[]      = {"PtEta0to1p2", "PtEta1p2to2p1", "EtaPt30to45", "EtaPt45to60", "EtaPtGreater60", "PtMedian", "Pt3bins"};
  std::vector<TString> effID2(effIDarr2, effIDarr2 + sizeof(effIDarr2)/sizeof(TString));
  int effIDNum2 = effID2.size();
  std::cout<< "Number of considered plots 2: " <<  effIDNum2 << std::endl;
    
  /// map with structure that keeps features of histograms
  std::map<TString, std::map<TString, eff*> > eff_;
  
  /// title for histo, x and y axis (separated by "/")
  TString title0 ="";
  TString title ="";
  
  /// axis range
  //double yLo = 0.5, yHi = 1.1;
  double yLo = 0.7, yHi = 1.;
  double yLoSF = 0.9, yHiSF = 1.1;
  
  /// Constructor for struct eff(TString iniVar, T  iniCuts, TString iniBins, TString iniTitles, double iniYLo=-9999., double iniYHi=-9999., double iniXLo=-9999., double iniXHi=-9999.)
  TCut cutPt  = "probePt>30."; /*"(probePt>30. || testPt>30. )";*/
  TCut cutEta = "TMath::Abs(probeEta)<2.1"; /*"(TMath::Abs(probeEta)<2.1 || TMath::Abs(testEta)<2.1)";*/
  TCut cutPtEta = cutPt && cutEta;
  for(int iFolder=0; iFolder < folderNum; iFolder++){
    title = foldersTitle[iFolder]+" Efficiency/ / ";
    eff_["Control"][folderID[iFolder]]        =new eff("Control", cutPtEta, mBinsControl, binsControl_, title, yLo, yHi, -9999.,-9999.);
    title = foldersTitle[iFolder]+" Efficiency/p_{T} [GeV]/ ";
    eff_["Pt"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtAN_, title, yLo, yHi, 30.,200.);
    title = foldersTitle[iFolder]+" Efficiency/#eta/ ";
    eff_["Eta"][folderID[iFolder]]             =new eff("Eta", cutPt, mBinsEta, binsEta_, title, yLo, yHi,-2.1,2.1);
    title = foldersTitle[iFolder]+" Efficiency/relIso/ ";
    eff_["RelIso"][folderID[iFolder]]          =new eff("RelIso", cutPtEta, mBinsRelIso, binsRelIso_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/absIso/ ";
    eff_["AbsIso"][folderID[iFolder]]          =new eff("AbsIso", cutPtEta, mBinsAbsIso, binsAbsIso_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Primary Vertices/ ";
    eff_["PVMult"][folderID[iFolder]]          =new eff("PVMult", cutPtEta, mBinsPVMult, binsPVMult_, title, yLo, yHi,0.,20.);
    title = foldersTitle[iFolder]+" Efficiency/N_{jet}/ ";
    eff_["Mult"][folderID[iFolder]]            =new eff("Mult", cutPtEta, mBinsMult, binsMult_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Minimum #DeltaR(#mu,jet)/ ";
    eff_["MinDR"][folderID[iFolder]]            =new eff("MinDR", cutPtEta, mBinsMinDR, binsMinDR_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Minimum M_{lep,lep}/ ";
    eff_["lepLepMass"][folderID[iFolder]]            =new eff("lepLepMass", cutPtEta, mBinsLepLepMass, binsLepLepMass_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 0<#eta<1.2/p_{T} [GeV]/ ";
    eff_["PtEta0to1p2"][folderID[iFolder]]             =new eff("Pt", "TMath::Abs(probeEta)<1.2", mBinsPt, binsPt_, title, yLo, yHi, 30.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency 1.2<#eta<2.1/p_{T} [GeV]/ ";
    eff_["PtEta1p2to2p1"][folderID[iFolder]]             =new eff("Pt", "TMath::Abs(probeEta)>1.2 && TMath::Abs(probeEta)<2.1", mBinsPt, binsPt_, title, yLo, yHi, 30.,200.,true);
    
    title = foldersTitle[iFolder]+" Efficiency, 30<p_{T}<45/#eta/ ";
    eff_["EtaPt30to45"][folderID[iFolder]]             =new eff("Eta", "probePt>30. && probePt<45.", mBinsEta, binsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 45<p_{T}<60/#eta/ ";
    eff_["EtaPt45to60"][folderID[iFolder]]             =new eff("Eta", "probePt>45. && probePt<60.", mBinsEta, binsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 60<p_{T}/#eta/ ";
    eff_["EtaPtGreater60"][folderID[iFolder]]             =new eff("Eta", "probePt>60.", mBinsEta, binsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency AN/p_{T} [GeV]/ ";
    eff_["PtAN"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtAN_, title, yLo, yHi, 30.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency Median/p_{T} [GeV]/ ";
    eff_["PtMedian"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtMedian_, title, yLo, yHi, 30.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency 3 bins/p_{T} [GeV]/ ";
    eff_["Pt3bins"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPt3bins_, title, yLo, yHi, 30.,200.);
  }

  /// ---
  /// get efficiencies from tree or histo
  ///  ---
  for(int iMethod=0; iMethod<mIDNum; iMethod++){
    for(int iEff=0; iEff<effIDNum; iEff++){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	getEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder]);
      }
    }
      
      for(int iEff=0; iEff<effIDNum2; iEff++){
	for(int iFolder=0; iFolder<folderNum; iFolder++){
	  getEfficiencies(eff_[effID2[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder]);
	}
	
    }
  }

 /// Draw one Canvas for each folder comparing different methods.
 /// Each canvas shows test (1st row) and probe collection (2nd) and efficiency (3rd) for different variables (columns)
  TCanvas* CanvComp [folderNum];
  TCanvas* CanvSFComp [folderNum];
  TCanvas* CanvEvtsComp [folderNum];
  TCanvas* CanvEvtsNormComp [folderNum];
  TCanvas* CanvLeg = new TCanvas("CanvLeg", "CanvLeg", 350,200);
  
  TCanvas* CanvComp2 [folderNum];
  TCanvas* CanvSFComp2 [folderNum];

  std::cout<< "Drawing eff. and SF"<<std::endl;
  for(int iFolder=0; iFolder<folderNum; iFolder++) {

    CanvComp[iFolder] = new TCanvas("Comparison"+folderID[iFolder], "Comparison"+folderID[iFolder], 1700,1000);
    CanvSFComp[iFolder] = new TCanvas("ComparisonSF"+folderID[iFolder], "ComparisonSF"+folderID[iFolder], 1700,1000);
    CanvEvtsComp[iFolder] = new TCanvas("ComparisonEvts"+folderID[iFolder], "ComparisonEvts"+folderID[iFolder], 1700,1000);
    CanvEvtsNormComp[iFolder] = new TCanvas("ComparisonEvtsNorm"+folderID[iFolder], "ComparisonEvtsNorm"+folderID[iFolder], 1700,1000);
    
    CanvComp2[iFolder] = new TCanvas("Comparison2"+folderID[iFolder], "Comparison2"+folderID[iFolder], 1700,1000);
    CanvSFComp2[iFolder] = new TCanvas("ComparisonSF2"+folderID[iFolder], "ComparisonSF2"+folderID[iFolder], 1700,1000);
    
    CanvComp[iFolder]->Divide(4,2);
    CanvSFComp[iFolder]->Divide(4,2);
    CanvEvtsComp[iFolder]->Divide(4,2);
    CanvEvtsNormComp[iFolder]->Divide(4,2);
    
    CanvComp2[iFolder]->Divide(4,2);
    CanvSFComp2[iFolder]->Divide(4,2);
  
    for(int iEff=0; iEff<effIDNum; iEff++){
      CanvComp[iFolder]->cd(iEff+1);
//       CanvComp[iFolder]->cd(iEff+1)->SetGrid(1,1);
      std::cout<< "Drawing eff."<<std::endl;
      drawEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
      CanvSFComp[iFolder]->cd(iEff+1);
      std::cout<< "Drawing SF"<<std::endl;
      drawSF          (eff_[effID[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID[iEff]][folderID[iFolder]]->xLo, eff_[effID[iEff]][folderID[iFolder]]->xHi);
    // if desired plot also raw event number histos
      if(onlyEffPlots!=1) {
	std::cout<< "Drawing event numbers"<<std::endl;
	CanvEvtsComp[iFolder]->cd(iEff+1);
	drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
	CanvEvtsNormComp[iFolder]->cd(iEff+1);
	drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend,"normInt");
      }
    }
    
    for(int iEff=0; iEff<effIDNum2; iEff++){
      CanvComp2[iFolder]->cd(iEff+1);
//       CanvComp[iFolder]->cd(iEff+1)->SetGrid(1,1);
      std::cout<< "Drawing eff. 2"<<std::endl;
      drawEfficiencies(eff_[effID2[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend);
      CanvSFComp2[iFolder]->cd(iEff+1);
      std::cout<< "Drawing SF"<<std::endl;
      drawSF          (eff_[effID2[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.15,0.15,0.9,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID2[iEff]][folderID[iFolder]]->xLo, eff_[effID2[iEff]][folderID[iFolder]]->xHi);
    }
    
    
  // draw legend
    CanvLeg->cd();
    if(iFolder==0) drawLegend(eff_[effID[0]][folderID[0]], method_, mID, 0.,0.,1.,1.);
  
//   effControl[iMethod][iFolder]->GetXaxis()->SetNdivisions(0);
//   effRelIso[iMethod][iFolder]->GetXaxis()->SetNdivisions(505);
 
    if(save){
      for(unsigned int iFileFormat=0; iFileFormat < fileFormat.size(); iFileFormat++){
	CanvComp[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_overview."+fileFormat[iFileFormat]);
	for(int iEff=0; iEff<effIDNum; iEff++){
	  CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	  CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	}
	
	for(int iEff=0; iEff<effIDNum2; iEff++){
	  CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
	  CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
	}
	
	if(iFolder==0) CanvLeg->Print(outputFolder+outputFileName+"_Legend."+fileFormat[iFileFormat]);
	std::cout<<"Canvas with plots is saved in "<<outputFolder<<std::endl;
      }
    }
  }
  std::cout<< "Done"<<std::endl;
}
void tagAndProbePlotsRun2012_MCdataCom_Ele27WP80(bool save=false, bool saveRoot=false)
{
  /// decide whether to do 1D or 2D plots or both
  bool do1D = true;
  bool do2D = true;
  
  /// set style
  // ============================
  //  Set ROOT Style
  // ============================
 
  gROOT->Reset();
//   gROOT->SetStyle("Plain");
//   
//   TStyle myStyle("HHStyle","HHStyle");
//   setHHStyle(myStyle);
//   TGaxis::SetMaxDigits(2);
//   myStyle.cd();
//   gROOT->SetStyle("HHStyle");
//   gROOT->ForceStyle();  
  
  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetLegendBorderSize(0);
  gStyle->SetPadBottomMargin(0.11);
  gStyle->SetLabelSize(0.05,"XY");
  gStyle->SetTitleSize(0.05,"XY");
  gStyle->SetFillColor(0);
  gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  gStyle->SetPadTickY(1);
  
//   const int fontstyle1=62;
  const int fontstyle1=42;
  gStyle->SetTitleFont(fontstyle1);
  gStyle->SetTitleFont(fontstyle1, "XYZ");
  gStyle->SetLabelFont(fontstyle1, "XYZ");
  gStyle->SetTextFont(fontstyle1);
  
  // for 2D histo text
  gStyle->SetPaintTextFormat("3.3f");
  gStyle->SetPalette(1);
  
  /// path where input files are stored
  TString inputPathScratch  ="/afs/naf.desy.de/group/cms/scratch/tophh/efficiencies";
  
//   TString outputFolder   = "/afs/desy.de/user/j/jlange/analysis/tagAndProbe/plots/2012/singleEle";
  TString outputFolder   = "/afs/desy.de/user/j/jlange/analysis/tagAndProbe/plots/2012/singleEleFineBinned";
 TString outputFileName = "/DataMCcomp_Ele27WP80_";

  TString fileFormatArr []= {"root", "png", "eps"};
  std::vector<TString> fileFormat(fileFormatArr, fileFormatArr + sizeof(fileFormatArr)/sizeof(TString));
  
  /// if set to 0: all plots (probe, test, eff) are drawn; to 1: only eff plots
  int onlyEffPlots =1;
  /// method ID of MC file to normalise scale factors to
   TString mIDnorm = "m1";
  //TString mIDnorm = "m1-25TriJetPUEPS";
  std::cout<< "Efficiency wrt. which SF is supposed to be normalized " <<  mIDnorm << std::endl;

  
   /// map with structure that keeps features of methods, like file, filename, legend etc.
  std::map<TString, method*> method_;
  
  /// standard for nice plots:
//   TString mIDarr []= {"m1","m2"};
  /// for different PU scenarios: (also savable in root file)
  TString mIDarr []= {"m1", "m1PUup", "m1PUdown", "m2", "m2PUup", "m2PUdown"};

  std::vector<TString> mID(mIDarr, mIDarr + sizeof(mIDarr)/sizeof(TString));
  int mIDNum = mID.size();
  std::cout<< "Number of considered methods (i.e. files): " <<  mIDNum << std::endl;
  
  // check if mIDnorm is in vector and give error if not
  bool inVector=false;
  for(int i=0; i< mIDNum; i++) if(mID[i]==mIDnorm) inVector=true;
  if(!inVector) {
    std::cout<<"ERROR!!!! Efficiency wrt. which SF is supposed to be normalized is not in mID vector!!! "<<std::endl; 
    return;
  }
  
  TString fileName ;
  
    /// Define histo and legend styles and options
//   int lineStyle   []= {1,1,1,1,1,1};
//   int lineColor   []= {2,1,4,kGreen+2,kGray+2,3};
//   int markerStyle []={1,21,22,20,22,23};
//   int markerColor []= {2,1,4,kGreen+2,kGray+2,3};
//   TString drawOpt []= {"","E X0 P same","E X0 P same","E X0 same","E X0 same","E same"};
//   TString legOpt  []= {"L","P","P","P","P","P"};
//   bool legOnPlot = false;
  
  /// Define pt and eta cuts for TH2 
  /// TCut does not work for TH2
  double cutPt2D  = 33.;
  double cutEta2D = 2.1;
  
  /// option to select different cuts 
  TCut cutEle = "probePt>33. && TMath::Abs(probeEta)<2.1";
  
  /// Constructor for struct method(TString iniFileName, TString iniLegName, int iniLineStyle, int iniLineColor, int iniMarkerStyle, int iniMarkerColor, TString iniDrawOpt, TString iniLepOpt, TString source)
  
   /// Summer12 MC
  fileName=inputPathScratch+"/analyzeZEleEleTagAndProbeMCSummer12_HLT_Ele27WP80.root";
  method_["m1"] = new method(fileName, "Simulation Ele27WP80", 1, 2, 1, 1, "E", "L", "treeV2",cutEle,"eventWeightPUeventWeightPU");
  
  method_["m1PUup"] = new method(fileName, "Simulation Ele27WP80 PUrew UP", 1, 2, 1, 1, "E", "L", "treeV2",cutEle,"eventWeightPUsysUpeventWeightPUUp","m1PUup");
  
  method_["m1PUdown"] = new method(fileName, "Simulation Ele27WP80 PUrew DOWN", 1, 2, 1, 1, "E", "L", "treeV2", cutEle, "eventWeightPUsysDowneventWeightPUDown","m1PUdown");
  
 
  /// data
  fileName=inputPathScratch+"/analyzeZEleEleTagAndProbeRun2012ABCDJan22ReReco_HLT_Ele27WP80.root";
  method_["m2"] = new method(fileName, "Data Ele27WP80", 1, 1, 24, 1, "E", "PL", "treeV2",cutEle, "","m1");
  
  method_["m2PUup"] = new method(fileName, "Data Ele27WP80 PU up", 1, 1, 25, 1, "E", "LP", "treeV2",cutEle,"","m1PUup");
  
  method_["m2PUdown"] = new method(fileName, "Data Ele27WP80 PU down", 1, 1, 26, 1, "E", "LP", "treeV2",cutEle,"","m1PUdown");
  
  /// different tap studies (different efficiencies)

//   const int folderNum=6;
//    TString folderID[]={"tapTrkQEle", "tapIDEle", "tapIsoEle", "tapConvRejEle", "tapTotalSelectionEle", "tapTriggerEle"};
//    TString foldersTitle[]={"Electron Track Quality", "Electron ID", "Electron Isolation", "Electron Conversion Rejection", "Electron Selection", "Electron Trigger"};
  
//      const int folderNum=6;
//    TString folderID[]={"tapTrkQEle", "tapIDEle", "tapIsoEle", "tapConvRejEle", "tapTotalSelectionEle", "tapTriggerEle"};
//    TString foldersTitle[]={"Electron d_{0}", "Electron ID_{CiC}", "Electron Isolation", "Electron Conversion Rejection", "Electron Selection", "Electron Trigger"};
  
//   const int folderNum=4;
//   TString folderID[]={"tapTrkQEle", "tapIDEle", "tapIsoEle", "tapConvRejEle"};
//   TString foldersTitle[]={"Electron d_{0}", "Electron ID_{CiC}", "Electron Isolation", "Electron Conversion Rejection"};
   
//    const int folderNum=2;
//    TString folderID[]={"tapTotalSelectionEle", "tapTriggerEle"};
//    TString foldersTitle[]={"Electron Selection", "Electron Trigger"};
  
//   const int folderNum=1;
//   TString folderID[]={"tapTotalSelectionEle"};
//   TString foldersTitle[]={"Electron Selection"};
  
//   const int folderNum=1;
//   TString folderID[]={"tapTriggerEle"};
//   TString foldersTitle[]={"Trigger"};
  
//      const int folderNum=3;
//    TString folderID[]={"tapTotalSelectionEle", "tapTriggerEle", "tapAllEle"};
//    TString foldersTitle[]={"Overall Selection", "Trigger", "Combined Selection and Trigger"};
  
/// to combine selection and trigger efficiencies use tapAll:
    const int folderNum=1;
  TString folderID[]={"tapAllEle"};
  TString foldersTitle[]={"Combined Selection and Trigger"};



  /// effName = name of the effHisto; variables: corresponding variable to effName; cuts: corresponding cut to effName

//    TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR","Pt_inclLegend"};
  TString effIDarr[]      = {"Control", "Pt", "Eta", "PVMult", "MinDR","EtaPt33to39","EtaPt39to45","EtaPtGreater45"};
//  TString effIDarr[]      = {"Pt_inclLegend"};
   //TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR","lepLepMass"};
  //TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "PtEta0to1p5", "PtEta1p5to2p1"};
  //TString effIDarr[]      = {"Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR"};
  //TString effIDarr[]      = {"Pt"};
  std::vector<TString> effID(effIDarr, effIDarr + sizeof(effIDarr)/sizeof(TString));
  int effIDNum = effID.size();
  std::cout<< "Number of considered plots: " <<  effIDNum << std::endl;
  
  
  TString effIDarr2[]      = {};
  //TString effIDarr2[]      = {"PtEta0to1p2", "PtEta1p2to2p1", "EtaPt30to45", "EtaPt45to60", "EtaPtGreater60", "PtMedian", "Pt3bins"};
  std::vector<TString> effID2(effIDarr2, effIDarr2 + sizeof(effIDarr2)/sizeof(TString));
  int effIDNum2 = effID2.size();
  std::cout<< "Number of considered plots 2: " <<  effIDNum2 << std::endl;
    
  /// map with structure that keeps features of histograms
  std::map<TString, std::map<TString, eff*> > eff_;
  std::map<TString, eff2D*> eff2DPtEta_;
  
  /// title for histo, x and y axis (separated by "/")
  TString title0 ="";
  TString title ="";
  
  /// axis range
  //double yLo = 0.5, yHi = 1.1;
  double yLo = 0.45, yHi = 1.;
  double yLoSF = 0.9, yHiSF = 1.1-0.0001;
  
  /// Constructor for struct eff(TString iniVar, T  iniCuts, TString iniBins, TString iniTitles, double iniYLo=-9999., double iniYHi=-9999., double iniXLo=-9999., double iniXHi=-9999.)
  TCut cutPt  = "probePt>33."; // && probeRelIso<0.2 "; //&& probeMult>1"; /*"(probePt>30. || testPt>30. )";*/
  TCut cutEta = "TMath::Abs(probeEta)<2.1 "; //&& probeRelIso<0.2 "; //&& probeMult>1"; /*"(TMath::Abs(probeEta)<2.1 || TMath::Abs(testEta)<2.1)";*/
  TCut cutPtEta = cutPt && cutEta;
  for(int iFolder=0; iFolder < folderNum; iFolder++){
    title = foldersTitle[iFolder]+" Efficiency/ / ";
    eff_["Control"][folderID[iFolder]]        =new eff("Control", cutPtEta, mBinsControl, binsControl_, title, yLo, yHi, -9999.,-9999.);
    title = foldersTitle[iFolder]+" Efficiency/p_{T} [GeV]/ ";
    eff_["Pt"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtEle_, title, yLo, yHi, 33.,200.);
    title = foldersTitle[iFolder]+" Efficiency/p_{T} [GeV]/ ";
    eff_["Pt_inclLegend"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtAN_, title, yLo, yHi, 33.,200.,true);
    title = foldersTitle[iFolder]+" Efficiency/#eta/ ";
    eff_["Eta"][folderID[iFolder]]             =new eff("Eta", cutPt, mBinsEtaEle, binsEtaEle_, title, yLo, yHi,-2.1,2.1);
    title = foldersTitle[iFolder]+" Efficiency/relIso/ ";
    eff_["RelIso"][folderID[iFolder]]          =new eff("RelIso", cutPtEta, mBinsRelIso, binsRelIso_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/absIso/ ";
    eff_["AbsIso"][folderID[iFolder]]          =new eff("AbsIso", cutPtEta, mBinsAbsIso, binsAbsIso_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/N_{PV}/ ";
    eff_["PVMult"][folderID[iFolder]]          =new eff("PVMult", cutPtEta, mBinsPVMult, binsPVMult_, title, yLo, yHi,0.,40.);
    title = foldersTitle[iFolder]+" Efficiency/N_{jet}/ ";
    eff_["Mult"][folderID[iFolder]]            =new eff("Mult", cutPtEta, mBinsMult, binsMult_, title, yLo, yHi);
    title = foldersTitle[iFolder]+" Efficiency/Minimum #DeltaR(e,jet)/ ";
    eff_["MinDR"][folderID[iFolder]]            =new eff("MinDR", cutPtEta && "probeRelIso<0.2", mBinsMinDR, binsMinDR_, title, yLo, yHi,0.,5.);
    title = foldersTitle[iFolder]+" Efficiency/Minimum M_{lep,lep}/ ";
    eff_["lepLepMass"][folderID[iFolder]]            =new eff("lepLepMass", cutPtEta, mBinsLepLepMass, binsLepLepMass_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 0<#eta<1.2/p_{T} [GeV]/ ";
    eff_["PtEta0to1p2"][folderID[iFolder]]             =new eff("Pt", "TMath::Abs(probeEta)<1.2", mBinsPt, binsPt_, title, yLo, yHi, 33.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency 1.2<#eta<2.1/p_{T} [GeV]/ ";
    eff_["PtEta1p2to2p1"][folderID[iFolder]]             =new eff("Pt", "TMath::Abs(probeEta)>1.2 && TMath::Abs(probeEta)<2.1", mBinsPt, binsPt_, title, yLo, yHi, 33.,200.,true);
    
    title = foldersTitle[iFolder]+" Efficiency, 30<p_{T}<32/#eta/ ";
    eff_["EtaPt30to32"][folderID[iFolder]]             =new eff("Eta", "probePt>30. && probePt<32.", mBinsEtaEle2, binsEtaEle2_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 33<p_{T}<39/#eta/ ";
    eff_["EtaPt33to39"][folderID[iFolder]]             =new eff("Eta", "probePt>33. && probePt<39.", mBinsEtaEle2, binsEtaEle2_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 39<p_{T}<45/#eta/ ";
    eff_["EtaPt39to45"][folderID[iFolder]]             =new eff("Eta", "probePt>39. && probePt<45.", mBinsEtaEle2, binsEtaEle2_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, 45<p_{T}/#eta/ ";
    eff_["EtaPtGreater45"][folderID[iFolder]]             =new eff("Eta", "probePt>45.", mBinsEtaEle2, binsEtaEle2_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency AN/p_{T} [GeV]/ ";
    eff_["PtAN"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtAN_, title, yLo, yHi, 33.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency Median/p_{T} [GeV]/ ";
    eff_["PtMedian"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPtMedian_, title, yLo, yHi, 33.,200.);
    
    title = foldersTitle[iFolder]+" Efficiency 3 bins/p_{T} [GeV]/ ";
    eff_["Pt3bins"][folderID[iFolder]]             =new eff("Pt", cutEta, mBinsPt, binsPt3bins_, title, yLo, yHi, 33.,200.);
    
    /// 2D pt:eta
    title = foldersTitle[iFolder]+" Efficiency/p_{T} [GeV]/#eta/ ";
    eff2DPtEta_[folderID[iFolder]]             =new eff2D("Pt", "Eta", cutPtEta, mBinsPtEle2D, binsPtEle2D_, mBinsEtaEle2D, binsEtaEle2D_, title, yLo, yHi, 33.+0.001,200.-0.001, -2.1+0.001, 2.1-0.001);
  }

  /// ---
  /// get efficiencies from tree or histo
  ///  ---
  for(int iMethod=0; iMethod<mIDNum; iMethod++){
    /// 1D
    if(do1D){
      for(int iEff=0; iEff<effIDNum; iEff++){
	for(int iFolder=0; iFolder<folderNum; iFolder++){
	  getEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder]);
	}
      }
	for(int iEff=0; iEff<effIDNum2; iEff++){
	  for(int iFolder=0; iFolder<folderNum; iFolder++){
	    getEfficiencies(eff_[effID2[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder]);
	  }
      }
    }
    /// 2D
    if(do2D){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	getEfficiencies2D(eff2DPtEta_[folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderID[iFolder], folderID[iFolder], cutPt2D, cutEta2D);
      }
    }    
  }

 /// Draw one Canvas for each folder comparing different methods.
 /// Each canvas shows test (1st row) and probe collection (2nd) and efficiency (3rd) for different variables (columns)
  TCanvas* CanvComp [folderNum];
  TCanvas* CanvSFComp [folderNum];
  TCanvas* CanvEffAndSFComp [folderNum];
  TCanvas* CanvEvtsComp [folderNum];
  TCanvas* CanvEvtsNormComp [folderNum];
  TCanvas* CanvLeg = new TCanvas("CanvLeg", "CanvLeg", 350,200);
  
  TCanvas* CanvComp2 [folderNum];
  TCanvas* CanvSFComp2 [folderNum];
  
  TCanvas* CanvComp2DPtEta [folderNum];
  TCanvas* CanvComp2DPtEtaSF [folderNum];
  TCanvas* CanvComp2DPtEtaSFerr [folderNum];
  TCanvas* CanvComp2DPtEtaPass [folderNum];
  TCanvas* CanvComp2DPtEtaAll [folderNum];

  std::cout<< "Drawing eff. and SF"<<std::endl;
  for(int iFolder=0; iFolder<folderNum; iFolder++) {

    CanvComp[iFolder] = new TCanvas("Comparison"+folderID[iFolder], "Comparison"+folderID[iFolder], 1700,1000);
    CanvSFComp[iFolder] = new TCanvas("ComparisonSF"+folderID[iFolder], "ComparisonSF"+folderID[iFolder], 1700,1000);
    CanvEffAndSFComp[iFolder] = new TCanvas("ComparisonEffAndSF"+folderID[iFolder], "ComparisonEffAndSF"+folderID[iFolder], 1700,1000);
    CanvEvtsComp[iFolder] = new TCanvas("ComparisonEvts"+folderID[iFolder], "ComparisonEvts"+folderID[iFolder], 1700,1000);
    CanvEvtsNormComp[iFolder] = new TCanvas("ComparisonEvtsNorm"+folderID[iFolder], "ComparisonEvtsNorm"+folderID[iFolder], 1700,1000);
    
    CanvComp2[iFolder] = new TCanvas("Comparison2"+folderID[iFolder], "Comparison2"+folderID[iFolder], 1700,1000);
    CanvSFComp2[iFolder] = new TCanvas("ComparisonSF2"+folderID[iFolder], "ComparisonSF2"+folderID[iFolder], 1700,1000);
    
    CanvComp[iFolder]->Divide(4,2);
    CanvSFComp[iFolder]->Divide(4,2);
    CanvEffAndSFComp[iFolder]->Divide(4,2);
    CanvEvtsComp[iFolder]->Divide(4,2);
    CanvEvtsNormComp[iFolder]->Divide(4,2);
    
    CanvComp2[iFolder]->Divide(4,2);
    CanvSFComp2[iFolder]->Divide(4,2);
  
    /// 1D
    if(do1D){
      for(int iEff=0; iEff<effIDNum; iEff++){
	CanvComp[iFolder]->cd(iEff+1);
  //       CanvComp[iFolder]->cd(iEff+1)->SetGrid(1,1);
  //       std::cout<< "Drawing eff."<<std::endl;
  //       drawEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.12,0.6,1.0,0.9,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
  //       CanvSFComp[iFolder]->cd(iEff+1);
  //       std::cout<< "Drawing SF"<<std::endl;
  //       drawSF          (eff_[effID[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.12,0.15,1.0,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID[iEff]][folderID[iFolder]]->xLo, eff_[effID[iEff]][folderID[iFolder]]->xHi);
	std::cout<< "Drawing Eff. and SF"<<std::endl;
	CanvEffAndSFComp[iFolder]->cd(iEff+1);
	drawEffAndSFinOne          (eff_[effID[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.12,0.15,1.0,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID[iEff]][folderID[iFolder]]->xLo, eff_[effID[iEff]][folderID[iFolder]]->xHi);
      /// if desired plot also raw event number histos
	if(onlyEffPlots!=1) {
	  std::cout<< "Drawing event numbers"<<std::endl;
	  CanvEvtsComp[iFolder]->cd(iEff+1);
	  drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.12,0.15,1.0,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
	  CanvEvtsNormComp[iFolder]->cd(iEff+1);
	  drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.12,0.15,1.0,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend,"normInt");
	}
      }
      for(int iEff=0; iEff<effIDNum2; iEff++){
	CanvComp2[iFolder]->cd(iEff+1);
  //       CanvComp[iFolder]->cd(iEff+1)->SetGrid(1,1);
	std::cout<< "Drawing eff. 2"<<std::endl;
	drawEfficiencies(eff_[effID2[iEff]][folderID[iFolder]], method_, mID, 0.12,0.15,1.0,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend);
	CanvSFComp2[iFolder]->cd(iEff+1);
	std::cout<< "Drawing SF"<<std::endl;
	drawSF          (eff_[effID2[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.12,0.15,1.0,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID2[iEff]][folderID[iFolder]]->xLo, eff_[effID2[iEff]][folderID[iFolder]]->xHi);
      }
    }
    
    /// draw 2D efficiencies
    if(do2D){

      CanvComp2DPtEta[iFolder] = new TCanvas("Comparison2DPtEta"+folderID[iFolder], "Comparison2DPtEta"+folderID[iFolder], 1700,1000);
      CanvComp2DPtEta[iFolder]->Divide((mIDNum+1)/2,2);
      
      CanvComp2DPtEtaSF[iFolder] = new TCanvas("Comparison2DPtEtaSF"+folderID[iFolder], "Comparison2DPtEtaSF"+folderID[iFolder], 1700,1000);
      CanvComp2DPtEtaSF[iFolder]->Divide((mIDNum+1)/2,2);
      
      CanvComp2DPtEtaSFerr[iFolder] = new TCanvas("Comparison2DPtEtaSFerr"+folderID[iFolder], "Comparison2DPtEtaSFerr"+folderID[iFolder], 1700,1000);
      CanvComp2DPtEtaSFerr[iFolder]->Divide((mIDNum+1)/2,2);
      
      CanvComp2DPtEtaPass[iFolder] = new TCanvas("Comparison2DPtEtaPass"+folderID[iFolder], "Comparison2DPtEtaPass"+folderID[iFolder], 1700,1000);
      CanvComp2DPtEtaPass[iFolder]->Divide((mIDNum+1)/2,2);
      
      CanvComp2DPtEtaAll[iFolder] = new TCanvas("Comparison2DPtEtaAll"+folderID[iFolder], "Comparison2DPtEtaAll"+folderID[iFolder], 1700,1000);
      CanvComp2DPtEtaAll[iFolder]->Divide((mIDNum+1)/2,2);
      
      std::cout<< "Drawing 2D Pt Eta Eff."<<std::endl;
      for(unsigned int iMethod=0; iMethod<mID.size(); iMethod++){
	CanvComp2DPtEta[iFolder]->cd(iMethod+1);
	eff2DPtEta_[folderID[iFolder]]->his[mID[iMethod]]->Draw("colz text");
	
	CanvComp2DPtEtaPass[iFolder]->cd(iMethod+1);
	eff2DPtEta_[folderID[iFolder]]->hisPass[mID[iMethod]]->Draw("colz text");
	
	CanvComp2DPtEtaAll[iFolder]->cd(iMethod+1);
	eff2DPtEta_[folderID[iFolder]]->hisAll[mID[iMethod]]->Draw("colz text");

	/// 2D SF!!!
	std::cout<< "Drawing 2D SF"<<std::endl;
	
	CanvComp2DPtEtaSF[iFolder]->cd(iMethod+1);
	getSF2D (eff2DPtEta_[folderID[iFolder]], method_, mID, mIDnorm, 0.8, 1.2);
	eff2DPtEta_[folderID[iFolder]]->hisSF[mID[iMethod]]->Draw("colz text");
	
	CanvComp2DPtEtaSFerr[iFolder]->cd(iMethod+1);
	eff2DPtEta_[folderID[iFolder]]->hisSFerr[mID[iMethod]]->Draw("colz text");
      }
    }
    
  // draw legend
    CanvLeg->cd();
    if(iFolder==0) drawLegend(eff_[effID[0]][folderID[0]], method_, mID, 0.,0.,1.,1.);
  
//   effControl[iMethod][iFolder]->GetXaxis()->SetNdivisions(0);
//   effRelIso[iMethod][iFolder]->GetXaxis()->SetNdivisions(505);
 
    if(save){
      for(unsigned int iFileFormat=0; iFileFormat < fileFormat.size(); iFileFormat++){
	if(do1D){
	  CanvComp[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_overview."+fileFormat[iFileFormat]);
	  for(int iEff=0; iEff<effIDNum; iEff++){
	  // 	  CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	  // 	  CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	    CanvEffAndSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_EffAndSF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
	  }
	  for(int iEff=0; iEff<effIDNum2; iEff++){
	    CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
	    CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
	  }
	}
	/// 2D
	if(do2D){
	  CanvComp2DPtEta[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+"Eff2DPtEta."+fileFormat[iFileFormat]);
	  CanvComp2DPtEtaSF[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+"SF2DPtEta."+fileFormat[iFileFormat]);
	}
	if(iFolder==0) CanvLeg->Print(outputFolder+outputFileName+"_Legend."+fileFormat[iFileFormat]);
	std::cout<<"Canvas with plots is saved in "<<outputFolder<<std::endl;
      }
    }
    /// save graph in root file
    /// 1D
    if(saveRoot && do1D){
      TFile f("EleEffSF2012.root", "recreate");
      eff_["Eta"]["tapAllEle"]->graphSF["m2"]->SetName("tapAllSFeta");
      eff_["Eta"]["tapAllEle"]->graphSF["m2"]->Write();
      eff_["Eta"]["tapAllEle"]->graphSF["m2PUup"]->SetName("tapAllSFetaPUup");
      eff_["Eta"]["tapAllEle"]->graphSF["m2PUup"]->Write();
      eff_["Eta"]["tapAllEle"]->graphSF["m2PUdown"]->SetName("tapAllSFetaPUdown");
      eff_["Eta"]["tapAllEle"]->graphSF["m2PUdown"]->Write();
      std::cout<<"EleEffSF2012.root with TGraphErrors is saved "<<std::endl;
    }
    /// 2D
    if(saveRoot && do2D){
      TFile f("EleEffSF2D2012.root", "recreate");
      eff2DPtEta_[ "tapAllEle"]->hisSF["m2"]->SetName("tapAllSFeta");
      eff2DPtEta_[ "tapAllEle"]->hisSF["m2"]->Write();
      eff2DPtEta_[ "tapAllEle"]->hisSF["m2PUup"]->SetName("tapAllSFetaPUup");
      eff2DPtEta_[ "tapAllEle"]->hisSF["m2PUup"]->Write();
      eff2DPtEta_[ "tapAllEle"]->hisSF["m2PUdown"]->SetName("tapAllSFetaPUdown");
      eff2DPtEta_[ "tapAllEle"]->hisSF["m2PUdown"]->Write();
      std::cout<<"EleEffSF2D2012.root with 2D SF Histos is saved in "<<std::endl;
    }
  }
  std::cout<< "Done"<<std::endl;
}
void crossTriggerIndependentControlTrigRun2011_SingleLep_LepTriJet_MuHadDifferentRunRanges(bool save=false)
{
  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetLegendBorderSize(0);
  gStyle->SetPadBottomMargin(0.11);
  gStyle->SetLabelSize(0.05,"XY");
  gStyle->SetTitleSize(0.05,"XY");
  gStyle->SetFillColor(0);
  gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  gStyle->SetPadTickY(1);
  
//   const int fontstyle1=62;
  const int fontstyle1=42;
  gStyle->SetTitleFont(fontstyle1);
  gStyle->SetTitleFont(fontstyle1, "XYZ");
  gStyle->SetLabelFont(fontstyle1, "XYZ");
  gStyle->SetTextFont(fontstyle1);
  
  
  /// path where input files are stored
  TString inputPathScratch  ="/scratch/hh/current/cms/user/jlange/output_4_2_4/fullLeptonic";
  TString inputPath42       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_4/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  TString inputPath428       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_8_patch7/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  
  TString outputFolder   = "/afs/desy.de/user/j/jlange/analysis/tagAndProbe/plots/2011/LepHad/PF2PAT/MuDifferentRunRanges";
//   TString outputFileName = "/MuDifferentRunRanges";
  TString outputFileName = "/MuDifferentRunRanges3Jets";

  TString fileFormatArr []= {"root", "png", "eps"};
  std::vector<TString> fileFormat(fileFormatArr, fileFormatArr + sizeof(fileFormatArr)/sizeof(TString));
  
  /// if set to 0: all plots (probe, test, eff) are drawn; to 1: only eff plots
  int onlyEffPlots =0;
  /// method ID of MC file to normalise scale factors to
  //TString mIDnorm = "m1WMu";
  TString mIDnorm = "m2allMu";
  //TString mIDnorm = "m1ttWcombMu";
  std::cout<< "Efficiency wrt. which SF is supposed to be normalized " <<  mIDnorm << std::endl;
  
  /// if two efficiencies should be averaged:
  /// destination method (leave empty if no averaging is supposed to take place):
  TString averageMIDdestination = "";
  TString averageMIDdestination_2 = "";
  //TString averageMIDdestination  = "m1ttWcombMu";
  /// first method to enter the averaging
  TString averageMID1  = "m1ttMuEPS";
  TString averageMID1_2= "m1ttEleEPS";
  /// second method to enter the averaging
  TString averageMID2  = "m1WMuEPS";
  TString averageMID2_2= "m1WEleEPS";

   /// map with structure that keeps features of methods, like file, filename, legend etc.
  std::map<TString, method*> method_;
  
//   TString mIDarr []= {"m1tt", "m1W", "m2", "m3", "m11", "m12"};
  //TString mIDarr []= {"m1ttEle", "m2allEle", "m2EPSEle", "m2ApostEPSEle", "m2B3e33Ele", "m2B5e33-WP70Ele"};
  TString mIDarr []= {"m2allMu", "m2AMu", "m2B3e33Mu", "m2B5e33Mu"};
  //TString mIDarr []= {"m1ttMu", "m1WMu", "m1ttWcombMu", "m2allMu"};
  //TString mIDarr []= {"m1ttMu", "m1WMu", "m2allMu"};
  //TString mIDarr []= {"m1ttEle", "m1WEle", "m2allEle"};
//   TString mIDarr []= {"m1ttEle", "m1ttMu", "m1WEle", "m1WMu"};
//   TString mIDarr []= {"m1ttEleEPS", "m1ttMuEPS", "m1WEleEPS", "m1WMuEPS", "m1ttWcombEleEPS", "m1ttWcombMuEPS", "m2EPSEle", "m2EPSMu"};
  //TString mIDarr []= {"m1ttEleEPS", "m1ttMuEPS", "m1WEleEPS", "m1WMuEPS","m2EPSEle", "m2EPSMu"};
  //TString mIDarr []= {"m1ttEle", "m1ttMu", "m2allEle", "m2allMu"};
 // TString mIDarr []= {"m1ttEle", "m2allEle", "m2EPSEle", "m2ApostEPSEle", "m2B3e33Ele", "m2B5e33-WP70Ele", "m1ttMu", "m2allMu", "m2EPSMu", "m2ApostEPSMu", "m2B3e33Mu", "m2B5e33Mu"};

  std::vector<TString> mID(mIDarr, mIDarr + sizeof(mIDarr)/sizeof(TString));
  int mIDNum = mID.size();
  std::cout<< "Number of considered methods (i.e. files): " <<  mIDNum << std::endl;
  
  // check if mIDnorm is in vector and give error if not
  bool inVector=false;
  for(int i=0; i< mIDNum; i++) if(mID[i]==mIDnorm) inVector=true;
  if(!inVector) {
    std::cout<<"ERROR!!!! Efficiency wrt. which SF is supposed to be normalized is not in mID vector!!! "<<std::endl; 
    return;
  }
  
  TString fileName ;
  
    /// Define histo and legend styles and options
//   int lineStyle   []= {1,1,1,1,1,1};
//   int lineColor   []= {2,1,4,kGreen+2,kGray+2,3};
//   int markerStyle []={1,21,22,20,22,23};
//   int markerColor []= {2,1,4,kGreen+2,kGray+2,3};
//   TString drawOpt []= {"","E X0 P same","E X0 P same","E X0 same","E X0 same","E same"};
//   TString legOpt  []= {"L","P","P","P","P","P"};
//   bool legOnPlot = false;
  
  /// Constructor for struct method(TString iniFileName, TString iniLegName, int iniLineStyle, int iniLineColor, int iniMarkerStyle, int iniMarkerColor, TString iniDrawOpt, TString iniLepOpt, TString source)

  /// Electrons:
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoEle32_IsoEle25TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoEle32_IsoEle25TriJet.root";
  method_["m1ttEle"] = new method(fileName, "MC t#bar{t}", 2, 2, 1, 2, "E same", "LP","treeV2","","eventWeightPUeventWeightPU");
  //weight
  //Summer11 tt IsoEle27_Ele25TriJet
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoEle32_IsoEle25TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoEle32_IsoEle25TriJet.root";
  method_["m1ttEleEPS"] = new method(fileName, "t#bar{t} (EleHad)", 2, 2, 1, 2, "E same", "LP","treeV2","","eventWeightPUEPSeventWeightPUEPS");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCSFall11WJets_IsoEle32_IsoEle25TriJet_cfg/prel.root";
  method_["m1WEle"] = new method(fileName, "MC W IsoEle32_Ele25TriJet", 2, 8, 1, 8, "E same", "LP","treeV2","","eventWeightPUeventWeightPU");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCSFall11WJets_IsoEle32_IsoEle25TriJet_cfg/prel.root";
  method_["m1WEleEPS"] = new method(fileName, "W (EleHad)", 2, 8, 1, 8, "E same", "LP","treeV2","","eventWeightPUEPSeventWeightPUEPS");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoEle32_IsoEle25TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoEle32_IsoEle25TriJet.root";
  method_["m1ttWcombEleEPS"] = new method(fileName, "t#bar{t} and W (EleHad)", 2, 1, 1, 1, "E same", "LP","treeV2","","eventWeightPUEPSeventWeightPUEPS");
  
//   fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCSummer11ZJets_IsoEle27_Ele25TriJet_cfg_TreeV2/analyzeCrossTriggerRatiosMCSummer11ZJets_IsoEle27_Ele25TriJet_TreeV2.root";
//   method_["m1Z"] = new method(fileName, "Summer11 Z IsoEle27_Ele25TriJet", 1, 4, 1, 1, "E same", "LP","treeV2","","weight");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCFall11_HLT_IsoEle32_IsoEle25TriJet.root";
  method_["m1TaPEle"] = new method(fileName, "MC Z IsoEle32_Ele25TriJet", 2, 4, 1, 4, "E same", "LP","treeV2","","weight");
  
  /// Ele data
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2allEle"] = new method(fileName, "Data full 2011", 2, 1, 21, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2EPSEle"] = new method(fileName, "Data 1 fb^{-1} (EleHad)", 2, 4, 25, 4, "E same", "LP","treeV2","runNumber<=167913","");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2AEle"] = new method(fileName, "Data 2011A (EleHad)", 2, 4, 25, 4, "E same", "LP","treeV2","runNumber<=175570","");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2ApostEPSEle"] = new method(fileName, "Data A post EPS", 2, 4, 25, 4, "E same", "LP","treeV2","runNumber>167913 && runNumber<=175570","");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2B3e33Ele"] = new method(fileName, "Data B 3e33", 2, 8, 23, 8, "E same", "LP","treeV2","runNumber>175570 && runNumber<=178380","");
  
  fileName=inputPath428+"/naf_analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeRun2011All_HLT_IsoEle27_32_IsoEle25TriJet.root";
  method_["m2B5e33-WP70Ele"] = new method(fileName, "Data B 5e33 WP70", 2, 6, 26, 6, "E same", "LP","treeV2","runNumber>178380","");
  
  //Run May10+PromptV4 IsoEle27(32)_IsoEle25TriJet
  
  /// Muons: 
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet.root";
  method_["m1ttMu"] = new method(fileName, "t#bar{t} (MuHad)", 1, 2, 1, 2, "E same", "LP","treeV2","","eventWeightPUeventWeightPU");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet.root";
  method_["m1ttMuEPS"] = new method(fileName, "t#bar{t} (MuHad)", 1, 2, 1, 2, "E same", "LP","treeV2","","eventWeightPUEPSeventWeightPUEPS");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet.root";
  method_["m1ttMunoPUrew"] = new method(fileName, "t#bar{t} (MuHad)", 1, 2, 1, 2, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCSFall11WJets_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeCrossTriggerRatiosMCFall11WJets_IsoMu24_eta2p1_IsoMu17TriJet.root";
  method_["m1WMu"] = new method(fileName, "W (MuHad)", 1, 8, 1, 8, "E same", "LP","treeV2","","eventWeightPUeventWeightPU");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCSFall11WJets_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeCrossTriggerRatiosMCFall11WJets_IsoMu24_eta2p1_IsoMu17TriJet.root";
  method_["m1WMuEPS"] = new method(fileName, "W (MuHad)", 1, 8, 1, 8, "E same", "LP","treeV2","","eventWeightPUEPSeventWeightPUEPS");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeMCFall11_HLT_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeMCFall11_HLT_IsoMu24_eta2p1_IsoMu17eta2p1TriJet.root";
  method_["m1MuTaP"] = new method(fileName, "Z (MuHad)", 1, 4, 1, 4, "E same", "LP","treeV2","","weight");
  
  fileName=inputPath428+"/naf_analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet_cfg/analyzeCrossTriggerRatiosMCFall11ttbar_IsoMu24_eta2p1_IsoMu17TriJet.root";
  method_["m1ttWcombMuEPS"] = new method(fileName, "t#bar{t} and W (MuHad)", 1, 1, 1, 1, "E same", "LP","treeV2","","eventWeightPUEPSeventWeightPUEPS");
  
  /// Mu data
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2allMu"] = new method(fileName, "Data 2011", 1, 1, 21, 1, "E same", "LP","treeV2","","");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2EPSMu"] = new method(fileName, "Data 1 fb^{-1}", 1, 4, 21, 4, "E same", "LP","treeV2","runNumber<=167913","");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2AMu"] = new method(fileName, "Data 2011A", 1, 4, 20, 4, "E same", "LP","treeV2","runNumber<=175570","");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2ApostEPSMu"] = new method(fileName, "Data A post EPS (MuHad)", 1, 4, 25, 4, "E same", "LP","treeV2","runNumber>167913 && runNumber<=175570","");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2B3e33Mu"] = new method(fileName, "Data 2011B 3e33", 1, 8, 22, 8, "E same", "LP","treeV2","runNumber>175570 && runNumber<=178380","");
  
  fileName=inputPath428+"/naf_analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet_cfg/analyzeZMuMuTagAndProbeRun2011All_HLT_IsoMu17_24_IsoMu17TriJet.root";
  method_["m2B5e33Mu"] = new method(fileName, "Data 2011B 5e33", 1, 6, 23, 6, "E same", "LP","treeV2","runNumber>178380","");
  
   
//   fileName=inputPathScratch+"/naf_analyzeZMuMuTagAndProbeRun2011A_2e33_170826_173198_HLT_IsoMu24_IsoMu17TriJet_muPt30_cfg/analyzeZMuMuTagAndProbeRun2011A_2e33_170826_173198_HLT_IsoMu24_IsoMu17TriJet_muPt30.root";
//   method_["m3"] = new method(fileName, "IsoMu24 2e33", 1, 4, 22, 4, "E0 same", "P","treeV2");
//    
//   fileName=inputPathScratch+"/naf_analyzeZMuMuTagAndProbeRun2011A_3e33_173212_175770_HLT_IsoMu24Eta_IsoMu17EtaTriJet_muPt30_cfg/analyzeZMuMuTagAndProbeRun2011A_3e33_173212_175770_HLT_IsoMu24Eta_IsoMu17EtaTriJet_muPt30.root";
//   method_["m4"] = new method(fileName, "IsoMu24 3e33", 1, 8, 23, 8, "E0 same", "P","treeV2");
  
  /// To compare different run ranges also beyond EPS:
//   fileName=inputPath42+"/naf_analyzeZEleEleTagAndProbeMCSummer11_HLT_IsoEle27_IsoEle25TriJet_cfg/analyzeZEleEleTagAndProbeMCSummer11_HLT_IsoEle27_IsoEle25TriJet.root";
//   method_["m1"] = new method(fileName, "Summer11 IsoEle27", 1, 2, 1, 2, "E same", "LP","treeV2","","PUweightEPSeventWeightPU");
//    //PUweightEPSeventWeightPU

  
  /// different tap studies (different efficiencies)

  
  const int folderNum=1;
  TString folderID[]={""};
  TString foldersTitle[]={"Jet Leg Trigger"};
  /// for reference trigger method:
  TString folderIDrefTriggerPass="******";
  TString folderIDrefTriggerAll="analyzeJetAllTrig1AfterCut";
  
//   TString folderIDrefTriggerPass="******";
//   TString folderIDrefTriggerAll="analyzeJetDiffMultTrig1AfterCut";


  /// effName = name of the effHisto; variables: corresponding variable to effName; cuts: corresponding cut to effName

//   TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR","lepLepMass"};
   //TString effIDarr[]      = {"Control", "Pt", "Eta", "RelIso", "PVMult", "Mult", "PtEta0to1p5", "PtEta1p5to2p1"};
  //TString effIDarr[]      = {"Pt", "Eta", "RelIso", "PVMult", "Mult", "MinDR"};
   //TString effIDarr[]      = {"pt3-3jets", "pt4-4jets", "pt4-geq4jets", "pt5-5jets", "eta3-3jets", "eta4-4jets", "eta4-geq4jets", "eta5-5jets"};
  //TString effIDarr[]      = {"pt3-3jets", "pt4-4jets", "pt4-geq4jets", "pt5-5jets", "eta3-3jets-ptl40", "eta4-4jets-ptl40", "eta4-geq4jets-ptl40", "absEta4-4jets-ptl40"};
  //TString effIDarr[]      = {"pt3-3jets", "pt4-4jets", "pt4-geq4jets", "pt5-5jets", "eta3-3jets-ptl40", "eta4-4jets-ptl40", "eta4-geq4jets-ptl40", "eta5-5jets-ptl40"};
  TString effIDarr[]      = {"pt3-3jets", "eta3-3jets", "eta3-3jets-ptl40", "pv-3jets"};
//   TString effIDarr[]      = {"pt4-4jets", "eta4-4jets-ptl40", "pv-4jets"};
  //TString effIDarr[]      = {"pt5-5jets", "eta5-5jets-ptl40", "pv-5jets"};
  //TString effIDarr[]      = {"pt3-3jets", "eta3-3jets", "eta3-3jets-ptl40", "pv-3jets", "pt5-5jets", "eta5-5jets-ptl40", "pv-5jets"};
  //TString effIDarr[]      = {"pt1-3jets", "pt2-3jets", "pt3-3jets", "pt1-4jets", "pt2-4jets", "pt3-4jets", "pt4-4jets"};
  // TString effIDarr[]      = {"pt3-3jets", "pt4-4jets", "pt4-geq4jets", "pt5-5jets", "pv-3jets", "pv-4jets", "pv-geq4jets", "pv-5jets"};
  std::vector<TString> effID(effIDarr, effIDarr + sizeof(effIDarr)/sizeof(TString));
  int effIDNum = effID.size();
  std::cout<< "Number of considered plots: " <<  effIDNum << std::endl;
    
  /// map with structure that keeps features of histograms
  std::map<TString, std::map<TString, eff*> > eff_;
  
  /// title for histo, x and y axis (separated by "/")
  TString title0 ="";
  TString title ="";
  
  /// axis range
  //double yLo = 0.5, yHi = 1.1;
  double yLo = 0.9, yHi = 1.;
  double yLo3 = 0.5, yHi3 = 1.;
  double yLoSF = 0.9, yHiSF = 1.1;
  
  /// Constructor for struct eff(TString iniVar, T  iniCuts, TString iniBins, TString iniTitles, double iniYLo=-9999., double iniYHi=-9999., double iniXLo=-9999., double iniXHi=-9999.)
  TCut cutPt  =""; /*"(probePt>30. || testPt>30. )";*/
  TCut cutEta =""; /*"(TMath::Abs(probeEta)<2.1 || TMath::Abs(testEta)<2.1)";*/
  TCut cutPtEta = cutPt && cutEta;
  for(int iFolder=0; iFolder < folderNum; iFolder++){
    title = foldersTitle[iFolder]+" Efficiency/ / ";
    eff_["Control"][folderID[iFolder]]        =new eff("Control", cutPtEta, mBinsControl, binsControl_, title, yLo, yHi, -9999.,-9999.,true);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/3rd Jet p_{T} [GeV]/ ";
//     eff_["pt3-3jets"][folderID[iFolder]]             =new eff("pt3", "n==3", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/3rd Jet p_{T} [GeV]/ ";
//     eff_["pt3-4jets"][folderID[iFolder]]             =new eff("pt3", "n==4", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/4th Jet p_{T} [GeV]/ ";
//     eff_["pt4-4jets"][folderID[iFolder]]             =new eff("pt4", "n==4", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/3rd Jet p_{T} [GeV]/ ";
//     eff_["pt3-5jets"][folderID[iFolder]]             =new eff("pt3", "n==5", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/4th Jet p_{T} [GeV]/ ";
//     eff_["pt4-5jets"][folderID[iFolder]]             =new eff("pt4", "n==5", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/5th Jet p_{T} [GeV]/ ";
//     eff_["pt5-5jets"][folderID[iFolder]]             =new eff("pt5", "n==5", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
    
    
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/3rd Jet p_{T} [GeV]/ ";
    eff_["pt3-3jets"][folderID[iFolder]]             =new eff("pt3", "n==3", mBinsJetPt, binsJetPt_, title, yLo3, yHi3, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/4th Jet p_{T} [GeV]/ ";
    eff_["pt4-4jets"][folderID[iFolder]]             =new eff("pt4", "n==4", mBinsJetPt, binsJetPt4_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}>=4/4th Jet p_{T} [GeV]/ ";
    eff_["pt4-geq4jets"][folderID[iFolder]]             =new eff("pt4", "n>=4", mBinsJetPt, binsJetPt4_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/5th Jet p_{T} [GeV]/ ";
    eff_["pt5-5jets"][folderID[iFolder]]             =new eff("pt5", "n==5", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
    
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/3rd Jet #eta/ ";
    eff_["eta3-3jets"][folderID[iFolder]]             =new eff("eta3", "n==3", mBinsJetEta, binsJetEta_, title, yLo3, yHi3, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/4th Jet #eta/ ";
    eff_["eta4-4jets"][folderID[iFolder]]             =new eff("eta4", "n==4", mBinsJetEta, binsJetEta_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}>=4/4th Jet #eta/ ";
    eff_["eta4-geq4jets"][folderID[iFolder]]             =new eff("eta4", "n>=4", mBinsJetEta, binsJetEta_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/5th Jet #eta/ ";
    eff_["eta5-5jets"][folderID[iFolder]]             =new eff("eta5", "n==5", mBinsJetEta, binsJetEta_, title, yLo, yHi, 30.,120.);
    
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/3rd Jet #eta (p_{T}<40 GeV)/ ";
    eff_["eta3-3jets-ptl40"][folderID[iFolder]]             =new eff("eta3", "n==3 && pt3 < 40", mBinsJetEta, binsJetEta_, title, yLo3, yHi3, -2.4,2.4);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/4th Jet #eta (p_{T}<40 GeV)/ ";
    eff_["eta4-4jets-ptl40"][folderID[iFolder]]             =new eff("eta4", "n==4 && pt4 < 40", mBinsJetEta, binsJetEta_, title, yLo, yHi, -2.4,2.4);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}>=4/4th Jet #eta (p_{T}<40 GeV)/ ";
    eff_["eta4-geq4jets-ptl40"][folderID[iFolder]]             =new eff("eta4", "n>=4 && pt4 < 40", mBinsJetEta, binsJetEta_, title, yLo, yHi, -2.4,2.4);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/5th Jet #eta (p_{T}<40 GeV)/ ";
    eff_["eta5-5jets-ptl40"][folderID[iFolder]]             =new eff("eta5", "n==5 && pt5 < 40", mBinsJetEta, binsJetEta_, title, yLo, yHi, -2.4,2.4);
    
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/4th Jet |#eta| (p_{T}<40 GeV)/ ";
    eff_["absEta4-4jets-ptl40"][folderID[iFolder]]             =new eff("TMath::Abs(eta4)", "n==4 && pt4 < 40", mBinsJetAbsEta, binsJetAbsEta_, title, yLo, yHi);
    
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/1st Jet p_{T} [GeV]/ ";
    eff_["pt1-3jets"][folderID[iFolder]]             =new eff("pt1", "n==3", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.,true);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/2nd Jet p_{T} [GeV]/ ";
    eff_["pt2-3jets"][folderID[iFolder]]             =new eff("pt2", "n==3", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3/3rd Jet p_{T} [GeV]/ ";
//     eff_["pt4-geq4jets"][folderID[iFolder]]             =new eff("pt3", "n==3", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/1st Jet p_{T} [GeV]/ ";
    eff_["pt1-4jets"][folderID[iFolder]]             =new eff("pt1", "n==4", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/2nd Jet p_{T} [GeV]/ ";
    eff_["pt2-4jets"][folderID[iFolder]]             =new eff("pt2", "n==4", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/3rd Jet p_{T} [GeV]/ ";
    eff_["pt3-4jets"][folderID[iFolder]]             =new eff("pt3", "n==4", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
//     title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/4th Jet p_{T} [GeV]/ ";
//     eff_["pt5-5jets"][folderID[iFolder]]             =new eff("pt4", "n==4", mBinsJetPt, binsJetPt_, title, yLo, yHi, 30.,120.);
    
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=3 /pv / ";
    eff_["pv-3jets"][folderID[iFolder]]             =new eff("pv", "n==3", mBinsPVMult, binsPVMult_, title, yLo, yHi, 0.,20.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=4/ pv / ";
    eff_["pv-4jets"][folderID[iFolder]]             =new eff("pv", "n==4", mBinsPVMult, binsPVMult_, title, yLo, yHi, 0.,20.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}>=4/ pv / ";
    eff_["pv-geq4jets"][folderID[iFolder]]             =new eff("pv", "n>=4", mBinsPVMult, binsPVMult_, title, yLo, yHi, 0.,20.);
    title = foldersTitle[iFolder]+" Efficiency, N_{Jet}=5/ pv / ";
    eff_["pv-5jets"][folderID[iFolder]]             =new eff("pv", "n==5", mBinsPVMult, binsPVMult_, title, yLo, yHi, 0.,20.);
  }

  /// ---
  /// get efficiencies from tree or histo
  ///  ---
  for(int iMethod=0; iMethod<mIDNum; iMethod++){
    for(int iEff=0; iEff<effIDNum; iEff++){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	getEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_[mID[iMethod]], mID[iMethod], folderIDrefTriggerPass, folderIDrefTriggerAll);
      }
    }
  }
  /// combine efficiencies (e.g. ttbar and W) with equal weights
  if(averageMIDdestination !="" && averageMID1 != "" && averageMID2 !=""){
    for(int iEff=0; iEff<effIDNum; iEff++){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	averageEfficiencies(eff_[effID[iEff]][folderID[iFolder]], averageMIDdestination, averageMID1, averageMID2, 0.5, 0.5);
      }
    }
  }
  if(averageMIDdestination_2 !="" && averageMID1_2 != "" && averageMID2_2 !=""){
    for(int iEff=0; iEff<effIDNum; iEff++){
      for(int iFolder=0; iFolder<folderNum; iFolder++){
	averageEfficiencies(eff_[effID[iEff]][folderID[iFolder]], averageMIDdestination_2, averageMID1_2, averageMID2_2, 0.5, 0.5);
      }
    }
  }

 /// Draw one Canvas for each folder comparing different methods.
 /// Each canvas shows test (1st row) and probe collection (2nd) and efficiency (3rd) for different variables (columns)
 TCanvas* CanvComp [folderNum];
 TCanvas* CanvSFComp [folderNum];
 TCanvas* CanvEvtsComp [folderNum];
 TCanvas* CanvEvtsNormComp [folderNum];
 TCanvas* CanvLeg = new TCanvas("CanvLeg", "CanvLeg", 350,300);

 std::cout<< "Drawing eff. and SF"<<std::endl;
for(int iFolder=0; iFolder<folderNum; iFolder++) {

  CanvComp[iFolder] = new TCanvas("Comparison"+folderID[iFolder], "Comparison"+folderID[iFolder], 1700,1000);
  CanvSFComp[iFolder] = new TCanvas("ComparisonSF"+folderID[iFolder], "ComparisonSF"+folderID[iFolder], 1700,1000);
  CanvEvtsComp[iFolder] = new TCanvas("ComparisonEvts"+folderID[iFolder], "ComparisonEvts"+folderID[iFolder], 1700,1000);
  CanvEvtsNormComp[iFolder] = new TCanvas("ComparisonEvtsNorm"+folderID[iFolder], "ComparisonEvtsNorm"+folderID[iFolder], 1700,1000);
  
  CanvComp[iFolder]->Divide(4,2);
  CanvSFComp[iFolder]->Divide(4,2);
  CanvEvtsComp[iFolder]->Divide(4,2);
  CanvEvtsNormComp[iFolder]->Divide(4,2);
  
  for(int iEff=0; iEff<effIDNum; iEff++){
    CanvComp[iFolder]->cd(iEff+1);
    std::cout<< "Drawing eff."<<std::endl;
    drawEfficiencies(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
    CanvSFComp[iFolder]->cd(iEff+1);
    std::cout<< "Drawing SF"<<std::endl;
    drawSF          (eff_[effID[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID[iEff]][folderID[iFolder]]->xLo, eff_[effID[iEff]][folderID[iFolder]]->xHi);
    // if desired plot also raw event number histos
    if(onlyEffPlots!=1) {
      std::cout<< "Drawing event numbers"<<std::endl;
      CanvEvtsComp[iFolder]->cd(iEff+1);
      drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend);
      CanvEvtsNormComp[iFolder]->cd(iEff+1);
      drawEventHistos(eff_[effID[iEff]][folderID[iFolder]], method_, mID, 0.15,0.15,0.9,0.45,eff_[effID[iEff]][folderID[iFolder]]->drawLegend,"normInt");
    }
  }
  // draw legend
  CanvLeg->cd();
  if(iFolder==0) drawLegend(eff_[effID[0]][folderID[0]], method_, mID, 0.,0.,1.,1.);
  
//   effControl[iMethod][iFolder]->GetXaxis()->SetNdivisions(0);
//   effRelIso[iMethod][iFolder]->GetXaxis()->SetNdivisions(505);
 
 if(save){
   for(unsigned int iFileFormat=0; iFileFormat < fileFormat.size(); iFileFormat++){
    CanvComp[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_overview."+fileFormat[iFileFormat]);
    for(int iEff=0; iEff<effIDNum; iEff++){
      CanvComp  [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID[iEff]+"."+fileFormat[iFileFormat]);
      CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
    }
    if(iFolder==0) CanvLeg->Print(outputFolder+outputFileName+"_Legend."+fileFormat[iFileFormat]);
    std::cout<<"Canvas with plots is saved in "<<outputFolder<<std::endl;
   }
  }
  
  /// save graph in root file
//   TFile f("JetLegTriggerEfficiencyIsoLepTriJetJetMult4.root", "recreate");
//   eff_["absEta4-4jets-ptl40"][""]->graphSF["m2allMu"]->SetName("JetLegTriggerEfficiencyIsoLepTriJetJetMult4");
//       //eff_["Eta"]["tapAll"]->graphSF["m2"]->SetTitle("tapAllSFeta");
//   eff_["absEta4-4jets-ptl40"][""]->graphSF["m2allMu"]->Write();
//   std::cout<<"JetLegTriggerEfficiencyIsoLepTriJetJetMult4.root with TGraphErrors is saved."<<std::endl;
  
 }
}
예제 #5
0
/** This is the entry point in to the lexer from an object that
 *  wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
 */
static void 
mTokens(pExprCppTreeLexer ctx)
{
    {
        //  D:\\message\\ExprCppTree.g:1:8: ( T__12 | T__13 | PLUS | MINUS | TIMES | ASSIGN | ID | INT | NEWLINE | WS )
        
        ANTLR3_UINT32 alt6;

        alt6=10;

        switch ( LA(1) ) 
        {
        case '(':
        	{
        		alt6=1;
        	}
            break;
        case ')':
        	{
        		alt6=2;
        	}
            break;
        case '+':
        	{
        		alt6=3;
        	}
            break;
        case '-':
        	{
        		alt6=4;
        	}
            break;
        case '*':
        	{
        		alt6=5;
        	}
            break;
        case '=':
        	{
        		alt6=6;
        	}
            break;
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
        case 'G':
        case 'H':
        case 'I':
        case 'J':
        case 'K':
        case 'L':
        case 'M':
        case 'N':
        case 'O':
        case 'P':
        case 'Q':
        case 'R':
        case 'S':
        case 'T':
        case 'U':
        case 'V':
        case 'W':
        case 'X':
        case 'Y':
        case 'Z':
        case 'a':
        case 'b':
        case 'c':
        case 'd':
        case 'e':
        case 'f':
        case 'g':
        case 'h':
        case 'i':
        case 'j':
        case 'k':
        case 'l':
        case 'm':
        case 'n':
        case 'o':
        case 'p':
        case 'q':
        case 'r':
        case 's':
        case 't':
        case 'u':
        case 'v':
        case 'w':
        case 'x':
        case 'y':
        case 'z':
        	{
        		alt6=7;
        	}
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
        case '~':
        	{
        		alt6=8;
        	}
            break;
        case '\n':
        case '\r':
        	{
        		alt6=9;
        	}
            break;
        case '\t':
        case ' ':
        	{
        		alt6=10;
        	}
            break;

        default:
            CONSTRUCTEX();
            EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            EXCEPTION->message      = (void *)"";
            EXCEPTION->decisionNum  = 6;
            EXCEPTION->state        = 0;


            goto ruleTokensEx;
        }

        switch (alt6) 
        {
    	case 1:
    	    // D:\\message\\ExprCppTree.g:1:10: T__12
    	    {
    	        /* 1:10: T__12 */
    	        mT__12(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 2:
    	    // D:\\message\\ExprCppTree.g:1:16: T__13
    	    {
    	        /* 1:16: T__13 */
    	        mT__13(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 3:
    	    // D:\\message\\ExprCppTree.g:1:22: PLUS
    	    {
    	        /* 1:22: PLUS */
    	        mPLUS(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 4:
    	    // D:\\message\\ExprCppTree.g:1:27: MINUS
    	    {
    	        /* 1:27: MINUS */
    	        mMINUS(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 5:
    	    // D:\\message\\ExprCppTree.g:1:33: TIMES
    	    {
    	        /* 1:33: TIMES */
    	        mTIMES(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 6:
    	    // D:\\message\\ExprCppTree.g:1:39: ASSIGN
    	    {
    	        /* 1:39: ASSIGN */
    	        mASSIGN(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 7:
    	    // D:\\message\\ExprCppTree.g:1:46: ID
    	    {
    	        /* 1:46: ID */
    	        mID(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 8:
    	    // D:\\message\\ExprCppTree.g:1:49: INT
    	    {
    	        /* 1:49: INT */
    	        mINT(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 9:
    	    // D:\\message\\ExprCppTree.g:1:53: NEWLINE
    	    {
    	        /* 1:53: NEWLINE */
    	        mNEWLINE(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;
    	case 10:
    	    // D:\\message\\ExprCppTree.g:1:61: WS
    	    {
    	        /* 1:61: WS */
    	        mWS(ctx ); 
    	        if  (HASEXCEPTION())
    	        {
    	            goto ruleTokensEx;
    	        }


    	    }
    	    break;

        }
    }

    
    goto ruleTokensEx; /* Prevent compiler warnings */
ruleTokensEx: ;
}
void analyzeCutflowWithAnalyzers(bool save=false)
{
  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetLegendBorderSize(0);
  gStyle->SetPadBottomMargin(0.11);
  gStyle->SetLabelSize(0.05,"XY");
  gStyle->SetTitleSize(0.05,"XY");
  gStyle->SetFillColor(0);
  
  
  /// path where input files are stored
  TString inputPathScratch  ="/scratch/hh/current/cms/user/jlange/output_4_2_4/fullLeptonic";
  TString inputPath42       ="/afs/naf.desy.de/user/j/jlange/nafscratch/top/CMSSW_4_2_4/src/TopAnalysis/Configuration/analysis/fullLeptonic";
  
  TString outputFolder   = "/afs/desy.de/user/j/jlange/analysis/tagAndProbe/plots/CutStudiesForTrigger";
  TString outputFileName = "/cutStudiesDifferentPU_";
  
  TString fileFormat = "png";
  
  
  TFile* file= new TFile(inputPath42+"/naf_analyzeCutflowWithAnalyzers_cfg/analyzeCutflowWithAnalyzers_MinJet4_pt30_MuPt20.root");
  file->cd();
  
  TTree *tJet = (TTree*) file->Get("analyzeJetAllTrig2AfterCut/tree")->Clone();
  tJet->AddFriend("tMu = analyzeMuonKinematicsTrig2/tree");
  
  TCut cutPtMu  = "tMu.pt>30";
  TCut cutPtJet = "pt1>35 && pt2>35 && pt3>35 && pt4>35";
  TCut cutPtMuJet = cutPtMu && cutPtJet;
  
  /// calculate efficiencies
  // no PUrew
  double NeventIni = 1000000.;
  double NmuPt20_minJet4pt30 = (double)tJet->GetEntries();
  double NmuPt23_minJet4pt30 = (double)tJet->GetEntries("tMu.pt>23");
  double NmuPt30_minJet4pt30 = (double)tJet->GetEntries("tMu.pt>30");
//   double NmuPt20_minJet4pt35 = (double)tJet->GetEntries("pt1>35 && pt2>35 && pt3>35 && pt4>35");
//   double NmuPt23_minJet4pt35 = (double)tJet->GetEntries("pt1>35 && pt2>35 && pt3>35 && pt4>35 && tMu.pt>23");
//   double NmuPt23_minJet4pt1_65 = (double)tJet->GetEntries("pt1>65 && pt2>50 && pt3>35 && pt4>20 && tMu.pt>23");
//   double NmuPt30_minJet4pt1_65 = (double)tJet->GetEntries("pt1>65 && pt2>50 && pt3>35 && pt4>20 && tMu.pt>30");
  double NmuPt20_minJet4pt35 = (double)tJet->GetEntries("pt1>35 && pt2>35 && pt3>35 && pt4>35");
  double NmuPt23_minJet4pt35 = (double)tJet->GetEntries("pt1>35 && pt2>35 && pt3>35 && pt4>35 && tMu.pt>23");
  double NmuPt23_minJet4pt1_65 = (double)tJet->GetEntries("pt1>65 && pt2>50 && pt3>35 && pt4>30 && tMu.pt>23");
  double NmuPt30_minJet4pt1_65 = (double)tJet->GetEntries("pt1>65 && pt2>50 && pt3>35 && pt4>30 && tMu.pt>30");
  double NmuPt30_minJet4pt1_50 = (double)tJet->GetEntries("pt1>50 && pt2>40 && pt3>35 && pt4>30 && tMu.pt>30");
  
  double NmuPt20_minJet4pt30_PUlo = (double)tJet->GetEntries("pv<10");
  double NmuPt20_minJet4pt30_PUhi = (double)tJet->GetEntries("pv>10");
  
  std::cout<<"NeventIni= "<<NeventIni<<std::endl;
  std::cout<<"NmuPt20_minJet4pt30= "<<NmuPt20_minJet4pt30<<std::endl;
  std::cout<<"NmuPt23_minJet4pt30= "<<NmuPt23_minJet4pt30<<std::endl;
  std::cout<<"NmuPt30_minJet4pt30= "<<NmuPt30_minJet4pt30<<std::endl;
  std::cout<<"NmuPt20_minJet4pt35= "<<NmuPt20_minJet4pt35<<std::endl;
  std::cout<<"NmuPt23_minJet4pt35= "<<NmuPt23_minJet4pt35<<std::endl;
  std::cout<<"NmuPt23_minJet4pt1_65= "<<NmuPt23_minJet4pt1_65<<std::endl;
  std::cout<<"NmuPt30_minJet4pt1_65= "<<NmuPt30_minJet4pt1_65<<std::endl;
  std::cout<<"NmuPt30_minJet4pt1_50= "<<NmuPt30_minJet4pt1_50<<std::endl;
  
  std::cout<<"eff muPt>20 minJet4pt>30 wrt NeventIni "<< NmuPt20_minJet4pt30/NeventIni <<std::endl;
  std::cout<<"eff muPt>23 minJet4pt>30 wrt NeventIni "<< NmuPt23_minJet4pt30/NeventIni <<std::endl;
  std::cout<<"eff muPt>30 minJet4pt>30 wrt NeventIni "<< NmuPt30_minJet4pt30/NeventIni <<std::endl;
  std::cout<<"eff muPt>20 minJet4pt>35 wrt NeventIni "<< NmuPt20_minJet4pt35/NeventIni <<std::endl;
  std::cout<<"eff muPt>23 minJet4pt>35 wrt NeventIni "<< NmuPt23_minJet4pt35/NeventIni <<std::endl;
  std::cout<<"eff muPt>23 minJet4pt1_65 wrt NeventIni "<< NmuPt23_minJet4pt1_65/NeventIni <<std::endl;
  std::cout<<std::endl;
  std::cout<<"eff muPt>30 minJet4pt1_65 wrt NeventIni "<< NmuPt30_minJet4pt1_65/NeventIni <<std::endl;
  std::cout<<std::endl;
  std::cout<<"eff muPt>30 minJet4pt1_50 wrt NeventIni "<< NmuPt30_minJet4pt1_50/NeventIni <<std::endl;
  std::cout<<std::endl;
  
  std::cout<<"eff muPt>23 minJet4pt>30 wrt muPt>20 minJet4pt>30 "<< NmuPt23_minJet4pt30/NmuPt20_minJet4pt30 <<std::endl;
  std::cout<<"eff muPt>30 minJet4pt>30 wrt muPt>20 minJet4pt>30 "<< NmuPt30_minJet4pt30/NmuPt20_minJet4pt30 <<std::endl;
  std::cout<<"eff muPt>20 minJet4pt>35 wrt muPt>20 minJet4pt>30 "<< NmuPt20_minJet4pt35/NmuPt20_minJet4pt30 <<std::endl;
  std::cout<<"eff muPt>23 minJet4pt>35 wrt muPt>20 minJet4pt>30 "<< NmuPt23_minJet4pt35/NmuPt20_minJet4pt30 <<std::endl;
  std::cout<<"eff muPt>23 minJet4pt1_65 wrt muPt>20 minJet4pt>30 "<< NmuPt23_minJet4pt1_65/NmuPt20_minJet4pt30 <<std::endl;
  std::cout<<"eff muPt>30 minJet4pt1_65 wrt muPt>20 minJet4pt>30 "<< NmuPt30_minJet4pt1_65/NmuPt20_minJet4pt30 <<std::endl;
  std::cout<<"eff muPt>30 minJet4pt1_50 wrt muPt>20 minJet4pt>30 "<< NmuPt30_minJet4pt1_50/NmuPt20_minJet4pt30 <<std::endl;
  
  // with PUrew
//   std::cout<<"--------------------------------------------"<<std::endl;
//   std::cout<<"!!! PU rew !!! "<<NeventIni<<std::endl;
//   NeventIni = 1000000.;
//   NmuPt20_minJet4pt30 = (double)tJet->GetEntries("weight");
//   NmuPt23_minJet4pt30 = (double)tJet->GetEntries("weight*(tMu.pt>23)");
//   NmuPt20_minJet4pt35 = (double)tJet->GetEntries("weight*(pt1>35 && pt2>35 && pt3>35 && pt4>35)");
//   NmuPt23_minJet4pt35 = (double)tJet->GetEntries("weight*(pt1>35 && pt2>35 && pt3>35 && pt4>35 && tMu.pt>23)");
//   
//   std::cout<<"NeventIni= "<<NeventIni<<std::endl;
//   std::cout<<"NmuPt20_minJet4pt30= "<<NmuPt20_minJet4pt30<<std::endl;
//   std::cout<<"NmuPt23_minJet4pt30= "<<NmuPt23_minJet4pt30<<std::endl;
//   std::cout<<"NmuPt20_minJet4pt35= "<<NmuPt20_minJet4pt35<<std::endl;
//   std::cout<<"NmuPt23_minJet4pt35= "<<NmuPt23_minJet4pt35<<std::endl;
//   
//   std::cout<<"eff muPt>20 minJet4pt>30 wrt NeventIni "<< NmuPt20_minJet4pt30/NeventIni <<std::endl;
//   std::cout<<"eff muPt>23 minJet4pt>30 wrt NeventIni "<< NmuPt23_minJet4pt30/NeventIni <<std::endl;
//   std::cout<<"eff muPt>20 minJet4pt>35 wrt NeventIni "<< NmuPt20_minJet4pt35/NeventIni <<std::endl;
//   std::cout<<"eff muPt>23 minJet4pt>35 wrt NeventIni "<< NmuPt23_minJet4pt35/NeventIni <<std::endl;
//   std::cout<<std::endl;
//   
//   std::cout<<"eff muPt>23 minJet4pt>30 wrt muPt>20 minJet4pt>30 "<< NmuPt23_minJet4pt30/NmuPt20_minJet4pt30 <<std::endl;
//   std::cout<<"eff muPt>20 minJet4pt>35 wrt muPt>20 minJet4pt>30 "<< NmuPt20_minJet4pt35/NmuPt20_minJet4pt30 <<std::endl;
//   std::cout<<"eff muPt>23 minJet4pt>35 wrt muPt>20 minJet4pt>30 "<< NmuPt23_minJet4pt35/NmuPt20_minJet4pt30 <<std::endl;
  
      
//   tJet->Scan("*", "","",10,10);
//   tJet->Scan("*", cutPtMu,"",10,10);
//   tJet->Scan("*", cutPtJet,"",10,10);
  
  TCanvas* canv1=new TCanvas("c","c",1);
  canv1->cd();
  //tree -> Draw("probePt>>hnew(30,0,150)", "", "", 100);
  tJet -> Draw("tMu.pt>>hnew1(30,0,150)", cutPtJet);
  TCanvas* canv2=new TCanvas("c2","c2",1);
  canv2->cd();
  tJet -> Draw("pt1>>hnew2(30,0,150)",cutPtJet);
  
  /// ------------------------------------------------------------------------------  
  /// map with structure that keeps features of methods, ignore file, filename=""
  /// use source for cuts
  std::map<TString, method*> method_;
  
  TString mIDarr []= {"m1", "m2", "m3", "m4"};
  //TString mIDarr []= {"m1", "m2", "m3", "m4","m5","m6","m7","m8"};
  std::vector<TString> mID(mIDarr, mIDarr + sizeof(mIDarr)/sizeof(TString));
  int mIDNum = mID.size();
  std::cout<< "Number of considered methods (i.e. cuts): " <<  mIDNum << std::endl;
  
  /// Constructor for struct method(TString iniFileName, TString iniLegName, int iniLineStyle, int iniLineColor, int iniMarkerStyle, int iniMarkerColor, TString iniDrawOpt, TString iniLepOpt, TString source)
  
  // no PUrew
  method_["m1"] = new method("", "p_{T}(mu)>20, p_{T}(jet)>30", 1, 1, 1, 2, "", "L","tree");
  method_["m2"] = new method("", "p_{T}(mu)>30, p_{T}(jet)>30", 1, 2, 1, 2, "same", "L", "tree",cutPtMu);
  method_["m3"] = new method("", "p_{T}(mu)>20, p_{T}(jet)>35", 1, 3, 1, 2, "same", "L","tree",cutPtJet);
  method_["m4"] = new method("", "p_{T}(mu)>30, p_{T}(jet)>35", 1, 4, 1, 2, "same", "L","tree",cutPtMuJet);
  // with PUrew
  method_["m5"] = new method("", "", 2, 1, 1, 2, "same", "","treeWeight");
  method_["m6"] = new method("", "", 2, 2, 1, 2, "same", "", "treeWeight",cutPtMu);
  method_["m7"] = new method("", "", 2, 3, 1, 2, "same", "","treeWeight",cutPtJet);
  method_["m8"] = new method("", "", 2, 4, 1, 2, "same", "","treeWeight",cutPtMuJet);
  
//    // no PUrew
//   method_["m1"] = new method("", "no PU reweighting", 1, 1, 1, 2, "", "L","tree");
//   method_["m2"] = new method("", "", 1, 2, 1, 2, "same", "", "tree",cutPtMu);
//   method_["m3"] = new method("", "", 1, 3, 1, 2, "same", "","tree",cutPtJet);
//   method_["m4"] = new method("", "", 1, 4, 1, 2, "same", "","tree",cutPtMuJet);
//   // with PUrew
//   method_["m5"] = new method("", "PU reweighting (first 1 fb^{-1})", 2, 1, 1, 2, "same", "L","treeWeight");
//   method_["m6"] = new method("", "", 2, 2, 1, 2, "same", "", "treeWeight",cutPtMu);
//   method_["m7"] = new method("", "", 2, 3, 1, 2, "same", "","treeWeight",cutPtJet);
//   method_["m8"] = new method("", "", 2, 4, 1, 2, "same", "","treeWeight",cutPtMuJet);
  
//   method_["m1"] = new method("", "no PU reweighting", 1, 1, 1, 2, "", "L","tree","1/NmuPt20_minJet4pt30");
//   method_["m2"] = new method("", "PU reweighting (first 1 fb^{-1}", 1, 2, 1, 2, "same", "L", "treeWeight");
//   method_["m3"] = new method("", "low PU N_{PV}<10", 1, 3, 1, 2, "same", "L","tree","pv<10");
//   method_["m4"] = new method("", "high PU N_{PV}>10", 1, 4, 1, 2, "same", "L","tree","pv>10");
  
  /// draw with the help of efficiency structure
  // variables to be plotted
  TString effIDarr[]      = {"muPt", "muEta", "jet1Pt", "jet2Pt", "jet3Pt", "jet4Pt", "jet1Eta", "jet2Eta", "jet3Eta", "jet4Eta"};
  std::vector<TString> effID(effIDarr, effIDarr + sizeof(effIDarr)/sizeof(TString));
  int effIDNum = effID.size();
  std::cout<< "Number of considered plots: " <<  effIDNum << std::endl;
  
  /// map with structure that keeps features of histograms
  std::map<TString, eff*> eff_;
  
  /// title for histo, x and y axis (separated by "/")
  TString title ="";
  TString title0 ="t#bar{t} Summer11 sample, 10^{6} events";
  
  double yLoEta=0; 
  double yHiEta=12000;
  
//   int mBinsPt0     = 60;
//   int mBinsEta0    = -1;
//   
//   double binsPt0[]     = {  0., 300. };
//   std::vector<double> binsPt0_(binsPt0, binsPt0 + sizeof(binsPt0)/sizeof(double));
//   double binsEta0[]    = { -2.4,-2.1,-1.65,-1.2,-0.9,-0.45,0.,0.45,0.9,1.2,1.65,2.1,2.4 };
//   std::vector<double> binsEta0_(binsEta0, binsEta0 + sizeof(binsEta0)/sizeof(double));
  
  int mBinsPt0     = 240;
  int mBinsEta0    = 120;
  
  double binsPt0[]     = {  0., 300. };
  std::vector<double> binsPt0_(binsPt0, binsPt0 + sizeof(binsPt0)/sizeof(double));
  double binsEta0[]    = { -2.4,2.4 };
  std::vector<double> binsEta0_(binsEta0, binsEta0 + sizeof(binsEta0)/sizeof(double));
  
  /// Constructor for struct eff(TString iniVar, TCut iniCuts, TString iniBins, TString iniTitles, double iniYLo=-9999., double iniYHi=-9999., double iniXLo=-9999., double iniXHi=-9999.)
  title = title0+"/ p_{T}(mu) / ";
  eff_["muPt"] =new eff("tMu.pt", "", mBinsPt0, binsPt0_, title,0,5000);
  title = title0+"/ #eta(mu) / ";
  eff_["muEta"] =new eff("tMu.eta", "", mBinsEta0, binsEta0_, title,yLoEta,yHiEta);
  title = title0+"/ p_{T}(jet 1) / ";
  eff_["jet1Pt"] =new eff("pt1", "", mBinsPt0, binsPt0_, title,0,3000);
  title = title0+"/ p_{T}(jet 2) / ";
  eff_["jet2Pt"] =new eff("pt2", "", mBinsPt0, binsPt0_, title,0,5000);
  title = title0+"/ p_{T}(jet 3) / ";
  eff_["jet3Pt"] =new eff("pt3", "", mBinsPt0, binsPt0_, title,0,7000);
  title = title0+"/ p_{T}(jet 4) / ";
  eff_["jet4Pt"] =new eff("pt4", "", mBinsPt0, binsPt0_, title,0,13000);
  title = title0+"/ #eta(jet 1) / ";
  eff_["jet1Eta"] =new eff("eta1", "", mBinsEta0, binsEta0_, title,yLoEta,yHiEta);
  title = title0+"/ #eta(jet 2) / ";
  eff_["jet2Eta"] =new eff("eta2", "", mBinsEta0, binsEta0_, title,yLoEta,yHiEta);
  title = title0+"/ #eta(jet 3) / ";
  eff_["jet3Eta"] =new eff("eta3", "", mBinsEta0, binsEta0_, title,yLoEta,yHiEta);
  title = title0+"/ #eta(jet 4) / ";
  eff_["jet4Eta"] =new eff("eta4", "", mBinsEta0, binsEta0_, title,yLoEta,yHiEta);
  
  /// PU reweightung
  TString PU;
  
  /// ---
  /// get histos from tree
  ///  ---
  for(int iMethod=0; iMethod<mIDNum; iMethod++){
    for(int iEff=0; iEff<effIDNum; iEff++){
      getHisto(eff_[effID[iEff]]->his[mID[iMethod]], eff_[effID[iEff]]->var, tJet, eff_[effID[iEff]]->binMode, eff_[effID[iEff]]->bins, method_[mID[iMethod]]->cuts, method_[mID[iMethod]]->source);
      
      setHistoStyle(eff_[effID[iEff]]->his[mID[iMethod]], eff_[effID[iEff]]->titles, method_[mID[iMethod]]->lineStyle, method_[mID[iMethod]]->lineColor, method_[mID[iMethod]]->markerStyle, method_[mID[iMethod]]->markerColor, eff_[effID[iEff]]->yLo, eff_[effID[iEff]]->yHi);
    }
  }
  
  /// Draw Canvas 
  TCanvas* CanvMu= new TCanvas("CanvMu", "CanvMu", 1280,900);
  TCanvas* CanvJetPt= new TCanvas("CanvJetPt", "CanvJetPt", 1280,900);
  TCanvas* CanvJetEta= new TCanvas("CanvJetEta", "CanvJetEta", 1280,900);

  CanvMu->Divide(2,2);
  CanvJetPt->Divide(2,2);
  CanvJetEta->Divide(2,2);
  
  CanvMu->cd(1);
  drawEfficiencies(eff_["muPt"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvMu->cd(2);
  drawEfficiencies(eff_["muEta"], method_, mID, 0.45,0.6,0.85,0.85);
  
  CanvJetPt->cd(1);
  drawEfficiencies(eff_["jet1Pt"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvJetPt->cd(2);
  drawEfficiencies(eff_["jet2Pt"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvJetPt->cd(3);
  drawEfficiencies(eff_["jet3Pt"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvJetPt->cd(4);
  drawEfficiencies(eff_["jet4Pt"], method_, mID, 0.45,0.6,0.85,0.85);
  
  CanvJetEta->cd(1);
  drawEfficiencies(eff_["jet1Eta"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvJetEta->cd(2);
  drawEfficiencies(eff_["jet2Eta"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvJetEta->cd(3);
  drawEfficiencies(eff_["jet3Eta"], method_, mID, 0.45,0.6,0.85,0.85);
  CanvJetEta->cd(4);
  drawEfficiencies(eff_["jet4Eta"], method_, mID, 0.45,0.6,0.85,0.85);
  
  // make studies of integral for shape uncertainties
  // load b-jets
//   TFile* fileBjet= new TFile(inputPath42+"/../semiLeptonic/diffXSection/naf_analyzeBTagEfficiency_cfg_new/analyzeBTagEfficiency.root");
//   fileBjet->cd();
//   TH1F* hisBjet= (TH1F*) fileBjet->Get("bTagEff/NumBJetsEta")->Clone();
//   
//   double* integral = hisBjet->GetIntegral();
//   int binsNum = hisBjet->GetNbinsX();
//   
//   for(int iBin = 0; iBin < binsNum+1; iBin++){
//     std::cout<<"Bin=" << iBin << "; binCenter=" << hisBjet->GetBinCenter(iBin) << "; cum. int.=" << integral[iBin] << std::endl;
//   }
  
  TString methodChoice="m2";
  TString effChoice="muEta";
  double* muIntegral = eff_[effChoice]->his[methodChoice]->GetIntegral();
  int muBinsNum = eff_[effChoice]->his[methodChoice]->GetNbinsX();
  
  for(int iBin = 0; iBin < muBinsNum+1; iBin++){
    std::cout<<"Bin=" << iBin << "; binCenter=" << eff_[effChoice]->his[methodChoice]->GetBinCenter(iBin) << "; cum. int.=" << muIntegral[iBin] << std::endl;
  }
  
  
  
  if(save){
    CanvMu->cd(1)->Print(outputFolder+outputFileName+"muPt."+fileFormat);
    CanvMu->cd(2)->Print(outputFolder+outputFileName+"muEta."+fileFormat);
    
    CanvJetPt->Print(outputFolder+outputFileName+"jetPt_overview."+fileFormat);
    CanvJetEta->Print(outputFolder+outputFileName+"jetEta_overview."+fileFormat);
    std::cout<<"Canvas with plots is saved in "<<outputFolder<<std::endl;
  }
  
}