# RDataFrame multithreading loses events

**URL:** <https://root-forum.cern.ch/t/rdataframe-multithreading-loses-events/49338>\
**Category:** ROOT\
**Tags:** python\
**Created:** [March 24, 2022, 9:08am UTC](https://root-forum.cern.ch/t/rdataframe-multithreading-loses-events/49338 "2022-03-24T09:08:55Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![avilla](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@avilla](https://root-forum.cern.ch/u/avilla)\
**Post date:** [March 24, 2022, 1:11pm UTC](https://root-forum.cern.ch/t/rdataframe-multithreading-loses-events/49338/8 "2022-03-24T13:11:23Z")

</div>

I am following the instructions from this [past topic](https://root-forum.cern.ch/t/rdataframe-and-tmva-in-pyroot/38930/3), I paste below the relevant part of my code:

```python
ROOT.gInterpreter.ProcessLine(f'''                                                                                                                                                            
TMVA::Experimental::RReader BDT1("{training_dir}/BDT1/weights/BDT1_{cuts}_BDT1.weights.xml");                                                                                                 
TMVA::Experimental::RReader BDT2("{training_dir}/BDT2/weights/BDT2_{cuts}_BDT2.weights.xml");                                                                                                 
TMVA::Experimental::RReader BDT3("{training_dir}/BDT3/weights/BDT3_{cuts}_BDT3.weights.xml");                                                                                                 
computeBDT1 = TMVA::Experimental::Compute<13, float>(BDT1);                                                                                                                                   
computeBDT2 = TMVA::Experimental::Compute<13, float>(BDT2);                                                                                                                                   
computeBDT3 = TMVA::Experimental::Compute<13, float>(BDT3);                                                                                                                                   
''')
df = df.Define('BDT1v', ROOT.computeBDT1, ROOT.BDT1.GetVariableNames())
df = df.Define('BDT2v', ROOT.computeBDT2, ROOT.BDT2.GetVariableNames())
df = df.Define('BDT3v', ROOT.computeBDT3, ROOT.BDT3.GetVariableNames())
df = df.Define('BDT1', 'BDT1v[0]')
df = df.Define('BDT2', 'BDT2v[0]')
df = df.Define('BDT3', 'BDT3v[0]')
df = df.Define('id1', 'idBDT==1')
df = df.Define('id2', 'idBDT==2')
df = df.Define('id3', 'idBDT==3')
df = df.Define('BDT', 'id1*BDT3 + id2*BDT1 + id3*BDT2')
df = df.Filter('BDT > -0.2', 'BDT')

```

What I see is that when running with multithreading the efficiency of the `BDT` cut increases, meaning that the script processes some events more than once.  
Can you point me to the available thread-safe variants of the BDT classifier?  
Is it possible to use it to read already existing weight files or should I rerun the training with this new model?  
Thanks

Andrea

---

_[View the full topic](https://root-forum.cern.ch/t/rdataframe-multithreading-loses-events/49338)._
