storing histogramms

Florian Schopper (fls@mpe.mpg.de)
Wed, 27 Jan 1999 12:14:41 +0100 (MET)


Dear Rooters,

we encountered a probably simple problem, which we couldn't find in
the roottalk list, though.

When we allocate Histogramms with new in the constructor of MChip,
and store the MChip class into a root-file,
we get a segmentation violation error when accessing the restored
histogramms.

Is it necessary to write a default constructor for MChip which allocates
the histogramms again?

thanks,
Florian

class MChip : public TObject
{
private:

TH1F *CommonModeHist;
TH1F *NHitHist;

public:
MChip(){}

MChip(Int_t nChannel, TString Appelation );

ClassDef(MChip,1)
} ;

The Constructor looks something like that:

MChip::MChip(Int_t N, TString Appelation)
{
CommonModeHist = new TH1F("CommonMode","CommonMode",50,-25.0,25.0);
CommonModeHist->SetDirectory(0);
NHitHist = new TH1F("NHits","Number of Hits",10,0,10);
HitHist->SetDirectory(0);

}

----------------------------------------------------------------------
Florian Schopper office: Max-Plank-Institut fuer
extraterrestrische physik
Ludwig-Merk str. 3 Postfach 1603
80805 Muenchen Giessenbachstr.
phone: 49/89/3226157 Garching bei Muenchen

phone: 49/89/3299 3625
fax: 49/89/3299 3569
e-mail: fls@mpe-garching.mpg.de
http://home.cern.ch/~fschoppe
----------------------------------------------------------------------
-----------------------------------------------------------------------