ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ForwardAnalysis/Utilities/interface/OneToManySelector.h
Revision: 1.1
Committed: Mon Nov 15 19:31:36 2010 UTC (14 years, 5 months ago) by antoniov
Content type: text/plain
Branch: MAIN
Log Message:
update

File Contents

# User Rev Content
1 antoniov 1.1 #ifndef ForwardAnalysis_Utilities_OneToManySelector_h
2     #define ForwardAnalysis_Utilities_OneToManySelector_h
3    
4     #include "FWCore/Framework/interface/Event.h"
5     #include "FWCore/ParameterSet/interface/ParameterSet.h"
6     #include "FWCore/Utilities/interface/InputTag.h"
7     #include "CommonTools/UtilAlgos/interface/AnyPairSelector.h"
8    
9     namespace forwardAnalysis {
10    
11     template <class Object, class Coll, class PairSelector=AnyPairSelector>
12     class OneToManySelector {
13     public:
14     OneToManySelector(edm::ParameterSet const& pset):
15     src_(pset.template getParameter<edm::InputTag>("src")),
16     selector_(reco::modules::make<PairSelector>(pset)) {}
17    
18     ~OneToManySelector() {}
19    
20     bool operator() (edm::Event const& event, Object const& obj){
21     edm::Handle<Coll> source;
22     event.getByLabel(src_,source);
23     typename Coll::const_iterator cand = source->begin(), source_end = source->end();
24     bool result = true;
25     for(; cand != source_end; ++cand){
26     if( !selector_(obj,*cand) ) { result = false; break; }
27     }
28     return result;
29     }
30    
31     private:
32     edm::InputTag src_;
33     PairSelector selector_;
34     };
35    
36     } // namespace
37    
38     #endif