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

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<>
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<typename Prod>
class RecoTauCleanerImpl< Prod >

Definition at line 42 of file RecoTauCleaner.cc.

Member Typedef Documentation

◆ Cleaner

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

Definition at line 43 of file RecoTauCleaner.cc.

◆ CleanerList

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

Definition at line 48 of file RecoTauCleaner.cc.

◆ output_type

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

Definition at line 50 of file RecoTauCleaner.cc.

Constructor & Destructor Documentation

◆ RecoTauCleanerImpl()

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

Definition at line 75 of file RecoTauCleaner.cc.

References HLT_2022v12_cff::cleaners, get, eostools::move(), muonDTDigis_cfi::pset, corrVsCorr::selection, AlCaHLTBitMon_QueryRunRegistry::string, and HistogramManager_cfi::VPSet().

75  {
76  tauSrc_ = pset.getParameter<edm::InputTag>("src");
77  tau_token = consumes<reco::PFTauCollection>(tauSrc_);
78  // Build our list of quality plugins
79  typedef std::vector<edm::ParameterSet> VPSet;
80  // Get each of our tau builders
81  const VPSet& cleaners = pset.getParameter<VPSet>("cleaners");
82  for (VPSet::const_iterator cleanerPSet = cleaners.begin(); cleanerPSet != cleaners.end(); ++cleanerPSet) {
83  auto cleanerEntry = std::make_unique<CleanerEntryType>();
84  // Get plugin name
85  const std::string& pluginType = cleanerPSet->getParameter<std::string>("plugin");
86  // Build the plugin
87  cleanerEntry->plugin_ = RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet, consumesCollector());
88  cleanerEntry->tolerance_ = cleanerPSet->getParameter<double>("tolerance");
89  cleaners_.emplace_back(std::move(cleanerEntry));
90  }
91 
92  // Check if we want to apply a final output selection
93  std::string selection = pset.getParameter<std::string>("outputSelection");
94  if (!selection.empty()) {
95  outputSelector_ = std::make_unique<StringCutObjectSelector<reco::PFTau>>(selection);
96  }
97 
98  // Enable/disable debug output
99  verbosity_ = pset.getParameter<int>("verbosity");
100 
101  // Build the predicate that ranks our taus.
102  produces<Prod>();
103 }
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_
#define get
def move(src, dest)
Definition: eostools.py:511

◆ ~RecoTauCleanerImpl()

template<typename Prod >
RecoTauCleanerImpl< Prod >::~RecoTauCleanerImpl ( )
override

Definition at line 106 of file RecoTauCleaner.cc.

106 {}

Member Function Documentation

◆ fillDescriptions() [1/3]

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

◆ fillDescriptions() [2/3]

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

Definition at line 295 of file RecoTauCleaner.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSet::addParameter(), submitPVResolutionJobs::desc, HLT_2022v12_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

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

◆ fillDescriptions() [3/3]

template<>
void RecoTauCleanerImpl< reco::PFTauRefVector >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)

Definition at line 402 of file RecoTauCleaner.cc.

402  {
403  // there was no cfi file for this plugin
404 }

◆ produce()

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

Definition at line 219 of file RecoTauCleaner.cc.

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

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

◆ cleaners_

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

Definition at line 67 of file RecoTauCleaner.cc.

◆ outputSelector_

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

Definition at line 69 of file RecoTauCleaner.cc.

◆ tau_token

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

Definition at line 70 of file RecoTauCleaner.cc.

◆ tauSrc_

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

Definition at line 66 of file RecoTauCleaner.cc.

◆ verbosity_

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

Definition at line 71 of file RecoTauCleaner.cc.