CMS 3D CMS Logo

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<>

Public Member Functions

 PATCleaner (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) final
 
 ~PATCleaner () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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

◆ OverlapTest

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

Definition at line 55 of file PATCleaner.h.

◆ Selector

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

Definition at line 48 of file PATCleaner.h.

Constructor & Destructor Documentation

◆ PATCleaner()

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

Definition at line 62 of file PATCleaner.h.

63  : src_(iConfig.getParameter<edm::InputTag>("src")),
65  preselectionCut_(iConfig.getParameter<std::string>("preselection")),
66  finalCut_(iConfig.getParameter<std::string>("finalCut")) {
67  // pick parameter set for overlaps
68  edm::ParameterSet overlapPSet = iConfig.getParameter<edm::ParameterSet>("checkOverlaps");
69  // get all the names of the tests (all nested PSets in this PSet)
70  std::vector<std::string> overlapNames = overlapPSet.getParameterNamesForType<edm::ParameterSet>();
71  // loop on them
72  for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) {
73  // retrieve configuration
75  // skip empty parameter sets
76  if (cfg.empty())
77  continue;
78  // get the name of the algorithm to use
79  std::string algorithm = cfg.getParameter<std::string>("algorithm");
80  // create the appropriate OverlapTest
81  if (algorithm == "byDeltaR") {
82  overlapTests_.emplace_back(new pat::helper::BasicOverlapTest(*itn, cfg, consumesCollector()));
83  } else if (algorithm == "bySuperClusterSeed") {
84  overlapTests_.emplace_back(new pat::helper::OverlapBySuperClusterSeed(*itn, cfg, consumesCollector()));
85  } else {
86  throw cms::Exception("Configuration")
87  << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n";
88  }
89  }
90 
91  produces<std::vector<PATObjType>>();
92 }

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

◆ ~PATCleaner()

template<class PATObjType >
pat::PATCleaner< PATObjType >::~PATCleaner ( )
inlineoverride

Definition at line 43 of file PATCleaner.h.

43 {}

Member Function Documentation

◆ produce()

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

Definition at line 95 of file PATCleaner.h.

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

References HLT_FULL_cff::candidates, iEvent, eostools::move(), getGTfromDQMFile::obj, convertSQLitetoXML_cfg::output, and analyzePatCleaning_cfg::overlaps.

Member Data Documentation

◆ finalCut_

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

Definition at line 53 of file PATCleaner.h.

◆ overlapTests_

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

Definition at line 56 of file PATCleaner.h.

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

◆ preselectionCut_

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

Definition at line 52 of file PATCleaner.h.

◆ src_

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

Definition at line 50 of file PATCleaner.h.

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

◆ srcToken_

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

Definition at line 51 of file PATCleaner.h.

convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::Handle
Definition: AssociativeIterator.h:50
edm::PtrVector< Candidate >
pat::PATCleaner::overlapTests_
std::vector< std::unique_ptr< OverlapTest > > overlapTests_
Definition: PATCleaner.h:56
pat::PATCleaner::preselectionCut_
const Selector preselectionCut_
Definition: PATCleaner.h:52
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
analyzePatCleaning_cfg.overlaps
overlaps
Definition: analyzePatCleaning_cfg.py:9
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
qcdUeDQM_cfi.algorithm
algorithm
Definition: qcdUeDQM_cfi.py:32
edm::ParameterSet::getParameterNamesForType
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::PATCleaner::src_
const edm::InputTag src_
Definition: PATCleaner.h:50
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
pat::helper::OverlapBySuperClusterSeed
Definition: OverlapTest.h:77
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:54996
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
pat::helper::BasicOverlapTest
Definition: OverlapTest.h:46
pat::PATCleaner::finalCut_
const Selector finalCut_
Definition: PATCleaner.h:53
pat::PATCleaner::srcToken_
const edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
Definition: PATCleaner.h:51
edm::InputTag
Definition: InputTag.h:15