]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliFlatESDTrack.cxx
fixed in AliFlatESDEvent: fNV0s, fPointerV0s not initialized in constructor, wrong...
[u/mrichter/AliRoot.git] / HLT / global / AliFlatESDTrack.cxx
CommitLineData
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// _______________________________________________________________________________________________________
47AliFlatESDTrack::AliFlatESDTrack() :
48 // Default constructor
49 fTrackParamMask(0),
50 fNTPCClusters(0),
51 fNITSClusters(0),
52
53 fSize(0),
54 fContent() {
55
56}
57
58// _______________________________________________________________________________________________________
59AliFlatESDTrack::AliFlatESDTrack(const AliESDtrack* track, AliESDfriendTrack* friendTrack) :
60 // Constructor
61 fTrackParamMask(0),
62 fNTPCClusters(0),
63 fNITSClusters(0),
64 fSize(0),
65 fContent() {
66
67 Fill(track, friendTrack);
68}
69
70// _______________________________________________________________________________________________________
71AliFlatESDTrack::~AliFlatESDTrack() {
72 // Destructor
73
74}
75
76// _______________________________________________________________________________________________________
77ULong64_t AliFlatESDTrack::EstimateSize(Bool_t useESDFriends, Int_t nTPCClusters ) {
78 // Estimate upper limit of the object size
79 // -> Added objects have to be added here as well
80
81 ULong64_t size = sizeof(AliFlatESDTrack) + (6*sizeof(AliFlatExternalTrackParam));
82
83 if (useESDFriends){
84 size += nTPCClusters*sizeof(AliFlatTPCCluster);
85 }
86 return size;
87}
88
89
90// _______________________________________________________________________________________________________
91Int_t AliFlatESDTrack::Fill(const AliESDtrack* track, AliESDfriendTrack* friendTrack){
92 // Fill external track parameters and friendTrack
93
94 fTrackParamMask = 0;
95 fNTPCClusters = 0;
96 fNITSClusters = 0;
97 fSize = 0;
98
99 if( !track ) return 0;
100
101 const AliExternalTrackParam *itsOut = 0;
102 if (friendTrack) itsOut = friendTrack->GetITSOut();
103
104 Int_t iResult = FillExternalTrackParam( track,
105 track->GetInnerParam(),
106 track->GetTPCInnerParam(),
107 track->GetOuterParam(),
108 track->GetConstrainedParam(),
109 itsOut );
110 fNITSClusters = track->GetNcls(0);
111
112 // -- Fill clusters from friend track
113 // -------------------------------------------------------
114 if (friendTrack) {
115 // Printf("DEBUG: Now filling clusters information for the current track");
116
117 // -- Get seed object
118 TObject* calibObject = NULL;
119 AliTPCseed* seed = NULL;
120 /*
121 for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
122 cout<<"Calibration object:"<<endl;
123 std::cout<<calibObject->GetName()<<std::endl;
124 calibObject->Print();
125 cout<<"----------"<<endl;
126 }
127 friendTrack->Print();
128 cout<<"ITS track: "<<(void*)friendTrack->GetITStrack()<<endl;
129 cout<<"TRD track: "<<(void*)friendTrack->GetTRDtrack()<<endl;
130 cout<<"ITS OUT track: "<<(void*)friendTrack->GetITSOut()<<endl;
131 cout<<"ITS indices: ";
132 if( friendTrack->GetITSindices() ){
133 for( int i=0; i<friendTrack->GetMaxITScluster(); i++ ) cout<<friendTrack->GetITSindices()[i]<<" ";
134 }
135 cout<<endl;
136 */
137 for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
138 if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break;
139 }
140
141 // -- Fill cluster
142 if (seed) {
143 for (Int_t idxRow = 0; idxRow < 160; idxRow++){
144 AliTPCclusterMI* currentCl = seed->GetClusterPointer(idxRow);
145 if (currentCl) {
146 AliFlatTPCCluster &tmpCl = *GetNextTPCClusterPointer();
147 tmpCl.fX = currentCl->GetX();
148 tmpCl.fY = currentCl->GetY();
149 tmpCl.fZ = currentCl->GetZ();
150 tmpCl.fPadRow = idxRow; // TO BE CHECKED IF THIS NEEDED or currentCl->GetRow();
151 tmpCl.fSigmaY2 = currentCl->GetSigmaY2();
152 tmpCl.fSigmaZ2 = currentCl->GetSigmaZ2();
153 tmpCl.fCharge = currentCl->GetQ();
154 tmpCl.fQMax = currentCl->GetMax();
155 StoreLastTPCCluster();
156 }
157 // else
158 // Printf("DEBUG: No cluster for row %d", idxRow);
159 }
160 }
161
162 /*
163 AliTPCseed* seed = NULL;
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->GetTPCClusterPointer(idxRow);
172 if (currentCl) {
173 AliFlatTPCCluster &tmpCl = *GetNexTPCClusterPointer();
174 tmpCl.fX = currentCl->GetX();
175 tmpCl.fY = currentCl->GetY();
176 tmpCl.fZ = currentCl->GetZ();
177 tmpCl.fPadRow = idxRow; // TO BE CHECKED IF THIS NEEDED or currentCl->GetRow();
178 tmpCl.fSigmaY2 = currentCl->GetSigmaY2();
179 tmpCl.fSigmaZ2 = currentCl->GetSigmaZ2();
180 tmpCl.fCharge = currentCl->GetQ();
181 tmpCl.fQMax = currentCl->GetMax();
182 StoreLastTPCCluster();
183 }
184 // else
185 // Printf("DEBUG: No cluster for row %d", idxRow);
186 }
187 }
188 */
189
190 // else
191 // Printf("DEBUG: No seed object");
192
193 // Printf("DEBUG: Number of clusters for track = %d", fNTPCClusters);
194
195 // -- Sorting clusters according to user defined function (increasing pad row numbering)
196 std::sort(GetTPCClusters(), GetTPCClusters()+fNTPCClusters, AliFlatTPCCluster::SortClusters);
197 }
198
199 return iResult;
200}
201
202// _______________________________________________________________________________________________________
203Int_t AliFlatESDTrack::FillExternalTrackParam(
204 const AliExternalTrackParam* refittedParam,
205 const AliExternalTrackParam* innerParam,
206 const AliExternalTrackParam* innerTPC,
207 const AliExternalTrackParam* outerParam,
208 const AliExternalTrackParam* constrainedParam,
209 const AliExternalTrackParam* outerITS
210 ){
211 // Fill external track parameters
212
213 fTrackParamMask = 0;
214 fNTPCClusters = 0;
215 fSize = 0;
216
217 Int_t iResult = 0;
218
219 Byte_t flag = 0x1;
220 iResult = FillExternalTrackParam(refittedParam, flag);
221
222 flag = 0x2;
223 iResult = FillExternalTrackParam(innerParam, flag);
224
225 flag = 0x4;
226 iResult = FillExternalTrackParam(innerTPC, flag);
227
228 flag = 0x8;
229 iResult = FillExternalTrackParam(outerParam, flag);
230
231 flag = 0x10;
232 iResult = FillExternalTrackParam(constrainedParam, flag);
233
234 flag = 0x20;
235 iResult = FillExternalTrackParam(outerITS, flag);
236
237 return iResult;
238}
239
240// _______________________________________________________________________________________________________
241Int_t AliFlatESDTrack::FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag) {
242 // Fill external track parameters
243
244 if (!param)
245 return -1;
246
247 Printf(" DEBUG: CONTENT %d >> %p + 0x%07llx = %p", flag, fContent, fSize, fContent + fSize);
248
249 AliFlatExternalTrackParam * current = reinterpret_cast<AliFlatExternalTrackParam*> (fContent + fSize);
250 current->SetAlpha(param->GetAlpha());
251 current->SetX(param->GetX());
252 current->SetY(param->GetY());
253 current->SetZ(param->GetZ());
254 current->SetSnp(param->GetSnp());
255 current->SetTgl(param->GetTgl());
256 current->SetSigned1Pt(param->GetSigned1Pt());
257
258 const Double_t *cov = param->GetCovariance();
259 for (Int_t idx = 0; idx <15; ++idx)
260 current->fC[idx] = cov[idx];
261
262 fTrackParamMask |= flag;
263 fSize += sizeof(AliFlatExternalTrackParam);
264
265 return 0;
266}
267
268// _______________________________________________________________________________________________________
269UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) {
270 // Count bits in field
271 UInt_t count = 0;
272 UInt_t reg = 0x0;
273
274 reg |= field;
275 reg &= mask;
276
277 for (count = 0; reg; count++)
278 reg &= reg - 1;
279
280 return count;
281}