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

Public Member Functions

 PATCleaner (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~PATCleaner ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
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

bool doFinalCut_
 
bool doPreselection_
 
Selector finalCut_
 
boost::ptr_vector< OverlapTestoverlapTests_
 
Selector preselectionCut_
 
edm::InputTag src_
 
edm::EDGetTokenT< edm::View
< PATObjType > > 
srcToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 40 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 48 of file PATCleaner.h.

Constructor & Destructor Documentation

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

Definition at line 64 of file PATCleaner.h.

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

64  :
65  src_(iConfig.getParameter<edm::InputTag>("src")),
67  preselectionCut_(iConfig.getParameter<std::string>("preselection")),
68  finalCut_(iConfig.getParameter<std::string>("finalCut"))
69 {
70  // pick parameter set for overlaps
71  edm::ParameterSet overlapPSet = iConfig.getParameter<edm::ParameterSet>("checkOverlaps");
72  // get all the names of the tests (all nested PSets in this PSet)
73  std::vector<std::string> overlapNames = overlapPSet.getParameterNamesForType<edm::ParameterSet>();
74  // loop on them
75  for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) {
76  // retrieve configuration
77  edm::ParameterSet cfg = overlapPSet.getParameter<edm::ParameterSet>(*itn);
78  // skip empty parameter sets
79  if (cfg.empty()) continue;
80  // get the name of the algorithm to use
81  std::string algorithm = cfg.getParameter<std::string>("algorithm");
82  // create the appropriate OverlapTest
83  if (algorithm == "byDeltaR") {
85  } else if (algorithm == "bySuperClusterSeed") {
87  } else {
88  throw cms::Exception("Configuration") << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n";
89  }
90  }
91 
92 
93  produces<std::vector<PATObjType> >();
94 }
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:216
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
boost::ptr_vector< OverlapTest > overlapTests_
Definition: PATCleaner.h:58
Selector finalCut_
Definition: PATCleaner.h:54
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:192
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
Definition: PATCleaner.h:51
Selector preselectionCut_
Definition: PATCleaner.h:53
edm::InputTag src_
Definition: PATCleaner.h:50
template<class PATObjType >
virtual pat::PATCleaner< PATObjType >::~PATCleaner ( )
inlinevirtual

Definition at line 43 of file PATCleaner.h.

43 {}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 98 of file PATCleaner.h.

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

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

Member Data Documentation

template<class PATObjType >
bool pat::PATCleaner< PATObjType >::doFinalCut_
private

Definition at line 52 of file PATCleaner.h.

template<class PATObjType >
bool pat::PATCleaner< PATObjType >::doPreselection_
private

Definition at line 52 of file PATCleaner.h.

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

Definition at line 54 of file PATCleaner.h.

template<class PATObjType >
boost::ptr_vector<OverlapTest> pat::PATCleaner< PATObjType >::overlapTests_
private

Definition at line 58 of file PATCleaner.h.

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

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

Definition at line 53 of file PATCleaner.h.

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

Definition at line 50 of file PATCleaner.h.

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

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

Definition at line 51 of file PATCleaner.h.