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