Re: disabling TNamed characteristics of TNamed inherited objects

From: William J Deninger (deninger@uiuc.edu)
Date: Thu Apr 09 1998 - 23:19:40 MEST


-----Original Message-----
From: Rene Brun <Rene.Brun@cern.ch>
To: William J Deninger <deninger@uiuc.edu>
Cc: roottalk <roottalk@hpsalo.cern.ch>
Date: Monday, April 06, 1998 1:37 AM
Subject: Re: disabling TNamed characteristics of TNamed inherited objects
>
>Your TCalo class should have a data member being a list (TList,
>TObjArray,..) of TWfdPulse objects. If calo is an instance of TCalo,
>then
>    calo->Write();
>will write one single key for this TCalo object. The other objects
>inside calo will not be visible when you list the directory.
>
>Rene Brun
>

Rene,
I don't believe that this method works.  It was tried with both TObjArray
and TClonesArray.  The following does produces a listing of objects in the
TFile directory. Would you have any other suggestions?  And all you help is
greatly appreciated!  --William J Deninger

//__________________________________________________
CINT/ROOT C/C++ Interpreter version 5.13.45, Mar 17 1998
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] TFile *f = new TFile("f:/test;3.root","recreate");
root [1] TDriftSpectrumInfo *d1 = new TDriftSpectrumInfo("d1");
root [2] Int_t i;
root [3] for (i=1; i<3; i++)  d1->Add(i);
root [4] d1->Build();
root [5] f.ls()
TFile**         f:/test;3.root
 TFile*         f:/test;3.root
  OBJ: TDriftSpectrumInfo       d1      d1 : 0
  OBJ: TDriftSpectrum   drift1  drift1 : 0
  OBJ: TDriftSpectrum   drift2  drift2 : 0
  OBJ: TDriftSpectrum   drift3  drift3 : 0root [6] d1->Write()
root [7] f->Write()
TFile Writing Name=f:/test;3.root Title=
root [8] f.Close()
root [9]

CINT/ROOT C/C++ Interpreter version 5.13.45, Mar 17 1998
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] TFile *f = new TFile("f:/test;3.root");
root [1] f.ls()
TFile**         f:/test;3.root
 TFile*         f:/test;3.root
  KEY: TDriftSpectrumInfo       d1;2    d1
  KEY: TDriftSpectrumInfo       d1;1    d1
  KEY: TDriftSpectrum   drift1;1        drift1
  KEY: TDriftSpectrum   drift2;1        drift2
  KEY: TDriftSpectrum   drift3;1        drift3
  root [2]

//__________________________________________________
class TDriftSpectrum  : public TH1F
{
public:
 TDriftSpectrum();
 TDriftSpectrum(Text_t* title);
 virtual ~TDriftSpectrum();

 ClassDef(TDriftSpectrum,1)
};

//__________________________________________________
class TDriftSpectrumInfo  : public TDriftSpectrum
{
public:
 TDriftSpectrumInfo();
 TDriftSpectrumInfo(Text_t *tname);
 virtual ~TDriftSpectrumInfo();

 TDriftSpectrum * Add(Int_t index);
 TDriftSpectrum * Add(Text_t *title);

 TObjArray *drift;

protected:
 ClassDef(TDriftSpectrumInfo,1)
};

TDriftSpectrumInfo::TDriftSpectrumInfo(Text_t *tname) :
TDriftSpectrum(tname)
{
 drift = new TObjArray(500);
 drift->Clear();
 size = 0;
}

TDriftSpectrum * TDriftSpectrumInfo::Add(Int_t index)
{
 Char_t title[256];
 sprintf(title,"drift%i",index);
 return Add(title);
}

TDriftSpectrum * TDriftSpectrumInfo::Add(Text_t *title)
{
 if ((*drift)[size]) delete (*drift)[size];

 (*drift)[size] = new TDriftSpectrum(title);
 return (TDriftSpectrum *) (*drift)[size++];
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET