Hot to add ULong_t to a Tree

Hi,

I am not able to add a 32 bit unsigned long to a Tree. I get this error:

when I checked the root guide for Trees I recognised that there is no special option for ULong_t but only for ULong_t64.

How do I manage to add this data type?
Please help.

BR

ULong_t is not a portable type. It may be 32 or 64 bits. For portability use UInt_t if you have an unsigned 32 bit integer or ULong64_t if you have an unsigned 64 bit integer.

Rene

Thank you. I understand. Is this also a problem if I use an unsigned long in a struct and add it to a Tree? Because I did so and didn’t get an error. Should I nevertheless change it?

BR

If a ULong is found in a class, we store it as a 64 bits number and we read it at the right position, but with truncation to a 32 bits integer in case of a 32 bits machine.

Rene

Thank you again but I have one further question. if I have a struct, like this:

struct { unsigned long header; unsigned long eventcnt; unsigned char trg_time; unsigned char subevents; unsigned char number_apvs; unsigned char number_fadcs; unsigned long fadcmode; unsigned long tlueventnumber; unsigned long spare2; unsigned short fadcdatalength[16]; } save_event_header_;

and add to a Tree, like this:

will it be added correctly?

BR

No, the way you do it will not work, because you are doing wrong assumptions on the variable alignements in the structure. But, the nice thing is that you can simplify your problem by simply doing
outputTree_->Branch(“save_event_header_ttree”,&save_event_header_);
In this case ROOT using the internal structure dictionary will nicely create the branches automatically for each member of the struct.
NB: for this to work you must use 5.26 or newer. With older versions use a class instead of a struct.

Rene

I am using ROOT 5.27/06 but I am compiling with gcc. Do I have to generate dictionaries myself to make this work without the definition of the structure of the struct? Thanks again and I guess again.

BR

Yes you must have a dictionary for the class.

Rene

Could you give me a clue on how to generate the dictionary for the struct save_event_header_ ? Also can I add all my structs, arrays, … to one dictionary and implement it globally, like in main()? I didn’t find any easy comprehensible documentation. Thank you.

BR

See root.cern.ch/drupal/content/how- … dictionary