PAT Cleaner module for PAT Objects. More...
#include <PhysicsTools/PatAlgos/interface/PATCleaner.h>
Public Member Functions | |
PATCleaner (const edm::ParameterSet &iConfig) | |
virtual void | produce (edm::Event &iEvent, const edm::EventSetup &iSetup) |
virtual | ~PATCleaner () |
Private Types | |
typedef pat::helper::OverlapTest | OverlapTest |
typedef StringCutObjectSelector < PATObjType > | Selector |
Private Attributes | |
bool | doFinalCut_ |
bool | doPreselection_ |
Selector | finalCut_ |
boost::ptr_vector< OverlapTest > | overlapTests_ |
Selector | preselectionCut_ |
edm::InputTag | src_ |
PAT Cleaner module for PAT Objects.
The same module is used for all collections.
Definition at line 41 of file PATCleaner.h.
typedef pat::helper::OverlapTest pat::PATCleaner< PATObjType >::OverlapTest [private] |
Definition at line 56 of file PATCleaner.h.
typedef StringCutObjectSelector<PATObjType> pat::PATCleaner< PATObjType >::Selector [private] |
Definition at line 49 of file PATCleaner.h.
pat::PATCleaner< PATObjType >::PATCleaner | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 64 of file PATCleaner.h.
References algorithm(), edm::ParameterSet::empty(), Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), pat::PATCleaner< PATObjType >::overlapTests_, and pat::PATCleaner< PATObjType >::src_.
: src_(iConfig.getParameter<edm::InputTag>("src")), preselectionCut_(iConfig.getParameter<std::string>("preselection")), finalCut_(iConfig.getParameter<std::string>("finalCut")) { // pick parameter set for overlaps edm::ParameterSet overlapPSet = iConfig.getParameter<edm::ParameterSet>("checkOverlaps"); // get all the names of the tests (all nested PSets in this PSet) std::vector<std::string> overlapNames = overlapPSet.getParameterNamesForType<edm::ParameterSet>(); // loop on them for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) { // retrieve configuration edm::ParameterSet cfg = overlapPSet.getParameter<edm::ParameterSet>(*itn); // skip empty parameter sets if (cfg.empty()) continue; // get the name of the algorithm to use std::string algorithm = cfg.getParameter<std::string>("algorithm"); // create the appropriate OverlapTest if (algorithm == "byDeltaR") { overlapTests_.push_back(new pat::helper::BasicOverlapTest(*itn, cfg)); } else if (algorithm == "bySuperClusterSeed") { overlapTests_.push_back(new pat::helper::OverlapBySuperClusterSeed(*itn, cfg)); } else { throw cms::Exception("Configuration") << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n"; } } produces<std::vector<PATObjType> >(); }
virtual pat::PATCleaner< PATObjType >::~PATCleaner | ( | ) | [inline, virtual] |
Definition at line 44 of file PATCleaner.h.
{}
void pat::PATCleaner< PATObjType >::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 97 of file PATCleaner.h.
References edm::Event::getByLabel(), VarParsing::obj, convertSQLitetoXML_cfg::output, analyzePatCleaning_cfg::overlaps, and edm::Event::put().
{ // Read the input. We use edm::View<> in case the input happes to be something different than a std::vector<> edm::Handle<edm::View<PATObjType> > candidates; iEvent.getByLabel(src_, candidates); // Prepare a collection for the output std::auto_ptr< std::vector<PATObjType> > output(new std::vector<PATObjType>()); // initialize the overlap tests for (boost::ptr_vector<OverlapTest>::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) { itov->readInput(iEvent,iSetup); } for (typename edm::View<PATObjType>::const_iterator it = candidates->begin(), ed = candidates->end(); it != ed; ++it) { // Apply a preselection to the inputs and copy them in the output if (!preselectionCut_(*it)) continue; // Add it to the list and take a reference to it, so it can be modified (e.g. to set the overlaps) // If at some point I'll decide to drop this item, I'll use pop_back to remove it output->push_back(*it); PATObjType &obj = output->back(); // Look for overlaps bool badForOverlap = false; for (boost::ptr_vector<OverlapTest>::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) { reco::CandidatePtrVector overlaps; bool hasOverlap = itov->fillOverlapsForItem(obj, overlaps); if (hasOverlap && itov->requireNoOverlaps()) { badForOverlap = true; // mark for discarding break; // no point in checking the others, as this item will be discarded } obj.setOverlaps(itov->name(), overlaps); } if (badForOverlap) { output->pop_back(); continue; } // Apply one final selection cut if (!finalCut_(obj)) output->pop_back(); } iEvent.put(output); }
bool pat::PATCleaner< PATObjType >::doFinalCut_ [private] |
Definition at line 52 of file PATCleaner.h.
bool pat::PATCleaner< PATObjType >::doPreselection_ [private] |
Definition at line 52 of file PATCleaner.h.
Selector pat::PATCleaner< PATObjType >::finalCut_ [private] |
Definition at line 54 of file PATCleaner.h.
boost::ptr_vector<OverlapTest> pat::PATCleaner< PATObjType >::overlapTests_ [private] |
Definition at line 58 of file PATCleaner.h.
Referenced by pat::PATCleaner< PATObjType >::PATCleaner().
Selector pat::PATCleaner< PATObjType >::preselectionCut_ [private] |
Definition at line 53 of file PATCleaner.h.
edm::InputTag pat::PATCleaner< PATObjType >::src_ [private] |
Definition at line 51 of file PATCleaner.h.
Referenced by pat::PATCleaner< PATObjType >::PATCleaner().