CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
NtpProducer< C > Class Template Reference

#include <NtpProducer.h>

Inheritance diagram for NtpProducer< C >:
edm::stream::EDProducer<>

Public Member Functions

 NtpProducer (const edm::ParameterSet &)
 constructor from parameter set More...
 
 ~NtpProducer () override
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 process an event More...
 

Private Attributes

bool eventInfo_
 
bool lazyParser_
 
std::string prefix_
 
edm::EDGetTokenT< C > srcToken_
 label of the collection to be read in More...
 
std::vector< std::pair< std::string, StringObjectFunction< typename C::value_type > > > tags_
 variable tags More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename C>
class NtpProducer< C >

Creates histograms defined in config file

Author
: Luca Lista, INFN

Template parameters:

Definition at line 21 of file NtpProducer.h.

Constructor & Destructor Documentation

◆ NtpProducer()

template<typename C >
NtpProducer< C >::NtpProducer ( const edm::ParameterSet par)

constructor from parameter set

Definition at line 43 of file NtpProducer.h.

References mps_fire::end, NtpProducer< C >::eventInfo_, NtpProducer< C >::lazyParser_, NtpProducer< C >::prefix_, submitPVResolutionJobs::q, MjjMonitor_cfi::quantity, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, NtpProducer< C >::tags_, and hcalRecHitTable_cff::variables.

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 = par.template getParameter<std::vector<edm::ParameterSet> >("variables");
49  std::vector<edm::ParameterSet>::const_iterator q = variables.begin(), end = variables.end();
50  if (eventInfo_) {
51  produces<edm::EventNumber_t>(prefix_ + "EventNumber").setBranchAlias(prefix_ + "EventNumber");
52  produces<unsigned int>(prefix_ + "RunNumber").setBranchAlias(prefix_ + "RunNumber");
53  produces<unsigned int>(prefix_ + "LumiBlock").setBranchAlias(prefix_ + "Lumiblock");
54  }
55  for (; q != end; ++q) {
56  std::string tag = prefix_ + q->getUntrackedParameter<std::string>("tag");
57  StringObjectFunction<typename C::value_type> quantity(q->getUntrackedParameter<std::string>("quantity"),
58  lazyParser_);
59  tags_.push_back(std::make_pair(tag, quantity));
60  produces<std::vector<float> >(tag).setBranchAlias(tag);
61  }
62 }
bool eventInfo_
Definition: NtpProducer.h:39
std::string prefix_
Definition: NtpProducer.h:38
edm::EDGetTokenT< C > srcToken_
label of the collection to be read in
Definition: NtpProducer.h:34
std::vector< std::pair< std::string, StringObjectFunction< typename C::value_type > > > tags_
variable tags
Definition: NtpProducer.h:36
bool lazyParser_
Definition: NtpProducer.h:37

◆ ~NtpProducer()

template<typename C >
NtpProducer< C >::~NtpProducer ( )
override

destructor

Definition at line 65 of file NtpProducer.h.

65 {}

Member Function Documentation

◆ produce()

template<typename C >
void NtpProducer< C >::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprotected

process an event

Definition at line 68 of file NtpProducer.h.

References mps_fire::end, edmPickEvents::event, iEvent, BXlumiParameters_cfi::lumi, eostools::move(), submitPVResolutionJobs::q, writedatasetfile::run, and x.

68  {
69  edm::Handle<C> coll;
70  iEvent.getByToken(srcToken_, coll);
71  if (eventInfo_) {
72  std::unique_ptr<edm::EventNumber_t> event(new edm::EventNumber_t);
73  std::unique_ptr<unsigned int> run(new unsigned int);
74  std::unique_ptr<unsigned int> lumi(new unsigned int);
75  *event = iEvent.id().event();
76  *run = iEvent.id().run();
77  *lumi = iEvent.luminosityBlock();
78  iEvent.put(std::move(event), prefix_ + "EventNumber");
79  iEvent.put(std::move(run), prefix_ + "RunNumber");
80  iEvent.put(std::move(lumi), prefix_ + "LumiBlock");
81  }
82  typename std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > >::const_iterator
83  q = tags_.begin(),
84  end = tags_.end();
85  for (; q != end; ++q) {
86  std::unique_ptr<std::vector<float> > x(new std::vector<float>);
87  x->reserve(coll->size());
88  for (typename C::const_iterator elem = coll->begin(); elem != coll->end(); ++elem) {
89  x->push_back(q->second(*elem));
90  }
91  iEvent.put(std::move(x), q->first);
92  }
93 }
bool eventInfo_
Definition: NtpProducer.h:39
std::string prefix_
Definition: NtpProducer.h:38
unsigned long long EventNumber_t
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< C > srcToken_
label of the collection to be read in
Definition: NtpProducer.h:34
std::vector< std::pair< std::string, StringObjectFunction< typename C::value_type > > > tags_
variable tags
Definition: NtpProducer.h:36
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

◆ eventInfo_

template<typename C >
bool NtpProducer< C >::eventInfo_
private

Definition at line 39 of file NtpProducer.h.

Referenced by NtpProducer< C >::NtpProducer().

◆ lazyParser_

template<typename C >
bool NtpProducer< C >::lazyParser_
private

Definition at line 37 of file NtpProducer.h.

Referenced by NtpProducer< C >::NtpProducer().

◆ prefix_

template<typename C >
std::string NtpProducer< C >::prefix_
private

Definition at line 38 of file NtpProducer.h.

Referenced by NtpProducer< C >::NtpProducer().

◆ srcToken_

template<typename C >
edm::EDGetTokenT<C> NtpProducer< C >::srcToken_
private

label of the collection to be read in

Definition at line 34 of file NtpProducer.h.

◆ tags_

template<typename C >
std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > > NtpProducer< C >::tags_
private

variable tags

Definition at line 36 of file NtpProducer.h.

Referenced by NtpProducer< C >::NtpProducer().