AliRoot Core  3dc7879 (3dc7879)
AliMultiplicity.cxx
Go to the documentation of this file.
1 #include <string.h>
2 #include "AliMultiplicity.h"
3 #include "AliLog.h"
4 #include "AliRefArray.h"
5 
6 ClassImp(AliMultiplicity)
7 
8 //______________________________________________________________________
10 AliVMultiplicity("AliMultiplicity",""), // must be named like that to be searchable in ESDEvent
11  fNtracks(0),
12  fNsingle(0),
13  fNsingleSPD2(0),
14 //
15  fDPhiWindow2(0.08*0.08),
16  fDThetaWindow2(0.025*0.025),
17  fDPhiShift(0.0045),
18  fNStdDev(1.0),
19 //
20  fLabels(0),
21  fLabelsL2(0),
22  fUsedClusS(0),
23  fUsedClusT(0),
24  fTh(0),
25  fPhi(0),
26  fDeltTh(0),
27  fDeltPhi(0),
28  fThsingle(0),
29  fPhisingle(0),
30  fLabelssingle(0),
31  fFastOrFiredChips(1200),
32  fClusterFiredChips(1200),
33  fNtracksOnline(0)
34 {
35  // Default Constructor
36  fFiredChips[0] = 0;
37  fFiredChips[1] = 0;
38  for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
39  for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
40 }
41 
42 //______________________________________________________________________
43 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, Int_t *labelss, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr):
44  AliVMultiplicity("AliMultiplicity",""),
45  fNtracks(ntr),
46  fNsingle(ns),
47  fNsingleSPD2(0),
48  //
49  fDPhiWindow2(0.08*0.08),
50  fDThetaWindow2(0.025*0.025),
51  fDPhiShift(0.0045),
52  fNStdDev(1.0),
53  //
54  fLabels(0),
55  fLabelsL2(0),
56  fUsedClusS(0),
57  fUsedClusT(0),
58  fTh(0),
59  fPhi(0),
60  fDeltTh(0),
61  fDeltPhi(0),
62  fThsingle(0),
63  fPhisingle(0),
64  fLabelssingle(0),
65  fFastOrFiredChips(1200),
66  fClusterFiredChips(1200),
67  fNtracksOnline(0)
68 {
69 // Standard constructor
70  for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
71  if(ntr>0){
72  fLabels = new Int_t[ntr];
73  fLabelsL2 = new Int_t[ntr];
74  fTh = new Double_t [ntr];
75  fPhi = new Double_t [ntr];
76  fDeltTh = new Double_t [ntr];
77  fDeltPhi = new Double_t [ntr];
78  for(Int_t i=0;i<fNtracks;i++){
79  fTh[i]=th[i];
80  fPhi[i]=ph[i];
81  fDeltTh[i]=dth[i];
82  fDeltPhi[i]=dph[i];
83  fLabels[i] = labels[i];
84  fLabelsL2[i] = labelsL2[i];
85  }
86  }
87  if(ns>0){
88  fThsingle = new Double_t [ns];
89  fPhisingle = new Double_t [ns];
90  fLabelssingle = new Int_t [ns];
91  for(Int_t i=0;i<fNsingle;i++){
92  fThsingle[i]=ts[i];
93  fPhisingle[i]=ps[i];
94  fLabelssingle[i]=labelss[i];
95  }
96  }
97  fFiredChips[0] = nfcL1;
98  fFiredChips[1] = nfcL2;
99  fFastOrFiredChips = fFastOr;
100  for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
101 }
102 
103 //______________________________________________________________________
104 AliMultiplicity::AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr) :
105  AliVMultiplicity("AliMultiplicity",""),
106  fNtracks(ntr),
107  fNsingle(ns),
108  fNsingleSPD2(0),
109  //
110  fDPhiWindow2(0.08*0.08),
111  fDThetaWindow2(0.025*0.025),
112  fDPhiShift(0.0045),
113  fNStdDev(1.0),
114  //
115  fLabels(0),
116  fLabelsL2(0),
117  fUsedClusS(0),
118  fUsedClusT(0),
119  fTh(0),
120  fPhi(0),
121  fDeltTh(0),
122  fDeltPhi(0),
123  fThsingle(0),
124  fPhisingle(0),
125  fLabelssingle(0),
126  fFastOrFiredChips(1200),
127  fClusterFiredChips(1200),
128  fNtracksOnline(0)
129 {
130  // Standard constructor to create the arrays w/o filling
131  for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
132  if(ntr>0){
133  fLabels = new Int_t[ntr];
134  fLabelsL2 = new Int_t[ntr];
135  fTh = new Double_t [ntr];
136  fPhi = new Double_t [ntr];
137  fDeltTh = new Double_t [ntr];
138  fDeltPhi = new Double_t [ntr];
139  for(Int_t i=fNtracks;i--;){
140  fTh[i]=fPhi[i]=fDeltTh[i]=fDeltPhi[i] = 0;
141  fLabels[i] = fLabelsL2[i] = 0;
142  }
143  }
144  if(ns>0){
145  fThsingle = new Double_t [ns];
146  fPhisingle = new Double_t [ns];
147  fLabelssingle = new Int_t [ns];
148  for(Int_t i=fNsingle;i--;) fThsingle[i] = fPhisingle[i] = fLabelssingle[i] = 0;
149  }
150  fFiredChips[0] = nfcL1;
151  fFiredChips[1] = nfcL2;
152  fFastOrFiredChips = fFastOr;
153  for(Int_t ilayer=6;ilayer--;) fITSClusters[ilayer] = 0;
154 }
155 
156 //______________________________________________________________________
158  AliVMultiplicity(m),
159  fNtracks(m.fNtracks),
160  fNsingle(m.fNsingle),
162  //
163  fDPhiWindow2(0.08*0.08),
164  fDThetaWindow2(0.025*0.025),
165  fDPhiShift(0.0045),
166  fNStdDev(1.0),
167  //
168  fLabels(0),
169  fLabelsL2(0),
170  fUsedClusS(0),
171  fUsedClusT(0),
172  fTh(0),
173  fPhi(0),
174  fDeltTh(0),
175  fDeltPhi(0),
176  fThsingle(0),
177  fPhisingle(0),
178  fLabelssingle(0),
179  fFastOrFiredChips(1200),
180  fClusterFiredChips(1200),
181  fNtracksOnline(0)
182 {
183  // copy constructor
184  for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
185  Duplicate(m);
186 }
187 
188 //______________________________________________________________________
190  // assignment operator
191  if(this == &m)return *this;
192  ((AliVMultiplicity*)this)->operator=(m);
193 
194  if(fTh)delete [] fTh;
195  fTh = 0;
196  if(fPhi)delete [] fPhi;
197  fPhi = 0;
198  if(fDeltTh)delete [] fDeltTh;
199  fDeltTh= 0;
200  if(fDeltPhi)delete [] fDeltPhi;
201  fDeltPhi = 0;
202  if(fLabels)delete [] fLabels;
203  fLabels = 0;
204  if(fLabelsL2)delete [] fLabelsL2;
205  fLabelsL2 = 0;
206  if(fThsingle)delete [] fThsingle;
207  fThsingle = 0;
208  if(fPhisingle)delete [] fPhisingle;
209  fPhisingle = 0;
210  if(fLabelssingle)delete [] fLabelssingle;
211  fLabelssingle = 0;
212  if(fUsedClusS) delete[] fUsedClusS;
213  fUsedClusS = 0;
214  if(fUsedClusT) delete[] fUsedClusT;
215  fUsedClusT = 0;
216  for (int il=2;il--;) {
217  if (fSCl2Tracks[il]) delete fSCl2Tracks[il];
218  fSCl2Tracks[il] = 0;
219  if (fTCl2Tracks[il][0]) delete fTCl2Tracks[il][0];
220  fTCl2Tracks[il][0] = 0;
221  if (fTCl2Tracks[il][1]) delete fTCl2Tracks[il][1];
222  fTCl2Tracks[il][1] = 0;
223  }
224  Duplicate(m);
225  //
226  return *this;
227 }
228 
229 void AliMultiplicity::Copy(TObject &obj) const {
230 
231  // this overwrites the virtual TOBject::Copy()
232  // to allow run time copying without casting
233  // in AliESDEvent
234 
235  if(this==&obj)return;
236  AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
237  if(!robj)return; // not an AliMultiplicity
238  *robj = *this;
239 
240 }
241 
242 
243 //______________________________________________________________________
245  // used by copy constructor and assignment operator
246  fNtracks = m.fNtracks;
247  if(fNtracks>0){
248  fTh = new Double_t[fNtracks];
249  fPhi = new Double_t[fNtracks];
250  fDeltTh = new Double_t[fNtracks];
251  fDeltPhi = new Double_t[fNtracks];
252  fLabels = new Int_t[fNtracks];
253  fLabelsL2 = new Int_t[fNtracks];
254  if (m.fUsedClusT) fUsedClusT = new ULong64_t[fNtracks]; else fUsedClusT = 0;
255  if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
256  if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
257  if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
258  if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
259  if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
260  if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
261  if(fUsedClusT) memcpy(fUsedClusT,m.fUsedClusT,fNtracks*sizeof(ULong64_t));
262  for (int i=2;i--;) for (int j=2;j--;) if (m.fTCl2Tracks[i][j]) fTCl2Tracks[i][j] = new AliRefArray(*m.fTCl2Tracks[i][j]);
263  }
264  else {
265  fTh = 0;
266  fPhi = 0;
267  fDeltTh = 0;
268  fDeltPhi = 0;
269  fLabels = 0;
270  fLabelsL2 = 0;
271  }
272  fNsingle = m.fNsingle;
274  if(fNsingle>0){
275  fThsingle = new Double_t[fNsingle];
276  fPhisingle = new Double_t[fNsingle];
277  fLabelssingle = new Int_t[fNsingle];
278  if (m.fUsedClusS) fUsedClusS = new UInt_t[fNsingle];
279  else fUsedClusS = 0;
280  if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
281  if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
282  if(m.fLabelssingle)memcpy(fLabelssingle,m.fLabelssingle,fNsingle*sizeof(Int_t));
283  if(fUsedClusS) memcpy(fUsedClusS,m.fUsedClusS,fNsingle*sizeof(UInt_t));
284  for (int i=2;i--;) if (m.fSCl2Tracks[i]) fSCl2Tracks[i] = new AliRefArray(*m.fSCl2Tracks[i]);
285  }
286  else {
287  fThsingle = 0;
288  fPhisingle = 0;
289  fLabelssingle = 0;
290  }
291 
292  fFiredChips[0] = m.fFiredChips[0];
293  fFiredChips[1] = m.fFiredChips[1];
294  for(Int_t ilayer = 0; ilayer < 6; ilayer++){
295  fITSClusters[ilayer] = m.fITSClusters[ilayer];
296  }
300  fNStdDev = m.fNStdDev;
304 }
305 
306 //______________________________________________________________________
308  // Destructor
309  if(fTh)delete [] fTh;
310  fTh = 0;
311  if(fPhi)delete [] fPhi;
312  fPhi = 0;
313  if(fDeltTh)delete [] fDeltTh;
314  fDeltTh = 0;
315  if(fDeltPhi)delete [] fDeltPhi;
316  fDeltPhi = 0;
317  if(fLabels)delete [] fLabels;
318  fLabels = 0;
319  if(fLabelsL2)delete [] fLabelsL2;
320  fLabelsL2 = 0;
321  if(fThsingle)delete [] fThsingle;
322  fThsingle = 0;
323  if(fPhisingle)delete [] fPhisingle;
324  fPhisingle = 0;
325  if(fLabelssingle)delete [] fLabelssingle;
326  fLabelssingle = 0;
327  if(fUsedClusS) delete[] fUsedClusS;
328  fUsedClusS = 0;
329  if(fUsedClusT) delete[] fUsedClusT;
330  fUsedClusT = 0;
331  for (int il=2;il--;) {
332  if (fSCl2Tracks[il]) delete fSCl2Tracks[il];
333  fSCl2Tracks[il] = 0;
334  if (fTCl2Tracks[il][0]) delete fTCl2Tracks[il][0];
335  fTCl2Tracks[il][0] = 0;
336  if (fTCl2Tracks[il][1]) delete fTCl2Tracks[il][1];
337  fTCl2Tracks[il][1] = 0;
338  }
339 }
340 
341 //______________________________________________________________________
342 void AliMultiplicity::Clear(Option_t*)
343 {
344  // reset all
346  if(fTh)delete [] fTh;
347  fTh = 0;
348  if(fPhi)delete [] fPhi;
349  fPhi = 0;
350  if(fDeltTh)delete [] fDeltTh;
351  fDeltTh = 0;
352  if(fDeltPhi)delete [] fDeltPhi;
353  fDeltPhi = 0;
354  if(fLabels)delete [] fLabels;
355  fLabels = 0;
356  if(fLabelsL2)delete [] fLabelsL2;
357  fLabelsL2 = 0;
358  if(fThsingle)delete [] fThsingle;
359  fThsingle = 0;
360  if(fPhisingle)delete [] fPhisingle;
361  fPhisingle = 0;
362  if(fLabelssingle)delete [] fLabelssingle;
363  fLabelssingle = 0;
364  if(fUsedClusS) delete[] fUsedClusS;
365  fUsedClusS = 0;
366  if(fUsedClusT) delete[] fUsedClusT;
367  fUsedClusT = 0;
368  for (int il=2;il--;) {
369  if (fSCl2Tracks[il]) delete fSCl2Tracks[il];
370  fSCl2Tracks[il] = 0;
371  if (fTCl2Tracks[il][0]) delete fTCl2Tracks[il][0];
372  fTCl2Tracks[il][0] = 0;
373  if (fTCl2Tracks[il][1]) delete fTCl2Tracks[il][1];
374  fTCl2Tracks[il][1] = 0;
375  }
376  fNtracks = fNsingle = 0;
377  for (int i=6;i--;) fITSClusters[0] = 0;
378  fFiredChips[0] = fFiredChips[1] = 0;
379  fFastOrFiredChips.ResetAllBits(kTRUE);
380  fClusterFiredChips.ResetAllBits(kTRUE);
381  fNtracksOnline = 0;
382  //
383 }
384 
385 //______________________________________________________________________
386 void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
387 {
388  if(i>=0 && i<fNtracks) {
389  if (layer == 0) {
390  fLabels[i] = label;
391  return;
392  } else if (layer == 1) {
393  if (fLabelsL2) {
394  fLabelsL2[i] = label;
395  return;
396  }
397  }
398  }
399  Error("SetLabel","Invalid track number %d or layer %d",i,layer);
400 }
401 
402 //______________________________________________________________________
403 void AliMultiplicity::SetLabelSingle(Int_t i, Int_t label)
404 {
405  if(i>=0 && i<fNsingle) {
406  if (fLabelssingle) {
407  fLabelssingle[i] = label;
408  return;
409  }
410  }
411  Error("SetLabelSingle","Invalid single cluster number %d",i);
412 }
413 
414 //______________________________________________________________________
415 UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
416 
417  if(layMax < layMin) {
418  AliError("layer min > layer max");
419  return 0;
420  }
421  if(layMin < 0) {
422  AliError("layer min < 0");
423  return 0;
424  }
425  if(layMax < 0) {
426  AliError("layer max > 0");
427  return 0;
428  }
429 
430  Int_t sum=0;
431  for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i];
432  return sum;
433 
434 }
435 
436 //______________________________________________________________________
437 void AliMultiplicity::SetTrackletData(Int_t id, const Float_t* tlet, UInt_t trSPD1, UInt_t trSPD2)
438 {
439  // fill tracklet data
440  if (id>=fNtracks) {AliError(Form("Number of declared tracklets %d < %d",fNtracks,id)); return;}
441  fTh[id] = tlet[0];
442  fPhi[id] = tlet[1];
443  fDeltPhi[id] = tlet[2];
444  fDeltTh[id] = tlet[3];
445  fLabels[id] = Int_t(tlet[4]);
446  fLabelsL2[id] = Int_t(tlet[5]);
447  if (!GetMultTrackRefs()) {
448  if (!fUsedClusT) {fUsedClusT = new ULong64_t[fNtracks]; memset(fUsedClusT,0,fNtracks*sizeof(ULong64_t));}
449  fUsedClusT[id] = (((ULong64_t)trSPD2)<<32) + trSPD1;
450  }
451  //
452 }
453 
454 //______________________________________________________________________
455 void AliMultiplicity::SetSingleClusterData(Int_t id, const Float_t* scl, UInt_t tr)
456 {
457  // fill single cluster data
458  if (id>=fNsingle) {AliError(Form("Number of declared singles %d < %d",fNsingle,id)); return;}
459  fThsingle[id] = scl[0];
460  fPhisingle[id] = scl[1];
461  fLabelssingle[id] = Int_t(scl[2]);
462  if (!GetMultTrackRefs()) {
463  if (!fUsedClusS) {fUsedClusS = new UInt_t[fNsingle]; memset(fUsedClusS,0,fNsingle*sizeof(UInt_t));}
464  fUsedClusS[id] = tr;
465  }
466  //
467 }
468 
469 //______________________________________________________________________
470 Bool_t AliMultiplicity::FreeClustersTracklet(Int_t i, Int_t mode) const
471 {
472  // return kTRUE if the tracklet was not used by the track (on any of layers) of type mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure
473  if (mode<0 || mode>1 || i<0 || i>fNtracks) return kFALSE;
474  if (GetMultTrackRefs()) { // new format allows multiple references
475  return !((fTCl2Tracks[0][mode] && fTCl2Tracks[0][mode]->HasReference(i)) ||
476  (fTCl2Tracks[1][mode] && fTCl2Tracks[1][mode]->HasReference(i)));
477  }
478  //
479  if (!fUsedClusT) return kFALSE;
480  const ULong64_t kMask0 = 0x0000ffff0000ffffLL;
481  const ULong64_t kMask1 = 0xffff0000ffff0000LL;
482  return (fUsedClusT[i]&(mode ? kMask1:kMask0)) == 0;
483 }
484 
485 //______________________________________________________________________
486 Bool_t AliMultiplicity::GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const
487 {
488  // set spd1 and spd2 to ID's of the tracks using the clusters of the tracklet (-1 if not used)
489  // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
490  // return false if the neither of clusters is used
491  // note: stored value: [(idSAPureSPD2+1)<<16+(idTPCITS/SA_SPD2+1)]<<32 + [(idSAPureSPD1+1)<<16+(idTPCITS/SA_SPD1+1)]
492  // Attention: new format allows references to multiple tracks, here only the 1st will be returned
493  spd1 = spd2 = -1;
494  if ( mode<0 || mode>1 || i<0 || i>fNtracks ) return kFALSE;
495  if (GetMultTrackRefs()) {
496  if (fTCl2Tracks[0][mode]) spd1 = fTCl2Tracks[0][mode]->GetReference(i,0);
497  if (fTCl2Tracks[1][mode]) spd2 = fTCl2Tracks[1][mode]->GetReference(i,0);
498  }
499  else {
500  if (!fUsedClusT) return kFALSE;
501  spd1 = (fUsedClusT[i]&0xffffffffLL);
502  spd2 = (fUsedClusT[i]>>32);
503  if (mode) { spd1 >>= 16; spd2 >>= 16;}
504  else { spd1 &= 0xffff; spd2 &= 0xffff;}
505  spd1--; // we are storing id+1
506  spd2--;
507  }
508  return !(spd1<0&&spd2<0);
509 }
510 
511 //______________________________________________________________________
512 Int_t AliMultiplicity::GetTrackletTrackIDsLay(Int_t lr,Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const
513 {
514  // fill array refs with maximum maxRef references on tracks used by the cluster of layer lr of tracklet i.
515  // return number of filled references
516  // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
517  //
518  int nrefs = 0;
519  if ( mode<0 || mode>1 || i<0 || i>fNtracks || lr<0||lr>1) return nrefs;
520  if (GetMultTrackRefs()) {
521  if (fTCl2Tracks[lr][mode]) nrefs = fTCl2Tracks[lr][mode]->GetReferences(i,refs, maxRef);
522  }
523  else {
524  if (!fUsedClusT || maxRef<1) return nrefs;
525  int tr = (fUsedClusT[i]&0xffffffffLL);
526  if (mode) { lr==0 ? tr >>= 16 : tr >>= 16;}
527  else { lr==0 ? tr &= 0xffff : tr &= 0xffff;}
528  refs[0] = tr--; // we are storing id+1
529  nrefs = 1;
530  }
531  return nrefs;
532 }
533 
534 //______________________________________________________________________
535 Int_t AliMultiplicity::GetSingleClusterTrackIDs(Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const
536 {
537  // fill array refs with maximum maxRef references on tracks used by the single cluster i of layer lr
538  // return number of filled references
539  // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
540  //
541  int nrefs = 0;
542  if ( mode<0 || mode>1 || i<0 || i>fNtracks) return nrefs;
543  if (GetMultTrackRefs()) {
544  if (fSCl2Tracks[mode]) nrefs = fSCl2Tracks[mode]->GetReferences(i,refs, maxRef);
545  }
546  else {
547  if (!fUsedClusS || maxRef<1) return nrefs;
548  int tr = fUsedClusS[i];
549  if (mode) tr >>= 16;
550  else tr &= 0xffff;
551  refs[0] = tr--; // we are storing id+1
552  nrefs = 1;
553  }
554  return nrefs;
555 }
556 
557 //______________________________________________________________________
558 Bool_t AliMultiplicity::FreeSingleCluster(Int_t i, Int_t mode) const
559 {
560  // return kTRUE if the cluster was not used by the track of type mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure
561  if (mode<0 || mode>1 || i<0 || i>fNsingle) return kFALSE;
562  if (GetMultTrackRefs()) { // new format allows multiple references
563  return !(fSCl2Tracks[mode] && fSCl2Tracks[mode]->HasReference(i));
564  }
565  if (!fUsedClusS) return kFALSE;
566  const UInt_t kMask0 = 0x0000ffff;
567  const UInt_t kMask1 = 0xffff0000;
568  return (fUsedClusS[i]&(mode ? kMask1:kMask0)) == 0;
569 }
570 
571 //______________________________________________________________________
572 Bool_t AliMultiplicity::GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const
573 {
574  // set tr to id of the track using the single clusters (-1 if not used)
575  // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
576  // return false if the cluster is not used
577  //
578  // Attention: new format allows references to multiple tracks, here only the 1st will be returned
579  tr = -1;
580  if (mode<0 || mode>1 || i<0 || i>fNsingle) return kFALSE;
581  if (GetMultTrackRefs()) { if (fSCl2Tracks[mode]) tr = fSCl2Tracks[mode]->GetReference(i,0);}
582  else {
583  if (!fUsedClusS) return kFALSE;
584  tr = fUsedClusS[i];
585  if (mode) tr >>= 16; else tr &= 0xffff;
586  tr--;
587  }
588  return tr>=0;
589 }
590 
591 //______________________________________________________________________
593 {
594  // sqeeze bit contrainers to minimum
595  fFastOrFiredChips.Compact();
596  fClusterFiredChips.Compact();
597 }
598 
599 //______________________________________________________________________
600 void AliMultiplicity::Print(Option_t *opt) const
601 {
602  // print
603  printf("N.tracklets: %4d N.singles: %4d, Multiple cluster->track refs:%s\n"
604  "Used: DPhiShift: %.3e Sig^2: dPhi:%.3e dTht:%.3e NStdDev:%.2f ScaleDThtSin2T:%s\n",
605  fNtracks,fNsingle,GetMultTrackRefs() ? "ON":"OFF",
607  TString opts = opt; opts.ToLower();
608  int t0spd1=-1,t1spd1=-1,t0spd2=-1,t1spd2=-1,nt[2][2]={{0}};
609  UInt_t t[2][2][10]={{{0}}};
610  //
611  if (opts.Contains("t")) {
612  for (int i=0;i<fNtracks;i++) {
613  if (GetMultTrackRefs()) for (int il=2;il--;)for(int it=2;it--;) nt[il][it] = GetTrackletTrackIDsLay(il,i,it,t[il][it],10);
614  else {
615  GetTrackletTrackIDs(i,0,t0spd1,t0spd2);
616  GetTrackletTrackIDs(i,1,t1spd1,t1spd2);
617  }
618  printf("T#%3d| Eta:%+5.2f Th:%+6.3f Phi:%+6.3f DTh:%+6.3f DPhi:%+6.3f L1:%5d L2:%5d ",
619  i,GetEta(i),fTh[i],fPhi[i],fDeltTh[i],fDeltPhi[i],fLabels[i],fLabelsL2[i]);
620  if (!GetMultTrackRefs()) printf("U:L1[%4d/%4d] L2[%4d/%4d]\n",t0spd1,t1spd1,t0spd2,t1spd2);
621  else {
622  printf("U:L1[");
623  if (!nt[0][0]) printf("%4d ",-1); else for(int j=0;j<nt[0][0];j++) printf("%4d ",t[0][0][j]); printf("/");
624  if (!nt[0][1]) printf("%4d ",-1); else for(int j=0;j<nt[0][1];j++) printf("%4d ",t[0][1][j]); printf("]");
625  //
626  printf(" L2[");
627  if (!nt[1][0]) printf("%4d ",-1); else for(int j=0;j<nt[1][0];j++) printf("%4d ",t[1][0][j]); printf("/");
628  if (!nt[1][1]) printf("%4d ",-1); else for(int j=0;j<nt[1][1];j++) printf("%4d ",t[1][1][j]); printf("]\n");
629  }
630  }
631  }
632  if (opts.Contains("s")) {
633  for (int i=0;i<fNsingle;i++) {
634  if (GetMultTrackRefs()) for(int it=2;it--;) nt[0][it] = GetSingleClusterTrackIDs(i,it,t[0][it],10);
635  else {
636  GetSingleClusterTrackID(i,0,t0spd1);
637  GetSingleClusterTrackID(i,1,t1spd1);
638  }
639  printf("S#%3d| Th:%+6.3f Phi:%+6.3f L:%6d ",i,fThsingle[i],fPhisingle[i],fLabelssingle[i]);
640  if (!GetMultTrackRefs()) printf("U:[%4d/%4d]\n", t0spd1,t1spd1);
641  else {
642  printf("U:[");
643  if (!nt[0][0]) printf("%4d ",-1); else for(int j=0;j<nt[0][0];j++) printf("%4d ",t[0][0][j]); printf("/");
644  if (!nt[0][1]) printf("%4d ",-1); else for(int j=0;j<nt[0][1];j++) printf("%4d ",t[0][1][j]); printf("]\n");
645  }
646  }
647  }
648  //
649 }
650 
651 Int_t AliMultiplicity::GetLabelSingleLr(Int_t i, Int_t lr) const
652 {
653  if (lr==1) {
654  if (!AreSPD2SinglesStored()) return -1;
655  else i += GetNumberOfSingleClustersLr(0);
656  }
657  if(i>=0 && i<fNsingle) {
658  return fLabelssingle[i];
659  } else {
660  Error("GetLabelSingle","Invalid cluster number %d",i); return -9999;
661  }
662  return -9999;
663 }
664 
665 Float_t AliMultiplicity::GetPhiAll(int icl, int lr) const
666 {
667  // return phi of the cluster out of total tracklets + singles
668  if (lr<0||lr>1) return -999;
669  if (icl<0||icl>(int)GetNumberOfITSClusters(lr)) {Error("GetPhiAll","Wrong cluster ID=%d for SPD%d",icl,lr); return -999;}
670  if (lr==0) return (icl<fNtracks) ? GetPhi(icl) : GetPhiSingle(icl-fNtracks);
671  return (icl<fNtracks) ? (GetPhi(icl) + GetDeltaPhi(icl)) : GetPhiSingleLr(icl-fNtracks, 1);
672 }
673 
674 Float_t AliMultiplicity::GetThetaAll(int icl, int lr) const
675 {
676  // return theta of the cluster out of total tracklets + singles
677  if (lr<0||lr>1) return -999;
678  if (icl<0||icl>(int)GetNumberOfITSClusters(lr)) {Error("GetPhiAll","Wrong cluster ID=%d for SPD%d",icl,lr); return -999;}
679  if (lr==0) return (icl<fNtracks) ? GetTheta(icl) : GetThetaSingle(icl-fNtracks);
680  return (icl<fNtracks) ? (GetTheta(icl) + GetDeltaTheta(icl)) : GetThetaSingleLr(icl-fNtracks, 1);
681 }
682 
683 Int_t AliMultiplicity::GetLabelAll(int icl, int lr) const
684 {
685  // return label of the cluster out of total tracklets + singles
686  if (lr<0||lr>1) return -99999;
687  if (icl<0||icl>(int)GetNumberOfITSClusters(lr)) {Error("GetPhiAll","Wrong cluster ID=%d for SPD%d",icl,lr); return -99999;}
688  if (lr==0) return (icl<fNtracks) ? GetLabel(icl,0) : GetLabelSingle(icl-fNtracks);
689  return (icl<fNtracks) ? GetLabel(icl,1) : GetLabelSingleLr(icl-fNtracks, 1);
690 }
void SetLabelSingle(Int_t i, Int_t label)
Bool_t AreSPD2SinglesStored() const
virtual void Copy(TObject &obj) const
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void SetSingleClusterData(Int_t id, const Float_t *scl, UInt_t tr=0)
Int_t GetLabelSingle(Int_t i) const
virtual Double_t * GetPhi() const
Bool_t FreeSingleCluster(Int_t i, Int_t mode) const
Bool_t GetMultTrackRefs() const
Int_t GetLabelSingleLr(Int_t i, Int_t layer) const
const Int_t nt
Definition: pdfIO.C:2
Double_t GetEta(Int_t i) const
Int_t GetReference(UInt_t from, UInt_t which) const
Definition: AliRefArray.h:74
Bool_t FreeClustersTracklet(Int_t i, Int_t mode) const
Double32_t * fPhi
Double_t GetThetaSingleLr(Int_t i, Int_t lr) const
UInt_t fITSClusters[6]
Double_t GetPhiSingleLr(Int_t i, Int_t lr) const
virtual Int_t GetLabel(Int_t i, Int_t layer) const
AliRefArray * fTCl2Tracks[2][2]
Double32_t * fPhisingle
virtual ~AliMultiplicity()
virtual void Clear(Option_t *opt="")
void sum()
Bool_t GetScaleDThetaBySin2T() const
Bool_t GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const
UInt_t GetReferences(UInt_t from, UInt_t *refs, UInt_t maxRef) const
Definition: AliRefArray.h:62
Int_t GetSingleClusterTrackIDs(Int_t i, Int_t mode, UInt_t *refs, UInt_t maxRef) const
Float_t GetPhiAll(int icl, int lr) const
Double_t GetDeltaTheta(Int_t i) const
void SetTrackletData(Int_t id, const Float_t *tlet, UInt_t trSPD1=0, UInt_t trSPD2=0)
ULong64_t * fUsedClusT
Double_t * GetThetaSingle() const
virtual void Print(Option_t *opt="") const
UInt_t GetNumberOfITSClusters(Int_t layer) const
virtual Double_t * GetTheta() const
AliRefArray * fSCl2Tracks[2]
Int_t GetTrackletTrackIDsLay(Int_t lr, Int_t i, Int_t mode, UInt_t *refs, UInt_t maxRef) const
Double32_t * fDeltTh
virtual Double_t GetDeltaPhi(Int_t i) const
Int_t GetLabelAll(int icl, int lr) const
virtual void Clear(Option_t *opt="")
Double32_t * fDeltPhi
Float_t GetThetaAll(int icl, int lr) const
Bool_t HasReference(UInt_t from) const
Definition: AliRefArray.h:27
Double32_t * fTh
#define AliError(message)
Definition: AliLog.h:591
Int_t GetNumberOfSingleClustersLr(Int_t lr) const
Double32_t * fThsingle
virtual void SetLabel(Int_t i, Int_t layer, Int_t label)
Bool_t GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const
void Duplicate(const AliMultiplicity &m)
AliMultiplicity & operator=(const AliMultiplicity &m)
Short_t fFiredChips[2]
Double_t * GetPhiSingle() const