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_;
37  std::string prefix_;
38  bool eventInfo_;
39 };
40 
41 template<typename C>
43  src_( par.template getParameter<edm::InputTag>( "src" ) ),
44  lazyParser_( par.template getUntrackedParameter<bool>( "lazyParser", false ) ),
45  prefix_( par.template getUntrackedParameter<std::string>( "prefix","" ) ),
46  eventInfo_( par.template getUntrackedParameter<bool>( "eventInfo",true ) ){
47  std::vector<edm::ParameterSet> variables =
48  par.template getParameter<std::vector<edm::ParameterSet> >("variables");
49  std::vector<edm::ParameterSet>::const_iterator
50  q = variables.begin(), end = variables.end();
51  if(eventInfo_){
52  produces<unsigned int>( prefix_+"EventNumber" ).setBranchAlias( prefix_ + "EventNumber" );
53  produces<unsigned int>( prefix_ + "RunNumber" ).setBranchAlias( prefix_ + "RunNumber" );
54  produces<unsigned int>( prefix_ + "LumiBlock" ).setBranchAlias( prefix_ + "Lumiblock" );
55  }
56  for (; q!=end; ++q) {
57  std::string tag = prefix_ + q->getUntrackedParameter<std::string>("tag");
58  StringObjectFunction<typename C::value_type> quantity(q->getUntrackedParameter<std::string>("quantity"), lazyParser_);
59  tags_.push_back(std::make_pair(tag, quantity));
60  produces<std::vector<float> >(tag).setBranchAlias(tag);
61 
62  }
63 }
64 
65 template<typename C>
67 }
68 
69 template<typename C>
72  iEvent.getByLabel(src_, coll);
73  if(eventInfo_){
74  std::auto_ptr<unsigned int> event( new unsigned int );
75  std::auto_ptr<unsigned int> run( new unsigned int );
76  std::auto_ptr<unsigned int> lumi( new unsigned int );
77  *event = iEvent.id().event();
78  *run = iEvent.id().run();
79  *lumi = iEvent.luminosityBlock();
80  iEvent.put( event, prefix_ + "EventNumber" );
81  iEvent.put( run, prefix_ + "RunNumber" );
82  iEvent.put( lumi, prefix_ + "LumiBlock" );
83  }
84  typename std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > >::const_iterator
85  q = tags_.begin(), end = tags_.end();
86  for(;q!=end; ++q) {
87  std::auto_ptr<std::vector<float> > x(new std::vector<float>);
88  x->reserve(coll->size());
89  for (typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem ) {
90  x->push_back(q->second(*elem));
91  }
92  iEvent.put(x, q->first);
93  }
94 }
95 
96 #endif
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
edm::InputTag src_
label of the collection to be read in
Definition: NtpProducer.h:33
bool eventInfo_
Definition: NtpProducer.h:38
std::string prefix_
Definition: NtpProducer.h:37
tuple lumi
Definition: fjr2json.py:35
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
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
edm::EventID id() const
Definition: EventBase.h:56
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
bool lazyParser_
Definition: NtpProducer.h:36
def template
Definition: svgfig.py:520