DESY Hbb Analysis Framework
Functions
AnalysisMuonsExample.cc File Reference
#include <string>
#include <iostream>
#include <vector>
#include "TFile.h"
#include "TFileCollection.h"
#include "TChain.h"
#include "TH1.h"
#include "Analysis/Tools/interface/Analysis.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 18 of file AnalysisMuonsExample.cc.

References analysis::tools::Analysis::addTree(), analysis::tools::Analysis::collection(), analysis::tools::Candidate::eta(), analysis::tools::Analysis::event(), analysis::tools::Muon::isGlobalMuon(), analysis::tools::Muon::isLooseMuon(), analysis::tools::Muon::isMediumMuon(), analysis::tools::Muon::isPFMuon(), analysis::tools::Muon::isTrackerMuon(), analysis::tools::Candidate::phi(), analysis::tools::Candidate::pt(), analysis::tools::Candidate::q(), and analysis::tools::Analysis::size().

19 {
20 // bool isMC = false;
21  TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
22 
23  // Input files list
24  std::string inputList = "rootFileList.txt";
25  Analysis analysis(inputList);
26 
27  // Physics Objects Collections
28  analysis.addTree<Muon> ("Muons","MssmHbb/Events/slimmedMuons");
29 
30  TFile hout("histograms_muons.root","recreate");
31 
32  std::map<std::string, TH1F*> h1;
33  h1["n"] = new TH1F("n" , "" , 30, 0, 30);
34  h1["pt"] = new TH1F("pt" , "" , 100, 0, 770);
35  h1["eta"] = new TH1F("eta" , "" , 100, -5.30, 3.30);
36  h1["phi"] = new TH1F("phi" , "" , 100, -3.7, 3.7);
37  h1["q"] = new TH1F("q", "", 4, -2, 2);
38  h1["isPF"] = new TH1F("isPF","",2,0,2);
39  h1["isGlobal"] = new TH1F("isGlobal","",2,0,2);
40  h1["isTracker"] = new TH1F("isTracker","",2,0,2);
41  h1["isLoose"] = new TH1F("isLoose","",2,0,2);
42  h1["isMedium"] = new TH1F("isMedium","",2,0,2);
43 
44 
45  // Analysis of events
46  std::cout << "This analysis has " << analysis.size() << " events" << std::endl;
47  int nevents = analysis.size();
48 
49 // int nFired = 0;
50  for ( int i = 0 ; i < nevents ; ++i )
51  {
52  if ( i > 0 && i%100000 == 0 ) std::cout << i << " events processed..." << std::endl;
53 
54  analysis.event(i);
55 
56  // Muons
57  auto muons = analysis.collection<Muon>("Muons");
58  int nmuons = 0;
59  for ( int m = 0 ; m < muons->size() ; ++m )
60  {
61  Muon muon = muons->at(m);
62  h1["pt"] -> Fill(muon.pt());
63  h1["eta"] -> Fill(muon.eta());
64  h1["phi"] -> Fill(muon.phi());
65  h1["q"] -> Fill(muon.q());
66  h1["isPF"] -> Fill(muon.isPFMuon() );
67  h1["isGlobal"] -> Fill(muon.isGlobalMuon() );
68  h1["isTracker"] -> Fill(muon.isTrackerMuon());
69  h1["isLoose"] -> Fill(muon.isLooseMuon() );
70  h1["isMedium"] -> Fill(muon.isMediumMuon() );
71  ++nmuons;
72 
73  }
74  h1["n"] -> Fill(nmuons);
75 
76  }
77 
78  for (auto & ih1 : h1)
79  {
80  ih1.second -> Write();
81  }
82 
83 //
84 }
float eta() const
returns the pseudorapidity
Definition: Candidate.cc:134
float phi() const
returns the azimuthal angle
Definition: Candidate.cc:135
bool isPFMuon() const
Definition: Muon.cc:42
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
bool isGlobalMuon() const
Definition: Muon.cc:43
bool isLooseMuon() const
Definition: Muon.cc:45
int q() const
returns the charge
Definition: Candidate.cc:139
bool isMediumMuon() const
Definition: Muon.cc:46
bool isTrackerMuon() const
Definition: Muon.cc:44