CMS 3D CMS Logo

Public Member Functions | Private Attributes

DeltaRNearestObjectComputer< T > Class Template Reference

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

List of all members.

Public Member Functions

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

Private Attributes

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

Detailed Description

template<typename T>
class DeltaRNearestObjectComputer< T >

Definition at line 44 of file DeltaRNearestObjectComputer.cc.


Constructor & Destructor Documentation

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

Definition at line 58 of file DeltaRNearestObjectComputer.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 >
DeltaRNearestObjectComputer< T >::~DeltaRNearestObjectComputer ( ) [virtual]

Definition at line 68 of file DeltaRNearestObjectComputer.cc.

{
}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 74 of file DeltaRNearestObjectComputer.cc.

References Geom::deltaR2(), edm::Event::getByLabel(), VarParsing::obj, edm::Event::put(), mathSSE::sqrt(), and makeHLTPrescaleTable::values.

                                                                                       {
    using namespace edm;

    // read input
    Handle<View<reco::Candidate> > probes;
    iEvent.getByLabel(probes_,  probes);

    Handle<View<T> > objects;
    iEvent.getByLabel(objects_, objects);

    // prepare vector for output    
    std::vector<float> values;
    
    // fill
    View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
    for (probe = probes->begin(); probe != endprobes; ++probe) {
        double dr2min = 10000;
        for (unsigned int iObj=0; iObj<objects->size(); iObj++) {
          const T& obj = objects->at(iObj);
          if (!objCut_(obj)) continue;
            double dr2 = deltaR2(*probe, obj);
            if (dr2 < dr2min) { dr2min = dr2; }
        }
        values.push_back(sqrt(dr2min));
    }

    // 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> DeltaRNearestObjectComputer< T >::objCut_ [private]

Definition at line 54 of file DeltaRNearestObjectComputer.cc.

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

Definition at line 53 of file DeltaRNearestObjectComputer.cc.

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

Definition at line 52 of file DeltaRNearestObjectComputer.cc.