]>
Commit | Line | Data |
---|---|---|
ec6160d5 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Jacek Otwinowski <Jacek.Otwinowski@gsi.de> * | |
8 | //* for The ALICE HLT 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 | /** @file AliHLTGlobalTrackMergerComponent.cxx | |
20 | @author Jacek Otwinowski | |
21 | @date | |
22 | @brief HLT global track merger component. | |
23 | */ | |
24 | ||
25 | using namespace std; | |
26 | #include <climits> | |
27 | #include <cassert> | |
28 | #include "AliHLTTPCTransform.h" | |
29 | #include "AliHLTTPCGlobalMerger.h" | |
30 | #include "AliHLTTPCVertex.h" | |
31 | #include "AliHLTTPCVertexData.h" | |
32 | #include "AliHLTTPCTrack.h" | |
33 | ||
34 | //#include "AliHLTTPCSpacePointData.h" | |
35 | //#include "AliHLTTPCClusterDataFormat.h" | |
36 | #include "AliHLTTPCTrackletDataFormat.h" | |
37 | #include "AliHLTTPCTrackSegmentData.h" | |
38 | #include "AliHLTTPCTrackArray.h" | |
39 | #include "AliHLTTPCDefinitions.h" | |
40 | #include "AliHLTTRDDefinitions.h" | |
41 | #include <cstdlib> | |
42 | #include <cerrno> | |
43 | ||
44 | #include "AliESDEvent.h" | |
45 | #include "AliTracker.h" | |
46 | #include "AliTRDtrackV1.h" | |
47 | #include "AliHLTGlobalTrackMerger.h" | |
48 | ||
49 | #include "AliHLTGlobalTrackMergerComponent.h" | |
50 | ||
51 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
52 | ClassImp(AliHLTGlobalTrackMergerComponent); | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliHLTGlobalTrackMergerComponent::AliHLTGlobalTrackMergerComponent() : AliHLTProcessor(), | |
56 | fGlobalTrackMerger(0), | |
57 | fESD(0) | |
58 | { | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliHLTGlobalTrackMergerComponent::~AliHLTGlobalTrackMergerComponent() | |
63 | { | |
64 | // see header file for class documentation | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | const char* AliHLTGlobalTrackMergerComponent::GetComponentID() | |
69 | { | |
70 | // see header file for class documentation | |
71 | return "GlobalTrackMerger"; | |
72 | } | |
73 | ||
74 | //_____________________________________________________________________________ | |
75 | void AliHLTGlobalTrackMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
76 | { | |
77 | // see header file for class documentation | |
78 | list.clear(); | |
79 | list.push_back( AliHLTTPCDefinitions::fgkTracksDataType ); | |
80 | list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType ); | |
81 | } | |
82 | ||
83 | //_____________________________________________________________________________ | |
84 | AliHLTComponentDataType AliHLTGlobalTrackMergerComponent::GetOutputDataType() | |
85 | { | |
86 | // see header file for class documentation | |
87 | return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC; | |
88 | } | |
89 | ||
90 | //_____________________________________________________________________________ | |
91 | void AliHLTGlobalTrackMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
92 | { | |
93 | // see header file for class documentation | |
94 | // XXX TODO: Find more realistic values. | |
95 | constBase = 20000; | |
96 | inputMultiplier = 1.0; | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | AliHLTComponent* AliHLTGlobalTrackMergerComponent::Spawn() | |
101 | { | |
102 | // see header file for class documentation | |
103 | return new AliHLTGlobalTrackMergerComponent; | |
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | void AliHLTGlobalTrackMergerComponent::SetMergerParameters(Double_t maxy,Double_t maxz,Double_t maxkappa,Double_t maxpsi,Double_t maxtgl) | |
108 | { | |
109 | // see header file for class documentation | |
110 | fGlobalTrackMerger->SetParameter( maxy, maxz, maxkappa, maxpsi, maxtgl ); | |
111 | } | |
112 | ||
113 | //_____________________________________________________________________________ | |
114 | int AliHLTGlobalTrackMergerComponent::DoInit( int /*argc*/, const char** /*argv*/ ) | |
115 | { | |
116 | // see header file for class documentation | |
117 | int iResult = 0; | |
118 | ||
119 | // Init merger | |
120 | fGlobalTrackMerger = new AliHLTGlobalTrackMerger(); | |
121 | ||
122 | // output of the component | |
123 | fESD = new AliESDEvent(); | |
124 | if (fESD) { | |
125 | fESD->CreateStdContent(); | |
126 | } | |
127 | ||
128 | if (!fGlobalTrackMerger || !fESD ) { | |
129 | HLTError("failed creating internal objects"); | |
130 | iResult=-ENOMEM; | |
131 | return iResult; | |
132 | } | |
133 | ||
134 | SetMergerParameters(); | |
135 | ||
136 | return iResult; | |
137 | } | |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | int AliHLTGlobalTrackMergerComponent::DoDeinit() | |
141 | { | |
142 | // see header file for class documentation | |
143 | if(fGlobalTrackMerger) delete fGlobalTrackMerger; fGlobalTrackMerger =0; | |
144 | if(fESD) delete fESD; fESD = 0; | |
145 | return 0; | |
146 | } | |
147 | ||
148 | //_____________________________________________________________________________ | |
149 | int AliHLTGlobalTrackMergerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
150 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, | |
151 | AliHLTUInt32_t& /*size*/, AliHLTComponentBlockDataList& /*outputBlocks*/ ) | |
152 | { | |
153 | // | |
154 | // global track merger function | |
155 | // takes TRD and TPC tracks and merges them | |
156 | // | |
157 | HLTInfo("DoEvent processing data"); | |
158 | ||
159 | // see header file for class documentation | |
160 | int iResult=0; | |
161 | ||
162 | if(!fGlobalTrackMerger || !fESD) { | |
163 | HLTError("component not initialized"); | |
164 | iResult=-ENOMEM; | |
165 | return iResult; | |
166 | } | |
167 | ||
168 | if(!blocks) { | |
169 | HLTError("no blocks"); | |
170 | iResult=-EINVAL; | |
171 | return iResult; | |
172 | } | |
173 | ||
174 | const AliHLTComponentBlockData* iter=0; | |
175 | AliHLTTPCTrackletData* inPtr=0; | |
176 | Bool_t bIsTRDTrackDataBlock=kFALSE; | |
177 | Bool_t bIsTPCTrackDataBlock=kFALSE; | |
178 | TClonesArray *aTRDTracks=0; | |
179 | Int_t minSlice = INT_MAX, maxSlice = 0; | |
180 | Int_t slice; | |
181 | ||
182 | unsigned long ndx; | |
a9f060e5 | 183 | Int_t nTRDDataBlocks = 0; |
184 | Int_t nTPCDataBlocks = 0; | |
ec6160d5 | 185 | for ( ndx = 0; ndx < evtData.fBlockCnt && iResult>=0; ndx++ ) |
186 | { | |
187 | iter = blocks+ndx; | |
188 | bIsTRDTrackDataBlock=kFALSE; | |
189 | bIsTPCTrackDataBlock=kFALSE; | |
190 | ||
191 | // check if TPC or TRD tracks | |
192 | if(!(bIsTRDTrackDataBlock=(iter->fDataType==AliHLTTRDDefinitions::fgkTRDSATracksDataType)) && | |
193 | !(bIsTPCTrackDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkTracksDataType))) { | |
194 | continue; | |
195 | } | |
196 | ||
197 | // collect TRD tracks from all SM | |
198 | // one TClonesArray of tracks per SM | |
199 | if(bIsTRDTrackDataBlock) | |
200 | { | |
a9f060e5 | 201 | nTRDDataBlocks++; |
202 | if(nTRDDataBlocks>1) continue; | |
ec6160d5 | 203 | for (TObject *pObj = (TObject *)GetFirstInputObject(AliHLTTRDDefinitions::fgkTRDSATracksDataType,"TClonesArray",0); |
204 | pObj !=0 && iResult>=0; | |
205 | pObj = (TObject *)GetNextInputObject(0)) { | |
206 | aTRDTracks = dynamic_cast<TClonesArray*>(pObj); | |
207 | if (!aTRDTracks) continue; | |
208 | ||
a9f060e5 | 209 | HLTInfo("reading block %d, trdTracks %d", ndx, aTRDTracks->GetEntriesFast()); |
ec6160d5 | 210 | |
a9f060e5 | 211 | // load TRD tracks |
ec6160d5 | 212 | if (fGlobalTrackMerger->LoadTracks(aTRDTracks,fESD) == kFALSE) { |
213 | HLTError("Cannot load TRD tracks"); | |
214 | iResult=-ENOMEM; | |
215 | return iResult; | |
216 | } | |
217 | } | |
218 | aTRDTracks->Delete(); | |
219 | } | |
220 | ||
221 | // collect TPC tracks from whole TPC | |
222 | if (bIsTPCTrackDataBlock) | |
223 | { | |
a9f060e5 | 224 | nTPCDataBlocks++; |
225 | if(nTPCDataBlocks>1) continue; | |
226 | ||
ec6160d5 | 227 | slice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification); |
228 | if(slice<minSlice) minSlice = slice; | |
229 | if(slice>maxSlice) maxSlice = slice; | |
230 | ||
231 | //minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification); | |
232 | //maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification); | |
233 | ||
234 | AliHLTTPCTrackArray tracks; | |
235 | inPtr=(AliHLTTPCTrackletData*)iter->fPtr; | |
236 | ||
a9f060e5 | 237 | HLTInfo("reading block %d (slice %d): %d tracklets", ndx, slice, inPtr->fTrackletCnt); |
ec6160d5 | 238 | |
239 | // read TPC track segments from memory | |
a9f060e5 | 240 | if((iResult=tracks.FillTracksChecked(inPtr->fTracklets, inPtr->fTrackletCnt, iter->fSize, -1/*global track*/, 0/*don't rotate*/))>=0) |
241 | { | |
242 | // load TPC tracks | |
ec6160d5 | 243 | if (fGlobalTrackMerger->LoadTracks(&tracks,fESD) == kFALSE) { |
244 | HLTError("Cannot load TPC tracks"); | |
245 | iResult=-ENOMEM; | |
246 | return iResult; | |
247 | } | |
a9f060e5 | 248 | } |
249 | } | |
ec6160d5 | 250 | } |
251 | ||
252 | // set magnetic field | |
253 | fESD->SetMagneticField(AliTracker::GetBz()); | |
254 | ||
255 | // merge tracks | |
256 | Bool_t isMerged = fGlobalTrackMerger->Merge(fESD); | |
257 | if(!isMerged) { | |
a9f060e5 | 258 | HLTInfo("No merged tracks"); |
ec6160d5 | 259 | } |
260 | ||
261 | // try to propagate all tracks to DCA to primary vertex | |
262 | fGlobalTrackMerger->PropagateTracksToDCA(fESD); | |
263 | ||
264 | // calculate specification | |
265 | // AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 ); | |
266 | // HLTInfo("minSlice %d, maxSlice %d", minSlice, maxSlice); | |
267 | ||
268 | // send output data | |
269 | //PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification); | |
270 | PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC); | |
271 | ||
a9f060e5 | 272 | // clean ESD event content |
ec6160d5 | 273 | fESD->Reset(); |
274 | ||
275 | return iResult; | |
276 | } | |
277 | ||
278 |