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
ObjectViewCleaner< T > Class Template Reference
Inheritance diagram for ObjectViewCleaner< T >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

void endJob ()
 
 ObjectViewCleaner (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~ObjectViewCleaner ()
 
- 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 deltaRMin_
 
std::string moduleLabel_
 
unsigned int nObjectsClean_
 
unsigned int nObjectsTot_
 
StringCutObjectSelector< T, true > objKeepCut_
 
StringCutObjectSelector
< reco::Candidate, true > 
objRemoveCut_
 
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)
 
- 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 T>
class ObjectViewCleaner< T >

Definition at line 54 of file ObjectViewCleaner.cc.

Constructor & Destructor Documentation

template<typename T >
ObjectViewCleaner< T >::ObjectViewCleaner ( const edm::ParameterSet iConfig)

Definition at line 89 of file ObjectViewCleaner.cc.

90  : srcCands_ (iConfig.getParameter<edm::InputTag> ("srcObject"))
91  , srcObjects_ (iConfig.getParameter<vector<edm::InputTag> >("srcObjectsToRemove"))
92  , deltaRMin_ (iConfig.getParameter<double> ("deltaRMin"))
93  , moduleLabel_(iConfig.getParameter<string> ("@module_label"))
94  , objKeepCut_(iConfig.existsAs<std::string>("srcObjectSelection") ? iConfig.getParameter<std::string>("srcObjectSelection") : "", true)
95  ,objRemoveCut_(iConfig.existsAs<std::string>("srcObjectsToRemoveSelection") ? iConfig.getParameter<std::string>("srcObjectsToRemoveSelection") : "", true)
96  , nObjectsTot_(0)
97  , nObjectsClean_(0)
98 {
99  produces<edm::RefToBaseVector<T> >();
100 }
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:181
unsigned int nObjectsTot_
unsigned int nObjectsClean_
std::vector< edm::InputTag > srcObjects_
edm::InputTag srcCands_
std::string moduleLabel_
StringCutObjectSelector< reco::Candidate, true > objRemoveCut_
StringCutObjectSelector< T, true > objKeepCut_
template<typename T >
ObjectViewCleaner< T >::~ObjectViewCleaner ( )
virtual

Definition at line 105 of file ObjectViewCleaner.cc.

106 {
107 
108 }

Member Function Documentation

template<typename T >
void ObjectViewCleaner< T >::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 160 of file ObjectViewCleaner.cc.

References gather_cfg::cout.

161 {
162  stringstream ss;
163  ss<<"nObjectsTot="<<nObjectsTot_<<" nObjectsClean="<<nObjectsClean_
164  <<" fObjectsClean="<<100.*(nObjectsClean_/(double)nObjectsTot_)<<"%\n";
165  cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++"
166  <<"\n"<<moduleLabel_<<"(ObjectViewCleaner) SUMMARY:\n"<<ss.str()
167  <<"++++++++++++++++++++++++++++++++++++++++++++++++++"
168  <<endl;
169 }
unsigned int nObjectsTot_
unsigned int nObjectsClean_
std::string moduleLabel_
tuple cout
Definition: gather_cfg.py:41
template<typename T >
void ObjectViewCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 118 of file ObjectViewCleaner.cc.

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

119 {
120  auto_ptr<edm::RefToBaseVector<T> >
121  cleanObjects(new edm::RefToBaseVector<T >());
122 
123  edm::Handle<edm::View<T> > candidates;
124  iEvent.getByLabel(srcCands_,candidates);
125 
126  bool* isClean = new bool[candidates->size()];
127  for (unsigned int iObject=0;iObject<candidates->size();iObject++) isClean[iObject] = true;
128 
129  for (unsigned int iSrc=0;iSrc<srcObjects_.size();iSrc++) {
131  iEvent.getByLabel(srcObjects_[iSrc],objects);
132 
133  for (unsigned int iObject=0;iObject<candidates->size();iObject++) {
134  const T& candidate = candidates->at(iObject);
135  if (!objKeepCut_(candidate)) isClean[iObject] = false;
136 
137  for (unsigned int iObj=0;iObj<objects->size();iObj++) {
138  const reco::Candidate& obj = objects->at(iObj);
139  if (!objRemoveCut_(obj)) continue;
140 
141  double deltaR = reco::deltaR(candidate,obj);
142  if (deltaR<deltaRMin_) isClean[iObject] = false;
143  }
144  }
145  }
146 
147  for (unsigned int iObject=0;iObject<candidates->size();iObject++)
148  if (isClean[iObject]) cleanObjects->push_back(candidates->refAt(iObject));
149 
150  nObjectsTot_ +=candidates->size();
151  nObjectsClean_+=cleanObjects->size();
152 
153  delete [] isClean;
154  iEvent.put(cleanObjects);
155 }
unsigned int nObjectsTot_
unsigned int nObjectsClean_
std::vector< edm::InputTag > srcObjects_
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
edm::InputTag srcCands_
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
StringCutObjectSelector< reco::Candidate, true > objRemoveCut_
long double T
StringCutObjectSelector< T, true > objKeepCut_

Member Data Documentation

template<typename T >
double ObjectViewCleaner< T >::deltaRMin_
private

Definition at line 69 of file ObjectViewCleaner.cc.

template<typename T >
std::string ObjectViewCleaner< T >::moduleLabel_
private
template<typename T >
unsigned int ObjectViewCleaner< T >::nObjectsClean_
private

Definition at line 76 of file ObjectViewCleaner.cc.

template<typename T >
unsigned int ObjectViewCleaner< T >::nObjectsTot_
private

Definition at line 75 of file ObjectViewCleaner.cc.

template<typename T >
StringCutObjectSelector<T,true> ObjectViewCleaner< T >::objKeepCut_
private

Definition at line 72 of file ObjectViewCleaner.cc.

template<typename T >
StringCutObjectSelector<reco::Candidate,true> ObjectViewCleaner< T >::objRemoveCut_
private

Definition at line 73 of file ObjectViewCleaner.cc.

template<typename T >
edm::InputTag ObjectViewCleaner< T >::srcCands_
private

Definition at line 67 of file ObjectViewCleaner.cc.

template<typename T >
std::vector<edm::InputTag> ObjectViewCleaner< T >::srcObjects_
private

Definition at line 68 of file ObjectViewCleaner.cc.