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