CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
ObjectViewMatcher< T1, T2 > Class Template Reference
Inheritance diagram for ObjectViewMatcher< T1, T2 >:
edm::global::EDProducer< edm::StreamCache< ovm::StreamCache< T1, T2 > > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

std::unique_ptr< ovm::StreamCache< T1, T2 > > beginStream (edm::StreamID) const override
 
void endJob () override
 
 ObjectViewMatcher (const edm::ParameterSet &iConfig)
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~ObjectViewMatcher () override
 
- Public Member Functions inherited from edm::global::EDProducer< edm::StreamCache< ovm::StreamCache< T1, T2 > > >
 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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

Private Attributes

std::string cut_
 
double deltaRMax_
 
std::string match_
 
std::string moduleLabel_
 
std::atomic< unsigned int > nObjectsMatch_
 
std::atomic< unsigned int > nObjectsTot_
 
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
 
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

template<typename T1, typename T2>
class ObjectViewMatcher< T1, T2 >

Definition at line 63 of file ObjectViewMatcher.cc.

Constructor & Destructor Documentation

◆ ObjectViewMatcher()

template<typename T1 , typename T2 >
ObjectViewMatcher< T1, T2 >::ObjectViewMatcher ( const edm::ParameterSet iConfig)

Definition at line 96 of file ObjectViewMatcher.cc.

References makeGlobalPositionRcd_cfg::tag.

97  : srcCandsToken_(this->consumes(iConfig.getParameter<edm::InputTag>("srcObject"))),
99  iConfig.getParameter<std::vector<edm::InputTag>>("srcObjectsToMatch"),
100  [this](edm::InputTag const& tag) { return this->template consumes<edm::View<T2>>(tag); })),
101  deltaRMax_(iConfig.getParameter<double>("deltaRMax")),
102  moduleLabel_(iConfig.getParameter<std::string>("@module_label")),
103  cut_(iConfig.getParameter<std::string>("srcObjectSelection")),
104  match_(iConfig.getParameter<std::string>("srcObjectsToMatchSelection")),
105  nObjectsTot_(0),
106  nObjectsMatch_(0) {
107  this->template produces<std::vector<T1>>();
108 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
std::string moduleLabel_
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::atomic< unsigned int > nObjectsMatch_
std::atomic< unsigned int > nObjectsTot_

◆ ~ObjectViewMatcher()

template<typename T1 , typename T2 >
ObjectViewMatcher< T1, T2 >::~ObjectViewMatcher ( )
override

Definition at line 112 of file ObjectViewMatcher.cc.

112 {}

Member Function Documentation

◆ beginStream()

template<typename T1 , typename T2 >
std::unique_ptr< ovm::StreamCache< T1, T2 > > ObjectViewMatcher< T1, T2 >::beginStream ( edm::StreamID  ) const
override

Definition at line 120 of file ObjectViewMatcher.cc.

120  {
121  return std::make_unique<ovm::StreamCache<T1, T2>>(cut_, match_);
122 }

◆ endJob()

template<typename T1 , typename T2 >
void ObjectViewMatcher< T1, T2 >::endJob ( void  )
overridevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 177 of file ObjectViewMatcher.cc.

References gather_cfg::cout, and contentValuesCheck::ss.

177  {
178  std::stringstream ss;
179  ss << "nObjectsTot=" << nObjectsTot_ << " nObjectsMatched=" << nObjectsMatch_
180  << " fObjectsMatch=" << 100. * (nObjectsMatch_ / (double)nObjectsTot_) << "%\n";
181  std::cout << "++++++++++++++++++++++++++++++++++++++++++++++++++"
182  << "\n"
183  << moduleLabel_ << "(ObjectViewMatcher) SUMMARY:\n"
184  << ss.str() << "++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
185 }
std::string moduleLabel_
std::atomic< unsigned int > nObjectsMatch_
std::atomic< unsigned int > nObjectsTot_

◆ fillDescriptions()

template<typename T1 , typename T2 >
void ObjectViewMatcher< T1, T2 >::fillDescriptions ( edm::ConfigurationDescriptions desc)
static

Definition at line 189 of file ObjectViewMatcher.cc.

References submitPVResolutionJobs::desc, muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

189  {
191  pset.add<edm::InputTag>("srcObject");
192  pset.add<std::vector<edm::InputTag>>("srcObjectsToMatch");
193  pset.add<double>("deltaRMax");
194  pset.add<std::string>("srcObjectSelection", "");
195  pset.add<std::string>("srcObjectsToMatchSelection", "");
196 
197  desc.addDefault(pset);
198 }

◆ produce()

template<typename T1 , typename T2 >
void ObjectViewMatcher< T1, T2 >::produce ( edm::StreamID  iID,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 126 of file ObjectViewMatcher.cc.

References HLT_2023v12_cff::candidates, counter, reco::deltaR(), PbPb_ZMuSkimMuonDPG_cff::deltaR, iEvent, eostools::move(), getGTfromDQMFile::obj, and L1TPhase2Offline_cfi::objects.

126  {
127  auto cleanObjects = std::make_unique<std::vector<T1>>();
128 
130  iEvent.getByToken(srcCandsToken_, candidates);
131 
132  bool* isMatch = new bool[candidates->size()];
133  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++)
134  isMatch[iObject] = false;
135 
136  auto& objCut = this->streamCache(iID)->objCut_;
137  auto& objMatchCut = this->streamCache(iID)->objMatchCut_;
138  for (unsigned int iSrc = 0; iSrc < srcObjectsTokens_.size(); iSrc++) {
140  iEvent.getByToken(srcObjectsTokens_[iSrc], objects);
141 
142  if (objects->empty())
143  continue;
144 
145  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++) {
146  const T1& candidate = candidates->at(iObject);
147  if (!objCut(candidate))
148  continue;
149 
150  for (unsigned int iObj = 0; iObj < objects->size(); iObj++) {
151  const T2& obj = objects->at(iObj);
152  if (!objMatchCut(obj))
153  continue;
154  double deltaR = reco::deltaR(candidate, obj);
155  if (deltaR < deltaRMax_)
156  isMatch[iObject] = true;
157  }
158  }
159  }
160 
161  unsigned int counter = 0;
162  typename edm::View<T1>::const_iterator tIt, endcands = candidates->end();
163  for (tIt = candidates->begin(); tIt != endcands; ++tIt, ++counter) {
164  if (isMatch[counter])
165  cleanObjects->push_back(*tIt);
166  }
167 
168  nObjectsTot_ += candidates->size();
169  nObjectsMatch_ += cleanObjects->size();
170 
171  delete[] isMatch;
172  iEvent.put(std::move(cleanObjects));
173 }
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
std::atomic< unsigned int > nObjectsMatch_
int iEvent
Definition: GenABIO.cc:224
std::atomic< unsigned int > nObjectsTot_
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
static std::atomic< unsigned int > counter
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ cut_

template<typename T1 , typename T2 >
std::string ObjectViewMatcher< T1, T2 >::cut_
private

Definition at line 83 of file ObjectViewMatcher.cc.

◆ deltaRMax_

template<typename T1 , typename T2 >
double ObjectViewMatcher< T1, T2 >::deltaRMax_
private

Definition at line 80 of file ObjectViewMatcher.cc.

◆ match_

template<typename T1 , typename T2 >
std::string ObjectViewMatcher< T1, T2 >::match_
private

Definition at line 84 of file ObjectViewMatcher.cc.

◆ moduleLabel_

template<typename T1 , typename T2 >
std::string ObjectViewMatcher< T1, T2 >::moduleLabel_
private

◆ nObjectsMatch_

template<typename T1 , typename T2 >
std::atomic<unsigned int> ObjectViewMatcher< T1, T2 >::nObjectsMatch_
mutableprivate

Definition at line 87 of file ObjectViewMatcher.cc.

◆ nObjectsTot_

template<typename T1 , typename T2 >
std::atomic<unsigned int> ObjectViewMatcher< T1, T2 >::nObjectsTot_
mutableprivate

Definition at line 86 of file ObjectViewMatcher.cc.

◆ srcCandsToken_

template<typename T1 , typename T2 >
edm::EDGetTokenT<edm::View<T1> > ObjectViewMatcher< T1, T2 >::srcCandsToken_
private

Definition at line 78 of file ObjectViewMatcher.cc.

◆ srcObjectsTokens_

template<typename T1 , typename T2 >
std::vector<edm::EDGetTokenT<edm::View<T2> > > ObjectViewMatcher< T1, T2 >::srcObjectsTokens_
private

Definition at line 79 of file ObjectViewMatcher.cc.