19 if (!iConfig.
empty()){
24 if (iConfig.
exists(
"description"))
88 const std::map<std::string, Filter*> &
filters){
92 ss<<
"Filter doing an OR of: ";
97 size_t orPos = filterORlistCopy.find(
"_OR_");
98 if (orPos == std::string::npos && filterORlistCopy.size()!=0){
99 size=filterORlistCopy.size();
108 filterORlistCopy = filterORlistCopy.substr(0+size+4);
110 std::map<std::string, Filter*>::const_iterator it=filters.find(filter);
111 if (it==filters.end()){
113 <<
" OR expression is: "<<filterORlist;
116 filters_.push_back(std::make_pair(it->first, it->second));
122 for (
unsigned int i=0 ;
i!=filters_.size();++
i)
123 if (filters_[
i].
second->accept(iEvent))
128 std::vector <std::pair<std::string , Filter * > >
filters_;
142 ntuplize_(iConfig.getParameter<bool>(
"ntuplize")),
143 makeContentPlots_(iConfig.getParameter<bool>(
"makeContentPlots")),
144 makeFinalPlots_(iConfig.getParameter<bool>(
"makeFinalPlots")),
145 makeCumulativePlots_(iConfig.getParameter<bool>(
"makeCumulativePlots")),
146 makeAllButOnePlots_(iConfig.getParameter<bool>(
"makeAllButOnePlots")),
148 makeSummaryTable_(iConfig.getParameter<bool>(
"makeSummaryTable")),
149 makeDetailledPrintout_(iConfig.exists(
"detailledPrintoutCategory"))
153 if (iConfig.
exists(
"nMonitor"))
154 nMonitor_=iConfig.
getParameter<
unsigned int>(
"nMonitor");
158 if (makeDetailledPrintout_)
168 this->acceptMap(iEvent);
176 if (nMonitor_!=0 && nSeen_%nMonitor_==0){
177 if (nSeen_==nMonitor_)
print();
180 std::map<std::string, bool> ret;
186 bool decision=(*filter)->accept(iEvent);
187 bool inverted=(*filter).inverted();
188 if (inverted) decision=!decision;
190 if (decision) count.
nPass_++;
191 global=global && decision;
195 if (makeDetailledPrintout_){
197 summary<<std::setw(20)<<
name().substr(0,19)<<
" : " 198 <<std::setw(10)<<iEvent.
id().
run()<<
" : " 199 <<std::setw(10)<<iEvent.
id().
event();
202 summary<<
" : "<<std::setw(10)<<(ret[fName]?
"pass":
"reject");
213 if (makeDetailledPrintout_){
215 summary<<std::setw(20)<<
" selection name "<<
" : " 216 <<std::setw(10)<<
" run "<<
" : " 217 <<std::setw(10)<<
" event ";
219 summary<<
" : "<<std::setw(10)<<(*filter)->name().substr(0,9);
226 if (!makeSummaryTable_)
return;
228 unsigned int maxFnameSize = 20;
230 if ((*filter)->name().size() > maxFnameSize) maxFnameSize = (*filter)->name().size()+1;
236 summary<<
" Summary table for selection: "<<
name()<<
" with: "<<nSeen_<<
" events run."<<std::endl;
237 if (nSeen_==0)
return;
241 summary<<
"filter: "<<std::right<<std::setw(10)<<fName<<
"\n" 242 <<(*filter)->descriptionText()<<
"\n";
245 summary<<
" filter stand-alone pass: "<<std::endl;
246 summary<<std::right<<std::setw(maxFnameSize)<<
"total read"<<
": " 247 <<std::right<<std::setw(10)<<nSeen_<<std::endl;
251 if ((*filter).inverted()) fName=
'!'+fName;
252 summary<<std::right<<std::setw(maxFnameSize)<<fName<<
": " 253 <<std::right<<std::setw(10)<<count.
nPass_<<
" passed events. " 254 <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.
nPass_/(
float)count.
nSeen_)*100.<<
" [%]"<<std::endl;
256 summary<<
" filter cumulative pass:"<<std::endl;
257 summary<<std::right<<std::setw(maxFnameSize)<<
"total read"<<
": " 258 <<std::right<<std::setw(10)<<nSeen_<<std::endl;
259 unsigned int lastCount=nSeen_;
263 if ((*filter).inverted()) fName=
'!'+fName;
264 summary<<std::right<<std::setw(maxFnameSize)<<fName<<
": " 265 <<std::right<<std::setw(10)<<count.
nCumulative_<<
" passed events. " 268 summary<<
" (to previous count) "<<std::right<<std::setw(10)<<std::setprecision (5)<<(count.
nCumulative_/(
float)lastCount)*100.<<
" [%]";
273 summary<<
"-------------------------------------\n";
322 std::vector<std::string> filterNames;
323 unsigned int nF=filtersPSet_.getParameterSetNames(filterNames);
324 for (
unsigned int iF=0;iF!=nF;iF++){
326 filters_.
insert(std::make_pair(filterNames[iF],
new Filter(filterNames[iF],pset, iC)));
330 std::vector<std::string> selectionNames;
331 std::map<std::string, std::vector<std::string> > selectionFilters;
332 unsigned int nS=selectionPSet_.getParameterSetNames(selectionNames);
333 for (
unsigned int iS=0;iS!=nS;iS++){
336 selections_.push_back(
Selection(selectionNames[iS],pset));
339 selectionFilters[selectionNames[iS]]=pset.
getParameter<std::vector<std::string> >(
"filterOrder");
347 for (
std::map<
std::string, std::vector<std::string> >::iterator sIt= selectionFilters.begin();sIt!=selectionFilters.end();++sIt)
350 for (std::vector<std::string>::iterator fOrS=sIt->second.begin();fOrS!=sIt->second.end();++fOrS)
352 if (filters_.find(*fOrS)==filters_.end())
355 if (fOrS->find(
"_OR_") != std::string::npos){
356 filters_.insert(std::make_pair((*fOrS),
new FilterOR((*fOrS),filters_)));
360 std::map<std::string, std::vector<std::string> >
::iterator s=selectionFilters.find(*fOrS);
361 if (s==selectionFilters.end()){
363 if ((*fOrS)[0] !=
'!'){
364 edm::LogError(
"SelectionHelper")<<
"unresolved filter/selection name: "<<*fOrS;
370 std::vector<std::string>::iterator newLoc=sIt->second.erase(fOrS);
372 sIt->second.insert(newLoc,s->second.begin(),s->second.end());
388 for (std::vector<Selection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt){
393 std::vector<std::string> & listOfFilters=selectionFilters[sName];
394 for (std::vector<std::string>::iterator fIt=listOfFilters.begin();fIt!=listOfFilters.end();++fIt)
398 if (fOsName[0]==
'!'){
400 fOsName = fOsName.substr(1);
402 std::map<std::string, Filter*>::iterator filterInstance=filters_.find(fOsName);
403 if (filterInstance==filters_.end()){
405 bool replaceBySelection=
false;
407 for ( std::vector<Selection>::iterator sit=selections_.begin(); sit!= selections_.end() ; ++sit){
408 if (fOsName == sit->name_){
410 replaceBySelection=
true;
413 if (!replaceBySelection){
420 selection.
filters_.push_back(
SFilter(filterInstance->second,inverted));
425 for (iterator sIt =
begin(); sIt!=
end();++sIt)
426 sIt->printDetailledPrintoutHeader();
430 iterator
begin() {
return selections_.begin(); }
431 iterator
end() {
return selections_.end();}
434 void print(){
for (std::vector<Selection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt) sIt->print();}
T getParameter(std::string const &) const
EventNumber_t event() const
unsigned long CacheIdentifier_t
std::vector< std::string > description_
std::map< std::string, bool > acceptMap(edm::Event &iEvent)
virtual bool accept(edm::Event &iEvent)
std::vector< Selection > selections_
std::string dump(unsigned int indent=0) const
edm::Event::CacheIdentifier_t eventCacheID_
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void printDetailledPrintoutHeader()
void insert(bool ok_to_replace, char const *, Entry const &)
std::map< std::string, Filter * > filters_
const std::string & dump()
std::vector< TPRegexp > filters
Selections(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
U second(std::pair< T, U > const &p)
bool makeCumulativePlots_
virtual bool accept(edm::Event &iEvent)
edm::ParameterSet filtersPSet_
bool makeCumulativePlots()
virtual bool select(const edm::Event &) const =0
decision of the selector module
bool makeDetailledPrintout_
CacheIdentifier_t cacheIdentifier() const
FilterOR(const std::string &filterORlist, const std::map< std::string, Filter * > &filters)
const std::vector< std::string > description()
const std::string & name()
Filter(std::string name, edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
const std::string & name()
const std::string descriptionText()
unsigned int nCumulative_
EventSelector * selector_
std::pair< int, edm::FunctionWithDict > OK
bool accept(edm::Event &iEvent)
std::map< std::string, Count > counts_
bool makeAllButOnePlots()
void addUntrackedParameter(std::string const &name, T const &value)
std::vector< Selection >::iterator iterator
SFilter(Filter *f, bool i)
edm::ParameterSet selectionPSet_
void print(bool description=true)
std::vector< std::pair< std::string, Filter * > > filters_
std::vector< SFilter > filters_
std::vector< SFilter >::iterator iterator
T get(const Candidate &c)
Selection(std::string name, const edm::ParameterSet &iConfig)
std::string detailledPrintoutCategory_