]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMultiplicity.cxx
Typo fixed.
[u/mrichter/AliRoot.git] / STEER / AliMultiplicity.cxx
1 #include <string.h>
2 #include "AliMultiplicity.h"
3 #include "AliLog.h"
4
5 ClassImp(AliMultiplicity)
6
7 //______________________________________________________________________
8 AliMultiplicity::AliMultiplicity():
9   TObject(),
10   fNtracks(0),
11   fNsingle(0),
12   fLabels(0),
13   fLabelsL2(0),
14   fTh(0),
15   fPhi(0),
16   fDeltTh(0),
17   fDeltPhi(0),
18   fThsingle(0),
19   fPhisingle(0),
20   fFastOrFiredChips(1200),
21   fClusterFiredChips(1200)
22 {
23   // Default Constructor
24   fFiredChips[0] = 0;
25   fFiredChips[1] = 0;
26   for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
27 }
28
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):
31   TObject(),
32   fNtracks(ntr),
33   fNsingle(ns),
34   fLabels(0),
35   fLabelsL2(0),
36   fTh(0),
37   fPhi(0),
38   fDeltTh(0),
39   fDeltPhi(0),
40   fThsingle(0),
41   fPhisingle(0),
42   fFastOrFiredChips(1200),
43   fClusterFiredChips(1200)
44 {
45 // Standard constructor
46   if(ntr>0){
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++){
54       fTh[i]=th[i];
55       fPhi[i]=ph[i];
56       fDeltTh[i]=dth[i];
57       fDeltPhi[i]=dph[i];
58       fLabels[i] = labels[i];
59       fLabelsL2[i] = labelsL2[i];
60     }
61   }
62   if(ns>0){
63     fThsingle = new Double_t [ns];
64     fPhisingle = new Double_t [ns];
65     for(Int_t i=0;i<fNsingle;i++){
66       fThsingle[i]=ts[i];
67       fPhisingle[i]=ps[i];
68     }
69   }
70   fFiredChips[0] = nfcL1;
71   fFiredChips[1] = nfcL2;
72   fFastOrFiredChips = fFastOr;
73   for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
74 }
75
76 //______________________________________________________________________
77 AliMultiplicity::AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr) :
78   TObject(),
79   fNtracks(ntr),
80   fNsingle(ns),
81   fLabels(0),
82   fLabelsL2(0),
83   fTh(0),
84   fPhi(0),
85   fDeltTh(0),
86   fDeltPhi(0),
87   fThsingle(0),
88   fPhisingle(0),
89   fFastOrFiredChips(1200),
90   fClusterFiredChips(1200)
91 {
92   // Standard constructor to create the arrays w/o filling
93   if(ntr>0){
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;
103     }
104   }
105   if(ns>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;
109   }
110   fFiredChips[0] = nfcL1;
111   fFiredChips[1] = nfcL2;
112   fFastOrFiredChips = fFastOr;
113   for(Int_t ilayer=6;ilayer--;) fITSClusters[ilayer] = 0;
114 }
115
116 //______________________________________________________________________
117 AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
118   TObject(m),
119   fNtracks(m.fNtracks),
120   fNsingle(m.fNsingle),
121   fLabels(0),
122   fLabelsL2(0),
123   fTh(0),
124   fPhi(0),
125   fDeltTh(0),
126   fDeltPhi(0),
127   fThsingle(0),
128   fPhisingle(0),
129   fFastOrFiredChips(1200),
130   fClusterFiredChips(1200)
131 {
132   // copy constructor
133   Duplicate(m);
134 }
135
136 //______________________________________________________________________
137 AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
138   // assignment operator
139   if(this == &m)return *this;
140   ((TObject *)this)->operator=(m);
141
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;
150   Duplicate(m);
151
152   return *this;
153 }
154
155 void AliMultiplicity::Copy(TObject &obj) const {
156   
157   // this overwrites the virtual TOBject::Copy()
158   // to allow run time copying without casting
159   // in AliESDEvent
160
161   if(this==&obj)return;
162   AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
163   if(!robj)return; // not an AliMultiplicity
164   *robj = *this;
165
166 }
167
168
169 //______________________________________________________________________
170 void AliMultiplicity::Duplicate(const AliMultiplicity& m){
171   // used by copy constructor and assignment operator
172   fNtracks = m.fNtracks;
173   if(fNtracks>0){
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];
180   }
181   else {
182     fTh = 0;
183     fPhi = 0;
184     fDeltTh = 0;
185     fDeltPhi = 0;
186     fLabels = 0;
187     fLabelsL2 = 0;
188   }
189   fNsingle = m.fNsingle;
190   if(fNsingle>0){
191     fThsingle = new Double_t[fNsingle];
192     fPhisingle = new Double_t[fNsingle];
193   }
194   else {
195     fThsingle = 0;
196     fPhisingle = 0;
197   }
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));
206
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];
211   }
212
213   fUsedClusT[0] = m.fUsedClusT[0];
214   fUsedClusT[1] = m.fUsedClusT[1];
215   fUsedClusS[0] = m.fUsedClusS[0];
216   fUsedClusS[1] = m.fUsedClusS[1];
217   
218   fFastOrFiredChips = m.fFastOrFiredChips;
219   fClusterFiredChips = m.fClusterFiredChips;
220 }
221
222 //______________________________________________________________________
223 AliMultiplicity::~AliMultiplicity(){
224   // Destructor
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;
233
234 }
235
236 //______________________________________________________________________
237 void AliMultiplicity::Clear(Option_t*)
238 {
239   // reset all
240   TObject::Clear();
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);
258   //
259 }
260
261 //______________________________________________________________________
262 void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
263 {
264     if(i>=0 && i<fNtracks) {
265         if (layer == 0) {
266             fLabels[i] = label;
267             return;
268         } else if (layer == 1) {
269             if (fLabelsL2) {
270                 fLabelsL2[i] = label;
271                 return;
272             }
273         }
274     }
275     Error("SetLabel","Invalid track number %d or layer %d",i,layer);
276 }
277
278 //______________________________________________________________________
279 UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
280
281   if(layMax < layMin) {
282     AliError("layer min > layer max");
283     return 0;
284   }
285   if(layMin < 0) {
286     AliError("layer min < 0");
287     return 0;
288   }
289   if(layMax < 0) {
290     AliError("layer max > 0");
291     return 0;
292   }
293
294   Int_t sum=0; 
295   for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i]; 
296   return sum; 
297
298 }
299
300 //______________________________________________________________________
301 void AliMultiplicity::SetTrackletData(Int_t id, const Float_t* tlet, UInt_t bits)
302 {
303   // fill tracklet data
304   if (id>=fNtracks) {AliError(Form("Number of declared tracklets %d < %d",fNtracks,id)); return;}
305   fTh[id]      = tlet[0];
306   fPhi[id]     = tlet[1];
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);
313   //
314 }
315
316 //______________________________________________________________________
317 void AliMultiplicity::SetSingleClusterData(Int_t id, const Float_t* scl, UInt_t bits)
318 {
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);
325   //
326 }
327
328 //______________________________________________________________________
329 void AliMultiplicity::CompactBits()
330 {
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();
338 }
339
340 //______________________________________________________________________
341 void AliMultiplicity::Print(Option_t *opt) const
342 {
343   // print
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));
351   }
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));
357   }
358   //
359 }