CMS 3D CMS Logo

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

Public Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &es)
 
 RecoTauMVATrainer (const edm::ParameterSet &pset)
 
virtual ~RecoTauMVATrainer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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_.

41  : mva_(pset.getParameter<std::string>("computerName"),
42  pset.getParameter<std::string>("dbLabel"),
43  pset.getParameter<edm::ParameterSet>("discriminantOptions")),
44  signalSrc_(pset.getParameter<edm::InputTag>("signalSrc")),
45  backgroundSrc_(pset.getParameter<edm::InputTag>("backgroundSrc")) {
46  // Check if we want to apply weights
47  applyWeights_ = false;
48  if (pset.exists("signalWeights")) {
49  applyWeights_ = true;
50  signalWeightsSrc_ = pset.getParameter<edm::InputTag>("signalWeights");
51  backgroundWeightsSrc_ = pset.getParameter<edm::InputTag>("backgroundWeights");
52  }
53  }
T getParameter(std::string const &) const
edm::InputTag signalWeightsSrc_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag backgroundSrc_
edm::InputTag signalSrc_
reco::tau::RecoTauMVAHelper mva_
edm::InputTag backgroundWeightsSrc_
virtual RecoTauMVATrainer::~RecoTauMVATrainer ( )
inlinevirtual

Definition at line 29 of file RecoTauMVATrainer.cc.

29 {};

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 76 of file RecoTauMVATrainer.cc.

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

77  {
78  // Make sure the MVA is up to date from the DB
79  mva_.setEvent(evt, es);
80 
81  // Get a view to our taus
84 
85  bool signalExists = true;
86  try {
87  evt.getByLabel(signalSrc_, signal);
88  if (!signal.isValid())
89  signalExists = false;
90  } catch(...) {
91  signalExists = false;
92  }
93 
94  bool backgroundExists = true;
95  try {
96  evt.getByLabel(backgroundSrc_, background);
97  if (!background.isValid())
98  backgroundExists = false;
99  } catch(...) {
100  backgroundExists = false;
101  }
102 
103  // Get weights if desired
105  edm::Handle<reco::PFTauDiscriminator> backgroundWeights;
106  if (applyWeights_ && signalExists)
107  evt.getByLabel(signalWeightsSrc_, signalWeights);
108  if (applyWeights_ && backgroundExists)
109  evt.getByLabel(backgroundWeightsSrc_, backgroundWeights);
110 
111  if (signalExists)
112  uploadTrainingData(&mva_, signal, signalWeights, true);
113  if (backgroundExists)
114  uploadTrainingData(&mva_, background, backgroundWeights, false);
115 }
void setEvent(const edm::Event &evt, const edm::EventSetup &es)
edm::InputTag signalWeightsSrc_
edm::InputTag backgroundSrc_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
edm::InputTag signalSrc_
reco::tau::RecoTauMVAHelper mva_
edm::InputTag backgroundWeightsSrc_

Member Data Documentation

bool RecoTauMVATrainer::applyWeights_
private

Definition at line 35 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

edm::InputTag RecoTauMVATrainer::backgroundSrc_
private

Definition at line 34 of file RecoTauMVATrainer.cc.

Referenced by analyze().

edm::InputTag RecoTauMVATrainer::backgroundWeightsSrc_
private

Definition at line 37 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

reco::tau::RecoTauMVAHelper RecoTauMVATrainer::mva_
private

Definition at line 32 of file RecoTauMVATrainer.cc.

Referenced by analyze().

edm::InputTag RecoTauMVATrainer::signalSrc_
private

Definition at line 33 of file RecoTauMVATrainer.cc.

Referenced by analyze().

edm::InputTag RecoTauMVATrainer::signalWeightsSrc_
private

Definition at line 36 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().