19 if ( cfg.
exists(
"srcSelectedMuons1") ) {
23 if ( cfg.
exists(
"srcSelectedMuons2") ) {
38 std::vector<const T*> getCleanedCollection(
const std::vector<T>& l1ExtraObjects,
const edm::Event& evt,
const edm::InputTag& srcSelectedMuons,
double dRveto)
40 std::vector<const T*> l1ExtraObjects_cleaned;
41 if ( srcSelectedMuons.
label() !=
"" ) {
42 std::vector<reco::CandidateBaseRef> selMuons =
getSelMuons(evt, srcSelectedMuons);
43 for (
typename std::vector<T>::const_iterator l1ExtraObject = l1ExtraObjects.begin();
44 l1ExtraObject != l1ExtraObjects.end(); ++l1ExtraObject ) {
45 bool isVetoed =
false;
46 for ( std::vector<reco::CandidateBaseRef>::const_iterator selMuon = selMuons.begin();
47 selMuon != selMuons.end(); ++selMuon ) {
48 double dR =
deltaR(l1ExtraObject->p4(), (*selMuon)->p4());
49 if ( dR < dRveto ) isVetoed =
true;
51 if ( !isVetoed ) l1ExtraObjects_cleaned.push_back(&(*l1ExtraObject));
54 for (
typename std::vector<T>::const_iterator l1ExtraObject = l1ExtraObjects.begin();
55 l1ExtraObject != l1ExtraObjects.end(); ++l1ExtraObject ) {
56 l1ExtraObjects_cleaned.push_back(&(*l1ExtraObject));
59 return l1ExtraObjects_cleaned;
62 template <
typename TPtr>
65 bool operator() (
const TPtr& t1,
const TPtr& t2)
67 return (t1->pt() > t2->pt());
77 l1ExtraPtrCollection l1ExtraObjects1_cleaned = getCleanedCollection(*l1ExtraObjects1, evt, srcSelectedMuons1_, dRveto1_);
81 l1ExtraPtrCollection l1ExtraObjects2_cleaned = getCleanedCollection(*l1ExtraObjects2, evt, srcSelectedMuons2_, dRveto2_);
84 l1ExtraObjects_sorted.insert(l1ExtraObjects_sorted.end(), l1ExtraObjects1_cleaned.begin(), l1ExtraObjects1_cleaned.end());
85 l1ExtraObjects_sorted.insert(l1ExtraObjects_sorted.end(), l1ExtraObjects2_cleaned.begin(), l1ExtraObjects2_cleaned.end());
86 higherPtT<const T*> higherPt;
87 std::sort(l1ExtraObjects_sorted.begin(), l1ExtraObjects_sorted.end(), higherPt);
91 size_t numL1ExtraObjects = l1ExtraObjects_sorted.size();
93 l1ExtraObjects_output->push_back(*l1ExtraObjects_sorted.at(iObject));
96 evt.
put(l1ExtraObjects_output, instanceLabel_);
T getParameter(std::string const &) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)