CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
edm::ThinningProducer< Collection, Selector > Class Template Reference

#include <ThinningProducer.h>

Inheritance diagram for edm::ThinningProducer< Collection, Selector >:
edm::stream::EDProducer<>

Public Member Functions

void produce (Event &event, EventSetup const &eventSetup) override
 
void registerThinnedAssociations (ProductRegistry const &productRegistry, ThinnedAssociationsHelper &thinnedAssociationsHelper) override
 
 ThinningProducer (ParameterSet const &pset)
 
 ~ThinningProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Types

using SelectorChooseReturnType = decltype(selector_->choose(0U, std::declval< typename detail::ElementType< Collection >::type const >()))
 

Private Attributes

edm::InputTag inputTag_
 
edm::EDGetTokenT< Collection > inputToken_
 
edm::EDPutTokenT< Collection > outputToken_
 
edm::propagate_const< std::unique_ptr< Selector > > selector_
 
edm::EDPutTokenT< ThinnedAssociationthinnedOutToken_
 

Static Private Attributes

static constexpr bool isSlimming = detail::IsStdOptional<SelectorChooseReturnType>::value
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

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

Author
W. David Dagenhart, created 11 June 2014

Definition at line 68 of file ThinningProducer.h.

Member Typedef Documentation

◆ SelectorChooseReturnType

template<typename Collection , typename Selector >
using edm::ThinningProducer< Collection, Selector >::SelectorChooseReturnType = decltype(selector_->choose(0U, std::declval<typename detail::ElementType<Collection>::type const>()))
private

Definition at line 88 of file ThinningProducer.h.

Constructor & Destructor Documentation

◆ ThinningProducer()

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

Definition at line 96 of file ThinningProducer.h.

References edm::ThinningProducer< Collection, Selector >::inputTag_, edm::ThinningProducer< Collection, Selector >::inputToken_, edm::ThinningProducer< Collection, Selector >::outputToken_, muonDTDigis_cfi::pset, and edm::ThinningProducer< Collection, Selector >::thinnedOutToken_.

97  : selector_(new Selector(pset, consumesCollector())) {
98  inputTag_ = pset.getParameter<InputTag>("inputTag");
99  inputToken_ = consumes<Collection>(inputTag_);
100 
101  outputToken_ = produces<Collection>();
102  thinnedOutToken_ = produces<ThinnedAssociation>();
103  }
edm::propagate_const< std::unique_ptr< Selector > > selector_
edm::EDPutTokenT< Collection > outputToken_
edm::EDGetTokenT< Collection > inputToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_

◆ ~ThinningProducer()

template<typename Collection , typename Selector >
edm::ThinningProducer< Collection, Selector >::~ThinningProducer ( )
override

Definition at line 106 of file ThinningProducer.h.

106 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 109 of file ThinningProducer.h.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and reco::modules::fillPSetDescription().

109  {
111  desc.setComment("Produces thinned collections and associations to them");
112  desc.add<edm::InputTag>("inputTag");
114  descriptions.addWithDefaultLabel(desc);
115  }
void fillPSetDescription(edm::ParameterSetDescription &desc)

◆ produce()

template<typename Collection , typename Selector >
void edm::ThinningProducer< Collection, Selector >::produce ( Event event,
EventSetup const &  eventSetup 
)
override

Definition at line 118 of file ThinningProducer.h.

References edmPickEvents::event, options_cfi::eventSetup, edm::detail::fillCollectionForThinning(), edm::OrphanHandleBase::id(), HLT_2022v11_cff::inputCollection, eostools::move(), edm::ThinnedAssociation::setParentCollectionID(), and edm::ThinnedAssociation::setThinnedCollectionID().

118  {
119  auto inputCollection = event.getHandle(inputToken_);
120 
121  edm::Event const& constEvent = event;
122  selector_->preChoose(inputCollection, constEvent, eventSetup);
123 
124  Collection thinnedCollection;
125  ThinnedAssociation thinnedAssociation;
126 
127  unsigned int iIndex = 0;
128  for (auto iter = inputCollection->begin(), iterEnd = inputCollection->end(); iter != iterEnd; ++iter, ++iIndex) {
129  using namespace detail;
130  fillCollectionForThinning(*iter, *selector_, iIndex, thinnedCollection, thinnedAssociation);
131  }
132  selector_->reset();
133 
134  OrphanHandle<Collection> orphanHandle = event.emplace(outputToken_, std::move(thinnedCollection));
135 
136  thinnedAssociation.setParentCollectionID(inputCollection.id());
137  thinnedAssociation.setThinnedCollectionID(orphanHandle.id());
138  event.emplace(thinnedOutToken_, std::move(thinnedAssociation));
139  }
edm::propagate_const< std::unique_ptr< Selector > > selector_
edm::EDPutTokenT< Collection > outputToken_
edm::EDGetTokenT< Collection > inputToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_
void fillCollectionForThinning(edmNew::DetSet< T > const &detset, Selector &selector, unsigned int &iIndex, edmNew::DetSetVector< T > &output, edm::ThinnedAssociation &association)
def move(src, dest)
Definition: eostools.py:511

◆ registerThinnedAssociations()

template<typename Collection , typename Selector >
void edm::ThinningProducer< Collection, Selector >::registerThinnedAssociations ( ProductRegistry const &  productRegistry,
ThinnedAssociationsHelper thinnedAssociationsHelper 
)
override

Definition at line 142 of file ThinningProducer.h.

References edm::ThinnedAssociationsHelper::addAssociation(), submitPVResolutionJobs::desc, edm::InputTag::instance(), edm::InputTag::label(), edm::InputTag::process(), edm::ProductRegistry::productList(), and edm::InputTag::willSkipCurrentProcess().

143  {
144  BranchID associationID;
145  BranchID thinnedCollectionID;
146 
147  // If the InputTag does not specify the process name, it is
148  // possible that there will be more than one match found below.
149  // For a particular event only one match is correct and the
150  // others will be false. It even possible for some events one
151  // match is correct and for others another is correct. This is
152  // a side effect of the lookup mechanisms when the process name
153  // is not specified.
154  // When using the registry this generates one would have to
155  // check the ProductIDs in ThinnedAssociation product to get
156  // the correct association. This ambiguity will probably be
157  // rare and possibly never occur in practice.
158  std::vector<BranchID> parentCollectionIDs;
159 
160  ProductRegistry::ProductList const& productList = productRegistry.productList();
161  for (auto const& product : productList) {
162  BranchDescription const& desc = product.second;
163  if (desc.unwrappedType().typeInfo() == typeid(Collection)) {
164  if (desc.produced() && desc.moduleLabel() == moduleDescription().moduleLabel() &&
165  desc.productInstanceName().empty()) {
166  thinnedCollectionID = desc.branchID();
167  }
168  if (desc.moduleLabel() == inputTag_.label() && desc.productInstanceName() == inputTag_.instance()) {
170  if (!desc.produced()) {
171  parentCollectionIDs.push_back(desc.branchID());
172  }
173  } else if (inputTag_.process().empty() || inputTag_.process() == desc.processName()) {
174  if (desc.produced()) {
175  parentCollectionIDs.push_back(desc.originalBranchID());
176  } else {
177  parentCollectionIDs.push_back(desc.branchID());
178  }
179  }
180  }
181  }
182  if (desc.produced() && desc.unwrappedType().typeInfo() == typeid(ThinnedAssociation) &&
183  desc.moduleLabel() == moduleDescription().moduleLabel() && desc.productInstanceName().empty()) {
184  associationID = desc.branchID();
185  }
186  }
187  if (parentCollectionIDs.empty()) {
188  // This could happen if the input collection was dropped. Go ahead and add
189  // an entry and let the exception be thrown only if the module is run (when
190  // it cannot find the product).
191  thinnedAssociationsHelper.addAssociation(BranchID(), associationID, thinnedCollectionID, isSlimming);
192  } else {
193  for (auto const& parentCollectionID : parentCollectionIDs) {
194  thinnedAssociationsHelper.addAssociation(parentCollectionID, associationID, thinnedCollectionID, isSlimming);
195  }
196  }
197  }
std::string const & instance() const
Definition: InputTag.h:37
std::map< BranchKey, BranchDescription > ProductList
std::string const & label() const
Definition: InputTag.h:36
static constexpr bool isSlimming
bool willSkipCurrentProcess() const
Definition: InputTag.h:42
std::string const & process() const
Definition: InputTag.h:40

Member Data Documentation

◆ inputTag_

template<typename Collection , typename Selector >
edm::InputTag edm::ThinningProducer< Collection, Selector >::inputTag_
private

◆ inputToken_

template<typename Collection , typename Selector >
edm::EDGetTokenT<Collection> edm::ThinningProducer< Collection, Selector >::inputToken_
private

◆ isSlimming

template<typename Collection , typename Selector >
constexpr bool edm::ThinningProducer< Collection, Selector >::isSlimming = detail::IsStdOptional<SelectorChooseReturnType>::value
staticprivate

Definition at line 89 of file ThinningProducer.h.

◆ outputToken_

template<typename Collection , typename Selector >
edm::EDPutTokenT<Collection> edm::ThinningProducer< Collection, Selector >::outputToken_
private

◆ selector_

template<typename Collection , typename Selector >
edm::propagate_const<std::unique_ptr<Selector> > edm::ThinningProducer< Collection, Selector >::selector_
private

Definition at line 81 of file ThinningProducer.h.

◆ thinnedOutToken_

template<typename Collection , typename Selector >
edm::EDPutTokenT<ThinnedAssociation> edm::ThinningProducer< Collection, Selector >::thinnedOutToken_
private