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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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  }

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_.

◆ ~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.

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

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

◆ 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.

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  }

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

◆ 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.

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  }

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

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
staticconstexprprivate

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
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edmNew::fillCollectionForThinning
void fillCollectionForThinning(edmNew::DetSet< T > const &detset, Selector &selector, unsigned int &iIndex, edmNew::DetSetVector< T > &output, edm::ThinnedAssociation &association)
Definition: DetSetVectorNew.h:725
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
edm::ThinningProducer::outputToken_
edm::EDPutTokenT< Collection > outputToken_
Definition: ThinningProducer.h:84
detail
Definition: ConvertingESProducerWithDependenciesT.h:23
edm::ThinningProducer::selector_
edm::propagate_const< std::unique_ptr< Selector > > selector_
Definition: ThinningProducer.h:81
edm::InputTag::willSkipCurrentProcess
bool willSkipCurrentProcess() const
Definition: InputTag.h:42
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::ThinningProducer::inputToken_
edm::EDGetTokenT< Collection > inputToken_
Definition: ThinningProducer.h:82
PDWG_EXOHSCP_cff.inputCollection
inputCollection
Definition: PDWG_EXOHSCP_cff.py:56
edm::ProductRegistry::ProductList
std::map< BranchKey, BranchDescription > ProductList
Definition: ProductRegistry.h:39
reco::modules::fillPSetDescription
void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: ParameterAdapter.h:34
edm::ThinningProducer::thinnedOutToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_
Definition: ThinningProducer.h:85
edmPickEvents.event
event
Definition: edmPickEvents.py:273
edm::ThinningProducer::inputTag_
edm::InputTag inputTag_
Definition: ThinningProducer.h:83
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
ALCARECOPromptCalibProdSiPixelAli0T_cff.Selector
Selector
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:81
ParameterSetDescription
edm::Event
Definition: Event.h:73
edm::ThinningProducer::isSlimming
static constexpr bool isSlimming
Definition: ThinningProducer.h:89
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27