CMS 3D CMS Logo

Public Member Functions | Private Attributes

ObjectMultiplicityCounter< T > Class Template Reference

Matcher of number of reconstructed objects in the event to probe. More...

Inheritance diagram for ObjectMultiplicityCounter< T >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 ObjectMultiplicityCounter (const edm::ParameterSet &iConfig)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual ~ObjectMultiplicityCounter ()

Private Attributes

StringCutObjectSelector< T, true > objCut_
edm::InputTag objects_
edm::InputTag probes_

Detailed Description

template<typename T>
class ObjectMultiplicityCounter< T >

Matcher of number of reconstructed objects in the event to probe.

Author:
Kalanand Mishra

Definition at line 27 of file ObjectMultiplicityCounter.cc.


Constructor & Destructor Documentation

template<typename T >
ObjectMultiplicityCounter< T >::ObjectMultiplicityCounter ( const edm::ParameterSet iConfig) [explicit]

Definition at line 41 of file ObjectMultiplicityCounter.cc.

                                                                                       :
    probes_(iConfig.getParameter<edm::InputTag>("probes")),
    objects_(iConfig.getParameter<edm::InputTag>("objects")),
    objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true)
{
    produces<edm::ValueMap<float> >();
}
template<typename T >
ObjectMultiplicityCounter< T >::~ObjectMultiplicityCounter ( ) [virtual]

Definition at line 51 of file ObjectMultiplicityCounter.cc.

{
}

Member Function Documentation

template<typename T >
void ObjectMultiplicityCounter< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 57 of file ObjectMultiplicityCounter.cc.

References prof2calltree::count, edm::Event::getByLabel(), dbtoconf::object, edm::Event::put(), and makeHLTPrescaleTable::values.

                                                                                     {
    using namespace edm;

    // read input
    Handle<View<reco::Candidate> > probes;
    Handle<View<T> > objects;
    iEvent.getByLabel(probes_,  probes);
    iEvent.getByLabel(objects_, objects);
    
    // fill
    float count = 0.0;
    View<reco::Candidate>::const_iterator probe, endprobes = probes->end(); 
    typename View<T>::const_iterator object, endobjects = objects->end();
    for (object = objects->begin(); object != endobjects; ++object) {
      if ( !(objCut_(*object)) ) continue;
      count += 1.0;
    }

    // prepare vector for output    
    std::vector<float> values(probes->size(), count);

    // convert into ValueMap and store
    std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
    ValueMap<float>::Filler filler(*valMap);
    filler.insert(probes, values.begin(), values.end());
    filler.fill();
    iEvent.put(valMap);
}

Member Data Documentation

template<typename T >
StringCutObjectSelector<T,true> ObjectMultiplicityCounter< T >::objCut_ [private]

Definition at line 37 of file ObjectMultiplicityCounter.cc.

template<typename T >
edm::InputTag ObjectMultiplicityCounter< T >::objects_ [private]

Definition at line 36 of file ObjectMultiplicityCounter.cc.

template<typename T >
edm::InputTag ObjectMultiplicityCounter< T >::probes_ [private]

Definition at line 35 of file ObjectMultiplicityCounter.cc.