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
Inheritance diagram for PatTriggerAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

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 ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

double binWidth_
 
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...
 
unsigned nBins_
 binning for turn-on curve 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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 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 67 of file PatTriggerAnalyzer.cc.

67  :
68  // pat::Trigger
69  trigger_( iConfig.getParameter< edm::InputTag >( "trigger" ) ),
70  // pat::TriggerEvent
71  triggerEvent_( iConfig.getParameter< edm::InputTag >( "triggerEvent" ) ),
72  // muon input collection
73  muons_( iConfig.getParameter< edm::InputTag >( "muons" ) ),
74  // muon match objects
75  muonMatch_( iConfig.getParameter< std::string >( "muonMatch" ) ),
76  // binning for turn-on curve
77  nBins_( iConfig.getParameter< unsigned >( "nBins" ) ),
78  binWidth_( iConfig.getParameter< double >( "binWidth" ) ),
79  // minimal id for of all trigger objects
80  minID_( iConfig.getParameter< unsigned >( "minID" ) ),
81  // maximal id for of all trigger objects
82  maxID_( iConfig.getParameter< unsigned >( "maxID" ) ),
83  histos1D_(), histos2D_()
84 {
85 }
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
unsigned nBins_
binning for turn-on curve
PatTriggerAnalyzer::~PatTriggerAnalyzer ( )

default destructor

Definition at line 87 of file PatTriggerAnalyzer.cc.

88 {
89 }

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 127 of file PatTriggerAnalyzer.cc.

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

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

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

92 {
94 
95  // pt correlation plot
96  histos2D_[ "ptTrigCand" ] = fileService->make< TH2D >( "ptTrigCand", "Object vs. candidate p_{T} (GeV)", 60, 0., 300., 60, 0., 300. );
97  histos2D_[ "ptTrigCand" ]->SetXTitle( "candidate p_{T} (GeV)" );
98  histos2D_[ "ptTrigCand" ]->SetYTitle( "object p_{T} (GeV)" );
99  // eta correlation plot
100  histos2D_[ "etaTrigCand" ] = fileService->make< TH2D >( "etaTrigCand", "Object vs. candidate #eta", 50, -2.5, 2.5, 50, -2.5, 2.5 );
101  histos2D_[ "etaTrigCand" ]->SetXTitle( "candidate #eta" );
102  histos2D_[ "etaTrigCand" ]->SetYTitle( "object #eta" );
103  // phi correlation plot
104  histos2D_[ "phiTrigCand" ] = fileService->make< TH2D >( "phiTrigCand", "Object vs. candidate #phi", 60, -TMath::Pi(), TMath::Pi(), 60, -TMath::Pi(), TMath::Pi() );
105  histos2D_[ "phiTrigCand" ]->SetXTitle( "candidate #phi" );
106  histos2D_[ "phiTrigCand" ]->SetYTitle( "object #phi" );
107  // candidate counter for turn-on curve
108  histos1D_[ "countCand" ] = fileService->make< TH1D >( "countCand", "p_{T} (GeV) of candidate", nBins_, 20., 20. + nBins_ * binWidth_ );
109  histos1D_[ "countCand" ]->SetXTitle( "candidate p_{T} (GeV)" );
110  histos1D_[ "countCand" ]->SetYTitle( "# of candidates" );
111  // turn-on curve
112  histos1D_[ "turnOn" ] = fileService->make< TH1D >( "turnOn", "p_{T} (GeV) of candidate", nBins_, 20., 20. + nBins_ * binWidth_ );
113  histos1D_[ "turnOn" ]->SetXTitle( "candidate p_{T} (GeV)" );
114  histos1D_[ "turnOn" ]->SetYTitle( "efficiency" );
115  // mean pt for all trigger objects
116  histos1D_[ "ptMean" ] = fileService->make< TH1D >( "ptMean", "Mean p_{T} (GeV) per trigger object type", maxID_ - minID_ + 1, minID_ - 0.5, maxID_ + 0.5);
117  histos1D_[ "ptMean" ]->SetXTitle( "trigger object type" );
118  histos1D_[ "ptMean" ]->SetYTitle( "mean p_{T} (GeV)" );
119 
120  // initialize counters for mean pt calculation
121  for( unsigned id = minID_; id <= maxID_; ++id ) {
122  sumN_ [ id ] = 0;
123  sumPt_[ id ] = 0.;
124  }
125 }
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
unsigned nBins_
binning for turn-on curve
void PatTriggerAnalyzer::endJob ( void  )
privatevirtual

everythin that needs to be done after the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 201 of file PatTriggerAnalyzer.cc.

References histos1D_, maxID_, minID_, sumN_, and sumPt_.

202 {
203  /*
204  turn-on curve
205  */
206 
207  // normalise bins for turn-on based with counter
208  histos1D_[ "turnOn" ]->Divide( histos1D_[ "countCand" ] );
209 
210  /*
211  mean pt
212  */
213 
214  // normalize the entries for the mean pt plot
215  for(unsigned id=minID_; id<=maxID_; ++id){
216  if( sumN_[ id ] != 0 ) histos1D_[ "ptMean" ]->Fill( id, sumPt_[ id ] / sumN_[ id ] );
217  }
218 }
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

double PatTriggerAnalyzer::binWidth_
private

Definition at line 42 of file PatTriggerAnalyzer.cc.

Referenced by beginJob().

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

histogram management

Definition at line 49 of file PatTriggerAnalyzer.cc.

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

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

Definition at line 50 of file PatTriggerAnalyzer.cc.

Referenced by analyze(), and beginJob().

unsigned PatTriggerAnalyzer::maxID_
private

maximal id for meanPt plot

Definition at line 46 of file PatTriggerAnalyzer.cc.

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

unsigned PatTriggerAnalyzer::minID_
private

minimal id for meanPt plot

Definition at line 44 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::InputTag PatTriggerAnalyzer::muons_
private

input for muons

Definition at line 37 of file PatTriggerAnalyzer.cc.

Referenced by analyze().

unsigned PatTriggerAnalyzer::nBins_
private

binning for turn-on curve

Definition at line 41 of file PatTriggerAnalyzer.cc.

Referenced by beginJob().

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

internals for meanPt histogram calculation

Definition at line 53 of file PatTriggerAnalyzer.cc.

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

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

Definition at line 54 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::InputTag PatTriggerAnalyzer::triggerEvent_
private

input for patTriggerEvent

Definition at line 35 of file PatTriggerAnalyzer.cc.

Referenced by analyze().