Basically I have what appears in the screenshot attached and I want to change the order. I.e the E to be in second instead of nfsp. And are leafs not branches sorry for the confusion
And if this is too messy I have the option also to create a restructured csv file instead, which I also have no idea how to do it.
Well, AFAIK, the leaves are not āorderedā. I think they keep the order of when they have been created. What is the output of tree->Print() in the ROOT prompt?
Thank you a lot, hope @pcanal will help.
I want to run a simulation and the tool I want to use only uses the info with specific order. I.e first the event then the energy, then the position etc
But then canāt you change the order in the analysis code (reading the tree)? One can access the tree data in a random order. I.e. if you ask first energy and then position is the same than first position and then energy. The order doesnāt matter
Yes I read it. Thank you for the answer.
āand that the order of the names has to reflect the order of the branches as listed above to allow for correct assignmentā this is in the documentation of the framework I want to import the root file, and the branches above are in different order from my root file
I want to use the deposition reader from allpix. And in the root tree is written:
" ROOT Trees
Data in ROOT trees are interpreted as follows. The tree with name tree_name is opened from the provided ROOT file, and information of energy deposits is read from its individual branches. By default the expected branch names and types are:
event (integer): Branch for the event number.
energy (double): Branch for the energy deposition information.
time (double): Branch for the time information when the energy deposition took place, calculated from the start of the event.
position.x (double): Leaf of the branch for the x position of the energy deposit in global coordinates of the setup.
position.y (double): Leaf of the branch for the y position of the energy deposit in global coordinates of the setup.
position.z (double): Leaf of the branch for the z position of the energy deposit in global coordinates of the setup.
detector (char array): Branch for the detector or volume name in which the energy was deposited.
pdg_code (integer): Branch for the PDG code particle id if the Monte Carlo particle producing this energy deposition.
track_id (integer): Branch for the track id of the current Monte Carlo particle.
parent_id (integer): Branch for the id of the parent Monte Carlo particle which created the current one.
Entries are read from all branches synchronously and accumulated in the same event until the event id read from the event branch changes.
By default, the event numbers need to be sorted with ascending order. This can be disabled by setting require_sequential_events to false. This is useful when running simulations in mutli-threading mode and merging datasets in the end. Currently only supported in ROOT files.
If the parameters assign_timestamps or create_mcparticles are set to false, no attempt is made in reading the respective branches, independently whether they are present or not.
Different branch names can be configured using the branch_names parameter. It should be noted that new names have to be provided for all branches, i.e. ten names, and that the order of the names has to reflect the order of the branches as listed above to allow for correct assignment. If assign_timestamps or create_mcparticles are set to false, their branch names (time and track_id, parent_id, respectively) should be omitted from the branch name list. Individual leafs of branches can be assigned using the dot notation, e.g. energy.Edep to access a leaf of the branch energy to retrieve the energy deposit information."
I guessed it was easier to change the root file rather than to change the source code of the program.
Also the root file was created by default from the program GENIE and it was given to me I cannot produce it differently even if I wanted
I think you need to ask Allpix and/or GENIE people.
They may know how to read GENIE files in Allpix directly, or they may have some GENIE -> Allpix converter.
Thank you a lot for your answers. Unfortunately they do not. I asked them and they said that the way to do it is the deposition reader. I also asked geant people, but I got no answer (since allpix uses geant and I thought I could import the root file from initial macro from geant).
The way I read this, the comment is NOT about the order of the branches in the TTree but instead in the order of ābranch nameā in a string passed to the referred to function to enact an aliasing. So I assumed that there need to be a call like: