CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ThinnedRefSet Class Reference

#include "ThinnedRefSet.h"

Detailed Description

Description: A minimal set interface (insertion, contains(), clear()) for a set of Ref keys to a thinned collection

Usage:

A ThinnedRefSet contains Ref keys to a thinned collection. The keys are inserted as Refs to the thinned collection itself, or to any parent collections of the thinned collection.

The main use case are Selector classes for edm::ThinningProducer. There, an object of the class would be stored as a member of the Selector class, filled in Selector::preChoose(), calling contains() in Selector::choose(), and cleared in Selector::reset().

Example of filling

class ExampleSelector {
...
};
void ExampleSelector::preChoose(edm::Handle<ThingCollection> tc, edm::Event const& e, edm::EventSetup const&) {
auto filler = keysToSave_.fill(edm::RefProd(tc), event.productGetter());
for (auto const& object : event.get(objectCollectionToken_) {
filler.insert(object.refToThing());
}
}

Example of querying if a key is present

bool ExampleSelector::choose(unsigned int iIndex, Thing const& iItem) const {
return keysToSave_.contains(iIndex);
}