]>
Commit | Line | Data |
---|---|---|
251a2c81 | 1 | /* $Id$ */ |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Author: The ALICE Off-line Project. * | |
7 | * Contributors are mentioned in the code where appropriate. * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /** | |
19 | * >> Flat structure representing an ESDTrack << | |
20 | * | |
21 | * To be used in the online and offline calibration schema. | |
22 | * | |
23 | * Class provides interface methods for | |
24 | * - Filling from AliESDtrack and AliExternalTrackParam, as well | |
25 | * as clusters from ESD friends (if requested) | |
26 | * - HLT Filling to be added | |
27 | * | |
28 | * | |
29 | * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli | |
30 | * | |
31 | **************************************************************************/ | |
32 | ||
33 | #include "TObject.h" | |
34 | ||
35 | #include "AliESDEvent.h" | |
36 | #include "AliESDtrack.h" | |
37 | #include "AliESDfriendTrack.h" | |
38 | #include "AliExternalTrackParam.h" | |
39 | #include "AliTPCseed.h" | |
40 | #include "AliTPCclusterMI.h" | |
41 | ||
42 | #include "AliFlatESDEvent.h" | |
43 | #include "AliFlatESDTrack.h" | |
44 | #include "Riostream.h" | |
45 | ||
46 | // _______________________________________________________________________________________________________ | |
47 | AliFlatESDTrack::AliFlatESDTrack() : | |
48 | // Default constructor | |
49 | fTrackParamMask(0), | |
50 | fNTPCClusters(0), | |
51 | fNITSClusters(0), | |
52 | ||
53 | fSize(0), | |
54 | fContent() { | |
55 | ||
56 | } | |
57 | ||
8fcd8556 | 58 | // _______________________________________________________________________________________________________ |
f009a562 | 59 | AliFlatESDTrack::AliFlatESDTrack(AliFlatESDSpecialConstructorFlag f) |
8fcd8556 | 60 | { |
61 | //special contructor | |
62 | //use to restore the vtable pointer | |
63 | ||
f009a562 | 64 | if(f == AliFlatESDReinitialize){ |
65 | AliFlatExternalTrackParam* trackParam = GetTrackParamRefitted(); | |
66 | if (trackParam) { new (trackParam) AliFlatExternalTrackParam(f); } | |
67 | trackParam = GetTrackParamIp(); | |
68 | if (trackParam) { new (trackParam) AliFlatExternalTrackParam(f); } | |
69 | trackParam = GetTrackParamTPCInner(); | |
70 | if (trackParam) { new (trackParam) AliFlatExternalTrackParam(f); } | |
71 | trackParam = GetTrackParamOp(); | |
72 | if (trackParam) { new (trackParam) AliFlatExternalTrackParam(f); } | |
73 | trackParam = GetTrackParamCp(); | |
74 | if (trackParam) { new (trackParam) AliFlatExternalTrackParam(f); } | |
75 | trackParam = GetTrackParamITSOut(); | |
76 | if (trackParam) { new (trackParam) AliFlatExternalTrackParam(f); } | |
77 | ||
78 | AliFlatTPCCluster* clusterTPC = GetTPCClusters(); | |
79 | for (Int_t i=0; i<fNTPCClusters; i++) | |
80 | new (clusterTPC++) AliFlatTPCCluster(f); | |
81 | } | |
82 | else AliFlatESDTrack(); | |
8fcd8556 | 83 | } |
84 | ||
251a2c81 | 85 | // _______________________________________________________________________________________________________ |
86 | AliFlatESDTrack::AliFlatESDTrack(const AliESDtrack* track, AliESDfriendTrack* friendTrack) : | |
87 | // Constructor | |
88 | fTrackParamMask(0), | |
89 | fNTPCClusters(0), | |
90 | fNITSClusters(0), | |
91 | fSize(0), | |
92 | fContent() { | |
93 | ||
94 | Fill(track, friendTrack); | |
95 | } | |
96 | ||
97 | // _______________________________________________________________________________________________________ | |
98 | AliFlatESDTrack::~AliFlatESDTrack() { | |
99 | // Destructor | |
100 | ||
101 | } | |
102 | ||
103 | // _______________________________________________________________________________________________________ | |
104 | ULong64_t AliFlatESDTrack::EstimateSize(Bool_t useESDFriends, Int_t nTPCClusters ) { | |
105 | // Estimate upper limit of the object size | |
106 | // -> Added objects have to be added here as well | |
107 | ||
108 | ULong64_t size = sizeof(AliFlatESDTrack) + (6*sizeof(AliFlatExternalTrackParam)); | |
109 | ||
110 | if (useESDFriends){ | |
111 | size += nTPCClusters*sizeof(AliFlatTPCCluster); | |
112 | } | |
113 | return size; | |
114 | } | |
115 | ||
116 | ||
117 | // _______________________________________________________________________________________________________ | |
118 | Int_t AliFlatESDTrack::Fill(const AliESDtrack* track, AliESDfriendTrack* friendTrack){ | |
119 | // Fill external track parameters and friendTrack | |
120 | ||
121 | fTrackParamMask = 0; | |
122 | fNTPCClusters = 0; | |
123 | fNITSClusters = 0; | |
124 | fSize = 0; | |
125 | ||
126 | if( !track ) return 0; | |
127 | ||
128 | const AliExternalTrackParam *itsOut = 0; | |
129 | if (friendTrack) itsOut = friendTrack->GetITSOut(); | |
130 | ||
131 | Int_t iResult = FillExternalTrackParam( track, | |
132 | track->GetInnerParam(), | |
133 | track->GetTPCInnerParam(), | |
134 | track->GetOuterParam(), | |
135 | track->GetConstrainedParam(), | |
136 | itsOut ); | |
137 | fNITSClusters = track->GetNcls(0); | |
138 | ||
139 | // -- Fill clusters from friend track | |
140 | // ------------------------------------------------------- | |
141 | if (friendTrack) { | |
142 | // Printf("DEBUG: Now filling clusters information for the current track"); | |
143 | ||
144 | // -- Get seed object | |
145 | TObject* calibObject = NULL; | |
146 | AliTPCseed* seed = NULL; | |
147 | /* | |
148 | for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) { | |
149 | cout<<"Calibration object:"<<endl; | |
150 | std::cout<<calibObject->GetName()<<std::endl; | |
151 | calibObject->Print(); | |
152 | cout<<"----------"<<endl; | |
153 | } | |
154 | friendTrack->Print(); | |
155 | cout<<"ITS track: "<<(void*)friendTrack->GetITStrack()<<endl; | |
156 | cout<<"TRD track: "<<(void*)friendTrack->GetTRDtrack()<<endl; | |
157 | cout<<"ITS OUT track: "<<(void*)friendTrack->GetITSOut()<<endl; | |
158 | cout<<"ITS indices: "; | |
159 | if( friendTrack->GetITSindices() ){ | |
160 | for( int i=0; i<friendTrack->GetMaxITScluster(); i++ ) cout<<friendTrack->GetITSindices()[i]<<" "; | |
161 | } | |
162 | cout<<endl; | |
163 | */ | |
164 | for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) { | |
165 | if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break; | |
166 | } | |
167 | ||
168 | // -- Fill cluster | |
169 | if (seed) { | |
170 | for (Int_t idxRow = 0; idxRow < 160; idxRow++){ | |
171 | AliTPCclusterMI* currentCl = seed->GetClusterPointer(idxRow); | |
172 | if (currentCl) { | |
f009a562 | 173 | AliFlatTPCCluster* tmpCl = GetNextTPCClusterPointer(); |
174 | new(tmpCl) AliFlatTPCCluster; | |
175 | tmpCl->SetX(currentCl->GetX()); | |
176 | tmpCl->SetY(currentCl->GetY()); | |
177 | tmpCl->SetZ(currentCl->GetZ()); | |
178 | // tmpCl->SetPadRow(idxRow); // TO BE CHECKED IF THIS NEEDED or currentCl->GetRow(); | |
179 | tmpCl->SetPadRow(currentCl->GetRow()); | |
180 | tmpCl->SetSigmaY2(currentCl->GetSigmaY2()); | |
181 | tmpCl->SetSigmaZ2(currentCl->GetSigmaZ2()); | |
182 | tmpCl->SetCharge(currentCl->GetQ()); | |
183 | tmpCl->SetQMax(currentCl->GetMax()); | |
251a2c81 | 184 | StoreLastTPCCluster(); |
185 | } | |
186 | // else | |
187 | // Printf("DEBUG: No cluster for row %d", idxRow); | |
188 | } | |
189 | } | |
190 | ||
191 | /* | |
192 | AliTPCseed* seed = NULL; | |
193 | for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) { | |
194 | if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break; | |
195 | } | |
196 | ||
197 | // -- Fill cluster | |
198 | if (seed) { | |
199 | for (Int_t idxRow = 0; idxRow < 160; idxRow++){ | |
200 | AliTPCclusterMI* currentCl = seed->GetTPCClusterPointer(idxRow); | |
201 | if (currentCl) { | |
202 | AliFlatTPCCluster &tmpCl = *GetNexTPCClusterPointer(); | |
203 | tmpCl.fX = currentCl->GetX(); | |
204 | tmpCl.fY = currentCl->GetY(); | |
205 | tmpCl.fZ = currentCl->GetZ(); | |
206 | tmpCl.fPadRow = idxRow; // TO BE CHECKED IF THIS NEEDED or currentCl->GetRow(); | |
207 | tmpCl.fSigmaY2 = currentCl->GetSigmaY2(); | |
208 | tmpCl.fSigmaZ2 = currentCl->GetSigmaZ2(); | |
209 | tmpCl.fCharge = currentCl->GetQ(); | |
210 | tmpCl.fQMax = currentCl->GetMax(); | |
211 | StoreLastTPCCluster(); | |
212 | } | |
213 | // else | |
214 | // Printf("DEBUG: No cluster for row %d", idxRow); | |
215 | } | |
216 | } | |
217 | */ | |
218 | ||
219 | // else | |
220 | // Printf("DEBUG: No seed object"); | |
221 | ||
222 | // Printf("DEBUG: Number of clusters for track = %d", fNTPCClusters); | |
223 | ||
224 | // -- Sorting clusters according to user defined function (increasing pad row numbering) | |
a1ca763e | 225 | // std::sort(GetTPCClusters(), GetTPCClusters()+fNTPCClusters, AliFlatTPCCluster::SortClusters); |
251a2c81 | 226 | } |
227 | ||
228 | return iResult; | |
229 | } | |
230 | ||
231 | // _______________________________________________________________________________________________________ | |
232 | Int_t AliFlatESDTrack::FillExternalTrackParam( | |
233 | const AliExternalTrackParam* refittedParam, | |
234 | const AliExternalTrackParam* innerParam, | |
235 | const AliExternalTrackParam* innerTPC, | |
236 | const AliExternalTrackParam* outerParam, | |
237 | const AliExternalTrackParam* constrainedParam, | |
238 | const AliExternalTrackParam* outerITS | |
239 | ){ | |
240 | // Fill external track parameters | |
241 | ||
242 | fTrackParamMask = 0; | |
243 | fNTPCClusters = 0; | |
244 | fSize = 0; | |
245 | ||
246 | Int_t iResult = 0; | |
247 | ||
248 | Byte_t flag = 0x1; | |
249 | iResult = FillExternalTrackParam(refittedParam, flag); | |
250 | ||
251 | flag = 0x2; | |
252 | iResult = FillExternalTrackParam(innerParam, flag); | |
253 | ||
254 | flag = 0x4; | |
255 | iResult = FillExternalTrackParam(innerTPC, flag); | |
256 | ||
257 | flag = 0x8; | |
258 | iResult = FillExternalTrackParam(outerParam, flag); | |
259 | ||
260 | flag = 0x10; | |
261 | iResult = FillExternalTrackParam(constrainedParam, flag); | |
262 | ||
263 | flag = 0x20; | |
264 | iResult = FillExternalTrackParam(outerITS, flag); | |
265 | ||
266 | return iResult; | |
267 | } | |
268 | ||
269 | // _______________________________________________________________________________________________________ | |
270 | Int_t AliFlatESDTrack::FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag) { | |
271 | // Fill external track parameters | |
272 | ||
273 | if (!param) | |
274 | return -1; | |
275 | ||
8dbbdcd3 | 276 | //Printf(" DEBUG: CONTENT %d >> %p + 0x%07llx = %p", flag, fContent, fSize, fContent + fSize); |
251a2c81 | 277 | |
278 | AliFlatExternalTrackParam * current = reinterpret_cast<AliFlatExternalTrackParam*> (fContent + fSize); | |
f009a562 | 279 | new (current) AliFlatExternalTrackParam; |
251a2c81 | 280 | current->SetAlpha(param->GetAlpha()); |
281 | current->SetX(param->GetX()); | |
282 | current->SetY(param->GetY()); | |
283 | current->SetZ(param->GetZ()); | |
284 | current->SetSnp(param->GetSnp()); | |
285 | current->SetTgl(param->GetTgl()); | |
286 | current->SetSigned1Pt(param->GetSigned1Pt()); | |
287 | ||
288 | const Double_t *cov = param->GetCovariance(); | |
289 | for (Int_t idx = 0; idx <15; ++idx) | |
290 | current->fC[idx] = cov[idx]; | |
291 | ||
292 | fTrackParamMask |= flag; | |
293 | fSize += sizeof(AliFlatExternalTrackParam); | |
294 | ||
295 | return 0; | |
296 | } | |
297 | ||
298 | // _______________________________________________________________________________________________________ | |
299 | UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) { | |
300 | // Count bits in field | |
301 | UInt_t count = 0; | |
302 | UInt_t reg = 0x0; | |
303 | ||
304 | reg |= field; | |
305 | reg &= mask; | |
306 | ||
307 | for (count = 0; reg; count++) | |
308 | reg &= reg - 1; | |
309 | ||
310 | return count; | |
311 | } |