CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsolationProducerNew.h
Go to the documentation of this file.
1 #ifndef IsolationAlgos_IsolationProducer_h
2 #define IsolationAlgos_IsolationProducer_h
3 /* \class IsolationProducer<C1, C2, Algo>
4  *
5  * \author Francesco Fabozzi, INFN
6  *
7  * template class to store isolation
8  *
9  */
19 #include <vector>
20 
21 namespace helper {
22 
23  template<typename Alg>
24  struct NullIsolationAlgorithmSetup {
25  static void init( Alg &, const edm::EventSetup& ) { }
26  };
27 
28  template<typename Alg>
29  struct IsolationAlgorithmSetup {
31  };
32 }
33 
34 namespace reco {
35  namespace modulesNew {
36 
37  template <typename C1, typename C2, typename Alg,
38  typename OutputCollection = edm::ValueMap<float>,
41  public:
44 
45  private:
46  void produce( edm::Event&, const edm::EventSetup& );
49  Alg alg_;
50  };
51 
52  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
54  srcToken_( consumes<C1>( cfg.template getParameter<edm::InputTag>( "src" ) ) ),
55  elementsToken_( consumes<C2>( cfg.template getParameter<edm::InputTag>( "elements" ) ) ),
56  alg_( reco::modules::make<Alg>( cfg ) ) {
57  produces<OutputCollection>();
58  }
59 
60  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
62  }
63 
64  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
66  using namespace edm;
67  using namespace std;
70  evt.getByToken( srcToken_, src );
71  evt.getByToken( elementsToken_, elements );
72 
73  Setup::init(alg_, es);
74 
76  auto_ptr<OutputCollection> isolations(new OutputCollection);
77  if(src->size()!= 0) {
78  typename OutputCollection::Filler filler(*isolations);
79  vector<double> iso(master.size(),-1);
80  size_t i = 0;
81  for( typename C1::const_iterator lep = src->begin(); lep != src->end(); ++ lep )
82  iso[master.index(i++)] = alg_(*lep, *elements);
83  filler.insert(master.get(), iso.begin(), iso.end());
84  filler.fill();
85  }
86  evt.put( isolations );
87  }
88 
89  }
90 }
91 
92 #endif
const edm::Handle< C1 > & get() const
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:259
static void init(Alg &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
int init
Definition: HydjetWrapper.h:62
S make(const edm::ParameterSet &cfg)
list elements
Definition: asciidump.py:414
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
size_t index(size_t i) const
void produce(edm::Event &, const edm::EventSetup &)
IsolationProducer(const edm::ParameterSet &)
NullIsolationAlgorithmSetup< Alg > type
def template
Definition: svgfig.py:520