Count candidates near to another candidate, write result in ValueMap. More...
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_ |
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
Definition at line 31 of file NearbyCandCountComputer.cc.
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.
{ }
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); }
double NearbyCandCountComputer::deltaR2_ [private] |
Definition at line 41 of file NearbyCandCountComputer.cc.
Referenced by produce().
StringCutObjectSelector<reco::Candidate,true> NearbyCandCountComputer::objCut_ [private] |
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().