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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () 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

◆ Cleaner

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

Definition at line 45 of file RecoTauCleaner.cc.

◆ CleanerList

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

Definition at line 50 of file RecoTauCleaner.cc.

◆ output_type

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

Definition at line 52 of file RecoTauCleaner.cc.

Constructor & Destructor Documentation

◆ RecoTauCleanerImpl()

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

Definition at line 77 of file RecoTauCleaner.cc.

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

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

108 {}

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

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

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

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

◆ produce()

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

Definition at line 221 of file RecoTauCleaner.cc.

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

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

◆ outputSelector_

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

Definition at line 71 of file RecoTauCleaner.cc.

◆ tau_token

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

Definition at line 72 of file RecoTauCleaner.cc.

◆ tauSrc_

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

Definition at line 68 of file RecoTauCleaner.cc.

◆ verbosity_

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

Definition at line 73 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:72
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RecoTauCleanerImpl::verbosity_
int verbosity_
Definition: RecoTauCleaner.cc:73
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:531
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
RecoTauCleanerImpl::cleaners_
CleanerList cleaners_
Definition: RecoTauCleaner.cc:69
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
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HistogramManager_cfi.VPSet
def VPSet(*args)
Definition: HistogramManager_cfi.py:401
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:33520
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
RecoTauCleanerImpl::outputSelector_
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
Definition: RecoTauCleaner.cc:71
RecoTauCleanerImpl::tauSrc_
edm::InputTag tauSrc_
Definition: RecoTauCleaner.cc:68