ttree | C # implementation of a T-Tree data structure | Dataset library
kandi X-RAY | ttree Summary
kandi X-RAY | ttree Summary
C# implementation of a T-Tree data structure
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ttree
ttree Key Features
ttree Examples and Code Snippets
Community Discussions
Trending Discussions on ttree
QUESTION
I was trying to calculate the average of a ternary tree. It seems not possible to finish it inside one function. Is there any way to solve this question, or it's necessary to use two functions? Thanks.
...ANSWER
Answered 2021-Jun-05 at 12:01In order to compute an average value, you have to perform a single division at the very end of the process, something like (allSum / allCount)
. As the division cannot be part of the recursive tree traversal process, it seems difficult to achieve what you want within a single function.
Let's start by providing a little fix for your code. It is unclear whether your auxiliary treeAverage'
function returns a pair or a single numeric value. We can rewrite the whole thing like this, where unambiguously it returns a pair:
QUESTION
I have an HDF5 with 100 "events". Each event contains variable, but roughly 180 groups called "traces", and each trace has inside 6 datasets which are arrays of 32 bit floats, each ~1000 cells long (this carries slightly from event to event, but remains constant inside an event). The file was generated with default h5py settings (so no chunking or compression unless h5py does it on its own).
The readout is not fast. It is ~6 times slower than readout of the same data from CERN ROOT TTrees. I know that HDF5 is far from the fastest formats on the market, But I would be grateful, if you could tell me, where the speed is lost.
To read the arrays in traces I do:
...ANSWER
Answered 2021-Apr-25 at 16:45There are a lot of HDF5 I/O issues to consider. I will try to cover each.
From my tests, time spent doing I/O is primarily a function of the number of reads/writes and not how much data (in MB) you read/write. Read this SO post for more details:
pytables writes much faster than h5py. Why? Note: it shows I/O performance for a fixed amount of data with different I/O write sizes for both h5py and PyTables. Based on this, it makes sense that most of the time is spent in the last line -- that's where you are reading the data from disk to memory as NumPy arrays (v1, v2, v3, v4, v5, v6
).
Regarding your questions:
- There's a reason there is no difference between reading
d2['SimSignal_X'][0]
andd2['SimSignal_X'][:]
. Both read the entire dataset into memory (all ~1000 dataset values). If you only want to read a slice of the data, you need to use slice notation. For example,d2['SimSignal_X'][0:100]
only reads the first 100 values (assumesd2['SimSignal_X']
only has a single axis --shape=(1000,)
). Note; reading a slice will reduce required memory, but won't improve I/O read time. (In fact, reading slices will probably increase read time.) - I am not familiar with CERN ROOT, so can't comment about performance of h5py vs ROOT. If you want to use Python, here are several things to consider:
- You are reading the HDF5 data into memory (as a NumPy array). You don't have to do that. Instead of creating arrays, you can create h5py dataset objects. This reduces the I/O initially. Then you use the objects "as-if" they are np.arrays. The only change is your last line of code -- like this:
v1, v2, v3, v4, v5, v6 = d2['SimSignal_X'], d2['SimSignal_Y'], d2['SimSignal_Z'], d2['SimEfield_X'], d2['SimEfield_Y'], d2['SimEfield_Z']
. Note how the slice notation is not used ([0]
or[:]
). - I have found PyTables to be faster than h5py. Your code can be easily converted to read with PyTables.
- HDF5 can use "chunking" to improve I/O performance. You did not say if you are using this. It might help (hard to say since your datasets aren't very large). You have to define this when you create the HDF5 file, so might not be useful in your case.
- Also you did not say if a compression filter was used when the data was written. This reduces the on-disk file size, but has the side effect of reducing I/O performance (increasing read times). If you don't know, check to see if compression was enabled at file creation.
- You are reading the HDF5 data into memory (as a NumPy array). You don't have to do that. Instead of creating arrays, you can create h5py dataset objects. This reduces the I/O initially. Then you use the objects "as-if" they are np.arrays. The only change is your last line of code -- like this:
QUESTION
I am trying to read a branch of TH1D objects in uproot4. A sample rootfile can be created with:
...ANSWER
Answered 2021-Mar-05 at 19:33You're not doing something wrong: it's a NotImplementedError because memberwise serialization has not been implemented in Uproot. That's Issue #38, which has been getting a lot of attention recently.
Other people finding this question, years later: check to see if Issue #38 has been resolved.
QUESTION
When I acess a root file and extract the data I want like in following example:
...ANSWER
Answered 2021-Jan-08 at 06:12This is actually a question about Uproot. In this line:
QUESTION
In uproot 3 documentation there is information, that uproot can write only branches containing 1 value per entry. On the other hand, I can see some topics on uproot Github regarding writing jagged arrays, etc. So, I would like to make sure: can uproot write TBranches containing arrays to a TTree? If so, is it documented anywhere?
Thanks!
...ANSWER
Answered 2020-Dec-19 at 15:00This will be better documented when it's ported to Uproot 4, but the best documentation we have on writing jagged arrays in Uproot 3 right now is the pull request and associated issues (all linked to each other):
https://github.com/scikit-hep/uproot3/pull/477
Here is an example from the tests:
QUESTION
these are the structures
...ANSWER
Answered 2020-Nov-03 at 19:00why the second statement works, meanwhile the first causes an error. If the & operator works on variables
Because the &
operator works on variables, and more generally on lvalue expressions, which designate objects, which have addresses. It does not work on rvalue expressions, which represent values without (necessarily) any persistent storage or address -- for example, 12
or x + 2
. Function return values are rvalues.
QUESTION
I am trying to use uproot to add a branch to an existing TTree that I have in a .root file. Is it possible to this with uproot?
...ANSWER
Answered 2020-Sep-23 at 17:19No, this is not possible.
The first difficulty is opening an arbitrary ROOT file and adding any content to it in a robust way (i.e. the result can be read back by ROOT and yet more can be added by ROOT, without segfaults). If you want the long story, it's in scikit-hep/uproot#381, but the short story is that if Uproot makes the file itself, Uproot controls the initial conditions and can put the file into a known good state. We (developers of Uproot) can know some good states without understanding 100% of the state space. But if we want to accept files from ROOT, modify them, and give them back to ROOT, then we have to understand all the possible states that its filesystem-inside-a-file defragmentation algorithm can get into before we can trust our modifications of those states to stay within the space of good states. Understanding that state space would require a lot of study because (1) it's a whole filesystem that can reclaim free space and everything, and (2) there isn't a specification for this aspect of the format. It's defined by what the C++ code does.
The second difficulty is adding a TBranch to an existing TTree. That's not implemented, but much more manageable: we'd just make a new copy of the TTree metadata with the extra TBranch and link the new metadata to the old TBaskets (data). The main difficulty is adding any object to a preexisting ROOT file.
QUESTION
Apparently, CERN's "Root" software is compatible (as of version 6.12) with C++17. However, I have been completely unable to get this to work with the newest version (6.20) and all previous questions I found on this topic are from a few years ago.
Does anyone with Root experience know if there is a particular compiler option to get it to work with C++17?
Examples of errors I get when trying to compile a trivial "Hello world" program:
- The following is (I think) due to the "TFile.h" header implicitly loading "TString.h":
ANSWER
Answered 2020-Jul-01 at 08:12You can use root only with the c++ standard with which your root version has been compiled. This is a known inconvenience and I believe the developers would be happy if/when they get this sorted out. The build configuration root-config --cflags
should set the appropriate c++ standard. This might very well be c++17 (it is for me)
QUESTION
I know that there is a solution for the similar question: How to get uproot.iterate() output like the root_numpy root2array() output fast But as I understand it is suitable for the flat ROOT TTrees only. I want to have generalized solution for:
- fixed-size dimension but nested data like particle momentum (px, py, pz) which are represented in the ROOT TTree as the
vector
- arbitrary-size dimension data
All my attempts to apply asjagged
for it failed. Is it possible to avoid jaggedarray
for case (1)?
ANSWER
Answered 2020-Mar-14 at 13:12If the data are fixed-size but stored as vector
, then they're treated as though they were not fixed-size. Uproot would always read them as jagged arrays, and therefore the asarray
method described in the other question is unavailable.
That said, if you have more knowledge than your file's metadata and are willing to try an unsupported hack, you can force the interpretation of your vector
to always have three elements. Here's an example—first, we need a suitable ROOT file:
QUESTION
I am working with C++ and ROOT. I created a simple tree in a separate .C file/code (called tree_ex1.c) and I am trying to get the contents of that tree and plot a histogram in another .C file (called tree_ex2.c). I expect that with using the tree_ex1.c if I plot the histogram of one of the variables in the tree it will be the same histogram that I would plot with my second .C file, tree_ex2.c
In my tree_ex1.c file, I created a simple tree and I plotted the histogram of one of the tree's branches. I am able to get a histogram from the tree_ex1.c. Then, in my tree_ex2.c file, I am trying to call the contents of the my tree in the first file to plot the same variable. However, my histogram from the tree_ex2.c does not look the same.
Below is my attempt. I get a plot that basically looks empty. The number of entries is 10000 but the mean and standard deviation is 0.
...ANSWER
Answered 2020-Mar-02 at 10:12I believe you're mistaking Branch
for SetBranchAddress
in the code you posted. The documentation of Branch says (e.g. https://root.cern/doc/master/classTTree.html#ab47499eeb7793160b20fa950f4de716a) "Add a new branch". While you want to read from an existing branch. https://root.cern/doc/master/classTTree.html#a39b867210e4a77ef44917fd5e7898a1d.
So I think if you replace
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ttree
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page