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 } // 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
Handle.h
init
int init
Definition: HydjetWrapper.h:64
mps_fire.i
i
Definition: mps_fire.py:355
EDProducer.h
IsolationProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: IsolationProducer.h:62
modules
Definition: ZHLTMatchFilter.cc:17
edm::EDGetTokenT< C1 >
edm
HLT enums.
Definition: AlignableModifier.h:19
bmtfDigis_cfi.Setup
Setup
Definition: bmtfDigis_cfi.py:5
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
helper::IsolationAlgorithmSetup
Definition: IsolationProducer.h:28
edm::Handle< C1 >
IsolationProducer::~IsolationProducer
~IsolationProducer() override
Definition: IsolationProducer.h:59
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
edm::AssociationVector
Definition: AssociationVector.h:67
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
IsolationProducer
Definition: IsolationProducer.h:38
helper::NullIsolationAlgorithmSetup::init
static void init(Alg &, const edm::EventSetup &)
Definition: IsolationProducer.h:24
helper
Definition: helper.py:1
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
IsolationProducer::alg_
Alg alg_
Definition: IsolationProducer.h:47
edm::EventSetup
Definition: EventSetup.h:57
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
helper::NullIsolationAlgorithmSetup
Definition: IsolationProducer.h:23
IsolationProducer::srcToken_
edm::EDGetTokenT< C1 > srcToken_
Definition: IsolationProducer.h:45
helper::IsolationAlgorithmSetup::type
NullIsolationAlgorithmSetup< Alg > type
Definition: IsolationProducer.h:29
reco::modules::make
S make(const edm::ParameterSet &cfg)
Definition: ParameterAdapter.h:21
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
bookConverter.elements
elements
Definition: bookConverter.py:147
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
IsolationProducer::IsolationProducer
IsolationProducer(const edm::ParameterSet &)
Definition: IsolationProducer.h:51
ParameterSetfwd.h
edm::EDProducer
Definition: EDProducer.h:36
IsolationProducer::elementsToken_
edm::EDGetTokenT< C2 > elementsToken_
Definition: IsolationProducer.h:46
ParameterAdapter.h
AssociationVector.h
ParameterSet.h
edm::Event
Definition: Event.h:73
HLTTauReferences_cfi.OutputCollection
OutputCollection
Definition: HLTTauReferences_cfi.py:92