19 if (!iConfig.
empty()) {
24 if (iConfig.
exists(
"description"))
49 bool decision =
false;
96 ss <<
"Filter doing an OR of: ";
98 unsigned int size = 0;
101 size_t orPos = filterORlistCopy.find(
"_OR_");
102 if (orPos == std::string::npos && !filterORlistCopy.empty()) {
103 size = filterORlistCopy.size();
111 filterORlistCopy = filterORlistCopy.substr(0 +
size + 4);
113 std::map<std::string, Filter*>::const_iterator it =
filters.find(
filter);
115 edm::LogError(
"FilterOR") <<
"cannot do an OR of: " <<
filter <<
" OR expression is: " << filterORlist;
118 filters_.push_back(std::make_pair(it->first, it->second));
119 ss << it->first <<
" ";
124 for (
unsigned int i = 0;
i !=
filters_.size(); ++
i)
131 std::vector<std::pair<std::string, Filter*> >
filters_;
154 if (iConfig.
exists(
"nMonitor"))
188 std::map<std::string, bool>
ret;
194 bool decision = (*filter)->accept(
iEvent);
195 bool inverted = (*filter).inverted();
197 decision = !decision;
201 global = global && decision;
203 count.nCumulative_++;
208 summary << std::setw(20) <<
name().substr(0, 19) <<
" : " << std::setw(10) <<
iEvent.id().run() <<
" : "
209 << std::setw(10) <<
iEvent.id().event();
225 summary << std::setw(20) <<
" selection name "
226 <<
" : " << std::setw(10) <<
" run "
227 <<
" : " << std::setw(10) <<
" event ";
229 summary <<
" : " << std::setw(10) << (*filter)->name().substr(0, 9);
239 unsigned int maxFnameSize = 20;
241 if ((*filter)->name().size() > maxFnameSize)
242 maxFnameSize = (*filter)->name().size() + 1;
248 summary <<
" Summary table for selection: " <<
name() <<
" with: " <<
nSeen_ <<
" events run." << std::endl;
254 summary <<
"filter: " << std::right << std::setw(10) <<
fName <<
"\n" << (*filter)->descriptionText() <<
"\n";
257 summary <<
" filter stand-alone pass: " << std::endl;
258 summary << std::right << std::setw(maxFnameSize) <<
"total read"
259 <<
": " << std::right << std::setw(10) <<
nSeen_ << std::endl;
263 if ((*filter).inverted())
265 summary << std::right << std::setw(maxFnameSize) <<
fName <<
": " << std::right << std::setw(10) <<
count.nPass_
266 <<
" passed events. " << std::right << std::setw(10) << std::setprecision(5)
269 summary <<
" filter cumulative pass:" << std::endl;
270 summary << std::right << std::setw(maxFnameSize) <<
"total read"
271 <<
": " << std::right << std::setw(10) <<
nSeen_ << std::endl;
272 unsigned int lastCount =
nSeen_;
276 if ((*filter).inverted())
278 summary << std::right << std::setw(maxFnameSize) <<
fName <<
": " << std::right << std::setw(10)
279 <<
count.nCumulative_ <<
" passed events. " << std::right << std::setw(10) << std::setprecision(5)
282 summary <<
" (to previous count) " << std::right << std::setw(10) << std::setprecision(5)
283 << (
count.nCumulative_ / (
float)lastCount) * 100. <<
" [%]";
286 lastCount =
count.nCumulative_;
288 summary <<
"-------------------------------------\n";
327 typedef std::vector<FilterSelection>::iterator
iterator;
335 std::vector<std::string> filterNames;
337 for (
unsigned int iF = 0; iF != nF; iF++) {
339 filters_.insert(std::make_pair(filterNames[iF],
344 std::vector<std::string> selectionNames;
345 std::map<std::string, std::vector<std::string> > selectionFilters;
347 for (
unsigned int iS = 0; iS != nS; iS++) {
353 selectionFilters[selectionNames[iS]] =
pset.getParameter<std::vector<std::string> >(
"filterOrder");
361 sIt != selectionFilters.end();
364 for (std::vector<std::string>::iterator fOrS = sIt->second.begin(); fOrS != sIt->second.end(); ++fOrS) {
367 if (fOrS->find(
"_OR_") != std::string::npos) {
372 std::map<std::string, std::vector<std::string> >
::iterator s = selectionFilters.find(*fOrS);
373 if (
s == selectionFilters.end()) {
375 if ((*fOrS)[0] !=
'!') {
376 edm::LogError(
"SelectionHelper") <<
"unresolved filter/selection name: " << *fOrS;
382 std::vector<std::string>::iterator newLoc = sIt->second.erase(fOrS);
384 sIt->second.insert(newLoc,
s->second.begin(),
s->second.end());
405 std::vector<std::string>& listOfFilters = selectionFilters[sName];
406 for (std::vector<std::string>::iterator fIt = listOfFilters.begin(); fIt != listOfFilters.end(); ++fIt) {
408 bool inverted =
false;
409 if (fOsName[0] ==
'!') {
411 fOsName = fOsName.substr(1);
413 std::map<std::string, Filter*>::iterator filterInstance =
filters_.find(fOsName);
414 if (filterInstance ==
filters_.end()) {
416 bool replaceBySelection =
false;
419 if (fOsName == sit->name_) {
421 replaceBySelection =
true;
424 if (!replaceBySelection) {
426 edm::LogError(
"Selections") <<
"cannot resolve: " << fOsName;
436 sIt->printDetailledPrintoutHeader();