Home | News | Documentation | Download

Segmentation fault with TMVA in ROOT 6.13


#1

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)


#2

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


#3

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.


#4

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.)


#5

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


#6

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


#7

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


#8

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

Cheers,
Kim


#9

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


#10

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


#11

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)