CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

reco::tautools::CastedRefProducer< DerivedCollection, BaseType > Class Template Reference

#include <CastedRefProducer.h>

Inheritance diagram for reco::tautools::CastedRefProducer< DerivedCollection, BaseType >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef base_ref_vector::value_type base_ref
typedef edm::RefToBaseVector
< BaseType > 
base_ref_vector
typedef edm::Ref
< DerivedCollection > 
derived_ref
typedef edm::RefVector
< DerivedCollection > 
OutputCollection

Public Member Functions

 CastedRefProducer (const edm::ParameterSet &pset)
 constructor from parameter set
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 process an event
 ~CastedRefProducer ()
 destructor

Private Attributes

edm::InputTag src_
 labels of the collection to be converted

Detailed Description

template<typename DerivedCollection, typename BaseType>
class reco::tautools::CastedRefProducer< DerivedCollection, BaseType >

Definition at line 25 of file CastedRefProducer.h.


Member Typedef Documentation

template<typename DerivedCollection , typename BaseType >
typedef base_ref_vector::value_type reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::base_ref

Definition at line 28 of file CastedRefProducer.h.

template<typename DerivedCollection , typename BaseType >
typedef edm::RefToBaseVector<BaseType> reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::base_ref_vector

Definition at line 27 of file CastedRefProducer.h.

template<typename DerivedCollection , typename BaseType >
typedef edm::Ref<DerivedCollection> reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::derived_ref

Definition at line 29 of file CastedRefProducer.h.

template<typename DerivedCollection , typename BaseType >
typedef edm::RefVector<DerivedCollection> reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::OutputCollection

Definition at line 30 of file CastedRefProducer.h.


Constructor & Destructor Documentation

template<typename DerivedCollection , typename BaseType >
reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::CastedRefProducer ( const edm::ParameterSet pset) [inline, explicit]

constructor from parameter set

Definition at line 32 of file CastedRefProducer.h.

        :src_(pset.template getParameter<edm::InputTag>("src")) {
          produces<OutputCollection>();
        }
template<typename DerivedCollection , typename BaseType >
reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::~CastedRefProducer ( ) [inline]

destructor

Definition at line 37 of file CastedRefProducer.h.

{};

Member Function Documentation

template<typename DerivedCollection , typename BaseType >
virtual void reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::produce ( edm::Event evt,
const edm::EventSetup es 
) [inline, virtual]

process an event

Implements edm::EDProducer.

Definition at line 39 of file CastedRefProducer.h.

References edm::RefToBaseVector< T >::at(), coll, edm::Event::getByLabel(), i, LaserDQM_cfg::input, edm::Event::put(), edm::RefToBaseVector< T >::size(), and reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::src_.

                                                                 {
      // Output collection
      std::auto_ptr<OutputCollection> coll(new OutputCollection());
      // Get input
      edm::Handle<edm::View<BaseType> > input;
      evt.getByLabel(src_, input);
      // Get references to the base
      const base_ref_vector &baseRefs = input->refVector();
      for(size_t i = 0; i < baseRefs.size(); ++i) {
        // Cast the base class to the derived class
        base_ref base = baseRefs.at(i);
        derived_ref derived = base.template castTo<derived_ref>();
        coll->push_back(derived);
      }
      evt.put( coll );
    }

Member Data Documentation

template<typename DerivedCollection , typename BaseType >
edm::InputTag reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::src_ [private]

labels of the collection to be converted

Definition at line 57 of file CastedRefProducer.h.

Referenced by reco::tautools::CastedRefProducer< DerivedCollection, BaseType >::produce().