]>
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" |
a1408c4b | 37 | #include "AliESDEvent.h" |
38 | #include "AliESDtrack.h" | |
f064ef44 | 39 | #include "AliESDMuonTrack.h" |
a1408c4b | 40 | #include "AliCDBEntry.h" |
41 | #include "AliCDBManager.h" | |
18ada816 | 42 | #include "AliPID.h" |
a1408c4b | 43 | #include "TTree.h" |
44 | #include "TList.h" | |
f064ef44 | 45 | #include "TClonesArray.h" |
9a9467ed | 46 | #include "AliHLTESDCaloClusterMaker.h" |
47 | #include "AliHLTCaloClusterDataStruct.h" | |
48 | #include "AliHLTCaloClusterReader.h" | |
49 | #include "AliESDCaloCluster.h" | |
d9386025 | 50 | #include "AliHLTGlobalVertexerComponent.h" |
a1408c4b | 51 | |
52 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
53 | ClassImp(AliHLTGlobalEsdConverterComponent) | |
54 | ||
55 | AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent() | |
56 | : AliHLTProcessor() | |
a1408c4b | 57 | , fWriteTree(0) |
093b64dc | 58 | , fVerbosity(0) |
8b7a0f3c | 59 | , fESD(NULL) |
a8714ffa | 60 | , fSolenoidBz(-5.00668) |
57a4102f | 61 | , fBenchmark("EsdConverter") |
a1408c4b | 62 | { |
63 | // see header file for class documentation | |
64 | // or | |
65 | // refer to README to build package | |
66 | // or | |
67 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
68 | } | |
69 | ||
70 | AliHLTGlobalEsdConverterComponent::~AliHLTGlobalEsdConverterComponent() | |
71 | { | |
72 | // see header file for class documentation | |
73 | if (fESD) delete fESD; | |
74 | fESD=NULL; | |
75 | } | |
76 | ||
77 | int AliHLTGlobalEsdConverterComponent::Configure(const char* arguments) | |
78 | { | |
79 | // see header file for class documentation | |
80 | int iResult=0; | |
81 | if (!arguments) return iResult; | |
82 | ||
83 | TString allArgs=arguments; | |
84 | TString argument; | |
85 | int bMissingParam=0; | |
86 | ||
87 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
88 | if (pTokens) { | |
89 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
fe0af255 | 90 | argument=((TObjString*)pTokens->At(i))->GetString(); |
a1408c4b | 91 | if (argument.IsNull()) continue; |
92 | ||
93 | if (argument.CompareTo("-solenoidBz")==0) { | |
94 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
75970b8d | 95 | HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz()); |
a1408c4b | 96 | continue; |
97 | } else { | |
98 | HLTError("unknown argument %s", argument.Data()); | |
99 | iResult=-EINVAL; | |
100 | break; | |
101 | } | |
102 | } | |
103 | delete pTokens; | |
104 | } | |
105 | if (bMissingParam) { | |
106 | HLTError("missing parameter for argument %s", argument.Data()); | |
107 | iResult=-EINVAL; | |
108 | } | |
109 | ||
110 | return iResult; | |
111 | } | |
112 | ||
113 | int AliHLTGlobalEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
114 | { | |
115 | // see header file for class documentation | |
116 | int iResult=0; | |
75970b8d | 117 | const char* path=NULL; |
a1408c4b | 118 | const char* defaultNotify=""; |
119 | if (cdbEntry) { | |
120 | path=cdbEntry; | |
121 | defaultNotify=" (default)"; | |
122 | } | |
123 | if (path) { | |
124 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
125 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
126 | if (pEntry) { | |
127 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
128 | if (pString) { | |
129 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
130 | iResult=Configure(pString->GetString().Data()); | |
131 | } else { | |
132 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
133 | } | |
134 | } else { | |
135 | HLTError("can not fetch object \"%s\" from CDB", path); | |
136 | } | |
137 | } | |
138 | ||
139 | return iResult; | |
140 | } | |
141 | ||
142 | void AliHLTGlobalEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
143 | { | |
144 | // see header file for class documentation | |
145 | list.push_back(kAliHLTDataTypeTrack); | |
146 | list.push_back(kAliHLTDataTypeTrackMC); | |
9a9467ed | 147 | list.push_back(kAliHLTDataTypeCaloCluster); |
0973c527 | 148 | list.push_back(kAliHLTDataTypedEdx ); |
7f167a74 | 149 | list.push_back(kAliHLTDataTypeESDVertex ); |
f064ef44 | 150 | list.push_back(kAliHLTDataTypeESDObject); |
151 | list.push_back(kAliHLTDataTypeTObject); | |
d9963894 | 152 | list.push_back(kAliHLTDataTypeGlobalVertexer); |
a1408c4b | 153 | } |
154 | ||
155 | AliHLTComponentDataType AliHLTGlobalEsdConverterComponent::GetOutputDataType() | |
156 | { | |
157 | // see header file for class documentation | |
7a9de6d1 | 158 | return kAliHLTDataTypeESDObject|kAliHLTDataOriginOut; |
a1408c4b | 159 | } |
160 | ||
161 | void AliHLTGlobalEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
162 | { | |
163 | // see header file for class documentation | |
164 | constBase=2000000; | |
165 | inputMultiplier=10.0; | |
166 | } | |
167 | ||
168 | int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv) | |
169 | { | |
170 | // see header file for class documentation | |
171 | int iResult=0; | |
172 | TString argument=""; | |
173 | int bMissingParam=0; | |
a1408c4b | 174 | |
d57fc872 | 175 | // default list of skiped ESD objects |
176 | TString skipObjects= | |
177 | // "AliESDRun," | |
178 | // "AliESDHeader," | |
179 | "AliESDZDC," | |
180 | "AliESDFMD," | |
181 | // "AliESDVZERO," | |
182 | // "AliESDTZERO," | |
183 | // "TPCVertex," | |
184 | // "SPDVertex," | |
185 | // "PrimaryVertex," | |
186 | // "AliMultiplicity," | |
187 | // "PHOSTrigger," | |
188 | // "EMCALTrigger," | |
189 | // "SPDPileupVertices," | |
190 | // "TrkPileupVertices," | |
191 | "Cascades," | |
192 | "Kinks," | |
193 | "AliRawDataErrorLogs," | |
194 | "AliESDACORDE"; | |
195 | ||
f167b631 | 196 | iResult=Reconfigure(NULL, NULL); |
197 | TString allArgs = ""; | |
198 | for ( int i = 0; i < argc; i++ ) { | |
199 | if ( !allArgs.IsNull() ) allArgs += " "; | |
200 | allArgs += argv[i]; | |
201 | } | |
a1408c4b | 202 | |
f167b631 | 203 | TObjArray* pTokens=allArgs.Tokenize(" "); |
204 | if (pTokens) { | |
205 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
206 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
207 | if (argument.IsNull()) continue; | |
208 | ||
209 | // -notree | |
210 | if (argument.CompareTo("-notree")==0) { | |
211 | fWriteTree=0; | |
212 | ||
213 | // -tree | |
214 | } else if (argument.CompareTo("-tree")==0) { | |
215 | fWriteTree=1; | |
216 | } else if (argument.CompareTo("-solenoidBz")==0) { | |
217 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
218 | HLTInfo("Magnetic Field set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
d57fc872 | 219 | HLTWarning("argument '-solenoidBz' is deprecated, solenoid field initiaized from CDB settings"); |
f167b631 | 220 | continue; |
d57fc872 | 221 | } else if (argument.Contains("-skipobject=")) { |
222 | argument.ReplaceAll("-skipobject=", ""); | |
223 | skipObjects=argument; | |
f167b631 | 224 | } else { |
225 | HLTError("unknown argument %s", argument.Data()); | |
d57fc872 | 226 | iResult=-EINVAL; |
f167b631 | 227 | break; |
228 | } | |
a1408c4b | 229 | } |
230 | } | |
231 | if (bMissingParam) { | |
232 | HLTError("missing parameter for argument %s", argument.Data()); | |
233 | iResult=-EINVAL; | |
234 | } | |
235 | ||
75970b8d | 236 | fSolenoidBz=GetBz(); |
237 | ||
a1408c4b | 238 | if (iResult>=0) { |
239 | fESD = new AliESDEvent; | |
240 | if (fESD) { | |
241 | fESD->CreateStdContent(); | |
d57fc872 | 242 | |
243 | // remove some of the objects which are not needed | |
244 | if (fESD->GetList() && !skipObjects.IsNull()) { | |
245 | pTokens=skipObjects.Tokenize(","); | |
246 | if (pTokens) { | |
247 | const char* id=NULL; | |
248 | TIter next(pTokens); | |
249 | TObject* pObject=NULL; | |
250 | while ((pObject=next())!=NULL) { | |
251 | id=((TObjString*)pObject)->GetString().Data(); | |
a0b62fd1 | 252 | TObject* pObj=fESD->GetList()->FindObject(id); |
253 | if (pObj) { | |
d57fc872 | 254 | HLTDebug("removing object %s", id); |
a0b62fd1 | 255 | fESD->GetList()->Remove(pObj); |
256 | delete pObj; | |
d57fc872 | 257 | } else { |
258 | HLTWarning("failed to remove object '%s' from ESD", id); | |
259 | } | |
260 | } | |
d57fc872 | 261 | fESD->GetStdContent(); |
262 | delete pTokens; | |
263 | } | |
264 | } | |
a1408c4b | 265 | } else { |
266 | iResult=-ENOMEM; | |
267 | } | |
6117ef63 | 268 | |
269 | SetupCTPData(); | |
a1408c4b | 270 | } |
271 | ||
57a4102f | 272 | fBenchmark.SetTimer(0,"total"); |
273 | ||
a1408c4b | 274 | return iResult; |
275 | } | |
276 | ||
277 | int AliHLTGlobalEsdConverterComponent::DoDeinit() | |
278 | { | |
279 | // see header file for class documentation | |
280 | if (fESD) delete fESD; | |
281 | fESD=NULL; | |
282 | ||
283 | return 0; | |
284 | } | |
285 | ||
286 | int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
6117ef63 | 287 | AliHLTComponentTriggerData& trigData) |
a1408c4b | 288 | { |
289 | // see header file for class documentation | |
290 | int iResult=0; | |
291 | if (!fESD) return -ENODEV; | |
292 | ||
57a4102f | 293 | if (IsDataEvent()) fBenchmark.StartNewEvent(); |
294 | fBenchmark.Start(0); | |
295 | ||
a1408c4b | 296 | AliESDEvent* pESD = fESD; |
297 | ||
298 | pESD->Reset(); | |
299 | pESD->SetMagneticField(fSolenoidBz); | |
6117ef63 | 300 | pESD->SetRunNumber(GetRunNo()); |
6700298e | 301 | pESD->SetPeriodNumber(GetPeriodNumber()); |
302 | pESD->SetOrbitNumber(GetOrbitNumber()); | |
303 | pESD->SetBunchCrossNumber(GetBunchCrossNumber()); | |
304 | pESD->SetTimeStamp(GetTimeStamp()); | |
a1408c4b | 305 | |
6117ef63 | 306 | const AliHLTCTPData* pCTPData=CTPData(); |
307 | if (pCTPData) { | |
308 | AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData); | |
309 | for (int index=0; index<gkNCTPTriggerClasses; index++) { | |
310 | if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue; | |
311 | pESD->SetTriggerClass(pCTPData->Name(index), index); | |
312 | } | |
313 | pESD->SetTriggerMask(mask); | |
314 | } | |
315 | ||
a1408c4b | 316 | TTree* pTree = NULL; |
317 | if (fWriteTree) | |
318 | pTree = new TTree("esdTree", "Tree with HLT ESD objects"); | |
319 | ||
320 | if (pTree) { | |
321 | pTree->SetDirectory(0); | |
322 | } | |
323 | ||
81509fd3 | 324 | if ((iResult=ProcessBlocks(pTree, pESD))>=0) { |
a1408c4b | 325 | // TODO: set the specification correctly |
326 | if (pTree) { | |
327 | // the esd structure is written to the user info and is | |
328 | // needed in te ReadFromTree method to read all objects correctly | |
329 | pTree->GetUserInfo()->Add(pESD); | |
330 | pESD->WriteToTree(pTree); | |
7a9de6d1 | 331 | iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0); |
a1408c4b | 332 | } else { |
7a9de6d1 | 333 | iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0); |
a1408c4b | 334 | } |
57a4102f | 335 | fBenchmark.AddOutput(GetLastObjectSize()); |
a1408c4b | 336 | } |
337 | if (pTree) { | |
338 | // clear user info list to prevent objects from being deleted | |
339 | pTree->GetUserInfo()->Clear(); | |
340 | delete pTree; | |
341 | } | |
57a4102f | 342 | |
343 | fBenchmark.Stop(0); | |
344 | HLTInfo( fBenchmark.GetStatistics() ); | |
345 | ||
a1408c4b | 346 | return iResult; |
347 | } | |
348 | ||
349 | int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD) | |
350 | { | |
351 | // see header file for class documentation | |
352 | ||
353 | int iResult=0; | |
354 | int iAddedDataBlocks=0; | |
355 | ||
356 | // Barrel tracking | |
357 | ||
358 | // in the first attempt this component reads the TPC tracks and updates in the | |
359 | // second step from the ITS tracks | |
093b64dc | 360 | |
093b64dc | 361 | // first read MC information (if present) |
362 | std::map<int,int> mcLabels; | |
d72d9d99 | 363 | std::map<int,int> mcLabelsITS; |
093b64dc | 364 | |
365 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC); | |
366 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 367 | |
368 | fBenchmark.AddInput(pBlock->fSize); | |
369 | ||
093b64dc | 370 | AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr ); |
371 | if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) { | |
372 | for( unsigned int il=0; il<dataPtr->fCount; il++ ){ | |
373 | AliHLTTrackMCLabel &lab = dataPtr->fLabels[il]; | |
374 | mcLabels[lab.fTrackID] = lab.fMCLabel; | |
375 | } | |
376 | } else { | |
377 | HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", | |
378 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, | |
379 | dataPtr->fCount, pBlock->fSize); | |
380 | } | |
381 | } | |
d72d9d99 | 382 | |
383 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS); | |
384 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
385 | ||
386 | fBenchmark.AddInput(pBlock->fSize); | |
387 | ||
388 | AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr ); | |
389 | if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) { | |
390 | for( unsigned int il=0; il<dataPtr->fCount; il++ ){ | |
391 | AliHLTTrackMCLabel &lab = dataPtr->fLabels[il]; | |
392 | mcLabelsITS[lab.fTrackID] = lab.fMCLabel; | |
393 | } | |
394 | } else { | |
395 | HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", | |
396 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, | |
397 | dataPtr->fCount, pBlock->fSize); | |
398 | } | |
399 | } | |
400 | ||
093b64dc | 401 | |
0973c527 | 402 | // read dEdx information (if present) |
403 | ||
404 | AliHLTFloat32_t *dEdxTPC = 0; | |
405 | Int_t ndEdxTPC = 0; | |
406 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC); | |
407 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 408 | fBenchmark.AddInput(pBlock->fSize); |
0973c527 | 409 | dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr ); |
410 | ndEdxTPC = pBlock->fSize / sizeof(AliHLTFloat32_t); | |
411 | break; | |
412 | } | |
413 | ||
cd60a73f | 414 | // convert the TPC tracks to ESD tracks |
a1408c4b | 415 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); |
416 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 417 | fBenchmark.AddInput(pBlock->fSize); |
a1408c4b | 418 | vector<AliHLTGlobalBarrelTrack> tracks; |
81509fd3 | 419 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) { |
a1408c4b | 420 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); |
421 | element!=tracks.end(); element++) { | |
422 | Float_t points[4] = { | |
423 | element->GetX(), | |
424 | element->GetY(), | |
425 | element->GetLastPointX(), | |
426 | element->GetLastPointY() | |
427 | }; | |
093b64dc | 428 | |
429 | Int_t mcLabel = -1; | |
430 | if( mcLabels.find(element->TrackID())!=mcLabels.end() ) | |
431 | mcLabel = mcLabels[element->TrackID()]; | |
432 | element->SetLabel( mcLabel ); | |
433 | ||
a1408c4b | 434 | AliESDtrack iotrack; |
550ecaab | 435 | |
436 | // for the moment, the number of clusters are not set when processing the | |
437 | // kTPCin update, only at kTPCout | |
438 | // there ar emainly three parameters updated for kTPCout | |
439 | // number of clusters | |
440 | // chi2 | |
441 | // pid signal | |
442 | // The first one can be updated already at that stage here, while the two others | |
443 | // eventually require to update from the ITS tracks before. The exact scheme | |
444 | // needs to be checked | |
c3261a7d | 445 | iotrack.SetID( element->TrackID() ); |
a1408c4b | 446 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCin); |
c3261a7d | 447 | { |
f167b631 | 448 | AliHLTGlobalBarrelTrack outPar(*element); |
c3261a7d | 449 | outPar.AliExternalTrackParam::PropagateTo( element->GetLastPointX(), fSolenoidBz ); |
450 | iotrack.UpdateTrackParams(&outPar,AliESDtrack::kTPCout); | |
451 | } | |
a1408c4b | 452 | iotrack.SetTPCPoints(points); |
0973c527 | 453 | if( element->TrackID()<ndEdxTPC ){ |
7e32fedf | 454 | iotrack.SetTPCsignal( dEdxTPC[element->TrackID()], 0, 0 ); |
455 | //AliTPCseed s; | |
456 | //s.Set( element->GetX(), element->GetAlpha(), | |
457 | //element->GetParameter(), element->GetCovariance() ); | |
458 | //s.SetdEdx( dEdxTPC[element->TrackID()] ); | |
459 | //s.CookPID(); | |
460 | //iotrack.SetTPCpid(s.TPCrPIDs() ); | |
0973c527 | 461 | } else { |
462 | if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels"); | |
463 | } | |
a1408c4b | 464 | pESD->AddTrack(&iotrack); |
093b64dc | 465 | if (fVerbosity>0) element->Print(); |
a1408c4b | 466 | } |
093b64dc | 467 | HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size()); |
a1408c4b | 468 | iAddedDataBlocks++; |
469 | } else if (iResult<0) { | |
093b64dc | 470 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", |
471 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
a1408c4b | 472 | } |
473 | } | |
474 | ||
7f167a74 | 475 | |
476 | // Get ITS SPD vertex | |
57a4102f | 477 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){ |
478 | fBenchmark.AddInput(i->fSize); | |
479 | } | |
7f167a74 | 480 | |
481 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) { | |
482 | AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ); | |
483 | pESD->SetPrimaryVertexSPD( vtx ); | |
484 | } | |
485 | ||
f167b631 | 486 | // now update ESD tracks with the ITSOut info |
487 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut); | |
cd60a73f | 488 | pBlock!=NULL; pBlock=GetNextInputBlock()) { |
57a4102f | 489 | fBenchmark.AddInput(pBlock->fSize); |
cd60a73f | 490 | vector<AliHLTGlobalBarrelTrack> tracks; |
491 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
492 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
493 | element!=tracks.end(); element++) { | |
cd60a73f | 494 | int tpcID=element->TrackID(); |
495 | // the ITS tracker assigns the TPC track used as seed for a certain track to | |
496 | // the trackID | |
497 | if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue; | |
cd60a73f | 498 | AliESDtrack *tESD = pESD->GetTrack( tpcID ); |
f167b631 | 499 | if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSout ); |
a1408c4b | 500 | } |
cd60a73f | 501 | } |
502 | } | |
18ada816 | 503 | |
f167b631 | 504 | // now update ESD tracks with the ITS info |
505 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS); | |
b7ed2eb4 | 506 | pBlock!=NULL; pBlock=GetNextInputBlock()) { |
57a4102f | 507 | fBenchmark.AddInput(pBlock->fSize); |
b7ed2eb4 | 508 | vector<AliHLTGlobalBarrelTrack> tracks; |
509 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
510 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
511 | element!=tracks.end(); element++) { | |
b7ed2eb4 | 512 | int tpcID=element->TrackID(); |
513 | // the ITS tracker assigns the TPC track used as seed for a certain track to | |
514 | // the trackID | |
515 | if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue; | |
d72d9d99 | 516 | Int_t mcLabel = -1; |
517 | if( mcLabelsITS.find(element->TrackID())!=mcLabelsITS.end() ) | |
518 | mcLabel = mcLabelsITS[element->TrackID()]; | |
519 | element->SetLabel( mcLabel ); | |
b7ed2eb4 | 520 | AliESDtrack *tESD = pESD->GetTrack( tpcID ); |
f167b631 | 521 | if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSin ); |
b7ed2eb4 | 522 | } |
523 | } | |
524 | } | |
525 | ||
d9386025 | 526 | // update with vertices and vertex-fitted tracks |
527 | ||
528 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer); | |
529 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 530 | fBenchmark.AddInput(pBlock->fSize); |
d9386025 | 531 | AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) ); |
532 | } | |
533 | ||
b7ed2eb4 | 534 | |
18ada816 | 535 | // convert the HLT TRD tracks to ESD tracks |
536 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD); | |
537 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 538 | fBenchmark.AddInput(pBlock->fSize); |
18ada816 | 539 | vector<AliHLTGlobalBarrelTrack> tracks; |
540 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
541 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
542 | element!=tracks.end(); element++) { | |
543 | ||
544 | Double_t TRDpid[AliPID::kSPECIES], eProb(0.2), restProb((1-eProb)/(AliPID::kSPECIES-1)); //eprob(element->GetTRDpid...); | |
545 | for(Int_t i=0; i<AliPID::kSPECIES; i++){ | |
546 | switch(i){ | |
547 | case AliPID::kElectron: TRDpid[AliPID::kElectron]=eProb; break; | |
548 | default: TRDpid[i]=restProb; break; | |
549 | } | |
550 | } | |
551 | ||
552 | AliESDtrack iotrack; | |
0d096bba | 553 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTRDout); |
18ada816 | 554 | iotrack.SetTRDpid(TRDpid); |
555 | ||
556 | pESD->AddTrack(&iotrack); | |
557 | if (fVerbosity>0) element->Print(); | |
558 | } | |
559 | HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size()); | |
560 | iAddedDataBlocks++; | |
561 | } else if (iResult<0) { | |
562 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", | |
563 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
564 | } | |
565 | } | |
b4479a87 | 566 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) |
9a9467ed | 567 | { |
57a4102f | 568 | fBenchmark.AddInput(pBlock->fSize); |
9a9467ed | 569 | AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr); |
570 | ||
571 | HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification); | |
572 | ||
2a24cbbe | 573 | //AliHLTCaloClusterReader reader; |
574 | //reader.SetMemory(caloClusterHeaderPtr); | |
9a9467ed | 575 | |
576 | AliHLTESDCaloClusterMaker clusterMaker; | |
577 | ||
578 | int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr); | |
2a24cbbe | 579 | |
9a9467ed | 580 | HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters); |
581 | iAddedDataBlocks++; | |
582 | } | |
f064ef44 | 583 | |
584 | // Add tracks from MUON. | |
57a4102f | 585 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTAnyDataType | kAliHLTDataOriginMUON); i!=NULL; i=GetNextInputBlock() ){ |
586 | fBenchmark.AddInput(i->fSize); | |
587 | } | |
588 | ||
f064ef44 | 589 | for (const TObject* obj = GetFirstInputObject(kAliHLTAnyDataType | kAliHLTDataOriginMUON); |
590 | obj != NULL; | |
591 | obj = GetNextInputObject() | |
592 | ) | |
593 | { | |
594 | const TClonesArray* tracklist = NULL; | |
595 | if (obj->IsA() == AliESDEvent::Class()) | |
596 | { | |
597 | const AliESDEvent* event = static_cast<const AliESDEvent*>(obj); | |
598 | HLTDebug("Received a MUON ESD with specification: 0x%X", GetSpecification(obj)); | |
599 | if (event->GetList() == NULL) continue; | |
600 | tracklist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonTracks")); | |
601 | if (tracklist == NULL) continue; | |
602 | } | |
603 | else if (obj->IsA() == TClonesArray::Class()) | |
604 | { | |
605 | tracklist = static_cast<const TClonesArray*>(obj); | |
606 | HLTDebug("Received a MUON TClonesArray of tracks with specification: 0x%X", GetSpecification(obj)); | |
607 | } | |
608 | else | |
609 | { | |
610 | // Cannot handle this object type. | |
611 | continue; | |
612 | } | |
613 | HLTDebug("Received %d MUON tracks.", tracklist->GetEntriesFast()); | |
614 | if (tracklist->GetEntriesFast() > 0) | |
615 | { | |
616 | const AliESDMuonTrack* track = dynamic_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(0)); | |
617 | if (track == NULL) | |
618 | { | |
619 | HLTError(Form("%s from MUON does not contain AliESDMuonTrack objects.", obj->ClassName())); | |
620 | continue; | |
a1408c4b | 621 | } |
f064ef44 | 622 | } |
623 | for (Int_t i = 0; i < tracklist->GetEntriesFast(); ++i) | |
624 | { | |
625 | const AliESDMuonTrack* track = static_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(i)); | |
626 | pESD->AddMuonTrack(track); | |
627 | } | |
628 | } | |
629 | ||
630 | if (iAddedDataBlocks>0 && pTree) { | |
631 | pTree->Fill(); | |
632 | } | |
a1408c4b | 633 | |
634 | if (iResult>=0) iResult=iAddedDataBlocks; | |
635 | return iResult; | |
636 | } |