34void TMVAMulticlassApplication(
TString myMethodList =
"" )
41 std::map<std::string,int> Use;
50 std::cout << std::endl;
51 std::cout <<
"==> Start TMVAMulticlassApp" << std::endl;
52 if (myMethodList !=
"") {
53 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
55 std::vector<TString> mlist =
gTools().SplitString( myMethodList,
',' );
56 for (
UInt_t i=0; i<mlist.size(); i++) {
57 std::string regMethod(mlist[i]);
59 if (Use.find(regMethod) == Use.end()) {
60 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
61 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" " << std::endl;
62 std::cout << std::endl;
83 TString dir =
"dataset/weights/";
84 TString prefix =
"TMVAMulticlass";
86 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
91 if (!
gSystem->AccessPathName( weightfile ))
93 reader->
BookMVA( methodName, weightfile );
95 std::cout <<
"TMVAMultiClassApplication: Skip " << methodName <<
" since it has not been trained !" << std::endl;
103 TH1F *histMLP_signal(0), *histBDTG_signal(0), *histFDAGA_signal(0), *histPDEFoam_signal(0);
104 TH1F *histDLCPU_signal(0), *histDLGPU_signal(0);
106 histMLP_signal =
new TH1F(
"MVA_MLP_signal",
"MVA_MLP_signal", nbin, 0., 1.1 );
108 histBDTG_signal =
new TH1F(
"MVA_BDTG_signal",
"MVA_BDTG_signal", nbin, 0., 1.1 );
110 histDLCPU_signal =
new TH1F(
"MVA_DLCPU_signal",
"MVA_DLCPU_signal", nbin, 0., 1.1);
112 histDLGPU_signal =
new TH1F(
"MVA_DLGPU_signal",
"MVA_DLGPU_signal", nbin, 0., 1.1);
114 histFDAGA_signal =
new TH1F(
"MVA_FDA_GA_signal",
"MVA_FDA_GA_signal", nbin, 0., 1.1 );
116 histPDEFoam_signal =
new TH1F(
"MVA_PDEFoam_signal",
"MVA_PDEFoam_signal", nbin, 0., 1.1 );
119 TFile *input(
nullptr);
120 TString fname =
gROOT->GetTutorialDir() +
"/machine_learning/data/tmva_multiclass_example.root";
121 if (!
gSystem->AccessPathName( fname )) {
125 std::cout <<
"ERROR: could not open data file" << std::endl;
128 std::cout <<
"--- TMVAMulticlassApp : Using input file: " << input->GetName() << std::endl;
136 std::cout <<
"--- Select signal sample" << std::endl;
142 std::cout <<
"--- Processing: " << theTree->
GetEntries() <<
" events" << std::endl;
148 std::cout <<
"--- ... Processing event: " << ievt << std::endl;
169 std::cout <<
"--- End of event loop: "; sw.
Print();
171 TFile *target =
new TFile(
"TMVAMulticlassApp.root",
"RECREATE" );
173 histMLP_signal->Write();
175 histBDTG_signal->Write();
177 histDLCPU_signal->Write();
179 histDLGPU_signal->Write();
181 histFDAGA_signal->Write();
183 histPDEFoam_signal->Write();
186 std::cout <<
"--- Created root file: \"TMVMulticlassApp.root\" containing the MVA output histograms" << std::endl;
190 std::cout <<
"==> TMVAMulticlassApp is done!" << std::endl << std::endl;
193int main(
int argc,
char** argv )
197 for (
int i=1; i<argc; i++) {
199 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
201 methodList += regMethod;
203 TMVAMulticlassApplication(methodList);
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long long Long64_t
Portable signed long integer 8 bytes.
float Float_t
Float 4 bytes (float).
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Close(Option_t *option="") override
Close a file.
1-D histogram with a float per channel (see TH1 documentation)
The Reader class serves to use the MVAs in a specific analysis context.
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
const std::vector< Float_t > & EvaluateMulticlass(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr, bool suppressMissingBranchError)
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual Long64_t GetEntries() const
create variable transformations