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

Member Typedef Documentation

◆ Cleaner

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

Definition at line 44 of file RecoTauCleaner.cc.

◆ CleanerList

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

Definition at line 49 of file RecoTauCleaner.cc.

◆ output_type

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

Definition at line 51 of file RecoTauCleaner.cc.

Constructor & Destructor Documentation

◆ RecoTauCleanerImpl()

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

Definition at line 76 of file RecoTauCleaner.cc.

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(); cleanerPSet != cleaners.end(); ++cleanerPSet) {
84  auto cleanerEntry = std::make_unique<CleanerEntryType>();
85  // Get plugin name
86  const std::string& pluginType = cleanerPSet->getParameter<std::string>("plugin");
87  // Build the plugin
88  cleanerEntry->plugin_ = RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet, consumesCollector());
89  cleanerEntry->tolerance_ = cleanerPSet->getParameter<double>("tolerance");
90  cleaners_.emplace_back(std::move(cleanerEntry));
91  }
92 
93  // Check if we want to apply a final output selection
94  std::string selection = pset.getParameter<std::string>("outputSelection");
95  if (!selection.empty()) {
96  outputSelector_ = std::make_unique<StringCutObjectSelector<reco::PFTau>>(selection);
97  }
98 
99  // Enable/disable debug output
100  verbosity_ = pset.getParameter<int>("verbosity");
101 
102  // Build the predicate that ranks our taus.
103  produces<Prod>();
104 }

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

◆ ~RecoTauCleanerImpl()

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

Definition at line 107 of file RecoTauCleaner.cc.

107 {}

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

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

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

◆ fillDescriptions() [3/3]

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

Definition at line 403 of file RecoTauCleaner.cc.

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

◆ produce()

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

Definition at line 220 of file RecoTauCleaner.cc.

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

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

Member Data Documentation

◆ cleaners_

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

Definition at line 68 of file RecoTauCleaner.cc.

◆ outputSelector_

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

Definition at line 70 of file RecoTauCleaner.cc.

◆ tau_token

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

Definition at line 71 of file RecoTauCleaner.cc.

◆ tauSrc_

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

Definition at line 67 of file RecoTauCleaner.cc.

◆ verbosity_

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

Definition at line 72 of file RecoTauCleaner.cc.

edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
metsig::tau
Definition: SignAlgoResolutions.h:49
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
RecoTauCleanerImpl::tau_token
edm::EDGetTokenT< reco::PFTauCollection > tau_token
Definition: RecoTauCleaner.cc:71
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RecoTauCleanerImpl::verbosity_
int verbosity_
Definition: RecoTauCleaner.cc:72
edm::Handle
Definition: AssociativeIterator.h:50
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
edm::Ref< PFTauCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
N
#define N
Definition: blowfish.cc:9
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::ParameterSet
Definition: ParameterSet.h:47
RecoTauCleanerImpl::cleaners_
CleanerList cleaners_
Definition: RecoTauCleaner.cc:68
edm::ParameterSet::addParameter
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HistogramManager_cfi.VPSet
def VPSet(*args)
Definition: HistogramManager_cfi.py:404
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::InputTag
Definition: InputTag.h:15
HLT_FULL_cff.cleaners
cleaners
Definition: HLT_FULL_cff.py:33470
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
RecoTauCleanerImpl::outputSelector_
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
Definition: RecoTauCleaner.cc:70
RecoTauCleanerImpl::tauSrc_
edm::InputTag tauSrc_
Definition: RecoTauCleaner.cc:67