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<fNTPCClusters; 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.fPadRow = currentCl->GetRow();
179 tmpCl.fSigmaY2 = currentCl->GetSigmaY2();
180 tmpCl.fSigmaZ2 = currentCl->GetSigmaZ2();
181 tmpCl.fCharge = currentCl->GetQ();
182 tmpCl.fQMax = currentCl->GetMax();
183 StoreLastTPCCluster();
186 // Printf("DEBUG: No cluster for row %d", idxRow);
191 AliTPCseed* seed = NULL;
192 for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
193 if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break;
198 for (Int_t idxRow = 0; idxRow < 160; idxRow++){
199 AliTPCclusterMI* currentCl = seed->GetTPCClusterPointer(idxRow);
201 AliFlatTPCCluster &tmpCl = *GetNexTPCClusterPointer();
202 tmpCl.fX = currentCl->GetX();
203 tmpCl.fY = currentCl->GetY();
204 tmpCl.fZ = currentCl->GetZ();
205 tmpCl.fPadRow = idxRow; // TO BE CHECKED IF THIS NEEDED or currentCl->GetRow();
206 tmpCl.fSigmaY2 = currentCl->GetSigmaY2();
207 tmpCl.fSigmaZ2 = currentCl->GetSigmaZ2();
208 tmpCl.fCharge = currentCl->GetQ();
209 tmpCl.fQMax = currentCl->GetMax();
210 StoreLastTPCCluster();
213 // Printf("DEBUG: No cluster for row %d", idxRow);
219 // Printf("DEBUG: No seed object");
221 // Printf("DEBUG: Number of clusters for track = %d", fNTPCClusters);
223 // -- Sorting clusters according to user defined function (increasing pad row numbering)
224 // std::sort(GetTPCClusters(), GetTPCClusters()+fNTPCClusters, AliFlatTPCCluster::SortClusters);
230 // _______________________________________________________________________________________________________
231 Int_t AliFlatESDTrack::FillExternalTrackParam(
232 const AliExternalTrackParam* refittedParam,
233 const AliExternalTrackParam* innerParam,
234 const AliExternalTrackParam* innerTPC,
235 const AliExternalTrackParam* outerParam,
236 const AliExternalTrackParam* constrainedParam,
237 const AliExternalTrackParam* outerITS
239 // Fill external track parameters
248 iResult = FillExternalTrackParam(refittedParam, flag);
251 iResult = FillExternalTrackParam(innerParam, flag);
254 iResult = FillExternalTrackParam(innerTPC, flag);
257 iResult = FillExternalTrackParam(outerParam, flag);
260 iResult = FillExternalTrackParam(constrainedParam, flag);
263 iResult = FillExternalTrackParam(outerITS, flag);
268 // _______________________________________________________________________________________________________
269 Int_t AliFlatESDTrack::FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag) {
270 // Fill external track parameters
275 //Printf(" DEBUG: CONTENT %d >> %p + 0x%07llx = %p", flag, fContent, fSize, fContent + fSize);
277 AliFlatExternalTrackParam * current = reinterpret_cast<AliFlatExternalTrackParam*> (fContent + fSize);
278 new (current) AliFlatExternalTrackParam(1);
279 current->SetAlpha(param->GetAlpha());
280 current->SetX(param->GetX());
281 current->SetY(param->GetY());
282 current->SetZ(param->GetZ());
283 current->SetSnp(param->GetSnp());
284 current->SetTgl(param->GetTgl());
285 current->SetSigned1Pt(param->GetSigned1Pt());
287 const Double_t *cov = param->GetCovariance();
288 for (Int_t idx = 0; idx <15; ++idx)
289 current->fC[idx] = cov[idx];
291 fTrackParamMask |= flag;
292 fSize += sizeof(AliFlatExternalTrackParam);
297 // _______________________________________________________________________________________________________
298 UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) {
299 // Count bits in field
306 for (count = 0; reg; count++)