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

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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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 33 of file PATCleaner.cc.

Member Typedef Documentation

◆ OverlapTest

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

Definition at line 48 of file PATCleaner.cc.

◆ Selector

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

Definition at line 41 of file PATCleaner.cc.

Constructor & Destructor Documentation

◆ PATCleaner()

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

Definition at line 55 of file PATCleaner.cc.

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.

56  : src_(iConfig.getParameter<edm::InputTag>("src")),
58  preselectionCut_(iConfig.getParameter<std::string>("preselection")),
59  finalCut_(iConfig.getParameter<std::string>("finalCut")) {
60  // pick parameter set for overlaps
61  edm::ParameterSet overlapPSet = iConfig.getParameter<edm::ParameterSet>("checkOverlaps");
62  // get all the names of the tests (all nested PSets in this PSet)
63  std::vector<std::string> overlapNames = overlapPSet.getParameterNamesForType<edm::ParameterSet>();
64  // loop on them
65  for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) {
66  // retrieve configuration
68  // skip empty parameter sets
69  if (cfg.empty())
70  continue;
71  // get the name of the algorithm to use
72  std::string algorithm = cfg.getParameter<std::string>("algorithm");
73  // create the appropriate OverlapTest
74  if (algorithm == "byDeltaR") {
75  overlapTests_.emplace_back(new pat::helper::BasicOverlapTest(*itn, cfg, consumesCollector()));
76  } else if (algorithm == "bySuperClusterSeed") {
77  overlapTests_.emplace_back(new pat::helper::OverlapBySuperClusterSeed(*itn, cfg, consumesCollector()));
78  } else {
79  throw cms::Exception("Configuration")
80  << "PATCleaner for " << src_ << ": unsupported algorithm '" << algorithm << "'\n";
81  }
82  }
83 
84  produces<std::vector<PATObjType>>();
85 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const Selector finalCut_
Definition: PATCleaner.cc:46
const Selector preselectionCut_
Definition: PATCleaner.cc:45
std::vector< std::unique_ptr< OverlapTest > > overlapTests_
Definition: PATCleaner.cc:49
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:180
const edm::InputTag src_
Definition: PATCleaner.cc:43
const edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
Definition: PATCleaner.cc:44

◆ ~PATCleaner()

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

Definition at line 36 of file PATCleaner.cc.

36 {}

Member Function Documentation

◆ produce()

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

Definition at line 88 of file PATCleaner.cc.

References HLT_2024v12_cff::candidates, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, eostools::move(), getGTfromDQMFile::obj, and analyzePatCleaning_cfg::overlaps.

88  {
89  // Read the input. We use edm::View<> in case the input happes to be something different than a std::vector<>
91  iEvent.getByToken(srcToken_, candidates);
92 
93  // Prepare a collection for the output
94  auto output = std::make_unique<std::vector<PATObjType>>();
95 
96  // initialize the overlap tests
97  for (auto& itov : overlapTests_) {
98  itov->readInput(iEvent, iSetup);
99  }
100 
101  for (typename edm::View<PATObjType>::const_iterator it = candidates->begin(), ed = candidates->end(); it != ed;
102  ++it) {
103  // Apply a preselection to the inputs and copy them in the output
104  if (!preselectionCut_(*it))
105  continue;
106 
107  // Add it to the list and take a reference to it, so it can be modified (e.g. to set the overlaps)
108  // If at some point I'll decide to drop this item, I'll use pop_back to remove it
109  output->push_back(*it);
110  PATObjType& obj = output->back();
111 
112  // Look for overlaps
113  bool badForOverlap = false;
114  for (auto& itov : overlapTests_) {
116  bool hasOverlap = itov->fillOverlapsForItem(obj, overlaps);
117  if (hasOverlap && itov->requireNoOverlaps()) {
118  badForOverlap = true; // mark for discarding
119  break; // no point in checking the others, as this item will be discarded
120  }
121  obj.setOverlaps(itov->name(), overlaps);
122  }
123  if (badForOverlap) {
124  output->pop_back();
125  continue;
126  }
127 
128  // Apply one final selection cut
129  if (!finalCut_(obj))
130  output->pop_back();
131  }
132 
133  iEvent.put(std::move(output));
134 }
const Selector finalCut_
Definition: PATCleaner.cc:46
const Selector preselectionCut_
Definition: PATCleaner.cc:45
int iEvent
Definition: GenABIO.cc:224
std::vector< std::unique_ptr< OverlapTest > > overlapTests_
Definition: PATCleaner.cc:49
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
Definition: output.py:1
const edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
Definition: PATCleaner.cc:44
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ finalCut_

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

Definition at line 46 of file PATCleaner.cc.

◆ overlapTests_

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

Definition at line 49 of file PATCleaner.cc.

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

◆ preselectionCut_

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

Definition at line 45 of file PATCleaner.cc.

◆ src_

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

Definition at line 43 of file PATCleaner.cc.

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

◆ srcToken_

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

Definition at line 44 of file PATCleaner.cc.