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_ |
The same module is used for all collections.
Definition at line 39 of file PATCleaner.cc.
typedef pat::helper::OverlapTest pat::PATCleaner< PATObjType >::OverlapTest [private] |
Definition at line 54 of file PATCleaner.cc.
typedef StringCutObjectSelector<PATObjType> pat::PATCleaner< PATObjType >::Selector [private] |
Definition at line 47 of file PATCleaner.cc.
pat::PATCleaner< PATObjType >::PATCleaner | ( | const edm::ParameterSet & | iConfig | ) | [inline, explicit] |
Definition at line 62 of file PATCleaner.cc.
References ptdrElectronId_cfi::algorithm, edm::ParameterSet::empty(), Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), pat::PATCleaner< PATObjType >::overlapTests_, and pat::PATCleaner< PATObjType >::src_.
00062 : 00063 src_(iConfig.getParameter<edm::InputTag>("src")), 00064 preselectionCut_(iConfig.getParameter<std::string>("preselection")), 00065 finalCut_(iConfig.getParameter<std::string>("finalCut")) 00066 { 00067 // pick parameter set for overlaps 00068 edm::ParameterSet overlapPSet = iConfig.getParameter<edm::ParameterSet>("checkOverlaps"); 00069 // get all the names of the tests (all nested PSets in this PSet) 00070 std::vector<std::string> overlapNames = overlapPSet.getParameterNamesForType<edm::ParameterSet>(); 00071 // loop on them 00072 for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) { 00073 // retrieve configuration 00074 edm::ParameterSet cfg = overlapPSet.getParameter<edm::ParameterSet>(*itn); 00075 // skip empty parameter sets 00076 if (cfg.empty()) continue; 00077 // get the name of the algorithm to use 00078 std::string algorithm = cfg.getParameter<std::string>("algorithm"); 00079 // create the appropriate OverlapTest 00080 if (algorithm == "byDeltaR") { 00081 overlapTests_.push_back(new pat::helper::BasicOverlapTest(*itn, cfg)); 00082 } else if (algorithm == "bySuperClusterSeed") { 00083 overlapTests_.push_back(new pat::helper::OverlapBySuperClusterSeed(*itn, cfg)); 00084 } else { 00085 throw cms::Exception("Configuration") << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n"; 00086 } 00087 } 00088 00089 00090 produces<std::vector<PATObjType> >(); 00091 }
virtual pat::PATCleaner< PATObjType >::~PATCleaner | ( | ) | [inline, virtual] |
void pat::PATCleaner< PATObjType >::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [inline, virtual] |
Implements edm::EDProducer.
Definition at line 95 of file PATCleaner.cc.
References pat::PATCleaner< PATObjType >::finalCut_, edm::Event::getByLabel(), it, VarParsing::obj, output(), pat::PATCleaner< PATObjType >::overlapTests_, pat::PATCleaner< PATObjType >::preselectionCut_, edm::Event::put(), and pat::PATCleaner< PATObjType >::src_.
00095 { 00096 using namespace edm; 00097 00098 // Read the input. We use View<> in case the input happes to be something different than a std::vector<> 00099 Handle<View<PATObjType> > candidates; 00100 iEvent.getByLabel(src_, candidates); 00101 00102 // Prepare a collection for the output 00103 std::auto_ptr< std::vector<PATObjType> > output(new std::vector<PATObjType>()); 00104 00105 // initialize the overlap tests 00106 for (boost::ptr_vector<OverlapTest>::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) { 00107 itov->readInput(iEvent,iSetup); 00108 } 00109 00110 for (typename View<PATObjType>::const_iterator it = candidates->begin(), ed = candidates->end(); it != ed; ++it) { 00111 // Apply a preselection to the inputs and copy them in the output 00112 if (!preselectionCut_(*it)) continue; 00113 00114 // Add it to the list and take a reference to it, so it can be modified (e.g. to set the overlaps) 00115 // If at some point I'll decide to drop this item, I'll use pop_back to remove it 00116 output->push_back(*it); 00117 PATObjType &obj = output->back(); 00118 00119 // Look for overlaps 00120 bool badForOverlap = false; 00121 for (boost::ptr_vector<OverlapTest>::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) { 00122 reco::CandidatePtrVector overlaps; 00123 bool hasOverlap = itov->fillOverlapsForItem(obj, overlaps); 00124 if (hasOverlap && itov->requireNoOvelaps()) { 00125 badForOverlap = true; // mark for discarding 00126 break; // no point in checking the others, as this item will be discarded 00127 } 00128 obj.setOverlaps(itov->name(), overlaps); 00129 } 00130 if (badForOverlap) { output->pop_back(); continue; } 00131 00132 // Apply one final selection cut 00133 if (!finalCut_(obj)) output->pop_back(); 00134 } 00135 00136 iEvent.put(output); 00137 }
bool pat::PATCleaner< PATObjType >::doFinalCut_ [private] |
Definition at line 50 of file PATCleaner.cc.
bool pat::PATCleaner< PATObjType >::doPreselection_ [private] |
Definition at line 50 of file PATCleaner.cc.
Selector pat::PATCleaner< PATObjType >::finalCut_ [private] |
Definition at line 52 of file PATCleaner.cc.
Referenced by pat::PATCleaner< PATObjType >::produce().
boost::ptr_vector<OverlapTest> pat::PATCleaner< PATObjType >::overlapTests_ [private] |
Definition at line 56 of file PATCleaner.cc.
Referenced by pat::PATCleaner< PATObjType >::PATCleaner(), and pat::PATCleaner< PATObjType >::produce().
Selector pat::PATCleaner< PATObjType >::preselectionCut_ [private] |
Definition at line 51 of file PATCleaner.cc.
Referenced by pat::PATCleaner< PATObjType >::produce().
edm::InputTag pat::PATCleaner< PATObjType >::src_ [private] |
Definition at line 49 of file PATCleaner.cc.
Referenced by pat::PATCleaner< PATObjType >::PATCleaner(), and pat::PATCleaner< PATObjType >::produce().