CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edm::ThinningProducer< Collection, Selector > Class Template Reference

#include <ThinningProducer.h>

Inheritance diagram for edm::ThinningProducer< Collection, Selector >:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (Event &event, EventSetup const &eventSetup) override
 
virtual void registerThinnedAssociations (ProductRegistry const &productRegistry, ThinnedAssociationsHelper &thinnedAssociationsHelper) override
 
 ThinningProducer (ParameterSet const &pset)
 
virtual ~ThinningProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::InputTag inputTag_
 
edm::EDGetTokenT< Collection > inputToken_
 
std::unique_ptr< Selectorselector_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

template<typename Collection, typename Selector>
class edm::ThinningProducer< Collection, Selector >

Author
W. David Dagenhart, created 11 June 2014

Definition at line 29 of file ThinningProducer.h.

Constructor & Destructor Documentation

template<typename Collection , typename Selector >
edm::ThinningProducer< Collection, Selector >::ThinningProducer ( ParameterSet const &  pset)
explicit

Definition at line 48 of file ThinningProducer.h.

References edm::ParameterSet::getParameter(), edm::ThinningProducer< Collection, Selector >::inputTag_, and edm::ThinningProducer< Collection, Selector >::inputToken_.

48  :
49  selector_(new Selector(pset, consumesCollector())) {
50 
51  inputTag_ = pset.getParameter<InputTag>("inputTag");
52  inputToken_ = consumes<Collection>(inputTag_);
53 
54  produces<Collection>();
55  produces<ThinnedAssociation>();
56  }
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< Collection > inputToken_
Functor that operates on &lt;T&gt;
Definition: Selector.h:24
std::unique_ptr< Selector > selector_
template<typename Collection , typename Selector >
edm::ThinningProducer< Collection, Selector >::~ThinningProducer ( )
virtual

Definition at line 60 of file ThinningProducer.h.

60 {}

Member Function Documentation

template<typename Collection , typename Selector >
void edm::ThinningProducer< Collection, Selector >::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 64 of file ThinningProducer.h.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setComment().

64  {
66  desc.setComment("Produces thinned collections and associations to them");
67  desc.add<edm::InputTag>("inputTag");
68  Selector::fillDescription(desc);
69  descriptions.addDefault(desc);
70  }
template<typename Collection , typename Selector >
void edm::ThinningProducer< Collection, Selector >::produce ( Event event,
EventSetup const &  eventSetup 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 74 of file ThinningProducer.h.

References event(), edm::OrphanHandleBase::id(), edm::HandleBase::id(), and HLT_25ns14e33_v1_cff::inputCollection.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

74  {
75 
77  event.getByToken(inputToken_, inputCollection);
78 
79  edm::Event const& constEvent = event;
80  selector_->preChoose(inputCollection, constEvent, eventSetup);
81 
82  std::auto_ptr<Collection> thinnedCollection(new Collection);
83  std::auto_ptr<ThinnedAssociation> thinnedAssociation(new ThinnedAssociation);
84 
85  unsigned int iIndex = 0;
86  for(auto iter = inputCollection->begin(), iterEnd = inputCollection->end();
87  iter != iterEnd; ++iter, ++iIndex) {
88  if(selector_->choose(iIndex, *iter)) {
89  thinnedCollection->push_back(*iter);
90  thinnedAssociation->push_back(iIndex);
91  }
92  }
93  OrphanHandle<Collection> orphanHandle = event.put(thinnedCollection);
94 
95  thinnedAssociation->setParentCollectionID(inputCollection.id());
96  thinnedAssociation->setThinnedCollectionID(orphanHandle.id());
97  event.put(thinnedAssociation);
98  }
ProductID id() const
Definition: HandleBase.cc:15
edm::EDGetTokenT< Collection > inputToken_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::unique_ptr< Selector > selector_
template<typename Collection , typename Selector >
void edm::ThinningProducer< Collection, Selector >::registerThinnedAssociations ( ProductRegistry const &  productRegistry,
ThinnedAssociationsHelper thinnedAssociationsHelper 
)
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 102 of file ThinningProducer.h.

References edm::ThinnedAssociationsHelper::addAssociation(), edm::BranchDescription::branchID(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::originalBranchID(), edm::BranchDescription::processName(), edm::BranchDescription::produced(), edm::BranchDescription::productInstanceName(), edm::ProductRegistry::productList(), edm::TypeWithDict::typeInfo(), and edm::BranchDescription::unwrappedType().

103  {
104 
105  BranchID associationID;
106  BranchID thinnedCollectionID;
107 
108  // If the InputTag does not specify the process name, it is
109  // possible that there will be more than one match found below.
110  // For a particular event only one match is correct and the
111  // others will be false. It even possible for some events one
112  // match is correct and for others another is correct. This is
113  // a side effect of the lookup mechanisms when the process name
114  // is not specified.
115  // When using the registry this generates one would have to
116  // check the ProductIDs in ThinnedAssociation product to get
117  // the correct association. This ambiguity will probably be
118  // rare and possibly never occur in practice.
119  std::vector<BranchID> parentCollectionIDs;
120 
121  ProductRegistry::ProductList const& productList = productRegistry.productList();
122  for(auto const& product : productList) {
123  BranchDescription const& desc = product.second;
124  if(desc.unwrappedType().typeInfo() == typeid(Collection) ) {
125  if(desc.produced() &&
126  desc.moduleLabel() == moduleDescription().moduleLabel() &&
127  desc.productInstanceName().empty()) {
128 
129  thinnedCollectionID = desc.branchID();
130  }
131  if(desc.moduleLabel() == inputTag_.label() &&
132  desc.productInstanceName() == inputTag_.instance()) {
134  if(!desc.produced()) {
135  parentCollectionIDs.push_back(desc.branchID());
136  }
137  } else if (inputTag_.process().empty() || inputTag_.process() == desc.processName()) {
138  if(desc.produced()) {
139  parentCollectionIDs.push_back(desc.originalBranchID());
140  } else {
141  parentCollectionIDs.push_back(desc.branchID());
142  }
143  }
144  }
145  }
146  if(desc.produced() &&
147  desc.unwrappedType().typeInfo() == typeid(ThinnedAssociation) &&
148  desc.moduleLabel() == moduleDescription().moduleLabel() &&
149  desc.productInstanceName().empty()) {
150 
151  associationID = desc.branchID();
152  }
153  }
154  if(parentCollectionIDs.empty()) {
155  // This could happen if the input collection was dropped. Go ahead and add
156  // an entry and let the exception be thrown only if the module is run (when
157  // it cannot find the product).
158  thinnedAssociationsHelper.addAssociation(BranchID(), associationID, thinnedCollectionID);
159  } else {
160  for(auto const& parentCollectionID : parentCollectionIDs) {
161  thinnedAssociationsHelper.addAssociation(parentCollectionID, associationID, thinnedCollectionID);
162  }
163  }
164  }
std::map< BranchKey, BranchDescription > ProductList
std::string const & moduleLabel() const
ModuleDescription const & moduleDescription() const
bool willSkipCurrentProcess() const
Definition: InputTag.h:49
std::string const & label() const
Definition: InputTag.h:43
std::string const & process() const
Definition: InputTag.h:47
std::string const & instance() const
Definition: InputTag.h:44

Member Data Documentation

template<typename Collection , typename Selector >
edm::InputTag edm::ThinningProducer< Collection, Selector >::inputTag_
private
template<typename Collection , typename Selector >
edm::EDGetTokenT<Collection> edm::ThinningProducer< Collection, Selector >::inputToken_
private
template<typename Collection , typename Selector >
std::unique_ptr<Selector> edm::ThinningProducer< Collection, Selector >::selector_
private

Definition at line 41 of file ThinningProducer.h.