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 ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 26 of file PFTauMVAInputDiscriminantTranslator.cc.

Constructor & Destructor Documentation

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

Definition at line 44 of file PFTauMVAInputDiscriminantTranslator.cc.

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

45  {
46  typedef std::vector<edm::ParameterSet> VPSet;
47  pfTauSource_ = pset.getParameter<edm::InputTag>("pfTauSource");
48  VPSet discriminants = pset.getParameter<VPSet>("discriminants");
49 
50  for(VPSet::const_iterator iDisc = discriminants.begin();
51  iDisc != discriminants.end(); ++iDisc) {
52  // WTF IS GOING ON HERE
53  std::string name = iDisc->getParameter<std::string>("name");
54  double defaultValue = (iDisc->exists("default")) ?
55  iDisc->getParameter<double>("default") : 0.;
56  // check if we are getting multiple indices
57  bool requestMultiple = iDisc->exists("indices");
58  if(requestMultiple) {
59  // make a discrimiantor for each desired index
60  std::vector<uint32_t> indices =
61  iDisc->getParameter<std::vector<uint32_t> >("indices");
62  for(std::vector<uint32_t>::const_iterator index = indices.begin();
63  index != indices.end(); ++index) {
64  DiscriminantInfo newDisc;
65  newDisc.name = name;
66  newDisc.index = *index;
67  newDisc.defaultValue = defaultValue;
68  // make a nice colleciton name
69  std::stringstream collectionName;
70  collectionName << name << *index;
71  newDisc.collName = collectionName.str();
72  // Build the plugin
73  edm::ParameterSet fakePSet;
74  newDisc.plugin = std::unique_ptr<reco::tau::RecoTauDiscriminantPlugin>(
76  reco::tau::discPluginName(name), fakePSet));
77  discriminators_.push_back(newDisc);
78  }
79  } else {
80  //single discriminant
81  DiscriminantInfo newDisc;
82  newDisc.name = name;
83  newDisc.collName = name;
84  newDisc.index = 0;
85  newDisc.defaultValue = defaultValue;
86  // Build the plugin
87  edm::ParameterSet fakePSet;
88  newDisc.plugin = std::unique_ptr<reco::tau::RecoTauDiscriminantPlugin>(
90  reco::tau::discPluginName(name), fakePSet));
91  discriminators_.push_back(newDisc);
92  }
93  }
94  // register products
95  for(auto const& disc : discriminators_) {
96  produces<PFTauDiscriminator>(disc.collName);
97  }
98 }
T getParameter(std::string const &) const
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 100 of file PFTauMVAInputDiscriminantTranslator.cc.

References DEFINE_FWK_MODULE, TtSemiLepEvtBuilder_cfi::disc, edm::Event::getByLabel(), eostools::move(), convertSQLitetoXML_cfg::output, edm::Event::put(), and mps_fire::result.

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

Member Data Documentation

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

Definition at line 41 of file PFTauMVAInputDiscriminantTranslator.cc.

edm::InputTag PFTauMVAInputDiscriminantTranslator::pfTauSource_
private

Definition at line 40 of file PFTauMVAInputDiscriminantTranslator.cc.