]>
Commit | Line | Data |
---|---|---|
93ce7d1b | 1 | // $Id$ |
dc2e6604 | 2 | /************************************************************************** |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // HLT TRD Utillities Class // | |
20 | // // | |
21 | /////////////////////////////////////////////////////////////////////////////// | |
22 | ||
23 | #include "AliHLTTRDUtils.h" | |
24 | #include <TClonesArray.h> | |
25 | #include "AliHLTTRDTrack.h" | |
4a6879bb | 26 | #include "AliHLTTRDTracklet.h" |
dc2e6604 | 27 | #include "AliHLTTRDCluster.h" |
18ada816 | 28 | #include "AliHLTExternalTrackParam.h" |
29 | #include "AliESDEvent.h" | |
30 | #include "AliESDtrack.h" | |
31 | #include "AliPID.h" | |
32 | ||
33 | ClassImp(AliHLTTRDUtils) | |
dc2e6604 | 34 | |
93ce7d1b | 35 | AliHLTUInt32_t AliHLTTRDUtils::AddClustersToOutput(TClonesArray* inClusterArray, AliHLTUInt8_t* outBlockPtr, Int_t nTimeBins) |
dc2e6604 | 36 | { |
37 | AliTRDcluster* cluster = 0; | |
38 | AliHLTUInt32_t addedSize = 0; | |
39 | // == OUTdatatype pointer | |
93ce7d1b | 40 | AliHLTTRDCluster* outPtr = (AliHLTTRDCluster*)outBlockPtr; |
dc2e6604 | 41 | |
42 | if (inClusterArray){ | |
43 | Int_t nbEntries = inClusterArray->GetEntries(); | |
44 | for (Int_t iCluster = 0; iCluster<nbEntries; iCluster++){ | |
45 | //cout << "Geting cluster #" << iCluster << endl; | |
dc2e6604 | 46 | |
93ce7d1b | 47 | cluster = (AliTRDcluster*)(inClusterArray->At(iCluster)); |
dc2e6604 | 48 | |
49 | AliHLTTRDCluster *hltCluster = new (outPtr) AliHLTTRDCluster(cluster); | |
50 | //cout << Form("cluster added at 0x%x (%i)\n",outPtr,outPtr); | |
51 | ||
93ce7d1b | 52 | addedSize += sizeof(*hltCluster); |
53 | outBlockPtr += sizeof(*hltCluster); | |
dc2e6604 | 54 | outPtr = (AliHLTTRDCluster*)outBlockPtr; |
55 | } | |
56 | } | |
93ce7d1b | 57 | |
58 | Int_t *TBptr = (Int_t*)outPtr; | |
59 | *TBptr = nTimeBins; | |
60 | ||
61 | addedSize += sizeof(*TBptr); | |
62 | outBlockPtr += sizeof(*TBptr); | |
63 | ||
dc2e6604 | 64 | return addedSize; |
65 | ||
66 | } | |
67 | ||
93ce7d1b | 68 | AliHLTUInt32_t AliHLTTRDUtils::AddTracksToOutput(TClonesArray* inTrackArray, AliHLTUInt8_t* output, Int_t nTimeBins) |
dc2e6604 | 69 | { |
18ada816 | 70 | //cout << "\nWriting tracks to the Memory\n ============= \n"; |
93ce7d1b | 71 | |
72 | Int_t *TBptr = (Int_t*)output; | |
73 | *TBptr = nTimeBins; | |
74 | ||
dc2e6604 | 75 | AliTRDtrackV1* track = 0; |
93ce7d1b | 76 | AliHLTUInt32_t addedSize = sizeof(*TBptr); |
77 | AliHLTUInt8_t* iterPtr = output+addedSize; | |
78 | AliHLTTRDTrack* outPtr = (AliHLTTRDTrack*)iterPtr; | |
79 | ||
dc2e6604 | 80 | if (inTrackArray){ |
81 | Int_t nbTracks = inTrackArray->GetEntries(); | |
82 | for (Int_t iTrack = 0; iTrack<nbTracks; iTrack++){ | |
83 | AliHLTUInt32_t trackSize=0; | |
84 | ||
93ce7d1b | 85 | track = (AliTRDtrackV1*)(inTrackArray->At(iTrack)); |
dc2e6604 | 86 | //track->Print(); |
87 | ||
88 | AliHLTTRDTrack *hltTrack = new (outPtr) AliHLTTRDTrack(track); | |
89 | trackSize = hltTrack->GetSize(); | |
90 | addedSize += trackSize; | |
e3e5ac39 | 91 | //HLTDebug("addedSize %i, trackSize %i", addedSize, trackSize); |
dc2e6604 | 92 | |
93 | iterPtr += trackSize; | |
94 | outPtr = (AliHLTTRDTrack*)iterPtr; | |
95 | } | |
96 | } | |
97 | return addedSize; | |
98 | ||
99 | } | |
100 | ||
101 | /** | |
102 | * Read cluster to the TClonesArray from the memory | |
103 | */ | |
104 | //============================================================================ | |
93ce7d1b | 105 | AliHLTUInt32_t AliHLTTRDUtils::ReadClusters(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size, Int_t* nTimeBins) |
dc2e6604 | 106 | { |
107 | //HLTDebug("\nReading clusters from the Memory\n ============= \n"); | |
108 | AliHLTTRDCluster * curCluster; | |
109 | UInt_t clusterSize = sizeof(AliHLTTRDCluster), curSize = 0; | |
4a6879bb | 110 | Int_t counter=outArray->GetEntriesFast(); |
93ce7d1b | 111 | |
112 | if(nTimeBins){ | |
113 | *nTimeBins=*(Int_t*)(((AliHLTUInt8_t*)inputPtr)+size-sizeof(Int_t)); | |
114 | //HLTDebug("Reading number of time bins from input block: %d", *nTimeBins); | |
115 | } | |
116 | size-=sizeof(*nTimeBins); | |
117 | ||
dc2e6604 | 118 | curCluster = (AliHLTTRDCluster*) inputPtr; |
4a6879bb | 119 | while (curSize < size) |
dc2e6604 | 120 | { |
e3e5ac39 | 121 | //HLTDebug(" fX = %f; fY = %f; fZ = %f", curCluster->fX, curCluster->fY, curCluster->fZ); |
dc2e6604 | 122 | |
4a6879bb | 123 | AliTRDcluster* curTRDCluster = new((*outArray)[counter]) AliTRDcluster(); |
dc2e6604 | 124 | curCluster->ExportTRDCluster(curTRDCluster); |
e3e5ac39 | 125 | //HLTDebug(" fX = %f; fY = %f; fZ = %f", curTRDCluster->GetX(), curTRDCluster->GetY(), curTRDCluster->GetZ()); |
dc2e6604 | 126 | curSize += clusterSize; |
4a6879bb | 127 | counter++; |
dc2e6604 | 128 | curCluster++; |
129 | //cout << " current readed size is " << curSize << "/" << size << endl; | |
130 | } | |
131 | ||
4a6879bb | 132 | return counter; |
dc2e6604 | 133 | } |
134 | ||
93ce7d1b | 135 | AliHLTUInt32_t AliHLTTRDUtils::ReadTracks(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size, Int_t* nTimeBins) |
dc2e6604 | 136 | { |
93ce7d1b | 137 | if(nTimeBins){ |
138 | *nTimeBins=*(Int_t*)inputPtr; | |
139 | //HLTDebug("Reading number of time bins from input block: %d", *nTimeBins); | |
140 | } | |
141 | ||
142 | AliHLTUInt8_t* iterPtr = ((AliHLTUInt8_t*)inputPtr)+sizeof(*nTimeBins); | |
dc2e6604 | 143 | |
144 | //cout << "\nReading tracks from the Memory\n ============= \n"; | |
e3e5ac39 | 145 | //HLTDebug ("\nReading tracks from the Memory\n ============= \n"); |
dc2e6604 | 146 | AliHLTTRDTrack * hltTrack; |
93ce7d1b | 147 | AliHLTUInt32_t trackSize = 0, curSize = sizeof(*nTimeBins); |
4a6879bb | 148 | Int_t counter=outArray->GetEntriesFast(); |
dc2e6604 | 149 | |
150 | while (curSize < size) | |
151 | { | |
152 | hltTrack = (AliHLTTRDTrack*) iterPtr; | |
e3e5ac39 | 153 | //HLTDebug("curSize %i, size %i",curSize, size); |
dc2e6604 | 154 | |
155 | trackSize = hltTrack->GetSize(); | |
e3e5ac39 | 156 | //HLTDebug("GetSize() %i", trackSize); |
dc2e6604 | 157 | |
93ce7d1b | 158 | // hltTrack->ReadTrackletsFromMemory(iterPtr + sizeof(AliHLTTRDTrack)); |
dc2e6604 | 159 | |
160 | AliTRDtrackV1* curTRDTrack = new((*outArray)[counter]) AliTRDtrackV1(); | |
161 | hltTrack->ExportTRDTrack(curTRDTrack); | |
162 | ||
163 | curSize += trackSize; | |
164 | iterPtr += trackSize; | |
165 | counter++; | |
166 | } | |
167 | ||
168 | //CheckTrackArray(outArray); | |
169 | ||
170 | return counter; | |
171 | } | |
172 | ||
18ada816 | 173 | AliHLTUInt32_t AliHLTTRDUtils::AddESDToOutput(const AliESDEvent* const esd, AliHLTUInt8_t* const outBlockPtr) |
174 | { | |
175 | AliESDtrack* esdTrack = 0; | |
176 | AliHLTUInt8_t* iterPtr = outBlockPtr; | |
177 | ||
178 | AliHLTTracksData* trksData = new(iterPtr) AliHLTTracksData; | |
179 | iterPtr += sizeof(AliHLTTracksData); | |
180 | trksData->fCount=0; | |
181 | ||
182 | if(esd){ | |
183 | Double_t pid[5]; | |
184 | for(Int_t i=0; i<esd->GetNumberOfTracks(); i++){ | |
185 | esdTrack=esd->GetTrack(i); | |
186 | if(!esdTrack)continue; | |
187 | AliHLTExternalTrackParam* trk = new(iterPtr) AliHLTExternalTrackParam; | |
188 | iterPtr += sizeof(AliHLTExternalTrackParam); | |
189 | trk->fAlpha = esdTrack->GetAlpha(); | |
190 | trk->fX = esdTrack->GetX(); | |
191 | trk->fY = esdTrack->GetY(); | |
192 | trk->fZ = esdTrack->GetZ(); | |
193 | trk->fSinPsi = esdTrack->GetSnp(); | |
194 | trk->fTgl = esdTrack->GetTgl(); | |
195 | trk->fq1Pt = esdTrack->GetSigned1Pt(); | |
196 | trk->fC[0] = esdTrack->GetSigmaY2(); | |
197 | trk->fC[1] = esdTrack->GetSigmaZY(); | |
198 | trk->fC[2] = esdTrack->GetSigmaZ2(); | |
199 | trk->fC[3] = esdTrack->GetSigmaSnpY(); | |
200 | trk->fC[4] = esdTrack->GetSigmaSnpZ(); | |
201 | trk->fC[5] = esdTrack->GetSigmaSnp2(); | |
202 | trk->fC[6] = esdTrack->GetSigmaTglY(); | |
203 | trk->fC[7] = esdTrack->GetSigmaTglZ(); | |
204 | trk->fC[8] = esdTrack->GetSigmaTglSnp(); | |
205 | trk->fC[9] = esdTrack->GetSigmaTgl2(); | |
206 | trk->fC[10] = esdTrack->GetSigma1PtY(); | |
207 | trk->fC[11] = esdTrack->GetSigma1PtZ(); | |
208 | trk->fC[12] = esdTrack->GetSigma1PtSnp(); | |
209 | trk->fC[13] = esdTrack->GetSigma1PtTgl(); | |
210 | trk->fC[14] = esdTrack->GetSigma1Pt2(); | |
211 | esdTrack->GetTRDpid(pid); | |
212 | //trk->fTRDpid = pid[AliPID::kElectron]; ... | |
213 | trk->fNPoints = 0; | |
214 | trksData->fCount++; | |
215 | } | |
216 | } | |
217 | return iterPtr - outBlockPtr; | |
218 | } | |
4a6879bb | 219 | |
220 | void AliHLTTRDUtils::EmulateHLTClusters(TClonesArray* clusterArray) | |
221 | { | |
222 | AliHLTUInt32_t estimatedSize = (clusterArray->GetEntriesFast()+1)*sizeof(AliHLTTRDCluster); | |
223 | AliHLTUInt8_t* pBlock = (AliHLTUInt8_t*)malloc(estimatedSize); | |
224 | AliHLTUInt32_t size = AddClustersToOutput(clusterArray, pBlock); | |
225 | clusterArray->Delete(); | |
226 | ReadClusters(clusterArray, pBlock, size); | |
227 | free(pBlock); | |
228 | } | |
229 | ||
230 | void AliHLTTRDUtils::EmulateHLTTracks(TClonesArray* trackArray) | |
231 | { | |
20b643d5 | 232 | AliHLTUInt32_t estimatedSize = (trackArray->GetEntriesFast()+1)*(sizeof(AliHLTTRDTrack)+6*(sizeof(AliHLTTRDTracklet)+30*sizeof(AliHLTTRDCluster))); |
4a6879bb | 233 | AliHLTUInt8_t* pBlock = (AliHLTUInt8_t*)malloc(estimatedSize); |
234 | AliHLTUInt32_t size = AddTracksToOutput(trackArray, pBlock); | |
235 | trackArray->Delete(); | |
236 | ReadTracks(trackArray, pBlock, size); | |
237 | free(pBlock); | |
238 | } |