CMS 3D CMS Logo

Public Member Functions | Private Attributes

RecoTauMVATrainer Class Reference

Inheritance diagram for RecoTauMVATrainer:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &es)
 RecoTauMVATrainer (const edm::ParameterSet &pset)
virtual ~RecoTauMVATrainer ()

Private Attributes

bool applyWeights_
edm::InputTag backgroundSrc_
edm::InputTag backgroundWeightsSrc_
reco::tau::RecoTauMVAHelper mva_
edm::InputTag signalSrc_
edm::InputTag signalWeightsSrc_

Detailed Description

Definition at line 26 of file RecoTauMVATrainer.cc.


Constructor & Destructor Documentation

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

Definition at line 40 of file RecoTauMVATrainer.cc.

References applyWeights_, backgroundWeightsSrc_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and signalWeightsSrc_.

  : mva_(pset.getParameter<std::string>("computerName"),
         pset.getParameter<std::string>("dbLabel")),
    signalSrc_(pset.getParameter<edm::InputTag>("signalSrc")),
    backgroundSrc_(pset.getParameter<edm::InputTag>("backgroundSrc")) {
      // Check if we want to apply weights
      applyWeights_ = false;
      if (pset.exists("signalWeights")) {
        applyWeights_ = true;
        signalWeightsSrc_ = pset.getParameter<edm::InputTag>("signalWeights");
        backgroundWeightsSrc_ = pset.getParameter<edm::InputTag>("backgroundWeights");
      }
    }
virtual RecoTauMVATrainer::~RecoTauMVATrainer ( ) [inline, virtual]

Definition at line 29 of file RecoTauMVATrainer.cc.

{};

Member Function Documentation

void RecoTauMVATrainer::analyze ( const edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 75 of file RecoTauMVATrainer.cc.

References applyWeights_, backgroundSrc_, backgroundWeightsSrc_, edm::Event::getByLabel(), edm::HandleBase::isValid(), mva_, reco::tau::RecoTauMVAHelper::setEvent(), signalSrc_, and signalWeightsSrc_.

                                                         {
  // Make sure the MVA is up to date from the DB
  mva_.setEvent(evt, es);

  // Get a view to our taus
  edm::Handle<reco::CandidateView> signal;
  edm::Handle<reco::CandidateView> background;

  bool signalExists = true;
  try {
    evt.getByLabel(signalSrc_, signal);
    if (!signal.isValid())
      signalExists = false;
  } catch(...) {
    signalExists = false;
  }

  bool backgroundExists = true;
  try {
    evt.getByLabel(backgroundSrc_, background);
    if (!background.isValid())
      backgroundExists = false;
  } catch(...) {
    backgroundExists = false;
  }

  // Get weights if desired
  edm::Handle<reco::PFTauDiscriminator> signalWeights;
  edm::Handle<reco::PFTauDiscriminator> backgroundWeights;
  if (applyWeights_ && signalExists)
    evt.getByLabel(signalWeightsSrc_, signalWeights);
  if (applyWeights_ && backgroundExists)
    evt.getByLabel(backgroundWeightsSrc_, backgroundWeights);

  if (signalExists)
    uploadTrainingData(&mva_, signal, signalWeights, true);
  if (backgroundExists)
    uploadTrainingData(&mva_, background, backgroundWeights, false);
}

Member Data Documentation

Definition at line 35 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

Definition at line 34 of file RecoTauMVATrainer.cc.

Referenced by analyze().

Definition at line 37 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

Definition at line 32 of file RecoTauMVATrainer.cc.

Referenced by analyze().

Definition at line 33 of file RecoTauMVATrainer.cc.

Referenced by analyze().

Definition at line 36 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().