5 #include <boost/algorithm/string.hpp>
20 if (static_cast<int>(trigKeys.size()) >=
filter.second) {
21 evtTrigs |= filterCode;
37 std::vector<int> retVal(filterNames.size(), -2);
44 std::vector<std::string> filterEntryStrings;
45 filterEntryStrings.reserve(filterNames.size());
48 filterEntryStrings.push_back(filterEntry.
toString());
53 if (psetRegistry ==
nullptr) {
54 retVal = std::vector<int>(filterNames.size(), -1);
57 for (
auto& psetIt : *psetRegistry) {
58 const std::map<std::string, edm::Entry>& mapOfPara =
60 const auto itToModLabel = mapOfPara.find(mag0);
61 if (itToModLabel != mapOfPara.end()) {
62 std::string itString = itToModLabel->second.toString();
64 for (
unsigned int i = 0;
i < filterNames.size();
i++) {
69 filterEntryStrings[
i]) {
70 auto itToCandCut = mapOfPara.find(mag1);
71 if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() ==
'I')
72 retVal[i] = itToCandCut->second.getInt32();
74 itToCandCut = mapOfPara.find(mag2);
75 if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() ==
'I')
76 retVal[i] = itToCandCut->second.getInt32();
78 itToCandCut = mapOfPara.find(mag3);
79 if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() ==
'I')
80 retVal[i] = itToCandCut->second.getInt32();
82 itToCandCut = mapOfPara.find(mag4);
83 if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() ==
'I')
84 retVal[i] = itToCandCut->second.getInt32();
94 for (
unsigned int i = 0;
i < filterNames.size();
i++)
130 std::vector<std::string>& activeFilters,
131 std::vector<std::string>& activeEleFilters,
132 std::vector<std::string>& activeEle2LegFilters,
133 std::vector<std::string>& activePhoFilters,
134 std::vector<std::string>& activePho2LegFilters) {
135 activeFilters.clear();
136 activeEleFilters.clear();
137 activeEle2LegFilters.clear();
138 activePhoFilters.clear();
139 activePho2LegFilters.clear();
141 for (
size_t pathNr = 0; pathNr < hltConfig.
size(); pathNr++) {
144 if (pathName.find(
"HLT_") == 0) {
145 if ((pathName.find(
"Photon") == 4 || pathName.find(
"Ele") == 4 || pathName.find(
"EG") != pathName.npos ||
146 pathName.find(
"PAPhoton") == 4 || pathName.find(
"PAEle") == 4 || pathName.find(
"PASinglePhoton") == 4 ||
147 pathName.find(
"HIPhoton") == 4 || pathName.find(
"HIEle") == 4 || pathName.find(
"HISinglePhoton") == 4 ||
148 pathName.find(
"Activity") == 4 || pathName.find(
"Physics") == 4 || pathName.find(
"DiSC") == 4) &&
149 (pathName.find(
"Jet") == pathName.npos && pathName.find(
"Muon") == pathName.npos &&
150 pathName.find(
"Tau") == pathName.npos && pathName.find(
"HT") == pathName.npos &&
151 pathName.find(
"MR") == pathName.npos && pathName.find(
"LEITI") == pathName.npos &&
152 pathName.find(
"Jpsi") == pathName.npos && pathName.find(
"Ups") == pathName.npos)) {
159 if (!filters.empty()) {
169 int minNRFF = minNRFFCache[
filter];
171 if (
filter < filters.size() - 1)
172 minNRFFP1 = minNRFFCache[
filter + 1];
174 (minNRFF == 1 && minNRFFP1 == 2) ||
175 (minNRFF == 1 && minNRFFP1 == 1 && filters[
filter + 1].find(
"Mass") != filters[
filter + 1].npos) ||
176 (minNRFF == 1 && minNRFFP1 == 1 && filters[
filter + 1].
find(
"FEM") != filters[
filter + 1].npos) ||
177 (minNRFF == 1 && minNRFFP1 == 1 && filters[
filter + 1].
find(
"PFMT") != filters[
filter + 1].npos) ||
178 filter == filters.size() - 1) {
179 activeFilters.push_back(filters[
filter]);
182 if (pathName.find(
"Photon") != pathName.npos || pathName.find(
"Activity") != pathName.npos ||
183 pathName.find(
"Physics") != pathName.npos || pathName.find(
"DiSC") == 4) {
184 activePhoFilters.push_back(filters[filter]);
185 int posPho = pathName.find(
"Pho") + 1;
186 if (pathName.find(
"Pho", posPho) != pathName.npos || pathName.find(
"SC", posPho) != pathName.npos) {
188 activePho2LegFilters.push_back(filters[filter]);
192 if (pathName.find(
"Ele") != pathName.npos || pathName.find(
"Activity") != pathName.npos ||
193 pathName.find(
"Physics") != pathName.npos) {
194 activeEleFilters.push_back(filters[filter]);
195 int posEle = pathName.find(
"Ele") + 1;
196 if (pathName.find(
"Ele", posEle) != pathName.npos || pathName.find(
"SC", posEle) != pathName.npos) {
197 if ((minNRFF == 1 && minNRFFP1 == 2) ||
198 (minNRFF == 1 && minNRFFP1 == 1 &&
199 filters[filter + 1].find(
"Mass") != filters[filter + 1].npos) ||
200 (minNRFF == 1 && minNRFFP1 == 1 &&
201 filters[filter + 1].
find(
"SC") != filters[filter + 1].npos) ||
202 (minNRFF == 1 && minNRFFP1 == 1 &&
203 filters[filter + 1].
find(
"FEM") != filters[filter + 1].npos)) {
205 activeEle2LegFilters.push_back(filters[filter] +
"::" + filters[filter + 1]);
223 std::sort(activeFilters.begin(), activeFilters.end());
224 std::sort(activeEleFilters.begin(), activeEleFilters.end());
225 std::sort(activeEle2LegFilters.begin(), activeEle2LegFilters.end());
226 std::sort(activePhoFilters.begin(), activePhoFilters.end());
234 std::vector<std::string>& activeFilters) {
236 std::vector<std::string> filteredNames;
245 filteredNames = activeFilters;
246 namesToFilter.swap(filteredNames);
251 const std::vector<std::string>& activeFilters) {
253 std::vector<std::string> filteredNames;
255 for (
auto& inputFilterNr : namesToFilter) {
256 std::vector<std::string>
names;
258 if (names.size() != 2)
260 if (std::binary_search(activeFilters.begin(), activeFilters.end(), names[0]) &&
261 std::binary_search(activeFilters.begin(), activeFilters.end(), names[1])) {
262 filteredNames.push_back(inputFilterNr);
266 namesToFilter.swap(filteredNames);
273 bool operator()(
const std::pair<std::string, std::string>& lhs,
274 const std::pair<std::string, std::string>& rhs)
const {
275 return keyLess(lhs.first, rhs.first);
277 bool operator()(
const std::pair<std::string, std::string>& lhs,
278 const std::pair<std::string, std::string>::first_type& rhs)
const {
279 return keyLess(lhs.first, rhs);
281 bool operator()(
const std::pair<std::string, std::string>::first_type& lhs,
282 const std::pair<std::string, std::string>& rhs)
const {
283 return keyLess(lhs, rhs.first);
287 bool keyLess(
const std::pair<std::string, std::string>::first_type& k1,
288 const std::pair<std::string, std::string>::first_type&
k2)
const {
294 const std::vector<std::string>&
filters,
295 std::vector<std::string>&
paths) {
297 std::vector<std::pair<std::string, std::string> > filtersAndPaths;
299 for (
size_t pathNr = 0; pathNr < hltConfig.
size(); pathNr++) {
301 if (pathName.find(
"HLT_") == 0) {
304 const std::vector<std::string>& pathFilters = hltConfig.
moduleLabels(pathNr);
305 if (!pathFilters.empty()) {
306 if (pathFilters.back() ==
"hltBoolEnd" && pathFilters.size() >= 2) {
308 filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size() - 2],
pathName));
310 filtersAndPaths.push_back(std::make_pair(pathFilters.back(),
pathName));
317 for (
auto const&
filter : filters) {
318 typedef std::vector<std::pair<std::string, std::string> >::const_iterator VecIt;
319 std::pair<VecIt, VecIt> searchResult =
321 if (searchResult.first != searchResult.second)
322 paths.push_back(searchResult.first->second);
344 size_t etStrPos = trigName.find(
"Et");
345 while (etStrPos != std::string::npos && trigName.find_first_of(
"1234567890", etStrPos) != etStrPos + 2) {
346 etStrPos = trigName.find(
"Et", etStrPos + 1);
348 if (etStrPos != std::string::npos && trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 2) {
349 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 2);
351 std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
363 bool isEle =
false, isPhoton =
false, isEG =
false, isEle2 =
false, isPhoton2 =
false, isEG2 =
false, isSC2 =
false;
364 size_t etStrPos = trigName.npos;
365 if (trigName.find(
"Ele") < trigName.find(
"Photon") && trigName.find(
"Ele") < trigName.find(
"EG")) {
366 etStrPos = trigName.find(
"Ele");
368 }
else if (trigName.find(
"EG") < trigName.find(
"Photon") && trigName.find(
"EG") < trigName.find(
"Ele")) {
369 etStrPos = trigName.find(
"EG");
371 }
else if (trigName.find(
"Photon") < trigName.find(
"Ele") && trigName.find(
"Photon") < trigName.find(
"EG")) {
372 etStrPos = trigName.find(
"Photon");
380 if (etStrPos != trigName.npos &&
381 (trigName.find(
"Ele", etStrPos + 1) != trigName.npos || trigName.find(
"EG", etStrPos + 1) != trigName.npos ||
382 trigName.find(
"Photon", etStrPos + 1) != trigName.npos || trigName.find(
"SC", etStrPos + 1) != trigName.npos)) {
383 if (trigName.find(
"Ele", etStrPos + 1) < trigName.find(
"Photon", etStrPos + 1) &&
384 trigName.find(
"Ele", etStrPos + 1) < trigName.find(
"EG", etStrPos + 1) &&
385 trigName.find(
"Ele", etStrPos + 1) < trigName.find(
"SC", etStrPos + 1)) {
386 etStrPos = trigName.find(
"Ele", etStrPos + 1);
388 }
else if (trigName.find(
"EG", etStrPos + 1) < trigName.find(
"Photon", etStrPos + 1) &&
389 trigName.find(
"EG", etStrPos + 1) < trigName.find(
"Ele", etStrPos + 1) &&
390 trigName.find(
"EG", etStrPos + 1) < trigName.find(
"SC", etStrPos + 1)) {
391 etStrPos = trigName.find(
"EG", etStrPos + 1);
393 }
else if (trigName.find(
"Photon", etStrPos + 1) < trigName.find(
"EG", etStrPos + 1) &&
394 trigName.find(
"Photon", etStrPos + 1) < trigName.find(
"Ele", etStrPos + 1) &&
395 trigName.find(
"Photon", etStrPos + 1) < trigName.find(
"SC", etStrPos + 1)) {
396 etStrPos = trigName.find(
"Photon", etStrPos + 1);
398 }
else if (trigName.find(
"SC", etStrPos + 1) < trigName.find(
"EG", etStrPos + 1) &&
399 trigName.find(
"SC", etStrPos + 1) < trigName.find(
"Ele", etStrPos + 1) &&
400 trigName.find(
"SC", etStrPos + 1) < trigName.find(
"Photon", etStrPos + 1)) {
401 etStrPos = trigName.find(
"Photon", etStrPos + 1);
407 if (etStrPos != trigName.npos &&
408 trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 3) {
409 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 3);
411 std::istringstream etValStr(trigName.substr(etStrPos + 3, endOfEtValStr - etStrPos - 3));
417 if (isEG2 || isSC2) {
418 if (etStrPos != trigName.npos &&
419 trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 2) {
420 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 2);
422 std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
430 if (etStrPos != trigName.npos &&
431 trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 6) {
432 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 6);
434 std::istringstream etValStr(trigName.substr(etStrPos + 6, endOfEtValStr - etStrPos - 6));
440 }
else if (etStrPos != trigName.npos) {
442 if (etStrPos != trigName.npos &&
443 trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 3) {
444 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 3);
446 std::istringstream etValStr(trigName.substr(etStrPos + 3, endOfEtValStr - etStrPos - 3));
453 if (etStrPos != trigName.npos &&
454 trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 2) {
455 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 2);
457 std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
465 if (etStrPos != trigName.npos &&
466 trigName.find_first_of(
"1234567890", etStrPos) == etStrPos + 6) {
467 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890", etStrPos + 6);
469 std::istringstream etValStr(trigName.substr(etStrPos + 6, endOfEtValStr - etStrPos - 6));
unsigned int size() const
number of trigger paths in trigger table
The single EDProduct to be saved for each event (AOD case)
const std::string & triggerName(unsigned int triggerIndex) const
TrigBitSet getCode(const char *descript) const
const Keys & filterKeys(trigger::size_type index) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool operator()(const std::pair< std::string, std::string >::first_type &lhs, const std::pair< std::string, std::string > &rhs) const
std::vector< TPRegexp > filters
const std::string names[nVars_]
const std::vector< std::string > & saveTagsModules(unsigned int trigger) const
bool keyLess(const std::pair< std::string, std::string >::first_type &k1, const std::pair< std::string, std::string >::first_type &k2) const
bool operator()(const std::pair< std::string, std::string > &lhs, const std::pair< std::string, std::string > &rhs) const
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< size_type > Keys
bool operator()(const std::pair< std::string, std::string > &lhs, const std::pair< std::string, std::string >::first_type &rhs) const
std::string toString() const
std::bitset< maxNrBits_ > TrigBitSet
static Registry * instance()