Hi Dave, The decision to import the CLHEP classes for TVector3 and TLorentzVector was taken at the ROOT FermiLab workshop 18 months ago. The idea was to have the same API between CLHEP and ROOT for these two classes. The import work was done by Peter Malzacher. My guess is that the original design was probably dictated by performance considerations. There are may be other reasons. It would be good if we had some comments from the CLHEP people or/and from Peter on this subject. I have to say that I agree personally with your comments, but before changing anything, I would like to have comments from other users. Rene Brun Dave Casper wrote: > > Hi, > > I was looking through the source for Root's vector classes and would like to > propose a specific improvement. > > These classes (e.g. TVector3) are essentially identical to those in CLHEP. > In my opinion the CLHEP vector classes are almost useless as foundation > classes because nothing is declared as virtual/protected. Not even the > destructor, and every book on class design I've read says that destructors > for base classes should always be virtual. This allows you to delete a > derived object using a pointer to the base object. I've had real problems > using CLHEP's vector classes in my programs, which is a pity since > derivation is the heart and soul of a supposedly standard class library. In > the end I've had to write my own vector classes in order to derive from > them. > > Would it be possible to make TVector3 and TLorentzVector's methods virtual > (at least the destructors) and their data members protected instead of > private, so they are suitable for deriving user classes from? I can't > fathom why CLHEP's vector classes weren't written this way in the first > place. If it's to allow inlining them I think it was a poor decision to > sacrifice the power of subclassing for whatever marginal to non-existent > gains might be achieved. > > Dave > dcasper@uci.edu
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:31 MET