#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include "TChain.h"
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TObjString.h"
#include "TSystem.h"
#include "TROOT.h"
#include "TMVA/Tools.h"
#include "TMVA/Factory.h"
#include "TMVA/DataLoader.h"
Go to the source code of this file.
Definition at line 24 of file train.C.
References om::cout, train_bdt::dataloader, allTimeWatchdog::endl, train_bdt::factory, file, lt, pot, string, and art::to_string().
Referenced by cvn::CVNEventDump::analyze(), cvn::CVNCosmicEventDump::analyze(), cvn::CVNEventProngDump::analyze(), and cvn::CVNAddTrainingData::produce().
26 TFile *
file =
new TFile(
"files/hadded_all_files.root");
31 TFile *filepot =
new TFile(
"files/hadded_fluxswap_files.root");
33 double pot = 9.47964e20;
36 TH1 *hPOT = (TH1F*)filepot->Get(
"pot");
37 double totPOT = hPOT->Integral();
38 cout<<
"pot from fluxswap is "<<totPOT<<
endl;
40 TH1 *hLt = (TH1F*)file->Get(
"livetime");
41 double totLt = hLt->Integral();
44 double nuScale = pot/totPOT;
45 double cosScale= lt/totLt;
47 cout<<
" scale for mc "<<nuScale;
48 cout<<
" scale for cosmic "<<cosScale;
50 TTree *sigTree = (TTree*)file->Get(
"sigTree");
51 TTree *bkgTree = (TTree*)file->Get(
"bkgTree");
53 TFile* outputFile = TFile::Open(
"files/test_current_bdt.root",
"recreate");
54 TMVA::Factory *
factory =
new TMVA::Factory(
"MVAnalysis",outputFile,
"V");
55 TMVA::DataLoader *
dataloader=
new TMVA::DataLoader(
"dataset");
57 dataloader->AddVariable(
"nhit",
'F');
58 dataloader->AddVariable(
"cvnsse",
'F');
60 dataloader->AddVariable(
"sparseassym",
'F');
63 dataloader->AddVariable(
"ptp",
'F');
64 dataloader->AddVariable(
"disttop",
'F');
65 dataloader->AddVariable(
"distnottop",
'F');
100 dataloader->AddSpectator(
"woscdumb",
'F');
102 dataloader->AddSpectator(
"isGENIE",
'F');
103 dataloader->AddSpectator(
"pdg",
'F');
104 dataloader->AddSpectator(
"pdgorig",
'F');
105 dataloader->AddSpectator(
"isCC",
'F');
110 TCut
presel =
"cvnsse>0.5 && prongl > 0";
116 dataloader->AddSignalTree (sigTree);
117 dataloader->AddBackgroundTree(bkgTree);
119 dataloader->AddCut(presel);
124 dataloader->SetWeightExpression(weightExp.c_str());
126 dataloader->PrepareTrainingAndTestTree(
"",
"SplitMode=random");
133 factory->BookMethod(dataloader, TMVA::Types::kBDT,
"test_current_bdt",
"H:V:NTrees=500:InverseBoostNegWeights::BoostType=RealAdaBoost:Shrinkage=0.1:nCuts=40:MaxDepth=5:MinNodeSize=2%:NodePurityLimit=0.9");
140 factory->TrainAllMethods();
141 factory->TestAllMethods();
142 factory->EvaluateAllMethods();
std::string to_string(ModuleType mt)