CMS 3D CMS Logo

Public Member Functions | Private Attributes

NearbyCandCountComputer Class Reference

Count candidates near to another candidate, write result in ValueMap. More...

Inheritance diagram for NearbyCandCountComputer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Attributes

double deltaR2_
StringCutObjectSelector
< reco::Candidate, true > 
objCut_
edm::InputTag objects_
StringCutObjectSelector
< pat::DiObjectProxy, true > 
pairCut_
edm::InputTag probes_

Detailed Description

Count candidates near to another candidate, write result in ValueMap.

Implementation notice: not templated, because we want to allow cuts on the pair through PATDiObjectProxy

Author:
Giovanni Petrucciani
Version:
Id:
NearbyCandCountComputer.cc,v 1.3 2010/10/05 15:05:10 gpetrucc Exp

Definition at line 31 of file NearbyCandCountComputer.cc.


Constructor & Destructor Documentation

NearbyCandCountComputer::NearbyCandCountComputer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 46 of file NearbyCandCountComputer.cc.

                                                                                :
    probes_(iConfig.getParameter<edm::InputTag>("probes")),
    objects_(iConfig.getParameter<edm::InputTag>("objects")),
    deltaR2_(std::pow(iConfig.getParameter<double>("deltaR"), 2)),
    objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true),
    pairCut_(iConfig.existsAs<std::string>("pairSelection") ? iConfig.getParameter<std::string>("pairSelection") : "", true)
{
    produces<edm::ValueMap<float> >();
}
NearbyCandCountComputer::~NearbyCandCountComputer ( ) [virtual]

Definition at line 57 of file NearbyCandCountComputer.cc.

{
}

Member Function Documentation

void NearbyCandCountComputer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 62 of file NearbyCandCountComputer.cc.

References prof2calltree::count, Geom::deltaR2(), deltaR2_, edm::Event::getByLabel(), objCut_, dbtoconf::object, objects_, pairCut_, probes_, edm::Event::put(), and makeHLTPrescaleTable::values.

                                                                                {
    using namespace edm;

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

    // prepare vector for output    
    std::vector<float> values;
    
    // fill
    View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
    View<reco::Candidate>::const_iterator object, beginobjects = objects->begin(), endobjects = objects->end();
    for (probe = probes->begin(); probe != endprobes; ++probe) {
        float count = 0;
        for (object = beginobjects; object != endobjects; ++object) {
            if ((deltaR2(*probe, *object) >= deltaR2_) &&
                objCut_(*object) && 
                pairCut_(pat::DiObjectProxy(*probe, *object))) {
                    count++;
            }             
        }
        values.push_back(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

Definition at line 41 of file NearbyCandCountComputer.cc.

Referenced by produce().

Definition at line 42 of file NearbyCandCountComputer.cc.

Referenced by produce().

Definition at line 40 of file NearbyCandCountComputer.cc.

Referenced by produce().

Definition at line 43 of file NearbyCandCountComputer.cc.

Referenced by produce().

Definition at line 39 of file NearbyCandCountComputer.cc.

Referenced by produce().