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

Public Member Functions

void endJob ()
 
 ObjectViewMatcher (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
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 &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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.

87  : srcCands_ (iConfig.getParameter<edm::InputTag> ("srcObject"))
88  , srcObjects_ (iConfig.getParameter<std::vector<edm::InputTag> >("srcObjectsToMatch"))
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
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 102 of file ObjectViewMatcher.cc.

102 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 160 of file ObjectViewMatcher.cc.

References gather_cfg::cout.

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_
tuple cout
Definition: gather_cfg.py:121
template<typename T1 , typename T2 >
void ObjectViewMatcher< T1, T2 >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 112 of file ObjectViewMatcher.cc.

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

113 {
114  std::auto_ptr<std::vector<T1> > cleanObjects(new std::vector<T1 >);
115 
116  edm::Handle<edm::View<T1> > candidates;
117  iEvent.getByLabel(srcCands_,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<srcObjects_.size();iSrc++) {
123  edm::Handle<edm::View<T2> > objects;
124  iEvent.getByLabel(srcObjects_[iSrc],objects);
125 
126  if(objects->size()==0) 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(cleanObjects);
155 }
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_
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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 66 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 75 of file ObjectViewMatcher.cc.

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

Definition at line 74 of file ObjectViewMatcher.cc.

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

Definition at line 70 of file ObjectViewMatcher.cc.

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

Definition at line 71 of file ObjectViewMatcher.cc.

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

Definition at line 64 of file ObjectViewMatcher.cc.

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

Definition at line 65 of file ObjectViewMatcher.cc.