store pt in the tracklet instead of momentum
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDTracklet.cxx
CommitLineData
d679dd6c 1#include "AliHLTTRDTracklet.h"
2#include "AliHLTTRDCluster.h"
3
4/**
5 * Default Constructor
6 */
7//============================================================================
8AliHLTTRDTracklet::AliHLTTRDTracklet():
9 fTRDtracklet(NULL),
10 fSize(sizeof(AliHLTTRDTracklet)),
e3cf3d02 11 //fSigmaY(-1),
d679dd6c 12 fSigmaY2(-1),
13 fTilt(-1),
14 fPadLength(-1),
15 fX0(-1),
e3cf3d02 16 //fMeanz(-1),
17 //fZProb(-1),
18 //fN(-1),
d679dd6c 19 fN2(-1),
20 fNUsed(-1),
e3cf3d02 21 //fFreq(-1),
22 //fNChange(-1),
23 //fMPads(-1),
d679dd6c 24 fC(-1),
e3cf3d02 25 //fCC(-1),
d679dd6c 26 fChi2(-1),
e3cf3d02 27 //fChi2Z(-1),
d679dd6c 28 fDet(-1),
e44c0591 29 fPt(-1),
d679dd6c 30 fdX(-1)
31{
32 InitArrays();
33}
34
35/**
36 * Main Constructor
37 */
38//============================================================================
39AliHLTTRDTracklet::AliHLTTRDTracklet(AliTRDseedV1 * inTracklet):
40 fTRDtracklet(NULL),
41 fSize(sizeof(AliHLTTRDTracklet)),
e3cf3d02 42 //fSigmaY(-1),
d679dd6c 43 fSigmaY2(-1),
44 fTilt(-1),
45 fPadLength(-1),
46 fX0(-1),
e3cf3d02 47 //fMeanz(-1),
48 //fZProb(-1),
49 //fN(-1),
d679dd6c 50 fN2(-1),
51 fNUsed(-1),
e3cf3d02 52 //fFreq(-1),
53 //fNChange(-1),
54 //fMPads(-1),
d679dd6c 55 fC(-1),
e3cf3d02 56 //fCC(-1),
d679dd6c 57 fChi2(-1),
e3cf3d02 58 //fChi2Z(-1),
d679dd6c 59 fDet(-1),
e44c0591 60 fPt(-1),
d679dd6c 61 fdX(-1)
62{
63 InitArrays();
64
65 fTRDtracklet = inTracklet;
66 CopyDataMembers();
67 // Print(kFALSE);
68 AddClusters();
69}
70
71/**
72 * Add clusters to the HLTTRDTracklet
73 */
74//============================================================================
75void AliHLTTRDTracklet::AddClusters()
76{
b36fa46e 77 for (Int_t iTimeBin = 0; iTimeBin < AliTRDseedV1::kNclusters; iTimeBin++)
d679dd6c 78 {
79// if (fClusters[iTimeBin])
80// HLTWarning("Trying to rewrite cluster in tracklet. Not good.");
81 AliTRDcluster* trdCluster = fTRDtracklet->GetClusters(iTimeBin);
82 if (trdCluster){
83 AliHLTTRDCluster * hltCluster = new (GetEndPointer()) AliHLTTRDCluster(trdCluster);
84 fSize += hltCluster->GetSize();
85 //HLTInfo("cluster %i; adr 0x%x; endPointer 0x%x; fSize %i", iTimeBin, hltCluster, GetEndPointer(), fSize);
86 fClusters[iTimeBin] = hltCluster;
87 }
88 else
89 fClusters[iTimeBin] = NULL;
90
91 }
92}
93
94/**
95 * Copy simple (non-pointer) data members from TRDTracklet to HLTTRDTracklet
96 */
97//============================================================================
98void AliHLTTRDTracklet::CopyDataMembers()
99{
100 for (Int_t i=0; i < 2; i++){
101 fYref[i] = fTRDtracklet->GetYref(i);
102 fZref[i] = fTRDtracklet->GetZref(i);
103 }
e3cf3d02 104 //fSigmaY = fTRDtracklet->GetSigmaY();
105 fSigmaY2 = fTRDtracklet->GetS2Y();
d679dd6c 106 fTilt = fTRDtracklet->GetTilt();
107 fPadLength = fTRDtracklet->GetPadLength();
108
109 fX0 = fTRDtracklet->GetX0();
b36fa46e 110 for (Int_t i = 0; i < AliTRDseedV1::kNclusters; i++){
e3cf3d02 111// fX[i] = fTRDtracklet->GetX(i);
112// fY[i] = fTRDtracklet->GetY(i);
113// fZ[i] = fTRDtracklet->GetZ(i);
d679dd6c 114 fIndexes[i] = fTRDtracklet->GetIndexes(i);
d679dd6c 115 }
116
117 for (Int_t i=0; i < 2; i++){
118 fYfit[i] = fTRDtracklet->GetYfit(i);
119 fZfit[i] = fTRDtracklet->GetZfit(i);
d679dd6c 120 fLabels[i] = fTRDtracklet->GetLabels(i);
121 }
e3cf3d02 122 fLabels[2] = fTRDtracklet->GetLabels(2);
d679dd6c 123 fN2 = fTRDtracklet->GetN2();
124 fNUsed = fTRDtracklet->GetNUsed();
d679dd6c 125
126 fC = fTRDtracklet->GetC();
d679dd6c 127 fChi2 = fTRDtracklet->GetChi2();
e3cf3d02 128 //fChi2Z = fTRDtracklet->GetChi2Z();
d679dd6c 129
130 fDet = fTRDtracklet->GetDetector();
e44c0591 131 fPt = fTRDtracklet->GetPt();
d679dd6c 132 fdX = fTRDtracklet->GetdX();
d679dd6c 133}
134
135/**
136 * Copy data to the output TRDseedV1
137 */
138//============================================================================
139void AliHLTTRDTracklet::ExportTRDTracklet(AliTRDseedV1 *outTracklet)
140{
141 outTracklet->Reset();
142 /* ======= From AliTRDseedV1 ======== */
143 outTracklet->SetDetector(fDet);
e44c0591 144 outTracklet->SetPt(fPt);
d679dd6c 145 outTracklet->SetDX(fdX);
146
147 /* ======= From AliTRDseed ======== */
148 for (Int_t i=0; i < 2; i++){
149 outTracklet->SetYref(i, fYref[i]);
150 outTracklet->SetZref(i, fZref[i]);
151 }
152
e3cf3d02 153 //outTracklet->SetSigmaY(fSigmaY);
154 //outTracklet->SetSigmaY2(fSigmaY2);
d679dd6c 155 outTracklet->SetTilt(fTilt);
156 outTracklet->SetPadLength(fPadLength);
157 outTracklet->SetX0(fX0);
158
b36fa46e 159 for (Int_t i=0; i < AliTRDseedV1::kNclusters; i++){
e3cf3d02 160// outTracklet->SetX(i,fX[i]);
161// outTracklet->SetX(i,fY[i]);
162// outTracklet->SetX(i,fZ[i]);
d679dd6c 163 outTracklet->SetIndexes(i, fIndexes[i]);
d679dd6c 164 }
e3cf3d02 165
166// for (Int_t i=0; i < 2; i++){
167// outTracklet->SetYfit(i,fYfit[i]);
168// outTracklet->SetZfit(i,fZfit[i]);
169// }
170 outTracklet->SetLabels(fLabels);
d679dd6c 171
e3cf3d02 172 //outTracklet->SetN2(fN2);
173 //outTracklet->SetNUsed(fNUsed);
d679dd6c 174 outTracklet->SetC(fC);
d679dd6c 175 outTracklet->SetChi2(fChi2);
d679dd6c 176
b36fa46e 177 for (Int_t iCluster = 0; iCluster < AliTRDseedV1::kNclusters; iCluster++){
d679dd6c 178 if (fClusters[iCluster]){
179 AliTRDcluster *trdCluster = new AliTRDcluster();
180 fClusters[iCluster]->ExportTRDCluster(trdCluster);
e3cf3d02 181 //outTracklet->SetClusters(iCluster, trdCluster);
d679dd6c 182 }
183 }
d679dd6c 184}
185
186
187/**
188 * Init arrays
189 */
190//============================================================================
191void AliHLTTRDTracklet::InitArrays()
192{
b36fa46e 193 for (Int_t i=0; i < AliTRDseedV1::kNclusters; i++){
d679dd6c 194 fClusters[i] = NULL;
195 }
196
197 for (Int_t i=0; i < 2; i++){
198 fYref[i] = -1;
199 fZref[i] = -1;
200 }
b36fa46e 201 for (Int_t i = 0; i < AliTRDseedV1::kNclusters; i++){
e3cf3d02 202// fX[i] = -1;
203// fY[i] = -1;
204// fZ[i] = -1;
d679dd6c 205 fIndexes[i] = -1;
d679dd6c 206 }
207
208 for (Int_t i=0; i < 2; i++){
209 fYfit[i] = -1;
210 fZfit[i] = -1;
e3cf3d02 211// fYfitR[i] = -1;
212// fZfitR[i] = -1;
d679dd6c 213 fLabels[i] = -1;
214 }
e3cf3d02 215 fLabels[2] = 0;
d679dd6c 216}
217
218/**
219 * Prints main info about tracklet
220 */
221//============================================================================
222void AliHLTTRDTracklet::Print(Bool_t printClusters)
223{
224 //printf("--hltTracklet-- addr 0x%p(%i); fSize %i\n", this, (int)this, fSize);
e44c0591 225 printf(" fDet %i; fPt %f; fdX %f fN %i\n", fDet, fPt, fdX, fN2);
d679dd6c 226
e3cf3d02 227 if(!printClusters) return;
b36fa46e 228 for (Int_t iCluster = 0; iCluster < AliTRDseedV1::kNclusters; iCluster++){
e3cf3d02 229 printf(" [%i] ",iCluster);
230 if (fClusters[iCluster]) fClusters[iCluster]->Print();
231 else printf(" NULL\n");
d679dd6c 232 }
d679dd6c 233}
234
235/**
236 * Read clusters to TRDtracklet from the memory
237 */
238//============================================================================
239void AliHLTTRDTracklet::ReadClustersFromMemory(void *input)
240{
241 AliHLTUInt8_t *iterPtr = (AliHLTUInt8_t*) input;
242 AliHLTTRDCluster* hltCluster = NULL;
243
b36fa46e 244 for (Int_t iCluster = 0; iCluster < AliTRDseedV1::kNclusters; iCluster++){
d679dd6c 245 // if we had something in the fClusters[iCluster] before copying,
246 // then this entry in the array should not be empty. Fill it.
247 if (fClusters[iCluster]){
248 hltCluster = (AliHLTTRDCluster*) iterPtr;
249 fClusters[iCluster] = hltCluster;
250 iterPtr += hltCluster->GetSize();
251 //hltCluster->Print();
252 }
253
254 }
255}