3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 * >> Flat structure representing an ESDTrack <<
21 * To be used in the online and offline calibration schema.
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
29 * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
31 **************************************************************************/
35 #include "AliESDEvent.h"
36 #include "AliESDtrack.h"
37 #include "AliESDfriendTrack.h"
38 #include "AliExternalTrackParam.h"
39 #include "AliTPCseed.h"
40 #include "AliTPCclusterMI.h"
42 #include "AliFlatESDEvent.h"
43 #include "AliFlatESDTrack.h"
44 #include "Riostream.h"
46 // _______________________________________________________________________________________________________
47 AliFlatESDTrack::AliFlatESDTrack() :
48 // Default constructor
58 // _______________________________________________________________________________________________________
59 AliFlatESDTrack::AliFlatESDTrack(Bool_t)
62 //use to restore the vtable pointer
64 AliFlatExternalTrackParam* trackParam = GetTrackParamRefitted();
65 if (trackParam) { new (trackParam) AliFlatExternalTrackParam(1); }
66 trackParam = GetTrackParamIp();
67 if (trackParam) { new (trackParam) AliFlatExternalTrackParam(1); }
68 trackParam = GetTrackParamTPCInner();
69 if (trackParam) { new (trackParam) AliFlatExternalTrackParam(1); }
70 trackParam = GetTrackParamOp();
71 if (trackParam) { new (trackParam) AliFlatExternalTrackParam(1); }
72 trackParam = GetTrackParamCp();
73 if (trackParam) { new (trackParam) AliFlatExternalTrackParam(1); }
74 trackParam = GetTrackParamITSOut();
75 if (trackParam) { new (trackParam) AliFlatExternalTrackParam(1); }
77 AliFlatTPCCluster* clusterTPC = GetTPCClusters();
78 for (Int_t i=0; i<GetNumberOfTPCClusters(); i++)
80 new (clusterTPC) AliFlatTPCCluster(1);
81 clusterTPC += sizeof(AliFlatTPCCluster);
85 // _______________________________________________________________________________________________________
86 AliFlatESDTrack::AliFlatESDTrack(const AliESDtrack* track, AliESDfriendTrack* friendTrack) :
94 Fill(track, friendTrack);
97 // _______________________________________________________________________________________________________
98 AliFlatESDTrack::~AliFlatESDTrack() {
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
108 ULong64_t size = sizeof(AliFlatESDTrack) + (6*sizeof(AliFlatExternalTrackParam));
111 size += nTPCClusters*sizeof(AliFlatTPCCluster);
117 // _______________________________________________________________________________________________________
118 Int_t AliFlatESDTrack::Fill(const AliESDtrack* track, AliESDfriendTrack* friendTrack){
119 // Fill external track parameters and friendTrack
126 if( !track ) return 0;
128 const AliExternalTrackParam *itsOut = 0;
129 if (friendTrack) itsOut = friendTrack->GetITSOut();
131 Int_t iResult = FillExternalTrackParam( track,
132 track->GetInnerParam(),
133 track->GetTPCInnerParam(),
134 track->GetOuterParam(),
135 track->GetConstrainedParam(),
137 fNITSClusters = track->GetNcls(0);
139 // -- Fill clusters from friend track
140 // -------------------------------------------------------
142 // Printf("DEBUG: Now filling clusters information for the current track");
144 // -- Get seed object
145 TObject* calibObject = NULL;
146 AliTPCseed* seed = NULL;
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;
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]<<" ";
164 for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
165 if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break;
170 for (Int_t idxRow = 0; idxRow < 160; idxRow++){
171 AliTPCclusterMI* currentCl = seed->GetClusterPointer(idxRow);
173 AliFlatTPCCluster &tmpCl = *GetNextTPCClusterPointer();
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();
185 // Printf("DEBUG: No cluster for row %d", idxRow);
190 AliTPCseed* seed = NULL;
191 for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
192 if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break;
197 for (Int_t idxRow = 0; idxRow < 160; idxRow++){
198 AliTPCclusterMI* currentCl = seed->GetTPCClusterPointer(idxRow);
200 AliFlatTPCCluster &tmpCl = *GetNexTPCClusterPointer();
201 tmpCl.fX = currentCl->GetX();
202 tmpCl.fY = currentCl->GetY();
203 tmpCl.fZ = currentCl->GetZ();
204 tmpCl.fPadRow = idxRow; // TO BE CHECKED IF THIS NEEDED or currentCl->GetRow();
205 tmpCl.fSigmaY2 = currentCl->GetSigmaY2();
206 tmpCl.fSigmaZ2 = currentCl->GetSigmaZ2();
207 tmpCl.fCharge = currentCl->GetQ();
208 tmpCl.fQMax = currentCl->GetMax();
209 StoreLastTPCCluster();
212 // Printf("DEBUG: No cluster for row %d", idxRow);
218 // Printf("DEBUG: No seed object");
220 // Printf("DEBUG: Number of clusters for track = %d", fNTPCClusters);
222 // -- Sorting clusters according to user defined function (increasing pad row numbering)
223 std::sort(GetTPCClusters(), GetTPCClusters()+fNTPCClusters, AliFlatTPCCluster::SortClusters);
229 // _______________________________________________________________________________________________________
230 Int_t AliFlatESDTrack::FillExternalTrackParam(
231 const AliExternalTrackParam* refittedParam,
232 const AliExternalTrackParam* innerParam,
233 const AliExternalTrackParam* innerTPC,
234 const AliExternalTrackParam* outerParam,
235 const AliExternalTrackParam* constrainedParam,
236 const AliExternalTrackParam* outerITS
238 // Fill external track parameters
247 iResult = FillExternalTrackParam(refittedParam, flag);
250 iResult = FillExternalTrackParam(innerParam, flag);
253 iResult = FillExternalTrackParam(innerTPC, flag);
256 iResult = FillExternalTrackParam(outerParam, flag);
259 iResult = FillExternalTrackParam(constrainedParam, flag);
262 iResult = FillExternalTrackParam(outerITS, flag);
267 // _______________________________________________________________________________________________________
268 Int_t AliFlatESDTrack::FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag) {
269 // Fill external track parameters
274 //Printf(" DEBUG: CONTENT %d >> %p + 0x%07llx = %p", flag, fContent, fSize, fContent + fSize);
276 AliFlatExternalTrackParam * current = reinterpret_cast<AliFlatExternalTrackParam*> (fContent + fSize);
277 current->SetAlpha(param->GetAlpha());
278 current->SetX(param->GetX());
279 current->SetY(param->GetY());
280 current->SetZ(param->GetZ());
281 current->SetSnp(param->GetSnp());
282 current->SetTgl(param->GetTgl());
283 current->SetSigned1Pt(param->GetSigned1Pt());
285 const Double_t *cov = param->GetCovariance();
286 for (Int_t idx = 0; idx <15; ++idx)
287 current->fC[idx] = cov[idx];
289 fTrackParamMask |= flag;
290 fSize += sizeof(AliFlatExternalTrackParam);
295 // _______________________________________________________________________________________________________
296 UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) {
297 // Count bits in field
304 for (count = 0; reg; count++)