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

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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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

43  : mva_(pset.getParameter<std::string>("computerName"),
44  pset.getParameter<std::string>("dbLabel"),
45  pset.getParameter<edm::ParameterSet>("discriminantOptions")),
46  signalSrc_(pset.getParameter<edm::InputTag>("signalSrc")),
47  backgroundSrc_(pset.getParameter<edm::InputTag>("backgroundSrc")) {
48  // Check if we want to apply weights
49  applyWeights_ = false;
50  if (pset.exists("signalWeights")) {
51  applyWeights_ = true;
52  signalWeightsSrc_ = pset.getParameter<edm::InputTag>("signalWeights");
53  backgroundWeightsSrc_ = pset.getParameter<edm::InputTag>("backgroundWeights");
54  }
55  if (pset.exists("eventWeights")) {
56  eventWeights_ = pset.getParameter<VInputTag>("eventWeights");
57  }
58  }
T getParameter(std::string const &) const
edm::InputTag signalWeightsSrc_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::InputTag > VInputTag
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 81 of file RecoTauMVATrainer.cc.

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

82  {
83  // Get a view to our taus
86 
87  bool signalExists = false;
88  evt.getByLabel(signalSrc_, signal);
89  if (signal.isValid() && signal->size())
90  signalExists = true;
91 
92  bool backgroundExists = false;
93  evt.getByLabel(backgroundSrc_, background);
94  if (background.isValid() && background->size())
95  backgroundExists = true;
96 
97  // Check if we have anything to do
98  bool somethingToDo = signalExists || backgroundExists;
99  if (!somethingToDo)
100  return;
101 
102  // Make sure the MVA is up to date from the DB
103  mva_.setEvent(evt, es);
104 
105  // Get event weights if specified
106  double eventWeight = 1.0;
107  BOOST_FOREACH(const edm::InputTag& weightTag, eventWeights_) {
108  edm::Handle<double> weightHandle;
109  evt.getByLabel(weightTag, weightHandle);
110  if (weightHandle.isValid())
111  eventWeight *= *weightHandle;
112  }
113 
114  // Get weights if desired
116  edm::Handle<reco::PFTauDiscriminator> backgroundWeights;
117  if (applyWeights_ && signalExists)
118  evt.getByLabel(signalWeightsSrc_, signalWeights);
119  if (applyWeights_ && backgroundExists)
120  evt.getByLabel(backgroundWeightsSrc_, backgroundWeights);
121 
122  if (signalExists)
123  uploadTrainingData(&mva_, signal, signalWeights, true, eventWeight);
124  if (backgroundExists)
125  uploadTrainingData(&mva_, background, backgroundWeights,
126  false, eventWeight);
127 }
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:356
edm::InputTag signalSrc_
reco::tau::RecoTauMVAHelper mva_
edm::InputTag backgroundWeightsSrc_

Member Data Documentation

bool RecoTauMVATrainer::applyWeights_
private

Definition at line 36 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

edm::InputTag RecoTauMVATrainer::backgroundSrc_
private

Definition at line 35 of file RecoTauMVATrainer.cc.

Referenced by analyze().

edm::InputTag RecoTauMVATrainer::backgroundWeightsSrc_
private

Definition at line 38 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

VInputTag RecoTauMVATrainer::eventWeights_
private

Definition at line 39 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().

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

Definition at line 33 of file RecoTauMVATrainer.cc.

Referenced by analyze().

edm::InputTag RecoTauMVATrainer::signalSrc_
private

Definition at line 34 of file RecoTauMVATrainer.cc.

Referenced by analyze().

edm::InputTag RecoTauMVATrainer::signalWeightsSrc_
private

Definition at line 37 of file RecoTauMVATrainer.cc.

Referenced by analyze(), and RecoTauMVATrainer().