# Dataloader says tree has 0 events

**URL:** <https://root-forum.cern.ch/t/dataloader-says-tree-has-0-events/47544>\
**Category:** Newbie\
**Tags:** tree, root\
**Created:** [November 5, 2021, 4:02am UTC](https://root-forum.cern.ch/t/dataloader-says-tree-has-0-events/47544 "2021-11-05T04:02:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dan/32/27719_2.png) [@Dan](https://root-forum.cern.ch/u/Dan)\
**Post date:** [November 5, 2021, 4:02am UTC](https://root-forum.cern.ch/t/dataloader-says-tree-has-0-events/47544/1 "2021-11-05T04:02:55Z")

</div>

* * *

_ROOT Version:_ 6.24  
_Platform:_ VSCode  
_Compiler:_ macOS C++ Compiler

* * *

Hi,

I’m trying to practice the basics of Root. I followed along with the TMVAClassification tutorial, and I got that to work. Now, I’m trying to use my own data to create a ML model. But I keep getting this error:

> DataSetInfo : [dataset] : Added class “Signal”  
> : Add Tree signalTree of type Signal with 0 events  
> **\<FATAL\> : Encountered empty TTree or TChain of class Signal**

This is confusing me because this is the code responsible:

```auto
auto fileName = "./student-mat-signal.csv";
auto rdf = ROOT::RDF::MakeCsvDataFrame(fileName, true, ',');
TTree *signalTree = new TTree("signalTree","Signals");
rdf.Snapshot("signalTree", "signalMathScores.root");
.
.
.
TMVA::DataLoader *dataloader=new TMVA::DataLoader("dataset");

dataloader->AddVariable( "G1" );
dataloader->AddVariable( "G3" );

Double_t signalWeight = 1.0;
dataloader->AddSignalTree(signalTree, signalWeight );

```

The signalMathScores.root file that gets created isn’t empty, so I don’t understand why the dataloader says there’s 0 events. Any ideas on what the problem could be?

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [November 5, 2021, 9:27am UTC](https://root-forum.cern.ch/t/dataloader-says-tree-has-0-events/47544/2 "2021-11-05T09:27:16Z")

</div>

Hello,

I think the problem is here:

```auto
TTree *signalTree = new TTree("signalTree","Signals");
rdf.Snapshot("signalTree", "signalMathScores.root");

```

You are creating an in-memory tree and also snapshotting the contents of the CSV file into a tree in a ROOT file. But I guess what you want TMVA to use is the tree you snapshot.

So what you can do here is remove the line `TTree *signalTree = new TTree("signalTree","Signals");` and instead, after the snapshot, you open the `signalMathScores.root` file and you read the tree from that file. See [this link](https://root.cern/manual/root_files/) for information on how to read objects stored in ROOT files.

---

<div class="post-metadata">

**Author:** ![Dan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dan/32/27719_2.png) [@Dan](https://root-forum.cern.ch/u/Dan)\
**Post date:** [November 5, 2021, 4:12pm UTC](https://root-forum.cern.ch/t/dataloader-says-tree-has-0-events/47544/3 "2021-11-05T16:12:37Z")

</div>

That worked! Thank you!
