CMS 3D CMS Logo

NtpProducer< C > Class Template Reference

Creates histograms defined in config file. More...

#include <PhysicsTools/UtilAlgos/interface/NtpProducer.h>

Inheritance diagram for NtpProducer< C >:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 NtpProducer (const edm::ParameterSet &)
 constructor from parameter set
 ~NtpProducer ()
 destructor

Protected Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 process an event

Private Attributes

edm::InputTag src_
 label of the collection to be read in
std::vector< std::pair
< std::string,
StringObjectFunction
< typename C::value_type > > > 
tags_
 variable tags


Detailed Description

template<typename C>
class NtpProducer< C >

Creates histograms defined in config file.

Author:
: Luca Lista, INFN
Template parameters:

Definition at line 20 of file NtpProducer.h.


Constructor & Destructor Documentation

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

constructor from parameter set

Definition at line 39 of file NtpProducer.h.

References end, ecalRecalibSequence_cff::tag, and NtpProducer< C >::tags_.

00039                                                         : 
00040   src_( par.template getParameter<edm::InputTag>( "src" ) ) {
00041    std::vector<edm::ParameterSet> variables = 
00042                                    par.template getParameter<std::vector<edm::ParameterSet> >("variables");
00043    std::vector<edm::ParameterSet>::const_iterator 
00044      q = variables.begin(), end = variables.end();
00045    for (; q!=end; ++q) {
00046      std::string tag = q->getUntrackedParameter<std::string>("tag");
00047      StringObjectFunction<typename C::value_type> quantity(q->getUntrackedParameter<std::string>("quantity"));
00048      tags_.push_back(std::make_pair(tag, quantity));
00049      produces<std::vector<float> >(tag).setBranchAlias(tag);
00050    }   
00051 }

template<typename C>
NtpProducer< C >::~NtpProducer (  )  [inline]

destructor

Definition at line 54 of file NtpProducer.h.

00054                              {
00055 }


Member Function Documentation

template<typename C>
void NtpProducer< C >::produce ( edm::Event iEvent,
const edm::EventSetup  
) [inline, protected, virtual]

process an event

Implements edm::EDProducer.

Definition at line 58 of file NtpProducer.h.

References coll, end, edm::Event::getByLabel(), edm::Event::put(), NtpProducer< C >::src_, NtpProducer< C >::tags_, and x.

00058                                                                      {
00059    edm::Handle<C> coll;
00060    iEvent.getByLabel(src_, coll);
00061 
00062    typename std::vector<std::pair<std::string, StringObjectFunction<typename C::value_type> > >::const_iterator 
00063      q = tags_.begin(), end = tags_.end();
00064    for(;q!=end; ++q) {
00065      std::auto_ptr<std::vector<float> > x(new std::vector<float>);
00066      x->reserve(coll->size());
00067      for (typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem ) {
00068        x->push_back(q->second(*elem));
00069      }
00070      iEvent.put(x, q->first);
00071    }
00072 }


Member Data Documentation

template<typename C>
edm::InputTag NtpProducer< C >::src_ [private]

label of the collection to be read in

Definition at line 33 of file NtpProducer.h.

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

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

variable tags

Definition at line 35 of file NtpProducer.h.

Referenced by NtpProducer< C >::NtpProducer(), and NtpProducer< C >::produce().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:29:03 2009 for CMSSW by  doxygen 1.5.4