CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
PFTauMVAInputDiscriminantTranslator Class Reference
Inheritance diagram for PFTauMVAInputDiscriminantTranslator:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  DiscriminantInfo
 

Public Member Functions

 PFTauMVAInputDiscriminantTranslator (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

std::vector< DiscriminantInfodiscriminators_
 
edm::InputTag pfTauSource_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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 PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::collName, SurfaceDeformationFactory::create(), PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::defaultValue, reco::tau::discPluginName(), reco::get(), edm::ParameterSet::getParameter(), PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::index, getHLTprescales::index, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::name, mergeVDriftHistosByStation::name, and PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::plugin.

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
std::string discPluginName(const std::string &mvaName)
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:56

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 103 of file PFTauMVAInputDiscriminantTranslator.cc.

References PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::collName, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::defaultValue, edm::Event::getByLabel(), PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::index, convertSQLitetoXML_cfg::output, python.pfTaus_cff::pfTaus, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::plugin, edm::Event::put(), and query::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  std::auto_ptr<PFTauDiscriminator> output(
113  // loop over taus
114  for(size_t itau = 0; itau < pfTaus->size(); ++itau) {
115  PFTauRef tauRef(pfTaus, itau);
116  // discriminator result
117  std::vector<double> result = (*disc.plugin)(tauRef);
118  // The desired index
119  double selected_result = disc.defaultValue;
120  if (result.size()-1 < disc.index) {
121  selected_result = result[disc.index];
122  }
123  output->setValue(itau, selected_result);
124  }
125  evt.put(output, disc.collName);
126  }
127 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355

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.