]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMultiplicity.cxx
Updates (A. Toia)
[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),
34581d1e 14 fUsedClusS(0),
15 fUsedClusT(0),
fe12e09c 16 fTh(0),
17 fPhi(0),
fa9ed8e9 18 fDeltTh(0),
968e8539 19 fDeltPhi(0),
968e8539 20 fThsingle(0),
ff44c37c 21 fPhisingle(0),
d7c5c1e4 22 fLabelssingle(0),
adc4b00f 23 fFastOrFiredChips(1200),
ab37e14c 24 fClusterFiredChips(1200)
fe12e09c 25{
32e449be 26 // Default Constructor
ab37e14c 27 fFiredChips[0] = 0;
28 fFiredChips[1] = 0;
d325d83f 29 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
32e449be 30}
31
32//______________________________________________________________________
d7c5c1e4 33AliMultiplicity::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 34 TObject(),
35 fNtracks(ntr),
cd888a89 36 fNsingle(ns),
37 fLabels(0),
0939e22a 38 fLabelsL2(0),
34581d1e 39 fUsedClusS(0),
40 fUsedClusT(0),
fe12e09c 41 fTh(0),
42 fPhi(0),
fa9ed8e9 43 fDeltTh(0),
968e8539 44 fDeltPhi(0),
968e8539 45 fThsingle(0),
ff44c37c 46 fPhisingle(0),
d7c5c1e4 47 fLabelssingle(0),
adc4b00f 48 fFastOrFiredChips(1200),
ab37e14c 49 fClusterFiredChips(1200)
fe12e09c 50{
32e449be 51// Standard constructor
32e449be 52 if(ntr>0){
59ea252e 53 fLabels = new Int_t[ntr];
0939e22a 54 fLabelsL2 = new Int_t[ntr];
cd888a89 55 fTh = new Double_t [ntr];
56 fPhi = new Double_t [ntr];
fa9ed8e9 57 fDeltTh = new Double_t [ntr];
cd888a89 58 fDeltPhi = new Double_t [ntr];
32e449be 59 for(Int_t i=0;i<fNtracks;i++){
fa9ed8e9 60 fTh[i]=th[i];
32e449be 61 fPhi[i]=ph[i];
fa9ed8e9 62 fDeltTh[i]=dth[i];
63 fDeltPhi[i]=dph[i];
59ea252e 64 fLabels[i] = labels[i];
0939e22a 65 fLabelsL2[i] = labelsL2[i];
32e449be 66 }
67 }
968e8539 68 if(ns>0){
cd888a89 69 fThsingle = new Double_t [ns];
70 fPhisingle = new Double_t [ns];
d7c5c1e4 71 fLabelssingle = new Int_t [ns];
968e8539 72 for(Int_t i=0;i<fNsingle;i++){
73 fThsingle[i]=ts[i];
74 fPhisingle[i]=ps[i];
d7c5c1e4 75 fLabelssingle[i]=labelss[i];
968e8539 76 }
77 }
ab37e14c 78 fFiredChips[0] = nfcL1;
79 fFiredChips[1] = nfcL2;
ff44c37c 80 fFastOrFiredChips = fFastOr;
d325d83f 81 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
32e449be 82}
83
1f9831ab 84//______________________________________________________________________
85AliMultiplicity::AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr) :
86 TObject(),
87 fNtracks(ntr),
88 fNsingle(ns),
89 fLabels(0),
90 fLabelsL2(0),
34581d1e 91 fUsedClusS(0),
92 fUsedClusT(0),
1f9831ab 93 fTh(0),
94 fPhi(0),
95 fDeltTh(0),
96 fDeltPhi(0),
97 fThsingle(0),
98 fPhisingle(0),
d7c5c1e4 99 fLabelssingle(0),
1f9831ab 100 fFastOrFiredChips(1200),
101 fClusterFiredChips(1200)
102{
103 // Standard constructor to create the arrays w/o filling
104 if(ntr>0){
105 fLabels = new Int_t[ntr];
106 fLabelsL2 = new Int_t[ntr];
107 fTh = new Double_t [ntr];
108 fPhi = new Double_t [ntr];
109 fDeltTh = new Double_t [ntr];
110 fDeltPhi = new Double_t [ntr];
34581d1e 111 fUsedClusT = new ULong64_t[ntr];
112
1f9831ab 113 for(Int_t i=fNtracks;i--;){
114 fTh[i]=fPhi[i]=fDeltTh[i]=fDeltPhi[i] = 0;
115 fLabels[i] = fLabelsL2[i] = 0;
116 }
117 }
118 if(ns>0){
119 fThsingle = new Double_t [ns];
120 fPhisingle = new Double_t [ns];
d7c5c1e4 121 fLabelssingle = new Int_t [ns];
34581d1e 122 fUsedClusS = new UInt_t[ns];
d7c5c1e4 123 for(Int_t i=fNsingle;i--;) fThsingle[i] = fPhisingle[i] = fLabelssingle[i] = 0;
1f9831ab 124 }
125 fFiredChips[0] = nfcL1;
126 fFiredChips[1] = nfcL2;
127 fFastOrFiredChips = fFastOr;
128 for(Int_t ilayer=6;ilayer--;) fITSClusters[ilayer] = 0;
129}
130
32e449be 131//______________________________________________________________________
fe12e09c 132AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
133 TObject(m),
134 fNtracks(m.fNtracks),
cd888a89 135 fNsingle(m.fNsingle),
136 fLabels(0),
0939e22a 137 fLabelsL2(0),
34581d1e 138 fUsedClusS(0),
139 fUsedClusT(0),
fe12e09c 140 fTh(0),
141 fPhi(0),
fa9ed8e9 142 fDeltTh(0),
968e8539 143 fDeltPhi(0),
968e8539 144 fThsingle(0),
ff44c37c 145 fPhisingle(0),
d7c5c1e4 146 fLabelssingle(0),
adc4b00f 147 fFastOrFiredChips(1200),
ab37e14c 148 fClusterFiredChips(1200)
fe12e09c 149{
32e449be 150 // copy constructor
32e449be 151 Duplicate(m);
32e449be 152}
153
154//______________________________________________________________________
155AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
156 // assignment operator
157 if(this == &m)return *this;
158 ((TObject *)this)->operator=(m);
159
316c6cd9 160 if(fTh)delete [] fTh;fTh = 0;
161 if(fPhi)delete [] fPhi;fPhi = 0;
fa9ed8e9 162 if(fDeltTh)delete [] fDeltTh;fDeltTh= 0;
316c6cd9 163 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
164 if(fLabels)delete [] fLabels;fLabels = 0;
0939e22a 165 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
316c6cd9 166 if(fThsingle)delete [] fThsingle;fThsingle = 0;
167 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
d7c5c1e4 168 if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
34581d1e 169 if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
170 if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
171
32e449be 172 Duplicate(m);
173
174 return *this;
175}
176
732a24fe 177void AliMultiplicity::Copy(TObject &obj) const {
178
179 // this overwrites the virtual TOBject::Copy()
180 // to allow run time copying without casting
181 // in AliESDEvent
182
183 if(this==&obj)return;
184 AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
185 if(!robj)return; // not an AliMultiplicity
186 *robj = *this;
187
188}
189
190
32e449be 191//______________________________________________________________________
192void AliMultiplicity::Duplicate(const AliMultiplicity& m){
193 // used by copy constructor and assignment operator
194 fNtracks = m.fNtracks;
195 if(fNtracks>0){
cd888a89 196 fTh = new Double_t[fNtracks];
197 fPhi = new Double_t[fNtracks];
fa9ed8e9 198 fDeltTh = new Double_t[fNtracks];
cd888a89 199 fDeltPhi = new Double_t[fNtracks];
59ea252e 200 fLabels = new Int_t[fNtracks];
0939e22a 201 fLabelsL2 = new Int_t[fNtracks];
34581d1e 202 if (m.fUsedClusT) fUsedClusT = new ULong64_t[fNtracks];
203 else fUsedClusT = 0;
c8f37c50 204 if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
205 if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
206 if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
207 if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
208 if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
209 if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
210 if(fUsedClusT) memcpy(fUsedClusT,m.fUsedClusT,fNtracks*sizeof(ULong64_t));
32e449be 211 }
212 else {
213 fTh = 0;
214 fPhi = 0;
fa9ed8e9 215 fDeltTh = 0;
32e449be 216 fDeltPhi = 0;
59ea252e 217 fLabels = 0;
0939e22a 218 fLabelsL2 = 0;
32e449be 219 }
968e8539 220 fNsingle = m.fNsingle;
221 if(fNsingle>0){
cd888a89 222 fThsingle = new Double_t[fNsingle];
223 fPhisingle = new Double_t[fNsingle];
d7c5c1e4 224 fLabelssingle = new Int_t[fNsingle];
34581d1e 225 if (m.fUsedClusS) fUsedClusS = new UInt_t[fNsingle];
226 else fUsedClusS = 0;
c8f37c50 227 if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
228 if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
229 if(m.fLabelssingle)memcpy(fLabelssingle,m.fLabelssingle,fNsingle*sizeof(Int_t));
230 if(fUsedClusS) memcpy(fUsedClusS,m.fUsedClusS,fNsingle*sizeof(UInt_t));
968e8539 231 }
232 else {
233 fThsingle = 0;
234 fPhisingle = 0;
d7c5c1e4 235 fLabelssingle = 0;
968e8539 236 }
c8f37c50 237
ab37e14c 238 fFiredChips[0] = m.fFiredChips[0];
239 fFiredChips[1] = m.fFiredChips[1];
d325d83f 240 for(Int_t ilayer = 0; ilayer < 6; ilayer++){
241 fITSClusters[ilayer] = m.fITSClusters[ilayer];
242 }
d325d83f 243
ff44c37c 244 fFastOrFiredChips = m.fFastOrFiredChips;
ab37e14c 245 fClusterFiredChips = m.fClusterFiredChips;
32e449be 246}
247
248//______________________________________________________________________
249AliMultiplicity::~AliMultiplicity(){
250 // Destructor
316c6cd9 251 if(fTh)delete [] fTh;fTh = 0;
252 if(fPhi)delete [] fPhi;fPhi = 0;
fa9ed8e9 253 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
316c6cd9 254 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
255 if(fLabels)delete [] fLabels;fLabels = 0;
0939e22a 256 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
316c6cd9 257 if(fThsingle)delete [] fThsingle;fThsingle = 0;
258 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
d7c5c1e4 259 if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
34581d1e 260 if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
261 if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
32e449be 262}
56258350 263
1f9831ab 264//______________________________________________________________________
265void AliMultiplicity::Clear(Option_t*)
266{
267 // reset all
268 TObject::Clear();
269 if(fTh)delete [] fTh;fTh = 0;
270 if(fPhi)delete [] fPhi;fPhi = 0;
271 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
272 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
273 if(fLabels)delete [] fLabels;fLabels = 0;
274 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
275 if(fThsingle)delete [] fThsingle;fThsingle = 0;
276 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
d7c5c1e4 277 if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
34581d1e 278 if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
279 if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
1f9831ab 280 fNtracks = fNsingle = 0;
281 for (int i=6;i--;) fITSClusters[0] = 0;
282 fFiredChips[0] = fFiredChips[1] = 0;
283 fFastOrFiredChips.ResetAllBits(kTRUE);
284 fClusterFiredChips.ResetAllBits(kTRUE);
1f9831ab 285 //
286}
287
56258350 288//______________________________________________________________________
289void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
290{
291 if(i>=0 && i<fNtracks) {
292 if (layer == 0) {
293 fLabels[i] = label;
294 return;
295 } else if (layer == 1) {
296 if (fLabelsL2) {
297 fLabelsL2[i] = label;
298 return;
299 }
300 }
301 }
302 Error("SetLabel","Invalid track number %d or layer %d",i,layer);
303}
d325d83f 304
d7c5c1e4 305//______________________________________________________________________
306void AliMultiplicity::SetLabelSingle(Int_t i, Int_t label)
307{
308 if(i>=0 && i<fNsingle) {
309 if (fLabelssingle) {
310 fLabelssingle[i] = label;
311 return;
312 }
313 }
314 Error("SetLabelSingle","Invalid single cluster number %d",i);
315}
316
d325d83f 317//______________________________________________________________________
318UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
319
320 if(layMax < layMin) {
321 AliError("layer min > layer max");
322 return 0;
323 }
324 if(layMin < 0) {
325 AliError("layer min < 0");
326 return 0;
327 }
328 if(layMax < 0) {
329 AliError("layer max > 0");
330 return 0;
331 }
332
333 Int_t sum=0;
334 for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i];
335 return sum;
336
337}
1f9831ab 338
339//______________________________________________________________________
34581d1e 340void AliMultiplicity::SetTrackletData(Int_t id, const Float_t* tlet, UInt_t trSPD1, UInt_t trSPD2)
1f9831ab 341{
342 // fill tracklet data
343 if (id>=fNtracks) {AliError(Form("Number of declared tracklets %d < %d",fNtracks,id)); return;}
344 fTh[id] = tlet[0];
345 fPhi[id] = tlet[1];
346 fDeltPhi[id] = tlet[2];
347 fDeltTh[id] = tlet[3];
348 fLabels[id] = Int_t(tlet[4]);
34581d1e 349 fLabelsL2[id] = Int_t(tlet[5]);
350 fUsedClusT[id] = (((ULong64_t)trSPD2)<<32) + trSPD1;
1f9831ab 351 //
352}
353
354//______________________________________________________________________
34581d1e 355void AliMultiplicity::SetSingleClusterData(Int_t id, const Float_t* scl, UInt_t tr)
1f9831ab 356{
357 // fill single cluster data
358 if (id>=fNsingle) {AliError(Form("Number of declared singles %d < %d",fNsingle,id)); return;}
359 fThsingle[id] = scl[0];
360 fPhisingle[id] = scl[1];
d5ea8984 361 fLabelssingle[id] = Int_t(scl[2]);
34581d1e 362 fUsedClusS[id] = tr;
1f9831ab 363 //
364}
365
34581d1e 366//______________________________________________________________________
367Bool_t AliMultiplicity::FreeClustersTracklet(Int_t i, Int_t mode) const
368{
369 // 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
370 if (!fUsedClusT || mode<0 || mode>1 || i<0 || i>fNtracks) return kFALSE;
d5ea8984 371 const ULong64_t kMask0 = 0x0000ffff0000ffffLL;
372 const ULong64_t kMask1 = 0xffff0000ffff0000LL;
34581d1e 373 return (fUsedClusT[i]&(mode ? kMask1:kMask0)) == 0;
374}
375
376//______________________________________________________________________
377Bool_t AliMultiplicity::GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const
378{
379 // set spd1 and spd2 to ID's of the tracks using the clusters of the tracklet (-1 if not used)
380 // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
381 // return false if the neither of clusters is used
382 //
383 // note: stored value: [(idSAPureSPD2+1)<<16+(idTPCITS/SA_SPD2+1)]<<32 + [(idSAPureSPD1+1)<<16+(idTPCITS/SA_SPD1+1)]
384 if (!fUsedClusT || mode<0 || mode>1 || i<0 || i>fNtracks) {spd1 = spd2 = -1; return kFALSE;}
818d8482 385 //
d5ea8984 386 spd1 = (fUsedClusT[i]&0xffffffffLL);
34581d1e 387 spd2 = (fUsedClusT[i]>>32);
388 if (mode) {
389 spd1 >>= 16;
390 spd2 >>= 16;
391 }
392 else {
393 spd1 &= 0xffff;
394 spd2 &= 0xffff;
395 }
396 spd1--; // we are storing id+1
397 spd2--;
398 return !(spd1<0&&spd2<0);
399}
400
401//______________________________________________________________________
402Bool_t AliMultiplicity::FreeSingleCluster(Int_t i, Int_t mode) const
403{
404 // return kTRUE if the cluster was not used by the track of type mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure
405 if (!fUsedClusS || mode<0 || mode>1 || i<0 || i>fNsingle) return kFALSE;
406 const UInt_t kMask0 = 0x0000ffff;
407 const UInt_t kMask1 = 0xffff0000;
408 return (fUsedClusS[i]&(mode ? kMask1:kMask0)) == 0;
409}
410
411//______________________________________________________________________
412Bool_t AliMultiplicity::GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const
413{
414 // set tr to id of the track using the single clusters (-1 if not used)
415 // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
416 // return false if the cluster is not used
417 //
418 // note: stored value: [(idSAPure+1)<<16+(idTPCITS/SA+1)]
419 if (!fUsedClusS || mode<0 || mode>1 || i<0 || i>fNsingle) {tr = -1; return kFALSE;}
420 tr = fUsedClusS[i];
421 if (mode) tr >>= 16;
422 else tr &= 0xffff;
423 return (--tr)>=0; // we are storing id+1
424}
425
1f9831ab 426//______________________________________________________________________
427void AliMultiplicity::CompactBits()
428{
429 // sqeeze bit contrainers to minimum
430 fFastOrFiredChips.Compact();
431 fClusterFiredChips.Compact();
1f9831ab 432}
433
434//______________________________________________________________________
435void AliMultiplicity::Print(Option_t *opt) const
436{
437 // print
438 printf("N.tracklets: %4d N.singles: %4d\n",fNtracks,fNsingle);
439 TString opts = opt; opts.ToLower();
34581d1e 440 int t0spd1=-1,t1spd1=-1,t0spd2=-1,t1spd2=-1;
441 //
1f9831ab 442 if (opts.Contains("t")) {
34581d1e 443 for (int i=0;i<fNtracks;i++) {
444 GetTrackletTrackIDs(i,0,t0spd1,t0spd2);
445 GetTrackletTrackIDs(i,1,t1spd1,t1spd2);
c8122432 446 printf("T#%3d| Eta:%+5.2f Th:%+6.3f Phi:%+6.3f DTh:%+6.3f DPhi:%+6.3f L1:%6d L2:%6d U:L1[%5d/%5d] L2[%5d/%5d]\n",
34581d1e 447 i,GetEta(i),fTh[i],fPhi[i],fDeltTh[i],fDeltPhi[i],fLabels[i],fLabelsL2[i],t0spd1,t1spd1,t0spd2,t1spd2);
448 }
1f9831ab 449 }
450 if (opts.Contains("s")) {
34581d1e 451 for (int i=0;i<fNsingle;i++) {
452 GetSingleClusterTrackID(i,0,t0spd1);
453 GetSingleClusterTrackID(i,1,t1spd1);
c8122432 454 printf("S#%3d| Th:%+6.3f Phi:%+6.3f L:%6d U:[%5d/%5d]\n",
34581d1e 455 i,fThsingle[i],fPhisingle[i],fLabelssingle[i], t0spd1,t1spd1);
456 }
1f9831ab 457 }
458 //
459}