2 #include "AliMultiplicity.h"
5 ClassImp(AliMultiplicity)
7 //______________________________________________________________________
8 AliMultiplicity::AliMultiplicity():
20 fFastOrFiredChips(1200),
21 fClusterFiredChips(1200)
23 // Default Constructor
26 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
29 //______________________________________________________________________
30 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, const TBits & fFastOr):
42 fFastOrFiredChips(1200),
43 fClusterFiredChips(1200)
45 // Standard constructor
47 fLabels = new Int_t[ntr];
48 fLabelsL2 = new Int_t[ntr];
49 fTh = new Double_t [ntr];
50 fPhi = new Double_t [ntr];
51 fDeltTh = new Double_t [ntr];
52 fDeltPhi = new Double_t [ntr];
53 for(Int_t i=0;i<fNtracks;i++){
58 fLabels[i] = labels[i];
59 fLabelsL2[i] = labelsL2[i];
63 fThsingle = new Double_t [ns];
64 fPhisingle = new Double_t [ns];
65 for(Int_t i=0;i<fNsingle;i++){
70 fFiredChips[0] = nfcL1;
71 fFiredChips[1] = nfcL2;
72 fFastOrFiredChips = fFastOr;
73 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
76 //______________________________________________________________________
77 AliMultiplicity::AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr) :
89 fFastOrFiredChips(1200),
90 fClusterFiredChips(1200)
92 // Standard constructor to create the arrays w/o filling
94 fLabels = new Int_t[ntr];
95 fLabelsL2 = new Int_t[ntr];
96 fTh = new Double_t [ntr];
97 fPhi = new Double_t [ntr];
98 fDeltTh = new Double_t [ntr];
99 fDeltPhi = new Double_t [ntr];
100 for(Int_t i=fNtracks;i--;){
101 fTh[i]=fPhi[i]=fDeltTh[i]=fDeltPhi[i] = 0;
102 fLabels[i] = fLabelsL2[i] = 0;
106 fThsingle = new Double_t [ns];
107 fPhisingle = new Double_t [ns];
108 for(Int_t i=fNsingle;i--;) fThsingle[i] = fPhisingle[i] = 0;
110 fFiredChips[0] = nfcL1;
111 fFiredChips[1] = nfcL2;
112 fFastOrFiredChips = fFastOr;
113 for(Int_t ilayer=6;ilayer--;) fITSClusters[ilayer] = 0;
116 //______________________________________________________________________
117 AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
119 fNtracks(m.fNtracks),
120 fNsingle(m.fNsingle),
129 fFastOrFiredChips(1200),
130 fClusterFiredChips(1200)
136 //______________________________________________________________________
137 AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
138 // assignment operator
139 if(this == &m)return *this;
140 ((TObject *)this)->operator=(m);
142 if(fTh)delete [] fTh;fTh = 0;
143 if(fPhi)delete [] fPhi;fPhi = 0;
144 if(fDeltTh)delete [] fDeltTh;fDeltTh= 0;
145 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
146 if(fLabels)delete [] fLabels;fLabels = 0;
147 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
148 if(fThsingle)delete [] fThsingle;fThsingle = 0;
149 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
155 void AliMultiplicity::Copy(TObject &obj) const {
157 // this overwrites the virtual TOBject::Copy()
158 // to allow run time copying without casting
161 if(this==&obj)return;
162 AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
163 if(!robj)return; // not an AliMultiplicity
169 //______________________________________________________________________
170 void AliMultiplicity::Duplicate(const AliMultiplicity& m){
171 // used by copy constructor and assignment operator
172 fNtracks = m.fNtracks;
174 fTh = new Double_t[fNtracks];
175 fPhi = new Double_t[fNtracks];
176 fDeltTh = new Double_t[fNtracks];
177 fDeltPhi = new Double_t[fNtracks];
178 fLabels = new Int_t[fNtracks];
179 fLabelsL2 = new Int_t[fNtracks];
189 fNsingle = m.fNsingle;
191 fThsingle = new Double_t[fNsingle];
192 fPhisingle = new Double_t[fNsingle];
198 if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
199 if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
200 if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
201 if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
202 if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
203 if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
204 if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
205 if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
207 fFiredChips[0] = m.fFiredChips[0];
208 fFiredChips[1] = m.fFiredChips[1];
209 for(Int_t ilayer = 0; ilayer < 6; ilayer++){
210 fITSClusters[ilayer] = m.fITSClusters[ilayer];
213 fUsedClusT[0] = m.fUsedClusT[0];
214 fUsedClusT[1] = m.fUsedClusT[1];
215 fUsedClusS[0] = m.fUsedClusS[0];
216 fUsedClusS[1] = m.fUsedClusS[1];
218 fFastOrFiredChips = m.fFastOrFiredChips;
219 fClusterFiredChips = m.fClusterFiredChips;
222 //______________________________________________________________________
223 AliMultiplicity::~AliMultiplicity(){
225 if(fTh)delete [] fTh;fTh = 0;
226 if(fPhi)delete [] fPhi;fPhi = 0;
227 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
228 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
229 if(fLabels)delete [] fLabels;fLabels = 0;
230 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
231 if(fThsingle)delete [] fThsingle;fThsingle = 0;
232 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
236 //______________________________________________________________________
237 void AliMultiplicity::Clear(Option_t*)
241 if(fTh)delete [] fTh;fTh = 0;
242 if(fPhi)delete [] fPhi;fPhi = 0;
243 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
244 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
245 if(fLabels)delete [] fLabels;fLabels = 0;
246 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
247 if(fThsingle)delete [] fThsingle;fThsingle = 0;
248 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
249 fNtracks = fNsingle = 0;
250 for (int i=6;i--;) fITSClusters[0] = 0;
251 fFiredChips[0] = fFiredChips[1] = 0;
252 fFastOrFiredChips.ResetAllBits(kTRUE);
253 fClusterFiredChips.ResetAllBits(kTRUE);
254 fUsedClusT[0].ResetAllBits(kTRUE);
255 fUsedClusT[1].ResetAllBits(kTRUE);
256 fUsedClusS[0].ResetAllBits(kTRUE);
257 fUsedClusS[1].ResetAllBits(kTRUE);
261 //______________________________________________________________________
262 void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
264 if(i>=0 && i<fNtracks) {
268 } else if (layer == 1) {
270 fLabelsL2[i] = label;
275 Error("SetLabel","Invalid track number %d or layer %d",i,layer);
278 //______________________________________________________________________
279 UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
281 if(layMax < layMin) {
282 AliError("layer min > layer max");
286 AliError("layer min < 0");
290 AliError("layer max > 0");
295 for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i];
300 //______________________________________________________________________
301 void AliMultiplicity::SetTrackletData(Int_t id, const Float_t* tlet, UInt_t bits)
303 // fill tracklet data
304 if (id>=fNtracks) {AliError(Form("Number of declared tracklets %d < %d",fNtracks,id)); return;}
307 fDeltPhi[id] = tlet[2];
308 fDeltTh[id] = tlet[3];
309 fLabels[id] = Int_t(tlet[4]);
310 fLabelsL2[id] = Int_t(tlet[5]);
311 if (bits&BIT(0)) fUsedClusT[0].SetBitNumber(id);
312 if (bits&BIT(1)) fUsedClusT[1].SetBitNumber(id);
316 //______________________________________________________________________
317 void AliMultiplicity::SetSingleClusterData(Int_t id, const Float_t* scl, UInt_t bits)
319 // fill single cluster data
320 if (id>=fNsingle) {AliError(Form("Number of declared singles %d < %d",fNsingle,id)); return;}
321 fThsingle[id] = scl[0];
322 fPhisingle[id] = scl[1];
323 if (bits&BIT(0)) fUsedClusS[0].SetBitNumber(id);
324 if (bits&BIT(1)) fUsedClusS[1].SetBitNumber(id);
328 //______________________________________________________________________
329 void AliMultiplicity::CompactBits()
331 // sqeeze bit contrainers to minimum
332 fFastOrFiredChips.Compact();
333 fClusterFiredChips.Compact();
334 fUsedClusT[0].Compact();
335 fUsedClusT[1].Compact();
336 fUsedClusS[0].Compact();
337 fUsedClusS[1].Compact();
340 //______________________________________________________________________
341 void AliMultiplicity::Print(Option_t *opt) const
344 printf("N.tracklets: %4d N.singles: %4d\n",fNtracks,fNsingle);
345 TString opts = opt; opts.ToLower();
346 if (opts.Contains("t")) {
347 for (int i=0;i<fNtracks;i++)
348 printf("T#%3d| Th:%+6.3f Phi:%+6.3f DTh:%+6.3f DPhi:%+6.3f L1:%4d L2:%4d U0:%d U1:%d\n",
349 i,fTh[i],fPhi[i],fDeltTh[i],fDeltPhi[i],fLabels[i],fLabelsL2[i],
350 FreeClustersTracklet(i,0),FreeClustersTracklet(i,1));
352 if (opts.Contains("s")) {
353 for (int i=0;i<fNsingle;i++)
354 printf("S#%3d| Th:%+6.3f Phi:%+6.3f U0:%d U1:%d\n",
355 i,fThsingle[i],fPhisingle[i],
356 FreeClustersTracklet(i,0),FreeClustersTracklet(i,1));