I created a class called lotsofdata containing arrays of ints and
TLorentzvectors.
For some strange reason, whenever I try to initialize a variable with that
class, the macro exits ROOT directly without any message.
Here is a simplified version of the problem:
#define MAXBGD 40000
#include <fstream> #include <iostream> #include "TLorentzVector.h"
class lotsofdata
{
public:
TLorentzVector PlBg[MAXBGD]; TLorentzVector MinBg[MAXBGD]; int PlBg_PDG[MAXBGD]; int MinBg_PDG[MAXBGD]; int PlBg_mamaPDG[MAXBGD]; int MinBg_mamaPDG[MAXBGD]; public: lotsofdata(void); ~lotsofdata(void); int Save(char* filename); /**< save class as binary */ int Load(char* filename); /**< load class from binary */ //ClassDef(lotsofdata,1); //special for ROOT};
//ClassImp(lotsofdata); //special for ROOT
//constructor
lotsofdata::lotsofdata()
{}
//destructor
lotsofdata::~lotsofdata()
{}
//save class
int lotsofdata::Save(char* filename)
{
cout<<"SAVING AS BINARY"<<endl;
ofstream ofs(filename, ios::binary);
ofs.write((char *)this, sizeof(lotsofdata));
return(0);
}
//load class
int lotsofdata::Load(char* filename)
{
cout<<"LOADING FROM BINARY"<<endl;
ifstream ifs(filename, ios::binary);
// if fstream cannot open file
if ( !ifs )
{
cerr << "WARNING: File could not be opened." << endl; return(1);
ifs.read((char *)this, sizeof(lotsofdata));
return(0);
}
void mystery(void)
{
lotsofdata titi;
}
I compile it with .L mystery.C+ and then run mystery().
If the TLorentzVector lines are commented, I stay inside ROOT, if not, it exits without any message (even if I add cout or printf before initializing titi).
What's the problem with including TLorentzVectors in a class and how can I solve it? Received on Sat Sep 01 2007 - 19:12:30 CEST
This archive was generated by hypermail 2.2.0 : Sun Sep 02 2007 - 17:50:01 CEST