]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMCParticle.cxx
Fixed memleak and delete of refarray
[u/mrichter/AliRoot.git] / STEER / AliMCParticle.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //     Realisation of AliVParticle for MC Particles
20 //     Implementation wraps a TParticle and delegates the methods
21 //     Author: Andreas Morsch, CERN
22 //-------------------------------------------------------------------------
23
24 #include <TRefArray.h>
25
26 #include "AliMCParticle.h"
27
28
29 ClassImp(AliMCParticle)
30
31 AliMCParticle::AliMCParticle():
32     AliVParticle(),
33     fParticle(0),
34     fTrackReferences(0),
35     fNTrackRef(0)
36 {
37     // Constructor
38 }
39
40 AliMCParticle::AliMCParticle(TParticle* part, TRefArray* rarray):
41     AliVParticle(),
42     fParticle(part),
43     fTrackReferences(rarray),
44     fNTrackRef(0)
45 {
46     // Constructor
47     if (rarray != 0) {
48       fNTrackRef = fTrackReferences->GetEntriesFast();
49     }
50 }
51     
52     
53 AliMCParticle::AliMCParticle(const AliMCParticle& mcPart) :
54     AliVParticle(mcPart),
55     fParticle(0),    
56     fTrackReferences(0),
57     fNTrackRef(0)
58 {
59 // Copy constructor
60 }
61
62 AliMCParticle& AliMCParticle::operator=(const AliMCParticle& mcPart)
63
64
65   if (this!=&mcPart) { 
66     AliVParticle::operator=(mcPart);
67   }
68   
69   return *this; 
70 }
71
72 AliMCParticle::~AliMCParticle()
73
74   // delete the track references passed externally
75   // fParticle should be handled by the user
76   // AliStack in case of AliMCEventHandler
77   if(fTrackReferences){
78     delete fTrackReferences;
79     fTrackReferences = 0;
80   }
81 }
82
83
84