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::EDProducer 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::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
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 (const std::string &iProcessName, std::vector< const char * > &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
< CleanerEntryType * > 
CleanerList
 
typedef Prod::value_type output_type
 

Private Attributes

CleanerList cleaners_
 
std::auto_ptr
< StringCutObjectSelector
< reco::PFTau > > 
outputSelector_
 
edm::EDGetTokenT
< reco::PFTauCollection
tau_token
 
edm::InputTag tauSrc_
 
int verbosity_
 

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<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<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 SurfaceDeformationFactory::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_.push_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_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
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.
SurfaceDeformation * create(int type, const std::vector< double > &params)
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  for ( typename CleanerList::const_iterator it = cleaners_.begin();
115  it != cleaners_.end(); ++it ) {
116  delete (*it);
117  }
118 }
CleanerList cleaners_

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 227 of file RecoTauCleaner.cc.

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

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

Member Data Documentation

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

Definition at line 67 of file RecoTauCleaner.cc.

template<typename Prod >
std::auto_ptr<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.