CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
 ObjectViewMatcher (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~ObjectViewMatcher ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

double deltaRMax_
 
std::string moduleLabel_
 
unsigned int nObjectsMatch_
 
unsigned int nObjectsTot_
 
StringCutObjectSelector< T1, true > objCut_
 
StringCutObjectSelector< T2, true > objMatchCut_
 
edm::InputTag srcCands_
 
std::vector< edm::InputTagsrcObjects_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 50 of file ObjectViewMatcher.cc.

Constructor & Destructor Documentation

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

Definition at line 85 of file ObjectViewMatcher.cc.

86  : srcCands_ (iConfig.getParameter<edm::InputTag> ("srcObject"))
87  , srcObjects_ (iConfig.getParameter<std::vector<edm::InputTag> >("srcObjectsToMatch"))
88  , deltaRMax_ (iConfig.getParameter<double> ("deltaRMax"))
89  , moduleLabel_(iConfig.getParameter<std::string> ("@module_label"))
90  , objCut_(iConfig.existsAs<std::string>("srcObjectSelection") ? iConfig.getParameter<std::string>("srcObjectSelection") : "", true)
91  ,objMatchCut_(iConfig.existsAs<std::string>("srcObjectsToMatchSelection") ? iConfig.getParameter<std::string>("srcObjectsToMatchSelection") : "", true)
92  , nObjectsTot_(0)
93  , nObjectsMatch_(0)
94 {
95  produces<std::vector<T1> >();
96 }
T getParameter(std::string const &) const
edm::InputTag srcCands_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
StringCutObjectSelector< T2, true > objMatchCut_
std::string moduleLabel_
std::vector< edm::InputTag > srcObjects_
StringCutObjectSelector< T1, true > objCut_
template<typename T1 , typename T2 >
ObjectViewMatcher< T1, T2 >::~ObjectViewMatcher ( )
virtual

Definition at line 101 of file ObjectViewMatcher.cc.

101 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 159 of file ObjectViewMatcher.cc.

References gather_cfg::cout.

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

Implements edm::EDProducer.

Definition at line 111 of file ObjectViewMatcher.cc.

References deltaR(), reco::deltaR(), edm::Event::getByLabel(), getGTfromDQMFile::obj, and edm::Event::put().

112 {
113  std::auto_ptr<std::vector<T1> > cleanObjects(new std::vector<T1 >);
114 
115  edm::Handle<edm::View<T1> > candidates;
116  iEvent.getByLabel(srcCands_,candidates);
117 
118  bool* isMatch = new bool[candidates->size()];
119  for (unsigned int iObject=0;iObject<candidates->size();iObject++) isMatch[iObject] = false;
120 
121  for (unsigned int iSrc=0;iSrc<srcObjects_.size();iSrc++) {
122  edm::Handle<edm::View<T2> > objects;
123  iEvent.getByLabel(srcObjects_[iSrc],objects);
124 
125  if(objects->size()==0) continue;
126 
127  for (unsigned int iObject=0;iObject<candidates->size();iObject++) {
128  const T1& candidate = candidates->at(iObject);
129  if (!objCut_(candidate)) continue;
130 
131 
132  for (unsigned int iObj=0;iObj<objects->size();iObj++) {
133  const T2& obj = objects->at(iObj);
134  if (!objMatchCut_(obj)) continue;
135  double deltaR = reco::deltaR(candidate,obj);
136  if (deltaR<deltaRMax_) isMatch[iObject] = true;
137  }
138  }
139  }
140 
141 
142 
143  unsigned int counter=0;
144  typename edm::View<T1>::const_iterator tIt, endcands = candidates->end();
145  for (tIt = candidates->begin(); tIt != endcands; ++tIt, ++counter) {
146  if(isMatch[counter]) cleanObjects->push_back( *tIt );
147  }
148 
149  nObjectsTot_ +=candidates->size();
150  nObjectsMatch_+=cleanObjects->size();
151 
152  delete [] isMatch;
153  iEvent.put(cleanObjects);
154 }
edm::InputTag srcCands_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
unsigned int nObjectsMatch_
unsigned int nObjectsTot_
StringCutObjectSelector< T2, true > objMatchCut_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< edm::InputTag > srcObjects_
StringCutObjectSelector< T1, true > objCut_

Member Data Documentation

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

Definition at line 65 of file ObjectViewMatcher.cc.

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

Definition at line 74 of file ObjectViewMatcher.cc.

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

Definition at line 73 of file ObjectViewMatcher.cc.

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

Definition at line 69 of file ObjectViewMatcher.cc.

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

Definition at line 70 of file ObjectViewMatcher.cc.

template<typename T1 , typename T2 >
edm::InputTag ObjectViewMatcher< T1, T2 >::srcCands_
private

Definition at line 63 of file ObjectViewMatcher.cc.

template<typename T1 , typename T2 >
std::vector<edm::InputTag> ObjectViewMatcher< T1, T2 >::srcObjects_
private

Definition at line 64 of file ObjectViewMatcher.cc.