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++) {
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;
122 std::cout <<
"--- Select signal sample" << std::endl;
128 std::cout <<
"--- Processing: " << theTree->
GetEntries() <<
" events" << std::endl;
134 std::cout <<
"--- ... Processing event: " << ievt << std::endl;
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++) {
177 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
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 Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
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.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
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.
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
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
virtual void Close(Option_t *option="")
Close a file.