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 
19 
20 template<typename C>
21 class NtpProducer : public edm::EDProducer {
22 public:
26  ~NtpProducer();
27 
28 protected:
30  virtual void produce( edm::Event&, const edm::EventSetup&) override;
31 
32 private:
36  std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > > tags_;
39  bool eventInfo_;
40 };
41 
42 template<typename C>
44  srcToken_( consumes<C>( par.template getParameter<edm::InputTag>( "src" ) ) ),
45  lazyParser_( par.template getUntrackedParameter<bool>( "lazyParser", false ) ),
46  prefix_( par.template getUntrackedParameter<std::string>( "prefix","" ) ),
47  eventInfo_( par.template getUntrackedParameter<bool>( "eventInfo",true ) ){
48  std::vector<edm::ParameterSet> variables =
49  par.template getParameter<std::vector<edm::ParameterSet> >("variables");
50  std::vector<edm::ParameterSet>::const_iterator
51  q = variables.begin(), end = variables.end();
52  if(eventInfo_){
53  produces<edm::EventNumber_t>( prefix_+"EventNumber" ).setBranchAlias( prefix_ + "EventNumber" );
54  produces<unsigned int>( prefix_ + "RunNumber" ).setBranchAlias( prefix_ + "RunNumber" );
55  produces<unsigned int>( prefix_ + "LumiBlock" ).setBranchAlias( prefix_ + "Lumiblock" );
56  }
57  for (; q!=end; ++q) {
58  std::string tag = prefix_ + q->getUntrackedParameter<std::string>("tag");
59  StringObjectFunction<typename C::value_type> quantity(q->getUntrackedParameter<std::string>("quantity"), lazyParser_);
60  tags_.push_back(std::make_pair(tag, quantity));
61  produces<std::vector<float> >(tag).setBranchAlias(tag);
62 
63  }
64 }
65 
66 template<typename C>
68 }
69 
70 template<typename C>
73  iEvent.getByToken(srcToken_, coll);
74  if(eventInfo_){
75  std::auto_ptr<edm::EventNumber_t> event( new edm::EventNumber_t );
76  std::auto_ptr<unsigned int> run( new unsigned int );
77  std::auto_ptr<unsigned int> lumi( new unsigned int );
78  *event = iEvent.id().event();
79  *run = iEvent.id().run();
80  *lumi = iEvent.luminosityBlock();
81  iEvent.put( event, prefix_ + "EventNumber" );
82  iEvent.put( run, prefix_ + "RunNumber" );
83  iEvent.put( lumi, prefix_ + "LumiBlock" );
84  }
85  typename std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > >::const_iterator
86  q = tags_.begin(), end = tags_.end();
87  for(;q!=end; ++q) {
88  std::auto_ptr<std::vector<float> > x(new std::vector<float>);
89  x->reserve(coll->size());
90  for (typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem ) {
91  x->push_back(q->second(*elem));
92  }
93  iEvent.put(x, q->first);
94  }
95 }
96 
97 #endif
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool eventInfo_
Definition: NtpProducer.h:39
std::string prefix_
Definition: NtpProducer.h:38
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
tuple lumi
Definition: fjr2json.py:35
edm::EDGetTokenT< C > srcToken_
label of the collection to be read in
Definition: NtpProducer.h:34
unsigned long long EventNumber_t
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
T x() const
Cartesian x coordinate.
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
virtual void produce(edm::Event &, const edm::EventSetup &) override
process an event
Definition: NtpProducer.h:71
#define end
Definition: vmac.h:37
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
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::vector< std::pair< std::string, StringObjectFunction< typename C::value_type > > > tags_
variable tags
Definition: NtpProducer.h:36
~NtpProducer()
destructor
Definition: NtpProducer.h:67
edm::EventID id() const
Definition: EventBase.h:60
NtpProducer(const edm::ParameterSet &)
constructor from parameter set
Definition: NtpProducer.h:43
volatile std::atomic< bool > shutdown_flag false
bool lazyParser_
Definition: NtpProducer.h:37
def template
Definition: svgfig.py:520