CMS 3D CMS Logo

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 } // namespace helper
33 
34 namespace reco {
35  namespace modulesNew {
36 
37  template <typename C1,
38  typename C2,
39  typename Alg,
43  public:
45  ~IsolationProducer() override;
46 
47  private:
48  void produce(edm::Event&, const edm::EventSetup&) override;
51  Alg alg_;
52  };
53 
54  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
56  : srcToken_(consumes<C1>(cfg.template getParameter<edm::InputTag>("src"))),
57  elementsToken_(consumes<C2>(cfg.template getParameter<edm::InputTag>("elements"))),
58  alg_(reco::modules::make<Alg>(cfg)) {
59  produces<OutputCollection>();
60  }
61 
62  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
64 
65  template <typename C1, typename C2, typename Alg, typename OutputCollection, typename Setup>
67  using namespace edm;
68  using namespace std;
71  evt.getByToken(srcToken_, src);
72  evt.getByToken(elementsToken_, elements);
73 
74  Setup::init(alg_, es);
75 
76  ::helper::MasterCollection<C1> master(src, evt);
77  auto isolations = std::make_unique<OutputCollection>();
78  if (!src->empty()) {
79  typename OutputCollection::Filler filler(*isolations);
80  vector<double> iso(master.size(), -1);
81  size_t i = 0;
82  for (typename C1::const_iterator lep = src->begin(); lep != src->end(); ++lep)
83  iso[master.index(i++)] = alg_(*lep, *elements);
84  filler.insert(master.get(), iso.begin(), iso.end());
85  filler.fill();
86  }
87  evt.put(std::move(isolations));
88  }
89 
90  } // namespace modulesNew
91 } // namespace reco
92 
93 #endif
Handle.h
init
int init
Definition: HydjetWrapper.h:64
mps_fire.i
i
Definition: mps_fire.py:428
reco::modulesNew::IsolationProducer::IsolationProducer
IsolationProducer(const edm::ParameterSet &)
Definition: IsolationProducerNew.h:55
EDProducer.h
modules
Definition: ZHLTMatchFilter.cc:17
reco::modulesNew::IsolationProducer
Definition: IsolationProducerNew.h:42
edm::EDGetTokenT< C1 >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
bmtfDigis_cfi.Setup
Setup
Definition: bmtfDigis_cfi.py:5
reco::modulesNew::IsolationProducer::alg_
Alg alg_
Definition: IsolationProducerNew.h:51
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
helper::IsolationAlgorithmSetup
Definition: IsolationProducer.h:28
edm::Handle< C1 >
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
edm::ParameterSet
Definition: ParameterSet.h:47
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
MasterCollectionHelper.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
helper::NullIsolationAlgorithmSetup::init
static void init(Alg &, const edm::EventSetup &)
Definition: IsolationProducerNew.h:25
helper
Definition: helper.py:1
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup
Definition: EventSetup.h:57
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
helper::NullIsolationAlgorithmSetup
Definition: IsolationProducer.h:23
helper::IsolationAlgorithmSetup::type
NullIsolationAlgorithmSetup< Alg > type
Definition: IsolationProducerNew.h:30
reco::modulesNew::IsolationProducer::srcToken_
edm::EDGetTokenT< C1 > srcToken_
Definition: IsolationProducerNew.h:49
reco::modules::make
S make(const edm::ParameterSet &cfg)
Definition: ParameterAdapter.h:21
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
ValueMap.h
bookConverter.elements
elements
Definition: bookConverter.py:147
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::ValueMap< float >
reco::modulesNew::IsolationProducer::elementsToken_
edm::EDGetTokenT< C2 > elementsToken_
Definition: IsolationProducerNew.h:50
ParameterSetfwd.h
edm::EDProducer
Definition: EDProducer.h:35
ParameterAdapter.h
ParameterSet.h
reco::modulesNew::IsolationProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: IsolationProducerNew.h:66
volumeBasedMagneticField_160812_cfi.master
master
Definition: volumeBasedMagneticField_160812_cfi.py:60
edm::Event
Definition: Event.h:73
HLTTauReferences_cfi.OutputCollection
OutputCollection
Definition: HLTTauReferences_cfi.py:92
reco::modulesNew::IsolationProducer::~IsolationProducer
~IsolationProducer() override
Definition: IsolationProducerNew.h:63