CMS 3D CMS Logo

Public Member Functions | Private Attributes

OtherObjectVariableComputer< T > Class Template Reference

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

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

List of all members.

Public Member Functions

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

Private Attributes

double default_
bool doSort_
StringCutObjectSelector< T, true > objCut_
edm::InputTag objects_
StringObjectFunction< T, true > objSort_
StringObjectFunction< T, true > objVar_
edm::InputTag probes_

Detailed Description

template<typename T>
class OtherObjectVariableComputer< T >

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

Author:
Kalanand Mishra

Definition at line 28 of file OtherObjectVariableComputer.cc.


Constructor & Destructor Documentation

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

Definition at line 46 of file OtherObjectVariableComputer.cc.

                                                                                           :
    probes_(iConfig.getParameter<edm::InputTag>("probes")),
    objects_(iConfig.getParameter<edm::InputTag>("objects")),
    objVar_(iConfig.getParameter<std::string>("expression")),
    default_(iConfig.getParameter<double>("default")),
    objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true),
    doSort_(iConfig.existsAs<std::string>("objectSortDescendingBy")),
    objSort_(doSort_ ? iConfig.getParameter<std::string>("objectSortDescendingBy") : "1", true)
{
    produces<edm::ValueMap<float> >();
}
template<typename T >
OtherObjectVariableComputer< T >::~OtherObjectVariableComputer ( ) [virtual]

Definition at line 60 of file OtherObjectVariableComputer.cc.

{
}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 66 of file OtherObjectVariableComputer.cc.

References edm::Event::getByLabel(), dbtoconf::object, edm::Event::put(), python::multivaluedict::sort(), 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
    std::vector<std::pair<double, double> > selected;
    typename View<T>::const_iterator object, endobjects = objects->end();
    for (object = objects->begin(); object != endobjects; ++object) {
      if (objCut_(*object)) {
        selected.push_back(std::pair<double, double>(objSort_(*object), objVar_(*object)));
        if (!doSort_) break; // if we take just the first one, there's no need of computing the others
      }
    }
    if (doSort_ && selected.size() > 1) std::sort(selected.begin(), selected.end()); // sorts (ascending)

    // prepare vector for output    
    std::vector<float> values(probes->size(), (selected.empty() ? default_ : selected.back().second));

    // 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 >
double OtherObjectVariableComputer< T >::default_ [private]

Definition at line 39 of file OtherObjectVariableComputer.cc.

template<typename T >
bool OtherObjectVariableComputer< T >::doSort_ [private]

Definition at line 41 of file OtherObjectVariableComputer.cc.

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

Definition at line 40 of file OtherObjectVariableComputer.cc.

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

Definition at line 37 of file OtherObjectVariableComputer.cc.

template<typename T >
StringObjectFunction<T,true> OtherObjectVariableComputer< T >::objSort_ [private]

Definition at line 42 of file OtherObjectVariableComputer.cc.

template<typename T >
StringObjectFunction<T,true> OtherObjectVariableComputer< T >::objVar_ [private]

Definition at line 38 of file OtherObjectVariableComputer.cc.

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

Definition at line 36 of file OtherObjectVariableComputer.cc.