Duplicate variables definition in header created by MakeClass


_ROOT Version: 6.14/06cosmictree.h (108.8 KB)

create-class.C (343 Bytes)

_Platform: Linux, ubuntu 16.04


I used MakeClass before but now I would like to look inside a root file and I created “cosmictree.h” and “cosmictree.C” using makeClass (cosmictree.h is here attached with the create-class.C root macro, sorry I did not attach cosmictree.C as I am allowed for two attachment only as new user). When trying too link “cosmictree.C” in root using “.L cosmictree.C” it gives duplicate definition errors like: (is like the root file is created with name spaces having same name of variables in different name spaces)


.L cosmictree.C
/home/ayad/research/belle2/analysis/cosmic/vxdcosmicfall2018/useroot/cosmictree.h:26:27: error: duplicate member ‘kMaxm_elements’
static constexpr Int_t kMaxm_elements = 1;
^
/home/ayad/research/belle2/analysis/cosmic/vxdcosmicfall2018/useroot/cosmictree.h:25:27: note: previous declaration is here
static constexpr Int_t kMaxm_elements = 1;
^
/home/ayad/research/belle2/analysis/cosmic/vxdcosmicfall2018/useroot/cosmictree.h:27:27: error: duplicate member ‘kMaxm_elements’
static constexpr Int_t kMaxm_elements = 1;
^
/home/ayad/research/belle2/analysis/cosmic/vxdcosmicfall2018/useroot/cosmictree.h:25:27: note: previous declaration is here
static constexpr Int_t kMaxm_elements = 1;
^
/home/ayad/research/belle2/analysis/cosmic/vxdcosmicfall2018/useroot/cosmictree.h:28:27: error: duplicate member ‘kMaxm_elements’
static constexpr Int_t kMaxm_elements = 1;


Thank you, Rachid

I’m afraid you will need to recreate your ROOT file and define your tree master branches in a different way. For all of them, either modify the “branchname” adding a “.” (dot) character in the end or set the “splitlevel = 0”.

If you do not want to (or cannot) regenerate your tree, I guess (and @pcanal would need to confirm it) the MakeProxy, the TTreeReader (plus the new MakeSelector which uses it) and the RDataFrame should be able to deal with what you have now.

Thank for your fast answer.

I cannot regenerate the tree because it is not my task. I should use the root file as it is.
I will read about what you suggested but if someone has an example of it, it will be with great help as I am currently busy.
The other solution is the hard handy one (hope the number of branches is not big enough to let it impossible) is to change constants, variables, and branches name by hand.

I don’t think it is a good idea. Your tree has multiple branches which share the same names (and that’s why you get them in the MakeClass generated analysis skeleton).

I think you should talk to your colleagues / supervisor about how they deal with this tree.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.