CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Attributes
RecoTauCleanerImpl< Prod > Class Template Reference
Inheritance diagram for RecoTauCleanerImpl< Prod >:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  CleanerEntryType
 
class  RemoveDuplicateJets
 

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauCleanerImpl (const edm::ParameterSet &pset)
 
 ~RecoTauCleanerImpl () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef reco::tau::RecoTauCleanerPlugin Cleaner
 
typedef std::vector< std::unique_ptr< CleanerEntryType > > CleanerList
 
typedef Prod::value_type output_type
 

Private Attributes

CleanerList cleaners_
 
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
 
edm::EDGetTokenT< reco::PFTauCollectiontau_token
 
edm::InputTag tauSrc_
 
int verbosity_
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::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<typename Prod>
class RecoTauCleanerImpl< Prod >

Definition at line 41 of file RecoTauCleaner.cc.

Member Typedef Documentation

template<typename Prod >
typedef reco::tau::RecoTauCleanerPlugin RecoTauCleanerImpl< Prod >::Cleaner
private

Definition at line 43 of file RecoTauCleaner.cc.

template<typename Prod >
typedef std::vector<std::unique_ptr<CleanerEntryType> > RecoTauCleanerImpl< Prod >::CleanerList
private

Definition at line 49 of file RecoTauCleaner.cc.

template<typename Prod >
typedef Prod::value_type RecoTauCleanerImpl< Prod >::output_type
private

Definition at line 51 of file RecoTauCleaner.cc.

Constructor & Destructor Documentation

template<typename Prod >
RecoTauCleanerImpl< Prod >::RecoTauCleanerImpl ( const edm::ParameterSet pset)
explicit

Definition at line 75 of file RecoTauCleaner.cc.

References RecoTauCleaner_cfi::cleaners, RecoTauCleanerImpl< Prod >::cleaners_, edm::EDConsumerBase::consumesCollector(), beamerCreator::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), RecoTauCleanerImpl< Prod >::outputSelector_, RecoTauCleanerImpl< Prod >::CleanerEntryType::plugin_, corrVsCorr::selection, AlCaHLTBitMon_QueryRunRegistry::string, RecoTauCleanerImpl< Prod >::tau_token, RecoTauCleanerImpl< Prod >::tauSrc_, RecoTauCleanerImpl< Prod >::CleanerEntryType::tolerance_, RecoTauCleanerImpl< Prod >::verbosity_, and HistogramManager_cfi::VPSet().

Referenced by RecoTauCleanerImpl< Prod >::RemoveDuplicateJets::operator()().

76 {
77  tauSrc_ = pset.getParameter<edm::InputTag>("src");
78  tau_token=consumes<reco::PFTauCollection>(tauSrc_);
79  // Build our list of quality plugins
80  typedef std::vector<edm::ParameterSet> VPSet;
81  // Get each of our tau builders
82  const VPSet& cleaners = pset.getParameter<VPSet>("cleaners");
83  for ( VPSet::const_iterator cleanerPSet = cleaners.begin();
84  cleanerPSet != cleaners.end(); ++cleanerPSet ) {
85  CleanerEntryType* cleanerEntry = new CleanerEntryType();
86  // Get plugin name
87  const std::string& pluginType = cleanerPSet->getParameter<std::string>("plugin");
88  // Build the plugin
89  cleanerEntry->plugin_.reset(RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet, consumesCollector()));
90  cleanerEntry->tolerance_ = ( cleanerPSet->exists("tolerance") ) ?
91  cleanerPSet->getParameter<double>("tolerance") : 0.;
92  cleaners_.emplace_back(cleanerEntry);
93  }
94 
95  // Check if we want to apply a final output selection
96  if ( pset.exists("outputSelection") ) {
97  std::string selection = pset.getParameter<std::string>("outputSelection");
98  if ( selection != "" ) {
100  }
101  }
102 
103  // Enable/disable debug output
104  verbosity_ = ( pset.exists("verbosity") ) ?
105  pset.getParameter<int>("verbosity") : 0;
106 
107  // Build the predicate that ranks our taus.
108  produces<Prod>();
109 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
edm::InputTag tauSrc_
selection
main part
Definition: corrVsCorr.py:98
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::PFTauCollection > tau_token
CleanerList cleaners_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
T get(const Candidate &c)
Definition: component.h:55
template<typename Prod >
RecoTauCleanerImpl< Prod >::~RecoTauCleanerImpl ( )
override

Member Function Documentation

template<typename Prod >
void RecoTauCleanerImpl< Prod >::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 223 of file RecoTauCleaner.cc.

References RecoTauCleanerImpl< Prod >::cleaners_, gather_cfg::cout, edm::Event::getByToken(), training_settings::idx, eostools::move(), N, convertSQLitetoXML_cfg::output, RecoTauCleanerImpl< Prod >::outputSelector_, edm::Event::put(), metsig::tau, RecoTauCleanerImpl< Prod >::tau_token, and RecoTauCleanerImpl< Prod >::verbosity_.

Referenced by RecoTauCleanerImpl< Prod >::RemoveDuplicateJets::operator()().

224 {
225  if ( verbosity_ ) {
226  std::cout << "<RecoTauCleanerImpl::produce>:" << std::endl;
227  }
228 
229  // Update all our cleaners with the event info if they need it
230  for ( typename CleanerList::iterator cleaner = cleaners_.begin();
231  cleaner != cleaners_.end(); ++cleaner ) {
232  (*cleaner)->plugin_->setup(evt, es);
233  }
234 
235  // Get the input collection of all taus. Some are from the same PFJet. We must clean them.
237  evt.getByToken(tau_token, inputTaus);
238 
239  // Sort the input tau refs according to our predicate
240  std::list<PFTauRankType*> rankedTaus;
241  size_t N = inputTaus->size();
242  for ( size_t idx = 0; idx < N; ++idx ) {
243  reco::PFTauRef inputRef(inputTaus, idx);
244  PFTauRankType* rankedTau = new PFTauRankType(inputRef);
245  rankedTau->N_ = cleaners_.size();
246  rankedTau->ranks_.reserve(rankedTau->N_);
247  rankedTau->tolerances_.reserve(rankedTau->N_);
248  for ( typename CleanerList::const_iterator cleaner = cleaners_.begin();
249  cleaner != cleaners_.end(); ++cleaner ) {
250  rankedTau->ranks_.push_back((*(*cleaner)->plugin_)(inputRef));
251  rankedTau->tolerances_.push_back((*cleaner)->tolerance_);
252  }
253  if ( verbosity_ ) {
254  std::ostringstream os;
255  os << "rankedTau #" << idx;
256  rankedTau->print(os.str());
257  }
258  rankedTaus.push_back(rankedTau);
259  }
260  rankedTaus.sort(isHigherRank);
261 
262  // Make an STL algorithm friendly vector of refs
263  typedef std::vector<reco::PFTauRef> PFTauRefs;
264  PFTauRefs dirty(inputTaus->size());
265  size_t idx_sorted = 0;
266  for ( std::list<PFTauRankType*>::const_iterator rankedTau = rankedTaus.begin();
267  rankedTau != rankedTaus.end(); ++rankedTau ) {
268  dirty[idx_sorted] = (*rankedTau)->tauRef_;
269  if ( verbosity_ ) {
270  std::cout << "dirty[" << idx_sorted << "] = " << dirty[idx_sorted].id() << ":" << dirty[idx_sorted].key() << std::endl;
271  }
272  delete (*rankedTau);
273  ++idx_sorted;
274  }
275 
276  // Clean the taus, ensuring that only one tau per jet is produced
277  PFTauRefs cleanTaus = reco::tau::cleanOverlaps<PFTauRefs, RemoveDuplicateJets>(dirty);
278 
279  // create output collection
280  auto output = std::make_unique<Prod>();
281  //output->reserve(cleanTaus.size());
282 
283  // Copy clean refs into output
284  for ( PFTauRefs::const_iterator tau = cleanTaus.begin();
285  tau != cleanTaus.end(); ++tau ) {
286  // If we are applying an output selection, check if it passes
287  bool selected = true;
288  if ( outputSelector_.get() && !(*outputSelector_)(**tau) ) {
289  selected = false;
290  }
291  if ( selected ) {
292  output->push_back(convert<output_type>(*tau));
293  }
294  }
295  evt.put(std::move(output));
296 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
edm::EDGetTokenT< reco::PFTauCollection > tau_token
CleanerList cleaners_
#define N
Definition: blowfish.cc:9
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

template<typename Prod >
CleanerList RecoTauCleanerImpl< Prod >::cleaners_
private
template<typename Prod >
std::unique_ptr<const StringCutObjectSelector<reco::PFTau> > RecoTauCleanerImpl< Prod >::outputSelector_
private
template<typename Prod >
edm::EDGetTokenT<reco::PFTauCollection> RecoTauCleanerImpl< Prod >::tau_token
private
template<typename Prod >
edm::InputTag RecoTauCleanerImpl< Prod >::tauSrc_
private

Definition at line 66 of file RecoTauCleaner.cc.

Referenced by RecoTauCleanerImpl< Prod >::RecoTauCleanerImpl().

template<typename Prod >
int RecoTauCleanerImpl< Prod >::verbosity_
private