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;
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++) {
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 );
120 TString fname =
"./tmva_example_multiclass.root";
126 input =
TFile::Open(
"http://root.cern/files/tmva_multiclass_example.root",
"CACHEREAD");
129 std::cout <<
"ERROR: could not open data file" << std::endl;
132 std::cout <<
"--- TMVAMulticlassApp : Using input file: " <<
input->GetName() << std::endl;
140 std::cout <<
"--- Select signal sample" << std::endl;
146 std::cout <<
"--- Processing: " << theTree->
GetEntries() <<
" events" << std::endl;
152 std::cout <<
"--- ... Processing event: " << ievt << std::endl;
173 std::cout <<
"--- End of event loop: "; sw.
Print();
177 histMLP_signal->Write();
179 histBDTG_signal->Write();
181 histDLCPU_signal->Write();
183 histDLGPU_signal->Write();
185 histFDAGA_signal->Write();
187 histPDEFoam_signal->Write();
190 std::cout <<
"--- Created root file: \"TMVMulticlassApp.root\" containing the MVA output histograms" << std::endl;
194 std::cout <<
"==> TMVAMulticlassApp is done!" << std::endl << std::endl;
197int main(
int argc,
char** argv )
201 for (
int i=1; i<argc; i++) {
203 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
205 methodList += regMethod;
207 TMVAMulticlassApplication(methodList);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
R__EXTERN TSystem * gSystem
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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.
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
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.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
A TTree represents a columnar dataset.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
virtual Long64_t GetEntries() const
create variable transformations