Dear Experts,
We are trying to make a class that owns TVectorD, TMatrixD, std::vector, std::vector and as soon as we try to access these obejct in member function we hit SegFault or similar problem. It seems that the size of the object is not known.
What is the proper way of using these class as member?
You can find a minimal example below:
HEADER FILE
#ifndef Test_HH_
#define Test_HH_
#include "TVectorD.h"
class Test
{
public:
Test();
void Print();
private:
TVectorD fV;
protected:
};
#endif//~Test_HH_
.CC FILE
#include "Test.hh"
#include <iostream>
//###### Constructor ######
Test::Test()
{
std::cout<<"file: "<<__FILE__<<" at line: "<<__LINE__<<std::endl;
fV = TVectorD(5);
fV.Print();
std::cout<<"file: "<<__FILE__<<" at line: "<<__LINE__<<std::endl;
fV(0) = 10;
std::cout<<"file: "<<__FILE__<<" at line: "<<__LINE__<<std::endl;
Print();
}
void Test::Print()
{
fV.Print();
std::cout<<"file: "<<__FILE__<<" at line: "<<__LINE__<<" "<< fV(0)<<std::endl;
}
And when we simply create a Test object in a main file we get:
ile: /astro/users/lpetit/Analysis/toybeamline/src/Test.cc at line: 7
Error in <UnknownClass::operator=(const TVectorT<Element> &)>: vectors not compatible
Vector (0) is as follows
| 1 |
------------------
file: /astro/users/lpetit/Analysis/toybeamline/src/Test.cc at line: 10
Error in <TVectorT<double>::operator()>: Request index(0) outside vector range of 0 - 0
file: /astro/users/lpetit/Analysis/toybeamline/src/Test.cc at line: 12
Vector (0) is as follows
| 1 |
------------------
Error in <TVectorT<double>::operator()>: Request index(0) outside vector range of 0 - 0
file: /astro/users/lpetit/Analysis/toybeamline/src/Test.cc at line: 19 10
Please read tips for efficient and successful posting and posting code
ROOT Version: v6.20.04
Platform: SL7
Compiler: gcc4.8.5