35 std::map<std::string,int> Use;
62 std::cout << std::endl;
63 std::cout <<
"==> Start TMVARegressionApplication" << std::endl;
66 if (myMethodList !=
"") {
67 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
70 for (
UInt_t i=0; i<mlist.size(); i++) {
71 std::string regMethod(mlist[i]);
73 if (Use.find(regMethod) == Use.end()) {
74 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
75 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
76 std::cout << std::endl;
103 TString prefix =
"TMVARegression";
106 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
108 TString methodName = it->first +
" method";
109 TString weightfile = dir + prefix +
"_" +
TString(it->first) +
".weights.xml";
110 reader->
BookMVA( methodName, weightfile );
117 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
118 TH1*
h =
new TH1F( it->first.c_str(),
TString(it->first) +
" method", 100, -100, 600 );
119 if (it->second) hists[++nhists] =
h;
128 TString fname =
"./tmva_reg_example.root";
133 input =
TFile::Open(
"http://root.cern.ch/files/tmva_reg_example.root" );
137 std::cout <<
"ERROR: could not open data file" << std::endl;
140 std::cout <<
"--- TMVARegressionApp : Using input file: " << input->GetName() << std::endl;
150 std::cout <<
"--- Select signal sample" << std::endl;
154 std::cout <<
"--- Processing: " << theTree->
GetEntries() <<
" events" << std::endl;
159 if (ievt%1000 == 0) {
160 std::cout <<
"--- ... Processing event: " << ievt << std::endl;
168 for (
Int_t ih=0; ih<nhists; ih++) {
171 hists[ih]->
Fill( val );
175 std::cout <<
"--- End of event loop: "; sw.
Print();
179 TFile *target =
new TFile(
"TMVARegApp.root",
"RECREATE" );
180 for (
Int_t ih=0; ih<nhists; ih++) hists[ih]->Write();
183 std::cout <<
"--- Created root file: \"" << target->
GetName()
184 <<
"\" containing the MVA output histograms" << std::endl;
188 std::cout <<
"==> TMVARegressionApplication is done!" << std::endl << std::endl;
191 int main(
int argc,
char** argv )
195 for (
int i=1; i<argc; i++) {
197 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
199 methodList += regMethod;
virtual const char * GetTitle() const
Returns title of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
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.
int main(int argc, char **argv)
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
const std::vector< Float_t > & EvaluateRegression(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
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
void TMVARegressionApplication(TString myMethodList="")
R__EXTERN TSystem * gSystem
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual const char * GetName() const
Returns name of object.
void AddSpectator(const TString &expression, Float_t *)
Add a float spectator or expression to the reader.
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.