ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ForwardAnalysis/Utilities/interface/OneToManySelector.h
Revision: 1.3
Committed: Thu Aug 4 18:03:59 2011 UTC (13 years, 9 months ago) by antoniov
Content type: text/plain
Branch: MAIN
Changes since 1.2: +10 -4 lines
Log Message:
add selector function

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 antoniov 1.3 #include "CommonTools/UtilAlgos/interface/AnySelector.h"
9 antoniov 1.1
10     namespace forwardAnalysis {
11    
12 antoniov 1.3 template <class Object, class Coll,
13     class PairSelector=AnyPairSelector, class S1=AnySelector, class S2=AnySelector>
14 antoniov 1.1 class OneToManySelector {
15     public:
16     OneToManySelector(edm::ParameterSet const& pset):
17 antoniov 1.3 src_( pset.template getParameter<edm::InputTag>("src") ),
18     selector_( reco::modules::make<PairSelector>(pset) ),
19     s1_( reco::modules::make<S1>(pset) ),
20     s2_( reco::modules::make<S2>(pset) ) {}
21 antoniov 1.1
22     ~OneToManySelector() {}
23    
24 antoniov 1.2 bool operator() (Object const& obj, edm::Event const& event){
25 antoniov 1.1 edm::Handle<Coll> source;
26     event.getByLabel(src_,source);
27     typename Coll::const_iterator cand = source->begin(), source_end = source->end();
28     bool result = true;
29     for(; cand != source_end; ++cand){
30 antoniov 1.3 if( !s1_(obj) || !s2_(*cand) || !selector_(obj,*cand) ) { result = false; break; }
31 antoniov 1.1 }
32     return result;
33     }
34    
35     private:
36     edm::InputTag src_;
37     PairSelector selector_;
38 antoniov 1.3 S1 s1_;
39     S2 s2_;
40 antoniov 1.1 };
41    
42     } // namespace
43    
44     #endif