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