]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliHLTTRDTrack.cxx
Bug fix: AliHLTComponent::ConfigureFromArgumentString
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDTrack.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors:                                                               *
7  *          for The ALICE HLT Project.                                    *
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 //  @file   AliHLTTRDTracklet.cxx
19 //  @author Theodor Rascanu
20 //  @date   
21 //  @brief  A datacontainer for tracklets for the HLT. 
22 // 
23
24 #include "AliHLTTRDTrack.h"
25 #include "AliHLTTRDTracklet.h"
26
27 /**
28  * Default Constructor
29  */
30 //============================================================================
31 AliHLTTRDTrack::AliHLTTRDTrack():
32   fDE(-1),
33   fFakeRatio(-1),
34   fChi2(-1),
35   // fMass(-1),
36   fN(-1),
37   fIntegratedLength(-1),
38   fX(-1),
39   fAlpha(-1),
40   fSize(sizeof(AliHLTTRDTrack)),
41   fBits(0)
42 {
43   InitArrays();
44   // not to be used
45 }
46
47 /**
48  * Constructor
49  * Creates hltTrack from TRDtrackV1
50  */
51 //============================================================================
52 AliHLTTRDTrack::AliHLTTRDTrack(const AliTRDtrackV1* const inTrack):
53   fDE(inTrack->fDE),
54   fFakeRatio(inTrack->fFakeRatio),
55   fChi2(inTrack->fChi2),
56   // fMass(inTrack->fMass),
57   fN(inTrack->fN),
58   fIntegratedLength(inTrack->GetIntegratedLength()),
59   fX(inTrack->GetX()),
60   fAlpha(inTrack->GetAlpha()),
61   fSize(sizeof(AliHLTTRDTrack)),
62   fBits(0)
63 {
64   CopyDataMembers(inTrack);
65 }
66
67 /**
68  * Default Destructor
69  * In principle should not be empty, but... we do not use it
70  */
71 //============================================================================
72 AliHLTTRDTrack::~AliHLTTRDTrack()
73 {
74   
75 }
76
77 /**
78  * Copy data members (except tracklets) from TRDtrackV1 to HLTTRDTrack.
79  */
80 //============================================================================
81 void AliHLTTRDTrack::CopyDataMembers(const AliTRDtrackV1* const inTrack)
82 {
83   for(Int_t i = 0; i < AliPID::kSPECIES; i++)
84     {
85       fPID[i] = inTrack->fPID[i];
86     }
87   
88   for (Int_t i = 0; i < 3; i++)
89     {
90       fBudget[i] = inTrack->fBudget[i];
91     }
92   
93   const Double_t* const Ptemp = inTrack->GetParameter();
94   for (Int_t i = 0; i < 5; i++)
95     {
96       fP[i] = Ptemp[i];
97     }
98
99   const Double_t* const Ctemp = inTrack->GetCovariance();
100   for (Int_t i = 0; i < 15; i++)
101     {
102       fC[i] = Ctemp[i];
103     }
104
105   UInt_t mask = inTrack->TestBits(-1);
106   fBits = mask >> 14;
107
108   for (Int_t iTracklet = 0; iTracklet < AliTRDtrackV1::kNplane; iTracklet++)
109     {
110       AliTRDseedV1* trdTracklet = inTrack->GetTracklet(iTracklet);
111       if (trdTracklet){
112         AliHLTTRDTracklet* hltTracklet = new (GetEndPointer()) AliHLTTRDTracklet(trdTracklet);
113         fSize += hltTracklet->GetSize();
114         fTrackletAtPlane[iTracklet] = kTRUE;
115       }
116       else fTrackletAtPlane[iTracklet] = kFALSE;
117     }
118 }
119
120 /**
121  * Copy data to the output TRDtrackV1
122  */
123 //============================================================================
124 void AliHLTTRDTrack::ExportTRDTrack(AliTRDtrackV1* const outTrack) const
125 {
126   //outTrack->Reset(); we always use a new fresh trdtrack as input, so this is useless
127   outTrack->SetBit(AliTRDtrackV1::kOwner);
128
129   outTrack->fDE=fDE;
130   outTrack->fFakeRatio=fFakeRatio;
131   outTrack->fChi2=fChi2;
132   // outTrack->fMass=fMass;
133   outTrack->fN=fN;
134   outTrack->SetIntegratedLength(fIntegratedLength);
135   outTrack->Set(fX, fAlpha, fP, fC);
136
137   for(Int_t i = 0; i < AliPID::kSPECIES; i++)
138     {
139       outTrack->fPID[i] = fPID[i];
140     }
141   for (Int_t i = 0; i < 3; i++)
142     {
143       outTrack->fBudget[i]=fBudget[i];
144     }
145
146   outTrack->SetBit(UInt_t(fBits)<<14);
147
148   AliHLTUInt8_t *iterPtr = (AliHLTUInt8_t*)this+sizeof(*this);
149   AliHLTTRDTracklet* hltTracklet;
150   
151   for (Int_t iTracklet = 0; iTracklet < AliTRDtrackV1::kNplane; iTracklet++){
152     if (fTrackletAtPlane[iTracklet]){
153       AliTRDseedV1* trdTracklet = new AliTRDseedV1();
154       hltTracklet = (AliHLTTRDTracklet*) iterPtr;
155       hltTracklet->ExportTRDTracklet(trdTracklet);
156       outTrack->SetTracklet(trdTracklet,iTracklet);
157       iterPtr += hltTracklet->GetSize();
158     }
159   }
160
161 }
162   
163
164 /**
165  * Init of arrays
166  */
167 //============================================================================
168 void AliHLTTRDTrack::InitArrays()
169 {
170   for(Int_t i = 0; i < AliTRDtrackV1::kNplane; i++){
171     fTrackletAtPlane[i]=kFALSE;
172   }
173
174   for(Int_t i = 0; i < AliPID::kSPECIES; i++)
175     {
176       fPID[i] = -1;
177     }
178   
179   for (Int_t i = 0; i < 3; i++)
180     {
181       fBudget[i] = -1;
182     }
183   for (Int_t i = 0; i < 5; i++)
184     {
185       fP[i] = -1;
186     }
187   for (Int_t i = 0; i < 15; i++)
188     {
189       fC[i] = -1;
190     }
191 }
192
193 /**
194  * Print main values for HLTTrack
195  */
196 //============================================================================
197 void AliHLTTRDTrack::Print(Bool_t printTracklets) const
198 {
199   printf("--hltTrack-- addr %p; fSize %i\n", this, fSize);
200   printf("   fX = %f; fAlpha = %f\n", fX, fAlpha);
201   printf("   ");
202   
203   for(Int_t i = 0; i < AliPID::kSPECIES; i++)
204     {
205       printf("fPID[%i] = %f; ",i, fPID[i]);
206     }
207   printf("\n   ");
208   
209   for (Int_t i = 0; i < 3; i++)
210     {
211       printf("fBudget[%i] = %f; ",i, fBudget[i]);
212     }
213   printf("\n");
214
215   if (printTracklets)
216     {
217       AliHLTUInt8_t *iterPtr = (AliHLTUInt8_t*)this+sizeof(*this);
218       AliHLTTRDTracklet* hltTracklet;
219
220       for (Int_t i = 0; i < AliTRDtrackV1::kNplane; i++){
221         if (fTrackletAtPlane[i]){
222           printf("[%i]",i);
223           hltTracklet = (AliHLTTRDTracklet*) iterPtr;
224           hltTracklet->Print();
225           iterPtr += hltTracklet->GetSize();
226         }
227         else
228           printf(" NULL ");
229       }
230     }
231
232   printf("\n");
233 }
234
235 /**
236  * Save track at block position
237  */
238 //============================================================================
239 AliHLTUInt32_t AliHLTTRDTrack::SaveAt(AliHLTUInt8_t *const block, const AliTRDtrackV1* const inTrack)
240 {
241   AliHLTUInt32_t size=0;
242
243   memcpy(block,inTrack,sizeof(AliTRDtrackV1));
244   size+=sizeof(AliTRDtrackV1);
245
246   for(int i=0; i<AliTRDtrackV1::kNplane; i++){
247     AliTRDseedV1* inTracklet = inTrack->GetTracklet(i);
248     if(inTracklet) size+=AliHLTTRDTracklet::SaveAt(block+size, inTracklet);
249   }
250
251   return size;
252 }
253
254 /**
255  * Read track from block
256  */
257 //============================================================================
258 AliHLTUInt32_t AliHLTTRDTrack::LoadFrom(AliTRDtrackV1 *const outTrack, const AliHLTUInt8_t *const block)
259 {
260   AliHLTUInt32_t size=0;
261
262   memcpy(((AliHLTUInt8_t*)outTrack)+sizeof(void*),block+sizeof(void*),sizeof(AliTRDtrackV1)-sizeof(void*));
263   size+=sizeof(AliTRDtrackV1);
264
265   for(int i=0; i<AliTRDtrackV1::kNplane; i++){
266     if(outTrack->GetTracklet(i)){
267       AliTRDseedV1 *const outTracklet = new AliTRDseedV1;
268       outTrack->fTracklet[i]=outTracklet;
269       size+=AliHLTTRDTracklet::LoadFrom(outTracklet, block+size);
270     }
271   }
272
273   outTrack->SetBit(AliTRDtrackV1::kOwner);
274   outTrack->fBackupTrack=NULL;
275   outTrack->fTrackLow=NULL;
276   outTrack->fTrackHigh=NULL;
277   return size;
278 }