# TTreeReader Error when applying MVA

**URL:** <https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799>\
**Category:** ROOT\
**Tags:** rdataframe, tmva\
**Created:** [June 25, 2025, 10:03am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799 "2025-06-25T10:03:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahuang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@ahuang](https://root-forum.cern.ch/u/ahuang)\
**Post date:** [June 25, 2025, 10:03am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/1 "2025-06-25T10:03:06Z")

</div>

Hello experts,

I’m trying to now apply and save the results of my trained MVA to my ntuples and am currently trying to test this with the current training file. I seem to be running into some sort of issue due to TTreeReaderValueBase::CreateProxy() not being able to read a specific branch which is formatted as a double. Is there a solution to this? I’ve attached the code for both the MVA and application and there is a link to the example ntuple in google drive.

Edit: The code in question which causes the error is the Belle\_e\_tmva\_apply.C

```auto
Error in <TTreeReaderValueBase::CreateProxy()>: The branch weMissM2 __boY4ScleanMask__ cm __sp0__ bc contains data of type double. It cannot be accessed by a TTreeReaderValue<float>
terminate called after throwing an instance of 'std::runtime_error'
  what(): An error was encountered while processing the data. TTreeReader status code is: 6

```

_ROOT Version:_ 6.32.00  
_Platform:_ Linux Red Hat Enterprise Linux 9 v9.6  
_Compiler:_ g++ (GCC) 14.2.0

[Belle\_e\_tmva\_apply.C](https://root-forum.cern.ch/uploads/short-url/uvgAKTSH2cyeNwW4ketLfIksGjc.C) (700 Bytes)  
[Bzptn\_e\_belle\_tmva.C](https://root-forum.cern.ch/uploads/short-url/84JIODkFzR6lD8jK9ZxxpPBX1ou.C) (4.8 KB)

> **[root – Google Drive](https://drive.google.com/drive/folders/1MJGCoONCqVWHv26Q2m6HoTTOSFwAkuV4)**

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [June 25, 2025, 1:15pm UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/2 "2025-06-25T13:15:01Z")

</div>

Hi,  
in your `Bzptn_e_belle_tmva.C` you have

```auto
    dataloader->AddVariable("weMissM2 __boY4ScleanMask__ cm __sp0__ bc", 'F'); // Missing Mass Squared

```

If this is a `double` as the error message suggests, can you maybe treat it at this line as a `double` and not as a `float`?

---

<div class="post-metadata">

**Author:** ![ahuang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@ahuang](https://root-forum.cern.ch/u/ahuang)\
**Post date:** [June 26, 2025, 1:20am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/3 "2025-06-26T01:20:43Z")

</div>

Changing the variable type within the code creating the MVAs does not appear to solve the problem unless I have done so wrong. I take it that changing to ‘D’ should be the correct input for setting as a double?

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [June 26, 2025, 6:22am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/4 "2025-06-26T06:22:27Z")

</div>

Did you change ALL the variables to ‘D’ or just one?

---

<div class="post-metadata">

**Author:** ![ahuang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@ahuang](https://root-forum.cern.ch/u/ahuang)\
**Post date:** [June 26, 2025, 6:41am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/5 "2025-06-26T06:41:28Z")

</div>

The error persists for both where only my “weMissM2\_\_boY4ScleanMask\_\_cm\_\_sp0\_\_bc” variable is set as a double or even with all the variables set as doubles (checking the data types of the variables, they are all doubles).

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [June 26, 2025, 8:49am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/6 "2025-06-26T08:49:34Z")

</div>

Can you explain how to run your files? I tried but I get: Failed to open TMVA XML file TMVAClassification\_Belle\_e\_id.weights.xml

---

<div class="post-metadata">

**Author:** ![ahuang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@ahuang](https://root-forum.cern.ch/u/ahuang)\
**Post date:** [June 26, 2025, 9:07am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/7 "2025-06-26T09:07:05Z")

</div>

The code in question which raises the error is the Belle\_e\_tmva\_apply.C and I’ve attached a version of the xml weight file to the google drive (the weight file was made with the variable set with float typing).

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [June 26, 2025, 9:31am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/8 "2025-06-26T09:31:46Z")

</div>

I can reproduce the bug.

Maybe the problem is TMVA::Experimental::Compute\<7, float\>(e\_id\_model) which should be changed to double, but then there is a TMVA function that does not support this.

So I guess the workaround is to copy your TTree to one with all variables as float?

Maybe @vpadulan or @moneta can comment.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 10, 2025, 9:31am UTC](https://root-forum.cern.ch/t/ttreereader-error-when-applying-mva/63799/9 "2025-07-10T09:31:50Z")

</div>

Closed on July 10, 2025, 9:31am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
