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 Types | Private Attributes
pat::PATCleaner< PATObjType > Class Template Reference

PAT Cleaner module for PAT Objects. More...

#include "PhysicsTools/PatAlgos/interface/PATCleaner.h"

Inheritance diagram for pat::PATCleaner< PATObjType >:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATCleaner (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) overridefinal
 
virtual ~PATCleaner ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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 Types

typedef pat::helper::OverlapTest OverlapTest
 
typedef
StringCutObjectSelector
< PATObjType > 
Selector
 

Private Attributes

const Selector finalCut_
 
std::vector< std::unique_ptr
< OverlapTest > > 
overlapTests_
 
const Selector preselectionCut_
 
const edm::InputTag src_
 
const edm::EDGetTokenT
< edm::View< PATObjType > > 
srcToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::stream::EDProducerBase
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<class PATObjType>
class pat::PATCleaner< PATObjType >

PAT Cleaner module for PAT Objects.

      The same module is used for all collections.
Author
Giovanni Petrucciani
Version
Id:
PATCleaner.h,v 1.3 2010/10/20 23:08:30 wmtan Exp

Definition at line 41 of file PATCleaner.h.

Member Typedef Documentation

template<class PATObjType >
typedef pat::helper::OverlapTest pat::PATCleaner< PATObjType >::OverlapTest
private

Definition at line 56 of file PATCleaner.h.

template<class PATObjType >
typedef StringCutObjectSelector<PATObjType> pat::PATCleaner< PATObjType >::Selector
private

Definition at line 49 of file PATCleaner.h.

Constructor & Destructor Documentation

template<class PATObjType >
pat::PATCleaner< PATObjType >::PATCleaner ( const edm::ParameterSet iConfig)
explicit

Definition at line 63 of file PATCleaner.h.

References HLT_25ns10e33_v2_cff::algorithm, looper::cfg, edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::empty(), Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), pat::PATCleaner< PATObjType >::overlapTests_, pat::PATCleaner< PATObjType >::src_, and AlCaHLTBitMon_QueryRunRegistry::string.

63  :
64  src_(iConfig.getParameter<edm::InputTag>("src")),
66  preselectionCut_(iConfig.getParameter<std::string>("preselection")),
67  finalCut_(iConfig.getParameter<std::string>("finalCut"))
68 {
69  // pick parameter set for overlaps
70  edm::ParameterSet overlapPSet = iConfig.getParameter<edm::ParameterSet>("checkOverlaps");
71  // get all the names of the tests (all nested PSets in this PSet)
72  std::vector<std::string> overlapNames = overlapPSet.getParameterNamesForType<edm::ParameterSet>();
73  // loop on them
74  for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) {
75  // retrieve configuration
77  // skip empty parameter sets
78  if (cfg.empty()) continue;
79  // get the name of the algorithm to use
80  std::string algorithm = cfg.getParameter<std::string>("algorithm");
81  // create the appropriate OverlapTest
82  if (algorithm == "byDeltaR") {
83  overlapTests_.emplace_back(new pat::helper::BasicOverlapTest(*itn, cfg, consumesCollector()));
84  } else if (algorithm == "bySuperClusterSeed") {
86  } else {
87  throw cms::Exception("Configuration") << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n";
88  }
89  }
90 
91 
92  produces<std::vector<PATObjType> >();
93 }
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:218
const Selector finalCut_
Definition: PATCleaner.h:54
tuple cfg
Definition: looper.py:293
const Selector preselectionCut_
Definition: PATCleaner.h:53
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
std::vector< std::unique_ptr< OverlapTest > > overlapTests_
Definition: PATCleaner.h:57
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::InputTag src_
Definition: PATCleaner.h:51
const edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
Definition: PATCleaner.h:52
template<class PATObjType >
virtual pat::PATCleaner< PATObjType >::~PATCleaner ( )
inlinevirtual

Definition at line 44 of file PATCleaner.h.

44 {}

Member Function Documentation

template<class PATObjType >
void pat::PATCleaner< PATObjType >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
finaloverridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 97 of file PATCleaner.h.

References objects.IsoTrackAnalyzer::candidates, edm::Event::getByToken(), getGTfromDQMFile::obj, convertSQLitetoXML_cfg::output, analyzePatCleaning_cfg::overlaps, and edm::Event::put().

97  {
98 
99  // Read the input. We use edm::View<> in case the input happes to be something different than a std::vector<>
101  iEvent.getByToken(srcToken_, candidates);
102 
103  // Prepare a collection for the output
104  std::auto_ptr< std::vector<PATObjType> > output(new std::vector<PATObjType>());
105 
106  // initialize the overlap tests
107  for (auto& itov : overlapTests_) {
108  itov->readInput(iEvent,iSetup);
109  }
110 
111  for (typename edm::View<PATObjType>::const_iterator it = candidates->begin(), ed = candidates->end(); it != ed; ++it) {
112  // Apply a preselection to the inputs and copy them in the output
113  if (!preselectionCut_(*it)) continue;
114 
115  // Add it to the list and take a reference to it, so it can be modified (e.g. to set the overlaps)
116  // If at some point I'll decide to drop this item, I'll use pop_back to remove it
117  output->push_back(*it);
118  PATObjType &obj = output->back();
119 
120  // Look for overlaps
121  bool badForOverlap = false;
122  for (auto& itov : overlapTests_) {
124  bool hasOverlap = itov->fillOverlapsForItem(obj, overlaps);
125  if (hasOverlap && itov->requireNoOverlaps()) {
126  badForOverlap = true; // mark for discarding
127  break; // no point in checking the others, as this item will be discarded
128  }
129  obj.setOverlaps(itov->name(), overlaps);
130  }
131  if (badForOverlap) { output->pop_back(); continue; }
132 
133  // Apply one final selection cut
134  if (!finalCut_(obj)) output->pop_back();
135  }
136 
137  iEvent.put(output);
138 }
const Selector finalCut_
Definition: PATCleaner.h:54
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
const Selector preselectionCut_
Definition: PATCleaner.h:53
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< std::unique_ptr< OverlapTest > > overlapTests_
Definition: PATCleaner.h:57
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
const edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
Definition: PATCleaner.h:52

Member Data Documentation

template<class PATObjType >
const Selector pat::PATCleaner< PATObjType >::finalCut_
private

Definition at line 54 of file PATCleaner.h.

template<class PATObjType >
std::vector<std::unique_ptr<OverlapTest> > pat::PATCleaner< PATObjType >::overlapTests_
private

Definition at line 57 of file PATCleaner.h.

Referenced by pat::PATCleaner< PATObjType >::PATCleaner().

template<class PATObjType >
const Selector pat::PATCleaner< PATObjType >::preselectionCut_
private

Definition at line 53 of file PATCleaner.h.

template<class PATObjType >
const edm::InputTag pat::PATCleaner< PATObjType >::src_
private

Definition at line 51 of file PATCleaner.h.

Referenced by pat::PATCleaner< PATObjType >::PATCleaner().

template<class PATObjType >
const edm::EDGetTokenT<edm::View<PATObjType> > pat::PATCleaner< PATObjType >::srcToken_
private

Definition at line 52 of file PATCleaner.h.