3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 // @file AliHLTGlobalFlatEsdConverterComponent.cxx
20 // @author Matthias Richter
22 // @brief Global ESD converter component.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32 #include "AliHLTGlobalFlatEsdConverterComponent.h"
33 #include "AliFlatESDEvent.h"
34 #include "AliFlatESDTrack.h"
35 #include "AliFlatExternalTrackParam.h"
36 #include "AliExternalTrackParam.h"
38 #include "AliHLTGlobalBarrelTrack.h"
39 #include "AliHLTExternalTrackParam.h"
40 #include "AliHLTTrackMCLabel.h"
41 #include "AliHLTCTPData.h"
42 #include "AliHLTErrorGuard.h"
43 #include "AliESDEvent.h"
44 #include "AliESDtrack.h"
45 #include "AliESDMuonTrack.h"
46 #include "AliESDMuonCluster.h"
47 #include "AliCDBEntry.h"
48 #include "AliCDBManager.h"
52 #include "TClonesArray.h"
53 //#include "AliHLTESDCaloClusterMaker.h"
54 //#include "AliHLTCaloClusterDataStruct.h"
55 //#include "AliHLTCaloClusterReader.h"
56 //#include "AliESDCaloCluster.h"
57 //#include "AliESDVZERO.h"
58 #include "AliHLTGlobalVertexerComponent.h"
59 #include "AliHLTVertexFinderBase.h"
60 #include "AliHLTTPCSpacePointData.h"
61 #include "AliHLTTPCClusterDataFormat.h"
62 #include "AliHLTTPCDefinitions.h"
63 #include "AliHLTTPCClusterMCData.h"
64 #include "AliHLTTPCTransform.h"
66 /** ROOT macro for the implementation of ROOT specific class methods */
67 ClassImp(AliHLTGlobalFlatEsdConverterComponent)
69 AliHLTGlobalFlatEsdConverterComponent::AliHLTGlobalFlatEsdConverterComponent()
73 , fSolenoidBz(-5.00668)
74 , fBenchmark("FlatEsdConverter")
76 // see header file for class documentation
78 // refer to README to build package
80 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
84 AliHLTGlobalFlatEsdConverterComponent::~AliHLTGlobalFlatEsdConverterComponent()
86 // see header file for class documentation
89 int AliHLTGlobalFlatEsdConverterComponent::Configure(const char* arguments)
91 // see header file for class documentation
93 if (!arguments) return iResult;
95 TString allArgs=arguments;
99 TObjArray* pTokens=allArgs.Tokenize(" ");
101 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
102 argument=((TObjString*)pTokens->At(i))->String();
103 if (argument.IsNull()) continue;
104 HLTError("unknown argument %s", argument.Data());
111 HLTError("missing parameter for argument %s", argument.Data());
118 int AliHLTGlobalFlatEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
120 // see header file for class documentation
122 const char* path=NULL;
123 const char* defaultNotify="";
126 defaultNotify=" (default)";
129 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
130 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
132 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
134 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
135 iResult=Configure(pString->String().Data());
137 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
140 HLTError("can not fetch object \"%s\" from CDB", path);
147 void AliHLTGlobalFlatEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
149 // see header file for class documentation
150 list.push_back(kAliHLTDataTypeTrack);
151 list.push_back(kAliHLTDataTypeTrackMC);
152 list.push_back(kAliHLTDataTypeCaloCluster);
153 list.push_back(kAliHLTDataTypedEdx );
154 list.push_back(kAliHLTDataTypeESDVertex );
155 list.push_back(kAliHLTDataTypeESDObject);
156 list.push_back(kAliHLTDataTypeTObject);
157 list.push_back(kAliHLTDataTypeGlobalVertexer);
158 list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s
159 list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
160 list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
161 list.push_back(kAliHLTDataTypeESDContent);
162 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
163 list.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
166 AliHLTComponentDataType AliHLTGlobalFlatEsdConverterComponent::GetOutputDataType()
168 // see header file for class documentation
169 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
172 void AliHLTGlobalFlatEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
174 // see header file for class documentation
176 inputMultiplier=10.0;
179 int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
181 // see header file for class documentation
186 // default list of skiped ESD objects
197 // "AliMultiplicity,"
200 // "SPDPileupVertices,"
201 // "TrkPileupVertices,"
204 "AliRawDataErrorLogs,"
207 iResult=Reconfigure(NULL, NULL);
208 TString allArgs = "";
209 for ( int i = 0; i < argc; i++ ) {
210 if ( !allArgs.IsNull() ) allArgs += " ";
214 TObjArray* pTokens=allArgs.Tokenize(" ");
216 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
217 argument=((TObjString*)pTokens->At(i))->String();
218 if (argument.IsNull()) continue;
221 if (argument.CompareTo("-noclusters")==0) {
224 } else if (argument.CompareTo("-clusters")==0) {
226 } else if (argument.Contains("-skipobject=")) {
227 argument.ReplaceAll("-skipobject=", "");
228 skipObjects=argument;
230 HLTError("unknown argument %s", argument.Data());
237 HLTError("missing parameter for argument %s", argument.Data());
247 fBenchmark.SetTimer(0,"total");
252 int AliHLTGlobalFlatEsdConverterComponent::DoDeinit()
254 // see header file for class documentation
259 int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
260 const AliHLTComponentBlockData* /*blocks*/,
261 AliHLTComponentTriggerData& /*trigData*/,
262 AliHLTUInt8_t* outputPtr,
263 AliHLTUInt32_t& size,
264 AliHLTComponentBlockDataList& outputBlocks)
266 // see header file for class documentation
268 bool benchmark = true;
270 if (!IsDataEvent()) return iResult;
272 fBenchmark.StartNewEvent();
277 size_t maxOutputSize = size;
280 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
281 new (flatEsd) AliFlatESDEvent;
285 pESD->SetMagneticField(fSolenoidBz);
286 pESD->SetRunNumber(GetRunNo());
287 pESD->SetPeriodNumber(GetPeriodNumber());
288 pESD->SetOrbitNumber(GetOrbitNumber());
289 pESD->SetBunchCrossNumber(GetBunchCrossNumber());
290 pESD->SetTimeStamp(GetTimeStamp());
292 const AliHLTCTPData* pCTPData=CTPData();
294 AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData);
295 for (int index=0; index<gkNCTPTriggerClasses; index++) {
296 if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue;
297 pESD->SetTriggerClass(pCTPData->Name(index), index);
299 pESD->SetTriggerMask(mask);
304 // tracks are based on the TPC tracks, and only updated from the ITS information
306 // 1) extract MC information for TPC and ITS from specific data blocks and store in
307 // intermediate vector arrays
308 // 2) extract TPC tracks, update with MC labels if available, the track parameters
309 // are estimated at the first cluster position
310 // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
311 // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
312 // 2.3) update kTPCrefit using the same parameters at the first cluster position
313 // HLT has strictly spoking no refit, but we want the flag to be set
314 // can be changed to be done after all the individual barrel detector parameters
315 // have been updated by looping over the tracks again
316 // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
317 // tracking information
318 // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
319 // 3.2) update with kITSin
320 // TODO 2010-07-12 find out if the kITSrefit has to be set as well
321 // 4) extract TRD tracks and add to ESD
322 // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
323 // 5) Add Trigger Detectors
326 // 1) first read MC information (if present)
328 std::map<int,int> mcLabelsTPC;
329 std::map<int,int> mcLabelsITS;
331 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
332 pBlock!=NULL; pBlock=GetNextInputBlock()) {
333 fBenchmark.AddInput(pBlock->fSize);
334 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
335 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
336 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
337 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
338 mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
341 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
342 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
343 dataPtr->fCount, pBlock->fSize);
347 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
348 pBlock!=NULL; pBlock=GetNextInputBlock()) {
349 fBenchmark.AddInput(pBlock->fSize);
350 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
351 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
352 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
353 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
354 mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
357 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
358 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
359 dataPtr->fCount, pBlock->fSize);
363 // 2) read dEdx information (if present)
365 AliHLTFloat32_t *dEdxTPC = 0;
367 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
368 pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
369 fBenchmark.AddInput(pBlock->fSize);
370 dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
371 ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
374 // 3) read TPC tracks
376 vector<AliHLTGlobalBarrelTrack> tracksTPC;
378 { // there is only one block of TPC data expected
379 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
381 fBenchmark.AddInput(pBlock->fSize);
382 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksTPC);
385 HLTWarning("converted %d track(s) to AliESDtrack and added to ESD", tracksTPC.size());
386 } else if (iResult<0) {
387 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
388 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
392 // 4) read ITS refitted tracks
394 vector<AliHLTGlobalBarrelTrack> tracksITS;
395 vector<AliHLTGlobalBarrelTrack> tracksITSOut;
397 if( iResult>=0 ) { // there is only one block of ITS tracks expected
398 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
400 fBenchmark.AddInput(pBlock->fSize);
401 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
405 if( iResult>=0 ) { // there is only one block of ITS tracks expected
406 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
408 fBenchmark.AddInput(pBlock->fSize);
409 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
415 const UInt_t kNSlices = 36;
416 const UInt_t kNPatches = 6;
418 const AliHLTTPCClusterData *clustersTPC[kNSlices][kNPatches];
419 const AliHLTTPCClusterMCLabel *clustersTPCMC[kNSlices][kNPatches];
420 for( UInt_t i=0; i<kNSlices; i++){
421 for( UInt_t j=0; j<kNPatches; j++){
422 clustersTPC[i][j] = 0;
423 clustersTPCMC[i][j] =0;
429 if( fWriteClusters ){
431 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
432 pBlock!=NULL; pBlock=GetNextInputBlock()) {
433 //fBenchmark.AddInput(pBlock->fSize);
434 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
435 UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
436 if( slice >= kNSlices || patch>= kNPatches ){
437 HLTWarning("Wrong slice / patch number of cluster block");
440 clustersTPC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterData*> ( pBlock->fPtr );
443 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
444 pBlock!=NULL; pBlock=GetNextInputBlock()) {
445 //fBenchmark.AddInput(pBlock->fSize);
446 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
447 UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
448 if( slice >= kNSlices || patch>= kNPatches ){
449 HLTWarning("Wrong slice / patch number of cluster MC block");
452 clustersTPCMC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterMCLabel*> ( pBlock->fPtr );
457 // Fill vertex information to the flat ESD
459 const AliESDVertex *primaryVertex = 0;
461 const AliESDVertex *primaryVertexSPD = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ) );
462 const AliESDVertex *primaryVertexTracks = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut ) );
464 // cout<<endl<<" Primary vertex Tracks: "<<primaryVertexTracks<<", SPD: "<< primaryVertexSPD <<endl<<endl;
466 flatEsd->FillPrimaryVertices( primaryVertexSPD, primaryVertexTracks );
468 primaryVertex = primaryVertexTracks;
469 if( !primaryVertex ) primaryVertex = primaryVertexSPD;
472 // Fill the track information to the flat ESD structure
475 UInt_t itsOutIter = 0;
476 for( UInt_t tpcIter=0; tpcIter < tracksTPC.size(); tpcIter++) {
478 const AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
480 Float_t points[4] = {
481 static_cast<Float_t>(tpcTrack->GetX()),
482 static_cast<Float_t>(tpcTrack->GetY()),
483 static_cast<Float_t>(tpcTrack->GetLastPointX()),
484 static_cast<Float_t>(tpcTrack->GetLastPointY())
488 if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() )
489 tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
491 //tpcTrack->SetLabel( tpcLabel );
492 // iotrack.SetID( tpcTrack->TrackID() );
494 // set kTPCout - just propagate to the outermost TPC cluster
496 AliHLTGlobalBarrelTrack outPar(*tpcTrack);
498 //outPar.AliExternalTrackParam::PropagateTo( tpcTrack->GetLastPointX(), fSolenoidBz );
499 const Int_t N=10; // number of steps.
500 const Float_t xRange = tpcTrack->GetLastPointX() - tpcTrack->GetX();
501 const Float_t xStep = xRange / N ;
502 for(int i = 1; i <= N; ++i) {
503 if(!outPar.AliExternalTrackParam::PropagateTo(tpcTrack->GetX() + xStep * i, fSolenoidBz)) break;
507 //iotrack.SetTPCPoints(points);
509 if( tpcTrack->TrackID()<ndEdxTPC ){
510 AliHLTFloat32_t *val = &(dEdxTPC[3*tpcTrack->TrackID()]);
511 iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] );
513 //s.Set( tpcTrack->GetX(), tpcTrack->GetAlpha(),
514 //tpcTrack->GetParameter(), tpcTrack->GetCovariance() );
515 //s.SetdEdx( val[0] );
517 //iotrack.SetTPCpid(s.TPCrPIDs() );
519 if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
522 //iotrack.SetLabel(mcLabel);
526 AliHLTGlobalBarrelTrack *itsRefit=0;
529 for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
531 if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
532 itsRefit = &(tracksITS[itsIter]);
533 if( mcLabelsITS.find(tpcIter)!=mcLabelsITS.end() ) itsLabel = mcLabelsITS[tpcIter];
539 AliHLTGlobalBarrelTrack *itsOut=0;
541 for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
543 if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
544 itsOut = &(tracksITSOut[itsOutIter]);
548 // Fill DCA parameters for TPC tracks
552 cP.UpdateTrackParams( (itsRefit ?itsRefit :tpcTrack), AliESDtrack::kTPCin );
553 cP.RelateToVertex( primaryVertex, fSolenoidBz, 1000 );
556 AliFlatESDTrack *flatTrack = flatEsd->GetNextTrackPointer();
558 UInt_t nClustersTPC = tpcTrack->GetNumberOfPoints();
559 UInt_t nClustersITS = itsRefit ?itsRefit->GetNumberOfPoints() :0;
561 flatTrack->SetNumberOfITSClusters( nClustersITS );
563 if( flatEsd->GetSize() + flatTrack->EstimateSize( kTRUE, nClustersTPC ) >= maxOutputSize ){
564 cout<<endl<<endl<<"NOT ENOUGH MEMORY!!!!"<<endl<<endl;
569 flatTrack->FillExternalTrackParam( itsRefit, NULL, tpcTrack, &outPar, cP.GetConstrainedParam(), itsOut);
571 if( fWriteClusters && tpcTrack->GetPoints() ){
572 const UInt_t* clusterIDs = tpcTrack->GetPoints();
573 for( UInt_t i=0; i<nClustersTPC; i++ ){
574 UInt_t id = clusterIDs[i];
575 UInt_t iSlice = AliHLTTPCSpacePointData::GetSlice(id);
576 UInt_t iPatch = AliHLTTPCSpacePointData::GetPatch(id);
577 UInt_t iCluster = AliHLTTPCSpacePointData::GetNumber(id);
578 if( iSlice >= kNSlices || iPatch>= kNPatches ){
579 HLTWarning("Wrong slice / patch number of TPC cluster");
582 const AliHLTTPCClusterData *clusterBlock = clustersTPC[iSlice][iPatch];
584 HLTWarning("no cluster block found for slice %d, patch %d",iSlice,iPatch);
587 if( iCluster>= clusterBlock->fSpacePointCnt ){
588 HLTWarning("no cluster block found for slice %d, patch %d, cluster %d",iSlice,iPatch,iCluster);
591 const AliHLTTPCSpacePointData &cIn = clusterBlock->fSpacePoints[iCluster];
592 AliFlatTPCCluster *c= flatTrack->GetNextTPCClusterPointer();
596 c->fPadRow = cIn.GetPadRow() + AliHLTTPCTransform::GetFirstRow(iPatch);
597 c->fSigmaY2 = cIn.GetSigmaY2();
598 c->fSigmaZ2 = cIn.GetSigmaZ2();
599 c->fCharge = cIn.GetCharge();
600 c->fQMax = cIn.GetQMax();
601 flatTrack->StoreLastTPCCluster();
606 flatEsd->StoreLastTrack();
608 if (fVerbosity>0) tpcTrack->Print();
616 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
617 if (pP && pP->fSize && pP->fPtr) {
618 const AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData*>(pP->fPtr);
619 const int* v0s = data->fTrackIndices + data->fNPrimTracks;
621 for (int i = 0; i < nV0s; ++i) {
622 AliFlatESDV0 *v0 = flatEsd->GetNextV0Pointer();
623 v0->fNegTrackID = v0s[2 * i];
624 v0->fPosTrackID = v0s[2 * i + 1];
625 flatEsd->StoreLastV0();
628 HLTWarning(" No V0 data block");
632 // Get ITS SPD vertex
633 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
634 fBenchmark.AddInput(i->fSize);
638 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
639 AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
640 pESD->SetPrimaryVertexSPD( vtx );
644 // update with vertices and vertex-fitted tracks
645 // output of the GlobalVertexerComponent
646 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
647 pBlock!=NULL; pBlock=GetNextInputBlock()) {
648 fBenchmark.AddInput(pBlock->fSize);
649 AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
652 // update with vertices and vertex-fitted tracks
653 // output of PrimaryVertexer and V0Finder components
654 TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
656 AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
658 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut);
659 if (pP && pP->fSize && pP->fPtr) {
660 const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut);
661 if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) {
662 const int* v0s = static_cast<const int*>(pV0->fPtr);
663 HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]);
665 AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL);
667 HLTWarning("Problem with primary finder's data block");
669 HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName());
672 // throw an error if there is a V0 data block which can not be handled without
673 // the AliKFVertex object
674 if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) {
675 ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s",
676 DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str());
682 // loop over all tracks and set the TPC refit flag by updating with the
683 // original TPC inner parameter if not yet set
684 // TODO: replace this by a proper refit
685 // code is comented for the moment as it does not fully solve the problems with
687 // - would set the main parameters to the TPC inner wall again, or
688 // - changes the inner param if the parameters are propagated, so we loose the track
689 // reference point for the display
690 // with the current sequence we have the latter case as the DCA operations above
691 // change the TPC inner parameters
693 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
694 if (!pESD->GetTrack(i) ||
695 !pESD->GetTrack(i)->GetTPCInnerParam() ||
696 pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
697 AliESDtrack* tESD=pESD->GetTrack(i);
698 AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
699 inner.SetLabel(tESD->GetLabel());
700 tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
706 AliHLTComponentBlockData outBlock;
707 FillBlockData( outBlock );
708 outBlock.fOffset = size;
709 outBlock.fSize = flatEsd->GetSize();
710 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
711 outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
713 outputBlocks.push_back( outBlock );
715 fBenchmark.AddOutput(outBlock.fSize);
717 size += outBlock.fSize;
721 HLTWarning( fBenchmark.GetStatistics() );
727 Double_t statistics[10];
729 fBenchmark.GetStatisticsData(statistics, names);
730 // statistics[5] = tracksTPC.size();
731 // statistics[7] = nV0s;
733 // FillBenchmarkHistos( statistics, names);
741 void AliHLTGlobalFlatEsdConverterComponent::FillBenchmarkHistos(Double_t *statistics, TString */*names*/){
744 // cout<<"Now writing benchmarks to " << fBenchmarkHistosFilename <<endl<<endl;
746 TFile *f = TFile::Open(fBenchmarkHistosFilename,"UPDATE");
747 THnSparseD *s = (THnSparseD*)f->Get("benchmarkInformation");
748 TNamed *t = (TNamed*)f->Get("time");
751 HLTWarning( "Benchmark Histograms not available!" );
759 histosList.SaveAs(fBenchmarkHistosFilename);