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),
76  selector_(reco::modules::make<Selector>(cfg, consumesCollector())),
78  produces<CColl>();
79  }
81  ~CandidateProducer() override {}
82 
83 private:
85  void beginRun(const edm::Run&, const edm::EventSetup& es) override {
86  if (!initialized_) {
87  converter_.beginFirstRun(es);
88  initialized_ = true;
89  }
90  }
92  void produce(edm::Event& evt, const edm::EventSetup& es) override {
94  evt.getByToken(srcToken_, src);
95  Init::init(selector_, evt, es);
96  ::helper::MasterCollection<TColl> master(src, evt);
97  std::unique_ptr<CColl> cands(new CColl);
98  if (!src->empty()) {
99  size_t size = src->size();
100  cands->reserve(size);
101  for (size_t idx = 0; idx != size; ++idx) {
102  if (selector_((*src)[idx]))
104  }
105  }
106  evt.put(std::move(cands));
107  }
116 };
117 
118 #endif
converter::helper::ConcreteCreator::create
static void create(size_t idx, CColl &cands, const Comp &components, Conv &converter)
Definition: CandidateProducer.h:32
Handle.h
Selector
Functor that operates on <T>
Definition: Selector.h:22
init
int init
Definition: HydjetWrapper.h:64
funct::false
false
Definition: Factorize.h:29
AnySelector
Definition: AnySelector.h:10
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
CandidateProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &es) override
begin job (first run)
Definition: CandidateProducer.h:85
converter
Definition: CandidateProducer.h:25
edm::Run
Definition: Run.h:45
modules
Definition: MuonCleanerBySegments.cc:35
edm::EDGetTokenT< TColl >
edm
HLT enums.
Definition: AlignableModifier.h:19
AnySelector.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
EDProducer.h
CandidateProducer::initialized_
bool initialized_
particles initialized?
Definition: CandidateProducer.h:115
CandidateProducer::produce
void produce(edm::Event &evt, const edm::EventSetup &es) override
process one event
Definition: CandidateProducer.h:92
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
EventSetupInitTrait.h
edm::Handle
Definition: AssociativeIterator.h:50
converter::helper::PolymorphicCreator::create
static void create(size_t idx, CColl &cands, const Comp &components, Conv &converter)
Definition: CandidateProducer.h:43
edm::Ref
Definition: AssociativeIterator.h:58
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
CandidateFwd.h
CandidateProducer::converter_
Conv converter_
converter helper
Definition: CandidateProducer.h:111
CandidateProducer::CandidateProducer
CandidateProducer(const edm::ParameterSet &cfg)
constructor from parameter set
Definition: CandidateProducer.h:73
converter::helper::CandCreator::type
ConcreteCreator type
Definition: CandidateProducer.h:54
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15144
edm::ParameterSet
Definition: ParameterSet.h:47
CandidateProducer::srcToken_
edm::EDGetTokenT< TColl > srcToken_
label of source collection and tag
Definition: CandidateProducer.h:109
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
MasterCollectionHelper.h
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
helper
Definition: helper.py:1
CandidateProducer::selector_
Selector selector_
selector
Definition: CandidateProducer.h:113
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::stream::EDProducer
Definition: EDProducer.h:38
converter::helper::ConcreteCreator
Definition: CandidateProducer.h:30
edm::EventSetup
Definition: EventSetup.h:58
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
reco::modules::make
S make(const edm::ParameterSet &cfg)
Definition: ParameterAdapter.h:21
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
makeMuonMisalignmentScenario.components
string components
Definition: makeMuonMisalignmentScenario.py:58
reco::CandidateCollection
edm::OwnVector< Candidate > CandidateCollection
collection of Candidate objects
Definition: CandidateFwd.h:21
CandidateProducer
Definition: CandidateProducer.h:70
Conv
Definition: CSCxTalk.h:5
ParameterSetfwd.h
converter::helper::PolymorphicCreator
Definition: CandidateProducer.h:41
converter::helper::CandConverter
Definition: CandidateProducer.h:28
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
converter::helper::CandCreator
Definition: CandidateProducer.h:53
volumeBasedMagneticField_160812_cfi.master
master
Definition: volumeBasedMagneticField_160812_cfi.py:60
edm::Event
Definition: Event.h:73
converter::helper::CandCreator< reco::CandidateCollection >::type
PolymorphicCreator type
Definition: CandidateProducer.h:59
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
CandidateProducer::~CandidateProducer
~CandidateProducer() override
destructor
Definition: CandidateProducer.h:81