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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper edm::ProductRegistryHelper

Public Member Functions

void endJob () override
 
void endJob () override
 
 ObjectViewCleaner (const edm::ParameterSet &iConfig)
 
 ObjectViewCleaner (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~ObjectViewCleaner ()
 
virtual ~ObjectViewCleaner ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

double deltaRMin_
 
std::string moduleLabel_
 
unsigned int nObjectsClean_
 
unsigned int nObjectsTot_
 
StringCutObjectSelector< T, true > objKeepCut_
 
StringCutObjectSelector
< reco::Candidate, true > 
objRemoveCut_
 
edm::EDGetTokenT< edm::View< T > > srcCands_
 
edm::EDGetTokenT< edm::View< T > > srcCandsToken_
 
std::vector< edm::EDGetTokenT
< edm::View< reco::Candidate > > > 
srcObjects_
 
std::vector< edm::EDGetTokenT
< edm::View< reco::Candidate > > > 
srcObjectsTokens_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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)
 
- 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 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.

References GlobalPosition_Frontier_DevDB_cff::tag.

90  : srcCandsToken_ (consumes<edm::View<T> >(iConfig.getParameter<edm::InputTag> ("srcObject")))
91  , srcObjectsTokens_ (edm::vector_transform(iConfig.getParameter<vector<edm::InputTag> >("srcObjectsToRemove"), [this](edm::InputTag const & tag){return consumes<edm::View<reco::Candidate> >(tag);}))
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< T > > 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)
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcObjectsTokens_
template<typename T >
ObjectViewCleaner< T >::~ObjectViewCleaner ( )
virtual

Definition at line 105 of file ObjectViewCleaner.cc.

106 {
107 
108 }
template<typename T >
ObjectViewCleaner< T >::ObjectViewCleaner ( const edm::ParameterSet iConfig)
template<typename T >
virtual ObjectViewCleaner< T >::~ObjectViewCleaner ( )
virtual

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 160 of file ObjectViewCleaner.cc.

References moduleLabel_(), nObjectsClean_(), nObjectsTot_(), and contentValuesCheck::ss.

161 {
162  stringstream ss;
163  ss<<"nObjectsTot="<<nObjectsTot_<<" nObjectsClean="<<nObjectsClean_
164  <<" fObjectsClean="<<100.*(nObjectsClean_/(double)nObjectsTot_)<<"%\n";
165  edm::LogInfo("ObjectViewCleaner")<<"++++++++++++++++++++++++++++++++++++++++++++++++++"
166  <<"\n"<<moduleLabel_<<"(ObjectViewCleaner) SUMMARY:\n"<<ss.str()
167  <<"++++++++++++++++++++++++++++++++++++++++++++++++++";
168 }
unsigned int nObjectsTot_
unsigned int nObjectsClean_
std::string moduleLabel_
template<typename T >
void ObjectViewCleaner< T >::endJob ( )
overridevirtual

Reimplemented from edm::EDProducer.

template<typename T >
void ObjectViewCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

template<typename T >
void ObjectViewCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 118 of file ObjectViewCleaner.cc.

References objects.IsoTrackAnalyzer::candidates, deltaR(), reco::deltaR(), deltaRMin_(), edm::Event::getByToken(), nObjectsClean_(), nObjectsTot_(), getGTfromDQMFile::obj, objKeepCut_(), objRemoveCut_(), and edm::Event::put().

119 {
120  auto_ptr<edm::RefToBaseVector<T> >
121  cleanObjects(new edm::RefToBaseVector<T >());
122 
124  iEvent.getByToken(srcCandsToken_,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<srcObjectsTokens_.size();iSrc++) {
131  iEvent.getByToken(srcObjectsTokens_[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_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
unsigned int nObjectsClean_
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
edm::EDGetTokenT< edm::View< T > > srcCandsToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
StringCutObjectSelector< reco::Candidate, true > objRemoveCut_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
StringCutObjectSelector< T, true > objKeepCut_
long double T
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcObjectsTokens_

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::EDGetTokenT<edm::View<T> > ObjectViewCleaner< T >::srcCands_
private

Definition at line 67 of file ObjectViewCleaner.cc.

template<typename T >
edm::EDGetTokenT<edm::View<T> > ObjectViewCleaner< T >::srcCandsToken_
private

Definition at line 67 of file ObjectViewCleaner.cc.

template<typename T >
std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > > ObjectViewCleaner< T >::srcObjects_
private

Definition at line 68 of file ObjectViewCleaner.cc.

template<typename T >
std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > > ObjectViewCleaner< T >::srcObjectsTokens_
private

Definition at line 68 of file ObjectViewCleaner.cc.