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 ()
 
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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 

Detailed Description

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

Definition at line 51 of file ObjectViewMatcher.cc.

Constructor & Destructor Documentation

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

Definition at line 86 of file ObjectViewMatcher.cc.

References ObjectViewMatcher< T1, T2 >::deltaRMax_, ObjectViewMatcher< T1, T2 >::moduleLabel_, ObjectViewMatcher< T1, T2 >::nObjectsMatch_, ObjectViewMatcher< T1, T2 >::nObjectsTot_, ObjectViewMatcher< T1, T2 >::objCut_, ObjectViewMatcher< T1, T2 >::objMatchCut_, AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

87  : srcCandsToken_ (consumes<edm::View<T1> >(iConfig.getParameter<edm::InputTag> ("srcObject")))
88  , srcObjectsTokens_ (edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >("srcObjectsToMatch"), [this](edm::InputTag const & tag){return consumes<edm::View<T2> >(tag);}))
89  , deltaRMax_ (iConfig.getParameter<double> ("deltaRMax"))
90  , moduleLabel_(iConfig.getParameter<std::string> ("@module_label"))
91  , objCut_(iConfig.existsAs<std::string>("srcObjectSelection") ? iConfig.getParameter<std::string>("srcObjectSelection") : "", true)
92  ,objMatchCut_(iConfig.existsAs<std::string>("srcObjectsToMatchSelection") ? iConfig.getParameter<std::string>("srcObjectsToMatchSelection") : "", true)
93  , nObjectsTot_(0)
94  , nObjectsMatch_(0)
95 {
96  produces<std::vector<T1> >();
97 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
StringCutObjectSelector< T2, true > objMatchCut_
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)
StringCutObjectSelector< T1, true > objCut_
template<typename T1 , typename T2 >
ObjectViewMatcher< T1, T2 >::~ObjectViewMatcher ( )
override

Definition at line 102 of file ObjectViewMatcher.cc.

102 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 160 of file ObjectViewMatcher.cc.

References gather_cfg::cout, ObjectViewMatcher< T1, T2 >::moduleLabel_, ObjectViewMatcher< T1, T2 >::nObjectsMatch_, and ObjectViewMatcher< T1, T2 >::nObjectsTot_.

161 {
162  std::stringstream ss;
163  ss<<"nObjectsTot="<<nObjectsTot_<<" nObjectsMatched="<<nObjectsMatch_
164  <<" fObjectsMatch="<<100.*(nObjectsMatch_/(double)nObjectsTot_)<<"%\n";
165  std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++"
166  <<"\n"<<moduleLabel_<<"(ObjectViewMatcher) SUMMARY:\n"<<ss.str()
167  <<"++++++++++++++++++++++++++++++++++++++++++++++++++"
168  << std::endl;
169 }
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
std::string moduleLabel_
template<typename T1 , typename T2 >
void ObjectViewMatcher< T1, T2 >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 112 of file ObjectViewMatcher.cc.

References edm::View< T >::begin(), objects.IsoTrackAnalyzer::candidates, counter, deltaR(), reco::deltaR(), ObjectViewMatcher< T1, T2 >::deltaRMax_, edm::Event::getByToken(), eostools::move(), ObjectViewMatcher< T1, T2 >::nObjectsMatch_, ObjectViewMatcher< T1, T2 >::nObjectsTot_, GetRecoTauVFromDQM_MC_cff::obj, ObjectViewMatcher< T1, T2 >::objCut_, ObjectViewMatcher< T1, T2 >::objMatchCut_, edm::Event::put(), ObjectViewMatcher< T1, T2 >::srcCandsToken_, and ObjectViewMatcher< T1, T2 >::srcObjectsTokens_.

113 {
114  auto cleanObjects = std::make_unique<std::vector<T1>>();
115 
117  iEvent.getByToken(srcCandsToken_,candidates);
118 
119  bool* isMatch = new bool[candidates->size()];
120  for (unsigned int iObject=0;iObject<candidates->size();iObject++) isMatch[iObject] = false;
121 
122  for (unsigned int iSrc=0;iSrc<srcObjectsTokens_.size();iSrc++) {
124  iEvent.getByToken(srcObjectsTokens_[iSrc],objects);
125 
126  if(objects->empty()) continue;
127 
128  for (unsigned int iObject=0;iObject<candidates->size();iObject++) {
129  const T1& candidate = candidates->at(iObject);
130  if (!objCut_(candidate)) continue;
131 
132 
133  for (unsigned int iObj=0;iObj<objects->size();iObj++) {
134  const T2& obj = objects->at(iObj);
135  if (!objMatchCut_(obj)) continue;
136  double deltaR = reco::deltaR(candidate,obj);
137  if (deltaR<deltaRMax_) isMatch[iObject] = true;
138  }
139  }
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]) cleanObjects->push_back( *tIt );
148  }
149 
150  nObjectsTot_ +=candidates->size();
151  nObjectsMatch_+=cleanObjects->size();
152 
153  delete [] isMatch;
154  iEvent.put(std::move(cleanObjects));
155 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
StringCutObjectSelector< T2, true > objMatchCut_
std::vector< edm::EDGetTokenT< edm::View< T2 > > > srcObjectsTokens_
edm::EDGetTokenT< edm::View< T1 > > srcCandsToken_
const_iterator begin() const
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static std::atomic< unsigned int > counter
StringCutObjectSelector< T1, true > objCut_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

template<typename T1 , typename T2 >
double ObjectViewMatcher< T1, T2 >::deltaRMax_
private
template<typename T1 , typename T2 >
std::string ObjectViewMatcher< T1, T2 >::moduleLabel_
private
template<typename T1 , typename T2 >
unsigned int ObjectViewMatcher< T1, T2 >::nObjectsMatch_
private
template<typename T1 , typename T2 >
unsigned int ObjectViewMatcher< T1, T2 >::nObjectsTot_
private
template<typename T1 , typename T2 >
StringCutObjectSelector<T1,true> ObjectViewMatcher< T1, T2 >::objCut_
private
template<typename T1 , typename T2 >
StringCutObjectSelector<T2,true> ObjectViewMatcher< T1, T2 >::objMatchCut_
private
template<typename T1 , typename T2 >
edm::EDGetTokenT<edm::View<T1> > ObjectViewMatcher< T1, T2 >::srcCandsToken_
private

Definition at line 64 of file ObjectViewMatcher.cc.

Referenced by ObjectViewMatcher< T1, T2 >::produce().

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

Definition at line 65 of file ObjectViewMatcher.cc.

Referenced by ObjectViewMatcher< T1, T2 >::produce().