CMS 3D CMS Logo

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

Public Member Functions

 PatTriggerAnalyzer (const edm::ParameterSet &iConfig)
 default constructor More...
 
 ~PatTriggerAnalyzer () override
 default destructor More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 15 of file PatTriggerAnalyzer.cc.

Constructor & Destructor Documentation

◆ PatTriggerAnalyzer()

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

default constructor

Definition at line 60 of file PatTriggerAnalyzer.cc.

References TFileService::kSharedResource.

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

default destructor

Definition at line 78 of file PatTriggerAnalyzer.cc.

78 {}

Member Function Documentation

◆ analyze()

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

everythin that needs to be done during the event loop

Implements edm::one::EDAnalyzerBase.

Definition at line 115 of file PatTriggerAnalyzer.cc.

References histos1D_, histos2D_, l1ctLayer2EG_cff::id, iEvent, maxID_, minID_, muonMatch_, DiMuonV_cfg::muons, muonsToken_, sumN_, sumPt_, PDWG_DiPhoton_SD_cff::triggerEvent, triggerEventToken_, and trigger::TriggerMuon.

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

◆ beginJob()

void PatTriggerAnalyzer::beginJob ( void  )
overrideprivatevirtual

everythin that needs to be done before the event loop

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 80 of file PatTriggerAnalyzer.cc.

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

80  {
81  edm::Service<TFileService> fileService;
82 
83  // pt correlation plot
84  histos2D_["ptTrigCand"] =
85  fileService->make<TH2D>("ptTrigCand", "Object vs. candidate p_{T} (GeV)", 60, 0., 300., 60, 0., 300.);
86  histos2D_["ptTrigCand"]->SetXTitle("candidate p_{T} (GeV)");
87  histos2D_["ptTrigCand"]->SetYTitle("object p_{T} (GeV)");
88  // eta correlation plot
89  histos2D_["etaTrigCand"] =
90  fileService->make<TH2D>("etaTrigCand", "Object vs. candidate #eta", 50, -2.5, 2.5, 50, -2.5, 2.5);
91  histos2D_["etaTrigCand"]->SetXTitle("candidate #eta");
92  histos2D_["etaTrigCand"]->SetYTitle("object #eta");
93  // phi correlation plot
94  histos2D_["phiTrigCand"] = fileService->make<TH2D>(
95  "phiTrigCand", "Object vs. candidate #phi", 60, -TMath::Pi(), TMath::Pi(), 60, -TMath::Pi(), TMath::Pi());
96  histos2D_["phiTrigCand"]->SetXTitle("candidate #phi");
97  histos2D_["phiTrigCand"]->SetYTitle("object #phi");
98  // turn-on curves
99  histos1D_["turnOn"] = fileService->make<TH1D>("turnOn", "p_{T} (GeV) of matched candidate", 10, 0., 50.);
100  histos1D_["turnOn"]->SetXTitle("candidate p_{T} (GeV)");
101  histos1D_["turnOn"]->SetYTitle("# of objects");
102  // mean pt for all trigger objects
103  histos1D_["ptMean"] = fileService->make<TH1D>(
104  "ptMean", "Mean p_{T} (GeV) per trigger object type", maxID_ - minID_ + 1, minID_ - 0.5, maxID_ + 0.5);
105  histos1D_["ptMean"]->SetXTitle("trigger object type");
106  histos1D_["ptMean"]->SetYTitle("mean p_{T} (GeV)");
107 
108  // initialize counters for mean pt calculation
109  for (unsigned id = minID_; id <= maxID_; ++id) {
110  sumN_[id] = 0;
111  sumPt_[id] = 0.;
112  }
113 }
std::map< unsigned, unsigned > sumN_
internals for meanPt histogram calculation
const double Pi
std::map< std::string, TH2D * > histos2D_
std::map< unsigned, double > sumPt_
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
unsigned maxID_
maximal id for meanPt plot

◆ endJob()

void PatTriggerAnalyzer::endJob ( void  )
overrideprivatevirtual

everythin that needs to be done after the event loop

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 184 of file PatTriggerAnalyzer.cc.

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

184  {
185  // normalize the entries for the mean pt plot
186  for (unsigned id = minID_; id <= maxID_; ++id) {
187  if (sumN_[id] != 0)
188  histos1D_["ptMean"]->Fill(id, sumPt_[id] / sumN_[id]);
189  }
190 }
std::map< unsigned, unsigned > sumN_
internals for meanPt histogram calculation
std::map< unsigned, double > sumPt_
std::map< std::string, TH1D * > histos1D_
histogram management
unsigned minID_
minimal id for meanPt plot
unsigned maxID_
maximal id for meanPt plot

Member Data Documentation

◆ histos1D_

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

histogram management

Definition at line 44 of file PatTriggerAnalyzer.cc.

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

◆ histos2D_

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

Definition at line 45 of file PatTriggerAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ maxID_

unsigned PatTriggerAnalyzer::maxID_
private

maximal id for meanPt plot

Definition at line 41 of file PatTriggerAnalyzer.cc.

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

◆ minID_

unsigned PatTriggerAnalyzer::minID_
private

minimal id for meanPt plot

Definition at line 39 of file PatTriggerAnalyzer.cc.

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

◆ muonMatch_

std::string PatTriggerAnalyzer::muonMatch_
private

input for trigger match objects

Definition at line 37 of file PatTriggerAnalyzer.cc.

Referenced by analyze().

◆ muonsToken_

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

input for muons

Definition at line 35 of file PatTriggerAnalyzer.cc.

Referenced by analyze().

◆ sumN_

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

internals for meanPt histogram calculation

Definition at line 48 of file PatTriggerAnalyzer.cc.

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

◆ sumPt_

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

Definition at line 49 of file PatTriggerAnalyzer.cc.

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

◆ trigger_

edm::InputTag PatTriggerAnalyzer::trigger_
private

input for patTrigger

Definition at line 31 of file PatTriggerAnalyzer.cc.

◆ triggerEventToken_

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

input for patTriggerEvent

Definition at line 33 of file PatTriggerAnalyzer.cc.

Referenced by analyze().