]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMultiplicity.cxx
In MUONRecoCheck.C:
[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(const AliMultiplicity& m):
78   TObject(m),
79   fNtracks(m.fNtracks),
80   fNsingle(m.fNsingle),
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   // copy constructor
93   Duplicate(m);
94 }
95
96 //______________________________________________________________________
97 AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
98   // assignment operator
99   if(this == &m)return *this;
100   ((TObject *)this)->operator=(m);
101
102   if(fTh)delete [] fTh;fTh = 0;
103   if(fPhi)delete [] fPhi;fPhi = 0; 
104   if(fDeltTh)delete [] fDeltTh;fDeltTh= 0; 
105   if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; 
106   if(fLabels)delete [] fLabels;fLabels = 0;
107   if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
108   if(fThsingle)delete [] fThsingle;fThsingle = 0;
109   if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
110   Duplicate(m);
111
112   return *this;
113 }
114
115 void AliMultiplicity::Copy(TObject &obj) const {
116   
117   // this overwrites the virtual TOBject::Copy()
118   // to allow run time copying without casting
119   // in AliESDEvent
120
121   if(this==&obj)return;
122   AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
123   if(!robj)return; // not an AliMultiplicity
124   *robj = *this;
125
126 }
127
128
129 //______________________________________________________________________
130 void AliMultiplicity::Duplicate(const AliMultiplicity& m){
131   // used by copy constructor and assignment operator
132   fNtracks = m.fNtracks;
133   if(fNtracks>0){
134     fTh = new Double_t[fNtracks];
135     fPhi = new Double_t[fNtracks];
136     fDeltTh = new Double_t[fNtracks];
137     fDeltPhi = new Double_t[fNtracks];
138     fLabels = new Int_t[fNtracks];
139     fLabelsL2 = new Int_t[fNtracks];
140   }
141   else {
142     fTh = 0;
143     fPhi = 0;
144     fDeltTh = 0;
145     fDeltPhi = 0;
146     fLabels = 0;
147     fLabelsL2 = 0;
148   }
149   fNsingle = m.fNsingle;
150   if(fNsingle>0){
151     fThsingle = new Double_t[fNsingle];
152     fPhisingle = new Double_t[fNsingle];
153   }
154   else {
155     fThsingle = 0;
156     fPhisingle = 0;
157   }
158   if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
159   if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
160   if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
161   if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
162   if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
163   if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
164   if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
165   if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
166
167   fFiredChips[0] = m.fFiredChips[0];
168   fFiredChips[1] = m.fFiredChips[1];
169   for(Int_t ilayer = 0; ilayer < 6; ilayer++){
170     fITSClusters[ilayer] = m.fITSClusters[ilayer];
171   }
172
173   
174
175   fFastOrFiredChips = m.fFastOrFiredChips;
176   fClusterFiredChips = m.fClusterFiredChips;
177 }
178
179 //______________________________________________________________________
180 AliMultiplicity::~AliMultiplicity(){
181   // Destructor
182   if(fTh)delete [] fTh;fTh = 0;
183   if(fPhi)delete [] fPhi;fPhi = 0; 
184   if(fDeltTh)delete [] fDeltTh;fDeltTh = 0; 
185   if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; 
186   if(fLabels)delete [] fLabels;fLabels = 0;
187   if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
188   if(fThsingle)delete [] fThsingle;fThsingle = 0;
189   if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
190
191 }
192
193 //______________________________________________________________________
194 void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
195 {
196     if(i>=0 && i<fNtracks) {
197         if (layer == 0) {
198             fLabels[i] = label;
199             return;
200         } else if (layer == 1) {
201             if (fLabelsL2) {
202                 fLabelsL2[i] = label;
203                 return;
204             }
205         }
206     }
207     Error("SetLabel","Invalid track number %d or layer %d",i,layer);
208 }
209
210 //______________________________________________________________________
211 UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
212
213   if(layMax < layMin) {
214     AliError("layer min > layer max");
215     return 0;
216   }
217   if(layMin < 0) {
218     AliError("layer min < 0");
219     return 0;
220   }
221   if(layMax < 0) {
222     AliError("layer max > 0");
223     return 0;
224   }
225
226   Int_t sum=0; 
227   for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i]; 
228   return sum; 
229
230 }