]>
Commit | Line | Data |
---|---|---|
a1408c4b | 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: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
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 | ||
a0b62fd1 | 19 | // @file AliHLTGlobalEsdConverterComponent.cxx |
20 | // @author Matthias Richter | |
21 | // @date | |
22 | // @brief Global ESD converter component. | |
23 | // | |
a1408c4b | 24 | |
25 | // see header file for class documentation | |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
31 | #include <cassert> | |
32 | #include "AliHLTGlobalEsdConverterComponent.h" | |
33 | #include "AliHLTGlobalBarrelTrack.h" | |
34 | #include "AliHLTExternalTrackParam.h" | |
093b64dc | 35 | #include "AliHLTTrackMCLabel.h" |
6117ef63 | 36 | #include "AliHLTCTPData.h" |
2352edc3 | 37 | #include "AliHLTTPCDefinitions.h" |
38 | #include "AliHLTTPCSpacePointData.h" | |
39 | #include "AliHLTTPCClusterDataFormat.h" | |
40 | #include "AliTPCclusterMI.h" | |
41 | #include "AliTPCseed.h" | |
5961f15d | 42 | #include "AliITStrackV2.h" |
2352edc3 | 43 | #include "AliESDfriend.h" |
44 | #include "AliESDfriendTrack.h" | |
45 | #include "AliHLTTPCTransform.h" | |
331d51c5 | 46 | #include "AliHLTErrorGuard.h" |
a1408c4b | 47 | #include "AliESDEvent.h" |
48 | #include "AliESDtrack.h" | |
f064ef44 | 49 | #include "AliESDMuonTrack.h" |
fe0324de | 50 | #include "AliESDMuonCluster.h" |
a1408c4b | 51 | #include "AliCDBEntry.h" |
52 | #include "AliCDBManager.h" | |
18ada816 | 53 | #include "AliPID.h" |
a1408c4b | 54 | #include "TTree.h" |
55 | #include "TList.h" | |
f064ef44 | 56 | #include "TClonesArray.h" |
f9ce172e | 57 | #include "TTimeStamp.h" |
58 | #include "THnSparse.h" | |
9a9467ed | 59 | #include "AliHLTESDCaloClusterMaker.h" |
60 | #include "AliHLTCaloClusterDataStruct.h" | |
61 | #include "AliHLTCaloClusterReader.h" | |
62 | #include "AliESDCaloCluster.h" | |
331d51c5 | 63 | #include "AliESDVZERO.h" |
d9386025 | 64 | #include "AliHLTGlobalVertexerComponent.h" |
b7449dbe | 65 | #include "AliHLTVertexFinderBase.h" |
3ccabd94 | 66 | #include "AliSysInfo.h" |
5961f15d | 67 | #include "AliHLTSAPTrackerData.h" |
68 | #include "AliFlatESDVertex.h" | |
a1408c4b | 69 | |
70 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
71 | ClassImp(AliHLTGlobalEsdConverterComponent) | |
72 | ||
73 | AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent() | |
74 | : AliHLTProcessor() | |
a1408c4b | 75 | , fWriteTree(0) |
093b64dc | 76 | , fVerbosity(0) |
8b7a0f3c | 77 | , fESD(NULL) |
accd913d | 78 | , fESDfriend(NULL) |
a8714ffa | 79 | , fSolenoidBz(-5.00668) |
b7342e4d | 80 | , fMakeFriends(0) |
57a4102f | 81 | , fBenchmark("EsdConverter") |
a1408c4b | 82 | { |
83 | // see header file for class documentation | |
84 | // or | |
85 | // refer to README to build package | |
86 | // or | |
87 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
2352edc3 | 88 | for( int i=0; i<fkNPartition; i++ ){ |
89 | fPartitionClusters[i] = 0; | |
90 | fNPartitionClusters[i] = 0; | |
91 | } | |
a1408c4b | 92 | } |
93 | ||
94 | AliHLTGlobalEsdConverterComponent::~AliHLTGlobalEsdConverterComponent() | |
95 | { | |
96 | // see header file for class documentation | |
b7342e4d | 97 | if (fESD) delete fESD; |
98 | if (fESDfriend) delete fESDfriend; | |
2352edc3 | 99 | for( int i=0; i<fkNPartition; i++ ){ |
accd913d | 100 | delete[] fPartitionClusters[i]; |
2352edc3 | 101 | } |
a1408c4b | 102 | } |
103 | ||
104 | int AliHLTGlobalEsdConverterComponent::Configure(const char* arguments) | |
105 | { | |
106 | // see header file for class documentation | |
107 | int iResult=0; | |
108 | if (!arguments) return iResult; | |
109 | ||
110 | TString allArgs=arguments; | |
111 | TString argument; | |
112 | int bMissingParam=0; | |
113 | ||
114 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
115 | if (pTokens) { | |
116 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
d7d775b6 | 117 | argument=((TObjString*)pTokens->At(i))->String(); |
a1408c4b | 118 | if (argument.IsNull()) continue; |
119 | ||
120 | if (argument.CompareTo("-solenoidBz")==0) { | |
121 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
75970b8d | 122 | HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz()); |
a1408c4b | 123 | continue; |
124 | } else { | |
125 | HLTError("unknown argument %s", argument.Data()); | |
126 | iResult=-EINVAL; | |
127 | break; | |
128 | } | |
129 | } | |
130 | delete pTokens; | |
131 | } | |
132 | if (bMissingParam) { | |
133 | HLTError("missing parameter for argument %s", argument.Data()); | |
134 | iResult=-EINVAL; | |
135 | } | |
136 | ||
137 | return iResult; | |
138 | } | |
139 | ||
140 | int AliHLTGlobalEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
141 | { | |
142 | // see header file for class documentation | |
143 | int iResult=0; | |
75970b8d | 144 | const char* path=NULL; |
a1408c4b | 145 | const char* defaultNotify=""; |
146 | if (cdbEntry) { | |
147 | path=cdbEntry; | |
148 | defaultNotify=" (default)"; | |
149 | } | |
150 | if (path) { | |
151 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
152 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
153 | if (pEntry) { | |
154 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
155 | if (pString) { | |
d7d775b6 | 156 | HLTInfo("received configuration object string: \'%s\'", pString->String().Data()); |
157 | iResult=Configure(pString->String().Data()); | |
a1408c4b | 158 | } else { |
159 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
160 | } | |
161 | } else { | |
162 | HLTError("can not fetch object \"%s\" from CDB", path); | |
163 | } | |
164 | } | |
165 | ||
166 | return iResult; | |
167 | } | |
168 | ||
169 | void AliHLTGlobalEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
170 | { | |
171 | // see header file for class documentation | |
172 | list.push_back(kAliHLTDataTypeTrack); | |
173 | list.push_back(kAliHLTDataTypeTrackMC); | |
9a9467ed | 174 | list.push_back(kAliHLTDataTypeCaloCluster); |
0973c527 | 175 | list.push_back(kAliHLTDataTypedEdx ); |
7f167a74 | 176 | list.push_back(kAliHLTDataTypeESDVertex ); |
f064ef44 | 177 | list.push_back(kAliHLTDataTypeESDObject); |
178 | list.push_back(kAliHLTDataTypeTObject); | |
d9963894 | 179 | list.push_back(kAliHLTDataTypeGlobalVertexer); |
b7449dbe | 180 | list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s |
181 | list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer | |
182 | list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex | |
331d51c5 | 183 | list.push_back(kAliHLTDataTypeESDContent); |
2352edc3 | 184 | list.push_back( AliHLTTPCDefinitions::fgkClustersDataType ); |
5961f15d | 185 | list.push_back(kAliHLTDataTypeFlatESDVertex); // VertexTracks resonctructed using SAP ITS tracks |
186 | list.push_back(kAliHLTDataTypeITSSAPData); // SAP ITS tracks | |
a1408c4b | 187 | } |
188 | ||
189 | AliHLTComponentDataType AliHLTGlobalEsdConverterComponent::GetOutputDataType() | |
190 | { | |
191 | // see header file for class documentation | |
accd913d | 192 | return kAliHLTMultipleDataType; |
193 | } | |
194 | ||
195 | int AliHLTGlobalEsdConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){ | |
196 | // see header file for class documentation | |
197 | ||
198 | tgtList.clear(); | |
199 | tgtList.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut ); | |
200 | tgtList.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut ); | |
201 | return tgtList.size(); | |
a1408c4b | 202 | } |
203 | ||
204 | void AliHLTGlobalEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
205 | { | |
206 | // see header file for class documentation | |
207 | constBase=2000000; | |
208 | inputMultiplier=10.0; | |
209 | } | |
210 | ||
211 | int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv) | |
212 | { | |
213 | // see header file for class documentation | |
214 | int iResult=0; | |
215 | TString argument=""; | |
216 | int bMissingParam=0; | |
a1408c4b | 217 | |
d57fc872 | 218 | // default list of skiped ESD objects |
219 | TString skipObjects= | |
220 | // "AliESDRun," | |
221 | // "AliESDHeader," | |
421e1221 | 222 | // "AliESDZDC," |
d57fc872 | 223 | "AliESDFMD," |
224 | // "AliESDVZERO," | |
225 | // "AliESDTZERO," | |
226 | // "TPCVertex," | |
227 | // "SPDVertex," | |
228 | // "PrimaryVertex," | |
229 | // "AliMultiplicity," | |
230 | // "PHOSTrigger," | |
231 | // "EMCALTrigger," | |
232 | // "SPDPileupVertices," | |
233 | // "TrkPileupVertices," | |
234 | "Cascades," | |
235 | "Kinks," | |
236 | "AliRawDataErrorLogs," | |
237 | "AliESDACORDE"; | |
238 | ||
f167b631 | 239 | iResult=Reconfigure(NULL, NULL); |
240 | TString allArgs = ""; | |
241 | for ( int i = 0; i < argc; i++ ) { | |
242 | if ( !allArgs.IsNull() ) allArgs += " "; | |
243 | allArgs += argv[i]; | |
244 | } | |
a1408c4b | 245 | |
f167b631 | 246 | TObjArray* pTokens=allArgs.Tokenize(" "); |
247 | if (pTokens) { | |
248 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
d7d775b6 | 249 | argument=((TObjString*)pTokens->At(i))->String(); |
f167b631 | 250 | if (argument.IsNull()) continue; |
251 | ||
252 | // -notree | |
253 | if (argument.CompareTo("-notree")==0) { | |
254 | fWriteTree=0; | |
255 | ||
256 | // -tree | |
257 | } else if (argument.CompareTo("-tree")==0) { | |
258 | fWriteTree=1; | |
259 | } else if (argument.CompareTo("-solenoidBz")==0) { | |
260 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
d7d775b6 | 261 | HLTInfo("Magnetic Field set to: %s", ((TObjString*)pTokens->At(i))->String().Data()); |
d57fc872 | 262 | HLTWarning("argument '-solenoidBz' is deprecated, solenoid field initiaized from CDB settings"); |
f167b631 | 263 | continue; |
d57fc872 | 264 | } else if (argument.Contains("-skipobject=")) { |
265 | argument.ReplaceAll("-skipobject=", ""); | |
266 | skipObjects=argument; | |
f167b631 | 267 | } else { |
268 | HLTError("unknown argument %s", argument.Data()); | |
d57fc872 | 269 | iResult=-EINVAL; |
f167b631 | 270 | break; |
271 | } | |
a1408c4b | 272 | } |
273 | } | |
274 | if (bMissingParam) { | |
275 | HLTError("missing parameter for argument %s", argument.Data()); | |
276 | iResult=-EINVAL; | |
277 | } | |
278 | ||
75970b8d | 279 | fSolenoidBz=GetBz(); |
280 | ||
b7342e4d | 281 | if(fESD) delete fESD; |
accd913d | 282 | fESD = NULL; |
b7342e4d | 283 | if(fESDfriend) delete fESDfriend; |
284 | fESDfriend=NULL; | |
accd913d | 285 | |
a1408c4b | 286 | if (iResult>=0) { |
287 | fESD = new AliESDEvent; | |
288 | if (fESD) { | |
289 | fESD->CreateStdContent(); | |
d57fc872 | 290 | |
291 | // remove some of the objects which are not needed | |
292 | if (fESD->GetList() && !skipObjects.IsNull()) { | |
293 | pTokens=skipObjects.Tokenize(","); | |
294 | if (pTokens) { | |
295 | const char* id=NULL; | |
296 | TIter next(pTokens); | |
297 | TObject* pObject=NULL; | |
298 | while ((pObject=next())!=NULL) { | |
d7d775b6 | 299 | id=((TObjString*)pObject)->String().Data(); |
a0b62fd1 | 300 | TObject* pObj=fESD->GetList()->FindObject(id); |
301 | if (pObj) { | |
d57fc872 | 302 | HLTDebug("removing object %s", id); |
a0b62fd1 | 303 | fESD->GetList()->Remove(pObj); |
304 | delete pObj; | |
d57fc872 | 305 | } else { |
306 | HLTWarning("failed to remove object '%s' from ESD", id); | |
307 | } | |
308 | } | |
d57fc872 | 309 | fESD->GetStdContent(); |
310 | delete pTokens; | |
311 | } | |
312 | } | |
a1408c4b | 313 | } else { |
314 | iResult=-ENOMEM; | |
315 | } | |
6117ef63 | 316 | |
317 | SetupCTPData(); | |
a1408c4b | 318 | } |
accd913d | 319 | |
320 | if( iResult>=0 && fMakeFriends ){ | |
321 | fESDfriend = new AliESDfriend(); | |
322 | } | |
a1408c4b | 323 | |
57a4102f | 324 | fBenchmark.SetTimer(0,"total"); |
325 | ||
a1408c4b | 326 | return iResult; |
327 | } | |
328 | ||
329 | int AliHLTGlobalEsdConverterComponent::DoDeinit() | |
330 | { | |
331 | // see header file for class documentation | |
b7342e4d | 332 | if(fESD) delete fESD; |
a1408c4b | 333 | fESD=NULL; |
b7342e4d | 334 | if(fESDfriend) delete fESDfriend; |
accd913d | 335 | fESDfriend = NULL; |
a1408c4b | 336 | return 0; |
337 | } | |
338 | ||
3ccabd94 | 339 | int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& evtData, |
6117ef63 | 340 | AliHLTComponentTriggerData& trigData) |
a1408c4b | 341 | { |
342 | // see header file for class documentation | |
343 | int iResult=0; | |
3ccabd94 | 344 | |
a1408c4b | 345 | if (!fESD) return -ENODEV; |
346 | ||
251a2c81 | 347 | if (!IsDataEvent()) return iResult; |
348 | fBenchmark.StartNewEvent(); | |
57a4102f | 349 | fBenchmark.Start(0); |
350 | ||
2352edc3 | 351 | for(Int_t i=0; i<fkNPartition; i++){ |
352 | delete[] fPartitionClusters[i]; | |
353 | fPartitionClusters[i] = 0; | |
354 | fNPartitionClusters[i] = 0; | |
accd913d | 355 | } |
356 | ||
2352edc3 | 357 | AliESDEvent* pESD = fESD; |
358 | ||
a1408c4b | 359 | pESD->Reset(); |
360 | pESD->SetMagneticField(fSolenoidBz); | |
6117ef63 | 361 | pESD->SetRunNumber(GetRunNo()); |
6700298e | 362 | pESD->SetPeriodNumber(GetPeriodNumber()); |
363 | pESD->SetOrbitNumber(GetOrbitNumber()); | |
364 | pESD->SetBunchCrossNumber(GetBunchCrossNumber()); | |
365 | pESD->SetTimeStamp(GetTimeStamp()); | |
a1408c4b | 366 | |
6117ef63 | 367 | const AliHLTCTPData* pCTPData=CTPData(); |
368 | if (pCTPData) { | |
16e6f752 | 369 | AliHLTTriggerMask_t mask=pCTPData->ActiveTriggers(trigData); |
6117ef63 | 370 | for (int index=0; index<gkNCTPTriggerClasses; index++) { |
16e6f752 | 371 | if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue; |
6117ef63 | 372 | pESD->SetTriggerClass(pCTPData->Name(index), index); |
373 | } | |
16e6f752 | 374 | //first 50 triggers |
375 | AliHLTTriggerMask_t mask50; | |
376 | mask50.set(); // set all bits | |
377 | mask50 >>= 50; // shift 50 right | |
378 | pESD->SetTriggerMask((mask&mask50).to_ulong()); | |
9eee9fe9 | 379 | //next 50 |
16e6f752 | 380 | pESD->SetTriggerMaskNext50((mask>>50).to_ulong()); |
6117ef63 | 381 | } |
382 | ||
a1408c4b | 383 | TTree* pTree = NULL; |
384 | if (fWriteTree) | |
385 | pTree = new TTree("esdTree", "Tree with HLT ESD objects"); | |
386 | ||
387 | if (pTree) { | |
388 | pTree->SetDirectory(0); | |
389 | } | |
390 | ||
accd913d | 391 | if( fESDfriend ) fESDfriend->Reset(); |
392 | ||
393 | if ((iResult=ProcessBlocks(pTree, pESD, fESDfriend))>=0) { | |
a1408c4b | 394 | // TODO: set the specification correctly |
395 | if (pTree) { | |
396 | // the esd structure is written to the user info and is | |
397 | // needed in te ReadFromTree method to read all objects correctly | |
398 | pTree->GetUserInfo()->Add(pESD); | |
399 | pESD->WriteToTree(pTree); | |
7a9de6d1 | 400 | iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0); |
a1408c4b | 401 | } else { |
7a9de6d1 | 402 | iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0); |
a1408c4b | 403 | } |
57a4102f | 404 | fBenchmark.AddOutput(GetLastObjectSize()); |
accd913d | 405 | if( iResult>=0 && fMakeFriends ){ |
406 | iResult=PushBack(fESDfriend, kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut, 0); | |
407 | fBenchmark.AddOutput(GetLastObjectSize()); | |
408 | } | |
a1408c4b | 409 | } |
410 | if (pTree) { | |
411 | // clear user info list to prevent objects from being deleted | |
412 | pTree->GetUserInfo()->Clear(); | |
413 | delete pTree; | |
414 | } | |
57a4102f | 415 | |
416 | fBenchmark.Stop(0); | |
b7342e4d | 417 | HLTBenchmark( fBenchmark.GetStatistics() ); |
f9ce172e | 418 | |
2352edc3 | 419 | for(Int_t i=0; i<fkNPartition; i++){ |
b7342e4d | 420 | delete[] fPartitionClusters[i]; |
421 | fPartitionClusters[i] = 0; | |
422 | fNPartitionClusters[i] = 0; | |
2352edc3 | 423 | } |
accd913d | 424 | |
425 | if( fESDfriend ) fESDfriend->Reset(); | |
426 | if( fESD ) fESD->Reset(); | |
427 | ||
a1408c4b | 428 | return iResult; |
429 | } | |
430 | ||
accd913d | 431 | int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD, AliESDfriend *pESDfriend ) |
a1408c4b | 432 | { |
433 | // see header file for class documentation | |
434 | ||
435 | int iResult=0; | |
436 | int iAddedDataBlocks=0; | |
437 | ||
b7449dbe | 438 | // check if there is an ESD block in the input and copy its content first to the |
439 | // ESD | |
440 | const TObject* pEsdObj = GetFirstInputObject(kAliHLTDataTypeESDObject, "AliESDEvent"); | |
441 | AliESDEvent* pInputESD=NULL; | |
442 | if (pEsdObj) pInputESD=dynamic_cast<AliESDEvent*>(const_cast<TObject*>(pEsdObj)); | |
443 | if (pInputESD) { | |
444 | pInputESD->GetStdContent(); | |
445 | *pESD=*pInputESD; | |
446 | } | |
447 | if (GetNextInputObject()!=NULL) { | |
448 | HLTWarning("handling of multiple ESD input objects not implemented, skipping input"); | |
449 | } | |
450 | ||
a1408c4b | 451 | // Barrel tracking |
e85f2e31 | 452 | // tracks are based on the TPC tracks, and only updated from the ITS information |
453 | // Sequence: | |
454 | // 1) extract MC information for TPC and ITS from specific data blocks and store in | |
455 | // intermediate vector arrays | |
456 | // 2) extract TPC tracks, update with MC labels if available, the track parameters | |
457 | // are estimated at the first cluster position | |
458 | // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp) | |
459 | // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner) | |
460 | // 2.3) update kTPCrefit using the same parameters at the first cluster position | |
461 | // HLT has strictly spoking no refit, but we want the flag to be set | |
462 | // can be changed to be done after all the individual barrel detector parameters | |
463 | // have been updated by looping over the tracks again | |
464 | // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS | |
465 | // tracking information | |
466 | // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin | |
467 | // 3.2) update with kITSin | |
468 | // TODO 2010-07-12 find out if the kITSrefit has to be set as well | |
469 | // 4) extract TRD tracks and add to ESD | |
470 | // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks | |
331d51c5 | 471 | // 5) Add Trigger Detectors |
472 | // VZERO, ZDC | |
e85f2e31 | 473 | |
2352edc3 | 474 | // read the clusters |
475 | // ---------- Access to clusters --------------------// | |
5961f15d | 476 | /* |
477 | const AliHLTComponentBlockData* pBl0=GetFirstInputBlock(); | |
478 | int cnt = 0; | |
479 | while (pBl0) { | |
480 | char tp[9],org[5]; | |
481 | strncpy(tp,pBl0->fDataType.fID,8); | |
482 | tp[8] = '0'; | |
483 | strncpy(org,pBl0->fDataType.fOrigin,4); | |
484 | org[4] = '0'; | |
485 | // | |
486 | printf(">>> Bl%3d %8s|%4s of size %d\n",cnt++,tp,org,pBl0->fSize); | |
487 | pBl0 = GetNextInputBlock(); | |
488 | }; | |
489 | */ | |
2352edc3 | 490 | for(Int_t i=0; i<fkNPartition; i++){ |
491 | delete[] fPartitionClusters[i]; | |
492 | fPartitionClusters[i] = 0; | |
493 | fNPartitionClusters[i] = 0; | |
494 | } | |
495 | ||
accd913d | 496 | if( pESDfriend ){ |
2352edc3 | 497 | |
498 | int nInputClusters = 0; | |
499 | ||
500 | for(const AliHLTComponentBlockData *iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){ | |
501 | ||
502 | if(iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType) continue; | |
503 | Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification); | |
504 | Int_t partition = AliHLTTPCDefinitions::GetMinPatchNr(iter->fSpecification); | |
505 | Int_t slicepartition = slice*6+partition; | |
506 | if(slicepartition<0 || slicepartition > fkNPartition){ | |
507 | HLTWarning("Wrong header of TPC cluster data, slice %d, partition %d", slice, partition ); | |
508 | continue; | |
509 | } | |
510 | ||
511 | AliHLTTPCClusterData *inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); | |
512 | nInputClusters += inPtrSP->fSpacePointCnt; | |
513 | ||
514 | delete[] fPartitionClusters[slicepartition]; | |
515 | fPartitionClusters[slicepartition] = new AliTPCclusterMI[inPtrSP->fSpacePointCnt]; | |
516 | fNPartitionClusters[slicepartition] = inPtrSP->fSpacePointCnt; | |
517 | ||
518 | // create offline clusters out of the HLT clusters | |
519 | ||
520 | for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) { | |
521 | AliHLTTPCSpacePointData *chlt = &( inPtrSP->fSpacePoints[i] ); | |
522 | AliTPCclusterMI *c = fPartitionClusters[slicepartition]+i; | |
523 | c->SetX(chlt->fX); | |
524 | c->SetY(chlt->fY); | |
525 | c->SetZ(chlt->fZ); | |
526 | c->SetSigmaY2(chlt->fSigmaY2); | |
527 | c->SetSigmaYZ( 0 ); | |
528 | c->SetSigmaZ2(chlt->fSigmaZ2); | |
529 | c->SetQ( chlt->fCharge ); | |
530 | c->SetMax( chlt->fQMax ); | |
531 | Int_t sector, row; | |
532 | Float_t padtime[3] = {0,chlt->fY,chlt->fZ}; | |
533 | AliHLTTPCTransform::Slice2Sector(slice,chlt->fPadRow, sector, row); | |
534 | AliHLTTPCTransform::Local2Raw( padtime, sector, row); | |
535 | c->SetDetector( sector ); | |
536 | c->SetRow( row ); | |
537 | c->SetPad( (Int_t) padtime[1] ); | |
538 | c->SetTimeBin( (Int_t) padtime[2] ); | |
539 | } | |
540 | } // end of loop over blocks of clusters | |
9be6e605 | 541 | |
542 | ||
543 | // fill event info | |
544 | { | |
545 | for( Int_t iSlice=0; iSlice<36; iSlice++ ){ | |
546 | int iSector = iSlice; | |
547 | int nclu = 0; | |
548 | for( Int_t iPartition=0; iPartition<3; iPartition++){ | |
549 | int slicepartition = iSlice*6+iPartition; | |
550 | nclu+= fNPartitionClusters[slicepartition]; | |
551 | } | |
552 | pESDfriend->SetNclustersTPC( iSector, nclu ); | |
553 | iSector = 36+iSlice; | |
554 | nclu = 0; | |
555 | for( Int_t iPartition=3; iPartition<6; iPartition++){ | |
556 | int slicepartition = iSlice*6+iPartition; | |
557 | nclu+= fNPartitionClusters[slicepartition]; | |
558 | } | |
559 | pESDfriend->SetNclustersTPC( iSector, nclu ); | |
560 | } | |
561 | } | |
562 | ||
563 | ||
564 | ||
2352edc3 | 565 | } |
566 | ||
e85f2e31 | 567 | // 1) first read MC information (if present) |
eb60b0c1 | 568 | std::map<int,int> mcLabelsTPC; |
d72d9d99 | 569 | std::map<int,int> mcLabelsITS; |
093b64dc | 570 | |
571 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC); | |
572 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 573 | |
574 | fBenchmark.AddInput(pBlock->fSize); | |
575 | ||
093b64dc | 576 | AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr ); |
577 | if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) { | |
578 | for( unsigned int il=0; il<dataPtr->fCount; il++ ){ | |
579 | AliHLTTrackMCLabel &lab = dataPtr->fLabels[il]; | |
eb60b0c1 | 580 | mcLabelsTPC[lab.fTrackID] = lab.fMCLabel; |
093b64dc | 581 | } |
582 | } else { | |
583 | HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", | |
584 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, | |
585 | dataPtr->fCount, pBlock->fSize); | |
586 | } | |
587 | } | |
d72d9d99 | 588 | |
589 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS); | |
590 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
591 | ||
592 | fBenchmark.AddInput(pBlock->fSize); | |
593 | ||
594 | AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr ); | |
595 | if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) { | |
596 | for( unsigned int il=0; il<dataPtr->fCount; il++ ){ | |
597 | AliHLTTrackMCLabel &lab = dataPtr->fLabels[il]; | |
598 | mcLabelsITS[lab.fTrackID] = lab.fMCLabel; | |
599 | } | |
600 | } else { | |
601 | HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", | |
602 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, | |
603 | dataPtr->fCount, pBlock->fSize); | |
604 | } | |
605 | } | |
606 | ||
093b64dc | 607 | |
0973c527 | 608 | // read dEdx information (if present) |
e85f2e31 | 609 | // TODO 2010-07-12 this needs to be verified |
0973c527 | 610 | |
611 | AliHLTFloat32_t *dEdxTPC = 0; | |
612 | Int_t ndEdxTPC = 0; | |
613 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC); | |
e38918a2 | 614 | pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) { |
57a4102f | 615 | fBenchmark.AddInput(pBlock->fSize); |
0973c527 | 616 | dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr ); |
72a916d9 | 617 | ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t)); |
0973c527 | 618 | } |
619 | ||
e85f2e31 | 620 | // 2) convert the TPC tracks to ESD tracks |
a1408c4b | 621 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); |
622 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
b7449dbe | 623 | if (pInputESD && pInputESD->GetNumberOfTracks()>0) { |
624 | HLTWarning("Tracks array already filled from the input esd block, additional filling from TPC tracks block might cause inconsistent content"); | |
625 | } | |
57a4102f | 626 | fBenchmark.AddInput(pBlock->fSize); |
a1408c4b | 627 | vector<AliHLTGlobalBarrelTrack> tracks; |
81509fd3 | 628 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) { |
a1408c4b | 629 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); |
630 | element!=tracks.end(); element++) { | |
631 | Float_t points[4] = { | |
2cb809a5 | 632 | static_cast<Float_t>(element->GetX()), |
633 | static_cast<Float_t>(element->GetY()), | |
634 | static_cast<Float_t>(element->GetLastPointX()), | |
635 | static_cast<Float_t>(element->GetLastPointY()) | |
a1408c4b | 636 | }; |
093b64dc | 637 | |
638 | Int_t mcLabel = -1; | |
eb60b0c1 | 639 | if( mcLabelsTPC.find(element->TrackID())!=mcLabelsTPC.end() ) |
640 | mcLabel = mcLabelsTPC[element->TrackID()]; | |
093b64dc | 641 | element->SetLabel( mcLabel ); |
642 | ||
a1408c4b | 643 | AliESDtrack iotrack; |
550ecaab | 644 | |
645 | // for the moment, the number of clusters are not set when processing the | |
646 | // kTPCin update, only at kTPCout | |
647 | // there ar emainly three parameters updated for kTPCout | |
648 | // number of clusters | |
649 | // chi2 | |
650 | // pid signal | |
651 | // The first one can be updated already at that stage here, while the two others | |
652 | // eventually require to update from the ITS tracks before. The exact scheme | |
ab700b08 | 653 | // needs to be checked |
c3261a7d | 654 | iotrack.SetID( element->TrackID() ); |
e85f2e31 | 655 | |
656 | // 2.1 set kTPCout | |
657 | // TODO 2010-07-12 disabled for the moment because of bug | |
658 | // https://savannah.cern.ch/bugs/index.php?69875 | |
659 | // the propagation does not work, there is an offset in z | |
660 | // propagate to last cluster and update parameters with flag kTPCout | |
661 | // Note: updating with flag kITSout further down will overwrite the outer | |
662 | // parameter again so this can be done only for ITS standalone tracks, meaning | |
663 | // tracks in the ITS not associated with any TPC track | |
664 | // HLT does not provide such standalone tracking | |
c3261a7d | 665 | { |
f167b631 | 666 | AliHLTGlobalBarrelTrack outPar(*element); |
114e074b | 667 | //outPar.AliExternalTrackParam::PropagateTo( element->GetLastPointX(), fSolenoidBz ); |
668 | const Int_t N=10; // number of steps. | |
669 | const Float_t xRange = element->GetLastPointX() - element->GetX(); | |
670 | const Float_t xStep = xRange / N ; | |
671 | for(int i = 1; i <= N; ++i) { | |
672 | if(!outPar.AliExternalTrackParam::PropagateTo(element->GetX() + xStep * i, fSolenoidBz)) break; | |
673 | } | |
b9838c05 | 674 | outPar.SetLabel(element->GetLabel()); |
114e074b | 675 | iotrack.UpdateTrackParams(&outPar,AliESDtrack::kTPCout); |
c3261a7d | 676 | } |
e85f2e31 | 677 | // 2.2 TPC tracking estimates parameters at first cluster |
ab700b08 | 678 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCin); |
e85f2e31 | 679 | |
680 | // 2.3 use the same parameters also for kTPCrefit, there is no proper refit in HLT | |
681 | // maybe this can be done later, however also the inner parameter is changed which | |
682 | // is used as a reference point in the display. That point should be at the first | |
683 | // TPC cluster | |
684 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCrefit); | |
a1408c4b | 685 | iotrack.SetTPCPoints(points); |
0973c527 | 686 | if( element->TrackID()<ndEdxTPC ){ |
72a916d9 | 687 | AliHLTFloat32_t *val = &(dEdxTPC[3*element->TrackID()]); |
5c2dca91 | 688 | iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] ); |
7e32fedf | 689 | //AliTPCseed s; |
690 | //s.Set( element->GetX(), element->GetAlpha(), | |
691 | //element->GetParameter(), element->GetCovariance() ); | |
72a916d9 | 692 | //s.SetdEdx( val[0] ); |
7e32fedf | 693 | //s.CookPID(); |
694 | //iotrack.SetTPCpid(s.TPCrPIDs() ); | |
0973c527 | 695 | } else { |
696 | if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels"); | |
697 | } | |
b9838c05 | 698 | iotrack.SetLabel(mcLabel); |
7fd2e09c | 699 | pESD->AddTrack(&iotrack); |
093b64dc | 700 | if (fVerbosity>0) element->Print(); |
9be6e605 | 701 | |
accd913d | 702 | if( pESDfriend ){ // create friend track |
2352edc3 | 703 | |
704 | AliHLTGlobalBarrelTrack gb(*element); | |
705 | AliTPCseed tTPC; | |
706 | tTPC.Set( gb.GetX(), gb.GetAlpha(), gb.GetParameter(), gb.GetCovariance() ); | |
707 | tTPC.SetLabel(mcLabel); | |
708 | ||
709 | // set the clusters | |
710 | UInt_t nClusters = element->GetNumberOfPoints(); | |
711 | const UInt_t*clusterIDs = element->GetPoints(); | |
712 | ||
713 | tTPC.SetNumberOfClusters(nClusters); | |
714 | ||
715 | for(UInt_t ic=0; ic<nClusters; ic++){ | |
716 | ||
717 | UInt_t id = clusterIDs[ic]; | |
718 | int iSlice = AliHLTTPCSpacePointData::GetSlice(id); | |
719 | int iPartition = AliHLTTPCSpacePointData::GetPatch(id); | |
720 | int iCluster = AliHLTTPCSpacePointData::GetNumber(id); | |
721 | ||
722 | if(iSlice<0 || iSlice>36 || iPartition<0 || iPartition>5){ | |
723 | HLTError("Corrupted TPC cluster Id: slice %d, partition %d, cluster %d", iSlice, iPartition, iCluster); | |
724 | continue; | |
725 | } | |
726 | ||
727 | AliTPCclusterMI *patchClusters = fPartitionClusters[iSlice*6 + iPartition]; | |
728 | if(!patchClusters){ | |
729 | HLTError("Clusters are missed for slice %d, partition %d", iSlice, iPartition ); | |
730 | continue; | |
731 | } | |
732 | ||
733 | if(iCluster >= fNPartitionClusters[iSlice*6 + iPartition]){ | |
734 | HLTError("TPC slice %d, partition %d: ClusterID==%d >= N Cluaters==%d ", iSlice, iPartition,iCluster, fNPartitionClusters[iSlice*6 + iPartition] ); | |
735 | continue; | |
736 | } | |
737 | ||
738 | AliTPCclusterMI *c = &(patchClusters[iCluster]); | |
739 | int sec = c->GetDetector(); | |
740 | int row = c->GetRow(); | |
741 | if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow(); | |
742 | ||
743 | tTPC.SetClusterPointer(row, c); | |
744 | ||
745 | AliTPCTrackerPoint &point = *( tTPC.GetTrackPoint( row ) ); | |
746 | //tTPC.Propagate( TMath::DegToRad()*(sec%18*20.+10.), c->GetX(), fSolenoidBz ); | |
747 | Double_t angle2 = tTPC.GetSnp()*tTPC.GetSnp(); | |
748 | angle2 = (angle2<1) ?TMath::Sqrt(angle2/(1-angle2)) :10.; | |
749 | point.SetAngleY( angle2 ); | |
750 | point.SetAngleZ( tTPC.GetTgl() ); | |
751 | } // end of associated cluster loop | |
752 | ||
753 | // Cook dEdx | |
754 | ||
b7342e4d | 755 | //AliTPCseed *seed = &(tTPC); |
2352edc3 | 756 | //fSeedArray->AddAt( seed, TMath::Abs(seed->GetLabel()) ); |
757 | //fdEdx->Fill( seed->P()*seed->Charge(), seed->CookdEdx(0.02, 0.6) ); | |
758 | ||
759 | AliESDfriendTrack friendTrack; | |
760 | friendTrack.AddCalibObject(&tTPC); | |
accd913d | 761 | pESDfriend->AddTrack(&friendTrack); |
2352edc3 | 762 | } |
a1408c4b | 763 | } |
2352edc3 | 764 | |
093b64dc | 765 | HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size()); |
a1408c4b | 766 | iAddedDataBlocks++; |
767 | } else if (iResult<0) { | |
093b64dc | 768 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", |
769 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
a1408c4b | 770 | } |
771 | } | |
772 | ||
7f167a74 | 773 | |
774 | // Get ITS SPD vertex | |
57a4102f | 775 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){ |
776 | fBenchmark.AddInput(i->fSize); | |
777 | } | |
7f167a74 | 778 | |
779 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) { | |
780 | AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ); | |
781 | pESD->SetPrimaryVertexSPD( vtx ); | |
782 | } | |
783 | ||
5961f15d | 784 | // Get ITS Standalone primaries (SAP) vertexTracks |
785 | { | |
786 | const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESDVertex|kAliHLTDataOriginITS); | |
787 | if (pBlock) { | |
788 | fBenchmark.AddInput(pBlock->fSize); | |
789 | AliFlatESDVertex *vtxFlat = reinterpret_cast<AliFlatESDVertex*>( pBlock->fPtr ); | |
790 | if (vtxFlat->GetNContributors()>0) { | |
5961f15d | 791 | AliESDVertex vtx; |
792 | vtxFlat->GetESDVertex(vtx); | |
793 | vtx.SetTitle("vertexITSSAP"); | |
794 | pESD->SetPrimaryVertexSPD( &vtx ); | |
795 | } | |
796 | } | |
797 | } | |
798 | ||
799 | // Get ITS Standalone primary (SAP) Tracks | |
800 | { | |
801 | const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeITSSAPData|kAliHLTDataOriginITS); | |
802 | if (pBlock) { | |
803 | fBenchmark.AddInput(pBlock->fSize); | |
804 | const AliHLTITSSAPTrackerDataContainer *dataSAP = reinterpret_cast<const AliHLTITSSAPTrackerDataContainer*>(pBlock->fPtr); | |
805 | AliITStrackV2 trcV2; | |
806 | int ntrITSSAP = dataSAP->fCount; | |
5961f15d | 807 | for (int itr=0;itr<ntrITSSAP;itr++) { |
808 | const AliHLTITSSAPTrackerData& trcFlatSAP = dataSAP->fTracks[itr]; | |
809 | AliESDtrack inpESDtrc; | |
810 | inpESDtrc.SetID(pESD->GetNumberOfTracks()); | |
811 | trcFlatSAP.paramInw.GetExternalTrackParam(trcV2); // track at the vertex | |
812 | trcV2.SetLabel(trcFlatSAP.label); | |
813 | trcV2.SetNumberOfClusters(trcFlatSAP.ncl); | |
814 | trcV2.SetChi2(trcFlatSAP.chi2); | |
815 | inpESDtrc.UpdateTrackParams(&trcV2,AliESDtrack::kITSrefit); | |
816 | inpESDtrc.SetStatus( (AliESDtrack::kITSin|AliESDtrack::kITSout|AliESDtrack::kITSpureSA) ); | |
817 | pESD->AddTrack(&inpESDtrc); | |
818 | // | |
819 | if( pESDfriend ) { | |
820 | AliESDfriendTrack friendTrack; | |
821 | trcFlatSAP.paramOut.GetExternalTrackParam(trcV2); // track at the vertex | |
822 | friendTrack.SetITSOut(trcV2); | |
823 | pESDfriend->AddTrack(&friendTrack); | |
824 | } | |
825 | } | |
826 | } | |
827 | } | |
9be6e605 | 828 | |
5961f15d | 829 | |
830 | ||
e85f2e31 | 831 | // 3.1. now update ESD tracks with the ITSOut info |
832 | // updating track parameters with flag kITSout will overwrite parameter set above with flag kTPCout | |
833 | // TODO 2010-07-12 there are some issues with this updating sequence, for the moment update with | |
834 | // flag kITSout is disabled, would require | |
835 | // a) to update kTPCout after kITSout | |
836 | // b) update only for ITS standalone tracks. The HLT ITS tracker does not provide standalone | |
837 | // tracking, every track is related to a TPC track | |
838 | // Furthermore there seems to be a bug as the data blocks describe track parameters around the | |
839 | // vertex, not at the outer ITS | |
840 | // bug https://savannah.cern.ch/bugs/index.php?69872 | |
f167b631 | 841 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut); |
cd60a73f | 842 | pBlock!=NULL; pBlock=GetNextInputBlock()) { |
57a4102f | 843 | fBenchmark.AddInput(pBlock->fSize); |
cd60a73f | 844 | vector<AliHLTGlobalBarrelTrack> tracks; |
845 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
846 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
847 | element!=tracks.end(); element++) { | |
cd60a73f | 848 | int tpcID=element->TrackID(); |
849 | // the ITS tracker assigns the TPC track used as seed for a certain track to | |
850 | // the trackID | |
851 | if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue; | |
cd60a73f | 852 | AliESDtrack *tESD = pESD->GetTrack( tpcID ); |
b9838c05 | 853 | element->SetLabel(tESD->GetLabel()); |
e85f2e31 | 854 | // 2010-07-12 disabled, see above, bugfix https://savannah.cern.ch/bugs/index.php?69872 |
855 | //if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSout ); | |
a1408c4b | 856 | } |
cd60a73f | 857 | } |
858 | } | |
18ada816 | 859 | |
e85f2e31 | 860 | // 3.2. now update ESD tracks with the ITS info |
f167b631 | 861 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS); |
b7ed2eb4 | 862 | pBlock!=NULL; pBlock=GetNextInputBlock()) { |
57a4102f | 863 | fBenchmark.AddInput(pBlock->fSize); |
b7ed2eb4 | 864 | vector<AliHLTGlobalBarrelTrack> tracks; |
865 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
866 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
867 | element!=tracks.end(); element++) { | |
b7ed2eb4 | 868 | int tpcID=element->TrackID(); |
869 | // the ITS tracker assigns the TPC track used as seed for a certain track to | |
870 | // the trackID | |
871 | if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue; | |
d72d9d99 | 872 | Int_t mcLabel = -1; |
873 | if( mcLabelsITS.find(element->TrackID())!=mcLabelsITS.end() ) | |
874 | mcLabel = mcLabelsITS[element->TrackID()]; | |
b7ed2eb4 | 875 | AliESDtrack *tESD = pESD->GetTrack( tpcID ); |
b9838c05 | 876 | if (!tESD) continue; |
eb60b0c1 | 877 | // the labels for the TPC and ITS tracking params can be different, e.g. |
878 | // there can be a decay. The ITS label should then be the better one, the | |
879 | // TPC label is saved in a member of AliESDtrack | |
880 | if (mcLabel>=0) { | |
881 | // upadte only if the ITS label is available, otherwise keep TPC label | |
882 | element->SetLabel( mcLabel ); | |
e85f2e31 | 883 | } else { |
884 | // bugfix https://savannah.cern.ch/bugs/?69713 | |
885 | element->SetLabel( tESD->GetLabel() ); | |
b9838c05 | 886 | } |
b9838c05 | 887 | tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSin ); |
888 | ||
889 | // TODO: add a proper refit | |
890 | //tESD->UpdateTrackParams( &(*element), AliESDtrack::kTPCrefit ); | |
b7ed2eb4 | 891 | } |
892 | } | |
893 | } | |
894 | ||
d9386025 | 895 | // update with vertices and vertex-fitted tracks |
b7449dbe | 896 | // output of the GlobalVertexerComponent |
d9386025 | 897 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer); |
898 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 899 | fBenchmark.AddInput(pBlock->fSize); |
d9386025 | 900 | AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) ); |
901 | } | |
902 | ||
b7449dbe | 903 | // update with vertices and vertex-fitted tracks |
904 | // output of PrimaryVertexer and V0Finder components | |
f9ce172e | 905 | |
b7449dbe | 906 | TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut); |
907 | if (pBase) { | |
908 | AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase); | |
909 | if (kfVertex) { | |
910 | const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut); | |
911 | if (pP && pP->fSize && pP->fPtr) { | |
912 | const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut); | |
913 | if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) { | |
914 | const int* v0s = static_cast<const int*>(pV0->fPtr); | |
915 | HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]); | |
916 | } | |
917 | AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL); | |
918 | } else | |
919 | HLTWarning("Problem with primary finder's data block"); | |
920 | } else { | |
921 | HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName()); | |
922 | } | |
923 | } else { | |
924 | // throw an error if there is a V0 data block which can not be handled without | |
925 | // the AliKFVertex object | |
926 | if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) { | |
927 | ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s", | |
928 | DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str()); | |
929 | } | |
930 | } | |
931 | ||
0d2e4e41 | 932 | // Fill DCA parameters for TPC tracks |
e85f2e31 | 933 | // TODO 2010-07-12 this propagates also the TPC inner param to beamline |
934 | // sounds not very reasonable | |
935 | // https://savannah.cern.ch/bugs/index.php?69873 | |
7fd2e09c | 936 | for (int i=0; i<pESD->GetNumberOfTracks(); i++) { |
0d2e4e41 | 937 | if (!pESD->GetTrack(i) || |
938 | !pESD->GetTrack(i)->GetTPCInnerParam() ) continue; | |
7fd2e09c | 939 | pESD->GetTrack(i)->RelateToVertexTPC(pESD->GetPrimaryVertexTracks(), fSolenoidBz, 1000 ); |
0d2e4e41 | 940 | } |
941 | ||
b9838c05 | 942 | // loop over all tracks and set the TPC refit flag by updating with the |
943 | // original TPC inner parameter if not yet set | |
944 | // TODO: replace this by a proper refit | |
945 | // code is comented for the moment as it does not fully solve the problems with | |
946 | // the display | |
e85f2e31 | 947 | // - would set the main parameters to the TPC inner wall again, or |
948 | // - changes the inner param if the parameters are propagated, so we loose the track | |
949 | // reference point for the display | |
950 | // with the current sequence we have the latter case as the DCA operations above | |
951 | // change the TPC inner parameters | |
b9838c05 | 952 | /* |
953 | for (int i=0; i<pESD->GetNumberOfTracks(); i++) { | |
954 | if (!pESD->GetTrack(i) || | |
955 | !pESD->GetTrack(i)->GetTPCInnerParam() || | |
956 | pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue; | |
957 | AliESDtrack* tESD=pESD->GetTrack(i); | |
958 | AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam()); | |
959 | inner.SetLabel(tESD->GetLabel()); | |
960 | tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit); | |
961 | } | |
962 | */ | |
b7ed2eb4 | 963 | |
e85f2e31 | 964 | // 4. convert the HLT TRD tracks to ESD tracks |
18ada816 | 965 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD); |
966 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 967 | fBenchmark.AddInput(pBlock->fSize); |
18ada816 | 968 | vector<AliHLTGlobalBarrelTrack> tracks; |
969 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
970 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
971 | element!=tracks.end(); element++) { | |
972 | ||
973 | Double_t TRDpid[AliPID::kSPECIES], eProb(0.2), restProb((1-eProb)/(AliPID::kSPECIES-1)); //eprob(element->GetTRDpid...); | |
974 | for(Int_t i=0; i<AliPID::kSPECIES; i++){ | |
975 | switch(i){ | |
976 | case AliPID::kElectron: TRDpid[AliPID::kElectron]=eProb; break; | |
977 | default: TRDpid[i]=restProb; break; | |
978 | } | |
979 | } | |
980 | ||
981 | AliESDtrack iotrack; | |
0d096bba | 982 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTRDout); |
0b745718 | 983 | iotrack.SetStatus(AliESDtrack::kTRDin); |
18ada816 | 984 | iotrack.SetTRDpid(TRDpid); |
985 | ||
986 | pESD->AddTrack(&iotrack); | |
987 | if (fVerbosity>0) element->Print(); | |
988 | } | |
989 | HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size()); | |
990 | iAddedDataBlocks++; | |
991 | } else if (iResult<0) { | |
992 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", | |
993 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
994 | } | |
995 | } | |
b4479a87 | 996 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) |
9a9467ed | 997 | { |
57a4102f | 998 | fBenchmark.AddInput(pBlock->fSize); |
9a9467ed | 999 | AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr); |
1000 | ||
1001 | HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification); | |
1002 | ||
2a24cbbe | 1003 | //AliHLTCaloClusterReader reader; |
1004 | //reader.SetMemory(caloClusterHeaderPtr); | |
9a9467ed | 1005 | |
1006 | AliHLTESDCaloClusterMaker clusterMaker; | |
1007 | ||
1008 | int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr); | |
2a24cbbe | 1009 | |
9a9467ed | 1010 | HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters); |
1011 | iAddedDataBlocks++; | |
1012 | } | |
f064ef44 | 1013 | |
331d51c5 | 1014 | // 5) Add Trigger Detectors |
1015 | // VZERO, ZDC | |
1016 | ||
1017 | // FIXME: the size of all input blocks can be added in one loop | |
1018 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO); | |
1019 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
1020 | fBenchmark.AddInput(pBlock->fSize); | |
1021 | } | |
1022 | ||
1023 | for ( const TObject *pObject = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO); | |
1024 | pObject != NULL; pObject = GetNextInputObject() ) { | |
1025 | AliESDVZERO *esdVZERO = dynamic_cast<AliESDVZERO*>(const_cast<TObject*>( pObject ) ); | |
1026 | if (esdVZERO) { | |
1027 | pESD->SetVZEROData( esdVZERO ); | |
1028 | break; | |
1029 | } else { | |
1030 | ALIHLTERRORGUARD(1, "input object of data type %s is not of class AliESDVZERO", | |
1031 | DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO).c_str()); | |
1032 | } | |
1033 | } | |
1034 | ||
421e1221 | 1035 | // FIXME: the size of all input blocks can be added in one loop |
1036 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC); | |
1037 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
1038 | fBenchmark.AddInput(pBlock->fSize); | |
1039 | } | |
1040 | for ( const TObject *pObject = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC); | |
1041 | pObject != NULL; pObject = GetNextInputObject() ) { | |
1042 | AliESDZDC *esdZDC = dynamic_cast<AliESDZDC*>(const_cast<TObject*>( pObject ) ); | |
1043 | if (esdZDC) { | |
8cd67fda | 1044 | #ifndef HAVE_NOT_ALIZDCRECONSTRUCTOR_r43770 |
421e1221 | 1045 | pESD->SetZDCData( esdZDC ); |
8cd67fda | 1046 | #else |
1047 | ALIHLTERRORGUARD(1, "Processing of ZDC data requires AliRoot r43770m skipping data block of type %s", | |
1048 | DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC).c_str()); | |
1049 | #endif | |
421e1221 | 1050 | break; |
1051 | } else { | |
1052 | ALIHLTERRORGUARD(1, "input object of data type %s is not of class AliESDZDC", | |
1053 | DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC).c_str()); | |
1054 | } | |
1055 | } | |
1056 | ||
fe0324de | 1057 | // Add tracks and clusters from MUON. |
57a4102f | 1058 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTAnyDataType | kAliHLTDataOriginMUON); i!=NULL; i=GetNextInputBlock() ){ |
1059 | fBenchmark.AddInput(i->fSize); | |
1060 | } | |
1061 | ||
f064ef44 | 1062 | for (const TObject* obj = GetFirstInputObject(kAliHLTAnyDataType | kAliHLTDataOriginMUON); |
1063 | obj != NULL; | |
1064 | obj = GetNextInputObject() | |
1065 | ) | |
1066 | { | |
1067 | const TClonesArray* tracklist = NULL; | |
fe0324de | 1068 | const TClonesArray* clusterlist = NULL; |
f064ef44 | 1069 | if (obj->IsA() == AliESDEvent::Class()) |
1070 | { | |
1071 | const AliESDEvent* event = static_cast<const AliESDEvent*>(obj); | |
1072 | HLTDebug("Received a MUON ESD with specification: 0x%X", GetSpecification(obj)); | |
1073 | if (event->GetList() == NULL) continue; | |
1074 | tracklist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonTracks")); | |
1075 | if (tracklist == NULL) continue; | |
fe0324de | 1076 | clusterlist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonClusters")); |
1077 | if (clusterlist == NULL) continue; | |
f064ef44 | 1078 | } |
1079 | else if (obj->IsA() == TClonesArray::Class()) | |
1080 | { | |
fe0324de | 1081 | if (!strcmp(obj->GetName(), "MuonTracks")) { |
1082 | tracklist = static_cast<const TClonesArray*>(obj); | |
1083 | HLTDebug("Received a MUON TClonesArray of tracks with specification: 0x%X", GetSpecification(obj)); | |
1084 | } else { | |
1085 | clusterlist = static_cast<const TClonesArray*>(obj); | |
1086 | HLTDebug("Received a MUON TClonesArray of clusters with specification: 0x%X", GetSpecification(obj)); | |
1087 | } | |
f064ef44 | 1088 | } |
1089 | else | |
1090 | { | |
1091 | // Cannot handle this object type. | |
1092 | continue; | |
1093 | } | |
fe0324de | 1094 | // copy tracks |
1095 | if (tracklist) { | |
1096 | HLTDebug("Received %d MUON tracks.", tracklist->GetEntriesFast()); | |
1097 | if (tracklist->GetEntriesFast() > 0) | |
1098 | { | |
1099 | const AliESDMuonTrack* track = dynamic_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(0)); | |
1100 | if (track == NULL) | |
1101 | { | |
1102 | HLTError(Form("%s from MUON does not contain AliESDMuonTrack objects.", obj->ClassName())); | |
1103 | continue; | |
1104 | } | |
1105 | } | |
1106 | for (Int_t i = 0; i < tracklist->GetEntriesFast(); ++i) | |
f064ef44 | 1107 | { |
fe0324de | 1108 | AliESDMuonTrack* track = pESD->NewMuonTrack(); |
1109 | *track = *(static_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(i))); | |
a1408c4b | 1110 | } |
f064ef44 | 1111 | } |
fe0324de | 1112 | // copy clusters |
1113 | if (clusterlist) { | |
1114 | HLTDebug("Received %d MUON clusters.", clusterlist->GetEntriesFast()); | |
1115 | if (clusterlist->GetEntriesFast() > 0) | |
1116 | { | |
1117 | const AliESDMuonCluster* cluster = dynamic_cast<const AliESDMuonCluster*>(clusterlist->UncheckedAt(0)); | |
1118 | if (cluster == NULL) | |
1119 | { | |
1120 | HLTError(Form("%s from MUON does not contain AliESDMuonCluster objects.", obj->ClassName())); | |
1121 | continue; | |
1122 | } | |
1123 | } | |
1124 | for (Int_t i = 0; i < clusterlist->GetEntriesFast(); ++i) | |
1125 | { | |
1126 | AliESDMuonCluster* cluster = pESD->NewMuonCluster(); | |
1127 | *cluster = *(static_cast<const AliESDMuonCluster*>(clusterlist->UncheckedAt(i))); | |
1128 | } | |
f064ef44 | 1129 | } |
1130 | } | |
2352edc3 | 1131 | |
accd913d | 1132 | if( fMakeFriends && pESDfriend ){ // create friend track |
1133 | pESD->SetESDfriend( pESDfriend ); | |
c5baab86 | 1134 | } |
accd913d | 1135 | |
c5baab86 | 1136 | |
f064ef44 | 1137 | if (iAddedDataBlocks>0 && pTree) { |
1138 | pTree->Fill(); | |
accd913d | 1139 | } |
a1408c4b | 1140 | |
1141 | if (iResult>=0) iResult=iAddedDataBlocks; | |
1142 | return iResult; | |
b7342e4d | 1143 | } |