From 6a0488a2c6fb166141261fc0fe734bde1e5b59ba Mon Sep 17 00:00:00 2001 From: Philippe Canal <pcanal@fnal.gov> Date: Wed, 10 Aug 2011 15:46:22 +0000 Subject: [PATCH] Add missing operator= git-svn-id: http://root.cern.ch/svn/root/trunk@40537 27541ba8-7e3a-0410-8455-c3a389f83636 --- test/Event.cxx | 55 +++++++++++++++++++++++++++++++++++++++++++++++- test/Event.h | 2 ++ test/EventMT.cxx | 53 ++++++++++++++++++++++++++++++++++++++++++++++ test/EventMT.h | 2 ++ 4 files changed, 111 insertions(+), 1 deletion(-) diff --git a/test/Event.cxx b/test/Event.cxx index 3222034e0c9..def16822501 100644 --- a/test/Event.cxx +++ b/test/Event.cxx @@ -343,12 +343,65 @@ Track::Track(Float_t random) : TObject(),fTriggerBits(64) fValid = Int_t(0.6+gRandom->Rndm(1)); } +//______________________________________________________________________________ +Track &Track::operator=(const Track &orig) +{ + // Copy a track + + TObject::operator=(orig); + fPx = orig.fPx; + fPy = orig.fPy; + fPz = orig.fPx; + fRandom = orig.fRandom; + fMass2 = orig.fMass2; + fBx = orig.fBx; + fBy = orig.fBy; + fMeanCharge = orig.fMeanCharge; + fXfirst = orig.fXfirst; + fXlast = orig.fXlast; + fYfirst = orig.fYfirst; + fYlast = orig.fYlast; + fZfirst = orig.fZfirst; + fZlast = orig.fZlast; + fCharge = orig.fCharge; + + fVertex[0] = orig.fVertex[0]; + fVertex[1] = orig.fVertex[1]; + fVertex[2] = orig.fVertex[2]; + fNpoint = orig.fNpoint; + if (fNsp > orig.fNsp) { + fNsp = orig.fNsp; + if (fNsp == 0) { + delete [] fPointValue; + } else { + for(int i=0; i<fNsp; i++) { + fPointValue[i] = orig.fPointValue[i]; + } + } + } else { + fNsp = orig.fNsp; + if (fNsp) { + fPointValue = new Double32_t[fNsp]; + for(int i=0; i<fNsp; i++) { + fPointValue[i] = orig.fPointValue[i]; + } + } else { + fPointValue = 0; + } + } + fValid = orig.fValid; + + fTriggerBits = orig.fTriggerBits; + + return *this; +} + //______________________________________________________________________________ void Track::Clear(Option_t * /*option*/) { fTriggerBits.Clear(); delete [] fPointValue; - fPointValue=0; + fPointValue = 0; } //______________________________________________________________________________ diff --git a/test/Event.h b/test/Event.h index e67edeaff0c..d03e8373674 100644 --- a/test/Event.h +++ b/test/Event.h @@ -50,6 +50,8 @@ public: Track(const Track& orig); Track(Float_t random); virtual ~Track() {Clear();} + Track &operator=(const Track &orig); + void Clear(Option_t *option=""); Float_t GetPx() const { return fPx; } Float_t GetPy() const { return fPy; } diff --git a/test/EventMT.cxx b/test/EventMT.cxx index 0e9c3f41001..f74d53455ab 100644 --- a/test/EventMT.cxx +++ b/test/EventMT.cxx @@ -323,6 +323,59 @@ Track::Track(Float_t random) : TObject(),fTriggerBits(64) fValid = Int_t(0.6+gRandom->Rndm(1)); } +//______________________________________________________________________________ +Track &Track::operator=(const Track &orig) +{ + // Copy a track + + TObject::operator=(orig); + fPx = orig.fPx; + fPy = orig.fPy; + fPz = orig.fPx; + fRandom = orig.fRandom; + fMass2 = orig.fMass2; + fBx = orig.fBx; + fBy = orig.fBy; + fMeanCharge = orig.fMeanCharge; + fXfirst = orig.fXfirst; + fXlast = orig.fXlast; + fYfirst = orig.fYfirst; + fYlast = orig.fYlast; + fZfirst = orig.fZfirst; + fZlast = orig.fZlast; + fCharge = orig.fCharge; + + fVertex[0] = orig.fVertex[0]; + fVertex[1] = orig.fVertex[1]; + fVertex[2] = orig.fVertex[2]; + fNpoint = orig.fNpoint; + if (fNsp > orig.fNsp) { + fNsp = orig.fNsp; + if (fNsp == 0) { + delete [] fPointValue; + } else { + for(int i=0; i<fNsp; i++) { + fPointValue[i] = orig.fPointValue[i]; + } + } + } else { + fNsp = orig.fNsp; + if (fNsp) { + fPointValue = new Double32_t[fNsp]; + for(int i=0; i<fNsp; i++) { + fPointValue[i] = orig.fPointValue[i]; + } + } else { + fPointValue = 0; + } + } + fValid = orig.fValid; + + fTriggerBits = orig.fTriggerBits; + + return *this; +} + //______________________________________________________________________________ void Track::Clear(Option_t * /*option*/) { diff --git a/test/EventMT.h b/test/EventMT.h index d936289d190..79fc24983f7 100644 --- a/test/EventMT.h +++ b/test/EventMT.h @@ -53,6 +53,8 @@ public: Track(const Track& orig); Track(Float_t random); virtual ~Track() {Clear();} + Track &operator=(const Track &orig); + void Clear(Option_t *option=""); Float_t GetPx() const { return fPx; } Float_t GetPy() const { return fPy; } -- GitLab