CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PatTriggerAnalyzer Class Reference
Inheritance diagram for PatTriggerAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 PatTriggerAnalyzer (const edm::ParameterSet &iConfig)
 default constructor More...
 
 ~PatTriggerAnalyzer () override
 default destructor More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 everythin that needs to be done during the event loop More...
 
void beginJob () override
 everythin that needs to be done before the event loop More...
 
void endJob () override
 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::EDGetTokenT< pat::MuonCollectionmuonsToken_
 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::EDGetTokenT< pat::TriggerEventtriggerEventToken_
 input for patTriggerEvent More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 16 of file PatTriggerAnalyzer.cc.

Constructor & Destructor Documentation

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

default constructor

Definition at line 65 of file PatTriggerAnalyzer.cc.

65  :
66  // pat::Trigger
67  trigger_( iConfig.getParameter< edm::InputTag >( "trigger" ) ),
68  // pat::TriggerEvent
69  triggerEventToken_( consumes< TriggerEvent >( iConfig.getParameter< edm::InputTag >( "triggerEvent" ) ) ),
70  // muon input collection
71  muonsToken_( consumes< MuonCollection >( iConfig.getParameter< edm::InputTag >( "muons" ) ) ),
72  // muon match objects
73  muonMatch_( iConfig.getParameter< std::string >( "muonMatch" ) ),
74  // minimal id for of all trigger objects
75  minID_( iConfig.getParameter< unsigned >( "minID" ) ),
76  // maximal id for of all trigger objects
77  maxID_( iConfig.getParameter< unsigned >( "maxID" ) ),
78  histos1D_(), histos2D_()
79 {
80 }
T getParameter(std::string const &) const
edm::EDGetTokenT< pat::MuonCollection > muonsToken_
input for muons
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
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
edm::EDGetTokenT< pat::TriggerEvent > triggerEventToken_
input for patTriggerEvent
PatTriggerAnalyzer::~PatTriggerAnalyzer ( )
override

default destructor

Definition at line 82 of file PatTriggerAnalyzer.cc.

83 {
84 }

Member Function Documentation

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

everythin that needs to be done during the event loop

Definition at line 118 of file PatTriggerAnalyzer.cc.

References edm::Event::getByToken(), histos1D_, histos2D_, triggerObjects_cff::id, maxID_, minID_, muonMatch_, extraflags_cff::muons, muonsToken_, pat::TriggerEvent::objects(), sumN_, sumPt_, triggerEventToken_, and trigger::TriggerMuon.

119 {
120  // PAT trigger event
121  edm::Handle< TriggerEvent > triggerEvent;
122  iEvent.getByToken( triggerEventToken_, triggerEvent );
123 
124  // PAT object collection
126  iEvent.getByToken( muonsToken_, muons );
127 
128  // PAT trigger helper for trigger matching information
129  const helper::TriggerMatchHelper matchHelper;
130 
131  /*
132  kinematics comparison
133  */
134 
135  // loop over muon references (PAT muons have been used in the matcher in task 3)
136  for( size_t iMuon = 0; iMuon < muons->size(); ++iMuon ) {
137  // we need all these ingedients to recieve matched trigger objects from the matchHelper
138  const TriggerObjectRef trigRef( matchHelper.triggerMatchObject( muons, iMuon, muonMatch_, iEvent, *triggerEvent ) );
139  // finally we can fill the histograms
140  if ( trigRef.isAvailable() && trigRef.isNonnull() ) { // check references (necessary!)
141  histos2D_[ "ptTrigCand" ]->Fill( muons->at( iMuon ).pt(), trigRef->pt() );
142  histos2D_[ "etaTrigCand" ]->Fill( muons->at( iMuon ).eta(), trigRef->eta() );
143  histos2D_[ "phiTrigCand" ]->Fill( muons->at( iMuon ).phi(), trigRef->phi() );
144  }
145  }
146 
147  /*
148  turn-on curve
149  */
150 
151  // get the trigger objects corresponding to the used matching (HLT muons)
152  const TriggerObjectRefVector trigRefs( triggerEvent->objects( trigger::TriggerMuon ) );
153  // loop over selected trigger objects
154  for ( TriggerObjectRefVector::const_iterator iTrig = trigRefs.begin(); iTrig != trigRefs.end(); ++iTrig ) {
155  // get all matched candidates for the trigger object
156  const reco::CandidateBaseRefVector candRefs( matchHelper.triggerMatchCandidates( ( *iTrig ), muonMatch_, iEvent, *triggerEvent ) );
157  if ( candRefs.empty() ) continue;
158  // fill the histogram...
159  // (only for the first match, since we resolved ambiguities in the matching configuration,
160  // so that we have one at maximum per trigger object)
161  reco::CandidateBaseRef muonRef( candRefs.at( 0 ) );
162  if ( muonRef.isAvailable() && muonRef.isNonnull() ) {
163  histos1D_[ "turnOn" ]->Fill( muonRef->pt() );
164  }
165  }
166 
167  /*
168  mean pt
169  */
170 
171  // loop over all trigger match objects from minID to maxID; have
172  // a look to DataFormats/HLTReco/interface/TriggerTypeDefs.h to
173  // know more about the available trrigger object id's
174  for ( unsigned id=minID_; id<=maxID_; ++id ) {
175  // vector of all objects for a given object id
176  const TriggerObjectRefVector objRefs( triggerEvent->objects( id ) );
177  // buffer the number of objects
178  sumN_[ id ] += objRefs.size();
179  // iterate the objects and buffer the pt of the objects
180  for ( TriggerObjectRefVector::const_iterator iRef = objRefs.begin(); iRef != objRefs.end(); ++iRef ) {
181  sumPt_[ id ] += ( *iRef )->pt();
182  }
183  }
184 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
const TriggerObjectCollection * objects() const
Definition: TriggerEvent.h:283
edm::EDGetTokenT< pat::MuonCollection > muonsToken_
input for muons
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
std::map< unsigned, double > sumPt_
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
edm::EDGetTokenT< pat::TriggerEvent > triggerEventToken_
input for patTriggerEvent
void PatTriggerAnalyzer::beginJob ( void  )
overrideprivatevirtual

everythin that needs to be done before the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file PatTriggerAnalyzer.cc.

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

87 {
89 
90  // pt correlation plot
91  histos2D_[ "ptTrigCand" ] = fileService->make< TH2D >( "ptTrigCand", "Object vs. candidate p_{T} (GeV)", 60, 0., 300., 60, 0., 300. );
92  histos2D_[ "ptTrigCand" ]->SetXTitle( "candidate p_{T} (GeV)" );
93  histos2D_[ "ptTrigCand" ]->SetYTitle( "object p_{T} (GeV)" );
94  // eta correlation plot
95  histos2D_[ "etaTrigCand" ] = fileService->make< TH2D >( "etaTrigCand", "Object vs. candidate #eta", 50, -2.5, 2.5, 50, -2.5, 2.5 );
96  histos2D_[ "etaTrigCand" ]->SetXTitle( "candidate #eta" );
97  histos2D_[ "etaTrigCand" ]->SetYTitle( "object #eta" );
98  // phi correlation plot
99  histos2D_[ "phiTrigCand" ] = fileService->make< TH2D >( "phiTrigCand", "Object vs. candidate #phi", 60, -TMath::Pi(), TMath::Pi(), 60, -TMath::Pi(), TMath::Pi() );
100  histos2D_[ "phiTrigCand" ]->SetXTitle( "candidate #phi" );
101  histos2D_[ "phiTrigCand" ]->SetYTitle( "object #phi" );
102  // turn-on curves
103  histos1D_[ "turnOn" ] = fileService->make< TH1D >( "turnOn", "p_{T} (GeV) of matched candidate", 10, 0., 50.);
104  histos1D_[ "turnOn" ]->SetXTitle( "candidate p_{T} (GeV)" );
105  histos1D_[ "turnOn" ]->SetYTitle( "# of objects" );
106  // mean pt for all trigger objects
107  histos1D_[ "ptMean" ] = fileService->make< TH1D >( "ptMean", "Mean p_{T} (GeV) per trigger object type", maxID_ - minID_ + 1, minID_ - 0.5, maxID_ + 0.5);
108  histos1D_[ "ptMean" ]->SetXTitle( "trigger object type" );
109  histos1D_[ "ptMean" ]->SetYTitle( "mean p_{T} (GeV)" );
110 
111  // initialize counters for mean pt calculation
112  for( unsigned id = minID_; id <= maxID_; ++id ){
113  sumN_ [ id ] = 0;
114  sumPt_[ id ] = 0.;
115  }
116 }
const double Pi
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
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
unsigned maxID_
maximal id for meanPt plot
void PatTriggerAnalyzer::endJob ( void  )
overrideprivatevirtual

everythin that needs to be done after the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 186 of file PatTriggerAnalyzer.cc.

References DEFINE_FWK_MODULE, histos1D_, triggerObjects_cff::id, maxID_, minID_, sumN_, and sumPt_.

187 {
188  // normalize the entries for the mean pt plot
189  for(unsigned id=minID_; id<=maxID_; ++id){
190  if( sumN_[ id ]!=0 ) histos1D_[ "ptMean" ]->Fill( id, sumPt_[ id ]/sumN_[ id ] );
191  }
192 }
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 46 of file PatTriggerAnalyzer.cc.

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

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

Definition at line 47 of file PatTriggerAnalyzer.cc.

Referenced by analyze(), and beginJob().

unsigned PatTriggerAnalyzer::maxID_
private

maximal id for meanPt plot

Definition at line 43 of file PatTriggerAnalyzer.cc.

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

unsigned PatTriggerAnalyzer::minID_
private

minimal id for meanPt plot

Definition at line 41 of file PatTriggerAnalyzer.cc.

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

std::string PatTriggerAnalyzer::muonMatch_
private

input for trigger match objects

Definition at line 39 of file PatTriggerAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT< pat::MuonCollection > PatTriggerAnalyzer::muonsToken_
private

input for muons

Definition at line 37 of file PatTriggerAnalyzer.cc.

Referenced by analyze().

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

internals for meanPt histogram calculation

Definition at line 50 of file PatTriggerAnalyzer.cc.

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

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

Definition at line 51 of file PatTriggerAnalyzer.cc.

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

edm::InputTag PatTriggerAnalyzer::trigger_
private

input for patTrigger

Definition at line 33 of file PatTriggerAnalyzer.cc.

edm::EDGetTokenT< pat::TriggerEvent > PatTriggerAnalyzer::triggerEventToken_
private

input for patTriggerEvent

Definition at line 35 of file PatTriggerAnalyzer.cc.

Referenced by analyze().