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));
128 std::vector <std::pair<std::string , Filter * > >
filters_;
142 ntuplize_(iConfig.getParameter<bool>(
"ntuplize")),
153 if (iConfig.
exists(
"nMonitor"))
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;
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");
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);
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;
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. "
266 <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.
nCumulative_/(float)count.
nSeen_)*100.<<
" [%]";
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;
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;
333 for (
unsigned int iS=0;iS!=nS;iS++){
339 selectionFilters[selectionNames[iS]]=pset.
getParameter<std::vector<std::string> >(
"filterOrder");
350 for (std::vector<std::string>::iterator fOrS=sIt->second.begin();fOrS!=sIt->second.end();++fOrS)
355 if (fOrS->find(
"_OR_") != std::string::npos){
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());
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;
408 if (fOsName == sit->name_){
410 replaceBySelection=
true;
413 if (!replaceBySelection){
420 selection.
filters_.push_back(
SFilter(filterInstance->second,inverted));
426 sIt->printDetailledPrintoutHeader();
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)
virtual bool select(const edm::Event &) const =0
decision of the selector module
pair< int, edm::FunctionWithDict > OK
std::vector< Selection > selections_
std::string dump(unsigned int indent=0) const
edm::Event::CacheIdentifier_t eventCacheID_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void printDetailledPrintoutHeader()
const_iterator begin() 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()
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_
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)
volatile std::atomic< bool > shutdown_flag false
std::vector< std::pair< std::string, Filter * > > filters_
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
std::vector< SFilter > filters_
const_iterator end() const
std::vector< SFilter >::iterator iterator
tuple size
Write out results.
T get(const Candidate &c)
Selection(std::string name, const edm::ParameterSet &iConfig)
std::string detailledPrintoutCategory_