ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DGele/PhysicsTools/PatAlgos/interface/MultiIsolator.h
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Oct 20 17:15:14 2009 UTC (15 years, 6 months ago) by dgele
Content type: text/plain
Branch: ANA
CVS Tags: start
Changes since 1.1: +0 -0 lines
Log Message:
version CMSSW_2_2_10

File Contents

# User Rev Content
1 dgele 1.1 #ifndef PhysicsTools_PatAlgos_interface_MultiIsolator_h
2     #define PhysicsTools_PatAlgos_interface_MultiIsolator_h
3    
4     #include "DataFormats/Common/interface/View.h"
5     #include "FWCore/ParameterSet/interface/ParameterSet.h"
6     #include "FWCore/Framework/interface/Event.h"
7    
8     #include "PhysicsTools/PatAlgos/interface/BaseIsolator.h"
9     #include "boost/ptr_container/ptr_vector.hpp"
10    
11     #include "DataFormats/PatCandidates/interface/Isolation.h"
12    
13     namespace pat { namespace helper {
14     class MultiIsolator {
15     public:
16     typedef std::vector<std::pair<pat::IsolationKeys,float> > IsolationValuePairs;
17     MultiIsolator() {}
18     MultiIsolator(const edm::ParameterSet &conf, bool cuts=true) ;
19     ~MultiIsolator() {}
20    
21     // adds an isolator (and takes onwership of the pointer)
22     void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key) ;
23    
24     // parses an isolator and adds it to the list
25     void addIsolator(const edm::ParameterSet &conf, bool withCut, uint32_t mask, pat::IsolationKeys key) ;
26    
27     // Parses out an isolator, and returns a pointer to it.
28     // For an empty PSet, it returns a null pointer.
29     // You own the returned pointer!
30     static BaseIsolator * make(const edm::ParameterSet &conf, bool withCut) ;
31    
32     void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup);
33     void endEvent() ;
34    
35     template<typename T>
36     uint32_t test(const edm::View<T> &coll, int idx) const;
37    
38     template<typename T>
39     void fill(const edm::View<T> &coll, int idx, IsolationValuePairs& isolations) const ;
40    
41     /// Fill Isolation from a Ref, Ptr or RefToBase to the object
42     template<typename RefType>
43     void fill(const RefType &ref, IsolationValuePairs& isolations) const ;
44    
45     void print(std::ostream &out) const ;
46    
47     std::string printSummary() const ;
48    
49     /// True if it has a non null configuration
50     bool enabled() const { return !isolators_.empty(); }
51     private:
52     boost::ptr_vector<BaseIsolator> isolators_;
53     std::vector<uint32_t> masks_;
54     std::vector<pat::IsolationKeys> keys_;
55     };
56    
57     template<typename T>
58     uint32_t
59     MultiIsolator::test(const edm::View<T> &coll, int idx) const {
60     uint32_t retval = 0;
61     edm::RefToBase<T> rb = coll.refAt(idx); // edm::Ptr<T> in a shiny new future to come one remote day ;-)
62     for (size_t i = 0, n = isolators_.size(); i < n; ++i) {
63     if (!isolators_[i].test(rb)) retval |= masks_[i];
64     }
65     return retval;
66     }
67    
68     template<typename RefType>
69     void
70     MultiIsolator::fill(const RefType &rb, IsolationValuePairs & isolations) const
71     {
72     isolations.resize(isolators_.size());
73     for (size_t i = 0, n = isolators_.size(); i < n; ++i) {
74     isolations[i].first = keys_[i];
75     isolations[i].second = isolators_[i].getValue(rb);
76     }
77     }
78    
79    
80     template<typename T>
81     void
82     MultiIsolator::fill(const edm::View<T> &coll, int idx, IsolationValuePairs & isolations) const
83     {
84     edm::RefToBase<T> rb = coll.refAt(idx);
85     fill(rb, isolations);
86     }
87    
88     }} // namespace
89    
90     #endif
91