#include <TreeTrainer.h>
Public Member Functions | |
void | addReader (const TreeReader &reader) |
void | addTree (TTree *tree, int target=-1, double weight=-1.0) |
bool | iteration (MVATrainer *trainer) |
void | reset () |
void | train (MVATrainer *trainer) |
Calibration::MVAComputer * | train (const std::string &trainDescription, double crossValidation=0.0, bool useXSLT=false) |
TreeTrainer () | |
TreeTrainer (TTree *tree, double weight=-1.0) | |
TreeTrainer (TTree *signal, TTree *background, double weight=-1.0) | |
~TreeTrainer () | |
Private Attributes | |
std::vector< TreeReader > | readers |
std::vector< double * > | weights |
Definition at line 18 of file TreeTrainer.h.
PhysicsTools::TreeTrainer::TreeTrainer | ( | ) |
Definition at line 19 of file TreeTrainer.cc.
{ }
PhysicsTools::TreeTrainer::TreeTrainer | ( | TTree * | tree, |
double | weight = -1.0 |
||
) |
PhysicsTools::TreeTrainer::TreeTrainer | ( | TTree * | signal, |
TTree * | background, | ||
double | weight = -1.0 |
||
) |
PhysicsTools::TreeTrainer::~TreeTrainer | ( | ) |
void PhysicsTools::TreeTrainer::addReader | ( | const TreeReader & | reader | ) |
Definition at line 82 of file TreeTrainer.cc.
References readers.
Referenced by addTree().
{ readers.push_back(reader); }
void PhysicsTools::TreeTrainer::addTree | ( | TTree * | tree, |
int | target = -1 , |
||
double | weight = -1.0 |
||
) |
Definition at line 58 of file TreeTrainer.cc.
References addReader(), PhysicsTools::TreeReader::addSingle(), PhysicsTools::MVATrainer::kTargetId, PhysicsTools::MVATrainer::kWeightId, and weights.
Referenced by TreeTrainer().
{ static const bool targets[2] = { true, false }; TreeReader reader(tree, false, weight > 0.0); if (target >= 0) { if (tree->GetBranch("__TARGET__")) throw cms::Exception("TreeTrainer") << "__TARGET__ branch already present in file." << std::endl; reader.addSingle(MVATrainer::kTargetId, &targets[!target]); } if (weight > 0.0) { double *ptr = new double(weight); weights.push_back(ptr); reader.addSingle(MVATrainer::kWeightId, ptr); } addReader(reader); }
bool PhysicsTools::TreeTrainer::iteration | ( | MVATrainer * | trainer | ) |
Definition at line 87 of file TreeTrainer.cc.
References calib, PhysicsTools::MVATrainer::getTrainCalibration(), PhysicsTools::TreeReader::loop(), and readers.
Referenced by train().
{ Calibration::MVAComputer *calib = trainer->getTrainCalibration(); if (!calib) return true; MVAComputer computer(calib, true); std::for_each(readers.begin(), readers.end(), std::bind2nd(std::mem_fun_ref(&TreeReader::loop), &computer)); return false; }
void PhysicsTools::TreeTrainer::reset | ( | void | ) |
Definition at line 50 of file TreeTrainer.cc.
References readers, and weights.
Referenced by ~TreeTrainer().
Calibration::MVAComputer * PhysicsTools::TreeTrainer::train | ( | const std::string & | trainDescription, |
double | crossValidation = 0.0 , |
||
bool | useXSLT = false |
||
) |
Definition at line 39 of file TreeTrainer.cc.
References PhysicsTools::MVATrainer::getCalibration(), PhysicsTools::MVATrainer::setCrossValidation(), and PhysicsTools::MVATrainer::setMonitoring().
{ MVATrainer trainer(trainFile, useXSLT); trainer.setMonitoring(true); trainer.setCrossValidation(crossValidation); train(&trainer); return trainer.getCalibration(); }
void PhysicsTools::TreeTrainer::train | ( | MVATrainer * | trainer | ) |
Definition at line 102 of file TreeTrainer.cc.
References iteration().
{ while(!iteration(trainer)); }
std::vector<TreeReader> PhysicsTools::TreeTrainer::readers [private] |
Definition at line 40 of file TreeTrainer.h.
Referenced by addReader(), iteration(), and reset().
std::vector<double*> PhysicsTools::TreeTrainer::weights [private] |
Definition at line 42 of file TreeTrainer.h.