CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PatMuonAnalyzer Class Reference

Example class that can be used to analyze pat::Muons both within FWLite and within the full framework. More...

#include "PhysicsTools/PatExamples/interface/PatMuonAnalyzer.h"

Inheritance diagram for PatMuonAnalyzer:
edm::BasicAnalyzer

Public Member Functions

void analyze (const edm::EventBase &event)
 everything that needs to be done during the event loop More...
 
void beginJob ()
 everything that needs to be done before the event loop More...
 
void endJob ()
 everything that needs to be done after the event loop More...
 
 PatMuonAnalyzer (const edm::ParameterSet &cfg, TFileDirectory &fs)
 default constructor More...
 
 PatMuonAnalyzer (const edm::ParameterSet &cfg, TFileDirectory &fs, edm::ConsumesCollector &&iC)
 
virtual ~PatMuonAnalyzer ()
 default destructor More...
 
- Public Member Functions inherited from edm::BasicAnalyzer
 BasicAnalyzer (const edm::ParameterSet &cfg, TFileDirectory &fileService)
 default constructor More...
 
 BasicAnalyzer (const edm::ParameterSet &cfg, TFileDirectory &fileService, edm::ConsumesCollector &&iC)
 
virtual ~BasicAnalyzer ()
 default destructor More...
 

Private Attributes

std::map< std::string, TH1 * > hists_
 histograms More...
 
edm::InputTag muons_
 input tag for mouns More...
 
edm::EDGetTokenT< std::vector
< pat::Muon > > 
muonsToken_
 

Detailed Description

Example class that can be used to analyze pat::Muons both within FWLite and within the full framework.

This is an example for keeping classes that can be used both within FWLite and within the full framework. The class is derived from the BasicAnalyzer base class, which is an interface for the two wrapper classes EDAnalyzerWrapper and FWLiteAnalyzerWrapper. You can fin more information on this on WorkBookFWLiteExamples::ExampleFive.

Definition at line 18 of file PatMuonAnalyzer.h.

Constructor & Destructor Documentation

PatMuonAnalyzer::PatMuonAnalyzer ( const edm::ParameterSet cfg,
TFileDirectory fs 
)

default constructor

Definition at line 7 of file PatMuonAnalyzer.cc.

References hists_, and TFileDirectory::make().

7  :
9  muons_(cfg.getParameter<edm::InputTag>("muons"))
10 {
11  hists_["muonPt" ] = fs.make<TH1F>("muonPt" , "pt" , 100, 0., 300.);
12  hists_["muonEta" ] = fs.make<TH1F>("muonEta" , "eta" , 100, -3., 3.);
13  hists_["muonPhi" ] = fs.make<TH1F>("muonPhi" , "phi" , 100, -5., 5.);
14 }
T getParameter(std::string const &) const
edm::InputTag muons_
input tag for mouns
T * make(const Args &...args) const
make new ROOT object
std::map< std::string, TH1 * > hists_
histograms
BasicAnalyzer(const edm::ParameterSet &cfg, TFileDirectory &fileService)
default constructor
Definition: BasicAnalyzer.h:46
PatMuonAnalyzer::PatMuonAnalyzer ( const edm::ParameterSet cfg,
TFileDirectory fs,
edm::ConsumesCollector &&  iC 
)

Definition at line 15 of file PatMuonAnalyzer.cc.

References hists_, and TFileDirectory::make().

15  :
17  muons_(cfg.getParameter<edm::InputTag>("muons")) ,
18  muonsToken_(iC.consumes<std::vector<pat::Muon> >(muons_))
19 {
20  hists_["muonPt" ] = fs.make<TH1F>("muonPt" , "pt" , 100, 0., 300.);
21  hists_["muonEta" ] = fs.make<TH1F>("muonEta" , "eta" , 100, -3., 3.);
22  hists_["muonPhi" ] = fs.make<TH1F>("muonPhi" , "phi" , 100, -5., 5.);
23 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::InputTag muons_
input tag for mouns
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
T * make(const Args &...args) const
make new ROOT object
std::map< std::string, TH1 * > hists_
histograms
BasicAnalyzer(const edm::ParameterSet &cfg, TFileDirectory &fileService)
default constructor
Definition: BasicAnalyzer.h:46
virtual PatMuonAnalyzer::~PatMuonAnalyzer ( )
inlinevirtual

default destructor

Definition at line 25 of file PatMuonAnalyzer.h.

25 {};

Member Function Documentation

void PatMuonAnalyzer::analyze ( const edm::EventBase event)
virtual

everything that needs to be done during the event loop

Implements edm::BasicAnalyzer.

Definition at line 27 of file PatMuonAnalyzer.cc.

References hists_, configurableAnalysis::Muon, patZpeak::muons, and muons_.

28 {
29  // define what muon you are using; this is necessary as FWLite is not
30  // capable of reading edm::Views
31  using pat::Muon;
32 
33  // Handle to the muon collection
35  event.getByLabel(muons_, muons);
36 
37  // loop muon collection and fill histograms
38  for(std::vector<Muon>::const_iterator mu1=muons->begin(); mu1!=muons->end(); ++mu1){
39  hists_["muonPt" ]->Fill( mu1->pt () );
40  hists_["muonEta"]->Fill( mu1->eta() );
41  hists_["muonPhi"]->Fill( mu1->phi() );
42  }
43 }
edm::InputTag muons_
input tag for mouns
std::map< std::string, TH1 * > hists_
histograms
tuple muons
Definition: patZpeak.py:38
void PatMuonAnalyzer::beginJob ( void  )
inlinevirtual

everything that needs to be done before the event loop

Implements edm::BasicAnalyzer.

Definition at line 27 of file PatMuonAnalyzer.h.

27 {};
void PatMuonAnalyzer::endJob ( void  )
inlinevirtual

everything that needs to be done after the event loop

Implements edm::BasicAnalyzer.

Definition at line 29 of file PatMuonAnalyzer.h.

29 {};

Member Data Documentation

std::map<std::string, TH1*> PatMuonAnalyzer::hists_
private

histograms

Definition at line 38 of file PatMuonAnalyzer.h.

Referenced by analyze(), and PatMuonAnalyzer().

edm::InputTag PatMuonAnalyzer::muons_
private

input tag for mouns

Definition at line 35 of file PatMuonAnalyzer.h.

Referenced by analyze().

edm::EDGetTokenT<std::vector<pat::Muon> > PatMuonAnalyzer::muonsToken_
private

Definition at line 36 of file PatMuonAnalyzer.h.