Skip to content

Reading croot's TTrees with standard ROOT macros  #11

@ebusato

Description

@ebusato

Hi Seb,

I created a TTree with croot using the following struct:

type ROOTDataMult2 struct {
Run uint32
Evt uint32
IChanAbs240 [2]uint16
Ampl [2]float64
Charge [2]float64
T20 [2]float64
T30 [2]float64
T80 [2]float64
NoLocMaxRisingFront [2]uint16
SampleTimes [999]float64
Pulse [2][999]float64
}

The TTree is written properly to the TFile and I can draw all these variables using TTree::Draw. This works great ! But now I'd like to implement the event loop myself using a standard ROOT macro. I could not figure out a way to do so. It always seems to fail because of the missing dictionnary for the ROOTDataMult2 object.

Would you have an example ROOT macro that allows looping over TTree with structs inside ?

Alternatively, is it possible to create TTree with croot with simple variables only (ints, floats, ...) and arrays of simple variables, no structs (in order to avoid the "missing dictionnary" issue) ? I tried creating a branch with

_, err = t.tree.Branch("data", &var, bufsiz, 0)

where var is an int, but it fails saying that it expects a struct.

Thanks !
Emmanuel

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions