 |
Belle II Software
release-05-01-25
|
11 #include <analysis/modules/CurlTagger/SelectorMVA.h>
13 #include <analysis/variables/TrackVariables.h>
14 #include <analysis/variables/MCTruthVariables.h>
15 #include <analysis/variables/Variables.h>
21 using namespace CurlTagger;
31 m_TFileName =
"CurlTagger_TrainingData_BelleII.root";
41 m_IsCurl = (Variable::genParticleIndex(iPart) == Variable::genParticleIndex(jPart) ? 1 : 0);
45 m_PtDiffEW = abs(Variable::particlePt(iPart) - Variable::particlePt(jPart)) / (Variable::particlePtErr(
46 iPart) + Variable::particlePtErr(jPart));
47 m_PzDiffEW = abs(Variable::particlePz(iPart) - Variable::particlePz(jPart)) / (Variable::particlePzErr(
48 iPart) + Variable::particlePzErr(jPart));
49 m_TrackD0DiffEW = abs(Variable::trackD0(iPart) - Variable::trackD0(jPart)) / (Variable::trackD0Error(
50 iPart) + Variable::trackD0Error(jPart));
51 m_TrackZ0DiffEW = abs(Variable::trackZ0(iPart) - Variable::trackZ0(jPart)) / (Variable::trackZ0Error(
52 iPart) + Variable::trackZ0Error(jPart));
53 m_TrackTanLambdaDiffEW = abs(Variable::trackTanLambda(iPart) - Variable::trackTanLambda(jPart)) / (Variable::trackTanLambdaError(
54 iPart) + Variable::trackTanLambdaError(jPart));
55 m_TrackPhi0DiffEW = abs(Variable::trackPhi0(iPart) - Variable::trackPhi0(jPart)) / (Variable::trackPhi0Error(
56 iPart) + Variable::trackPhi0Error(jPart));
57 m_TrackOmegaDiffEW = abs(Variable::trackOmega(iPart) - Variable::trackOmega(jPart)) / (Variable::trackOmegaError(
58 iPart) + Variable::trackOmegaError(jPart));
77 m_TTree =
new TTree(
"ntuple",
"Training Data for the Curl Tagger MVA");
92 m_variables = {
"PPhi",
"ChargeProduct",
"PtDiffEW",
"PzDiffEW",
"TrackD0DiffEW",
"TrackZ0DiffEW",
"TrackTanLambdaDiffEW",
"TrackPhi0DiffEW",
"TrackOmegaDiffEW"};
125 specificOptions. m_nLevels = 4;
128 auto weightfile = teacher->train(dataset);
Options for the FANN MVA method.
std::string m_identifier
Identifier containing the finished training.
Float_t m_ChargeProduct
charge(p1) * charge(p2)
SelectorMVA(bool belleFlag, bool trainFlag)
Constructor.
std::string m_TFileName
name of output file for training data
Teacher for the FastBDT MVA method.
virtual void initialize() override
initialize whatever needs to be initalized (root file etc)
static void saveToDatabase(Weightfile &weightfile, const std::string &identifier, const Belle2::IntervalOfValidity &iov=Belle2::IntervalOfValidity(0, 0, -1, -1))
Static function which saves a Weightfile in the basf2 condition database.
virtual std::vector< float > apply(Dataset &test_data) const override
Apply this expert onto a dataset.
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
std::string m_weight_variable
Weight variable (branch name) defining the weights.
Float_t m_TrackPhi0DiffEW
error weighted track Phi0 difference
virtual void finalize() override
finalize whatever needs to be finalized (train the MVA)
Float_t m_TrackD0DiffEW
error weighted track D0 difference
~SelectorMVA()
Destructor.
Float_t m_TrackZ0DiffEW
error weighted track Z0 difference
TFile * m_TFile
output file for training data
float getCharge(void) const
Returns particle charge.
unsigned int m_nCuts
Number of cut Levels = log_2(Number of Cuts)
Abstract base class for different kinds of events.
void updateVariables(Particle *iPart, Particle *jPart)
updates the value of the MVA variable
std::string m_target_variable
Target variable (branch name) defining the target.
unsigned int m_nTrees
Number of trees.
int m_signal_class
Signal class which is used as signal in a classification problem.
MVA::FastBDTExpert m_expert
mva expert
Float_t m_PzDiffEW
error weighted particle Pz difference
Float_t m_TrackOmegaDiffEW
error weighted track Omega difference
std::vector< std::string > m_variables
Vector of all variables (branch names) used in the training.
virtual void collectTrainingInfo(Particle *iPart, Particle *jPart) override
collect training data and save to a root file
General options which are shared by all MVA trainings.
TVector3 getMomentum() const
Returns momentum vector.
Wraps the data of a single event into a Dataset.
Float_t m_PPhi
angle between particle momentum vectors
static Weightfile loadFromDatabase(const std::string &identifier, const Belle2::EventMetaData &emd=Belle2::EventMetaData(0, 0, 0))
Static function which loads a Weightfile from the basf2 condition database.
bool m_TrainFlag
applying mva or training it
Class to store reconstructed particles.
std::vector< std::string > m_datafiles
Name of the datafiles containing the training data.
MVA::GeneralOptions m_generalOptions
mva general options (for the expert)
std::string m_identifier
mva identifier
virtual float getResponse(Particle *iPart, Particle *jPart) override
Selector response that this pair of particles come from the same mc/actual particle.
Proivdes a dataset from a ROOT file This is the usually used dataset providing training data to the m...
Float_t m_PtDiffEW
error weighted particle Pt difference
std::vector< std::string > m_variables
names of variables used by mva
TTree * m_TTree
training data tree
Float_t m_TrackTanLambdaDiffEW
error weighted track tan lambda diff difference
virtual std::vector< float > getVariables(Particle *iPart, Particle *jPart) override
returns vector of variables used by this selector.
std::string m_target_variable
name of target variable (isCurl)
Float_t m_IsCurl
isCurl Truth