CMS 3D CMS Logo

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

List of all members.

Public Member Functions

void analyze (const edm::EventBase &event)
 everything that needs to be done during the event loop
void beginJob ()
 everything that needs to be done before the event loop
void endJob ()
 everything that needs to be done after the event loop
 PatMuonAnalyzer (const edm::ParameterSet &cfg, TFileDirectory &fs)
 default constructor
virtual ~PatMuonAnalyzer ()
 default destructor

Private Attributes

std::map< std::string, TH1 * > hists_
 histograms
edm::InputTag muons_
 input tag for mouns

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 17 of file PatMuonAnalyzer.h.


Constructor & Destructor Documentation

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

default constructor

Definition at line 8 of file PatMuonAnalyzer.cc.

References hists_, and TFileDirectory::make().

                                                                              : 
  edm::BasicAnalyzer::BasicAnalyzer(cfg, fs),
  muons_(cfg.getParameter<edm::InputTag>("muons"))
{
  hists_["muonPt"  ] = fs.make<TH1F>("muonPt"  , "pt"  ,  100,  0., 300.);
  hists_["muonEta" ] = fs.make<TH1F>("muonEta" , "eta" ,  100, -3.,   3.);
  hists_["muonPhi" ] = fs.make<TH1F>("muonPhi" , "phi" ,  100, -5.,   5.); 
}
virtual PatMuonAnalyzer::~PatMuonAnalyzer ( ) [inline, virtual]

default destructor

Definition at line 23 of file PatMuonAnalyzer.h.

{};

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 19 of file PatMuonAnalyzer.cc.

References hists_, patZpeak::muons, and muons_.

{
  // define what muon you are using; this is necessary as FWLite is not 
  // capable of reading edm::Views
  using pat::Muon;

  // Handle to the muon collection
  edm::Handle<std::vector<Muon> > muons;
  event.getByLabel(muons_, muons);

  // loop muon collection and fill histograms
  for(std::vector<Muon>::const_iterator mu1=muons->begin(); mu1!=muons->end(); ++mu1){
    hists_["muonPt" ]->Fill( mu1->pt () );
    hists_["muonEta"]->Fill( mu1->eta() );
    hists_["muonPhi"]->Fill( mu1->phi() );
  }
}
void PatMuonAnalyzer::beginJob ( void  ) [inline, virtual]

everything that needs to be done before the event loop

Implements edm::BasicAnalyzer.

Definition at line 25 of file PatMuonAnalyzer.h.

{};
void PatMuonAnalyzer::endJob ( void  ) [inline, virtual]

everything that needs to be done after the event loop

Implements edm::BasicAnalyzer.

Definition at line 27 of file PatMuonAnalyzer.h.

{};

Member Data Documentation

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

histograms

Definition at line 35 of file PatMuonAnalyzer.h.

Referenced by analyze(), and PatMuonAnalyzer().

input tag for mouns

Definition at line 33 of file PatMuonAnalyzer.h.

Referenced by analyze().