CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- 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
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::PFTauCollection
tau_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, 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<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 beamerCreator::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), RecoTauCleanerImpl< Prod >::CleanerEntryType::plugin_, corrVsCorr::selection, AlCaHLTBitMon_QueryRunRegistry::string, and RecoTauCleanerImpl< Prod >::CleanerEntryType::tolerance_.

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

Definition at line 112 of file RecoTauCleaner.cc.

113 {
114 }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 223 of file RecoTauCleaner.cc.

References gather_cfg::cout, edm::Event::getByToken(), customizeTrackingMonitorSeedNumber::idx, N, convertSQLitetoXML_cfg::output, edm::Event::put(), and metsig::tau.

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  std::auto_ptr<Prod> output(new 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(output);
296 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< reco::PFTauCollection > tau_token
CleanerList cleaners_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
#define N
Definition: blowfish.cc:9
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

template<typename Prod >
CleanerList RecoTauCleanerImpl< Prod >::cleaners_
private

Definition at line 67 of file RecoTauCleaner.cc.

template<typename Prod >
std::unique_ptr<const StringCutObjectSelector<reco::PFTau> > RecoTauCleanerImpl< Prod >::outputSelector_
private

Definition at line 69 of file RecoTauCleaner.cc.

template<typename Prod >
edm::EDGetTokenT<reco::PFTauCollection> RecoTauCleanerImpl< Prod >::tau_token
private

Definition at line 70 of file RecoTauCleaner.cc.

template<typename Prod >
edm::InputTag RecoTauCleanerImpl< Prod >::tauSrc_
private

Definition at line 66 of file RecoTauCleaner.cc.

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

Definition at line 71 of file RecoTauCleaner.cc.