2 #include "AliMultiplicity.h"
5 ClassImp(AliMultiplicity)
7 //______________________________________________________________________
8 AliMultiplicity::AliMultiplicity():
23 fFastOrFiredChips(1200),
24 fClusterFiredChips(1200)
26 // Default Constructor
29 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
32 //______________________________________________________________________
33 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):
48 fFastOrFiredChips(1200),
49 fClusterFiredChips(1200)
51 // Standard constructor
53 fLabels = new Int_t[ntr];
54 fLabelsL2 = new Int_t[ntr];
55 fTh = new Double_t [ntr];
56 fPhi = new Double_t [ntr];
57 fDeltTh = new Double_t [ntr];
58 fDeltPhi = new Double_t [ntr];
59 for(Int_t i=0;i<fNtracks;i++){
64 fLabels[i] = labels[i];
65 fLabelsL2[i] = labelsL2[i];
69 fThsingle = new Double_t [ns];
70 fPhisingle = new Double_t [ns];
71 fLabelssingle = new Int_t [ns];
72 for(Int_t i=0;i<fNsingle;i++){
75 fLabelssingle[i]=labelss[i];
78 fFiredChips[0] = nfcL1;
79 fFiredChips[1] = nfcL2;
80 fFastOrFiredChips = fFastOr;
81 for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
84 //______________________________________________________________________
85 AliMultiplicity::AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr) :
100 fFastOrFiredChips(1200),
101 fClusterFiredChips(1200)
103 // Standard constructor to create the arrays w/o filling
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];
111 fUsedClusT = new ULong64_t[ntr];
113 for(Int_t i=fNtracks;i--;){
114 fTh[i]=fPhi[i]=fDeltTh[i]=fDeltPhi[i] = 0;
115 fLabels[i] = fLabelsL2[i] = 0;
119 fThsingle = new Double_t [ns];
120 fPhisingle = new Double_t [ns];
121 fLabelssingle = new Int_t [ns];
122 fUsedClusS = new UInt_t[ns];
123 for(Int_t i=fNsingle;i--;) fThsingle[i] = fPhisingle[i] = fLabelssingle[i] = 0;
125 fFiredChips[0] = nfcL1;
126 fFiredChips[1] = nfcL2;
127 fFastOrFiredChips = fFastOr;
128 for(Int_t ilayer=6;ilayer--;) fITSClusters[ilayer] = 0;
131 //______________________________________________________________________
132 AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
134 fNtracks(m.fNtracks),
135 fNsingle(m.fNsingle),
147 fFastOrFiredChips(1200),
148 fClusterFiredChips(1200)
154 //______________________________________________________________________
155 AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
156 // assignment operator
157 if(this == &m)return *this;
158 ((TObject *)this)->operator=(m);
160 if(fTh)delete [] fTh;fTh = 0;
161 if(fPhi)delete [] fPhi;fPhi = 0;
162 if(fDeltTh)delete [] fDeltTh;fDeltTh= 0;
163 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
164 if(fLabels)delete [] fLabels;fLabels = 0;
165 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
166 if(fThsingle)delete [] fThsingle;fThsingle = 0;
167 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
168 if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
169 if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
170 if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
177 void AliMultiplicity::Copy(TObject &obj) const {
179 // this overwrites the virtual TOBject::Copy()
180 // to allow run time copying without casting
183 if(this==&obj)return;
184 AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
185 if(!robj)return; // not an AliMultiplicity
191 //______________________________________________________________________
192 void AliMultiplicity::Duplicate(const AliMultiplicity& m){
193 // used by copy constructor and assignment operator
194 fNtracks = m.fNtracks;
196 fTh = new Double_t[fNtracks];
197 fPhi = new Double_t[fNtracks];
198 fDeltTh = new Double_t[fNtracks];
199 fDeltPhi = new Double_t[fNtracks];
200 fLabels = new Int_t[fNtracks];
201 fLabelsL2 = new Int_t[fNtracks];
202 if (m.fUsedClusT) fUsedClusT = new ULong64_t[fNtracks];
213 fNsingle = m.fNsingle;
215 fThsingle = new Double_t[fNsingle];
216 fPhisingle = new Double_t[fNsingle];
217 fLabelssingle = new Int_t[fNsingle];
218 if (m.fUsedClusS) fUsedClusS = new UInt_t[fNsingle];
226 if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
227 if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
228 if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
229 if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
230 if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
231 if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
232 if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
233 if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
234 if(m.fLabelssingle)memcpy(fLabelssingle,m.fLabelssingle,fNsingle*sizeof(Int_t));
235 if(fUsedClusS) memcpy(fUsedClusS,m.fUsedClusS,fNsingle*sizeof(UInt_t));
236 if(fUsedClusT) memcpy(fUsedClusT,m.fUsedClusT,fNtracks*sizeof(ULong64_t));
237 fFiredChips[0] = m.fFiredChips[0];
238 fFiredChips[1] = m.fFiredChips[1];
239 for(Int_t ilayer = 0; ilayer < 6; ilayer++){
240 fITSClusters[ilayer] = m.fITSClusters[ilayer];
243 fFastOrFiredChips = m.fFastOrFiredChips;
244 fClusterFiredChips = m.fClusterFiredChips;
247 //______________________________________________________________________
248 AliMultiplicity::~AliMultiplicity(){
250 if(fTh)delete [] fTh;fTh = 0;
251 if(fPhi)delete [] fPhi;fPhi = 0;
252 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
253 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
254 if(fLabels)delete [] fLabels;fLabels = 0;
255 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
256 if(fThsingle)delete [] fThsingle;fThsingle = 0;
257 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
258 if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
259 if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
260 if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
263 //______________________________________________________________________
264 void AliMultiplicity::Clear(Option_t*)
268 if(fTh)delete [] fTh;fTh = 0;
269 if(fPhi)delete [] fPhi;fPhi = 0;
270 if(fDeltTh)delete [] fDeltTh;fDeltTh = 0;
271 if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0;
272 if(fLabels)delete [] fLabels;fLabels = 0;
273 if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
274 if(fThsingle)delete [] fThsingle;fThsingle = 0;
275 if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
276 if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
277 if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
278 if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
279 fNtracks = fNsingle = 0;
280 for (int i=6;i--;) fITSClusters[0] = 0;
281 fFiredChips[0] = fFiredChips[1] = 0;
282 fFastOrFiredChips.ResetAllBits(kTRUE);
283 fClusterFiredChips.ResetAllBits(kTRUE);
287 //______________________________________________________________________
288 void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
290 if(i>=0 && i<fNtracks) {
294 } else if (layer == 1) {
296 fLabelsL2[i] = label;
301 Error("SetLabel","Invalid track number %d or layer %d",i,layer);
304 //______________________________________________________________________
305 void AliMultiplicity::SetLabelSingle(Int_t i, Int_t label)
307 if(i>=0 && i<fNsingle) {
309 fLabelssingle[i] = label;
313 Error("SetLabelSingle","Invalid single cluster number %d",i);
316 //______________________________________________________________________
317 UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
319 if(layMax < layMin) {
320 AliError("layer min > layer max");
324 AliError("layer min < 0");
328 AliError("layer max > 0");
333 for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i];
338 //______________________________________________________________________
339 void AliMultiplicity::SetTrackletData(Int_t id, const Float_t* tlet, UInt_t trSPD1, UInt_t trSPD2)
341 // fill tracklet data
342 if (id>=fNtracks) {AliError(Form("Number of declared tracklets %d < %d",fNtracks,id)); return;}
345 fDeltPhi[id] = tlet[2];
346 fDeltTh[id] = tlet[3];
347 fLabels[id] = Int_t(tlet[4]);
348 fLabelsL2[id] = Int_t(tlet[5]);
349 fUsedClusT[id] = (((ULong64_t)trSPD2)<<32) + trSPD1;
350 printf("(%d %d)(%d %d)\n",trSPD1&0xffff,trSPD1>>16, trSPD2&0xffff, trSPD2>>16);
354 //______________________________________________________________________
355 void AliMultiplicity::SetSingleClusterData(Int_t id, const Float_t* scl, UInt_t tr)
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];
361 fLabelssingle[id] = scl[2];
366 //______________________________________________________________________
367 Bool_t AliMultiplicity::FreeClustersTracklet(Int_t i, Int_t mode) const
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;
371 const ULong64_t kMask0 = 0x0000ffff0000ffff;
372 const ULong64_t kMask1 = 0xffff0000ffff0000;
373 return (fUsedClusT[i]&(mode ? kMask1:kMask0)) == 0;
376 //______________________________________________________________________
377 Bool_t AliMultiplicity::GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const
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
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;}
385 spd1 = (fUsedClusT[i]&0xffffffff);
386 spd2 = (fUsedClusT[i]>>32);
395 spd1--; // we are storing id+1
397 return !(spd1<0&&spd2<0);
400 //______________________________________________________________________
401 Bool_t AliMultiplicity::FreeSingleCluster(Int_t i, Int_t mode) const
403 // return kTRUE if the cluster was not used by the track of type mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure
404 if (!fUsedClusS || mode<0 || mode>1 || i<0 || i>fNsingle) return kFALSE;
405 const UInt_t kMask0 = 0x0000ffff;
406 const UInt_t kMask1 = 0xffff0000;
407 return (fUsedClusS[i]&(mode ? kMask1:kMask0)) == 0;
410 //______________________________________________________________________
411 Bool_t AliMultiplicity::GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const
413 // set tr to id of the track using the single clusters (-1 if not used)
414 // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
415 // return false if the cluster is not used
417 // note: stored value: [(idSAPure+1)<<16+(idTPCITS/SA+1)]
418 if (!fUsedClusS || mode<0 || mode>1 || i<0 || i>fNsingle) {tr = -1; return kFALSE;}
422 return (--tr)>=0; // we are storing id+1
425 //______________________________________________________________________
426 void AliMultiplicity::CompactBits()
428 // sqeeze bit contrainers to minimum
429 fFastOrFiredChips.Compact();
430 fClusterFiredChips.Compact();
433 //______________________________________________________________________
434 void AliMultiplicity::Print(Option_t *opt) const
437 printf("N.tracklets: %4d N.singles: %4d\n",fNtracks,fNsingle);
438 TString opts = opt; opts.ToLower();
439 int t0spd1=-1,t1spd1=-1,t0spd2=-1,t1spd2=-1;
441 if (opts.Contains("t")) {
442 for (int i=0;i<fNtracks;i++) {
443 GetTrackletTrackIDs(i,0,t0spd1,t0spd2);
444 GetTrackletTrackIDs(i,1,t1spd1,t1spd2);
445 printf("T#%3d| Eta:%+5.2f Th:%+6.3f Phi:%+6.3f DTh:%+6.3f DPhi:%+6.3f L1:%4d L2:%4d U:L1[%5d/%5d] L2[%5d/%5d]\n",
446 i,GetEta(i),fTh[i],fPhi[i],fDeltTh[i],fDeltPhi[i],fLabels[i],fLabelsL2[i],t0spd1,t1spd1,t0spd2,t1spd2);
449 if (opts.Contains("s")) {
450 for (int i=0;i<fNsingle;i++) {
451 GetSingleClusterTrackID(i,0,t0spd1);
452 GetSingleClusterTrackID(i,1,t1spd1);
453 printf("S#%3d| Th:%+6.3f Phi:%+6.3f L:%4d U:[%5d/%5d]\n",
454 i,fThsingle[i],fPhisingle[i],fLabelssingle[i], t0spd1,t1spd1);