CMS 3D CMS Logo

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

Classes

struct  CleanerEntryType
 
class  RemoveDuplicateJets
 

Public Member Functions

template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
template<>
void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

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
 

Detailed Description

template<typename Prod>
class RecoTauCleanerImpl< Prod >

Definition at line 44 of file RecoTauCleaner.cc.

Member Typedef Documentation

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

Definition at line 46 of file RecoTauCleaner.cc.

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

Definition at line 52 of file RecoTauCleaner.cc.

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

Definition at line 54 of file RecoTauCleaner.cc.

Constructor & Destructor Documentation

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

Definition at line 80 of file RecoTauCleaner.cc.

References RecoTauCleaner_cfi::cleaners, RecoTauCleanerImpl< Prod >::cleaners_, reco::get(), edm::ParameterSet::getParameter(), eostools::move(), RecoTauCleanerImpl< Prod >::outputSelector_, corrVsCorr::selection, AlCaHLTBitMon_QueryRunRegistry::string, RecoTauCleanerImpl< Prod >::tau_token, RecoTauCleanerImpl< Prod >::tauSrc_, RecoTauCleanerImpl< Prod >::verbosity_, and HistogramManager_cfi::VPSet().

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

81 {
82  tauSrc_ = pset.getParameter<edm::InputTag>("src");
83  tau_token=consumes<reco::PFTauCollection>(tauSrc_);
84  // Build our list of quality plugins
85  typedef std::vector<edm::ParameterSet> VPSet;
86  // Get each of our tau builders
87  const VPSet& cleaners = pset.getParameter<VPSet>("cleaners");
88  for ( VPSet::const_iterator cleanerPSet = cleaners.begin();
89  cleanerPSet != cleaners.end(); ++cleanerPSet ) {
90  auto cleanerEntry = std::make_unique<CleanerEntryType>();
91  // Get plugin name
92  const std::string& pluginType = cleanerPSet->getParameter<std::string>("plugin");
93  // Build the plugin
94  cleanerEntry->plugin_ = std::unique_ptr<Cleaner>{RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet, consumesCollector())};
95  cleanerEntry->tolerance_ = cleanerPSet->getParameter<double>("tolerance");
96  cleaners_.emplace_back(std::move(cleanerEntry));
97  }
98 
99  // Check if we want to apply a final output selection
100  std::string selection = pset.getParameter<std::string>("outputSelection");
101  if ( !selection.empty() ) {
102  outputSelector_ = std::make_unique<StringCutObjectSelector<reco::PFTau>>(selection);
103  }
104 
105  // Enable/disable debug output
106  verbosity_ = pset.getParameter<int>("verbosity");
107 
108  // Build the predicate that ranks our taus.
109  produces<Prod>();
110 }
T getParameter(std::string const &) const
edm::InputTag tauSrc_
selection
main part
Definition: corrVsCorr.py:100
edm::EDGetTokenT< reco::PFTauCollection > tau_token
CleanerList cleaners_
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
template<typename Prod >
RecoTauCleanerImpl< Prod >::~RecoTauCleanerImpl ( )
override

Member Function Documentation

template<typename Prod >
static void RecoTauCleanerImpl< Prod >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static
template<>
void RecoTauCleanerImpl< reco::PFTauCollection >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)

Definition at line 304 of file RecoTauCleaner.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSet::addParameter(), edm::ParameterSetDescription::addVPSet(), and AlCaHLTBitMon_QueryRunRegistry::string.

304  {
305  // RecoTauCleaner
307  desc.add<std::string>("outputSelection", "");
308  {
309  // this description is the validator for all PSets in the cleaners VPSet passed to the plugin from the python configuration
310  edm::ParameterSetDescription vps_description_for_cleaners;
311  // the common parameters for all cleaners
312  // no default value is provided -- the user has to provide the values for these parameters
313  vps_description_for_cleaners.add<std::string>("plugin");
314  vps_description_for_cleaners.add<double>("tolerance", 0);
315  vps_description_for_cleaners.add<std::string>("name");
316 
317  // the following parameters are not common for all cleaners, they are needed for few PSets, therefore they are added as optional
318  // these optional parameters are used in the default cleaners vector
319  vps_description_for_cleaners.addOptional<int>("passForCharge");
320  vps_description_for_cleaners.addOptional<double>("selectionFailValue");
321  vps_description_for_cleaners.addOptional<std::vector<unsigned int>>("nprongs");
322  vps_description_for_cleaners.addOptional<edm::InputTag>("src");
323  vps_description_for_cleaners.addOptional<double>("minTrackPt");
324  vps_description_for_cleaners.addOptional<std::string>("selection");
325  vps_description_for_cleaners.addOptional<std::string>("selectionPassFunction");
326  // more PSets for cleaners can be found in
327  // RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py
328  // however, at this moment (2018-11-09) they do not have any new optional parameters
329 
330  // the cleaner defaults, as in RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py
331  std::vector<edm::ParameterSet> default_cleaners;
332  default_cleaners.reserve(7);
333  {
334  edm::ParameterSet cleaner_Charge;
335  cleaner_Charge.addParameter<std::string>("name", "Charge");
336  cleaner_Charge.addParameter<std::string>("plugin", "RecoTauChargeCleanerPlugin");
337  cleaner_Charge.addParameter<int>("passForCharge", 1);
338  cleaner_Charge.addParameter<double>("selectionFailValue", 0);
339  cleaner_Charge.addParameter<std::vector<unsigned int>>("nprongs", {1, 3,});
340  cleaner_Charge.addParameter<double>("tolerance", 0);
341  default_cleaners.push_back(cleaner_Charge);
342  }
343  {
344  edm::ParameterSet temp2;
345  temp2.addParameter<std::string>("name", "HPS_Select");
346  temp2.addParameter<std::string>("plugin", "RecoTauDiscriminantCleanerPlugin");
347  temp2.addParameter<edm::InputTag>("src", edm::InputTag("hpsSelectionDiscriminator"));
348  temp2.addParameter<double>("tolerance", 0);
349  default_cleaners.push_back(temp2);
350  }
351  {
352  edm::ParameterSet temp2;
353  temp2.addParameter<std::string>("name", "killSoftTwoProngTaus");
354  temp2.addParameter<std::string>("plugin", "RecoTauSoftTwoProngTausCleanerPlugin");
355  temp2.addParameter<double>("minTrackPt", 5.0);
356  temp2.addParameter<double>("tolerance", 0);
357  default_cleaners.push_back(temp2);
358  }
359  {
360  edm::ParameterSet temp2;
361  temp2.addParameter<std::string>("name", "ChargedHadronMultiplicity");
362  temp2.addParameter<std::string>("plugin", "RecoTauChargedHadronMultiplicityCleanerPlugin");
363  temp2.addParameter<double>("tolerance", 0);
364  default_cleaners.push_back(temp2);
365  }
366  {
367  edm::ParameterSet temp2;
368  temp2.addParameter<std::string>("name", "Pt");
369  temp2.addParameter<std::string>("plugin", "RecoTauStringCleanerPlugin");
370  temp2.addParameter<std::string>("selectionPassFunction", "-pt()");
371  temp2.addParameter<std::string>("selection", "leadPFCand().isNonnull()");
372  temp2.addParameter<double>("selectionFailValue", 1000.0);
373  temp2.addParameter<double>("tolerance", 0.01);
374  default_cleaners.push_back(temp2);
375  }
376  {
377  edm::ParameterSet temp2;
378  temp2.addParameter<std::string>("name", "StripMultiplicity");
379  temp2.addParameter<std::string>("plugin", "RecoTauStringCleanerPlugin");
380  temp2.addParameter<std::string>("selectionPassFunction", "-signalPiZeroCandidates().size()");
381  temp2.addParameter<std::string>("selection", "leadPFCand().isNonnull()");
382  temp2.addParameter<double>("selectionFailValue", 1000.0);
383  temp2.addParameter<double>("tolerance", 0);
384  default_cleaners.push_back(temp2);
385  }
386  {
387  edm::ParameterSet temp2;
388  temp2.addParameter<std::string>("name", "CombinedIsolation");
389  temp2.addParameter<std::string>("plugin", "RecoTauStringCleanerPlugin");
390  temp2.addParameter<std::string>("selectionPassFunction", "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()");
391  temp2.addParameter<std::string>("selection", "leadPFCand().isNonnull()");
392  temp2.addParameter<double>("selectionFailValue", 1000.0);
393  temp2.addParameter<double>("tolerance", 0);
394  default_cleaners.push_back(temp2);
395  }
396 
397  desc.addVPSet("cleaners", vps_description_for_cleaners, default_cleaners);
398  }
399 
400  desc.add<int>("verbosity", 0);
401  desc.add<edm::InputTag>("src", edm::InputTag("combinatoricRecoTaus"));
402  descriptions.add("RecoTauCleaner", desc);
403 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<>
void RecoTauCleanerImpl< reco::PFTauRefVector >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)

Definition at line 407 of file RecoTauCleaner.cc.

References DEFINE_FWK_MODULE.

407  {
408 // there was no cfi file for this plugin
409 }
template<typename Prod >
void RecoTauCleanerImpl< Prod >::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 224 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()().

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

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 71 of file RecoTauCleaner.cc.

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

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