1 #ifndef PhysicsTools_TagAndProbe_TriggerMatchProducer_h 2 #define PhysicsTools_TagAndProbe_TriggerMatchProducer_h 29 template <
class object>
57 template <
class object>
59 : hltPrescaleProvider_(iConfig, consumesCollector(), *this) {
60 _inputProducer = iConfig.template getParameter<edm::InputTag>(
"InputProducer");
64 const edm::InputTag dTriggerEventTag(
"hltTriggerSummaryAOD",
"",
"HLT");
68 const edm::InputTag dTriggerResults(
"TriggerResults",
"",
"HLT");
82 produces<edm::PtrVector<object> >();
83 produces<edm::RefToBaseVector<object> >(
"R");
88 template <
class object>
96 template <
class object>
100 using namespace reco;
112 event.getByToken(_inputProducerToken, candHandle);
114 edm::LogError(
"TriggerMatchProducer") <<
"Error! Can't get collection: " << _inputProducer;
120 event.getByToken(triggerEventToken_, trgEvent);
122 event.getByToken(triggerResultsToken_, pTrgResults);
125 std::vector<std::string> activeHLTPathsInThisEvent =
hltConfig.triggerNames();
126 std::map<std::string, bool> triggerInMenu;
127 std::map<std::string, bool> triggerUnprescaled;
135 for (std::vector<std::string>::const_iterator iHLT = activeHLTPathsInThisEvent.begin();
136 iHLT != activeHLTPathsInThisEvent.end();
140 if (TString(*iHLT).Contains(TRegexp(hltTag_))) {
141 triggerInMenu[*iHLT] =
true;
142 if (hltPrescaleProvider_.prescaleValue<
double>(
event,
eventSetup, *iHLT) == 1)
143 triggerUnprescaled[*iHLT] =
true;
149 edm::LogInfo(
"info") <<
"******** Following Trigger Summary Object Not Found: " << triggerEventTag_;
162 std::vector<int>
index;
163 std::vector<std::string>
filters;
166 for (std::map<std::string, bool>::const_iterator iMyHLT = triggerInMenu.begin(); iMyHLT != triggerInMenu.end();
168 if (!(iMyHLT->second && triggerUnprescaled[iMyHLT->first]))
171 int triggerIndex = -1;
175 triggerIndex =
hltConfig.triggerIndex(iMyHLT->first);
177 cout <<
"bad trigger\n";
180 if (triggerIndex == -1 || !(pTrgResults->
wasrun(triggerIndex)) || !(pTrgResults->
accept(triggerIndex)) ||
181 (pTrgResults->
error(triggerIndex))) {
205 for (
size_t i = 0;
i < candHandle->size(); ++
i) {
212 bool hltTrigger =
false;
221 for (
int ipart = 0; ipart != nK; ++ipart) {
224 hltTrigger = dRval < delRMatchingCut_;
231 outColRef->push_back(refs[
counter]);
232 outColPtr->push_back(ptrVect[
counter]);
240 template <
class object>
243 if (!hltPrescaleProvider_.init(iRun, iSetup, triggerEventTag_.process(), changed_)) {
244 edm::LogError(
"TriggerMatchProducer") <<
"Error! Can't initialize HLTConfigProvider";
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
bool error() const
Has any path encountered an error (exception)
HLTPrescaleProvider hltPrescaleProvider_
void push_back(Ptr< T > const &iPtr)
trigger::size_type sizeFilters() const
void produce(edm::Event &, const edm::EventSetup &) override
Log< level::Error, false > LogError
std::vector< TPRegexp > filters
edm::InputTag _inputProducer
bool wasrun() const
Was at least one path run?
T getUntrackedParameter(std::string const &, T const &) const
Single trigger physics object (e.g., an isolated muon)
edm::InputTag triggerResultsTag_
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
const TriggerObjectCollection & getObjects() const
edm::EDGetTokenT< edm::View< object > > _inputProducerToken
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Log< level::Info, false > LogInfo
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
std::vector< size_type > Keys
~TriggerMatchProducer() override
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
static std::atomic< unsigned int > counter
TriggerMatchProducer(const edm::ParameterSet &)
void push_back(const RefToBase< T > &)
edm::InputTag triggerEventTag_