]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMultiplicity.cxx
The description of changes:
[u/mrichter/AliRoot.git] / STEER / AliMultiplicity.cxx
CommitLineData
9e44b53d 1#include <string.h>
32e449be 2#include "AliMultiplicity.h"
d325d83f 3#include "AliLog.h"
32e449be 4
5ClassImp(AliMultiplicity)
6
7//______________________________________________________________________
fe12e09c 8AliMultiplicity::AliMultiplicity():
9 TObject(),
10 fNtracks(0),
cd888a89 11 fNsingle(0),
12 fLabels(0),
0939e22a 13 fLabelsL2(0),
fe12e09c 14 fTh(0),
15 fPhi(0),
fa9ed8e9 16 fDeltTh(0),
968e8539 17 fDeltPhi(0),
968e8539 18 fThsingle(0),
ff44c37c 19 fPhisingle(0),
20 fFastOrFiredChips(1200)
fe12e09c 21{
32e449be 22 // Default Constructor
cd888a89 23 fFiredChips[0] = 0;
24 fFiredChips[1] = 0;
d325d83f 25 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
32e449be 26}
27
28//______________________________________________________________________
fa9ed8e9 29AliMultiplicity::AliMultiplicity(Int_t ntr, Float_t *th, Float_t *ph, Float_t *dth, Float_t *dph, Int_t *labels, Int_t* labelsL2, Int_t ns, Float_t *ts, Float_t *ps, Short_t nfcL1, Short_t nfcL2, TBits fFastOr):
fe12e09c 30 TObject(),
31 fNtracks(ntr),
cd888a89 32 fNsingle(ns),
33 fLabels(0),
0939e22a 34 fLabelsL2(0),
fe12e09c 35 fTh(0),
36 fPhi(0),
fa9ed8e9 37 fDeltTh(0),
968e8539 38 fDeltPhi(0),
968e8539 39 fThsingle(0),
ff44c37c 40 fPhisingle(0),
41 fFastOrFiredChips(1200)
fe12e09c 42{
32e449be 43// Standard constructor
32e449be 44 if(ntr>0){
59ea252e 45 fLabels = new Int_t[ntr];
0939e22a 46 fLabelsL2 = new Int_t[ntr];
cd888a89 47 fTh = new Double_t [ntr];
48 fPhi = new Double_t [ntr];
fa9ed8e9 49 fDeltTh = new Double_t [ntr];
cd888a89 50 fDeltPhi = new Double_t [ntr];
32e449be 51 for(Int_t i=0;i<fNtracks;i++){
fa9ed8e9 52 fTh[i]=th[i];
32e449be 53 fPhi[i]=ph[i];
fa9ed8e9 54 fDeltTh[i]=dth[i];
55 fDeltPhi[i]=dph[i];
59ea252e 56 fLabels[i] = labels[i];
0939e22a 57 fLabelsL2[i] = labelsL2[i];
32e449be 58 }
59 }
968e8539 60 if(ns>0){
cd888a89 61 fThsingle = new Double_t [ns];
62 fPhisingle = new Double_t [ns];
968e8539 63 for(Int_t i=0;i<fNsingle;i++){
64 fThsingle[i]=ts[i];
65 fPhisingle[i]=ps[i];
66 }
67 }
9b373e9a 68 fFiredChips[0] = nfcL1;
69 fFiredChips[1] = nfcL2;
ff44c37c 70 fFastOrFiredChips = fFastOr;
d325d83f 71 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
32e449be 72}
73
74//______________________________________________________________________
fe12e09c 75AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
76 TObject(m),
77 fNtracks(m.fNtracks),
cd888a89 78 fNsingle(m.fNsingle),
79 fLabels(0),
0939e22a 80 fLabelsL2(0),
fe12e09c 81 fTh(0),
82 fPhi(0),
fa9ed8e9 83 fDeltTh(0),
968e8539 84 fDeltPhi(0),
968e8539 85 fThsingle(0),
ff44c37c 86 fPhisingle(0),
87 fFastOrFiredChips(1200)
fe12e09c 88{
32e449be 89 // copy constructor
32e449be 90 Duplicate(m);
32e449be 91}
92
93//______________________________________________________________________
94AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
95 // assignment operator
96 if(this == &m)return *this;
97 ((TObject *)this)->operator=(m);
98
316c6cd9 99 if(fTh)delete [] fTh;fTh = 0;
100 if(fPhi)delete [] fPhi;fPhi = 0;
fa9ed8e9 101 if(fDeltTh)delete [] fDeltTh;fDeltTh= 0;
316c6cd9 102 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
103 if(fLabels)delete [] fLabels;fLabels = 0;
0939e22a 104 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
316c6cd9 105 if(fThsingle)delete [] fThsingle;fThsingle = 0;
106 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
32e449be 107 Duplicate(m);
108
109 return *this;
110}
111
732a24fe 112void AliMultiplicity::Copy(TObject &obj) const {
113
114 // this overwrites the virtual TOBject::Copy()
115 // to allow run time copying without casting
116 // in AliESDEvent
117
118 if(this==&obj)return;
119 AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
120 if(!robj)return; // not an AliMultiplicity
121 *robj = *this;
122
123}
124
125
32e449be 126//______________________________________________________________________
127void AliMultiplicity::Duplicate(const AliMultiplicity& m){
128 // used by copy constructor and assignment operator
129 fNtracks = m.fNtracks;
130 if(fNtracks>0){
cd888a89 131 fTh = new Double_t[fNtracks];
132 fPhi = new Double_t[fNtracks];
fa9ed8e9 133 fDeltTh = new Double_t[fNtracks];
cd888a89 134 fDeltPhi = new Double_t[fNtracks];
59ea252e 135 fLabels = new Int_t[fNtracks];
0939e22a 136 fLabelsL2 = new Int_t[fNtracks];
32e449be 137 }
138 else {
139 fTh = 0;
140 fPhi = 0;
fa9ed8e9 141 fDeltTh = 0;
32e449be 142 fDeltPhi = 0;
59ea252e 143 fLabels = 0;
0939e22a 144 fLabelsL2 = 0;
32e449be 145 }
968e8539 146 fNsingle = m.fNsingle;
147 if(fNsingle>0){
cd888a89 148 fThsingle = new Double_t[fNsingle];
149 fPhisingle = new Double_t[fNsingle];
968e8539 150 }
151 else {
152 fThsingle = 0;
153 fPhisingle = 0;
154 }
cd888a89 155 if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
156 if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
fa9ed8e9 157 if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
cd888a89 158 if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
159 if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
0939e22a 160 if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
cd888a89 161 if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
162 if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
466ffa28 163
164 fFiredChips[0] = m.fFiredChips[0];
165 fFiredChips[1] = m.fFiredChips[1];
d325d83f 166 for(Int_t ilayer = 0; ilayer < 6; ilayer++){
167 fITSClusters[ilayer] = m.fITSClusters[ilayer];
168 }
169
170
ff44c37c 171
172 fFastOrFiredChips = m.fFastOrFiredChips;
32e449be 173}
174
175//______________________________________________________________________
176AliMultiplicity::~AliMultiplicity(){
177 // Destructor
316c6cd9 178 if(fTh)delete [] fTh;fTh = 0;
179 if(fPhi)delete [] fPhi;fPhi = 0;
fa9ed8e9 180 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
316c6cd9 181 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
182 if(fLabels)delete [] fLabels;fLabels = 0;
0939e22a 183 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
316c6cd9 184 if(fThsingle)delete [] fThsingle;fThsingle = 0;
185 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
186
32e449be 187}
56258350 188
189//______________________________________________________________________
190void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
191{
192 if(i>=0 && i<fNtracks) {
193 if (layer == 0) {
194 fLabels[i] = label;
195 return;
196 } else if (layer == 1) {
197 if (fLabelsL2) {
198 fLabelsL2[i] = label;
199 return;
200 }
201 }
202 }
203 Error("SetLabel","Invalid track number %d or layer %d",i,layer);
204}
d325d83f 205
206//______________________________________________________________________
207UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
208
209 if(layMax < layMin) {
210 AliError("layer min > layer max");
211 return 0;
212 }
213 if(layMin < 0) {
214 AliError("layer min < 0");
215 return 0;
216 }
217 if(layMax < 0) {
218 AliError("layer max > 0");
219 return 0;
220 }
221
222 Int_t sum=0;
223 for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i];
224 return sum;
225
226}