CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  }
62 }
63 
64 template<typename TColl, typename CColl, typename Selector = AnySelector,
66  typename Creator = typename converter::helper::CandCreator<CColl>::type,
69 public:
72  srcToken_(consumes<TColl>(cfg.template getParameter<edm::InputTag>("src"))),
73  converter_(cfg),
76  produces<CColl>();
77  }
80 
81 private:
83  void beginRun(const edm::Run&, const edm::EventSetup& es) override {
84  if (!initialized_) {
85  converter_.beginFirstRun(es);
86  initialized_ = true;
87  }
88  }
90  void produce(edm::Event& evt, const edm::EventSetup& es) override {
92  evt.getByToken(srcToken_, src);
93  Init::init(selector_, evt, es);
95  std::auto_ptr<CColl> cands(new CColl);
96  if(src->size()!= 0) {
97  size_t size = src->size();
98  cands->reserve(size);
99  for(size_t idx = 0; idx != size; ++ idx) {
100  if(selector_((*src)[idx]))
101  Creator::create(master.index(idx), *cands, master, converter_);
102  }
103  }
104  evt.put(cands);
105  }
114 };
115 
116 #endif
type
Definition: HCALResponse.h:21
void produce(edm::Event &evt, const edm::EventSetup &es) override
process one event
void beginRun(const edm::Run &, const edm::EventSetup &es) override
begin job (first run)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
bool initialized_
particles initialized?
CandidateProducer(const edm::ParameterSet &cfg)
constructor from parameter set
int init
Definition: HydjetWrapper.h:62
S make(const edm::ParameterSet &cfg)
static void create(size_t idx, CColl &cands, const Comp &components, Conv &converter)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Conv converter_
converter helper
Definition: CSCxTalk.h:5
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
size_t index(size_t i) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Selector selector_
selector
Functor that operates on &lt;T&gt;
Definition: Selector.h:24
static void create(size_t idx, CColl &cands, const Comp &components, Conv &converter)
~CandidateProducer()
destructor
edm::EDGetTokenT< TColl > srcToken_
label of source collection and tag
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
volatile std::atomic< bool > shutdown_flag false
edm::OwnVector< Candidate > CandidateCollection
collection of Candidate objects
Definition: CandidateFwd.h:21
SurfaceDeformation * create(int type, const std::vector< double > &params)
tuple size
Write out results.
def template
Definition: svgfig.py:520
Definition: Run.h:41