CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
PFTauMVAInputDiscriminantTranslator Class Reference
Inheritance diagram for PFTauMVAInputDiscriminantTranslator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  DiscriminantInfo
 

Public Member Functions

 PFTauMVAInputDiscriminantTranslator (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::vector< DiscriminantInfodiscriminators_
 
edm::InputTag pfTauSource_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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

Definition at line 29 of file PFTauMVAInputDiscriminantTranslator.cc.

Constructor & Destructor Documentation

PFTauMVAInputDiscriminantTranslator::PFTauMVAInputDiscriminantTranslator ( const edm::ParameterSet pset)

Definition at line 47 of file PFTauMVAInputDiscriminantTranslator.cc.

References ecaldqm::collectionName, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::collName, beamerCreator::create(), PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::defaultValue, TtSemiLepEvtBuilder_cfi::disc, reco::tau::discPluginName(), PFTauMVAInputDiscriminatorTranslator_cfi::discriminants, reco::get(), edm::ParameterSet::getParameter(), PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::index, diffTreeTool::index, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::name, dataset::name, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::plugin, AlCaHLTBitMon_QueryRunRegistry::string, and HistogramManager_cfi::VPSet().

48  {
49  typedef std::vector<edm::ParameterSet> VPSet;
50  pfTauSource_ = pset.getParameter<edm::InputTag>("pfTauSource");
51  VPSet discriminants = pset.getParameter<VPSet>("discriminants");
52 
53  for(VPSet::const_iterator iDisc = discriminants.begin();
54  iDisc != discriminants.end(); ++iDisc) {
55  // WTF IS GOING ON HERE
56  std::string name = iDisc->getParameter<std::string>("name");
57  double defaultValue = (iDisc->exists("default")) ?
58  iDisc->getParameter<double>("default") : 0.;
59  // check if we are getting multiple indices
60  bool requestMultiple = iDisc->exists("indices");
61  if(requestMultiple) {
62  // make a discrimiantor for each desired index
63  std::vector<uint32_t> indices =
64  iDisc->getParameter<std::vector<uint32_t> >("indices");
65  for(std::vector<uint32_t>::const_iterator index = indices.begin();
66  index != indices.end(); ++index) {
67  DiscriminantInfo newDisc;
68  newDisc.name = name;
69  newDisc.index = *index;
70  newDisc.defaultValue = defaultValue;
71  // make a nice colleciton name
72  std::stringstream collectionName;
73  collectionName << name << *index;
74  newDisc.collName = collectionName.str();
75  // Build the plugin
76  edm::ParameterSet fakePSet;
77  newDisc.plugin.reset(
79  reco::tau::discPluginName(name), fakePSet));
80  discriminators_.push_back(newDisc);
81  }
82  } else {
83  //single discriminant
84  DiscriminantInfo newDisc;
85  newDisc.name = name;
86  newDisc.collName = name;
87  newDisc.index = 0;
88  newDisc.defaultValue = defaultValue;
89  // Build the plugin
90  edm::ParameterSet fakePSet;
91  newDisc.plugin.reset(
93  reco::tau::discPluginName(name), fakePSet));
94  discriminators_.push_back(newDisc);
95  }
96  }
97  // register products
98  BOOST_FOREACH(const DiscriminantInfo& disc, discriminators_) {
99  produces<PFTauDiscriminator>(disc.collName);
100  }
101 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
std::string discPluginName(const std::string &mvaName)
std::string const collectionName[nCollections]
Definition: Collections.h:47
T get(const Candidate &c)
Definition: component.h:55

Member Function Documentation

void PFTauMVAInputDiscriminantTranslator::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 103 of file PFTauMVAInputDiscriminantTranslator.cc.

References PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::collName, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::defaultValue, DEFINE_FWK_MODULE, TtSemiLepEvtBuilder_cfi::disc, edm::Event::getByLabel(), PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::index, eostools::move(), convertSQLitetoXML_cfg::output, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::plugin, edm::Event::put(), and mps_fire::result.

104  {
105  // Handle to get PFTaus to associated to
107  evt.getByLabel(pfTauSource_, pfTaus);
108 
109  BOOST_FOREACH(const DiscriminantInfo& disc, discriminators_) {
110  // output for this discriminator
111  auto output = std::make_unique<PFTauDiscriminator>(edm::RefProd<PFTauCollection>(pfTaus));
112  // loop over taus
113  for(size_t itau = 0; itau < pfTaus->size(); ++itau) {
114  PFTauRef tauRef(pfTaus, itau);
115  // discriminator result
116  std::vector<double> result = (*disc.plugin)(tauRef);
117  // The desired index
118  double selected_result = disc.defaultValue;
119  if (result.size()-1 < disc.index) {
120  selected_result = result[disc.index];
121  }
122  output->setValue(itau, selected_result);
123  }
124  evt.put(std::move(output), disc.collName);
125  }
126 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

std::vector<DiscriminantInfo> PFTauMVAInputDiscriminantTranslator::discriminators_
private

Definition at line 44 of file PFTauMVAInputDiscriminantTranslator.cc.

edm::InputTag PFTauMVAInputDiscriminantTranslator::pfTauSource_
private

Definition at line 43 of file PFTauMVAInputDiscriminantTranslator.cc.