CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

PFTauMVAInputDiscriminantTranslator Class Reference

Inheritance diagram for PFTauMVAInputDiscriminantTranslator:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Classes

struct  DiscriminantInfo

Public Member Functions

 PFTauMVAInputDiscriminantTranslator (const edm::ParameterSet &)
void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

std::vector< DiscriminantInfodiscriminators_
edm::InputTag pfTauSource_

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.

                                 {
  typedef std::vector<edm::ParameterSet> VPSet;
  pfTauSource_ = pset.getParameter<edm::InputTag>("pfTauSource");
  VPSet discriminants = pset.getParameter<VPSet>("discriminants");

  for(VPSet::const_iterator iDisc = discriminants.begin();
      iDisc != discriminants.end(); ++iDisc) {
    // WTF IS GOING ON HERE
    std::string name = iDisc->getParameter<std::string>("name");
    double defaultValue = (iDisc->exists("default")) ?
        iDisc->getParameter<double>("default") : 0.;
    // check if we are getting multiple indices
    bool requestMultiple = iDisc->exists("indices");
    if(requestMultiple) {
      // make a discrimiantor for each desired index
      std::vector<uint32_t> indices =
          iDisc->getParameter<std::vector<uint32_t> >("indices");
      for(std::vector<uint32_t>::const_iterator index = indices.begin();
          index != indices.end(); ++index) {
        DiscriminantInfo newDisc;
        newDisc.name = name;
        newDisc.index = *index;
        newDisc.defaultValue = defaultValue;
        // make a nice colleciton name
        std::stringstream collectionName;
        collectionName << name << *index;
        newDisc.collName = collectionName.str();
        // Build the plugin
        edm::ParameterSet fakePSet;
        newDisc.plugin.reset(
            RecoTauDiscriminantPluginFactory::get()->create(
                reco::tau::discPluginName(name), fakePSet));
        discriminators_.push_back(newDisc);
      }
    } else {
      //single discriminant
      DiscriminantInfo newDisc;
      newDisc.name = name;
      newDisc.collName = name;
      newDisc.index = 0;
      newDisc.defaultValue = defaultValue;
      // Build the plugin
      edm::ParameterSet fakePSet;
      newDisc.plugin.reset(
          RecoTauDiscriminantPluginFactory::get()->create(
              reco::tau::discPluginName(name), fakePSet));
      discriminators_.push_back(newDisc);
    }
  }
  // register products
  BOOST_FOREACH(const DiscriminantInfo& disc, discriminators_) {
    produces<PFTauDiscriminator>(disc.collName);
  }
}

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, pfTaus_cff::pfTaus, PFTauMVAInputDiscriminantTranslator::DiscriminantInfo::plugin, edm::Event::put(), and query::result.

                                                                           {
  // Handle to get PFTaus to associated to
  edm::Handle<PFTauCollection> pfTaus;
  evt.getByLabel(pfTauSource_, pfTaus);

  BOOST_FOREACH(const DiscriminantInfo& disc, discriminators_) {
    // output for this discriminator
    std::auto_ptr<PFTauDiscriminator> output(
        new PFTauDiscriminator(edm::RefProd<PFTauCollection>(pfTaus)));
    // loop over taus
    for(size_t itau = 0; itau < pfTaus->size(); ++itau) {
      PFTauRef tauRef(pfTaus, itau);
      // discriminator result
      std::vector<double> result = (*disc.plugin)(tauRef);
      // The desired index
      double selected_result = disc.defaultValue;
      if (result.size()-1 < disc.index) {
        selected_result = result[disc.index];
      }
      output->setValue(itau, selected_result);
    }
    evt.put(output, disc.collName);
  }
}

Member Data Documentation

Definition at line 44 of file PFTauMVAInputDiscriminantTranslator.cc.

Definition at line 43 of file PFTauMVAInputDiscriminantTranslator.cc.