CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

RecoTauMVATrainer Class Reference

Inheritance diagram for RecoTauMVATrainer:
edm::EDAnalyzer edm::EDConsumerBase

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 Types

typedef std::vector
< edm::InputTag
VInputTag

Private Attributes

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

Detailed Description

Definition at line 26 of file RecoTauMVATrainer.cc.


Member Typedef Documentation

typedef std::vector<edm::InputTag> RecoTauMVATrainer::VInputTag [private]

Definition at line 32 of file RecoTauMVATrainer.cc.


Constructor & Destructor Documentation

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

Definition at line 42 of file RecoTauMVATrainer.cc.

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

  : mva_(pset.getParameter<std::string>("computerName"),
         pset.getParameter<std::string>("dbLabel"),
         pset.getParameter<edm::ParameterSet>("discriminantOptions")),
    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");
      }
      if (pset.exists("eventWeights")) {
        eventWeights_ = pset.getParameter<VInputTag>("eventWeights");
      }
    }
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 81 of file RecoTauMVATrainer.cc.

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

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

  bool signalExists = false;
  evt.getByLabel(signalSrc_, signal);
  if (signal.isValid() && signal->size())
    signalExists = true;

  bool backgroundExists = false;
  evt.getByLabel(backgroundSrc_, background);
  if (background.isValid() && background->size())
    backgroundExists = true;

  // Check if we have anything to do
  bool somethingToDo = signalExists || backgroundExists;
  if (!somethingToDo)
    return;

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

  // Get event weights if specified
  double eventWeight = 1.0;
  BOOST_FOREACH(const edm::InputTag& weightTag, eventWeights_) {
    edm::Handle<double> weightHandle;
    evt.getByLabel(weightTag, weightHandle);
    if (weightHandle.isValid())
      eventWeight *= *weightHandle;
  }

  // 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, eventWeight);
  if (backgroundExists)
    uploadTrainingData(&mva_, background, backgroundWeights,
        false, eventWeight);
}

Member Data Documentation

Definition at line 36 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

Definition at line 35 of file RecoTauMVATrainer.cc.

Referenced by analyze().

Definition at line 38 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

Definition at line 39 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

Definition at line 33 of file RecoTauMVATrainer.cc.

Referenced by analyze().

Definition at line 34 of file RecoTauMVATrainer.cc.

Referenced by analyze().

Definition at line 37 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().