33void TMVARegressionApplication(
TString myMethodList =
"" )
40 std::map<std::string,int> Use;
79 std::cout << std::endl;
80 std::cout <<
"==> Start TMVARegressionApplication" << std::endl;
83 if (myMethodList !=
"") {
84 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
87 for (
UInt_t i=0; i<mlist.size(); i++) {
88 std::string regMethod(mlist[i]);
90 if (Use.find(regMethod) == Use.end()) {
91 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
92 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
93 std::cout << std::endl;
119 TString dir =
"dataset/weights/";
120 TString prefix =
"TMVARegression";
123 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
125 TString methodName = it->first +
" method";
126 TString weightfile = dir + prefix +
"_" +
TString(it->first) +
".weights.xml";
127 reader->
BookMVA( methodName, weightfile );
134 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
135 TH1*
h =
new TH1F( it->first.c_str(),
TString(it->first) +
" method", 100, -100, 600 );
136 if (it->second) hists[++nhists] =
h;
145 TString fname =
"./tmva_reg_example.root";
151 input =
TFile::Open(
"http://root.cern.ch/files/tmva_reg_example.root",
"CACHEREAD");
154 std::cout <<
"ERROR: could not open data file" << std::endl;
157 std::cout <<
"--- TMVARegressionApp : Using input file: " << input->GetName() << std::endl;
167 std::cout <<
"--- Select signal sample" << std::endl;
171 std::cout <<
"--- Processing: " << theTree->
GetEntries() <<
" events" << std::endl;
176 if (ievt%1000 == 0) {
177 std::cout <<
"--- ... Processing event: " << ievt << std::endl;
185 for (
Int_t ih=0; ih<nhists; ih++) {
188 hists[ih]->
Fill( val );
192 std::cout <<
"--- End of event loop: "; sw.
Print();
196 TFile *target =
new TFile(
"TMVARegApp.root",
"RECREATE" );
197 for (
Int_t ih=0; ih<nhists; ih++) hists[ih]->Write();
200 std::cout <<
"--- Created root file: \"" << target->
GetName()
201 <<
"\" containing the MVA output histograms" << std::endl;
205 std::cout <<
"==> TMVARegressionApplication is done!" << std::endl << std::endl;
208int main(
int argc,
char** argv )
212 for (
int i=1; i<argc; i++) {
214 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
216 methodList += regMethod;
218 TMVARegressionApplication(methodList);
R__EXTERN TSystem * gSystem
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
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)}
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
The Reader class serves to use the MVAs in a specific analysis context.
const std::vector< Float_t > & EvaluateRegression(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
void AddSpectator(const TString &expression, Float_t *)
Add a float spectator or expression to the reader.
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void Print(Option_t *option="") const
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=0)
Change branch address, dealing with clone trees properly.
virtual Long64_t GetEntries() const
create variable transformations