20 if (!iConfig.
empty()){
25 if (iConfig.
exists(
"description"))
89 const std::map<std::string, Filter*> &
filters){
93 ss<<
"Filter doing an OR of: ";
98 size_t orPos = filterORlistCopy.find(
"_OR_");
99 if (orPos == std::string::npos && !filterORlistCopy.empty()){
100 size=filterORlistCopy.size();
109 filterORlistCopy = filterORlistCopy.substr(0+size+4);
111 std::map<std::string, Filter*>::const_iterator it=filters.find(filter);
112 if (it==filters.end()){
114 <<
" OR expression is: "<<filterORlist;
117 filters_.push_back(std::make_pair(it->first, it->second));
123 for (
unsigned int i=0 ;
i!=filters_.size();++
i)
124 if (filters_[
i].
second->accept(iEvent))
129 std::vector <std::pair<std::string , Filter * > >
filters_;
143 ntuplize_(iConfig.getParameter<
bool>(
"ntuplize")),
144 makeContentPlots_(iConfig.getParameter<
bool>(
"makeContentPlots")),
145 makeFinalPlots_(iConfig.getParameter<
bool>(
"makeFinalPlots")),
146 makeCumulativePlots_(iConfig.getParameter<
bool>(
"makeCumulativePlots")),
147 makeAllButOnePlots_(iConfig.getParameter<
bool>(
"makeAllButOnePlots")),
149 makeSummaryTable_(iConfig.getParameter<
bool>(
"makeSummaryTable")),
150 makeDetailledPrintout_(iConfig.exists(
"detailledPrintoutCategory"))
154 if (iConfig.
exists(
"nMonitor"))
155 nMonitor_=iConfig.
getParameter<
unsigned int>(
"nMonitor");
159 if (makeDetailledPrintout_)
169 this->acceptMap(iEvent);
177 if (nMonitor_!=0 && nSeen_%nMonitor_==0){
178 if (nSeen_==nMonitor_)
print();
181 std::map<std::string, bool> ret;
187 bool decision=(*filter)->accept(iEvent);
188 bool inverted=(*filter).inverted();
189 if (inverted) decision=!decision;
191 if (decision) count.
nPass_++;
192 global=global && decision;
196 if (makeDetailledPrintout_){
198 summary<<std::setw(20)<<
name().substr(0,19)<<
" : " 199 <<std::setw(10)<<iEvent.
id().
run()<<
" : " 200 <<std::setw(10)<<iEvent.
id().
event();
203 summary<<
" : "<<std::setw(10)<<(ret[fName]?
"pass":
"reject");
214 if (makeDetailledPrintout_){
216 summary<<std::setw(20)<<
" selection name "<<
" : " 217 <<std::setw(10)<<
" run "<<
" : " 218 <<std::setw(10)<<
" event ";
220 summary<<
" : "<<std::setw(10)<<(*filter)->name().substr(0,9);
227 if (!makeSummaryTable_)
return;
229 unsigned int maxFnameSize = 20;
231 if ((*filter)->name().size() > maxFnameSize) maxFnameSize = (*filter)->name().size()+1;
237 summary<<
" Summary table for selection: "<<
name()<<
" with: "<<nSeen_<<
" events run."<<std::endl;
238 if (nSeen_==0)
return;
242 summary<<
"filter: "<<std::right<<std::setw(10)<<fName<<
"\n" 243 <<(*filter)->descriptionText()<<
"\n";
246 summary<<
" filter stand-alone pass: "<<std::endl;
247 summary<<std::right<<std::setw(maxFnameSize)<<
"total read"<<
": " 248 <<std::right<<std::setw(10)<<nSeen_<<std::endl;
252 if ((*filter).inverted()) fName=
'!'+fName;
253 summary<<std::right<<std::setw(maxFnameSize)<<fName<<
": " 254 <<std::right<<std::setw(10)<<count.
nPass_<<
" passed events. " 255 <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.
nPass_/(
float)count.
nSeen_)*100.<<
" [%]"<<std::endl;
257 summary<<
" filter cumulative pass:"<<std::endl;
258 summary<<std::right<<std::setw(maxFnameSize)<<
"total read"<<
": " 259 <<std::right<<std::setw(10)<<nSeen_<<std::endl;
260 unsigned int lastCount=nSeen_;
264 if ((*filter).inverted()) fName=
'!'+fName;
265 summary<<std::right<<std::setw(maxFnameSize)<<fName<<
": " 266 <<std::right<<std::setw(10)<<count.
nCumulative_<<
" passed events. " 269 summary<<
" (to previous count) "<<std::right<<std::setw(10)<<std::setprecision (5)<<(count.
nCumulative_/(
float)lastCount)*100.<<
" [%]";
274 summary<<
"-------------------------------------\n";
314 typedef std::vector<FilterSelection>::iterator
iterator;
323 std::vector<std::string> filterNames;
324 unsigned int nF=filtersPSet_.getParameterSetNames(filterNames);
325 for (
unsigned int iF=0;iF!=nF;iF++){
327 filters_.
insert(std::make_pair(filterNames[iF],
new Filter(filterNames[iF],pset, iC)));
331 std::vector<std::string> selectionNames;
332 std::map<std::string, std::vector<std::string> > selectionFilters;
333 unsigned int nS=selectionPSet_.getParameterSetNames(selectionNames);
334 for (
unsigned int iS=0;iS!=nS;iS++){
340 selectionFilters[selectionNames[iS]]=pset.
getParameter<std::vector<std::string> >(
"filterOrder");
348 for (
std::map<
std::string, std::vector<std::string> >::iterator sIt= selectionFilters.begin();sIt!=selectionFilters.end();++sIt)
351 for (std::vector<std::string>::iterator fOrS=sIt->second.begin();fOrS!=sIt->second.end();++fOrS)
353 if (filters_.find(*fOrS)==filters_.end())
356 if (fOrS->find(
"_OR_") != std::string::npos){
357 filters_.insert(std::make_pair((*fOrS),
new FilterOR((*fOrS),filters_)));
361 std::map<std::string, std::vector<std::string> >
::iterator s=selectionFilters.find(*fOrS);
362 if (s==selectionFilters.end()){
364 if ((*fOrS)[0] !=
'!'){
365 edm::LogError(
"SelectionHelper")<<
"unresolved filter/selection name: "<<*fOrS;
371 std::vector<std::string>::iterator newLoc=sIt->second.erase(fOrS);
373 sIt->second.insert(newLoc,s->second.begin(),s->second.end());
389 for (std::vector<FilterSelection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt){
394 std::vector<std::string> & listOfFilters=selectionFilters[sName];
395 for (std::vector<std::string>::iterator fIt=listOfFilters.begin();fIt!=listOfFilters.end();++fIt)
399 if (fOsName[0]==
'!'){
401 fOsName = fOsName.substr(1);
403 std::map<std::string, Filter*>::iterator filterInstance=filters_.find(fOsName);
404 if (filterInstance==filters_.end()){
406 bool replaceBySelection=
false;
408 for ( std::vector<FilterSelection>::iterator sit=selections_.begin(); sit!= selections_.end() ; ++sit){
409 if (fOsName == sit->name_){
411 replaceBySelection=
true;
414 if (!replaceBySelection){
421 selection.
filters_.push_back(
SFilter(filterInstance->second,inverted));
426 for (iterator sIt =
begin(); sIt!=
end();++sIt)
427 sIt->printDetailledPrintoutHeader();
431 iterator
begin() {
return selections_.begin(); }
432 iterator
end() {
return selections_.end();}
435 void print(){
for (std::vector<FilterSelection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt) sIt->print();}
edm::ParameterSet selectionPSet_
T getParameter(std::string const &) const
EventNumber_t event() const
unsigned long CacheIdentifier_t
std::vector< std::string > description_
std::vector< FilterSelection >::iterator iterator
void printDetailledPrintoutHeader()
bool makeCumulativePlots_
virtual bool accept(edm::Event &iEvent)
std::vector< FilterSelection > selections_
std::string dump(unsigned int indent=0) const
edm::Event::CacheIdentifier_t eventCacheID_
bool accept(edm::Event &iEvent) override
FilterSelections(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
std::vector< SFilter > filters_
std::map< std::string, bool > acceptMap(edm::Event &iEvent)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::ParameterSet filtersPSet_
void insert(bool ok_to_replace, char const *, Entry const &)
S & print(S &os, JobReport::InputFile const &f)
const std::string & dump()
std::vector< SFilter >::iterator iterator
std::vector< TPRegexp > filters
const std::string & name()
std::string detailledPrintoutCategory_
U second(std::pair< T, U > const &p)
bool accept(edm::Event &iEvent) override
unsigned int nCumulative_
bool makeCumulativePlots()
virtual bool select(const edm::Event &) const =0
decision of the selector module
CacheIdentifier_t cacheIdentifier() const
FilterOR(const std::string &filterORlist, const std::map< std::string, Filter * > &filters)
const std::vector< std::string > description()
Filter(std::string name, edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
const std::string & name()
const std::string descriptionText()
EventSelector * selector_
std::pair< int, edm::FunctionWithDict > OK
void addUntrackedParameter(std::string const &name, T const &value)
SFilter(Filter *f, bool i)
FilterSelection(std::string name, const edm::ParameterSet &iConfig)
std::map< std::string, Count > counts_
std::vector< std::pair< std::string, Filter * > > filters_
bool makeAllButOnePlots()
void print(bool description=true)
bool makeDetailledPrintout_
T get(const Candidate &c)
std::map< std::string, Filter * > filters_