CMS 3D CMS Logo

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

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Attributes

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

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 30 of file ThinningProducer.h.

Constructor & Destructor Documentation

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

Definition at line 51 of file ThinningProducer.h.

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

51  :
52  selector_(new Selector(pset, consumesCollector())) {
53 
54  inputTag_ = pset.getParameter<InputTag>("inputTag");
55  inputToken_ = consumes<Collection>(inputTag_);
56 
57  outputToken_ = produces<Collection>();
58  thinnedOutToken_ = produces<ThinnedAssociation>();
59  }
edm::propagate_const< std::unique_ptr< Selector > > selector_
edm::EDPutTokenT< Collection > outputToken_
edm::EDGetTokenT< Collection > inputToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_
template<typename Collection , typename Selector >
edm::ThinningProducer< Collection, Selector >::~ThinningProducer ( )
virtual

Member Function Documentation

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

Definition at line 67 of file ThinningProducer.h.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), edm::ThinningProducer< Collection, Selector >::produce(), and edm::ParameterSetDescription::setComment().

Referenced by edm::ThinningProducer< Collection, Selector >::~ThinningProducer().

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

Definition at line 77 of file ThinningProducer.h.

References event(), edm::OrphanHandleBase::id(), edm::HandleBase::id(), genParticles_cff::inputCollection, edm::ThinningProducer< Collection, Selector >::inputToken_, eostools::move(), edm::ThinningProducer< Collection, Selector >::outputToken_, edm::ThinnedAssociation::push_back(), edm::ThinningProducer< Collection, Selector >::registerThinnedAssociations(), edm::ThinningProducer< Collection, Selector >::selector_, edm::ThinnedAssociation::setParentCollectionID(), edm::ThinnedAssociation::setThinnedCollectionID(), and edm::ThinningProducer< Collection, Selector >::thinnedOutToken_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), HTMLExport.HTMLExportStatic::export(), and edm::ThinningProducer< Collection, Selector >::fillDescriptions().

77  {
78 
80  event.getByToken(inputToken_, inputCollection);
81 
82  edm::Event const& constEvent = event;
83  selector_->preChoose(inputCollection, constEvent, eventSetup);
84 
85  Collection thinnedCollection;
86  ThinnedAssociation thinnedAssociation;
87 
88  unsigned int iIndex = 0;
89  for(auto iter = inputCollection->begin(), iterEnd = inputCollection->end();
90  iter != iterEnd; ++iter, ++iIndex) {
91  if(selector_->choose(iIndex, *iter)) {
92  thinnedCollection.push_back(*iter);
93  thinnedAssociation.push_back(iIndex);
94  }
95  }
96  OrphanHandle<Collection> orphanHandle = event.emplace(outputToken_,std::move(thinnedCollection));
97 
98  thinnedAssociation.setParentCollectionID(inputCollection.id());
99  thinnedAssociation.setThinnedCollectionID(orphanHandle.id());
100  event.emplace(thinnedOutToken_,std::move(thinnedAssociation));
101  }
ProductID id() const
Definition: HandleBase.cc:15
edm::propagate_const< std::unique_ptr< Selector > > selector_
edm::EDPutTokenT< Collection > outputToken_
edm::EDGetTokenT< Collection > inputToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_
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
def move(src, dest)
Definition: eostools.py:511
template<typename Collection , typename Selector >
void edm::ThinningProducer< Collection, Selector >::registerThinnedAssociations ( ProductRegistry const &  productRegistry,
ThinnedAssociationsHelper thinnedAssociationsHelper 
)
overridevirtual

Definition at line 105 of file ThinningProducer.h.

References edm::ThinnedAssociationsHelper::addAssociation(), edm::BranchDescription::branchID(), edm::ThinningProducer< Collection, Selector >::inputTag_, edm::InputTag::instance(), edm::InputTag::label(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::originalBranchID(), edm::InputTag::process(), edm::BranchDescription::processName(), edm::BranchDescription::produced(), edm::BranchDescription::productInstanceName(), edm::ProductRegistry::productList(), edm::TypeWithDict::typeInfo(), edm::BranchDescription::unwrappedType(), and edm::InputTag::willSkipCurrentProcess().

Referenced by edm::ThinningProducer< Collection, Selector >::produce().

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

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 >
edm::EDPutTokenT<Collection> edm::ThinningProducer< Collection, Selector >::outputToken_
private
template<typename Collection , typename Selector >
edm::propagate_const<std::unique_ptr<Selector> > edm::ThinningProducer< Collection, Selector >::selector_
private
template<typename Collection , typename Selector >
edm::EDPutTokenT<ThinnedAssociation> edm::ThinningProducer< Collection, Selector >::thinnedOutToken_
private