Problem with t->MakeClass when using vector/Lorentz

Dear experts,

  • I made a tree as usual with “MakeClass” with root version 6 but this time I stored vector, matrix and Lorentz in the tree, and the compilation (using gcc) gave me several error message [1] so I wonder what is wrong. Without vector, matrix and Lorentz it used to compile.
  • I posted 3 files. The make, and the root file that I used to create the class are here:
    calpas.web.cern.ch/calpas/Makefile
    calpas.web.cern.ch/calpas/output.root
    Do you see what is wrong?
    Regards

[1]
In file included from hto2taus.C:2:0:
hto2taus.h:29:33: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_int’
const Int_t kMaxvector_int = 1;
^
hto2taus.h:28:33: note: previous declaration ‘const Int_t hto2taus::kMaxvector_int’
const Int_t kMaxvector_int = 1;
^
hto2taus.h:31:36: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:26:36: note: previous declaration ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:32:36: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:26:36: note: previous declaration ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:33:36: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:26:36: note: previous declaration ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:35:34: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_bool’
const Int_t kMaxvector_bool = 1;
^
hto2taus.h:34:34: note: previous declaration ‘const Int_t hto2taus::kMaxvector_bool’
const Int_t kMaxvector_bool = 1;
^
hto2taus.h:37:33: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_int’
const Int_t kMaxvector_int = 1;
^
hto2taus.h:28:33: note: previous declaration ‘const Int_t hto2taus::kMaxvector_int’
const Int_t kMaxvector_int = 1;
^
hto2taus.h:38:33: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_int’
const Int_t kMaxvector_int = 1;
^
hto2taus.h:28:33: note: previous declaration ‘const Int_t hto2taus::kMaxvector_int’
const Int_t kMaxvector_int = 1;
^
hto2taus.h:39:36: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:26:36: note: previous declaration ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:40:36: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:26:36: note: previous declaration ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;
^
hto2taus.h:41:36: error: redeclaration of ‘const Int_t hto2taus::kMaxvector_double’
const Int_t kMaxvector_double = 1;

hto2taus.h (15.1 KB)
hto2taus.C (1.41 KB)
main.cc (2.17 KB)

Try to comment out the offending lines (i.e. all with “error: redeclaration of”).

Dear Pepe,
Sure, but is it normal that it creates a buggy class?
Regards

Dear,
I removed the double lines and the code compiled. As I’m still suspicious, I wonder if I fill properly the tree. Can you please confirm that [1] is correct? I have a doubt for the matrix and the vector part.
Regards

[1]
void code{
int evt;
vector vmu_p4;
vector vmu_genmatch;
TMatrixD metCov[2][2];


hto2taus = new TTree(“hto2taus”, “hto2taus”);
hto2taus->Branch(“evt”, &evt, “evt/I”);
hto2taus->Branch(“vmu_p4”, &vmu_p4 “vector”);
hto2taus->Branch(“vmu_genmatch”, &vmu_genmatch, “vector”);
hto2taus->Branch(“mcovmet”, “TMatrixD”, &metCov);

}

Dear,
does anyone have an idea if this is correct?
Regards

Hi,

TMatrixD metCov[2][2]; ... hto2taus->Branch("mcovmet", "TMatrixD", &metCov);

Will only store one TMatrixD (instead of 4). If I remember correctly there is no easy way to request the storing of a C style array of objects as a top level branch (It is automatic if the array is a member of a class that has a dictionary and an object of that class is being stored as a top level object).

Also you can simplify the others with:

vector<double> vmu_p4;
vector<int> vmu_genmatch;

...
hto2taus->Branch("evt", &evt);
hto2taus->Branch("vmu_p4", &vmu_p4;
hto2taus->Branch("vmu_genmatch", &vmu_genmatch);

Cheers,
Philippe.

Dear pcanal,
ok, thank you for your answer.
Regards