CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

Public Member Functions

 AssociationVectorSelector (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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.

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

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  
)
privatevirtual

Implements edm::EDProducer.

Definition at line 46 of file AssociationVectorSelector.h.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

46  {
47  using namespace edm;
48  using namespace std;
49  Handle<association_t> association;
50  evt.getByLabel(association_, association);
51  auto_ptr<collection_t> selected(new collection_t);
52  vector<typename CVal::value_type> selectedValues;
53  size_t size = association->size();
54  selected->reserve(size);
55  selectedValues.reserve(size);
56  for(typename association_t::const_iterator i = association->begin();
57  i != association->end(); ++i) {
58  const typename association_t::key_type & obj = * i->first;
59  if(selectKey_(obj)&&selectVal_(i->second)) {
60  typedef typename edm::clonehelper::CloneTrait<collection_t>::type clone_t;
61  selected->push_back(clone_t::clone(obj));
62  selectedValues.push_back(i->second);
63  }
64  }
65  // new association must be created after the
66  // selected collection is full because it uses the size
67  KeyRefProd ref = evt.getRefBeforePut<collection_t>();
68  auto_ptr<association_t> selectedAssociation(new association_t(ref, selected.get()));
69  size = selected->size();
70  OrphanHandle<collection_t> oh = evt.put(selected);
71  for(size_t i = 0; i != size; ++i)
72  selectedAssociation->setValue(i, selectedValues[i]);
73  evt.put(selectedAssociation);
74 }
int i
Definition: DBlmapReader.cc:9
transient_vector_type::const_iterator const_iterator
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
RefProd< PROD > getRefBeforePut()
Definition: Event.h:97
KeyRef::value_type key_type
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
edm::AssociationVector< KeyRefProd, CVal > association_t
tuple size
Write out results.

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.