CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NtpProducer.h
Go to the documentation of this file.
1 #ifndef UtilAlgos_NtpProducer_h
2 #define UtilAlgos_NtpProducer_h
3 
18 
19 template<typename C>
20 class NtpProducer : public edm::EDProducer {
21 public:
25  ~NtpProducer();
26 
27 protected:
29  virtual void produce( edm::Event&, const edm::EventSetup& );
30 
31 private:
35  std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > > tags_;
36 };
37 
38 template<typename C>
40  src_( par.template getParameter<edm::InputTag>( "src" ) ) {
41  std::vector<edm::ParameterSet> variables =
42  par.template getParameter<std::vector<edm::ParameterSet> >("variables");
43  std::vector<edm::ParameterSet>::const_iterator
44  q = variables.begin(), end = variables.end();
45  for (; q!=end; ++q) {
46  std::string tag = q->getUntrackedParameter<std::string>("tag");
47  StringObjectFunction<typename C::value_type> quantity(q->getUntrackedParameter<std::string>("quantity"));
48  tags_.push_back(std::make_pair(tag, quantity));
49  produces<std::vector<float> >(tag).setBranchAlias(tag);
50  }
51 }
52 
53 template<typename C>
55 }
56 
57 template<typename C>
60  iEvent.getByLabel(src_, coll);
61 
62  typename std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > >::const_iterator
63  q = tags_.begin(), end = tags_.end();
64  for(;q!=end; ++q) {
65  std::auto_ptr<std::vector<float> > x(new std::vector<float>);
66  x->reserve(coll->size());
67  for (typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem ) {
68  x->push_back(q->second(*elem));
69  }
70  iEvent.put(x, q->first);
71  }
72 }
73 
74 #endif
edm::InputTag src_
label of the collection to be read in
Definition: NtpProducer.h:33
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
#define end
Definition: vmac.h:38
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
JetCorrectorParametersCollection coll
Definition: classes.h:14
std::vector< std::pair< std::string, StringObjectFunction< typename C::value_type > > > tags_
variable tags
Definition: NtpProducer.h:35
~NtpProducer()
destructor
Definition: NtpProducer.h:66
NtpProducer(const edm::ParameterSet &)
constructor from parameter set
Definition: NtpProducer.h:42
virtual void produce(edm::Event &, const edm::EventSetup &)
process an event
Definition: NtpProducer.h:70
x
Definition: VDTMath.h:216
def template
Definition: svgfig.py:520