Segmentation fault with TMVA in ROOT 6.13

Hello,

I have a segmentation fault problem when running a multivariate classification in 6.13. The algorithm training works without problems, but when it comes to using the trained algorithms to classify new data the program crashes every time.

I upload two files: the first is the ROOT macro I use for the classification; I checked it thoroughly, and all paths seem to lead to existing files. The second file is the stack trace of the crash, including the terminal output before the crash.

I would really appreciate any hint to a solution, as I am pretty clueless as to how I could solve this.

Classification1_1.C (4.8 KB)
stack-trace.txt (3.0 KB)

Hi,

Try using this as your event loop:

for (Long64_t iEvent=0; iEvent < theTree->GetEntries(); ++iEvent) {
    if (iEvent%1000 == 0) {
        std::cout << "--- ... Processing event: " << iEvent << std::endl;
    }

    theTree->GetEntry(iEvent);
      
    Pp_px = dPp_px; Pp_py = dPp_py; Pp_pz = dPp_pz; Pp_e=dPp_e; Pm_px=dPm_px;
    Pm_py = dPm_py; Pm_pz = dPm_pz; Pm_e = dPm_e;
    gamma_px = dgamma_px; gamma_py=dgamma_py; gamma_pz = dgamma_pz;
    gamma_e = dgamma_e;

    histBDT->Fill(reader->EvaluateMVA("BDT2"));
}

Basically, the way you set up your script is that data is read from the TTree into the variables d* (dPp_px etc). TMVA itself is setup to read data from the variables lacking the d prefix (Pp_px etc). However, data was never transferred between the two sets of variables.

This should explain why TMVA choked on the input. Please try it out and get back to us!

Cheers,
Kim

Thank you for your quick reply. That is indeed something I did’t think of; unfortunately, it doesn’t seem to change much: the program still crashes at the same point.

Can you run the TMVAClassificationApplication.C example successfully? Use:

root -l -b -q "$ROOTSYS/tutorials/tmva/TMVAClassificationApplication.C(\"BDTG\")"

(You might have to run root -l -b -q $ROOTSYS/tutorials/tmva/TMVAClassification.C(\"BDTG\")") first to ensure all required files are generated.)

Yes, no problems with that! In fact I used it as a guideline to create my macro.

I think the next step is to figure out where exactly things go wrong in your script. You can use something like this.

for (Long64_t iEvent=0; iEvent < theTree->GetEntries(); ++iEvent) {
    std::cout << "Checkpoint 1" << std::endl;
    theTree->GetEntry(iEvent);

    std::cout << "Checkpoint 2" << std::endl;
    Pp_px = dPp_px; Pp_py = dPp_py; Pp_pz = dPp_pz; Pp_e=dPp_e; Pm_px=dPm_px;
    Pm_py = dPm_py; Pm_pz = dPm_pz; Pm_e = dPm_e;
    gamma_px = dgamma_px; gamma_py=dgamma_py; gamma_pz = dgamma_pz;
    gamma_e = dgamma_e;

    std::cout << "Checkpoint 3" << std::endl;
    auto mva_output = reader->EvaluateMVA("BDT2");

    std::cout << "Checkpoint 4" << std::endl;
    histBDT->Fill(mva_output);
}

If checkpoints 1-4 are printed, the problem is external to TMVA. If any are not printed we need to dig deeper.

Cheers,
Kim

All checkpoints are printed multiple times. I guess as you said the problem is external to TMVA.

What about the last iteration just before the crash; Are all checkpoints printed then as well?

Cheers,
Kim

They are all printed, yes! After printing the last “Checkpoint 4” string the program halts for a moment and then crashes.

Then I suggest you take a look at you histogram. What number is it trying to fill it with when it crashes?

I post here the full output up until right before the crash. Apparently the last number which is filled in is -0.807566, which does not appear to me to have any special significance. Both lower and higher numbers were filled in before.
Terminal output.txt (22.4 KB)