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