added a protection
[u/mrichter/AliRoot.git] / STEER / AliMultiplicity.cxx
CommitLineData
9e44b53d 1#include <string.h>
32e449be 2#include "AliMultiplicity.h"
3
4ClassImp(AliMultiplicity)
5
6//______________________________________________________________________
fe12e09c 7AliMultiplicity::AliMultiplicity():
8 TObject(),
9 fNtracks(0),
cd888a89 10 fNsingle(0),
11 fLabels(0),
fe12e09c 12 fTh(0),
13 fPhi(0),
968e8539 14 fDeltPhi(0),
968e8539 15 fThsingle(0),
16 fPhisingle(0)
fe12e09c 17{
32e449be 18 // Default Constructor
cd888a89 19 fFiredChips[0] = 0;
20 fFiredChips[1] = 0;
32e449be 21}
22
23//______________________________________________________________________
59ea252e 24AliMultiplicity::AliMultiplicity(Int_t ntr, Float_t *t, Float_t *ph, Float_t *df, Int_t *labels, Int_t ns, Float_t *ts, Float_t *ps):
fe12e09c 25 TObject(),
26 fNtracks(ntr),
cd888a89 27 fNsingle(ns),
28 fLabels(0),
fe12e09c 29 fTh(0),
30 fPhi(0),
968e8539 31 fDeltPhi(0),
968e8539 32 fThsingle(0),
33 fPhisingle(0)
fe12e09c 34{
32e449be 35// Standard constructor
32e449be 36 if(ntr>0){
59ea252e 37 fLabels = new Int_t[ntr];
cd888a89 38 fTh = new Double_t [ntr];
39 fPhi = new Double_t [ntr];
40 fDeltPhi = new Double_t [ntr];
32e449be 41 for(Int_t i=0;i<fNtracks;i++){
42 fTh[i]=t[i];
43 fPhi[i]=ph[i];
44 fDeltPhi[i]=df[i];
59ea252e 45 fLabels[i] = labels[i];
32e449be 46 }
47 }
968e8539 48 if(ns>0){
cd888a89 49 fThsingle = new Double_t [ns];
50 fPhisingle = new Double_t [ns];
968e8539 51 for(Int_t i=0;i<fNsingle;i++){
52 fThsingle[i]=ts[i];
53 fPhisingle[i]=ps[i];
54 }
55 }
cd888a89 56 fFiredChips[0] = 0;
57 fFiredChips[1] = 0;
32e449be 58}
59
60//______________________________________________________________________
fe12e09c 61AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
62 TObject(m),
63 fNtracks(m.fNtracks),
cd888a89 64 fNsingle(m.fNsingle),
65 fLabels(0),
fe12e09c 66 fTh(0),
67 fPhi(0),
968e8539 68 fDeltPhi(0),
968e8539 69 fThsingle(0),
70 fPhisingle(0)
fe12e09c 71{
32e449be 72 // copy constructor
32e449be 73 Duplicate(m);
32e449be 74}
75
76//______________________________________________________________________
77AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
78 // assignment operator
79 if(this == &m)return *this;
80 ((TObject *)this)->operator=(m);
81
316c6cd9 82 if(fTh)delete [] fTh;fTh = 0;
83 if(fPhi)delete [] fPhi;fPhi = 0;
84 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
85 if(fLabels)delete [] fLabels;fLabels = 0;
86 if(fThsingle)delete [] fThsingle;fThsingle = 0;
87 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
32e449be 88 Duplicate(m);
89
90 return *this;
91}
92
93//______________________________________________________________________
94void AliMultiplicity::Duplicate(const AliMultiplicity& m){
95 // used by copy constructor and assignment operator
96 fNtracks = m.fNtracks;
97 if(fNtracks>0){
cd888a89 98 fTh = new Double_t[fNtracks];
99 fPhi = new Double_t[fNtracks];
100 fDeltPhi = new Double_t[fNtracks];
59ea252e 101 fLabels = new Int_t[fNtracks];
32e449be 102 }
103 else {
104 fTh = 0;
105 fPhi = 0;
106 fDeltPhi = 0;
59ea252e 107 fLabels = 0;
32e449be 108 }
968e8539 109 fNsingle = m.fNsingle;
110 if(fNsingle>0){
cd888a89 111 fThsingle = new Double_t[fNsingle];
112 fPhisingle = new Double_t[fNsingle];
968e8539 113 }
114 else {
115 fThsingle = 0;
116 fPhisingle = 0;
117 }
cd888a89 118 if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
119 if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
120 if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
121 if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
122 if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
123 if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
466ffa28 124
125 fFiredChips[0] = m.fFiredChips[0];
126 fFiredChips[1] = m.fFiredChips[1];
32e449be 127}
128
129//______________________________________________________________________
130AliMultiplicity::~AliMultiplicity(){
131 // Destructor
316c6cd9 132 if(fTh)delete [] fTh;fTh = 0;
133 if(fPhi)delete [] fPhi;fPhi = 0;
134 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
135 if(fLabels)delete [] fLabels;fLabels = 0;
136 if(fThsingle)delete [] fThsingle;fThsingle = 0;
137 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
138
32e449be 139}
140
141