]>
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 | ||
19 | /** @file AliHLTGlobalEsdConverterComponent.cxx | |
20 | @author Matthias Richter | |
21 | @date | |
22 | @brief Global ESD converter component. | |
23 | */ | |
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 | |
f167b631 | 175 | iResult=Reconfigure(NULL, NULL); |
176 | TString allArgs = ""; | |
177 | for ( int i = 0; i < argc; i++ ) { | |
178 | if ( !allArgs.IsNull() ) allArgs += " "; | |
179 | allArgs += argv[i]; | |
180 | } | |
a1408c4b | 181 | |
f167b631 | 182 | TObjArray* pTokens=allArgs.Tokenize(" "); |
183 | if (pTokens) { | |
184 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
185 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
186 | if (argument.IsNull()) continue; | |
187 | ||
188 | // -notree | |
189 | if (argument.CompareTo("-notree")==0) { | |
190 | fWriteTree=0; | |
191 | ||
192 | // -tree | |
193 | } else if (argument.CompareTo("-tree")==0) { | |
194 | fWriteTree=1; | |
195 | } else if (argument.CompareTo("-solenoidBz")==0) { | |
196 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
197 | HLTInfo("Magnetic Field set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
198 | fSolenoidBz=((TObjString*)pTokens->At(i))->GetString().Atof(); | |
199 | continue; | |
200 | } else { | |
201 | HLTError("unknown argument %s", argument.Data()); | |
202 | break; | |
203 | } | |
a1408c4b | 204 | } |
205 | } | |
206 | if (bMissingParam) { | |
207 | HLTError("missing parameter for argument %s", argument.Data()); | |
208 | iResult=-EINVAL; | |
209 | } | |
210 | ||
75970b8d | 211 | fSolenoidBz=GetBz(); |
212 | ||
a1408c4b | 213 | if (iResult>=0) { |
214 | fESD = new AliESDEvent; | |
215 | if (fESD) { | |
216 | fESD->CreateStdContent(); | |
217 | } else { | |
218 | iResult=-ENOMEM; | |
219 | } | |
6117ef63 | 220 | |
221 | SetupCTPData(); | |
a1408c4b | 222 | } |
223 | ||
57a4102f | 224 | fBenchmark.SetTimer(0,"total"); |
225 | ||
a1408c4b | 226 | return iResult; |
227 | } | |
228 | ||
229 | int AliHLTGlobalEsdConverterComponent::DoDeinit() | |
230 | { | |
231 | // see header file for class documentation | |
232 | if (fESD) delete fESD; | |
233 | fESD=NULL; | |
234 | ||
235 | return 0; | |
236 | } | |
237 | ||
238 | int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
6117ef63 | 239 | AliHLTComponentTriggerData& trigData) |
a1408c4b | 240 | { |
241 | // see header file for class documentation | |
242 | int iResult=0; | |
243 | if (!fESD) return -ENODEV; | |
244 | ||
57a4102f | 245 | if (IsDataEvent()) fBenchmark.StartNewEvent(); |
246 | fBenchmark.Start(0); | |
247 | ||
a1408c4b | 248 | AliESDEvent* pESD = fESD; |
249 | ||
250 | pESD->Reset(); | |
251 | pESD->SetMagneticField(fSolenoidBz); | |
6117ef63 | 252 | pESD->SetRunNumber(GetRunNo()); |
6700298e | 253 | pESD->SetPeriodNumber(GetPeriodNumber()); |
254 | pESD->SetOrbitNumber(GetOrbitNumber()); | |
255 | pESD->SetBunchCrossNumber(GetBunchCrossNumber()); | |
256 | pESD->SetTimeStamp(GetTimeStamp()); | |
a1408c4b | 257 | |
6117ef63 | 258 | const AliHLTCTPData* pCTPData=CTPData(); |
259 | if (pCTPData) { | |
260 | AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData); | |
261 | for (int index=0; index<gkNCTPTriggerClasses; index++) { | |
262 | if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue; | |
263 | pESD->SetTriggerClass(pCTPData->Name(index), index); | |
264 | } | |
265 | pESD->SetTriggerMask(mask); | |
266 | } | |
267 | ||
a1408c4b | 268 | TTree* pTree = NULL; |
269 | if (fWriteTree) | |
270 | pTree = new TTree("esdTree", "Tree with HLT ESD objects"); | |
271 | ||
272 | if (pTree) { | |
273 | pTree->SetDirectory(0); | |
274 | } | |
275 | ||
81509fd3 | 276 | if ((iResult=ProcessBlocks(pTree, pESD))>=0) { |
a1408c4b | 277 | // TODO: set the specification correctly |
278 | if (pTree) { | |
279 | // the esd structure is written to the user info and is | |
280 | // needed in te ReadFromTree method to read all objects correctly | |
281 | pTree->GetUserInfo()->Add(pESD); | |
282 | pESD->WriteToTree(pTree); | |
7a9de6d1 | 283 | iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0); |
a1408c4b | 284 | } else { |
7a9de6d1 | 285 | iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0); |
a1408c4b | 286 | } |
57a4102f | 287 | fBenchmark.AddOutput(GetLastObjectSize()); |
a1408c4b | 288 | } |
289 | if (pTree) { | |
290 | // clear user info list to prevent objects from being deleted | |
291 | pTree->GetUserInfo()->Clear(); | |
292 | delete pTree; | |
293 | } | |
57a4102f | 294 | |
295 | fBenchmark.Stop(0); | |
296 | HLTInfo( fBenchmark.GetStatistics() ); | |
297 | ||
a1408c4b | 298 | return iResult; |
299 | } | |
300 | ||
301 | int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD) | |
302 | { | |
303 | // see header file for class documentation | |
304 | ||
305 | int iResult=0; | |
306 | int iAddedDataBlocks=0; | |
307 | ||
308 | // Barrel tracking | |
309 | ||
310 | // in the first attempt this component reads the TPC tracks and updates in the | |
311 | // second step from the ITS tracks | |
093b64dc | 312 | |
093b64dc | 313 | // first read MC information (if present) |
314 | std::map<int,int> mcLabels; | |
315 | ||
316 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC); | |
317 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 318 | |
319 | fBenchmark.AddInput(pBlock->fSize); | |
320 | ||
093b64dc | 321 | AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr ); |
322 | if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) { | |
323 | for( unsigned int il=0; il<dataPtr->fCount; il++ ){ | |
324 | AliHLTTrackMCLabel &lab = dataPtr->fLabels[il]; | |
325 | mcLabels[lab.fTrackID] = lab.fMCLabel; | |
326 | } | |
327 | } else { | |
328 | HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", | |
329 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, | |
330 | dataPtr->fCount, pBlock->fSize); | |
331 | } | |
332 | } | |
333 | ||
0973c527 | 334 | // read dEdx information (if present) |
335 | ||
336 | AliHLTFloat32_t *dEdxTPC = 0; | |
337 | Int_t ndEdxTPC = 0; | |
338 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC); | |
339 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 340 | fBenchmark.AddInput(pBlock->fSize); |
0973c527 | 341 | dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr ); |
342 | ndEdxTPC = pBlock->fSize / sizeof(AliHLTFloat32_t); | |
343 | break; | |
344 | } | |
345 | ||
cd60a73f | 346 | // convert the TPC tracks to ESD tracks |
a1408c4b | 347 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); |
348 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 349 | fBenchmark.AddInput(pBlock->fSize); |
a1408c4b | 350 | vector<AliHLTGlobalBarrelTrack> tracks; |
81509fd3 | 351 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) { |
a1408c4b | 352 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); |
353 | element!=tracks.end(); element++) { | |
354 | Float_t points[4] = { | |
355 | element->GetX(), | |
356 | element->GetY(), | |
357 | element->GetLastPointX(), | |
358 | element->GetLastPointY() | |
359 | }; | |
093b64dc | 360 | |
361 | Int_t mcLabel = -1; | |
362 | if( mcLabels.find(element->TrackID())!=mcLabels.end() ) | |
363 | mcLabel = mcLabels[element->TrackID()]; | |
364 | element->SetLabel( mcLabel ); | |
365 | ||
a1408c4b | 366 | AliESDtrack iotrack; |
550ecaab | 367 | |
368 | // for the moment, the number of clusters are not set when processing the | |
369 | // kTPCin update, only at kTPCout | |
370 | // there ar emainly three parameters updated for kTPCout | |
371 | // number of clusters | |
372 | // chi2 | |
373 | // pid signal | |
374 | // The first one can be updated already at that stage here, while the two others | |
375 | // eventually require to update from the ITS tracks before. The exact scheme | |
376 | // needs to be checked | |
c3261a7d | 377 | iotrack.SetID( element->TrackID() ); |
a1408c4b | 378 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCin); |
c3261a7d | 379 | { |
f167b631 | 380 | AliHLTGlobalBarrelTrack outPar(*element); |
c3261a7d | 381 | outPar.AliExternalTrackParam::PropagateTo( element->GetLastPointX(), fSolenoidBz ); |
382 | iotrack.UpdateTrackParams(&outPar,AliESDtrack::kTPCout); | |
383 | } | |
a1408c4b | 384 | iotrack.SetTPCPoints(points); |
0973c527 | 385 | if( element->TrackID()<ndEdxTPC ){ |
7e32fedf | 386 | iotrack.SetTPCsignal( dEdxTPC[element->TrackID()], 0, 0 ); |
387 | //AliTPCseed s; | |
388 | //s.Set( element->GetX(), element->GetAlpha(), | |
389 | //element->GetParameter(), element->GetCovariance() ); | |
390 | //s.SetdEdx( dEdxTPC[element->TrackID()] ); | |
391 | //s.CookPID(); | |
392 | //iotrack.SetTPCpid(s.TPCrPIDs() ); | |
0973c527 | 393 | } else { |
394 | if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels"); | |
395 | } | |
a1408c4b | 396 | pESD->AddTrack(&iotrack); |
093b64dc | 397 | if (fVerbosity>0) element->Print(); |
a1408c4b | 398 | } |
093b64dc | 399 | HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size()); |
a1408c4b | 400 | iAddedDataBlocks++; |
401 | } else if (iResult<0) { | |
093b64dc | 402 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", |
403 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
a1408c4b | 404 | } |
405 | } | |
406 | ||
7f167a74 | 407 | |
408 | // Get ITS SPD vertex | |
57a4102f | 409 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){ |
410 | fBenchmark.AddInput(i->fSize); | |
411 | } | |
7f167a74 | 412 | |
413 | for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) { | |
414 | AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ); | |
415 | pESD->SetPrimaryVertexSPD( vtx ); | |
416 | } | |
417 | ||
f167b631 | 418 | // now update ESD tracks with the ITSOut info |
419 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut); | |
cd60a73f | 420 | pBlock!=NULL; pBlock=GetNextInputBlock()) { |
57a4102f | 421 | fBenchmark.AddInput(pBlock->fSize); |
cd60a73f | 422 | vector<AliHLTGlobalBarrelTrack> tracks; |
423 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
424 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
425 | element!=tracks.end(); element++) { | |
cd60a73f | 426 | int tpcID=element->TrackID(); |
427 | // the ITS tracker assigns the TPC track used as seed for a certain track to | |
428 | // the trackID | |
429 | if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue; | |
cd60a73f | 430 | AliESDtrack *tESD = pESD->GetTrack( tpcID ); |
f167b631 | 431 | if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSout ); |
a1408c4b | 432 | } |
cd60a73f | 433 | } |
434 | } | |
18ada816 | 435 | |
f167b631 | 436 | // now update ESD tracks with the ITS info |
437 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS); | |
b7ed2eb4 | 438 | pBlock!=NULL; pBlock=GetNextInputBlock()) { |
57a4102f | 439 | fBenchmark.AddInput(pBlock->fSize); |
b7ed2eb4 | 440 | vector<AliHLTGlobalBarrelTrack> tracks; |
441 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
442 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
443 | element!=tracks.end(); element++) { | |
b7ed2eb4 | 444 | int tpcID=element->TrackID(); |
445 | // the ITS tracker assigns the TPC track used as seed for a certain track to | |
446 | // the trackID | |
447 | if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue; | |
448 | AliESDtrack *tESD = pESD->GetTrack( tpcID ); | |
f167b631 | 449 | if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSin ); |
b7ed2eb4 | 450 | } |
451 | } | |
452 | } | |
453 | ||
d9386025 | 454 | // update with vertices and vertex-fitted tracks |
455 | ||
456 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer); | |
457 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 458 | fBenchmark.AddInput(pBlock->fSize); |
d9386025 | 459 | AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) ); |
460 | } | |
461 | ||
b7ed2eb4 | 462 | |
18ada816 | 463 | // convert the HLT TRD tracks to ESD tracks |
464 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD); | |
465 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
57a4102f | 466 | fBenchmark.AddInput(pBlock->fSize); |
18ada816 | 467 | vector<AliHLTGlobalBarrelTrack> tracks; |
468 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
469 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
470 | element!=tracks.end(); element++) { | |
471 | ||
472 | Double_t TRDpid[AliPID::kSPECIES], eProb(0.2), restProb((1-eProb)/(AliPID::kSPECIES-1)); //eprob(element->GetTRDpid...); | |
473 | for(Int_t i=0; i<AliPID::kSPECIES; i++){ | |
474 | switch(i){ | |
475 | case AliPID::kElectron: TRDpid[AliPID::kElectron]=eProb; break; | |
476 | default: TRDpid[i]=restProb; break; | |
477 | } | |
478 | } | |
479 | ||
480 | AliESDtrack iotrack; | |
481 | iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTRDin); | |
482 | iotrack.SetTRDpid(TRDpid); | |
483 | ||
484 | pESD->AddTrack(&iotrack); | |
485 | if (fVerbosity>0) element->Print(); | |
486 | } | |
487 | HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size()); | |
488 | iAddedDataBlocks++; | |
489 | } else if (iResult<0) { | |
490 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", | |
491 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
492 | } | |
493 | } | |
b4479a87 | 494 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock()) |
9a9467ed | 495 | { |
57a4102f | 496 | fBenchmark.AddInput(pBlock->fSize); |
9a9467ed | 497 | AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr); |
498 | ||
499 | HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification); | |
500 | ||
2a24cbbe | 501 | //AliHLTCaloClusterReader reader; |
502 | //reader.SetMemory(caloClusterHeaderPtr); | |
9a9467ed | 503 | |
504 | AliHLTESDCaloClusterMaker clusterMaker; | |
505 | ||
506 | int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr); | |
2a24cbbe | 507 | |
9a9467ed | 508 | HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters); |
509 | iAddedDataBlocks++; | |
510 | } | |
f064ef44 | 511 | |
512 | // Add tracks from MUON. | |
57a4102f | 513 | for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTAnyDataType | kAliHLTDataOriginMUON); i!=NULL; i=GetNextInputBlock() ){ |
514 | fBenchmark.AddInput(i->fSize); | |
515 | } | |
516 | ||
f064ef44 | 517 | for (const TObject* obj = GetFirstInputObject(kAliHLTAnyDataType | kAliHLTDataOriginMUON); |
518 | obj != NULL; | |
519 | obj = GetNextInputObject() | |
520 | ) | |
521 | { | |
522 | const TClonesArray* tracklist = NULL; | |
523 | if (obj->IsA() == AliESDEvent::Class()) | |
524 | { | |
525 | const AliESDEvent* event = static_cast<const AliESDEvent*>(obj); | |
526 | HLTDebug("Received a MUON ESD with specification: 0x%X", GetSpecification(obj)); | |
527 | if (event->GetList() == NULL) continue; | |
528 | tracklist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonTracks")); | |
529 | if (tracklist == NULL) continue; | |
530 | } | |
531 | else if (obj->IsA() == TClonesArray::Class()) | |
532 | { | |
533 | tracklist = static_cast<const TClonesArray*>(obj); | |
534 | HLTDebug("Received a MUON TClonesArray of tracks with specification: 0x%X", GetSpecification(obj)); | |
535 | } | |
536 | else | |
537 | { | |
538 | // Cannot handle this object type. | |
539 | continue; | |
540 | } | |
541 | HLTDebug("Received %d MUON tracks.", tracklist->GetEntriesFast()); | |
542 | if (tracklist->GetEntriesFast() > 0) | |
543 | { | |
544 | const AliESDMuonTrack* track = dynamic_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(0)); | |
545 | if (track == NULL) | |
546 | { | |
547 | HLTError(Form("%s from MUON does not contain AliESDMuonTrack objects.", obj->ClassName())); | |
548 | continue; | |
a1408c4b | 549 | } |
f064ef44 | 550 | } |
551 | for (Int_t i = 0; i < tracklist->GetEntriesFast(); ++i) | |
552 | { | |
553 | const AliESDMuonTrack* track = static_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(i)); | |
554 | pESD->AddMuonTrack(track); | |
555 | } | |
556 | } | |
557 | ||
558 | if (iAddedDataBlocks>0 && pTree) { | |
559 | pTree->Fill(); | |
560 | } | |
a1408c4b | 561 | |
562 | if (iResult>=0) iResult=iAddedDataBlocks; | |
563 | return iResult; | |
564 | } |