Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integer support to TVectorT #8517

Closed
ynikitenko opened this issue Jun 23, 2021 · 5 comments
Closed

Add integer support to TVectorT #8517

ynikitenko opened this issue Jun 23, 2021 · 5 comments

Comments

@ynikitenko
Copy link

Is your feature request related to a problem? Please describe.

I'd like to store a vector of integers in a TFile. Rene Brun suggested using TVectorD for doubles, but I'd like to store integers (to store them in the vector of doubles is possible, but less convenient).

TVectorT has support only for floats and doubles. As of 2011, it doesn't support integers.
But I think it would be nice to add that support.

When I try to use TVectorT<int> in ROOT 6.24/00, ld gives an error:

undefined reference to `TVectorT::TVectorT(int)'

Describe the solution you'd like

Add support for TVectorT<int> and a TVectorI shortcut (would be easier to use that from Python).

Describe alternatives you've considered

@pcanal proposed such a code,

struct VectorWrapper : public TObject {
    std::vector<int> fContent;
    ClassDef(VectorWrapper, 2);
};

and to generate, compile and link a dictionary for that. However, it would take much more time than to use a ready class.

@pcanal
Copy link
Member

pcanal commented Jun 23, 2021

You can now just use std::vector<int> directly:

std::vector<int> v;
...
f->WriteObject(&v, "somename");

For quite a while now, inheriting from TObject is no longer a requirement for storing an object in a TFile

Cheers,
Philippe.

@ynikitenko
Copy link
Author

Hi Philippe, thanks for the info!

I'll try that. It's a pity that I couldn't find a more recent answer to that question during the search.
Is there a recent way to write one value to a ROOT file, e.g. a double?

Cheers,
Yaroslav

@pcanal
Copy link
Member

pcanal commented Jun 23, 2021

For numerical type, you would use TParameter<double> (i.e. you still need a class for data stored directly in a TFile/TDirectory. You do not need an object if the data is stored in a TTree).

@ynikitenko
Copy link
Author

Thanks, Philippe. I added that information to the old thread on the forum. I also found what you were saying in the manual (so it is present somewhere in the documentation, though I usually read the reference guide).
About my initial feature request: I think this is a continuous wish of users to have a vector for ints (and other types) when you have a vector for doubles. So it's up to you whether you add this support or not (me personally no longer need that).

@dpiparo
Copy link
Member

dpiparo commented Feb 3, 2024

Closing since the original need has been clarified and addressed with the regular IO capabilities.

@dpiparo dpiparo closed this as completed Feb 3, 2024
@dpiparo dpiparo added this to Issues in Fixed in 6.32.00 via automation Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

5 participants