CMS 3D CMS Logo

CandidateProducer.h
Go to the documentation of this file.
1 #ifndef RecoAlgos_CandidateProducer_h
2 #define RecoAlgos_CandidateProducer_h
3 
24 
25 namespace converter {
26  namespace helper {
27  template <typename T>
28  struct CandConverter {};
29 
30  struct ConcreteCreator {
31  template <typename CColl, typename Comp, typename Conv>
32  static void create(size_t idx, CColl& cands, const Comp& components, Conv& converter) {
33  typename Conv::Candidate c;
35  ref_type ref = components.template getConcreteRef<ref_type>(idx);
36  converter.convert(ref, c);
37  cands.push_back(c);
38  }
39  };
40 
42  template <typename CColl, typename Comp, typename Conv>
43  static void create(size_t idx, CColl& cands, const Comp& components, Conv& converter) {
44  typename Conv::Candidate* c = new typename Conv::Candidate;
46  ref_type ref = components.template getConcreteRef<ref_type>(idx);
47  converter.convert(ref, *c);
48  cands.push_back(c);
49  }
50  };
51 
52  template <typename CColl>
53  struct CandCreator {
55  };
56 
57  template <>
60  };
61  } // namespace helper
62 } // namespace converter
63 
64 template <typename TColl,
65  typename CColl,
66  typename Selector = AnySelector,
68  typename Creator = typename converter::helper::CandCreator<CColl>::type,
71 public:
74  : srcToken_(consumes<TColl>(cfg.template getParameter<edm::InputTag>("src"))),
75  converter_(cfg, consumesCollector()),
76  selectorInit_(consumesCollector()),
77  selector_(reco::modules::make<Selector>(cfg, consumesCollector())),
79  produces<CColl>();
80  }
82  ~CandidateProducer() override {}
83 
84 private:
86  void beginRun(const edm::Run&, const edm::EventSetup& es) override {
87  if (!initialized_) {
88  converter_.beginFirstRun(es);
89  initialized_ = true;
90  }
91  }
93  void produce(edm::Event& evt, const edm::EventSetup& es) override {
95  evt.getByToken(srcToken_, src);
96  selectorInit_.init(selector_, evt, es);
97  ::helper::MasterCollection<TColl> master(src, evt);
98  std::unique_ptr<CColl> cands(new CColl);
99  if (!src->empty()) {
100  size_t size = src->size();
101  cands->reserve(size);
102  for (size_t idx = 0; idx != size; ++idx) {
103  if (selector_((*src)[idx]))
105  }
106  }
107  evt.put(std::move(cands));
108  }
118 };
119 
120 #endif
size
Write out results.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Definition: helper.py:1
void produce(edm::Event &evt, const edm::EventSetup &es) override
process one event
def create(alignables, pedeDump, additionalData, outputFile, config)
void beginRun(const edm::Run &, const edm::EventSetup &es) override
begin job (first run)
bool initialized_
particles initialized?
CandidateProducer(const edm::ParameterSet &cfg)
constructor from parameter set
S make(const edm::ParameterSet &cfg)
static void create(size_t idx, CColl &cands, const Comp &components, Conv &converter)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Conv converter_
converter helper
Init selectorInit_
selector
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
Functor that operates on <T>
Definition: Selector.h:22
static void create(size_t idx, CColl &cands, const Comp &components, Conv &converter)
edm::EDGetTokenT< TColl > srcToken_
label of source collection and tag
fixed size matrix
HLT enums.
edm::OwnVector< Candidate > CandidateCollection
collection of Candidate objects
Definition: CandidateFwd.h:21
~CandidateProducer() override
destructor
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45