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(
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";