Hello, dear ROOT forum:
I made a modification in the ClassificationApplication macro, and it compiles well but at the time to execute it, sends me an error. Here is part of the modified code,
using namespace TMVA;
void BmesonClassificationApplication( TString myMethodList = "" )
{
TMVA::Tools::Instance();
std::map<std::string,int> Use;
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
Float_t nB, nMu, B_px, B_py, B_pz, B_kaon_px, B_kaon_py, B_kaon_pz;
reader->AddVariable( "nB", &nB );
reader->AddVariable( "nMu", &nMu );
...
TString dir = "Dataset_B_Decay/weights/";
TString prefix = "BmesonClassification";
// Book method(s)
for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
if (it->second) {
TString methodName = TString(it->first) + TString(" method");
TString weightfile = dir + prefix + TString("_") + TString(it->first) + TString(".weights.xml");
reader->BookMVA( methodName, weightfile );
}
}
// Book output histograms
UInt_t nbin = 100;
TH1F *histNn(0);
TH1F *histNnbfgs(0);
TH1F *histNnbnn(0);
...
if (Use["MLP"]) histNn = new TH1F( "MVA_MLP", "MVA_MLP", nbin, -1.25, 1.5 );
...
TFile *input(0);
TString fname = "/data.root";
...
TFile* signalfile = new TFile("signal.root");
TTree* signaltree = (TTree*)signalfile->Get("rootuple/ntuple");
signaltree->SetBranchAddress( "nB", &nB );
signaltree->SetBranchAddress( "nMu", &nMu );
...
std::vector<Float_t> vecVar(4); // vector for EvaluateMVA tests
std::cout << "--- Processing: " << signaltree->GetEntries() << " events" << std::endl;
TStopwatch sw;
sw.Start();
for (Long64_t ievt=0; ievt<signaltree->GetEntries();ievt++) {
if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl;
signaltree->GetEntry(ievt);
if (Use["MLP" ]) histNn ->Fill( reader->EvaluateMVA( "MLP method" ) );
...
sw.Stop();
std::cout << "--- End of event loop: "; sw.Print();
TFile *target = new TFile( "BmesonClassificationApp.root","RECREATE" );
if (Use["MLP" ]) histNn ->Write();
...
std::cout << "--- Created root file: \"TMVApp_BmesonClassification.root\" containing the MVA output histograms" << std::endl;
delete reader;
std::cout << "==> TMVA_BmesonClassificationApplication is done!" << std::endl << std::endl;
}
}
int main( int argc, char** argv )
{
TString methodList;
for (int i=1; i<argc; i++) {
TString regMethod(argv[i]);
if(regMethod=="-b" || regMethod=="--batch") continue;
if (!methodList.IsNull()) methodList += TString(",");
methodList += regMethod;
}
BmesonClassificationApplication(methodList);
return 0;
}
The error is:
==> Start BClassificationApplication
<FATAL> : <BookMVA> fatal error: unable to open input weight file: Dataset_B_Decay/weights/BmesonClassification_MLP.weights.xml
***> abort program execution
terminate called after throwing an instance of 'std::runtime_error'
what(): FATAL error
BTW the macro of only BmesonClassification.C works and I obtain the weights files BmesonClassification_BDT.weights.xml, etc. Could you please give a clue that what’s going on?
Thanks a lot and have a nice day
Karen