Matcher of number of reconstructed objects in the event to probe. More...
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_ |
Matcher of number of reconstructed objects in the event to probe.
Definition at line 28 of file OtherObjectVariableComputer.cc.
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> >(); }
OtherObjectVariableComputer< T >::~OtherObjectVariableComputer | ( | ) | [virtual] |
Definition at line 60 of file OtherObjectVariableComputer.cc.
{ }
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); }
double OtherObjectVariableComputer< T >::default_ [private] |
Definition at line 39 of file OtherObjectVariableComputer.cc.
bool OtherObjectVariableComputer< T >::doSort_ [private] |
Definition at line 41 of file OtherObjectVariableComputer.cc.
StringCutObjectSelector<T,true> OtherObjectVariableComputer< T >::objCut_ [private] |
Definition at line 40 of file OtherObjectVariableComputer.cc.
edm::InputTag OtherObjectVariableComputer< T >::objects_ [private] |
Definition at line 37 of file OtherObjectVariableComputer.cc.
StringObjectFunction<T,true> OtherObjectVariableComputer< T >::objSort_ [private] |
Definition at line 42 of file OtherObjectVariableComputer.cc.
StringObjectFunction<T,true> OtherObjectVariableComputer< T >::objVar_ [private] |
Definition at line 38 of file OtherObjectVariableComputer.cc.
edm::InputTag OtherObjectVariableComputer< T >::probes_ [private] |
Definition at line 36 of file OtherObjectVariableComputer.cc.