]>
Commit | Line | Data |
---|---|---|
71d7c760 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
7 | * Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
8 | * for The ALICE Off-line Project. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /////////////////////////////////////////////////////////////////////////////// | |
20 | // // | |
21 | // a TPC sector tracker processing component for the HLT // | |
22 | // // | |
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #if __GNUC__== 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTTPCGlobalMergerComponent.h" | |
a6c02c85 | 30 | #include "AliHLTTPCTransform.h" |
31 | #include "AliHLTTPCGlobalMerger.h" | |
32 | #include "AliHLTTPCVertex.h" | |
33 | #include "AliHLTTPCVertexData.h" | |
34 | #include "AliHLTTPCTrackSegmentData.h" | |
35 | #include "AliHLTTPCTrackArray.h" | |
71d7c760 | 36 | #include "AliHLTTPCTrackletDataFormat.h" |
a6c02c85 | 37 | #include "AliHLTTPCSpacePointData.h" |
71d7c760 | 38 | #include "AliHLTTPCClusterDataFormat.h" |
39 | #include <stdlib.h> | |
40 | #include <errno.h> | |
41 | ||
42 | // this is a global object used for automatic component registration, do not use this | |
43 | AliHLTTPCGlobalMergerComponent gAliHLTTPCGlobalMergerComponent; | |
44 | ||
45 | ClassImp(AliHLTTPCGlobalMergerComponent) | |
46 | ||
47 | AliHLTTPCGlobalMergerComponent::AliHLTTPCGlobalMergerComponent() | |
48 | { | |
49 | fGlobalMerger = NULL; | |
50 | fVertex = NULL; | |
51 | } | |
52 | ||
53 | AliHLTTPCGlobalMergerComponent::~AliHLTTPCGlobalMergerComponent() | |
54 | { | |
55 | } | |
56 | ||
57 | // Public functions to implement AliHLTComponent's interface. | |
58 | // These functions are required for the registration process | |
59 | ||
60 | const char* AliHLTTPCGlobalMergerComponent::GetComponentID() | |
61 | { | |
62 | return "TPCGlobalMerger"; | |
63 | } | |
64 | ||
65 | void AliHLTTPCGlobalMergerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
66 | { | |
67 | list.clear(); | |
68 | list.push_back( AliHLTTPCDefinitions::gkTrackSegmentsDataType ); | |
69 | list.push_back( AliHLTTPCDefinitions::gkVertexDataType ); | |
70 | } | |
71 | ||
72 | AliHLTComponent_DataType AliHLTTPCGlobalMergerComponent::GetOutputDataType() | |
73 | { | |
74 | return AliHLTTPCDefinitions::gkTrackSegmentsDataType; | |
75 | } | |
76 | ||
77 | void AliHLTTPCGlobalMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
78 | { | |
79 | // XXX TODO: Find more realistic values. | |
80 | constBase = 0; | |
81 | inputMultiplier = 1.0; | |
82 | } | |
83 | ||
84 | AliHLTComponent* AliHLTTPCGlobalMergerComponent::Spawn() | |
85 | { | |
86 | return new AliHLTTPCGlobalMergerComponent; | |
87 | } | |
88 | ||
89 | void AliHLTTPCGlobalMergerComponent::SetMergerParameters(Double_t maxy,Double_t maxz,Double_t maxkappa,Double_t maxpsi,Double_t maxtgl) | |
90 | { | |
91 | fGlobalMerger->SetParameter( maxy, maxz, maxkappa, maxpsi, maxtgl ); | |
92 | } | |
93 | ||
94 | int AliHLTTPCGlobalMergerComponent::DoInit( int argc, const char** argv ) | |
95 | { | |
96 | if ( fGlobalMerger || fVertex ) | |
97 | return EINPROGRESS; | |
a6c02c85 | 98 | fGlobalMerger = new AliHLTTPCGlobalMerger(); |
99 | fVertex = new AliHLTTPCVertex(); | |
71d7c760 | 100 | SetMergerParameters(); |
101 | return 0; | |
102 | } | |
103 | ||
104 | int AliHLTTPCGlobalMergerComponent::DoDeinit() | |
105 | { | |
106 | if ( fGlobalMerger ) | |
107 | delete fGlobalMerger; | |
108 | fGlobalMerger = NULL; | |
109 | if ( fVertex ) | |
110 | delete fVertex; | |
111 | fVertex = NULL; | |
112 | return 0; | |
113 | } | |
114 | ||
115 | int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, | |
116 | AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
117 | AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks ) | |
118 | { | |
119 | const AliHLTComponent_BlockData* iter = NULL; | |
120 | const AliHLTComponent_BlockData* lastVertexBlock = NULL; | |
121 | unsigned long ndx; | |
122 | ||
123 | std::vector<SliceData> slices; | |
124 | std::vector<SliceData>::iterator sdIter, sdEnd; | |
125 | int minSlice = INT_MAX, maxSlice = 0; | |
126 | bool found; | |
127 | AliHLTTPCTrackletData* inPtr; | |
128 | AliHLTTPCTrackletData* outPtr; | |
129 | UInt_t tSize = 0; | |
130 | Int_t slice=0; | |
131 | ||
132 | // Create sorted (by slice number) list of data (tracks and vertex) for each slice present. | |
133 | // also note the min and max slice numbers | |
134 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
135 | { | |
136 | iter = blocks+ndx; | |
137 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
138 | found=false; | |
139 | sdIter = slices.begin(); | |
140 | sdEnd = slices.end(); | |
141 | while ( sdIter != sdEnd ) | |
142 | { | |
143 | if ( sdIter->fSlice > slice || sdIter->fSlice == slice ) | |
144 | break; | |
145 | sdIter++; | |
146 | } | |
db16520a | 147 | if ( sdIter==sdEnd || sdIter->fSlice>slice ) |
71d7c760 | 148 | { |
149 | if ( sdIter == sdEnd ) | |
150 | maxSlice = slice; | |
151 | if ( sdIter==slices.begin() ) | |
152 | minSlice = slice; | |
153 | SliceData sd; | |
154 | sd.fSlice = slice; | |
155 | sd.fVertexBlock = NULL; | |
156 | sd.fVertexBlockIndex = 0; | |
157 | sd.fTrackletBlock = NULL; | |
158 | sd.fTrackletBlockIndex = 0; | |
159 | sdIter = slices.insert( sdIter, sd ); | |
160 | } | |
161 | if ( sdIter->fSlice == slice ) | |
162 | { | |
163 | if ( iter->fDataType == AliHLTTPCDefinitions::gkTrackSegmentsDataType ) | |
164 | { | |
165 | if ( !sdIter->fTrackletBlock ) | |
166 | { | |
167 | sdIter->fTrackletBlock = iter; | |
168 | sdIter->fTrackletBlockIndex = ndx; | |
169 | } | |
170 | else | |
171 | { | |
172 | Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "Duplicate track data block", | |
173 | "Duplicate track data block for slice %lu in event 0x%08lX (%lu) - previous block: %lu - new block: %lu.", | |
174 | slice, evtData.fEventID, evtData.fEventID, sdIter->fTrackletBlockIndex, ndx ); | |
175 | } | |
176 | } | |
177 | if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType ) | |
178 | { | |
179 | lastVertexBlock = iter; | |
180 | if ( !sdIter->fVertexBlock ) | |
181 | { | |
182 | sdIter->fVertexBlock = iter; | |
183 | sdIter->fVertexBlockIndex = ndx; | |
184 | } | |
185 | else | |
186 | { | |
187 | Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "Duplicate vertex data block", | |
188 | "Duplicate vertex data block for slice %lu in event 0x%08lX (%lu) - previous block: %lu - new block: %lu.", | |
189 | slice, evtData.fEventID, evtData.fEventID, sdIter->fVertexBlockIndex, ndx ); | |
190 | } | |
191 | } | |
192 | } | |
193 | } | |
194 | ||
db16520a | 195 | //fGlobalMerger->Setup( minSlice, maxSlice ); |
196 | fGlobalMerger->Setup( 0, 35 ); | |
71d7c760 | 197 | |
198 | if ( !lastVertexBlock ) | |
199 | { | |
db16520a | 200 | Logging( kHLTLogInfo, "HLT::GlobalMerger::DoEvent", "No vertex data block", |
71d7c760 | 201 | "No vertex data block found for event 0x%08lX (%lu).", evtData.fEventID, evtData.fEventID ); |
202 | fVertex->SetZero(); | |
203 | } | |
204 | else | |
a6c02c85 | 205 | fVertex->Read( (AliHLTTPCVertexData*)( lastVertexBlock->fPtr ) ); |
71d7c760 | 206 | |
207 | // Add all tracks into the merger | |
208 | sdIter = slices.begin(); | |
209 | sdEnd = slices.end(); | |
db16520a | 210 | int lastSlice = -1; |
71d7c760 | 211 | while ( sdIter != sdEnd ) |
212 | { | |
213 | if ( sdIter->fVertexBlock ) | |
214 | { | |
a6c02c85 | 215 | fVertex->Read( (AliHLTTPCVertexData*)( sdIter->fVertexBlock->fPtr ) ); |
71d7c760 | 216 | fGlobalMerger->SetVertex( fVertex ); |
217 | } | |
db16520a | 218 | for ( int slNr=lastSlice+1; slNr<=sdIter->fSlice; slNr++ ) |
219 | fGlobalMerger->InitSlice( slNr ); | |
220 | if ( sdIter->fTrackletBlock ) | |
71d7c760 | 221 | { |
db16520a | 222 | inPtr = (AliHLTTPCTrackletData*)( sdIter->fTrackletBlock->fPtr ); |
223 | if ( !inPtr ) | |
224 | { | |
225 | Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "No track data block", | |
226 | "No track data block found for event 0x%08lX (%lu).", evtData.fEventID, evtData.fEventID ); | |
227 | } | |
228 | else | |
229 | { | |
230 | //fGlobalMerger->InitSlice( sdIter->fSlice ); | |
231 | fGlobalMerger->FillTracks( inPtr->fTrackletCnt, inPtr->fTracklets ); | |
232 | } | |
71d7c760 | 233 | } |
db16520a | 234 | lastSlice = sdIter->fSlice; |
71d7c760 | 235 | sdIter++; |
236 | } | |
db16520a | 237 | for ( int slNr=lastSlice+1; slNr<=35; slNr++ ) |
238 | fGlobalMerger->InitSlice( slNr ); | |
239 | ||
71d7c760 | 240 | |
241 | // Now we can really merge | |
242 | fGlobalMerger->Merge(); | |
243 | ||
244 | UInt_t ntracks0=0; | |
245 | outPtr = (AliHLTTPCTrackletData*)(outputPtr); | |
246 | ||
247 | tSize = fGlobalMerger->GetOutTracks()->WriteTracks( ntracks0, outPtr->fTracklets ); | |
248 | outPtr->fTrackletCnt = ntracks0; | |
249 | ||
250 | tSize += sizeof(AliHLTTPCTrackletData); | |
251 | ||
252 | AliHLTComponent_BlockData bd; | |
253 | FillBlockData( bd ); | |
254 | bd.fOffset = 0; | |
255 | bd.fSize = tSize; | |
256 | bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 ); | |
257 | outputBlocks.push_back( bd ); | |
258 | ||
259 | size = tSize; | |
260 | return 0; | |
261 | } | |
262 | ||
263 |