3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 // @file AliHLTGlobalEsdConverterComponent.cxx
20 // @author Matthias Richter
22 // @brief Global ESD converter component.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32 #include "AliHLTGlobalEsdConverterComponent.h"
33 #include "AliHLTGlobalBarrelTrack.h"
34 #include "AliHLTExternalTrackParam.h"
35 #include "AliHLTTrackMCLabel.h"
36 #include "AliHLTCTPData.h"
37 #include "AliESDEvent.h"
38 #include "AliESDtrack.h"
39 #include "AliESDMuonTrack.h"
40 #include "AliCDBEntry.h"
41 #include "AliCDBManager.h"
45 #include "TClonesArray.h"
46 #include "AliHLTESDCaloClusterMaker.h"
47 #include "AliHLTCaloClusterDataStruct.h"
48 #include "AliHLTCaloClusterReader.h"
49 #include "AliESDCaloCluster.h"
50 #include "AliHLTGlobalVertexerComponent.h"
52 /** ROOT macro for the implementation of ROOT specific class methods */
53 ClassImp(AliHLTGlobalEsdConverterComponent)
55 AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent()
60 , fSolenoidBz(-5.00668)
61 , fBenchmark("EsdConverter")
63 // see header file for class documentation
65 // refer to README to build package
67 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70 AliHLTGlobalEsdConverterComponent::~AliHLTGlobalEsdConverterComponent()
72 // see header file for class documentation
73 if (fESD) delete fESD;
77 int AliHLTGlobalEsdConverterComponent::Configure(const char* arguments)
79 // see header file for class documentation
81 if (!arguments) return iResult;
83 TString allArgs=arguments;
87 TObjArray* pTokens=allArgs.Tokenize(" ");
89 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
90 argument=((TObjString*)pTokens->At(i))->GetString();
91 if (argument.IsNull()) continue;
93 if (argument.CompareTo("-solenoidBz")==0) {
94 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
95 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
98 HLTError("unknown argument %s", argument.Data());
106 HLTError("missing parameter for argument %s", argument.Data());
113 int AliHLTGlobalEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
115 // see header file for class documentation
117 const char* path=NULL;
118 const char* defaultNotify="";
121 defaultNotify=" (default)";
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()*/);
127 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
129 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
130 iResult=Configure(pString->GetString().Data());
132 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
135 HLTError("can not fetch object \"%s\" from CDB", path);
142 void AliHLTGlobalEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
144 // see header file for class documentation
145 list.push_back(kAliHLTDataTypeTrack);
146 list.push_back(kAliHLTDataTypeTrackMC);
147 list.push_back(kAliHLTDataTypeCaloCluster);
148 list.push_back(kAliHLTDataTypedEdx );
149 list.push_back(kAliHLTDataTypeESDVertex );
150 list.push_back(kAliHLTDataTypeESDObject);
151 list.push_back(kAliHLTDataTypeTObject);
152 list.push_back(kAliHLTDataTypeGlobalVertexer);
155 AliHLTComponentDataType AliHLTGlobalEsdConverterComponent::GetOutputDataType()
157 // see header file for class documentation
158 return kAliHLTDataTypeESDObject|kAliHLTDataOriginOut;
161 void AliHLTGlobalEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
163 // see header file for class documentation
165 inputMultiplier=10.0;
168 int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv)
170 // see header file for class documentation
175 // default list of skiped ESD objects
186 // "AliMultiplicity,"
189 // "SPDPileupVertices,"
190 // "TrkPileupVertices,"
193 "AliRawDataErrorLogs,"
196 iResult=Reconfigure(NULL, NULL);
197 TString allArgs = "";
198 for ( int i = 0; i < argc; i++ ) {
199 if ( !allArgs.IsNull() ) allArgs += " ";
203 TObjArray* pTokens=allArgs.Tokenize(" ");
205 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
206 argument=((TObjString*)pTokens->At(i))->GetString();
207 if (argument.IsNull()) continue;
210 if (argument.CompareTo("-notree")==0) {
214 } else if (argument.CompareTo("-tree")==0) {
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());
219 HLTWarning("argument '-solenoidBz' is deprecated, solenoid field initiaized from CDB settings");
221 } else if (argument.Contains("-skipobject=")) {
222 argument.ReplaceAll("-skipobject=", "");
223 skipObjects=argument;
225 HLTError("unknown argument %s", argument.Data());
232 HLTError("missing parameter for argument %s", argument.Data());
239 fESD = new AliESDEvent;
241 fESD->CreateStdContent();
243 // remove some of the objects which are not needed
244 if (fESD->GetList() && !skipObjects.IsNull()) {
245 pTokens=skipObjects.Tokenize(",");
249 TObject* pObject=NULL;
250 while ((pObject=next())!=NULL) {
251 id=((TObjString*)pObject)->GetString().Data();
252 TObject* pObj=fESD->GetList()->FindObject(id);
254 HLTDebug("removing object %s", id);
255 fESD->GetList()->Remove(pObj);
258 HLTWarning("failed to remove object '%s' from ESD", id);
261 fESD->GetStdContent();
272 fBenchmark.SetTimer(0,"total");
277 int AliHLTGlobalEsdConverterComponent::DoDeinit()
279 // see header file for class documentation
280 if (fESD) delete fESD;
286 int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
287 AliHLTComponentTriggerData& trigData)
289 // see header file for class documentation
291 if (!fESD) return -ENODEV;
293 if (IsDataEvent()) fBenchmark.StartNewEvent();
296 AliESDEvent* pESD = fESD;
299 pESD->SetMagneticField(fSolenoidBz);
300 pESD->SetRunNumber(GetRunNo());
301 pESD->SetPeriodNumber(GetPeriodNumber());
302 pESD->SetOrbitNumber(GetOrbitNumber());
303 pESD->SetBunchCrossNumber(GetBunchCrossNumber());
304 pESD->SetTimeStamp(GetTimeStamp());
306 const AliHLTCTPData* pCTPData=CTPData();
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);
313 pESD->SetTriggerMask(mask);
318 pTree = new TTree("esdTree", "Tree with HLT ESD objects");
321 pTree->SetDirectory(0);
324 if ((iResult=ProcessBlocks(pTree, pESD))>=0) {
325 // TODO: set the specification correctly
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);
331 iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0);
333 iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0);
335 fBenchmark.AddOutput(GetLastObjectSize());
338 // clear user info list to prevent objects from being deleted
339 pTree->GetUserInfo()->Clear();
344 HLTInfo( fBenchmark.GetStatistics() );
349 int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD)
351 // see header file for class documentation
354 int iAddedDataBlocks=0;
357 // tracks are based on the TPC tracks, and only updated from the ITS information
359 // 1) extract MC information for TPC and ITS from specific data blocks and store in
360 // intermediate vector arrays
361 // 2) extract TPC tracks, update with MC labels if available, the track parameters
362 // are estimated at the first cluster position
363 // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
364 // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
365 // 2.3) update kTPCrefit using the same parameters at the first cluster position
366 // HLT has strictly spoking no refit, but we want the flag to be set
367 // can be changed to be done after all the individual barrel detector parameters
368 // have been updated by looping over the tracks again
369 // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
370 // tracking information
371 // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
372 // 3.2) update with kITSin
373 // TODO 2010-07-12 find out if the kITSrefit has to be set as well
374 // 4) extract TRD tracks and add to ESD
375 // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
377 // 1) first read MC information (if present)
378 std::map<int,int> mcLabelsTPC;
379 std::map<int,int> mcLabelsITS;
381 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
382 pBlock!=NULL; pBlock=GetNextInputBlock()) {
384 fBenchmark.AddInput(pBlock->fSize);
386 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
387 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
388 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
389 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
390 mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
393 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
394 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
395 dataPtr->fCount, pBlock->fSize);
399 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
400 pBlock!=NULL; pBlock=GetNextInputBlock()) {
402 fBenchmark.AddInput(pBlock->fSize);
404 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
405 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
406 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
407 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
408 mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
411 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
412 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
413 dataPtr->fCount, pBlock->fSize);
418 // read dEdx information (if present)
419 // TODO 2010-07-12 this needs to be verified
421 AliHLTFloat32_t *dEdxTPC = 0;
423 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
424 pBlock!=NULL; pBlock=GetNextInputBlock()) {
425 fBenchmark.AddInput(pBlock->fSize);
426 dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
427 ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
431 // 2) convert the TPC tracks to ESD tracks
432 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
433 pBlock!=NULL; pBlock=GetNextInputBlock()) {
434 fBenchmark.AddInput(pBlock->fSize);
435 vector<AliHLTGlobalBarrelTrack> tracks;
436 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
437 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
438 element!=tracks.end(); element++) {
439 Float_t points[4] = {
442 element->GetLastPointX(),
443 element->GetLastPointY()
447 if( mcLabelsTPC.find(element->TrackID())!=mcLabelsTPC.end() )
448 mcLabel = mcLabelsTPC[element->TrackID()];
449 element->SetLabel( mcLabel );
453 // for the moment, the number of clusters are not set when processing the
454 // kTPCin update, only at kTPCout
455 // there ar emainly three parameters updated for kTPCout
456 // number of clusters
459 // The first one can be updated already at that stage here, while the two others
460 // eventually require to update from the ITS tracks before. The exact scheme
461 // needs to be checked
462 iotrack.SetID( element->TrackID() );
465 // TODO 2010-07-12 disabled for the moment because of bug
466 // https://savannah.cern.ch/bugs/index.php?69875
467 // the propagation does not work, there is an offset in z
468 // propagate to last cluster and update parameters with flag kTPCout
469 // Note: updating with flag kITSout further down will overwrite the outer
470 // parameter again so this can be done only for ITS standalone tracks, meaning
471 // tracks in the ITS not associated with any TPC track
472 // HLT does not provide such standalone tracking
474 AliHLTGlobalBarrelTrack outPar(*element);
475 //outPar.AliExternalTrackParam::PropagateTo( element->GetLastPointX(), fSolenoidBz );
476 const Int_t N=10; // number of steps.
477 const Float_t xRange = element->GetLastPointX() - element->GetX();
478 const Float_t xStep = xRange / N ;
479 for(int i = 1; i <= N; ++i) {
480 if(!outPar.AliExternalTrackParam::PropagateTo(element->GetX() + xStep * i, fSolenoidBz)) break;
482 outPar.SetLabel(element->GetLabel());
483 iotrack.UpdateTrackParams(&outPar,AliESDtrack::kTPCout);
485 // 2.2 TPC tracking estimates parameters at first cluster
486 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCin);
488 // 2.3 use the same parameters also for kTPCrefit, there is no proper refit in HLT
489 // maybe this can be done later, however also the inner parameter is changed which
490 // is used as a reference point in the display. That point should be at the first
492 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCrefit);
493 iotrack.SetTPCPoints(points);
494 if( element->TrackID()<ndEdxTPC ){
495 AliHLTFloat32_t *val = &(dEdxTPC[3*element->TrackID()]);
496 iotrack.SetTPCsignal( val[0], val[1], val[2] );
498 //s.Set( element->GetX(), element->GetAlpha(),
499 //element->GetParameter(), element->GetCovariance() );
500 //s.SetdEdx( val[0] );
502 //iotrack.SetTPCpid(s.TPCrPIDs() );
504 if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
506 iotrack.SetLabel(mcLabel);
507 pESD->AddTrack(&iotrack);
508 if (fVerbosity>0) element->Print();
510 HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
512 } else if (iResult<0) {
513 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
514 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
519 // Get ITS SPD vertex
520 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
521 fBenchmark.AddInput(i->fSize);
524 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
525 AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
526 pESD->SetPrimaryVertexSPD( vtx );
529 // 3.1. now update ESD tracks with the ITSOut info
530 // updating track parameters with flag kITSout will overwrite parameter set above with flag kTPCout
531 // TODO 2010-07-12 there are some issues with this updating sequence, for the moment update with
532 // flag kITSout is disabled, would require
533 // a) to update kTPCout after kITSout
534 // b) update only for ITS standalone tracks. The HLT ITS tracker does not provide standalone
535 // tracking, every track is related to a TPC track
536 // Furthermore there seems to be a bug as the data blocks describe track parameters around the
537 // vertex, not at the outer ITS
538 // bug https://savannah.cern.ch/bugs/index.php?69872
539 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
540 pBlock!=NULL; pBlock=GetNextInputBlock()) {
541 fBenchmark.AddInput(pBlock->fSize);
542 vector<AliHLTGlobalBarrelTrack> tracks;
543 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
544 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
545 element!=tracks.end(); element++) {
546 int tpcID=element->TrackID();
547 // the ITS tracker assigns the TPC track used as seed for a certain track to
549 if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue;
550 AliESDtrack *tESD = pESD->GetTrack( tpcID );
551 element->SetLabel(tESD->GetLabel());
552 // 2010-07-12 disabled, see above, bugfix https://savannah.cern.ch/bugs/index.php?69872
553 //if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSout );
558 // 3.2. now update ESD tracks with the ITS info
559 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
560 pBlock!=NULL; pBlock=GetNextInputBlock()) {
561 fBenchmark.AddInput(pBlock->fSize);
562 vector<AliHLTGlobalBarrelTrack> tracks;
563 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
564 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
565 element!=tracks.end(); element++) {
566 int tpcID=element->TrackID();
567 // the ITS tracker assigns the TPC track used as seed for a certain track to
569 if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue;
571 if( mcLabelsITS.find(element->TrackID())!=mcLabelsITS.end() )
572 mcLabel = mcLabelsITS[element->TrackID()];
573 AliESDtrack *tESD = pESD->GetTrack( tpcID );
575 // the labels for the TPC and ITS tracking params can be different, e.g.
576 // there can be a decay. The ITS label should then be the better one, the
577 // TPC label is saved in a member of AliESDtrack
579 // upadte only if the ITS label is available, otherwise keep TPC label
580 element->SetLabel( mcLabel );
582 // bugfix https://savannah.cern.ch/bugs/?69713
583 element->SetLabel( tESD->GetLabel() );
585 tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSin );
587 // TODO: add a proper refit
588 //tESD->UpdateTrackParams( &(*element), AliESDtrack::kTPCrefit );
593 // update with vertices and vertex-fitted tracks
595 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
596 pBlock!=NULL; pBlock=GetNextInputBlock()) {
597 fBenchmark.AddInput(pBlock->fSize);
598 AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
601 // Fill DCA parameters for TPC tracks
602 // TODO 2010-07-12 this propagates also the TPC inner param to beamline
603 // sounds not very reasonable
604 // https://savannah.cern.ch/bugs/index.php?69873
605 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
606 if (!pESD->GetTrack(i) ||
607 !pESD->GetTrack(i)->GetTPCInnerParam() ) continue;
608 pESD->GetTrack(i)->RelateToVertexTPC(pESD->GetPrimaryVertexTracks(), fSolenoidBz, 1000 );
611 // loop over all tracks and set the TPC refit flag by updating with the
612 // original TPC inner parameter if not yet set
613 // TODO: replace this by a proper refit
614 // code is comented for the moment as it does not fully solve the problems with
616 // - would set the main parameters to the TPC inner wall again, or
617 // - changes the inner param if the parameters are propagated, so we loose the track
618 // reference point for the display
619 // with the current sequence we have the latter case as the DCA operations above
620 // change the TPC inner parameters
622 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
623 if (!pESD->GetTrack(i) ||
624 !pESD->GetTrack(i)->GetTPCInnerParam() ||
625 pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
626 AliESDtrack* tESD=pESD->GetTrack(i);
627 AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
628 inner.SetLabel(tESD->GetLabel());
629 tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
633 // 4. convert the HLT TRD tracks to ESD tracks
634 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD);
635 pBlock!=NULL; pBlock=GetNextInputBlock()) {
636 fBenchmark.AddInput(pBlock->fSize);
637 vector<AliHLTGlobalBarrelTrack> tracks;
638 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
639 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
640 element!=tracks.end(); element++) {
642 Double_t TRDpid[AliPID::kSPECIES], eProb(0.2), restProb((1-eProb)/(AliPID::kSPECIES-1)); //eprob(element->GetTRDpid...);
643 for(Int_t i=0; i<AliPID::kSPECIES; i++){
645 case AliPID::kElectron: TRDpid[AliPID::kElectron]=eProb; break;
646 default: TRDpid[i]=restProb; break;
651 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTRDout);
652 iotrack.SetStatus(AliESDtrack::kTRDin);
653 iotrack.SetTRDpid(TRDpid);
655 pESD->AddTrack(&iotrack);
656 if (fVerbosity>0) element->Print();
658 HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
660 } else if (iResult<0) {
661 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
662 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
665 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock())
667 fBenchmark.AddInput(pBlock->fSize);
668 AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
670 HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification);
672 //AliHLTCaloClusterReader reader;
673 //reader.SetMemory(caloClusterHeaderPtr);
675 AliHLTESDCaloClusterMaker clusterMaker;
677 int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr);
679 HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters);
683 // Add tracks from MUON.
684 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTAnyDataType | kAliHLTDataOriginMUON); i!=NULL; i=GetNextInputBlock() ){
685 fBenchmark.AddInput(i->fSize);
688 for (const TObject* obj = GetFirstInputObject(kAliHLTAnyDataType | kAliHLTDataOriginMUON);
690 obj = GetNextInputObject()
693 const TClonesArray* tracklist = NULL;
694 if (obj->IsA() == AliESDEvent::Class())
696 const AliESDEvent* event = static_cast<const AliESDEvent*>(obj);
697 HLTDebug("Received a MUON ESD with specification: 0x%X", GetSpecification(obj));
698 if (event->GetList() == NULL) continue;
699 tracklist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonTracks"));
700 if (tracklist == NULL) continue;
702 else if (obj->IsA() == TClonesArray::Class())
704 tracklist = static_cast<const TClonesArray*>(obj);
705 HLTDebug("Received a MUON TClonesArray of tracks with specification: 0x%X", GetSpecification(obj));
709 // Cannot handle this object type.
712 HLTDebug("Received %d MUON tracks.", tracklist->GetEntriesFast());
713 if (tracklist->GetEntriesFast() > 0)
715 const AliESDMuonTrack* track = dynamic_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(0));
718 HLTError(Form("%s from MUON does not contain AliESDMuonTrack objects.", obj->ClassName()));
722 for (Int_t i = 0; i < tracklist->GetEntriesFast(); ++i)
724 const AliESDMuonTrack* track = static_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(i));
725 pESD->AddMuonTrack(track);
729 if (iAddedDataBlocks>0 && pTree) {
733 if (iResult>=0) iResult=iAddedDataBlocks;