6 #include "TFileCollection.h"    10 #include "Analysis/Tools/interface/JetCollection.h"    11 #include "Analysis/Tools/interface/Muons.h"    22 int main(
int argc, 
char * argv[])
    24    TH1::SetDefaultSumw2();  
    27    std::string inputList = 
"rootFileList.txt"; 
    28    TFileCollection fc(
"dum",
"",inputList.c_str());
    32    TChain * t_xsection  = 
new TChain(
"MonteCarloStudies/Metadata/CrossSections");
    33    t_xsection -> AddFileInfoList((TCollection*) fc.GetList());
    36    TChain * t_genfilter  = 
new TChain(
"MonteCarloStudies/Metadata/GeneratorFilter");
    37    t_genfilter -> AddFileInfoList((TCollection*) fc.GetList());
    44    TChain * t_Event   = 
new TChain(
"MonteCarloStudies/Events/EventInfo");
    45    t_Event->AddFileInfoList((TCollection*) fc.GetList());
    48    TChain * t_Jets    = 
new TChain(
"MonteCarloStudies/Events/slimmedJetsPuppi");
    49    TChain * t_Muons   = 
new TChain(
"MonteCarloStudies/Events/slimmedMuons");
    50    t_Jets   -> AddFileInfoList((TCollection*) fc.GetList());
    51    t_Muons  -> AddFileInfoList((TCollection*) fc.GetList());
    54    t_Event -> AddFriend(t_Jets);
    55    t_Event -> AddFriend(t_Muons);
    58    JetCollection  jets (t_Jets);
    62    std::map<std::string, TH1F*> h1;
    64    h1[
"h_jet_N"]        = 
new TH1F(
"h_jet_N" , 
"", 20, 0., 20.);
    65    h1[
"h_jet_Pt"]       = 
new TH1F(
"h_jet_Pt" , 
"", 200, 0., 1000.);
    66    h1[
"h_jet_Eta"]      = 
new TH1F(
"h_jet_Eta", 
"", 100, -5, 5.);
    67    h1[
"h_jet_Phi"]      = 
new TH1F(
"h_jet_Phi", 
"", 100, 3.2, 3.2);
    68    h1[
"h_jet_Btag"]     = 
new TH1F(
"h_jet_Btag", 
"", 100, 0., 1.);
    69    h1[
"h_jet_Flavour"]  = 
new TH1F(
"h_jet_Flavour", 
"", 40, -10., 30.);
    70    h1[
"h_jet_IdLoose"]  = 
new TH1F(
"h_jet_IdLoose", 
"", 2, 0, 2);
    71    h1[
"h_jet_IdTight"]  = 
new TH1F(
"h_jet_IdTight", 
"", 2, 0, 2);
    73    h1[
"h_muon_N"]       = 
new TH1F(
"h_muon_N" , 
"", 20, 0., 20.);
    74    h1[
"h_muon_Pt"]      = 
new TH1F(
"h_muon_Pt" , 
"", 200, 0., 1000.);
    75    h1[
"h_muon_Eta"]     = 
new TH1F(
"h_muon_Eta", 
"", 100, -5, 5.);
    76    h1[
"h_muon_Phi"]     = 
new TH1F(
"h_muon_Phi", 
"", 100, 3.2, 3.2);
    80    int nEvents = t_Event->GetEntries();
    84    for ( 
int i = 0 ; i < nEvents ; ++i )
    92       h1[
"h_jet_N"]  -> Fill(jets.size());
    93       for ( 
int i = 0; i < jets.size(); ++i )
    96          h1[
"h_jet_Pt"]      -> Fill(jet.
pt());
    97          h1[
"h_jet_Eta"]     -> Fill(jet.
eta());
    98          h1[
"h_jet_Phi"]     -> Fill(jet.
phi());
    99          h1[
"h_jet_Btag"]    -> Fill(jet.
btag(
"btag_csvivf"));
   100          h1[
"h_jet_Flavour"] -> Fill(jet.
flavour());
   101          h1[
"h_jet_IdLoose"] -> Fill(jet.
idLoose());
   102          h1[
"h_jet_IdTight"] -> Fill(jet.
idTight());
   105       h1[
"h_muon_N"]  -> Fill(muons.size());
   106       for ( 
int i = 0; i < muons.size(); ++i )
   108          Muon muon = muons.at(i);
   109          h1[
"h_muon_Pt"]      -> Fill(muon.
pt());
   110          h1[
"h_muon_Eta"]     -> Fill(muon.
eta());
   111          h1[
"h_muon_Phi"]     -> Fill(muon.
phi());
   116    TFile * outFile = 
new TFile(
"ExampleNtupleHistograms.root",
"RECREATE");
   117    outFile -> mkdir(
"Jets",
"Jets");
   118    outFile -> mkdir(
"Muons",
"Muons");
   120    for ( 
auto& ih1 : h1 )
   122       if ( ih1.first.find(
"h_jet_") != std::string::npos )
   123          outFile -> cd(
"Jets");
   124       if ( ih1.first.find(
"h_muon_") != std::string::npos )
   125          outFile -> cd(
"Muons");
   126       ih1.second -> Write();
   137    std::cout << 
"=======================================================" << std::endl;
   138    std::cout << 
"  CROSS SECTIONS" << std::endl;
   139    std::cout << 
"=======================================================" << std::endl;
   141    TObjArray * xsecBranches = tree->GetListOfBranches();
   142    std::map<std::string, double> xsections;
   143    for ( 
int i = 0 ; i < xsecBranches->GetEntries() ; ++i )
   145       std::string branch = xsecBranches->At(i)->GetName();
   146       if ( branch == 
"run" ) 
continue;
   147       xsections[branch] = 0;
   148       tree -> SetBranchAddress(branch.c_str(), &xsections[branch]);
   151    for ( 
auto& xs : xsections )
   153       std::cout << xs.first << 
" = " << xs.second << 
" pb " << std::endl;
   155    std::cout << 
"=======================================================" << std::endl;
   156    std::cout << std::endl;
   157    std::cout << std::endl;
   163    std::cout << 
"=======================================================" << std::endl;
   164    std::cout << 
"  GENERATOR FILTER" << std::endl;
   165    std::cout << 
"=======================================================" << std::endl;
   167    unsigned int nEvtTot;
   168    unsigned int nEvtFlt;
   169    unsigned int sEvtTot = 0;
   170    unsigned int sEvtFlt = 0;
   172    tree -> SetBranchAddress(
"nEventsTotal", &nEvtTot);
   173    tree -> SetBranchAddress(
"nEventsFiltered", &nEvtFlt);
   175    for ( 
int i = 0; i < tree->GetEntries(); ++i )
   181    float genFilterEff = float(sEvtFlt)/sEvtTot;
   183    std::cout << 
"Total generated events = " << sEvtTot << std::endl;
   184    std::cout << 
"Filtered generated events = " << sEvtFlt << std::endl;
   185    std::cout << 
"Generator Filter Efficiency = " << genFilterEff << std::endl;
   187    std::cout << 
"=======================================================" << std::endl;
   188    std::cout << std::endl;
   189    std::cout << std::endl;