From 5e63bd99f833910ba2078ab8dcea2b6a1d4e28d5 Mon Sep 17 00:00:00 2001 From: yuanchao Date: Mon, 16 Aug 2021 19:10:33 +0800 Subject: [PATCH 1/4] remove unused headers for CommonTools packages --- .../CandAlgos/interface/CloneProducer.h | 59 ----- CommonTools/CandUtils/interface/CandMatcher.h | 239 ------------------ .../CandUtils/interface/FastCandMatcher.h | 103 -------- .../CandUtils/interface/NamedCandCombiner.h | 150 ----------- .../ParticleFlow/interface/ObjectSelector.h | 43 ---- .../ParticleFlow/interface/ObjectSelectors.h | 17 -- .../interface/BinomialProbability.h | 49 ---- .../UtilAlgos/interface/DummyMatchSelector.h | 26 -- .../UtilAlgos/interface/MassMinSelector.h | 21 -- .../UtilAlgos/interface/MassRangeSelector.h | 22 -- CommonTools/UtilAlgos/interface/MinSelector.h | 20 -- .../UtilAlgos/interface/ObjectPairFilter.h | 60 ----- .../interface/ObjectRefVectorSelector.h | 23 -- .../UtilAlgos/interface/OrPairSelector.h | 21 -- CommonTools/Utils/interface/Angle.h | 23 -- CommonTools/Utils/interface/InvariantMass.h | 12 - CommonTools/Utils/interface/LazyResult.h | 76 ------ CommonTools/Utils/interface/MassMinSelector.h | 22 -- .../Utils/interface/MassRangeSelector.h | 23 -- CommonTools/Utils/interface/MinSelector.h | 19 -- CommonTools/Utils/interface/OrPairSelector.h | 22 -- 21 files changed, 1050 deletions(-) delete mode 100644 CommonTools/CandAlgos/interface/CloneProducer.h delete mode 100755 CommonTools/CandUtils/interface/CandMatcher.h delete mode 100755 CommonTools/CandUtils/interface/FastCandMatcher.h delete mode 100755 CommonTools/CandUtils/interface/NamedCandCombiner.h delete mode 100644 CommonTools/ParticleFlow/interface/ObjectSelector.h delete mode 100644 CommonTools/ParticleFlow/interface/ObjectSelectors.h delete mode 100644 CommonTools/Statistics/interface/BinomialProbability.h delete mode 100644 CommonTools/UtilAlgos/interface/DummyMatchSelector.h delete mode 100755 CommonTools/UtilAlgos/interface/MassMinSelector.h delete mode 100755 CommonTools/UtilAlgos/interface/MassRangeSelector.h delete mode 100755 CommonTools/UtilAlgos/interface/MinSelector.h delete mode 100755 CommonTools/UtilAlgos/interface/ObjectPairFilter.h delete mode 100755 CommonTools/UtilAlgos/interface/ObjectRefVectorSelector.h delete mode 100755 CommonTools/UtilAlgos/interface/OrPairSelector.h delete mode 100644 CommonTools/Utils/interface/Angle.h delete mode 100755 CommonTools/Utils/interface/InvariantMass.h delete mode 100644 CommonTools/Utils/interface/LazyResult.h delete mode 100755 CommonTools/Utils/interface/MassMinSelector.h delete mode 100755 CommonTools/Utils/interface/MassRangeSelector.h delete mode 100755 CommonTools/Utils/interface/MinSelector.h delete mode 100755 CommonTools/Utils/interface/OrPairSelector.h diff --git a/CommonTools/CandAlgos/interface/CloneProducer.h b/CommonTools/CandAlgos/interface/CloneProducer.h deleted file mode 100644 index 4405c92d80ae4..0000000000000 --- a/CommonTools/CandAlgos/interface/CloneProducer.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef CandAlgos_CloneProducer_h -#define CandAlgos_CloneProducer_h -/** \class CloneProducer - * - * Clones a concrete Candidate collection - * to a CandidateCollection (i.e.: OwnVector) filled - * with clones of the original candidate collection - * - * \author: Francesco Fabozzi, INFN - * modified by Luca Lista, INFN - * - * Template parameters: - * - C : Concrete candidate collection type - * - */ -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/Candidate/interface/Candidate.h" - -template -class CloneProducer : public edm::EDProducer { -public: - /// constructor from parameter set - explicit CloneProducer( const edm::ParameterSet& ); - /// destructor - ~CloneProducer(); - -private: - /// process an event - virtual void produce( edm::Event&, const edm::EventSetup& ); - /// labels of the collection to be converted - edm::EDGetTokenT srcToken_; -}; - -template -CloneProducer::CloneProducer( const edm::ParameterSet& par ) : - srcToken_( consumes( par.template getParameter( "src" ) ) ) { - produces(); -} - -template -CloneProducer::~CloneProducer() { -} - -template -void CloneProducer::produce( edm::Event& evt, const edm::EventSetup& ) { - std::unique_ptr coll( new reco::CandidateCollection ); - edm::Handle masterCollection; - evt.getByToken( srcToken_, masterCollection ); - for( size_t i = 0; i < masterCollection->size(); ++i ) { - reco::CandidateBaseRef masterClone( edm::Ref( masterCollection, i ) ); - coll->push_back( masterClone->clone() ); - } - evt.put( std::move( coll ) ); -} - -#endif diff --git a/CommonTools/CandUtils/interface/CandMatcher.h b/CommonTools/CandUtils/interface/CandMatcher.h deleted file mode 100755 index 9a0c2c1fdcbf6..0000000000000 --- a/CommonTools/CandUtils/interface/CandMatcher.h +++ /dev/null @@ -1,239 +0,0 @@ -#ifndef CandUtils_CandMatcher_h -#define CandUtils_CandMatcher_h -/* class CandMatcher - * - * \author Luca Lista, INFN - * - */ -#include -#include "DataFormats/Candidate/interface/Candidate.h" -#include "DataFormats/Common/interface/AssociationMap.h" -#include "DataFormats/Common/interface/OneToOne.h" -#include "FWCore/Utilities/interface/EDMException.h" -#include "CommonTools/CandUtils/interface/CandMapTrait.h" - -template -class CandMatcherBase { -public: - /// map type - typedef typename reco::helper::CandMapTrait::type map_type; - /// ref type - typedef typename reco::helper::CandRefTrait::ref_type ref_type; - /// refProd type - typedef typename reco::helper::CandRefTrait::refProd_type refProd_type; - /// map vector - typedef std::vector map_vector; - /// concrete candidate reference type - typedef typename map_type::key_type reference_type; - /// concrete candidate reference type - typedef typename reference_type::value_type value_type; - /// constructor - explicit CandMatcherBase( const map_vector & maps ); - /// constructor - explicit CandMatcherBase( const map_type & map ); - /// destructor - virtual ~CandMatcherBase(); - /// get match from transient reference - ref_type operator()( const reco::Candidate & ) const; - -protected: - /// get ultimate daughter (can skip status = 3 in MC) - virtual std::vector getDaughters( const reco::Candidate * ) const = 0; - /// composite candidate preselection - virtual bool compositePreselect( const reco::Candidate & c, const reco::Candidate & m ) const = 0; - /// init maps - void initMaps(); - -protected: - const std::vector & maps() const { return maps_; } -private: - /// pointers to stored maps - std::vector maps_; - /// reference to matched collectino - refProd_type matched_; - /// pointer map type - typedef std::map CandRefMap; - /// pointer map type - typedef std::map MatchedRefMap; - /// pointer map of candidates (e.g.: reco) - CandRefMap candRefs_; - /// pointer map of matched candidates (e.g.: MC truth) - MatchedRefMap matchedRefs_; - /// mother + n.daughters indices from matched - std::vector > matchedMothers_; - /// init at constructor - void init(); -}; - -template -class CandMatcher : public CandMatcherBase { -public: - /// constructor - explicit CandMatcher( const typename CandMatcherBase::map_vector & maps ); - /// constructor - explicit CandMatcher( const typename CandMatcherBase::map_type & map ); - /// destructor - virtual ~CandMatcher(); - -protected: - /// get ultimate daughter (get all in the general case) - virtual std::vector getDaughters( const reco::Candidate * ) const; - /// composite candidate preselection - virtual bool compositePreselect( const reco::Candidate & c, const reco::Candidate & m ) const; -}; - -#include -#include - -template -void CandMatcherBase::init() { - matched_ = maps_.front()->refProd().val; - for( typename map_vector::const_iterator m = maps_.begin() + 1; - m != maps_.end(); ++ m ) { - if( (*m)->refProd().val != matched_ ) - throw edm::Exception( edm::errors::InvalidReference ) - << "Multiple match maps specified matching different MC truth collections.\n" - << "Please, specify maps all matching to the same MC truth collection.\n" - << "In most of the cases you may want to match to genParticleCandidate."; - } -} - -template -CandMatcherBase::CandMatcherBase( const typename CandMatcherBase::map_vector & maps ): - maps_( maps ) { - init(); -} - -template -CandMatcherBase::CandMatcherBase( const typename CandMatcherBase::map_type & map ): - maps_( 1, & map ) { - init(); -} - -template -void CandMatcherBase::initMaps() { - using namespace reco; - using namespace std; - for( typename map_vector::const_iterator m = maps_.begin(); - m != maps_.end(); ++ m ) { - typename CandMatcherBase::map_type::ref_type::key_type cands = (*m)->refProd().key; - for( size_t i = 0; i < cands->size(); ++ i ) { - candRefs_[ & (*cands)[ i ] ] = reference_type( cands, i ); - } - const C2 & matched = * matched_; - size_t matchedSize = matched.size(); - for( size_t i = 0; i < matchedSize; ++ i ) - matchedRefs_[ & matched[ i ] ] = ref_type( matched_, i ); - matchedMothers_.resize( matchedSize ); - for( size_t i = 0; i < matchedSize; ++ i ) { - const Candidate & c = matched[ i ]; - for( Candidate::const_iterator d = c.begin(); d != c.end(); ++ d ) { - vector daus = getDaughters( & * d ); - for( size_t j = 0; j < daus.size(); ++ j ) { - const Candidate * daughter = daus[ j ]; - typename MatchedRefMap::const_iterator f = matchedRefs_.find( daughter ); - if ( f == matchedRefs_.end() ) continue; - size_t k = f->second.key(); - assert( k < matchedMothers_.size() ); - matchedMothers_[ k ].insert( i ); - } - } - } - } -} - -template -CandMatcherBase::~CandMatcherBase() { -} - -template -typename CandMatcherBase::ref_type CandMatcherBase::operator()( const reco::Candidate & c ) const { - using namespace reco; - using namespace std; - if ( c.hasMasterClone() ) - return (*this)( * c.masterClone() ); - unsigned int nDau = c.numberOfDaughters(); - const C2 & matched = * matched_; - if ( nDau > 0 ) { - // check for composite candidate c - // navigate to daughters and find parent matches - set momsIntersection, momDaughters, tmp; - for( Candidate::const_iterator d = c.begin(); d != c.end(); ++ d ) { - // check here generically if status == 3, then descend down to one more level - ref_type m = (*this)( * d ); - // if a daughter does not match, return a null ref. - if ( m.isNull() ) return ref_type(); - // get matched mother indices (fetched previously) - const set & allMomDaughters = matchedMothers_[ m.key() ]; - momDaughters.clear(); - for( set::const_iterator k = allMomDaughters.begin(); - k != allMomDaughters.end(); ++ k ) { - size_t m = * k; - if( compositePreselect( c, matched[ m ] ) ) - momDaughters.insert( m ); - } - // if no mother was found return null reference - if ( momDaughters.size() == 0 ) return ref_type(); - // the first time, momsIntersection is set to momDaughters - if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters; - else { - tmp.clear(); - set_intersection( momsIntersection.begin(), momsIntersection.end(), - momDaughters.begin(), momDaughters.end(), - inserter( tmp, tmp.begin() ) ); - swap( momsIntersection, tmp ); - } - if ( momsIntersection.size() == 0 ) return ref_type(); - } - // if multiple mothers are found, return a null reference - if ( momsIntersection.size() > 1 ) return ref_type(); - // return a reference to the unique mother - return ref_type( matched_, * momsIntersection.begin() ); - } else { - // check for non-composite (leaf) candidate - // if one of the maps contains the candidate c - for( typename std::vector::const_iterator m = maps_.begin(); - m != maps_.end(); ++ m ) { - typename CandRefMap::const_iterator f = candRefs_.find( & c ); - if ( f != candRefs_.end() ) { - reference_type ref = f->second; - typename map_type::const_iterator f = (*m)->find( ref ); - if ( f != (*m)->end() ) { - return f->val; - } - } - } - return ref_type(); - } -} - -template -CandMatcher::CandMatcher( const typename CandMatcherBase::map_vector & maps ) : - CandMatcherBase( maps ) { - CandMatcherBase::initMaps(); -} - -template -CandMatcher::CandMatcher( const typename CandMatcherBase::map_type & map ) : - CandMatcherBase( map ) { - CandMatcherBase::initMaps(); -} - -template -CandMatcher::~CandMatcher() { -} - -template -std::vector CandMatcher::getDaughters( const reco::Candidate * c ) const { - std::vector v; - v.push_back( c ); - return v; -} - -template -bool CandMatcher::compositePreselect( const reco::Candidate & c, const reco::Candidate & m ) const { - // By default, check that the number of daughters is identical - return( c.numberOfDaughters() == m.numberOfDaughters() ); -} - -#endif diff --git a/CommonTools/CandUtils/interface/FastCandMatcher.h b/CommonTools/CandUtils/interface/FastCandMatcher.h deleted file mode 100755 index aad0f64bf0243..0000000000000 --- a/CommonTools/CandUtils/interface/FastCandMatcher.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef CandUtils_FastCandMatcher_h -#define CandUtils_FastCandMatcher_h -/* class CandMatcher - * - * \author Luca Lista, INFN - * - */ -#include -#include "DataFormats/Candidate/interface/Candidate.h" -#include "DataFormats/Common/interface/AssociationMap.h" -#include "DataFormats/Common/interface/OneToOne.h" -#include "FWCore/Utilities/interface/EDMException.h" - -template -class FastCandMatcher { -public: - /// map type - typedef edm::AssociationMap > map_type; - /// map vector - typedef std::vector map_vector; - /// constructor - explicit FastCandMatcher( const map_vector & maps ); - /// constructor - explicit FastCandMatcher( const map_type & map ); - /// get match from transient reference - const reco::Candidate * operator()( const reco::Candidate & ) const; - -protected: - const std::vector & maps() const { return maps_; } -private: - /// pointers to stored maps - std::vector maps_; -}; - -template -FastCandMatcher::FastCandMatcher( const typename FastCandMatcher::map_vector & maps ): - maps_( maps ) { -} - -template -FastCandMatcher::FastCandMatcher( const typename FastCandMatcher::map_type & map ): - maps_( 1, & map ) { -} - -template -const reco::Candidate * FastCandMatcher::operator()( const reco::Candidate & c ) const { - using namespace reco; - using namespace std; - if ( c.hasMasterClone() ) - return (*this)( * c.masterClone() ); - unsigned int nDau = c.numberOfDaughters(); - if ( nDau > 0 ) { - // check for composite candidate c - // navigate to daughters and find parent matches - set momsIntersection, momDaughters, tmp; - for( Candidate::const_iterator dau = c.begin(); dau != c.end(); ++ dau ) { - // check here generically if status == 3, then descend down to one more level - const Candidate * dauMatch = (*this)( * dau ); - // if a daughter does not match, return a null ref. - if ( dauMatch == 0 ) return 0; - // get matched mothers - size_t mothers = dauMatch->numberOfMothers(); - for( size_t i = 0; i < mothers; ++ i ) { - const reco::Candidate * mom = dauMatch->mother( i ); - if ( mom != 0 && mom->pdgId() == dauMatch->pdgId() && - mom->status() == 3 && dauMatch->status() == 1 ) { - // assume a single mother at this point... - mom = mom->mother( 0 ); - } - momDaughters.insert( mom ); - } - // if no mother was found return null reference - if ( momDaughters.size() == 0 ) return 0; - // the first time, momsIntersection is set to momDaughters - if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters; - else { - tmp.clear(); - set_intersection( momsIntersection.begin(), momsIntersection.end(), - momDaughters.begin(), momDaughters.end(), - inserter( tmp, tmp.begin() ) ); - swap( momsIntersection, tmp ); - } - if ( momsIntersection.size() == 0 ) return 0; - } - // if multiple mothers are found, return a null reference - if ( momsIntersection.size() > 1 ) return 0; - // return a reference to the unique mother - return * momsIntersection.begin(); - } else { - // check for non-composite (leaf) candidate - // if one of the maps contains the candidate c - for( typename std::vector::const_iterator m = maps_.begin(); - m != maps_.end(); ++ m ) { - for( typename map_type::const_iterator i = (*m)->begin(); i != (*m)->end(); ++ i ) { - if ( & * i->key == & c ) - return & * i->val; - } - } - return 0; - } -} - -#endif diff --git a/CommonTools/CandUtils/interface/NamedCandCombiner.h b/CommonTools/CandUtils/interface/NamedCandCombiner.h deleted file mode 100755 index 6f1633fc6c77f..0000000000000 --- a/CommonTools/CandUtils/interface/NamedCandCombiner.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef CandUtils_NamedCandCombiner_h -#define CandUtils_NamedCandCombiner_h -/** \class NamedCandCombiner - * - * \author Luca Lista, INFN - * - */ -#include "CommonTools/CandUtils/interface/NamedCandCombinerBase.h" -#include "CommonTools/CandUtils/interface/AddFourMomenta.h" -#include "CommonTools/CandUtils/interface/CandSelector.h" -#include "CommonTools/UtilAlgos/interface/AnyPairSelector.h" -#include "DataFormats/Candidate/interface/NamedCompositeCandidate.h" -#include "DataFormats/Candidate/interface/ShallowClonePtrCandidate.h" -#include - -namespace combiner { - namespace helpers { - struct NormalClone { - template - static void addDaughter(CMP & cmp, const Ptr & c, std::string name) { - cmp.addDaughter(*c, name); - } - }; - - struct ShallowClone { - template - static void addDaughter(CMP & cmp, const reco::CandidatePtr & c, std::string name) { - if(c->numberOfDaughters()==0) - cmp.addDaughter(reco::ShallowClonePtrCandidate(c), name); - else - cmp.addDaughter(*c, name); - } - }; - } -} - -template -class NamedCandCombiner : public NamedCandCombinerBase { -public: - /// default constructor - NamedCandCombiner(std::string name) : - NamedCandCombinerBase(name), - select_(), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector and two charges - NamedCandCombiner(std::string name, int q1, int q2) : - NamedCandCombinerBase(name, q1, q2), - select_(), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector and three charges - NamedCandCombiner(std::string name, int q1, int q2, int q3 ) : - NamedCandCombinerBase(name, q1, q2, q3), - select_(), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector and four charges - NamedCandCombiner(std::string name, int q1, int q2, int q3, int q4) : - NamedCandCombinerBase(name, q1, q2, q3, q4), - select_(), selectPair_(), setup_(), name_(name) { } - /// default constructor - NamedCandCombiner(std::string name, const Selector & select) : - NamedCandCombinerBase(name), - select_(select), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector and two charges - NamedCandCombiner(std::string name, const Selector & select, int q1, int q2 ) : - NamedCandCombinerBase(name, q1, q2), - select_(select), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector and three charges - NamedCandCombiner(std::string name, const Selector & select, int q1, int q2, int q3 ) : - NamedCandCombinerBase(name, q1, q2, q3), - select_(select), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector and four charges - NamedCandCombiner(std::string name, const Selector & select, int q1, int q2, int q3, int q4 ) : - NamedCandCombinerBase(name, q1, q2, q3, q4), - select_(select), selectPair_(), setup_(), name_(name) { } - /// constructor from selector - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair) : - NamedCandCombinerBase(name), - select_(select), selectPair_(selectPair), setup_(), name_(name) { } - /// constructor from a selector and two charges - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, int q1, int q2) : - NamedCandCombinerBase(name, q1, q2), - select_(select), selectPair_(selectPair), setup_(), name_(name) { } - /// constructor from a selector and three charges - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3) : - NamedCandCombinerBase(name, q1, q2, q3), - select_(select), selectPair_(selectPair), setup_(), name_(name) { } - /// constructor from a selector and four charges - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3, int q4) : - NamedCandCombinerBase(name, q1, q2, q3, q4), - select_(select), selectPair_(selectPair), setup_(), name_(name) { } - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup) : - NamedCandCombinerBase(name), - select_(select), selectPair_(selectPair), setup_(setup), name_(name) { } - /// constructor from a selector and two charges - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2) : - NamedCandCombinerBase(name, q1, q2), - select_(select), selectPair_(selectPair), setup_(setup), name_(name) { } - /// constructor from a selector and three charges - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3) : - NamedCandCombinerBase(name, q1, q2, q3), - select_(select), selectPair_(selectPair), setup_(setup), name_(name) { } - /// constructor from a selector and four charges - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3, int q4) : - NamedCandCombinerBase(name, q1, q2, q3, q4), - select_(select), selectPair_(selectPair), setup_(setup), name_(name) { } - /// constructor from a selector, specifying to check for charge - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup,const std::vector & dauCharge) : - NamedCandCombinerBase(name, true, dauCharge), select_(select), selectPair_(selectPair), setup_(setup), name_(name) { } - /// constructor from a selector, specifying to check for charge - NamedCandCombiner( std::string name, const Selector & select, const PairSelector & selectPair, const std::vector & dauCharge ) : - NamedCandCombinerBase(name, true, dauCharge), select_(select), selectPair_(selectPair), setup_(), name_(name) { } - /// constructor from a selector, specifying to check for charge - NamedCandCombiner(std::string name, const std::vector & dauCharge) : - NamedCandCombinerBase(name, true, dauCharge), select_(), selectPair_(), setup_(), name_(name) { } - /// constructor from a selector, specifying optionally to check for charge - NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, - bool checkCharge, bool checkOverlap, const std::vector & dauCharge) : - NamedCandCombinerBase(name, checkCharge, checkOverlap, dauCharge), - select_(select), selectPair_(selectPair), setup_(setup), name_(name) { } - /// return reference to setup object to allow its initialization - Setup & setup() { return setup_; } - -private: - /// select a candidate - virtual bool select(const reco::Candidate & c) const { - return select_(c); - } - /// select a candidate - virtual bool selectPair(const reco::Candidate & c1, const reco::Candidate & c2) const { - return selectPair_(c1, c2); - } - /// set kinematics to reconstructed composite - virtual void setup(reco::NamedCompositeCandidate & c) const { - setup_.set(c); - } - /// add candidate daughter - virtual void addDaughter(reco::NamedCompositeCandidate & cmp, const reco::CandidatePtr & c, std::string n) const { - Cloner::addDaughter(cmp, c, n); - } - /// candidate selector - Selector select_; - /// candidate pair selector - PairSelector selectPair_; - /// utility to setup composite candidate kinematics from daughters - Setup setup_; - /// name - std::string name_; -}; - -#endif diff --git a/CommonTools/ParticleFlow/interface/ObjectSelector.h b/CommonTools/ParticleFlow/interface/ObjectSelector.h deleted file mode 100644 index 49d7280d68d7e..0000000000000 --- a/CommonTools/ParticleFlow/interface/ObjectSelector.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef CommonTools_ParticleFlow_ObjectSelector -#define CommonTools_ParticleFlow_ObjectSelector - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" - - -namespace edm { - class EventSetup; -} - -namespace ipf2pat { - - template< typename Selector, typename CollectionType > - class ObjectSelector { - public: - ObjectSelector(const edm::ParameterSet& ps) : - eventSetupPtr_(0), - selector_(ps) {} - - - const CollectionType& select( const edm::Handle& handleToCollection, - const edm::EventBase& event ) { - /* static edm::Event e; */ - selector_.select( handleToCollection, event, *eventSetupPtr_ ); - return selector_.selected(); - } - - - private: - const edm::EventSetup* eventSetupPtr_; - - Selector selector_; - }; - - -} - - - -#endif diff --git a/CommonTools/ParticleFlow/interface/ObjectSelectors.h b/CommonTools/ParticleFlow/interface/ObjectSelectors.h deleted file mode 100644 index a4a6a207899c3..0000000000000 --- a/CommonTools/ParticleFlow/interface/ObjectSelectors.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CommonTools_ParticleFlow_ObjectSelectors -#define CommonTools_ParticleFlow_ObjectSelectors - -#include "CommonTools/ParticleFlow/interface/ObjectSelector.h" -#include "CommonTools/ParticleFlow/interface/PtMinPFCandidateSelectorDefinition.h" -#include "CommonTools/ParticleFlow/interface/PdgIdPFCandidateSelectorDefinition.h" -#include "CommonTools/ParticleFlow/interface/IsolatedPFCandidateSelectorDefinition.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" - - -namespace ipf2pat { - typedef ObjectSelector< pf2pat::PtMinPFCandidateSelectorDefinition, reco::PFCandidateCollection > PtMinPFCandidateSelector; - typedef ObjectSelector< pf2pat::PdgIdPFCandidateSelectorDefinition, reco::PFCandidateCollection > PdgIdPFCandidateSelector; - typedef ObjectSelector< pf2pat::IsolatedPFCandidateSelectorDefinition, reco::PFCandidateCollection > IsolatedPFCandidateSelector; -} - -#endif diff --git a/CommonTools/Statistics/interface/BinomialProbability.h b/CommonTools/Statistics/interface/BinomialProbability.h deleted file mode 100644 index 70cc211076dd8..0000000000000 --- a/CommonTools/Statistics/interface/BinomialProbability.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef BinomialProbability_H -#define BinomialProbability_H - -#include - -/** A simple class for accumulating binomial "events", - * i.e. events that have a yes/no outcome, - * and for computing the binomial error on the - * fraction of positive hits. - */ - -class BinomialProbability { -public: - - BinomialProbability() : theHits(0), theTotal(0) {} - - BinomialProbability(int hits, int entries) : - theHits(hits), theTotal(entries) {} - - float value() const { - return theTotal == 0 ? 0 :float(theHits) / float(theTotal); - } - - float error() const { - float p = value(); - return theTotal <= 1 ? 0 : sqrt( p*(1.f - p)/(theTotal-1)); - } - - int entries() const { return theTotal;} - - int hits() const { return theHits;} - - void hit() { theHits++; theTotal++;} - - void miss() { theTotal++;} - - void update( bool hit) { - if ( hit) theHits++; - theTotal++; - } - -private: - - int theHits; - int theTotal; - -}; - -#endif diff --git a/CommonTools/UtilAlgos/interface/DummyMatchSelector.h b/CommonTools/UtilAlgos/interface/DummyMatchSelector.h deleted file mode 100644 index 8d0d99aab14d8..0000000000000 --- a/CommonTools/UtilAlgos/interface/DummyMatchSelector.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DummyMatchSelector_h -#define DummyMatchSelector_h - -/** - Dummy class for preselection of object matches. -*/ - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -namespace reco { - - template - class DummyMatchSelector { - - public: - - DummyMatchSelector(const edm::ParameterSet& cfg) { } - - bool operator()( const T1 & c, const T2 & hlt ) const { return true; } - - }; - -} - - -#endif diff --git a/CommonTools/UtilAlgos/interface/MassMinSelector.h b/CommonTools/UtilAlgos/interface/MassMinSelector.h deleted file mode 100755 index 73f37fc036aa6..0000000000000 --- a/CommonTools/UtilAlgos/interface/MassMinSelector.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef UtilAlgos_MassMinSelector_h -#define UtilAlgos_MassMinSelector_h -#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" -#include "CommonTools/Utils/interface/MassMinSelector.h" - -namespace reco { - namespace modules { - - template<> - struct ParameterAdapter { - static MassMinSelector make( const edm::ParameterSet & cfg ) { - return - MassMinSelector( cfg.getParameter( "massMin" ) ); - } - }; - - } -} - -#endif - diff --git a/CommonTools/UtilAlgos/interface/MassRangeSelector.h b/CommonTools/UtilAlgos/interface/MassRangeSelector.h deleted file mode 100755 index 62019baf4e5b3..0000000000000 --- a/CommonTools/UtilAlgos/interface/MassRangeSelector.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef UtilAlgos_MassRangeSelector_h -#define UtilAlgos_MassRangeSelector_h -#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" -#include "CommonTools/Utils/interface/MassRangeSelector.h" - -namespace reco { - namespace modules { - - template<> - struct ParameterAdapter { - static MassRangeSelector make( const edm::ParameterSet & cfg ) { - return - MassRangeSelector( cfg.getParameter( "massMin" ), - cfg.getParameter( "massMax" ) ); - } - }; - - } -} - -#endif - diff --git a/CommonTools/UtilAlgos/interface/MinSelector.h b/CommonTools/UtilAlgos/interface/MinSelector.h deleted file mode 100755 index efa3d22ccca5d..0000000000000 --- a/CommonTools/UtilAlgos/interface/MinSelector.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef UtilAlgos_MinSelector_h -#define UtilAlgos_MinSelector_h -#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" -#include "CommonTools/Utils/interface/MinSelector.h" - -namespace reco { - namespace modules { - - template - struct ParameterAdapter > { - static MinSelector make( const edm::ParameterSet & cfg ) { - return MinSelector( cfg.template getParameter( "min" ) ); - } - }; - - } -} - -#endif - diff --git a/CommonTools/UtilAlgos/interface/ObjectPairFilter.h b/CommonTools/UtilAlgos/interface/ObjectPairFilter.h deleted file mode 100755 index 18a66ca61d081..0000000000000 --- a/CommonTools/UtilAlgos/interface/ObjectPairFilter.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef RecoAlgos_ObjectPairFilter_h -#define RecoAlgos_ObjectPairFilter_h -/** \class ObjectPairFilter - * - * Filters an event if one or more pairs of objects passes a given selection - * - * \author Luca Lista, INFN - * - * \version $Revision: 1.3 $ - * - * $Id: ObjectPairFilter.h,v 1.3 2010/02/20 20:55:26 wmtan Exp $ - * - */ - -#include "FWCore/Framework/interface/EDFilter.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" -#include -#include - -template -class ObjectPairFilter : public edm::EDFilter { -public: - /// constructor - explicit ObjectPairFilter( const edm::ParameterSet & cfg ) : - select_( reco::modules::make( cfg ) ), - srcToken_( consumes( cfg.template getParameter( "src" ) ) ), - minNumber_( 1 ) { - std::vector ints = cfg.template getParameterNamesForType(); - const std::string minNumber( "minNumber" ); - bool foundMinNumber = std::find( ints.begin(), ints.end(), minNumber ) != ints.end(); - if ( foundMinNumber ) - minNumber_ = cfg.template getParameter( minNumber ); - } - -private: - /// process one event - bool filter( edm::Event& evt, const edm::EventSetup&) override { - edm::Handle source; - evt.getByToken( srcToken_, source ); - size_t n = 0; - for( typename C::const_iterator i = source->begin(); i != source->end(); ++ i ) - for( typename C::const_iterator j = i + 1; j != source->end(); ++ j ) { - if ( select_( * i, * j ) ) n ++; - if ( n >= minNumber_ ) return true; - } - return false; - } - /// object filter - S select_; - /// source collection label - edm::EDGetTokenT srcToken_; - /// minimum number of entries in a collection - unsigned int minNumber_; -}; - -#endif - diff --git a/CommonTools/UtilAlgos/interface/ObjectRefVectorSelector.h b/CommonTools/UtilAlgos/interface/ObjectRefVectorSelector.h deleted file mode 100755 index 0537972897fcc..0000000000000 --- a/CommonTools/UtilAlgos/interface/ObjectRefVectorSelector.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CandAlgos_ObjectRefVectorSelector_h -#define CandAlgos_ObjectRefVectorSelector_h -/* \class RefVectorRefVectorStoreMananger - * - * \author Luca Lista, INFN - * - */ -#include "CommonTools/UtilAlgos/interface/ObjectSelector.h" -#include "DataFormats/Common/interface/RefVector.h" - -template, - typename SizeSelector = NonNullNumberSelector, - typename PostProcessor = helper::NullPostProcessor > -class ObjectRefVectorSelector : - public ObjectSelector { -public: - explicit ObjectRefVectorSelector( const edm::ParameterSet & cfg ) : - ObjectSelector( cfg ) { } -}; - -#endif - diff --git a/CommonTools/UtilAlgos/interface/OrPairSelector.h b/CommonTools/UtilAlgos/interface/OrPairSelector.h deleted file mode 100755 index afea4fecf1847..0000000000000 --- a/CommonTools/UtilAlgos/interface/OrPairSelector.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef UtilAlgos_OrPairSelector_h -#define UtilAlgos_OrPairSelector_h -#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" -#include "CommonTools/Utils/interface/OrPairSelector.h" - -namespace reco { - namespace modules { - - template - struct ParameterAdapter > { - static OrPairSelector make(const edm::ParameterSet & cfg) { - return OrPairSelector(modules::make(cfg.getParameter("cut1")), - modules::make(cfg.getParameter("cut2"))); - } - }; - - } -} - -#endif - diff --git a/CommonTools/Utils/interface/Angle.h b/CommonTools/Utils/interface/Angle.h deleted file mode 100644 index baf9889550e9a..0000000000000 --- a/CommonTools/Utils/interface/Angle.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CommonTools_Utils_Angle_h -#define CommonTools_Utils_Angle_h - -/* \class Angle - * - * returns three-dimensional Angle between two objects; - * defined via scalar product: - * angle = acos((v1 * v2)/(|v1| * |v2|)) - * - * \author Christian Veelken, UC Davis - */ - -#include "DataFormats/Math/interface/LorentzVector.h" -#include "DataFormats/Math/interface/angle.h" - -template -struct Angle { - double operator()( const T1 & t1, const T2 & t2 ) const { - return angle( t1, t2 ); - } -}; - -#endif diff --git a/CommonTools/Utils/interface/InvariantMass.h b/CommonTools/Utils/interface/InvariantMass.h deleted file mode 100755 index 52b1c3500c095..0000000000000 --- a/CommonTools/Utils/interface/InvariantMass.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CommonTools_Utils_InvariantMass_h -#define CommonTools_Utils_InvariantMass_h -#include "DataFormats/Math/interface/LorentzVector.h" - -template -struct InvariantMass { - double operator()( const T1 & t1, const T2 & t2 ) const { - return ( t1.momentum() + t2.momentum() ).mass(); - } -}; - -#endif diff --git a/CommonTools/Utils/interface/LazyResult.h b/CommonTools/Utils/interface/LazyResult.h deleted file mode 100644 index e15dc6afd1cf2..0000000000000 --- a/CommonTools/Utils/interface/LazyResult.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef CommonTools_Utils_LazyResult_h -#define CommonTools_Utils_LazyResult_h -// -*- C++ -*- -// -// Package: CommonTools/Utils -// Class : LazyResult -// -/**\class LazyResult LazyResult.h "CommonTools/Utils/interface/LazyResult.h" - Description: Wrapper around a function call for lazy execution. - - Usage: - // example: lazy addition - auto result = LazyResult(std::plus, x, x); - std::cout << result.value() << std::endl; - -Notes: - * The arguments for the delayed call are stored by reference (watch their - lifetime). - * The overhead in memory compared to just storing the result is small: one - reference per argument, one bool flag and a function pointer (on my system: - 1 byte for lambda function, 8 bytes for global function and 16 bytes for - member function due to possible index to virtual table). - -Implementation: - - * For the Args... we explicitly add const& (also in the the args_ tuple). - Otherwise, the arguments will be stored by value which comes with too much - overhead. This implies that the lifetime of the arguments passed to - LazyResult neet to live longer than the LazyResult instance. Function pointers - are small, so no need for const& to the Func. - * An alternative to using a ::value() member function to get the result could - be a cast operator: operator Result const &(). This might be pretty because - the result is automatically evaluated the first time you try to bind it to - a Result const &. I think this would however be too implicit and dangerous. - -*/ -// -// Original Author: Jonas Rembser -// Created: Mon, 14 Jun 2020 00:00:00 GMT -// - -#include -#include - -template -class LazyResult { -public: - using Result = typename std::invoke_result::type; - - LazyResult(Func func, Args const&... args) : func_(func), args_(args...) {} - - Result const& value() { - if (!evaluated_) { - evaluate(); - } - return result_; - } - -private: - void evaluate() { evaluateImpl(std::make_index_sequence{}); } - - template - void evaluateImpl(std::index_sequence) { - result_ = func_(std::get(args_)...); - evaluated_ = true; - } - - // having evaluated_ and the potentially small func_ together might - // save alignemnt bits (e.g. a lambda function is just 1 byte) - bool evaluated_ = false; - Func func_; - std::tuple args_; - Result result_; -}; - -#endif diff --git a/CommonTools/Utils/interface/MassMinSelector.h b/CommonTools/Utils/interface/MassMinSelector.h deleted file mode 100755 index 8a8bdc2099199..0000000000000 --- a/CommonTools/Utils/interface/MassMinSelector.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RecoAlgos_MassMinSelector_h -#define RecoAlgos_MassMinSelector_h -/* \class MassMinSelector - * - * \author Luca Lista, INFN - * - * $Id: MassMinSelector.h,v 1.1 2007/07/12 08:30:40 llista Exp $ - */ - -struct MassMinSelector { - MassMinSelector( double massMin ) : - massMin_( massMin ) { } - template - bool operator()( const T & t ) const { - return t.mass() >= massMin_; - } - -private: - double massMin_; -}; - -#endif diff --git a/CommonTools/Utils/interface/MassRangeSelector.h b/CommonTools/Utils/interface/MassRangeSelector.h deleted file mode 100755 index c4b68f3342690..0000000000000 --- a/CommonTools/Utils/interface/MassRangeSelector.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef RecoAlgos_MassRangeSelector_h -#define RecoAlgos_MassRangeSelector_h -/* \class MassRangeSelector - * - * \author Luca Lista, INFN - * - * $Id: MassRangeSelector.h,v 1.3 2007/06/18 18:33:53 llista Exp $ - */ - -struct MassRangeSelector { - MassRangeSelector( double massMin, double massMax ) : - massMin_( massMin ), massMax_( massMax ) { } - template - bool operator()( const T & t ) const { - double mass = t.mass(); - return ( mass >= massMin_ && mass <= massMax_ ); - } - -private: - double massMin_, massMax_; -}; - -#endif diff --git a/CommonTools/Utils/interface/MinSelector.h b/CommonTools/Utils/interface/MinSelector.h deleted file mode 100755 index 14e2fa5b23c3d..0000000000000 --- a/CommonTools/Utils/interface/MinSelector.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RecoAlgos_MinSelector_h -#define RecoAlgos_MinSelector_h -/* \class MinSelector - * - * \author Luca Lista, INFN - * - * $Id: MinSelector.h,v 1.1 2009/02/24 14:40:26 llista Exp $ - */ - -template -struct MinSelector { - MinSelector( T min ) : min_( min ) { } - bool operator()( T t ) const { return t >= min_; } - -private: - T min_; -}; - -#endif diff --git a/CommonTools/Utils/interface/OrPairSelector.h b/CommonTools/Utils/interface/OrPairSelector.h deleted file mode 100755 index 2619ee3378a2c..0000000000000 --- a/CommonTools/Utils/interface/OrPairSelector.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CommonTools_Utils_OrPairSelector_h -#define CommonTools_Utils_OrPairSelector_h -/* \class OrPairSelector - * - * \author Luca Lista, INFN - * - * $Id: OrPairSelector.h,v 1.1 2009/02/24 14:40:26 llista Exp $ - */ - -template -struct OrPairSelector { - OrPairSelector(const S1 & s1, const S2 & s2) : s1_(s1), s2_(s2) { } - template - bool operator()(const T1 & t1, const T2 & t2) const { - return s1_(t1) || s2_(t2); - } -private: - S1 s1_; - S2 s2_; -}; - -#endif From 4c277aa8bcd657bd10e6bcb5a514ad5232567d0b Mon Sep 17 00:00:00 2001 From: yuanchao Date: Fri, 20 Aug 2021 18:56:41 +0800 Subject: [PATCH 2/4] recover some headers as requested by Joosep Pata --- CommonTools/UtilAlgos/interface/MinSelector.h | 20 +++++ .../UtilAlgos/interface/OrPairSelector.h | 21 +++++ CommonTools/Utils/interface/LazyResult.h | 76 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100755 CommonTools/UtilAlgos/interface/MinSelector.h create mode 100755 CommonTools/UtilAlgos/interface/OrPairSelector.h create mode 100644 CommonTools/Utils/interface/LazyResult.h diff --git a/CommonTools/UtilAlgos/interface/MinSelector.h b/CommonTools/UtilAlgos/interface/MinSelector.h new file mode 100755 index 0000000000000..efa3d22ccca5d --- /dev/null +++ b/CommonTools/UtilAlgos/interface/MinSelector.h @@ -0,0 +1,20 @@ +#ifndef UtilAlgos_MinSelector_h +#define UtilAlgos_MinSelector_h +#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" +#include "CommonTools/Utils/interface/MinSelector.h" + +namespace reco { + namespace modules { + + template + struct ParameterAdapter > { + static MinSelector make( const edm::ParameterSet & cfg ) { + return MinSelector( cfg.template getParameter( "min" ) ); + } + }; + + } +} + +#endif + diff --git a/CommonTools/UtilAlgos/interface/OrPairSelector.h b/CommonTools/UtilAlgos/interface/OrPairSelector.h new file mode 100755 index 0000000000000..afea4fecf1847 --- /dev/null +++ b/CommonTools/UtilAlgos/interface/OrPairSelector.h @@ -0,0 +1,21 @@ +#ifndef UtilAlgos_OrPairSelector_h +#define UtilAlgos_OrPairSelector_h +#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" +#include "CommonTools/Utils/interface/OrPairSelector.h" + +namespace reco { + namespace modules { + + template + struct ParameterAdapter > { + static OrPairSelector make(const edm::ParameterSet & cfg) { + return OrPairSelector(modules::make(cfg.getParameter("cut1")), + modules::make(cfg.getParameter("cut2"))); + } + }; + + } +} + +#endif + diff --git a/CommonTools/Utils/interface/LazyResult.h b/CommonTools/Utils/interface/LazyResult.h new file mode 100644 index 0000000000000..e15dc6afd1cf2 --- /dev/null +++ b/CommonTools/Utils/interface/LazyResult.h @@ -0,0 +1,76 @@ +#ifndef CommonTools_Utils_LazyResult_h +#define CommonTools_Utils_LazyResult_h +// -*- C++ -*- +// +// Package: CommonTools/Utils +// Class : LazyResult +// +/**\class LazyResult LazyResult.h "CommonTools/Utils/interface/LazyResult.h" + Description: Wrapper around a function call for lazy execution. + + Usage: + // example: lazy addition + auto result = LazyResult(std::plus, x, x); + std::cout << result.value() << std::endl; + +Notes: + * The arguments for the delayed call are stored by reference (watch their + lifetime). + * The overhead in memory compared to just storing the result is small: one + reference per argument, one bool flag and a function pointer (on my system: + 1 byte for lambda function, 8 bytes for global function and 16 bytes for + member function due to possible index to virtual table). + +Implementation: + + * For the Args... we explicitly add const& (also in the the args_ tuple). + Otherwise, the arguments will be stored by value which comes with too much + overhead. This implies that the lifetime of the arguments passed to + LazyResult neet to live longer than the LazyResult instance. Function pointers + are small, so no need for const& to the Func. + * An alternative to using a ::value() member function to get the result could + be a cast operator: operator Result const &(). This might be pretty because + the result is automatically evaluated the first time you try to bind it to + a Result const &. I think this would however be too implicit and dangerous. + +*/ +// +// Original Author: Jonas Rembser +// Created: Mon, 14 Jun 2020 00:00:00 GMT +// + +#include +#include + +template +class LazyResult { +public: + using Result = typename std::invoke_result::type; + + LazyResult(Func func, Args const&... args) : func_(func), args_(args...) {} + + Result const& value() { + if (!evaluated_) { + evaluate(); + } + return result_; + } + +private: + void evaluate() { evaluateImpl(std::make_index_sequence{}); } + + template + void evaluateImpl(std::index_sequence) { + result_ = func_(std::get(args_)...); + evaluated_ = true; + } + + // having evaluated_ and the potentially small func_ together might + // save alignemnt bits (e.g. a lambda function is just 1 byte) + bool evaluated_ = false; + Func func_; + std::tuple args_; + Result result_; +}; + +#endif From 74f57dd04426590055737390256c059dbd26fa72 Mon Sep 17 00:00:00 2001 From: yuanchao Date: Fri, 20 Aug 2021 19:02:48 +0800 Subject: [PATCH 3/4] recover some headers as requested by Joosep Pata --- CommonTools/Utils/interface/MinSelector.h | 19 +++++++++++++++++ CommonTools/Utils/interface/OrPairSelector.h | 22 ++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 CommonTools/Utils/interface/MinSelector.h create mode 100755 CommonTools/Utils/interface/OrPairSelector.h diff --git a/CommonTools/Utils/interface/MinSelector.h b/CommonTools/Utils/interface/MinSelector.h new file mode 100755 index 0000000000000..14e2fa5b23c3d --- /dev/null +++ b/CommonTools/Utils/interface/MinSelector.h @@ -0,0 +1,19 @@ +#ifndef RecoAlgos_MinSelector_h +#define RecoAlgos_MinSelector_h +/* \class MinSelector + * + * \author Luca Lista, INFN + * + * $Id: MinSelector.h,v 1.1 2009/02/24 14:40:26 llista Exp $ + */ + +template +struct MinSelector { + MinSelector( T min ) : min_( min ) { } + bool operator()( T t ) const { return t >= min_; } + +private: + T min_; +}; + +#endif diff --git a/CommonTools/Utils/interface/OrPairSelector.h b/CommonTools/Utils/interface/OrPairSelector.h new file mode 100755 index 0000000000000..2619ee3378a2c --- /dev/null +++ b/CommonTools/Utils/interface/OrPairSelector.h @@ -0,0 +1,22 @@ +#ifndef CommonTools_Utils_OrPairSelector_h +#define CommonTools_Utils_OrPairSelector_h +/* \class OrPairSelector + * + * \author Luca Lista, INFN + * + * $Id: OrPairSelector.h,v 1.1 2009/02/24 14:40:26 llista Exp $ + */ + +template +struct OrPairSelector { + OrPairSelector(const S1 & s1, const S2 & s2) : s1_(s1), s2_(s2) { } + template + bool operator()(const T1 & t1, const T2 & t2) const { + return s1_(t1) || s2_(t2); + } +private: + S1 s1_; + S2 s2_; +}; + +#endif From 06c1e3ee5022541e1369ae8d5a7e7d302df25294 Mon Sep 17 00:00:00 2001 From: yuanchao Date: Fri, 20 Aug 2021 20:23:59 +0800 Subject: [PATCH 4/4] fixed code check errors on altered files --- CommonTools/UtilAlgos/interface/MinSelector.h | 13 ++++++------- CommonTools/UtilAlgos/interface/OrPairSelector.h | 15 +++++++-------- CommonTools/Utils/interface/MinSelector.h | 6 +++--- CommonTools/Utils/interface/OrPairSelector.h | 9 +++++---- 4 files changed, 21 insertions(+), 22 deletions(-) mode change 100755 => 100644 CommonTools/UtilAlgos/interface/MinSelector.h mode change 100755 => 100644 CommonTools/UtilAlgos/interface/OrPairSelector.h mode change 100755 => 100644 CommonTools/Utils/interface/MinSelector.h mode change 100755 => 100644 CommonTools/Utils/interface/OrPairSelector.h diff --git a/CommonTools/UtilAlgos/interface/MinSelector.h b/CommonTools/UtilAlgos/interface/MinSelector.h old mode 100755 new mode 100644 index efa3d22ccca5d..c92b27faa991c --- a/CommonTools/UtilAlgos/interface/MinSelector.h +++ b/CommonTools/UtilAlgos/interface/MinSelector.h @@ -5,16 +5,15 @@ namespace reco { namespace modules { - - template + + template struct ParameterAdapter > { - static MinSelector make( const edm::ParameterSet & cfg ) { - return MinSelector( cfg.template getParameter( "min" ) ); + static MinSelector make(const edm::ParameterSet& cfg) { + return MinSelector(cfg.template getParameter("min")); } }; - } -} + } // namespace modules +} // namespace reco #endif - diff --git a/CommonTools/UtilAlgos/interface/OrPairSelector.h b/CommonTools/UtilAlgos/interface/OrPairSelector.h old mode 100755 new mode 100644 index afea4fecf1847..8b87a4ccdabf1 --- a/CommonTools/UtilAlgos/interface/OrPairSelector.h +++ b/CommonTools/UtilAlgos/interface/OrPairSelector.h @@ -5,17 +5,16 @@ namespace reco { namespace modules { - - template + + template struct ParameterAdapter > { - static OrPairSelector make(const edm::ParameterSet & cfg) { - return OrPairSelector(modules::make(cfg.getParameter("cut1")), - modules::make(cfg.getParameter("cut2"))); + static OrPairSelector make(const edm::ParameterSet& cfg) { + return OrPairSelector(modules::make(cfg.getParameter("cut1")), + modules::make(cfg.getParameter("cut2"))); } }; - } -} + } // namespace modules +} // namespace reco #endif - diff --git a/CommonTools/Utils/interface/MinSelector.h b/CommonTools/Utils/interface/MinSelector.h old mode 100755 new mode 100644 index 14e2fa5b23c3d..810932963e388 --- a/CommonTools/Utils/interface/MinSelector.h +++ b/CommonTools/Utils/interface/MinSelector.h @@ -7,10 +7,10 @@ * $Id: MinSelector.h,v 1.1 2009/02/24 14:40:26 llista Exp $ */ -template +template struct MinSelector { - MinSelector( T min ) : min_( min ) { } - bool operator()( T t ) const { return t >= min_; } + MinSelector(T min) : min_(min) {} + bool operator()(T t) const { return t >= min_; } private: T min_; diff --git a/CommonTools/Utils/interface/OrPairSelector.h b/CommonTools/Utils/interface/OrPairSelector.h old mode 100755 new mode 100644 index 2619ee3378a2c..afdd6da046a0f --- a/CommonTools/Utils/interface/OrPairSelector.h +++ b/CommonTools/Utils/interface/OrPairSelector.h @@ -7,13 +7,14 @@ * $Id: OrPairSelector.h,v 1.1 2009/02/24 14:40:26 llista Exp $ */ -template +template struct OrPairSelector { - OrPairSelector(const S1 & s1, const S2 & s2) : s1_(s1), s2_(s2) { } - template - bool operator()(const T1 & t1, const T2 & t2) const { + OrPairSelector(const S1& s1, const S2& s2) : s1_(s1), s2_(s2) {} + template + bool operator()(const T1& t1, const T2& t2) const { return s1_(t1) || s2_(t2); } + private: S1 s1_; S2 s2_;