#include <cassert>
#include "AliHLTGlobalFlatEsdConverterComponent.h"
#include "AliFlatESDEvent.h"
+#include "AliFlatESDTrigger.h"
+#include "AliFlatESDVertex.h"
+#include "AliFlatESDV0.h"
#include "AliFlatESDTrack.h"
#include "AliFlatExternalTrackParam.h"
#include "AliExternalTrackParam.h"
int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
const AliHLTComponentBlockData* /*blocks*/,
- AliHLTComponentTriggerData& /*trigData*/,
+ AliHLTComponentTriggerData& trigData,
AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t& size,
AliHLTComponentBlockDataList& outputBlocks )
// see header file for class documentation
int iResult=0;
-#ifdef xxx
if (!IsDataEvent()) return iResult;
size_t maxOutputSize = size;
size = 0;
-
- if( maxOutputSize < sizeof( AliFlatESDEvent ) ){
- HLTWarning("Output buffer is too small.");
- return -ENOMEM;
- }
- AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
- new (flatEsd) AliFlatESDEvent;
-
- flatEsd->SetMagneticField( fSolenoidBz );
- flatEsd->SetRunNumber( GetRunNo() );
- flatEsd->SetPeriodNumber( GetPeriodNumber() );
- flatEsd->SetOrbitNumber( GetOrbitNumber() );
- flatEsd->SetBunchCrossNumber( GetBunchCrossNumber() );
- flatEsd->SetTimeStamp( GetTimeStamp() );
-
- /*
- const AliHLTCTPData* pCTPData=CTPData();
- if (pCTPData) {
- AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData);
- for (int index=0; index<gkNCTPTriggerClasses; index++) {
- if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue;
- pESD->SetTriggerClass(pCTPData->Name(index), index);
- }
- pESD->SetTriggerMask(mask);
- }
- */
-
- // Barrel tracking
- // tracks are based on the TPC tracks, and only updated from the ITS information
- // Sequence:
- // 1) extract MC information for TPC and ITS from specific data blocks and store in
- // intermediate vector arrays
- // 2) extract TPC tracks, update with MC labels if available, the track parameters
- // are estimated at the first cluster position
- // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
- // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
- // 2.3) update kTPCrefit using the same parameters at the first cluster position
- // HLT has strictly spoking no refit, but we want the flag to be set
- // can be changed to be done after all the individual barrel detector parameters
- // have been updated by looping over the tracks again
- // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
- // tracking information
- // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
- // 3.2) update with kITSin
- // TODO 2010-07-12 find out if the kITSrefit has to be set as well
- // 4) extract TRD tracks and add to ESD
- // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
- // 5) Add Trigger Detectors
- // VZERO, ZDC
-
- // 1) first read MC information (if present)
+ // Read part of the input data to local arrays
+
+ // 1) first, read MC information if present
std::map<int,int> mcLabelsTPC;
std::map<int,int> mcLabelsITS;
ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
}
- // 3) read TPC tracks
+ // 3) read TPC tracks, ITS refitted tracks, ITS OUT tracks
vector<AliHLTGlobalBarrelTrack> tracksTPC;
+ vector<AliHLTGlobalBarrelTrack> tracksITS;
+ vector<AliHLTGlobalBarrelTrack> tracksITSOut;
+
+ if( iResult>=0 ){
- { // there is only one block of TPC data expected
const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
if( pBlock ){
fBenchmark.AddInput(pBlock->fSize);
- iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksTPC);
+ iResult = AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksTPC);
+ }
+
+ if( iResult>=0 ) {
+ pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
+ if( pBlock ){
+ fBenchmark.AddInput(pBlock->fSize);
+ iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
+ }
+ }
+
+ if( iResult>=0 ) {
+ pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
+ if( pBlock ){
+ fBenchmark.AddInput(pBlock->fSize);
+ iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITSOut);
+ }
}
- if( iResult>=0 ){
- HLTWarning("converted %d track(s) to AliESDtrack and added to ESD", tracksTPC.size());
- } else if (iResult<0) {
- HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
- DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
+
+ if( iResult<0 ){
+ HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
+ DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
}
}
-
- // 4) read ITS refitted tracks
- vector<AliHLTGlobalBarrelTrack> tracksITS;
- vector<AliHLTGlobalBarrelTrack> tracksITSOut;
+ HLTWarning("converted %d TPC %d ITS %d ITSout track(s) to GlobalBarrelTrack", tracksTPC.size(), tracksITS.size(), tracksITSOut.size() );
- if( iResult>=0 ) { // there is only one block of ITS tracks expected
- const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
- if( pBlock ){
- fBenchmark.AddInput(pBlock->fSize);
- iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
- }
- }
+ // ---------------------------------------------
+ //
+ // Start to fill the flat ESD structure
+ //
- if( iResult>=0 ) { // there is only one block of ITS tracks expected
- const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
- if( pBlock ){
- fBenchmark.AddInput(pBlock->fSize);
- iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
- }
- }
+ Int_t err = 0;
+ AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
-
- // read TPC clusters
- const UInt_t kNSlices = 36;
- const UInt_t kNPatches = 6;
-
- const AliHLTTPCClusterData *clustersTPC[kNSlices][kNPatches];
- const AliHLTTPCClusterMCLabel *clustersTPCMC[kNSlices][kNPatches];
- for( UInt_t i=0; i<kNSlices; i++){
- for( UInt_t j=0; j<kNPatches; j++){
- clustersTPC[i][j] = 0;
- clustersTPCMC[i][j] =0;
- }
- }
+ do{ // single loop for easy break in case of output buffer overflow
- fWriteClusters = 1;
+ err = ( maxOutputSize < sizeof( AliFlatESDEvent ) );
+ if( err ) break;
- if( fWriteClusters ){
+ new (flatEsd) AliFlatESDEvent;
+
+ size_t freeSpace = maxOutputSize - flatEsd->GetSize();
+
+ // fill run info
+ {
+ flatEsd->SetMagneticField( fSolenoidBz );
+ flatEsd->SetPeriodNumber( GetPeriodNumber() );
+ flatEsd->SetRunNumber( GetRunNo() );
+ flatEsd->SetOrbitNumber( GetOrbitNumber() );
+ flatEsd->SetBunchCrossNumber( GetBunchCrossNumber() );
+ flatEsd->SetTimeStamp( GetTimeStamp() );
+ //flatEsd->SetEventSpecie( GetEventSpecie() ); !!SG!! to do
+ }
- for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
- pBlock!=NULL; pBlock=GetNextInputBlock()) {
- //fBenchmark.AddInput(pBlock->fSize);
- UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
- UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
- if( slice >= kNSlices || patch>= kNPatches ){
- HLTWarning("Wrong slice / patch number of cluster block");
- continue;
- }
- clustersTPC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterData*> ( pBlock->fPtr );
+ // Fill trigger information
+ {
+ const AliHLTCTPData* pCTPData=CTPData();
+ if (pCTPData) {
+ size_t triggerSize = 0;
+ int nTriggers = 0;
+ AliFlatESDTrigger *trigger = flatEsd->SetTriggersStart();
+ AliHLTTriggerMask_t mask = pCTPData->ActiveTriggers(trigData);
+ for (int index=0; index<gkNCTPTriggerClasses; index++) {
+ if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
+ const char* name = pCTPData->Name(index);
+ if( name && name[0]!='\0' ){
+ err = trigger->SetTriggerClass( name, index, freeSpace );
+ if( err != 0 ) break;
+ nTriggers++;
+ freeSpace -= trigger->GetSize();
+ triggerSize += trigger->GetSize();
+ trigger = trigger->GetNextTriggerNonConst();
+ }
+ }
+ flatEsd->SetTriggersEnd( nTriggers, triggerSize );
+ //first 50 triggers
+ AliHLTTriggerMask_t mask50;
+ mask50.set(); // set all bits
+ mask50 >>= 50; // shift 50 right
+ flatEsd->SetTriggerMask((mask&mask50).to_ulong());
+ //next 50
+ flatEsd->SetTriggerMaskNext50((mask>>50).to_ulong());
+ }
}
+
+ if( err ) break;
- for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
- pBlock!=NULL; pBlock=GetNextInputBlock()) {
- //fBenchmark.AddInput(pBlock->fSize);
- UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
- UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
- if( slice >= kNSlices || patch>= kNPatches ){
- HLTWarning("Wrong slice / patch number of cluster MC block");
- continue;
- }
- clustersTPCMC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterMCLabel*> ( pBlock->fPtr );
- }
+ const AliESDVertex *primaryVertex = 0;
- }
+ { // fill primary vertex Tracks
- // Fill vertex information to the flat ESD
+ const AliESDVertex *primaryVertexTracks = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut ) );
+ primaryVertex = primaryVertexTracks;
+ err = flatEsd->SetPrimaryVertexTracks( primaryVertexTracks, freeSpace );
+ freeSpace = maxOutputSize - flatEsd->GetSize();
+ }
- const AliESDVertex *primaryVertex = 0;
- {
- const AliESDVertex *primaryVertexSPD = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ) );
- const AliESDVertex *primaryVertexTracks = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut ) );
-
- cout<<endl<<" Primary vertex Tracks: "<<primaryVertexTracks<<", SPD: "<< primaryVertexSPD <<endl<<endl;
+ if( err ) break;
- flatEsd->FillPrimaryVertices( primaryVertexSPD, primaryVertexTracks );
+ { // fill primary vertex SPD
- primaryVertex = primaryVertexTracks;
- if( !primaryVertex ) primaryVertex = primaryVertexSPD;
- }
+ const AliESDVertex *primaryVertexSPD = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ) );
+ if( !primaryVertex ) primaryVertex = primaryVertexSPD;
+ err = flatEsd->SetPrimaryVertexSPD( primaryVertexSPD, freeSpace );
+ freeSpace = maxOutputSize - flatEsd->GetSize();
+ }
+
+ if( err ) break;
- // Fill the track information to the flat ESD structure
- {
- UInt_t itsIter = 0;
- UInt_t itsOutIter = 0;
- for( UInt_t tpcIter=0; tpcIter < tracksTPC.size(); tpcIter++) {
-
- const AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
- /*
- Float_t points[4] = {
- static_cast<Float_t>(tpcTrack->GetX()),
- static_cast<Float_t>(tpcTrack->GetY()),
- static_cast<Float_t>(tpcTrack->GetLastPointX()),
- static_cast<Float_t>(tpcTrack->GetLastPointY())
- };
- */
- Int_t tpcLabel = -1;
- if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() )
- tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
- //tpcTrack->SetLabel( tpcLabel );
- // iotrack.SetID( tpcTrack->TrackID() );
+ { // Fill track information to the flat ESD structure
+
+ size_t trackSize = 0;
+ int nTracks = 0;
+ Long64_t *table = NULL;
+ AliFlatESDTrack *flatTrack = NULL;
+ err = flatEsd->SetTracksStart( flatTrack, table, tracksTPC.size(), freeSpace );
+ freeSpace = maxOutputSize - flatEsd->GetSize();
+
+ if( err ) break;
- // set kTPCout - just propagate to the outermost TPC cluster
+ for( UInt_t tpcIter=0, itsIter = 0, itsOutIter = 0; tpcIter < tracksTPC.size(); tpcIter++) {
- AliHLTGlobalBarrelTrack outPar(*tpcTrack);
- {
- //outPar.AliExternalTrackParam::PropagateTo( tpcTrack->GetLastPointX(), fSolenoidBz );
- const Int_t N=10; // number of steps.
- const Float_t xRange = tpcTrack->GetLastPointX() - tpcTrack->GetX();
- const Float_t xStep = xRange / N ;
- for(int i = 1; i <= N; ++i) {
- if(!outPar.AliExternalTrackParam::PropagateTo(tpcTrack->GetX() + xStep * i, fSolenoidBz)) break;
- }
- }
+ // TPC track parameters
- //iotrack.SetTPCPoints(points);
- /*
- if( tpcTrack->TrackID()<ndEdxTPC ){
- AliHLTFloat32_t *val = &(dEdxTPC[3*tpcTrack->TrackID()]);
- iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] );
- //AliTPCseed s;
- //s.Set( tpcTrack->GetX(), tpcTrack->GetAlpha(),
- //tpcTrack->GetParameter(), tpcTrack->GetCovariance() );
- //s.SetdEdx( val[0] );
- //s.CookPID();
- //iotrack.SetTPCpid(s.TPCrPIDs() );
- } else {
- if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
- }
- */
- //iotrack.SetLabel(mcLabel);
-
- // ITS track
-
- AliHLTGlobalBarrelTrack *itsRefit=0;
- Int_t itsLabel = -1;
+ AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
+ Float_t tpcPoints[4];
+ Float_t tpcDeDx[3]={0,0,0};
+ Int_t tpcLabel = -1;
+ AliHLTGlobalBarrelTrack tpcOutTrack(*tpcTrack);
- for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
-
- if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
- itsRefit = &(tracksITS[itsIter]);
- if( mcLabelsITS.find(tpcIter)!=mcLabelsITS.end() ) itsLabel = mcLabelsITS[tpcIter];
- itsIter++;
+ if (fVerbosity>0) tpcTrack->Print();
+
+ {
+ tpcPoints[0] = static_cast<Float_t>(tpcTrack->GetX());
+ tpcPoints[1] = static_cast<Float_t>(tpcTrack->GetY());
+ tpcPoints[2] = static_cast<Float_t>(tpcTrack->GetLastPointX());
+ tpcPoints[3] = static_cast<Float_t>(tpcTrack->GetLastPointY());
+
+ if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() ) tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
+
+ tpcTrack->SetLabel( tpcLabel );
+
+ { // TPC out - just propagate to the outermost TPC cluster
+ //tpcOutTrack.AliExternalTrackParam::PropagateTo( tpcTrack->GetLastPointX(), fSolenoidBz );
+ const Int_t N=10; // number of steps.
+ const Float_t xRange = tpcTrack->GetLastPointX() - tpcTrack->GetX();
+ const Float_t xStep = xRange / N ;
+ for(int i = 1; i <= N; ++i) {
+ if(!tpcOutTrack.AliExternalTrackParam::PropagateTo(tpcTrack->GetX() + xStep * i, fSolenoidBz)) break;
+ }
+ tpcOutTrack.SetLabel(tpcTrack->GetLabel());
+ }
+
+ if( tpcTrack->TrackID()<ndEdxTPC ){
+ AliHLTFloat32_t *val = &(dEdxTPC[3*tpcTrack->TrackID()]);
+ tpcDeDx[0] = val[0];
+ tpcDeDx[1] = val[1];
+ tpcDeDx[2] = val[2];
+ //AliTPCseed s;
+ //s.Set( tpcTrack->GetX(), tpcTrack->GetAlpha(),
+ //tpcTrack->GetParameter(), tpcTrack->GetCovariance() );
+ //s.SetdEdx( val[0] );
+ //s.CookPID();
+ //iotrack.SetTPCpid(s.TPCrPIDs() );
+ } else {
+ if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
+ }
}
- // ITS Out track
-
+ // ITS track parameters
+
+ AliHLTGlobalBarrelTrack *itsRefit=0;
AliHLTGlobalBarrelTrack *itsOut=0;
+ Int_t itsLabel = tpcLabel;
- for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
-
- if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
- itsOut = &(tracksITSOut[itsOutIter]);
- itsOutIter++;
+ {
+ // ITS Refit & mc label
+
+ for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
+
+ if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
+ itsRefit = &(tracksITS[itsIter]);
+ if( mcLabelsITS.find(tpcIter)!=mcLabelsITS.end() ) itsLabel = mcLabelsITS[tpcIter];
+ itsIter++;
+ }
+
+ // ITS Out track
+
+ for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
+
+ if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
+ itsOut = &(tracksITSOut[itsOutIter]);
+ itsOutIter++;
+ }
+
+ if( itsRefit ) itsRefit->SetLabel( itsLabel );
+ if( itsOut ) itsOut->SetLabel( itsLabel );
}
+
+ // vertex-constrained parameters for TPC tracks
- // Fill DCA parameters for TPC tracks
- AliESDtrack cP;
-
+ const AliExternalTrackParam *tpcConstrained=0;
+
+ AliESDtrack esdTrack;
+ esdTrack.SetID( tpcTrack->TrackID() );
+ esdTrack.UpdateTrackParams(&tpcOutTrack,AliESDtrack::kTPCout);
+ esdTrack.UpdateTrackParams(&(*tpcTrack),AliESDtrack::kTPCin);
+ esdTrack.UpdateTrackParams(&(*tpcTrack),AliESDtrack::kTPCrefit);
+ esdTrack.SetTPCPoints(tpcPoints);
+ esdTrack.SetTPCsignal( tpcDeDx[0], tpcDeDx[1], (UChar_t) tpcDeDx[2] );
+ if( itsOut ) esdTrack.UpdateTrackParams( itsOut, AliESDtrack::kITSout );
+ if( itsRefit ) esdTrack.UpdateTrackParams( itsRefit, AliESDtrack::kITSin );
+ esdTrack.SetLabel(tpcLabel);
+
if( primaryVertex ){
- cP.UpdateTrackParams( (itsRefit ?itsRefit :tpcTrack), AliESDtrack::kTPCin );
- cP.RelateToVertex( primaryVertex, fSolenoidBz, 1000 );
- }
-
-
- AliFlatESDTrack *flatTrack = flatEsd->GetNextTrackPointer();
+ //iotrack.UpdateTrackParams( (itsRefit ?itsRefit :tpcTrack), AliESDtrack::kTPCin );
+ esdTrack.RelateToVertex( primaryVertex, fSolenoidBz, 1000 );
+ tpcConstrained = esdTrack.GetConstrainedParam();
+ }
UInt_t nClustersTPC = tpcTrack->GetNumberOfPoints();
UInt_t nClustersITS = itsRefit ?itsRefit->GetNumberOfPoints() :0;
- flatTrack->SetNumberOfITSClusters( nClustersITS );
+ // fill flat track
- if( flatEsd->GetSize() + flatTrack->EstimateSize( kTRUE, nClustersTPC ) >= maxOutputSize ){
- cout<<endl<<endl<<"NOT ENOUGH MEMORY!!!!"<<endl<<endl;
- iResult=-ENOMEM;
- break;
- }
+ table[tpcIter] = trackSize;
+ err = ( freeSpace < flatTrack->EstimateSize() );
+ if( err ) break;
- flatTrack->FillExternalTrackParam( itsRefit, NULL, tpcTrack, &outPar, cP.GetConstrainedParam(), itsOut);
+ new (flatTrack) AliFlatESDTrack;
- if( fWriteClusters && tpcTrack->GetPoints() ){
- const UInt_t* clusterIDs = tpcTrack->GetPoints();
- for( UInt_t i=0; i<nClustersTPC; i++ ){
- UInt_t id = clusterIDs[i];
- UInt_t iSlice = AliHLTTPCSpacePointData::GetSlice(id);
- UInt_t iPatch = AliHLTTPCSpacePointData::GetPatch(id);
- UInt_t iCluster = AliHLTTPCSpacePointData::GetNumber(id);
- if( iSlice >= kNSlices || iPatch>= kNPatches ){
- HLTWarning("Wrong slice / patch number of TPC cluster");
- continue;
- }
- const AliHLTTPCClusterData *clusterBlock = clustersTPC[iSlice][iPatch];
- if( !clusterBlock ){
- HLTWarning("no cluster block found for slice %d, patch %d",iSlice,iPatch);
- continue;
- }
- if( iCluster>= clusterBlock->fSpacePointCnt ){
- HLTWarning("no cluster block found for slice %d, patch %d, cluster %d",iSlice,iPatch,iCluster);
- continue;
- }
- const AliHLTTPCSpacePointData &cIn = clusterBlock->fSpacePoints[iCluster];
- AliFlatTPCCluster *c= flatTrack->GetNextTPCClusterPointer();
- c->SetX( cIn.GetX() );
- c->SetY( cIn.GetY() );
- c->SetZ( cIn.GetZ() );
- c->SetPadRow( cIn.GetPadRow() + AliHLTTPCTransform::GetFirstRow(iPatch) );
- c->SetSigmaY2( cIn.GetSigmaY2() );
- c->SetSigmaZ2( cIn.GetSigmaZ2() );
- c->SetCharge( cIn.GetCharge() );
- c->SetQMax( cIn.GetQMax() );
- flatTrack->StoreLastTPCCluster();
- }
- }
+ flatTrack->SetExternalTrackParam( itsRefit, itsRefit, tpcTrack, &tpcOutTrack, tpcConstrained, itsOut );
+ flatTrack->SetNumberOfTPCClusters( nClustersTPC );
+ flatTrack->SetNumberOfITSClusters( nClustersITS );
+ trackSize += flatTrack->GetSize();
+ freeSpace -= flatTrack->GetSize();
+ nTracks++;
+ flatTrack = flatTrack->GetNextTrackNonConst();
+ }
+ flatEsd->SetTracksEnd( nTracks, trackSize );
+ }
-
- flatEsd->StoreLastTrack();
-
- if (fVerbosity>0) tpcTrack->Print();
- }
- }
+ if( err ) break;
- // Fill v0's
+ // Fill v0's
- {
- int nV0s =0;
- const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
- if (pP && pP->fSize && pP->fPtr) {
- const AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData*>(pP->fPtr);
- const int* v0s = data->fTrackIndices + data->fNPrimTracks;
- nV0s = data->fNV0s;
- for (int i = 0; i < nV0s; ++i) {
- AliFlatESDV0 *v0 = flatEsd->GetNextV0Pointer();
- v0->fNegTrackID = v0s[2 * i];
- v0->fPosTrackID = v0s[2 * i + 1];
- flatEsd->StoreLastV0();
+ {
+ size_t v0size = 0;
+ int nV0s = 0;
+ AliFlatESDV0 *flatV0 = flatEsd->SetV0sStart();
+
+ const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
+ if ( pBlock && pBlock->fSize && pBlock->fPtr) {
+ fBenchmark.AddInput(pBlock->fSize);
+ const AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData*>(pBlock->fPtr);
+ const int* v0s = data->fTrackIndices + data->fNPrimTracks;
+ for (int i = 0; i < data->fNV0s; ++i) {
+ if( freeSpace < flatV0->GetSize() ) { err = -1; break; }
+ new (flatV0) AliFlatESDV0;
+ flatV0->SetNegTrackID( v0s[2 * i] );
+ flatV0->SetPosTrackID( v0s[2 * i + 1] );
+ nV0s++;
+ v0size += flatV0->GetSize();
+ freeSpace -= flatV0->GetSize();
+ flatV0 = flatV0->GetNextV0NonConst();
+ }
+ } else {
+ HLTWarning("xxx No V0 data block");
}
- } else {
- HLTWarning("xxx No V0 data block");
+
+ flatEsd->SetV0sEnd( nV0s, v0size );
+ cout<<"\nxxxx Found "<<nV0s<<" V0's\n"<<endl;
}
- cout<<"\nxxxx Found "<<nV0s<<" V0's\n"<<endl;
- }
-
- // Get ITS SPD vertex
- for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
- fBenchmark.AddInput(i->fSize);
- }
+
+ if( err ) break;
- /*
- for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
- AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
- pESD->SetPrimaryVertexSPD( vtx );
- }
+ }while(0);
+ if( err ){
+ HLTWarning( "Output buffer size %d exceeded, flat ESD event is not stored", maxOutputSize );
+ return -ENOSPC;
+ }
- // update with vertices and vertex-fitted tracks
- // output of the GlobalVertexerComponent
- for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
- pBlock!=NULL; pBlock=GetNextInputBlock()) {
- fBenchmark.AddInput(pBlock->fSize);
- AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
- }
-
- // update with vertices and vertex-fitted tracks
- // output of PrimaryVertexer and V0Finder components
- TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
- if (pBase) {
- AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
- if (kfVertex) {
- const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut);
- if (pP && pP->fSize && pP->fPtr) {
- const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut);
- if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) {
- const int* v0s = static_cast<const int*>(pV0->fPtr);
- HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]);
- }
- AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL);
- } else
- HLTWarning("Problem with primary finder's data block");
- } else {
- HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName());
- }
- } else {
- // throw an error if there is a V0 data block which can not be handled without
- // the AliKFVertex object
- if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) {
- ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s",
- DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str());
- }
- }
- */
-
-
- // loop over all tracks and set the TPC refit flag by updating with the
- // original TPC inner parameter if not yet set
- // TODO: replace this by a proper refit
- // code is comented for the moment as it does not fully solve the problems with
- // the display
- // - would set the main parameters to the TPC inner wall again, or
- // - changes the inner param if the parameters are propagated, so we loose the track
- // reference point for the display
- // with the current sequence we have the latter case as the DCA operations above
- // change the TPC inner parameters
- /*
- for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
- if (!pESD->GetTrack(i) ||
- !pESD->GetTrack(i)->GetTPCInnerParam() ||
- pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
- AliESDtrack* tESD=pESD->GetTrack(i);
- AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
- inner.SetLabel(tESD->GetLabel());
- tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
- }
- */
-
- if (iResult>=0) {
-
+ { // set up the output block description
+
AliHLTComponentBlockData outBlock;
FillBlockData( outBlock );
outBlock.fOffset = size;
outputBlocks.push_back( outBlock );
- fBenchmark.AddOutput(outBlock.fSize);
-
+ fBenchmark.AddOutput(outBlock.fSize);
+
size += outBlock.fSize;
}
- cout<<"iResut = "<<iResult<<endl;
fBenchmark.Stop(0);
HLTWarning( fBenchmark.GetStatistics() );
-#endif
- return iResult;
+
+ return 0;
}