Hello Rooters
I have a root file and I want to read the leaf values and show them on the screen. This is a screenshot of my tree:
could anyone give a hint?
Hello Rooters
I have a root file and I want to read the leaf values and show them on the screen. This is a screenshot of my tree:
could anyone give a hint?
Hi,
clicking on the name of a leaf shows its values in a histogram, is that what you are looking for?
To print out all the values, you can open the ROOT terminal and use TTree::Scan
(see here).
Cheers,
Enrico
Thanks. I know, but I want another way to do this, because I want then choose some of the values.
See @Wile_E_Coyote’s suggestion for one way to programmatically loop over TTree data. Here some other ways to loop over TTree data are described.
Cheers,
Enrico
Thank you very much.
Hello again
I have a branch called Particle and in that branch there is a leaf called Particle.spin. I want to make a constraint on the value of the leaf to select some special events. I use this condition:
if(Particle.Spin== 1)
but I get this error:
Error: Symbol Particle is not defined in current scope (tmpfile)(7)
Error: Failed to evaluate Particle.Spin
what is wrong with symbol Particle?
Hi,
I guess you never declared a variable called Particle
.
Please check the links we shared and the TTree tutorials for actual code that you can use as a starting point.
Cheers,
Enrico
what do you mean by declaring variable Particle?
In both C++ and python you have to declare/define a variable before using it. For example,
int x = 42;
if (x == 1) {
...
}
If the definition of x
in the first line was not present, you would probably get a similar error saying Symbol x is not defined in current scope
. In other words there is no object called Particle
in your program. You have to define it (as a variable that TTree fills with the corresponding branch values) before you use it. For examples of how to define variables that are filled with TTree branch/leaf values, and how to tell TTree to actually fill those variables with values, see all the resources we linked.
Cheers,
Enrico
Thank you very much.
I am having the same problem as @pure is having. Can anyone please send a sample root file and a code for that?