CMS 3D CMS Logo

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> >,
36  typename Setup = typename helper::IsolationAlgorithmSetup<Alg>::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 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:122
Definition: helper.py:1
static void init(Alg &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
int init
Definition: HydjetWrapper.h:67
S make(const edm::ParameterSet &cfg)
edm::EDGetTokenT< C1 > srcToken_
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
void produce(edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< C2 > elementsToken_
fixed size matrix
HLT enums.
IsolationProducer(const edm::ParameterSet &)
NullIsolationAlgorithmSetup< Alg > type
def move(src, dest)
Definition: eostools.py:510