CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsolationProducer.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  */
18 #include <vector>
19 
20 namespace helper {
21 
22  template<typename Alg>
24  static void init( Alg &, const edm::EventSetup& ) { }
25  };
26 
27  template<typename Alg>
30  };
31 }
32 
33 template <typename C1, typename C2, typename Alg,
34  typename OutputCollection = edm::AssociationVector<edm::RefProd<C1>,
35  std::vector<typename Alg::value_type> >,
38 public:
41 
42 private:
43  void produce( edm::Event&, const edm::EventSetup& );
46  Alg alg_;
47 };
48 
49 template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
51  srcToken_( consumes<C1>( cfg.template getParameter<edm::InputTag>( "src" ) ) ),
52  elementsToken_( consumes<C2>( cfg.template getParameter<edm::InputTag>( "elements" ) ) ),
53  alg_( reco::modules::make<Alg>( cfg ) ) {
54  produces<OutputCollection>();
55 }
56 
57 template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
59 }
60 
61 template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
63  using namespace edm;
64  using namespace std;
67  evt.getByToken( srcToken_, src );
68  evt.getByToken( elementsToken_, elements );
69 
70  Setup::init( alg_, es );
71 
72  typename OutputCollection::refprod_type ref( src );
73  auto_ptr<OutputCollection> isolations( new OutputCollection( ref ) );
74 
75  size_t i = 0;
76  for( typename C1::const_iterator lep = src->begin(); lep != src->end(); ++ lep ) {
77  typename Alg::value_type iso= alg_(*lep,*elements);
78  isolations->setValue( i++, iso );
79  }
80  evt.put( isolations );
81 }
82 
83 #endif
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
edm::EDGetTokenT< C1 > srcToken_
Container::value_type value_type
void produce(edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< C2 > elementsToken_
IsolationProducer(const edm::ParameterSet &)
NullIsolationAlgorithmSetup< Alg > type
def template
Definition: svgfig.py:520