]>
Commit | Line | Data |
---|---|---|
1 | #include <string.h> | |
2 | #include "AliMultiplicity.h" | |
3 | #include "AliLog.h" | |
4 | ||
5 | ClassImp(AliMultiplicity) | |
6 | ||
7 | //______________________________________________________________________ | |
8 | AliMultiplicity::AliMultiplicity(): | |
9 | TObject(), | |
10 | fNtracks(0), | |
11 | fNsingle(0), | |
12 | fLabels(0), | |
13 | fLabelsL2(0), | |
14 | fTh(0), | |
15 | fPhi(0), | |
16 | fDeltTh(0), | |
17 | fDeltPhi(0), | |
18 | fThsingle(0), | |
19 | fPhisingle(0), | |
20 | fFastOrFiredChips(1200) | |
21 | { | |
22 | // Default Constructor | |
23 | fFiredChips[0] = 0; | |
24 | fFiredChips[1] = 0; | |
25 | for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0; | |
26 | } | |
27 | ||
28 | //______________________________________________________________________ | |
29 | AliMultiplicity::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): | |
30 | TObject(), | |
31 | fNtracks(ntr), | |
32 | fNsingle(ns), | |
33 | fLabels(0), | |
34 | fLabelsL2(0), | |
35 | fTh(0), | |
36 | fPhi(0), | |
37 | fDeltTh(0), | |
38 | fDeltPhi(0), | |
39 | fThsingle(0), | |
40 | fPhisingle(0), | |
41 | fFastOrFiredChips(1200) | |
42 | { | |
43 | // Standard constructor | |
44 | if(ntr>0){ | |
45 | fLabels = new Int_t[ntr]; | |
46 | fLabelsL2 = new Int_t[ntr]; | |
47 | fTh = new Double_t [ntr]; | |
48 | fPhi = new Double_t [ntr]; | |
49 | fDeltTh = new Double_t [ntr]; | |
50 | fDeltPhi = new Double_t [ntr]; | |
51 | for(Int_t i=0;i<fNtracks;i++){ | |
52 | fTh[i]=th[i]; | |
53 | fPhi[i]=ph[i]; | |
54 | fDeltTh[i]=dth[i]; | |
55 | fDeltPhi[i]=dph[i]; | |
56 | fLabels[i] = labels[i]; | |
57 | fLabelsL2[i] = labelsL2[i]; | |
58 | } | |
59 | } | |
60 | if(ns>0){ | |
61 | fThsingle = new Double_t [ns]; | |
62 | fPhisingle = new Double_t [ns]; | |
63 | for(Int_t i=0;i<fNsingle;i++){ | |
64 | fThsingle[i]=ts[i]; | |
65 | fPhisingle[i]=ps[i]; | |
66 | } | |
67 | } | |
68 | fFiredChips[0] = nfcL1; | |
69 | fFiredChips[1] = nfcL2; | |
70 | fFastOrFiredChips = fFastOr; | |
71 | for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0; | |
72 | } | |
73 | ||
74 | //______________________________________________________________________ | |
75 | AliMultiplicity::AliMultiplicity(const AliMultiplicity& m): | |
76 | TObject(m), | |
77 | fNtracks(m.fNtracks), | |
78 | fNsingle(m.fNsingle), | |
79 | fLabels(0), | |
80 | fLabelsL2(0), | |
81 | fTh(0), | |
82 | fPhi(0), | |
83 | fDeltTh(0), | |
84 | fDeltPhi(0), | |
85 | fThsingle(0), | |
86 | fPhisingle(0), | |
87 | fFastOrFiredChips(1200) | |
88 | { | |
89 | // copy constructor | |
90 | Duplicate(m); | |
91 | } | |
92 | ||
93 | //______________________________________________________________________ | |
94 | AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){ | |
95 | // assignment operator | |
96 | if(this == &m)return *this; | |
97 | ((TObject *)this)->operator=(m); | |
98 | ||
99 | if(fTh)delete [] fTh;fTh = 0; | |
100 | if(fPhi)delete [] fPhi;fPhi = 0; | |
101 | if(fDeltTh)delete [] fDeltTh;fDeltTh= 0; | |
102 | if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; | |
103 | if(fLabels)delete [] fLabels;fLabels = 0; | |
104 | if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0; | |
105 | if(fThsingle)delete [] fThsingle;fThsingle = 0; | |
106 | if(fPhisingle)delete [] fPhisingle;fPhisingle = 0; | |
107 | Duplicate(m); | |
108 | ||
109 | return *this; | |
110 | } | |
111 | ||
112 | void 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 | ||
126 | //______________________________________________________________________ | |
127 | void AliMultiplicity::Duplicate(const AliMultiplicity& m){ | |
128 | // used by copy constructor and assignment operator | |
129 | fNtracks = m.fNtracks; | |
130 | if(fNtracks>0){ | |
131 | fTh = new Double_t[fNtracks]; | |
132 | fPhi = new Double_t[fNtracks]; | |
133 | fDeltTh = new Double_t[fNtracks]; | |
134 | fDeltPhi = new Double_t[fNtracks]; | |
135 | fLabels = new Int_t[fNtracks]; | |
136 | fLabelsL2 = new Int_t[fNtracks]; | |
137 | } | |
138 | else { | |
139 | fTh = 0; | |
140 | fPhi = 0; | |
141 | fDeltTh = 0; | |
142 | fDeltPhi = 0; | |
143 | fLabels = 0; | |
144 | fLabelsL2 = 0; | |
145 | } | |
146 | fNsingle = m.fNsingle; | |
147 | if(fNsingle>0){ | |
148 | fThsingle = new Double_t[fNsingle]; | |
149 | fPhisingle = new Double_t[fNsingle]; | |
150 | } | |
151 | else { | |
152 | fThsingle = 0; | |
153 | fPhisingle = 0; | |
154 | } | |
155 | if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t)); | |
156 | if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t)); | |
157 | if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t)); | |
158 | if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t)); | |
159 | if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t)); | |
160 | if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t)); | |
161 | if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t)); | |
162 | if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t)); | |
163 | ||
164 | fFiredChips[0] = m.fFiredChips[0]; | |
165 | fFiredChips[1] = m.fFiredChips[1]; | |
166 | for(Int_t ilayer = 0; ilayer < 6; ilayer++){ | |
167 | fITSClusters[ilayer] = m.fITSClusters[ilayer]; | |
168 | } | |
169 | ||
170 | ||
171 | ||
172 | fFastOrFiredChips = m.fFastOrFiredChips; | |
173 | } | |
174 | ||
175 | //______________________________________________________________________ | |
176 | AliMultiplicity::~AliMultiplicity(){ | |
177 | // Destructor | |
178 | if(fTh)delete [] fTh;fTh = 0; | |
179 | if(fPhi)delete [] fPhi;fPhi = 0; | |
180 | if(fDeltTh)delete [] fDeltTh;fDeltTh = 0; | |
181 | if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; | |
182 | if(fLabels)delete [] fLabels;fLabels = 0; | |
183 | if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0; | |
184 | if(fThsingle)delete [] fThsingle;fThsingle = 0; | |
185 | if(fPhisingle)delete [] fPhisingle;fPhisingle = 0; | |
186 | ||
187 | } | |
188 | ||
189 | //______________________________________________________________________ | |
190 | void 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 | } | |
205 | ||
206 | //______________________________________________________________________ | |
207 | UInt_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 | } |