CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector > Class Template Reference

#include <AssociationVectorSelector.h>

Inheritance diagram for AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 AssociationVectorSelector (const edm::ParameterSet &)

Private Types

typedef edm::AssociationVector
< KeyRefProd, CVal > 
association_t
typedef association_t::CKey collection_t

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::InputTag association_
KeySelector selectKey_
ValSelector selectVal_

Detailed Description

template<typename KeyRefProd, typename CVal, typename KeySelector = AnySelector, typename ValSelector = AnySelector>
class AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >

Definition at line 17 of file AssociationVectorSelector.h.


Member Typedef Documentation

template<typename KeyRefProd , typename CVal , typename KeySelector = AnySelector, typename ValSelector = AnySelector>
typedef edm::AssociationVector<KeyRefProd, CVal> AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::association_t [private]

Definition at line 21 of file AssociationVectorSelector.h.

template<typename KeyRefProd , typename CVal , typename KeySelector = AnySelector, typename ValSelector = AnySelector>
typedef association_t::CKey AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::collection_t [private]

Definition at line 22 of file AssociationVectorSelector.h.


Constructor & Destructor Documentation

template<typename KeyRefProd , typename CVal , typename KeySelector , typename ValSelector >
AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::AssociationVectorSelector ( const edm::ParameterSet cfg)

Definition at line 36 of file AssociationVectorSelector.h.

References ExpressReco_HICollisions_FallBack::alias.

                                                                                                                           :
  association_(cfg.template getParameter<edm::InputTag>("association")),
  selectKey_(reco::modules::make<KeySelector>(cfg)),
  selectVal_(reco::modules::make<ValSelector>(cfg)) {
  std::string alias(cfg.template getParameter<std::string>("@module_label"));
  produces<collection_t>().setBranchAlias(alias);
  produces<association_t>().setBranchAlias(alias + "Association");
}

Member Function Documentation

template<typename KeyRefProd , typename CVal , typename KeySelector , typename ValSelector >
void AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::produce ( edm::Event evt,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 46 of file AssociationVectorSelector.h.

References clone(), edm::Event::getByLabel(), edm::Event::getRefBeforePut(), i, VarParsing::obj, edm::Event::put(), and findQualityFiles::size.

                                                                                                                       {
  using namespace edm;
  using namespace std;
  Handle<association_t> association;
  evt.getByLabel(association_, association);
  auto_ptr<collection_t> selected(new collection_t);  
  vector<typename CVal::value_type> selectedValues;
  size_t size = association->size();
  selected->reserve(size);
  selectedValues.reserve(size);
  for(typename association_t::const_iterator i = association->begin();
      i != association->end(); ++i) {
    const typename association_t::key_type & obj = * i->first;
    if(selectKey_(obj)&&selectVal_(i->second)) {
      typedef typename edm::clonehelper::CloneTrait<collection_t>::type clone_t;
      selected->push_back(clone_t::clone(obj));
      selectedValues.push_back(i->second);
    }
  }
  // new association must be created after the
  // selected collection is full because it uses the size
  KeyRefProd ref = evt.getRefBeforePut<collection_t>();
  auto_ptr<association_t> selectedAssociation(new association_t(ref, selected.get()));
  size = selected->size();
  OrphanHandle<collection_t> oh = evt.put(selected);
  for(size_t i = 0; i != size; ++i)
    selectedAssociation->setValue(i, selectedValues[i]);
  evt.put(selectedAssociation);
}

Member Data Documentation

template<typename KeyRefProd , typename CVal , typename KeySelector = AnySelector, typename ValSelector = AnySelector>
edm::InputTag AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::association_ [private]

Definition at line 24 of file AssociationVectorSelector.h.

template<typename KeyRefProd , typename CVal , typename KeySelector = AnySelector, typename ValSelector = AnySelector>
KeySelector AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::selectKey_ [private]

Definition at line 25 of file AssociationVectorSelector.h.

template<typename KeyRefProd , typename CVal , typename KeySelector = AnySelector, typename ValSelector = AnySelector>
ValSelector AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::selectVal_ [private]

Definition at line 26 of file AssociationVectorSelector.h.