Hello ROOT and C++ Guru's,
I have some TTrees in some files that contains object of a class
that was inheriting from the CLHEP HepLorentzVector's,
and I want to switch to TLorentzVector but still being abble to
access those data's, so I tryied to customize the streamer of my
new class (inheriting from TLorentzVector) to read the old data's:
Is such a thing doabble ?
Did somebody has tried that before (and succeeded )?
I am accessing these objects,
via a TClonesArray (e.g I have the following definitions:
class TPart : public TLorentzVector { ... }
class TClasEvent : public TObject {
<...>
static TClonesArray *gPart;
<...>
}
And my Tree is based on TClasEvent
I tried the following custom streamer for TPart:
//______________________________________________________________________________
void TPart::Streamer(TBuffer &R__b)
{
// Stream an object of class TPart.
Double_t dx,dy,dz,ee;
cout << " Begin Part streamer " << endl;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion();
if (R__v<2) { // CLHEP HepLorentzVector streamer
cout << " Hep Lorentz Vector streamer " << endl;
TObject::Streamer(R__b);
TObject::Dump();
// TObject::Streamer(R__b);
R__b >> dx;
R__b >> dy;
R__b >> dz;
R__b >> ee;
SetPx(dx);
SetPy(dy);
SetPz(dz);
SetE(ee);
cout << "Part found: " << dx << " _ " << dy << " _ " << dz << " _
" << ee << endl;
TObject::Dump();
// HepLorentzVector::Streamer(R__b);
} else {
cout << " TLorentzVector streamer " << endl;
TLorentzVector::Streamer(R__b);
}
R__b >> id;
R__b >> charge;
R__b >> index;
} else {
R__b.WriteVersion(TPart::IsA());
TLorentzVector::Streamer(R__b);
R__b << id;
R__b << charge;
R__b << index;
}
cout << " End Part streamer " << endl;
}
But this doesn't work, only of the first element
of the TClonesArray is read (and not correctly)
and at the of the TClasEvent streamer, I got a seg fault.
I also try to uncomment the second TObject::streamer()
(because in my naive vision of HepLorentzVector I saw
that the TObject::streamer was called twice, once in
the HepLorentzVector and once for Hep3Vector part of it.
There is obviously something I don't understand in the streamer
manipulation.
thanks for any hints on that matter,
eric
----------------------------------------------------------------
The definition of HepLorentzVector:
class HepLorentzVector : public TObject {
< inline functions..>
private:
Hep3Vector pp;
HepDouble ee;
// The energy component
}
and for Hep3Vector:
class Hep3Vector : public TObject {
< ... inline functions ... >
private:
HepDouble dx;
HepDouble dy;
HepDouble dz;
// The components.
};
And the streamers:
//______________________________________________________________________________
void HepLorentzVector::Streamer(TBuffer &R__b)
{
// Stream an object of class HepLorentzVector.
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(); if (R__v) { }
TObject::Streamer(R__b);
pp.Streamer(R__b);
R__b >> ee;
} else {
R__b.WriteVersion(HepLorentzVector::IsA());
TObject::Streamer(R__b);
pp.Streamer(R__b);
R__b << ee;
}
}
//______________________________________________________________________________
void Hep3Vector::Streamer(TBuffer &R__b)
{
// Stream an object of class Hep3Vector.
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(); if (R__v) { }
TObject::Streamer(R__b);
R__b >> dx;
R__b >> dy;
R__b >> dz;
} else {
R__b.WriteVersion(Hep3Vector::IsA());
TObject::Streamer(R__b);
R__b << dx;
R__b << dy;
R__b << dz;
}
}
--
----- Eric Anciant ------------
DAPNIA/SPhN - Bat 703 - Orme des merisiers
CE-SACLAY - 91191 GIF-SUR-YVETTE Cedex - FRANCE
Office: (33 - 1) 69 08 22 47 fax: (33-1) 69 08 75 84
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET