CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ObjectViewCleaner< T > Class Template Reference
Inheritance diagram for ObjectViewCleaner< T >:
edm::stream::EDProducer< edm::GlobalCache< Counters > > edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void endJob () override
 
 ObjectViewCleaner (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~ObjectViewCleaner () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< Counters > >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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 > > srcCandsToken_
 
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcObjectsTokens_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< Counters > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- 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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

template<typename T>
class ObjectViewCleaner< T >

Definition at line 52 of file ObjectViewCleaner.cc.

Constructor & Destructor Documentation

◆ ObjectViewCleaner()

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

Definition at line 85 of file ObjectViewCleaner.cc.

89  iConfig.getParameter<vector<edm::InputTag>>("srcObjectsToRemove"),
90  [this](edm::InputTag const& tag) { return consumes<edm::View<reco::Candidate>>(tag); })),
91  deltaRMin_(iConfig.getParameter<double>("deltaRMin")),
92  moduleLabel_(iConfig.getParameter<string>("@module_label")),
93  objKeepCut_(iConfig.existsAs<std::string>("srcObjectSelection")
94  ? iConfig.getParameter<std::string>("srcObjectSelection")
95  : "",
96  true),
97  objRemoveCut_(iConfig.existsAs<std::string>("srcObjectsToRemoveSelection")
98  ? iConfig.getParameter<std::string>("srcObjectsToRemoveSelection")
99  : "",
100  true),
101  nObjectsTot_(0),
102  nObjectsClean_(0) {
103  produces<edm::RefToBaseVector<T>>();

◆ ~ObjectViewCleaner()

template<typename T >
ObjectViewCleaner< T >::~ObjectViewCleaner ( )
override

Definition at line 107 of file ObjectViewCleaner.cc.

Member Function Documentation

◆ endJob()

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

Reimplemented from edm::EDProducer.

Definition at line 159 of file ObjectViewCleaner.cc.

160  {
161  stringstream ss;
162  ss << "nObjectsTot=" << nObjectsTot_ << " nObjectsClean=" << nObjectsClean_
163  << " fObjectsClean=" << 100. * (nObjectsClean_ / (double)nObjectsTot_) << "%\n";
164  edm::LogInfo("ObjectViewCleaner") << "++++++++++++++++++++++++++++++++++++++++++++++++++"
165  << "\n"
166  << moduleLabel_ << "(ObjectViewCleaner) SUMMARY:\n"
167  << ss.str() << "++++++++++++++++++++++++++++++++++++++++++++++++++";

References contentValuesCheck::ss.

◆ produce()

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

Implements edm::EDProducer.

Definition at line 115 of file ObjectViewCleaner.cc.

116  {
117  auto cleanObjects = std::make_unique<edm::RefToBaseVector<T>>();
118 
120  iEvent.getByToken(srcCandsToken_, candidates);
121 
122  bool* isClean = new bool[candidates->size()];
123  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++)
124  isClean[iObject] = true;
125 
126  for (unsigned int iSrc = 0; iSrc < srcObjectsTokens_.size(); iSrc++) {
128  iEvent.getByToken(srcObjectsTokens_[iSrc], objects);
129 
130  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++) {
131  const T& candidate = candidates->at(iObject);
132  if (!objKeepCut_(candidate))
133  isClean[iObject] = false;
134 
135  for (unsigned int iObj = 0; iObj < objects->size(); iObj++) {
136  const reco::Candidate& obj = objects->at(iObj);
137  if (!objRemoveCut_(obj))
138  continue;
139 
140  double deltaR = reco::deltaR(candidate, obj);
141  if (deltaR < deltaRMin_)
142  isClean[iObject] = false;
143  }
144  }
145  }
146 
147  for (unsigned int iObject = 0; iObject < candidates->size(); iObject++)
148  if (isClean[iObject])
149  cleanObjects->push_back(candidates->refAt(iObject));
150 
151  nObjectsTot_ += candidates->size();
152  nObjectsClean_ += cleanObjects->size();
153 
154  delete[] isClean;
155  iEvent.put(std::move(cleanObjects));

References HLT_2018_cff::candidates, reco::deltaR(), PbPb_ZMuSkimMuonDPG_cff::deltaR, iEvent, eostools::move(), and getGTfromDQMFile::obj.

Member Data Documentation

◆ deltaRMin_

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

Definition at line 84 of file ObjectViewCleaner.cc.

◆ moduleLabel_

template<typename T >
std::string ObjectViewCleaner< T >::moduleLabel_
private

◆ nObjectsClean_

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

Definition at line 92 of file ObjectViewCleaner.cc.

◆ nObjectsTot_

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

Definition at line 91 of file ObjectViewCleaner.cc.

◆ objKeepCut_

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

Definition at line 88 of file ObjectViewCleaner.cc.

◆ objRemoveCut_

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

Definition at line 89 of file ObjectViewCleaner.cc.

◆ srcCandsToken_

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

Definition at line 82 of file ObjectViewCleaner.cc.

◆ srcObjectsTokens_

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

Definition at line 83 of file ObjectViewCleaner.cc.

objects
Definition: __init__.py:1
edm::LogInfo
Definition: MessageLogger.h:254
ObjectViewCleaner::deltaRMin_
double deltaRMin_
Definition: ObjectViewCleaner.cc:84
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
edm::Handle
Definition: AssociativeIterator.h:50
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
ObjectViewCleaner::nObjectsTot_
unsigned int nObjectsTot_
Definition: ObjectViewCleaner.cc:91
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
ObjectViewCleaner::nObjectsClean_
unsigned int nObjectsClean_
Definition: ObjectViewCleaner.cc:92
ObjectViewCleaner::srcCandsToken_
edm::EDGetTokenT< edm::View< T > > srcCandsToken_
Definition: ObjectViewCleaner.cc:82
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
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
ObjectViewCleaner::moduleLabel_
std::string moduleLabel_
Definition: ObjectViewCleaner.cc:86
edm::View
Definition: CaloClusterFwd.h:14
iEvent
int iEvent
Definition: GenABIO.cc:224
ObjectViewCleaner::objKeepCut_
StringCutObjectSelector< T, true > objKeepCut_
Definition: ObjectViewCleaner.cc:88
reco::Candidate
Definition: Candidate.h:27
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
T
long double T
Definition: Basic3DVectorLD.h:48
HLT_2018_cff.candidates
candidates
Definition: HLT_2018_cff.py:53513
ObjectViewCleaner::srcObjectsTokens_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcObjectsTokens_
Definition: ObjectViewCleaner.cc:83
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
ObjectViewCleaner::objRemoveCut_
StringCutObjectSelector< reco::Candidate, true > objRemoveCut_
Definition: ObjectViewCleaner.cc:89
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
edm::InputTag
Definition: InputTag.h:15