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 Member Functions | Private Attributes
PatTriggerAnalyzer Class Reference

#include <PatTriggerAnalyzer.h>

Inheritance diagram for PatTriggerAnalyzer:
edm::EDAnalyzer

Public Member Functions

 PatTriggerAnalyzer (const edm::ParameterSet &iConfig)
 default constructor More...
 
 ~PatTriggerAnalyzer ()
 default destructor More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 everythin that needs to be done during the event loop More...
 
virtual void beginJob ()
 everythin that needs to be done before the event loop More...
 
virtual void endJob ()
 everythin that needs to be done after the event loop More...
 

Private Attributes

std::map< std::string, TH1D * > histos1D_
 histogram management More...
 
std::map< std::string, TH2D * > histos2D_
 
unsigned maxID_
 maximal id for meanPt plot More...
 
unsigned minID_
 minimal id for meanPt plot More...
 
std::string muonMatch_
 input for trigger match objects More...
 
edm::InputTag muons_
 input for muons More...
 
std::map< unsigned, unsigned > sumN_
 internals for meanPt histogram calculation More...
 
std::map< unsigned, double > sumPt_
 
edm::InputTag trigger_
 input for patTrigger More...
 
edm::InputTag triggerEvent_
 input for patTriggerEvent More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 19 of file PatTriggerAnalyzer.h.

Constructor & Destructor Documentation

PatTriggerAnalyzer::PatTriggerAnalyzer ( const edm::ParameterSet iConfig)
explicit

default constructor

Definition at line 12 of file PatTriggerAnalyzer.cc.

12  :
13  // pat::Trigger
14  trigger_( iConfig.getParameter< edm::InputTag >( "trigger" ) ),
15  // pat::TriggerEvent
16  triggerEvent_( iConfig.getParameter< edm::InputTag >( "triggerEvent" ) ),
17  // muon input collection
18  muons_( iConfig.getParameter< edm::InputTag >( "muons" ) ),
19  // muon match objects
20  muonMatch_( iConfig.getParameter< std::string >( "muonMatch" ) ),
21  // minimal id for of all trigger objects
22  minID_( iConfig.getParameter< unsigned >( "minID" ) ),
23  // maximal id for of all trigger objects
24  maxID_( iConfig.getParameter< unsigned >( "maxID" ) ),
25  histos1D_(), histos2D_()
26 {
27 }
T getParameter(std::string const &) const
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
edm::InputTag triggerEvent_
input for patTriggerEvent
edm::InputTag muons_
input for muons
edm::InputTag trigger_
input for patTrigger
std::map< std::string, TH2D * > histos2D_
unsigned maxID_
maximal id for meanPt plot
std::string muonMatch_
input for trigger match objects
PatTriggerAnalyzer::~PatTriggerAnalyzer ( )

default destructor

Definition at line 29 of file PatTriggerAnalyzer.cc.

30 {
31 }

Member Function Documentation

void PatTriggerAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

everythin that needs to be done during the event loop

Implements edm::EDAnalyzer.

Definition at line 65 of file PatTriggerAnalyzer.cc.

References edm::Event::getByLabel(), histos1D_, histos2D_, ExpressReco_HICollisions_FallBack::id, maxID_, minID_, muonMatch_, ExpressReco_HICollisions_FallBack::muons, muons_, sumN_, sumPt_, triggerEvent_, and trigger::TriggerMuon.

66 {
67  // PAT trigger event
68  edm::Handle< TriggerEvent > triggerEvent;
69  iEvent.getByLabel( triggerEvent_, triggerEvent );
70 
71  // PAT object collection
73  iEvent.getByLabel( muons_, muons );
74 
75  // PAT trigger helper for trigger matching information
76  const helper::TriggerMatchHelper matchHelper;
77 
78  /*
79  kinematics comparison
80  */
81 
82  // loop over muon references (PAT muons have been used in the matcher in task 3)
83  for( size_t iMuon = 0; iMuon < muons->size(); ++iMuon ) {
84  // we need all these ingedients to recieve matched trigger object from the matchHelper
85  const TriggerObjectRef trigRef( matchHelper.triggerMatchObject( muons, iMuon, muonMatch_, iEvent, *triggerEvent ) );
86  // finally we can fill the histograms
87  if ( trigRef.isAvailable() && trigRef.isNonnull() ) { // check references (necessary!)
88  histos2D_[ "ptTrigCand" ]->Fill( muons->at( iMuon ).pt(), trigRef->pt() );
89  histos2D_[ "etaTrigCand" ]->Fill( muons->at( iMuon ).eta(), trigRef->eta() );
90  histos2D_[ "phiTrigCand" ]->Fill( muons->at( iMuon ).phi(), trigRef->phi() );
91  }
92  }
93 
94  /*
95  turn-on curve
96  */
97 
98  // get the trigger objects corresponding to the used matching (HLT muons)
99  const TriggerObjectRefVector trigRefs( triggerEvent->objects( trigger::TriggerMuon ) );
100  // loop over selected trigger objects
101  for ( TriggerObjectRefVector::const_iterator iTrig = trigRefs.begin(); iTrig != trigRefs.end(); ++iTrig ) {
102  // get all matched candidates for the trigger object
103  const reco::CandidateBaseRefVector candRefs( matchHelper.triggerMatchCandidates( ( *iTrig), muonMatch_, iEvent, *triggerEvent ) );
104  if ( candRefs.empty() ) continue;
105  // fill the histogram...
106  // (only for the first match, since we resolved ambiguities in the matching configuration,
107  // so that we have one at maximum per trigger object)
108  reco::CandidateBaseRef muonRef( candRefs.at( 0 ) );
109  if ( muonRef.isAvailable() && muonRef.isNonnull() ) {
110  histos1D_[ "turnOn" ]->Fill( muonRef->pt() );
111  }
112  }
113 
114  /*
115  mean pt
116  */
117 
118  // loop over all trigger match objects from minID to maxID; have
119  // a look to DataFormats/HLTReco/interface/TriggerTypeDefs.h to
120  // know more about the available trrigger object id's
121  for ( unsigned id=minID_; id<=maxID_; ++id ) {
122  // vector of all objects for a given object id
123  const TriggerObjectRefVector objRefs( triggerEvent->objects( id ) );
124  // buffer the number of objects
125  sumN_[ id ] += objRefs.size();
126  // iterate the objects and buffer the pt of the objects
127  for ( TriggerObjectRefVector::const_iterator iRef = objRefs.begin(); iRef != objRefs.end(); ++iRef ) {
128  sumPt_[ id ] += ( *iRef )->pt();
129  }
130  }
131 }
std::map< std::string, TH1D * > histos1D_
histogram management
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
unsigned minID_
minimal id for meanPt plot
edm::InputTag triggerEvent_
input for patTriggerEvent
std::map< unsigned, double > sumPt_
edm::InputTag muons_
input for muons
std::map< std::string, TH2D * > histos2D_
std::map< unsigned, unsigned > sumN_
internals for meanPt histogram calculation
unsigned maxID_
maximal id for meanPt plot
std::string muonMatch_
input for trigger match objects
void PatTriggerAnalyzer::beginJob ( void  )
privatevirtual

everythin that needs to be done before the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file PatTriggerAnalyzer.cc.

References fileService, histos1D_, histos2D_, ExpressReco_HICollisions_FallBack::id, TFileDirectory::make(), maxID_, minID_, Pi, sumN_, and sumPt_.

34 {
36 
37  // pt correlation plot
38  histos2D_[ "ptTrigCand" ] = fileService->make< TH2D >( "ptTrigCand", "Object vs. candidate p_{T} (GeV)", 60, 0., 300., 60, 0., 300. );
39  histos2D_[ "ptTrigCand" ]->SetXTitle( "candidate p_{T} (GeV)" );
40  histos2D_[ "ptTrigCand" ]->SetYTitle( "object p_{T} (GeV)" );
41  // eta correlation plot
42  histos2D_[ "etaTrigCand" ] = fileService->make< TH2D >( "etaTrigCand", "Object vs. candidate #eta", 50, -2.5, 2.5, 50, -2.5, 2.5 );
43  histos2D_[ "etaTrigCand" ]->SetXTitle( "candidate #eta" );
44  histos2D_[ "etaTrigCand" ]->SetYTitle( "object #eta" );
45  // phi correlation plot
46  histos2D_[ "phiTrigCand" ] = fileService->make< TH2D >( "phiTrigCand", "Object vs. candidate #phi", 60, -TMath::Pi(), TMath::Pi(), 60, -TMath::Pi(), TMath::Pi() );
47  histos2D_[ "phiTrigCand" ]->SetXTitle( "candidate #phi" );
48  histos2D_[ "phiTrigCand" ]->SetYTitle( "object #phi" );
49  // turn-on curves
50  histos1D_[ "turnOn" ] = fileService->make< TH1D >( "turnOn", "p_{T} (GeV) of matched candidate", 10, 0., 50.);
51  histos1D_[ "turnOn" ]->SetXTitle( "candidate p_{T} (GeV)" );
52  histos1D_[ "turnOn" ]->SetYTitle( "# of objects" );
53  // mean pt for all trigger objects
54  histos1D_[ "ptMean" ] = fileService->make< TH1D >( "ptMean", "Mean p_{T} (GeV) per filter ID", maxID_ - minID_ + 1, minID_ - 0.5, maxID_ + 0.5);
55  histos1D_[ "ptMean" ]->SetXTitle( "filter ID" );
56  histos1D_[ "ptMean" ]->SetYTitle( "mean p_{T} (GeV)" );
57 
58  // initialize counters for mean pt calculation
59  for( unsigned id = minID_; id <= maxID_; ++id ){
60  sumN_ [ id ] = 0;
61  sumPt_[ id ] = 0.;
62  }
63 }
const double Pi
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
edm::Service< TFileService > fileService
std::map< unsigned, double > sumPt_
std::map< std::string, TH2D * > histos2D_
std::map< unsigned, unsigned > sumN_
internals for meanPt histogram calculation
T * make() const
make new ROOT object
unsigned maxID_
maximal id for meanPt plot
void PatTriggerAnalyzer::endJob ( void  )
privatevirtual

everythin that needs to be done after the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 133 of file PatTriggerAnalyzer.cc.

References histos1D_, ExpressReco_HICollisions_FallBack::id, maxID_, minID_, sumN_, and sumPt_.

134 {
135  // normalize the entries for the mean pt plot
136  for(unsigned id=minID_; id<=maxID_; ++id){
137  if( sumN_[ id ]!=0 ) histos1D_[ "ptMean" ]->Fill( id, sumPt_[ id ]/sumN_[ id ] );
138  }
139 }
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
std::map< unsigned, double > sumPt_
std::map< unsigned, unsigned > sumN_
internals for meanPt histogram calculation
unsigned maxID_
maximal id for meanPt plot

Member Data Documentation

std::map< std::string, TH1D* > PatTriggerAnalyzer::histos1D_
private

histogram management

Definition at line 49 of file PatTriggerAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

std::map< std::string, TH2D* > PatTriggerAnalyzer::histos2D_
private

Definition at line 50 of file PatTriggerAnalyzer.h.

Referenced by analyze(), and beginJob().

unsigned PatTriggerAnalyzer::maxID_
private

maximal id for meanPt plot

Definition at line 46 of file PatTriggerAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

unsigned PatTriggerAnalyzer::minID_
private

minimal id for meanPt plot

Definition at line 44 of file PatTriggerAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

std::string PatTriggerAnalyzer::muonMatch_
private

input for trigger match objects

Definition at line 42 of file PatTriggerAnalyzer.h.

Referenced by analyze().

edm::InputTag PatTriggerAnalyzer::muons_
private

input for muons

Definition at line 40 of file PatTriggerAnalyzer.h.

Referenced by analyze().

std::map< unsigned, unsigned > PatTriggerAnalyzer::sumN_
private

internals for meanPt histogram calculation

Definition at line 53 of file PatTriggerAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

std::map< unsigned, double > PatTriggerAnalyzer::sumPt_
private

Definition at line 54 of file PatTriggerAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

edm::InputTag PatTriggerAnalyzer::trigger_
private

input for patTrigger

Definition at line 36 of file PatTriggerAnalyzer.h.

edm::InputTag PatTriggerAnalyzer::triggerEvent_
private

input for patTriggerEvent

Definition at line 38 of file PatTriggerAnalyzer.h.

Referenced by analyze().