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;
101 using namespace trigger;
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(event, eventSetup, *iHLT) == 1)
143 triggerUnprescaled[*iHLT] =
true;
148 if (not trgEvent.isValid()) {
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))) {
187 int testindex = trgEvent->filterIndex(testTag);
188 if (!(testindex >= trgEvent->sizeFilters())) {
195 index.push_back(trgEvent->filterIndex(filterTag));
205 for (
size_t i = 0;
i < candHandle->size(); ++
i) {
207 refs.push_back(candHandle->refAt(
i));
212 bool hltTrigger =
false;
213 for (
unsigned int idx = 0; idx <
index.size(); ++idx) {
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";
T getUntrackedParameter(std::string const &, T const &) const
HLTPrescaleProvider hltPrescaleProvider_
void produce(edm::Event &, const edm::EventSetup &) override
Log< level::Error, false > LogError
std::vector< TPRegexp > filters
edm::InputTag _inputProducer
Single trigger physics object (e.g., an isolated muon)
edm::InputTag triggerResultsTag_
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
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_
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_