CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

RecoTauMVADiscriminator Class Reference

Inheritance diagram for RecoTauMVADiscriminator:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &)
double discriminate (const reco::PFTauRef &)
 RecoTauMVADiscriminator (const edm::ParameterSet &pset)
 ~RecoTauMVADiscriminator ()

Private Types

typedef boost::ptr_map
< reco::PFTau::hadronicDecayMode,
reco::tau::RecoTauMVAHelper
MVAMap

Private Attributes

std::string dbLabel_
std::auto_ptr
< reco::tau::RecoTauMVAHelper
defaultMVA_
MVAMap mvas_
bool remapOutput_
double unsupportedDMValue_

Detailed Description

Definition at line 37 of file RecoTauMVADiscriminator.cc.


Member Typedef Documentation

Definition at line 48 of file RecoTauMVADiscriminator.cc.


Constructor & Destructor Documentation

RecoTauMVADiscriminator::RecoTauMVADiscriminator ( const edm::ParameterSet pset) [explicit]

Definition at line 58 of file RecoTauMVADiscriminator.cc.

References dtTTrigAnalyzer_cfg::dbLabel, defaultMVA_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), mvas_, reco::tau::helpers::nCharged(), TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminantFailValue_, remapOutput_, AlCaHLTBitMon_QueryRunRegistry::string, reco::tau::translateDecayMode(), and unsupportedDMValue_.

  :PFTauDiscriminationProducerBase(pset) {
  std::string dbLabel;
  if (pset.exists("dbLabel"))
    dbLabel = pset.getParameter<std::string>("dbLabel");

  unsupportedDMValue_ = (pset.exists("unsupportedDecayModeValue")) ?
      pset.getParameter<double>("unsupportedDecayModeValue")
      : prediscriminantFailValue_;

  remapOutput_ = pset.getParameter<bool>("remapOutput");

  edm::ParameterSet discriminantOptions = pset.getParameter<edm::ParameterSet>(
      "discriminantOptions");

  typedef std::vector<edm::ParameterSet> VPSet;
  const VPSet& mvas = pset.getParameter<VPSet>("mvas");

  for (VPSet::const_iterator mva = mvas.begin(); mva != mvas.end(); ++mva) {
    unsigned int nCharged = mva->getParameter<unsigned int>("nCharged");
    unsigned int nPiZeros = mva->getParameter<unsigned int>("nPiZeros");
    reco::PFTau::hadronicDecayMode decayMode = reco::tau::translateDecayMode(
        nCharged, nPiZeros);
    // Check to ensure this decay mode is not already added
    if (!mvas_.count(decayMode)) {
      std::string computerName = mva->getParameter<std::string>("mvaLabel");
      // Add it
      mvas_.insert(
          decayMode, new reco::tau::RecoTauMVAHelper(
            computerName, dbLabel, discriminantOptions));
    } else {
      edm::LogError("DecayModeNotUnique") << "The tau decay mode with "
        "nCharged/nPiZero = " << nCharged << "/" << nPiZeros << " dm: "
        << decayMode <<
        " is associated to multiple MVA implmentations, "
        "the second instantiation is being ignored!!!";
    }
  }

  // Check if we a catch-all MVA is desired.
  if (pset.exists("defaultMVA")) {
    defaultMVA_.reset(new reco::tau::RecoTauMVAHelper(
            pset.getParameter<std::string>("defaultMVA"),
            dbLabel, discriminantOptions));
  }

}
RecoTauMVADiscriminator::~RecoTauMVADiscriminator ( ) [inline]

Definition at line 40 of file RecoTauMVADiscriminator.cc.

{}

Member Function Documentation

void RecoTauMVADiscriminator::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
) [virtual]

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 106 of file RecoTauMVADiscriminator.cc.

References defaultMVA_, and mvas_.

                                                                  {
  // Pass the event setup so the MVAHelpers can get the MVAs from the DB
  BOOST_FOREACH(MVAMap::value_type mva, mvas_) {
      mva.second->setEvent(evt, es);
  }
  if (defaultMVA_.get())
    defaultMVA_->setEvent(evt, es);
}
double RecoTauMVADiscriminator::discriminate ( const reco::PFTauRef tau)

Definition at line 117 of file RecoTauMVADiscriminator.cc.

References defaultMVA_, mvas_, convertSQLitetoXML_cfg::output, remapOutput_, metsig::tau, and unsupportedDMValue_.

                                                                    {
  // Find the right MVA for this tau's decay mode
  MVAMap::iterator mva = mvas_.find(tau->decayMode());
  // If this DM has an associated decay mode, get and return the result.
  double output = unsupportedDMValue_;
  if (mva != mvas_.end() || defaultMVA_.get()) {
    if (mva != mvas_.end())
      output = mva->second->operator()(tau);
    else
      output = defaultMVA_->operator()(tau);
    // TMVA produces output from -1 to 1
    if (remapOutput_) {
      output += 1.;
      output /= 2.;
    }
  }
  return output;
}

Member Data Documentation

std::string RecoTauMVADiscriminator::dbLabel_ [private]

Definition at line 53 of file RecoTauMVADiscriminator.cc.

Definition at line 50 of file RecoTauMVADiscriminator.cc.

Referenced by beginEvent(), discriminate(), and RecoTauMVADiscriminator().

Definition at line 52 of file RecoTauMVADiscriminator.cc.

Referenced by beginEvent(), discriminate(), and RecoTauMVADiscriminator().

Definition at line 55 of file RecoTauMVADiscriminator.cc.

Referenced by discriminate(), and RecoTauMVADiscriminator().

Definition at line 54 of file RecoTauMVADiscriminator.cc.

Referenced by discriminate(), and RecoTauMVADiscriminator().