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(AliFlatESDSpecialConstructorFlag f)
62 //use to restore the vtable pointer
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); }
78 AliFlatTPCCluster* clusterTPC = GetTPCClusters();
79 for (Int_t i=0; i<fNTPCClusters; i++)
80 new (clusterTPC++) AliFlatTPCCluster(f);
82 else AliFlatESDTrack();
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 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());
184 StoreLastTPCCluster();
187 // Printf("DEBUG: No cluster for row %d", idxRow);
192 AliTPCseed* seed = NULL;
193 for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
194 if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break;
199 for (Int_t idxRow = 0; idxRow < 160; idxRow++){
200 AliTPCclusterMI* currentCl = seed->GetTPCClusterPointer(idxRow);
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();
214 // Printf("DEBUG: No cluster for row %d", idxRow);
220 // Printf("DEBUG: No seed object");
222 // Printf("DEBUG: Number of clusters for track = %d", fNTPCClusters);
224 // -- Sorting clusters according to user defined function (increasing pad row numbering)
225 // std::sort(GetTPCClusters(), GetTPCClusters()+fNTPCClusters, AliFlatTPCCluster::SortClusters);
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
240 // Fill external track parameters
249 iResult = FillExternalTrackParam(refittedParam, flag);
252 iResult = FillExternalTrackParam(innerParam, flag);
255 iResult = FillExternalTrackParam(innerTPC, flag);
258 iResult = FillExternalTrackParam(outerParam, flag);
261 iResult = FillExternalTrackParam(constrainedParam, flag);
264 iResult = FillExternalTrackParam(outerITS, flag);
269 // _______________________________________________________________________________________________________
270 Int_t AliFlatESDTrack::FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag) {
271 // Fill external track parameters
276 //Printf(" DEBUG: CONTENT %d >> %p + 0x%07llx = %p", flag, fContent, fSize, fContent + fSize);
278 AliFlatExternalTrackParam * current = reinterpret_cast<AliFlatExternalTrackParam*> (fContent + fSize);
279 new (current) AliFlatExternalTrackParam;
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());
288 const Double_t *cov = param->GetCovariance();
289 for (Int_t idx = 0; idx <15; ++idx)
290 current->fC[idx] = cov[idx];
292 fTrackParamMask |= flag;
293 fSize += sizeof(AliFlatExternalTrackParam);
298 // _______________________________________________________________________________________________________
299 UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) {
300 // Count bits in field
307 for (count = 0; reg; count++)