34 void TMVAMulticlassApplication( TString myMethodList =
"" )
41 std::map<std::string,int> Use;
48 std::cout << std::endl;
49 std::cout <<
"==> Start TMVAMulticlassApplication" << std::endl;
50 if (myMethodList !=
"") {
51 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
54 for (
UInt_t i=0; i<mlist.size(); i++) {
55 std::string regMethod(mlist[i]);
57 if (Use.find(regMethod) == Use.end()) {
58 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
59 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" " << std::endl;
60 std::cout << std::endl;
81 TString dir =
"dataset/weights/";
82 TString prefix =
"TMVAMulticlass";
84 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
86 TString methodName = TString(it->first) + TString(
" method");
87 TString weightfile = dir + prefix + TString(
"_") + TString(it->first) + TString(
".weights.xml");
88 reader->
BookMVA( methodName, weightfile );
94 TH1F *histMLP_signal(0), *histBDTG_signal(0), *histFDAGA_signal(0), *histPDEFoam_signal(0);
96 histMLP_signal =
new TH1F(
"MVA_MLP_signal",
"MVA_MLP_signal", nbin, 0., 1.1 );
98 histBDTG_signal =
new TH1F(
"MVA_BDTG_signal",
"MVA_BDTG_signal", nbin, 0., 1.1 );
100 histFDAGA_signal =
new TH1F(
"MVA_FDA_GA_signal",
"MVA_FDA_GA_signal", nbin, 0., 1.1 );
102 histPDEFoam_signal =
new TH1F(
"MVA_PDEFoam_signal",
"MVA_PDEFoam_signal", nbin, 0., 1.1 );
106 TString fname =
"./tmva_example_multiple_background.root";
111 std::cout <<
"ERROR: could not open data file, please generate example data first!" << std::endl;
114 std::cout <<
"--- TMVAMulticlassApp : Using input file: " << input->GetName() << std::endl;
121 TTree* theTree = (TTree*)input->Get(
"TreeS");
122 std::cout <<
"--- Select signal sample" << std::endl;
123 theTree->SetBranchAddress(
"var1", &var1 );
124 theTree->SetBranchAddress(
"var2", &var2 );
125 theTree->SetBranchAddress(
"var3", &var3 );
126 theTree->SetBranchAddress(
"var4", &var4 );
128 std::cout <<
"--- Processing: " << theTree->GetEntries() <<
" events" << std::endl;
132 for (
Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) {
134 std::cout <<
"--- ... Processing event: " << ievt << std::endl;
136 theTree->GetEntry(ievt);
151 std::cout <<
"--- End of event loop: "; sw.
Print();
153 TFile *target =
new TFile(
"TMVAMulticlassApp.root",
"RECREATE" );
155 histMLP_signal->Write();
157 histBDTG_signal->Write();
159 histFDAGA_signal->Write();
161 histPDEFoam_signal->Write();
164 std::cout <<
"--- Created root file: \"TMVMulticlassApp.root\" containing the MVA output histograms" << std::endl;
168 std::cout <<
"==> TMVAClassificationApplication is done!" << std::endl << std::endl;
171 int main(
int argc,
char** argv )
175 for (
int i=1; i<argc; i++) {
176 TString regMethod(argv[i]);
177 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
178 if (!methodList.IsNull()) methodList += TString(
",");
179 methodList += regMethod;
181 TMVAMulticlassApplication(methodList);
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
tomato 1-D histogram with a float per channel (see TH1 documentation)}
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
void Stop()
Stop the stopwatch.
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
R__EXTERN TSystem * gSystem
Abstract ClassifierFactory template that handles arbitrary types.
int main(int argc, char **argv)
const std::vector< Float_t > & EvaluateMulticlass(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables