CMS 3D CMS Logo

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

Public Member Functions

void endJob () override
 
 ObjectViewMatcher (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~ObjectViewMatcher () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double deltaRMax_
 
std::string moduleLabel_
 
unsigned int nObjectsMatch_
 
unsigned int nObjectsTot_
 
StringCutObjectSelector< T1, true > objCut_
 
StringCutObjectSelector< T2, true > objMatchCut_
 
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
 
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

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

Definition at line 48 of file ObjectViewMatcher.cc.

Constructor & Destructor Documentation

◆ ObjectViewMatcher()

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

Definition at line 80 of file ObjectViewMatcher.cc.

84  edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>("srcObjectsToMatch"),
85  [this](edm::InputTag const& tag) { return consumes<edm::View<T2>>(tag); })),
86  deltaRMax_(iConfig.getParameter<double>("deltaRMax")),
87  moduleLabel_(iConfig.getParameter<std::string>("@module_label")),
88  objCut_(iConfig.existsAs<std::string>("srcObjectSelection")
89  ? iConfig.getParameter<std::string>("srcObjectSelection")
90  : "",
91  true),
92  objMatchCut_(iConfig.existsAs<std::string>("srcObjectsToMatchSelection")
93  ? iConfig.getParameter<std::string>("srcObjectsToMatchSelection")
94  : "",
95  true),
96  nObjectsTot_(0),
97  nObjectsMatch_(0) {
98  produces<std::vector<T1>>();

◆ ~ObjectViewMatcher()

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

Definition at line 102 of file ObjectViewMatcher.cc.

Member Function Documentation

◆ endJob()

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

Reimplemented from edm::EDProducer.

Definition at line 159 of file ObjectViewMatcher.cc.

160  {
161  std::stringstream ss;
162  ss << "nObjectsTot=" << nObjectsTot_ << " nObjectsMatched=" << nObjectsMatch_
163  << " fObjectsMatch=" << 100. * (nObjectsMatch_ / (double)nObjectsTot_) << "%\n";
164  std::cout << "++++++++++++++++++++++++++++++++++++++++++++++++++"
165  << "\n"
166  << moduleLabel_ << "(ObjectViewMatcher) SUMMARY:\n"
167  << ss.str() << "++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;

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

◆ produce()

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

Implements edm::EDProducer.

Definition at line 110 of file ObjectViewMatcher.cc.

111  {
112  auto cleanObjects = std::make_unique<std::vector<T1>>();
113 
115  iEvent.getByToken(srcCandsToken_, candidates);
116 
117  bool* isMatch = new bool[candidates->size()];
118  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++)
119  isMatch[iObject] = false;
120 
121  for (unsigned int iSrc = 0; iSrc < srcObjectsTokens_.size(); iSrc++) {
123  iEvent.getByToken(srcObjectsTokens_[iSrc], objects);
124 
125  if (objects->empty())
126  continue;
127 
128  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++) {
129  const T1& candidate = candidates->at(iObject);
130  if (!objCut_(candidate))
131  continue;
132 
133  for (unsigned int iObj = 0; iObj < objects->size(); iObj++) {
134  const T2& obj = objects->at(iObj);
135  if (!objMatchCut_(obj))
136  continue;
137  double deltaR = reco::deltaR(candidate, obj);
138  if (deltaR < deltaRMax_)
139  isMatch[iObject] = true;
140  }
141  }
142  }
143 
144  unsigned int counter = 0;
145  typename edm::View<T1>::const_iterator tIt, endcands = candidates->end();
146  for (tIt = candidates->begin(); tIt != endcands; ++tIt, ++counter) {
147  if (isMatch[counter])
148  cleanObjects->push_back(*tIt);
149  }
150 
151  nObjectsTot_ += candidates->size();
152  nObjectsMatch_ += cleanObjects->size();
153 
154  delete[] isMatch;
155  iEvent.put(std::move(cleanObjects));

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

Member Data Documentation

◆ deltaRMax_

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

Definition at line 78 of file ObjectViewMatcher.cc.

◆ moduleLabel_

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

◆ nObjectsMatch_

template<typename T1 , typename T2 >
unsigned int ObjectViewMatcher< T1, T2 >::nObjectsMatch_
private

Definition at line 87 of file ObjectViewMatcher.cc.

◆ nObjectsTot_

template<typename T1 , typename T2 >
unsigned int ObjectViewMatcher< T1, T2 >::nObjectsTot_
private

Definition at line 86 of file ObjectViewMatcher.cc.

◆ objCut_

template<typename T1 , typename T2 >
StringCutObjectSelector<T1, true> ObjectViewMatcher< T1, T2 >::objCut_
private

Definition at line 82 of file ObjectViewMatcher.cc.

◆ objMatchCut_

template<typename T1 , typename T2 >
StringCutObjectSelector<T2, true> ObjectViewMatcher< T1, T2 >::objMatchCut_
private

Definition at line 84 of file ObjectViewMatcher.cc.

◆ srcCandsToken_

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

Definition at line 76 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 77 of file ObjectViewMatcher.cc.

counter
Definition: counter.py:1
ObjectViewMatcher::srcCandsToken_
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
Definition: ObjectViewMatcher.cc:76
gather_cfg.cout
cout
Definition: gather_cfg.py:144
objects
Definition: __init__.py:1
ObjectViewMatcher::objCut_
StringCutObjectSelector< T1, true > objCut_
Definition: ObjectViewMatcher.cc:82
ObjectViewMatcher::nObjectsTot_
unsigned int nObjectsTot_
Definition: ObjectViewMatcher.cc:86
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::Handle
Definition: AssociativeIterator.h:50
ObjectViewMatcher::deltaRMax_
double deltaRMax_
Definition: ObjectViewMatcher.cc:78
ObjectViewMatcher::objMatchCut_
StringCutObjectSelector< T2, true > objMatchCut_
Definition: ObjectViewMatcher.cc:84
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
ObjectViewMatcher::srcObjectsTokens_
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
Definition: ObjectViewMatcher.cc:77
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
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
edm::View
Definition: CaloClusterFwd.h:14
iEvent
int iEvent
Definition: GenABIO.cc:224
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
hgcalPerformanceValidation.objects
objects
Definition: hgcalPerformanceValidation.py:695
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:55048
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ObjectViewMatcher::nObjectsMatch_
unsigned int nObjectsMatch_
Definition: ObjectViewMatcher.cc:87
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
edm::InputTag
Definition: InputTag.h:15
ObjectViewMatcher::moduleLabel_
std::string moduleLabel_
Definition: ObjectViewMatcher.cc:80