Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : /* $Id$ */
17 :
18 : //-------------------------------------------------------------------------
19 : // AOD class to store tracklets
20 : // Author: Jan Fiete Grosse-Oetringhaus, CERN
21 : // Class created from AliMultiplicity
22 : //-------------------------------------------------------------------------
23 :
24 : #include <TString.h>
25 : #include "AliAODTracklets.h"
26 :
27 170 : ClassImp(AliAODTracklets)
28 :
29 : AliAODTracklets::AliAODTracklets()
30 4 : : AliVMultiplicity(), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0), fLabelsL2(0)
31 4 : ,fFastOrFiredChips(),fClusterFiredChips()
32 10 : {
33 2 : fFiredChips[0] = fFiredChips[1] = 0;
34 28 : for (int i=6;i--;) fITSClusters[i] = 0;
35 : // default constructor
36 4 : }
37 :
38 : AliAODTracklets::AliAODTracklets(const char* name, const char* title)
39 0 : : AliVMultiplicity(name, title), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0), fLabelsL2(0)
40 0 : , fFastOrFiredChips(),fClusterFiredChips()
41 0 : {
42 : // Named constructor
43 0 : fFiredChips[0] = fFiredChips[1] = 0;
44 0 : for (int i=6;i--;) fITSClusters[i] = 0;
45 0 : }
46 :
47 : AliAODTracklets::AliAODTracklets(const AliAODTracklets& tracklet) :
48 0 : AliVMultiplicity(tracklet),
49 0 : fNTracks(tracklet.fNTracks),
50 0 : fTheta(0),
51 0 : fPhi(0),
52 0 : fDeltaPhi(0),
53 0 : fLabels(0),
54 0 : fLabelsL2(0),
55 0 : fFastOrFiredChips(tracklet.fFastOrFiredChips),fClusterFiredChips(tracklet.fClusterFiredChips)
56 0 : {
57 : // Copy constructor
58 0 : fTheta = new Double32_t[fNTracks];
59 0 : fPhi = new Double32_t[fNTracks];
60 0 : fDeltaPhi = new Double32_t[fNTracks];
61 0 : fLabels = new Int_t[fNTracks];
62 0 : fLabelsL2 = new Int_t[fNTracks];
63 0 : for (Int_t i = 0; i < fNTracks; i++) {
64 0 : fTheta[i] = tracklet.fTheta[i];
65 0 : fPhi[i] = tracklet.fPhi[i];
66 0 : fDeltaPhi[i] = tracklet.fDeltaPhi[i];
67 0 : fLabels[i] = tracklet.fLabels[i];
68 0 : fLabelsL2[i] = tracklet.fLabelsL2[i];
69 : }
70 0 : fFiredChips[0] = tracklet.fFiredChips[0];
71 0 : fFiredChips[1] = tracklet.fFiredChips[1];
72 0 : for (int i=6;i--;) fITSClusters[i] = tracklet.fITSClusters[i];
73 0 : }
74 :
75 : AliAODTracklets& AliAODTracklets::operator=(const AliAODTracklets& tracklet)
76 : {
77 : // Assignment operator
78 0 : if(&tracklet == this) return *this;
79 0 : AliVMultiplicity::operator=(tracklet);
80 0 : if(fNTracks!=tracklet.fNTracks){
81 0 : fNTracks = tracklet.fNTracks;
82 0 : CreateContainer(fNTracks);
83 0 : }
84 0 : for (Int_t i = 0; i < fNTracks; i++) {
85 0 : fTheta[i] = tracklet.fTheta[i];
86 0 : fPhi[i] = tracklet.fPhi[i];
87 0 : fDeltaPhi[i] = tracklet.fDeltaPhi[i];
88 0 : fLabels[i] = tracklet.fLabels[i];
89 0 : fLabelsL2[i] = tracklet.fLabelsL2[i];
90 : }
91 0 : fFiredChips[0] = tracklet.fFiredChips[0];
92 0 : fFiredChips[1] = tracklet.fFiredChips[1];
93 0 : fFastOrFiredChips = tracklet.fFastOrFiredChips;
94 0 : fClusterFiredChips = tracklet.fClusterFiredChips;
95 0 : for (int i=6;i--;) fITSClusters[i] = tracklet.fITSClusters[i];
96 0 : return *this;
97 0 : }
98 :
99 : void AliAODTracklets::CreateContainer(Int_t nTracks)
100 : {
101 : // function that creates container to store tracklets
102 :
103 16 : DeleteContainer();
104 :
105 8 : fNTracks = nTracks;
106 :
107 8 : if (fNTracks <= 0) {
108 0 : fNTracks = 0;
109 0 : return;
110 : }
111 :
112 8 : fTheta = new Double32_t[fNTracks];
113 8 : fPhi = new Double32_t[fNTracks];
114 8 : fDeltaPhi = new Double32_t[fNTracks];
115 8 : fLabels = new Int_t[fNTracks];
116 8 : fLabelsL2 = new Int_t[fNTracks];
117 16 : }
118 :
119 :
120 : AliAODTracklets::~AliAODTracklets()
121 0 : {
122 : // destructor
123 :
124 0 : DeleteContainer();
125 0 : }
126 :
127 : void AliAODTracklets::DeleteContainer()
128 : {
129 : // deletes allocated memory
130 48 : if (fTheta)
131 : {
132 16 : delete[] fTheta;
133 8 : fTheta = 0;
134 8 : }
135 :
136 24 : if (fPhi)
137 : {
138 16 : delete[] fPhi;
139 8 : fPhi = 0;
140 8 : }
141 :
142 24 : if (fDeltaPhi)
143 : {
144 16 : delete[] fDeltaPhi;
145 8 : fDeltaPhi = 0;
146 8 : }
147 :
148 24 : if (fLabels)
149 : {
150 16 : delete[] fLabels;
151 8 : fLabels = 0;
152 8 : }
153 :
154 24 : if (fLabelsL2)
155 : {
156 16 : delete[] fLabelsL2;
157 8 : fLabelsL2 = 0;
158 8 : }
159 :
160 24 : fNTracks = 0;
161 24 : }
162 :
163 : Bool_t AliAODTracklets::SetTracklet(Int_t pos, Double32_t theta, Double32_t phi, Double32_t deltaPhi, Int_t labelL1, Int_t labelL2)
164 : {
165 : // Sets a tracklet at the given position
166 :
167 144 : if (pos < 0 || pos >= fNTracks)
168 0 : return kFALSE;
169 :
170 48 : fTheta[pos] = theta;
171 48 : fPhi[pos] = phi;
172 48 : fDeltaPhi[pos] = deltaPhi;
173 48 : fLabels[pos] = labelL1;
174 48 : fLabelsL2[pos] = labelL2;
175 :
176 48 : return kTRUE;
177 48 : }
178 :
179 : //______________________________________________________________________
180 : void AliAODTracklets::Print(Option_t *opt) const
181 : {
182 : // print
183 0 : printf("N.tracklets: %4d | ScaleDThtSin2T:%s\n",fNTracks,GetScaleDThetaBySin2T() ? "ON":"OFF");
184 0 : TString opts = opt; opts.ToLower();
185 : //
186 0 : if (opts.Contains("t")) {
187 0 : for (int i=0;i<fNTracks;i++) {
188 0 : printf("T#%3d| Eta:%+5.2f Th:%+6.3f Phi:%+6.3f DPhi:%+6.3f L1:%5d L2:%5d\n",
189 0 : i,GetEta(i),fTheta[i],fPhi[i],fDeltaPhi[i],fLabels[i],fLabelsL2[i]);
190 : }
191 0 : }
192 : //
193 0 : }
194 :
195 : //________________________________________________________________
196 : void AliAODTracklets::SetLabel(Int_t i, Int_t layer,Int_t label)
197 : {
198 : // set labels
199 144 : if (i>=0 && i<fNTracks)
200 : {
201 72 : if(layer == 0) fLabels[i] = label;
202 24 : else fLabelsL2[i] = label;
203 : }
204 48 : }
205 :
206 : //________________________________________________________________
207 : Int_t AliAODTracklets::GetLabel(Int_t i, Int_t layer) const
208 : {
209 : // access labels
210 144 : if (i>=0 && i<fNTracks)
211 : {
212 144 : return (layer == 0) ? fLabels[i] : fLabelsL2[i];
213 : }
214 : else
215 0 : Error("GetLabel","Invalid track number %d",i); return -9999;
216 48 : }
217 :
218 : //________________________________________________________________
219 : Double_t AliAODTracklets::GetTheta(Int_t i) const
220 : {
221 : // access theta's
222 0 : if (i>=0 && i<fNTracks)
223 : {
224 0 : return fTheta[i];
225 : }
226 : else
227 0 : Error("GetTheta","Invalid track number %d",i); return -9999.;
228 0 : }
229 :
230 : //________________________________________________________________
231 : Double_t AliAODTracklets::GetPhi(Int_t i) const
232 : {
233 : // access phi's
234 0 : if (i>=0 && i<fNTracks)
235 : {
236 0 : return fPhi[i];
237 : }
238 : else
239 0 : Error("GetPhi","Invalid track number %d",i); return -9999.;
240 0 : }
241 :
242 : //________________________________________________________________
243 : Double_t AliAODTracklets::GetDeltaPhi(Int_t i) const
244 : {
245 : // access delta phi's
246 0 : if (i>=0 && i<fNTracks)
247 : {
248 0 : return fDeltaPhi[i];
249 : }
250 : else
251 0 : Error("GetDeltaPhi","Invalid track number %d",i); return -9999.;
252 0 : }
|