CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 } // namespace helper
32 
33 template <typename C1,
34  typename C2,
35  typename Alg,
36  typename OutputCollection = edm::AssociationVector<edm::RefProd<C1>, std::vector<typename Alg::value_type> >,
39 public:
41  ~IsolationProducer() override;
42 
43 private:
44  void produce(edm::Event&, const edm::EventSetup&) override;
47  Alg alg_;
48 };
49 
50 template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
52  : srcToken_(consumes<C1>(cfg.template getParameter<edm::InputTag>("src"))),
53  elementsToken_(consumes<C2>(cfg.template getParameter<edm::InputTag>("elements"))),
54  alg_(reco::modules::make<Alg>(cfg)) {
55  produces<OutputCollection>();
56 }
57 
58 template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
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 isolations = std::make_unique<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(std::move(isolations));
81 }
82 
83 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
tuple cfg
Definition: looper.py:296
static void init(Alg &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
int init
Definition: HydjetWrapper.h:64
S make(const edm::ParameterSet &cfg)
dictionary elements
def move
Definition: eostools.py:511
edm::EDGetTokenT< C1 > srcToken_
~IsolationProducer() override
edm::EDGetTokenT< C2 > elementsToken_
IsolationProducer(const edm::ParameterSet &)
NullIsolationAlgorithmSetup< Alg > type
def template
Definition: svgfig.py:521
void produce(edm::Event &, const edm::EventSetup &) override