Beispiel #1
0
//AC.template.verifiedRecord
void  MainWidget::init_word()
{
    QAxWidget word("Word.Application");
    word.setProperty("Visible", false);//隐式的打开一个word应用程序

    QAxObject * documents = word.querySubObject("Documents"); //获取所有工作文档
    documents->dynamicCall("Add (void)");//创建一个word文档
    QAxObject * document = word.querySubObject("ActiveDocument"); //获取当前激活的文档
    QAxObject *selection = word.querySubObject("Selection"); //写入文件内容

    QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
    QString    str = time.toString("yyyy-MM-dd hh:mm:ss ddd"); //设置显示格式
    selection->dynamicCall("TypeText(const QString&)","hello"+str);

    //设置保存
    QVariant newFileName("e:/test.doc"); //存放位置和名称
    QVariant fileFormat(1); //文件格式
    QVariant LockComments(false);
    QVariant Password("");     //设置打开密码
    QVariant recent(true);
    QVariant writePassword("");
    QVariant ReadOnlyRecommended(false);

    document->querySubObject("SaveAs(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)",    newFileName, fileFormat, LockComments, Password, recent, writePassword, ReadOnlyRecommended);
    document->dynamicCall("Close (boolean)", true);   //关闭文档
    word.dynamicCall("Quit (void)");//退出
}
void ScreenShotPage::takeScreenshot()
{
    QPixmap screenshot;

    screenshot = QPixmap::grabWindow(scene()->views().at(0)->effectiveWinId());

    QString path;

    if (QDir(ImagesPath).exists())
        path = ImagesPath;
    else
        path = QDir::homePath();

    QString fileFormat(QString("%1/%2-%3.png").arg(path).arg(QDate::currentDate().toString("yyyyMMdd")).arg(QTime::currentTime().toString("hhmmss")));

    if (!screenshot.save(fileFormat))
        mWarning("MWindow") << "Could not save screenshot to" << path;

    playScreenshotEffect();

    MBanner * bannerPath = new MBanner();
    bannerPath->setObjectName("pathBanner");
    bannerPath->setStyleName("InformationBanner");
    bannerPath->setTitle("Screenshot has been saved in: " + fileFormat);
    bannerPath->appear(scene(), MSceneWindow::DestroyWhenDone);
}
Beispiel #3
0
void SongsOnlineWidget::preview()
{
//    QMessageBox::information(this, "提示", "浏览");

    QString fileFormat("视频文件(*.xls *.xlsx)");
    QString document = QProcessEnvironment::systemEnvironment().value("USERPROFILE")+"\\Desktop";
    QString pathStr = QFileDialog::getOpenFileName(this,
                                                     "批量上传",
                                                     document,
                                                     fileFormat
                                                     );

    if(pathStr.isEmpty())
        return;

    lineEdit_upload->setText(pathStr);
}
Beispiel #4
0
void FmAddModifyDialog::previewImage()
{
    QString fileFormat("图片文件(*.jpg)");
    QString pathStr = QFileDialog::getOpenFileName(this,
                                                tr("上传头像"),
                                                ".",
                                                fileFormat
                                                );
    if(pathStr.isEmpty())
        return;

    lineEdit_listImage->setText(pathStr);
    widgetImage->setHidden(false);
    widgetAddMusic->setHidden(true);
    label_image->setHidden(false);
    QPixmap pixmap(pathStr);
    label_image->setPixmap(pixmap);
}
QString GeoSceneTileDataset::relativeTileFileName( const TileId &id ) const
{
    const QString suffix = fileFormat().toLower();

    QString relFileName;

    switch ( m_storageLayoutMode ) {
    default:
        mDebug() << Q_FUNC_INFO << "Invalid storage layout mode! Falling back to default.";
    case GeoSceneTileDataset::Marble:
        relFileName = QString( "%1/%2/%3/%3_%4.%5" )
            .arg( themeStr() )
            .arg( id.zoomLevel() )
            .arg( id.y(), tileDigits, 10, QChar('0') )
            .arg( id.x(), tileDigits, 10, QChar('0') )
            .arg( suffix );
        break;
    case GeoSceneTileDataset::OpenStreetMap:
        relFileName = QString( "%1/%2/%3/%4.%5" )
            .arg( themeStr() )
            .arg( id.zoomLevel() )
            .arg( id.x() )
            .arg( id.y() )
            .arg( suffix );
        break;
    case GeoSceneTileDataset::TileMapService:
        relFileName = QString( "%1/%2/%3/%4.%5" )
            .arg( themeStr() )
            .arg( id.zoomLevel() )
            .arg( id.x() )
            .arg( ( 1<<id.zoomLevel() ) - id.y() - 1 )  //Y coord in TMS runs from bottom to top
            .arg( suffix );
        break;
    }

    return relFileName;
}
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;
}
Beispiel #9
0
bool nuiAiffReader::ReadInfo()
{
  ScanAllChunks();
  
  //there are 8 unused bytes at the beginning of the "SSND" chunk in an AIFF file
  Chunk* pSSNDChunk = GetChunk("SSND");
  if (!pSSNDChunk)
    return false;
  pSSNDChunk->mDataPosition += 8;
  
  bool res = false;
  
  res = GoToChunk("FORM");
  if (!res)
    return false;
  std::vector<char> fileFormat(4);
  char* waveFormat = "AIFF";
  for(uint32 i = 0; i < 4; i++)
  {
    if( 1 != mrStream.ReadUInt8((uint8*)&(fileFormat[i]), 1))
      return false;
    if (fileFormat[i] != waveFormat[i])
      return false; // this stream is not a wave stream
  }
  mInfo.SetFileFormat(eAudioWave);
  
  res = GoToChunk("COMM");
  if (!res)
    return false;
  
  int16 Channels = 0;
  uint32 SampleFrames = 0;
  int16 SampleSize = 0;
  extended SampleRate;
  
  //Read all parameters given in "COMM" chunk
  if( 1 != mrStream.ReadInt16(&Channels,1))
    return false;
  if( 1 != mrStream.ReadUInt32(&SampleFrames,1))
    return false;
  if( 1 != mrStream.ReadInt16(&SampleSize,1))
    return false;
  
  //read SampleRate exponent
  if( 1 != mrStream.ReadInt16(SampleRate.exp,1))
    return false;
  //read Samplerate Mantisse
  if( 4 != mrStream.ReadInt16(SampleRate.man,4))
    return false;
  
  
  mInfo.SetFormatTag(AIFF_FORMAT_TAG);
  
  mInfo.SetSampleRate(ExtendedToDouble(SampleRate));
  mInfo.SetChannels(Channels);
  mInfo.SetBitsPerSample(SampleSize);
  mInfo.SetSampleFrames(SampleFrames);
  
  mInfo.SetStartFrame(0);
  mInfo.SetStopFrame(mInfo.GetSampleFrames());
  
  return true;
}
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;
  
 }
}
Beispiel #11
0
bool nuiWaveReader::ReadInfo()
{
  ScanAllChunks();
  
  uint16 Format = eWaveFormatUnknown;
  uint16 NbChannels = 0;
  uint32 SamplesPerSec = 0;
  uint32 AvgBytesPerSec = 0;
  uint16 BlockAlign = 0;
  uint16 BitsPerSample = 0;
  uint32 NbSamples = 0;
  
  bool res = false;
  
  res = GoToChunk("RIFF");
  if (!res)
    return false;
  std::vector<char> fileFormat(4);
  char* waveFormat = "WAVE";
  for (int32 i = 0; i < 4; i++)
  {
    if( 1 != mrStream.ReadUInt8((uint8*)&(fileFormat[i]), 1))
      return false;
    if (fileFormat[i] != waveFormat[i])
      return false; // this stream is not a wave stream
  }
  mInfo.SetFileFormat(eAudioWave);

  res = GoToChunk("fmt ");
  if (!res)
    return false;
   
  //Read all parameters given in "fmt" chunk
  if( 1 != mrStream.ReadUInt16(&Format,1))
    return false;
  if( 1 != mrStream.ReadUInt16(&NbChannels,1))
    return false;
  if( 1 != mrStream.ReadUInt32(&SamplesPerSec,1))
    return false;
  if( 1 != mrStream.ReadUInt32(&AvgBytesPerSec,1))
    return false;
  if( 1 != mrStream.ReadUInt16(&BlockAlign,1))
    return false;
  if( 1 != mrStream.ReadUInt16(&BitsPerSample,1))
    return false;
  
  
  mInfo.SetFormatTag(Format);
  mInfo.SetSampleRate(SamplesPerSec);
  mInfo.SetChannels(NbChannels);
  mInfo.SetBitsPerSample(BitsPerSample);
  
  //get number of sample frames
  for(int32 i = 0; i < mChunks.size(); i++)
  {
    if(mChunks[i]->CompareId("data"))  //attempt to reach "data" Chunk
    {
      NbSamples = (int32)mChunks[i]->mDataSize;
      mInfo.SetSampleFrames(NbSamples * 8 / BitsPerSample / NbChannels);
      break;
    }
  }

  mInfo.SetStartFrame(0);
  mInfo.SetStopFrame(mInfo.GetSampleFrames());
  
  return true;
}