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 #include "AliSysInfo.h"
68 /** ROOT macro for the implementation of ROOT specific class methods */
69 ClassImp(AliHLTGlobalFlatEsdConverterComponent)
71 AliHLTGlobalFlatEsdConverterComponent::AliHLTGlobalFlatEsdConverterComponent()
75 , fSolenoidBz(-5.00668)
76 , fBenchmark("FlatEsdConverter")
78 // see header file for class documentation
80 // refer to README to build package
82 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
86 AliHLTGlobalFlatEsdConverterComponent::~AliHLTGlobalFlatEsdConverterComponent()
88 // see header file for class documentation
91 int AliHLTGlobalFlatEsdConverterComponent::Configure(const char* arguments)
93 // see header file for class documentation
95 if (!arguments) return iResult;
97 TString allArgs=arguments;
101 TObjArray* pTokens=allArgs.Tokenize(" ");
103 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
104 argument=((TObjString*)pTokens->At(i))->String();
105 if (argument.IsNull()) continue;
106 HLTError("unknown argument %s", argument.Data());
113 HLTError("missing parameter for argument %s", argument.Data());
120 int AliHLTGlobalFlatEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
122 // see header file for class documentation
124 const char* path=NULL;
125 const char* defaultNotify="";
128 defaultNotify=" (default)";
131 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
132 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
134 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
136 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
137 iResult=Configure(pString->String().Data());
139 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
142 HLTError("can not fetch object \"%s\" from CDB", path);
149 void AliHLTGlobalFlatEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
151 // see header file for class documentation
152 list.push_back(kAliHLTDataTypeTrack);
153 list.push_back(kAliHLTDataTypeTrackMC);
154 list.push_back(kAliHLTDataTypeCaloCluster);
155 list.push_back(kAliHLTDataTypedEdx );
156 list.push_back(kAliHLTDataTypeESDVertex );
157 list.push_back(kAliHLTDataTypeESDObject);
158 list.push_back(kAliHLTDataTypeTObject);
159 list.push_back(kAliHLTDataTypeGlobalVertexer);
160 list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s
161 list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
162 list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
163 list.push_back(kAliHLTDataTypeESDContent);
164 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
165 list.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
168 AliHLTComponentDataType AliHLTGlobalFlatEsdConverterComponent::GetOutputDataType()
170 // see header file for class documentation
171 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
174 void AliHLTGlobalFlatEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
176 // see header file for class documentation
178 inputMultiplier=10.0;
181 int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
183 // see header file for class documentation
188 // default list of skiped ESD objects
199 // "AliMultiplicity,"
202 // "SPDPileupVertices,"
203 // "TrkPileupVertices,"
206 "AliRawDataErrorLogs,"
209 iResult=Reconfigure(NULL, NULL);
210 TString allArgs = "";
211 for ( int i = 0; i < argc; i++ ) {
212 if ( !allArgs.IsNull() ) allArgs += " ";
216 TObjArray* pTokens=allArgs.Tokenize(" ");
218 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
219 argument=((TObjString*)pTokens->At(i))->String();
220 if (argument.IsNull()) continue;
223 if (argument.CompareTo("-noclusters")==0) {
226 } else if (argument.CompareTo("-clusters")==0) {
228 } else if (argument.Contains("-skipobject=")) {
229 argument.ReplaceAll("-skipobject=", "");
230 skipObjects=argument;
232 HLTError("unknown argument %s", argument.Data());
239 HLTError("missing parameter for argument %s", argument.Data());
249 fBenchmark.SetTimer(0,"total");
254 int AliHLTGlobalFlatEsdConverterComponent::DoDeinit()
256 // see header file for class documentation
261 int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
262 const AliHLTComponentBlockData* /*blocks*/,
263 AliHLTComponentTriggerData& /*trigData*/,
264 AliHLTUInt8_t* outputPtr,
265 AliHLTUInt32_t& size,
266 AliHLTComponentBlockDataList& outputBlocks)
269 // see header file for class documentation
272 AliSysInfo::AddStamp("DoEvent.Start");
276 bool benchmark = true;
278 if (!IsDataEvent()) return iResult;
280 fBenchmark.StartNewEvent();
285 size_t maxOutputSize = size;
288 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
289 new (flatEsd) AliFlatESDEvent; //standard ctor to initialize an empty event
293 pESD->SetMagneticField(fSolenoidBz);
294 pESD->SetRunNumber(GetRunNo());
295 pESD->SetPeriodNumber(GetPeriodNumber());
296 pESD->SetOrbitNumber(GetOrbitNumber());
297 pESD->SetBunchCrossNumber(GetBunchCrossNumber());
298 pESD->SetTimeStamp(GetTimeStamp());
300 const AliHLTCTPData* pCTPData=CTPData();
302 AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData);
303 for (int index=0; index<gkNCTPTriggerClasses; index++) {
304 if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue;
305 pESD->SetTriggerClass(pCTPData->Name(index), index);
307 pESD->SetTriggerMask(mask);
312 // tracks are based on the TPC tracks, and only updated from the ITS information
314 // 1) extract MC information for TPC and ITS from specific data blocks and store in
315 // intermediate vector arrays
316 // 2) extract TPC tracks, update with MC labels if available, the track parameters
317 // are estimated at the first cluster position
318 // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
319 // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
320 // 2.3) update kTPCrefit using the same parameters at the first cluster position
321 // HLT has strictly spoking no refit, but we want the flag to be set
322 // can be changed to be done after all the individual barrel detector parameters
323 // have been updated by looping over the tracks again
324 // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
325 // tracking information
326 // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
327 // 3.2) update with kITSin
328 // TODO 2010-07-12 find out if the kITSrefit has to be set as well
329 // 4) extract TRD tracks and add to ESD
330 // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
331 // 5) Add Trigger Detectors
334 // 1) first read MC information (if present)
336 std::map<int,int> mcLabelsTPC;
337 std::map<int,int> mcLabelsITS;
339 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
340 pBlock!=NULL; pBlock=GetNextInputBlock()) {
341 fBenchmark.AddInput(pBlock->fSize);
342 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
343 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
344 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
345 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
346 mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
349 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
350 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
351 dataPtr->fCount, pBlock->fSize);
355 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
356 pBlock!=NULL; pBlock=GetNextInputBlock()) {
357 fBenchmark.AddInput(pBlock->fSize);
358 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
359 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
360 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
361 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
362 mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
365 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
366 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
367 dataPtr->fCount, pBlock->fSize);
371 // 2) read dEdx information (if present)
373 AliHLTFloat32_t *dEdxTPC = 0;
375 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
376 pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
377 fBenchmark.AddInput(pBlock->fSize);
378 dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
379 ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
382 // 3) read TPC tracks
384 vector<AliHLTGlobalBarrelTrack> tracksTPC;
386 { // there is only one block of TPC data expected
387 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
389 fBenchmark.AddInput(pBlock->fSize);
390 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksTPC);
393 HLTWarning("converted %d track(s) to AliESDtrack and added to ESD", tracksTPC.size());
394 } else if (iResult<0) {
395 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
396 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
400 // 4) read ITS refitted tracks
402 vector<AliHLTGlobalBarrelTrack> tracksITS;
403 vector<AliHLTGlobalBarrelTrack> tracksITSOut;
405 if( iResult>=0 ) { // there is only one block of ITS tracks expected
406 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
408 fBenchmark.AddInput(pBlock->fSize);
409 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
413 if( iResult>=0 ) { // there is only one block of ITS tracks expected
414 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
416 fBenchmark.AddInput(pBlock->fSize);
417 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
423 const UInt_t kNSlices = 36;
424 const UInt_t kNPatches = 6;
426 const AliHLTTPCClusterData *clustersTPC[kNSlices][kNPatches];
427 const AliHLTTPCClusterMCLabel *clustersTPCMC[kNSlices][kNPatches];
428 for( UInt_t i=0; i<kNSlices; i++){
429 for( UInt_t j=0; j<kNPatches; j++){
430 clustersTPC[i][j] = 0;
431 clustersTPCMC[i][j] =0;
437 if( fWriteClusters ){
439 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
440 pBlock!=NULL; pBlock=GetNextInputBlock()) {
441 fBenchmark.AddInput(pBlock->fSize);
442 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
443 UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
444 if( slice >= kNSlices || patch>= kNPatches ){
445 HLTWarning("Wrong slice / patch number of cluster block");
448 clustersTPC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterData*> ( pBlock->fPtr );
451 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
452 pBlock!=NULL; pBlock=GetNextInputBlock()) {
453 fBenchmark.AddInput(pBlock->fSize);
454 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
455 UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
456 if( slice >= kNSlices || patch>= kNPatches ){
457 HLTWarning("Wrong slice / patch number of cluster MC block");
460 clustersTPCMC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterMCLabel*> ( pBlock->fPtr );
465 // Fill vertex information to the flat ESD
467 const AliESDVertex *primaryVertex = 0;
469 const AliESDVertex *primaryVertexSPD = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ) );
470 const AliESDVertex *primaryVertexTracks = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut ) );
472 // cout<<endl<<" Primary vertex Tracks: "<<primaryVertexTracks<<", SPD: "<< primaryVertexSPD <<endl<<endl;
474 flatEsd->FillPrimaryVertices( primaryVertexSPD, primaryVertexTracks );
476 primaryVertex = primaryVertexTracks;
477 if( !primaryVertex ) primaryVertex = primaryVertexSPD;
480 // Fill the track information to the flat ESD structure
483 UInt_t itsOutIter = 0;
484 for( UInt_t tpcIter=0; tpcIter < tracksTPC.size(); tpcIter++) {
486 const AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
488 Float_t points[4] = {
489 static_cast<Float_t>(tpcTrack->GetX()),
490 static_cast<Float_t>(tpcTrack->GetY()),
491 static_cast<Float_t>(tpcTrack->GetLastPointX()),
492 static_cast<Float_t>(tpcTrack->GetLastPointY())
496 if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() )
497 tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
499 //tpcTrack->SetLabel( tpcLabel );
500 // iotrack.SetID( tpcTrack->TrackID() );
502 // set kTPCout - just propagate to the outermost TPC cluster
504 AliHLTGlobalBarrelTrack outPar(*tpcTrack);
506 //outPar.AliExternalTrackParam::PropagateTo( tpcTrack->GetLastPointX(), fSolenoidBz );
507 const Int_t N=10; // number of steps.
508 const Float_t xRange = tpcTrack->GetLastPointX() - tpcTrack->GetX();
509 const Float_t xStep = xRange / N ;
510 for(int i = 1; i <= N; ++i) {
511 if(!outPar.AliExternalTrackParam::PropagateTo(tpcTrack->GetX() + xStep * i, fSolenoidBz)) break;
515 //iotrack.SetTPCPoints(points);
517 if( tpcTrack->TrackID()<ndEdxTPC ){
518 AliHLTFloat32_t *val = &(dEdxTPC[3*tpcTrack->TrackID()]);
519 iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] );
521 //s.Set( tpcTrack->GetX(), tpcTrack->GetAlpha(),
522 //tpcTrack->GetParameter(), tpcTrack->GetCovariance() );
523 //s.SetdEdx( val[0] );
525 //iotrack.SetTPCpid(s.TPCrPIDs() );
527 if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
530 //iotrack.SetLabel(mcLabel);
534 AliHLTGlobalBarrelTrack *itsRefit=0;
537 for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
539 if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
540 itsRefit = &(tracksITS[itsIter]);
541 if( mcLabelsITS.find(tpcIter)!=mcLabelsITS.end() ) itsLabel = mcLabelsITS[tpcIter];
547 AliHLTGlobalBarrelTrack *itsOut=0;
549 for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
551 if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
552 itsOut = &(tracksITSOut[itsOutIter]);
556 // Fill DCA parameters for TPC tracks
560 cP.UpdateTrackParams( (itsRefit ?itsRefit :tpcTrack), AliESDtrack::kTPCin );
561 cP.RelateToVertex( primaryVertex, fSolenoidBz, 1000 );
564 AliFlatESDTrack *flatTrack = flatEsd->GetNextTrackPointer();
565 new(flatTrack) AliFlatESDTrack;
566 //cout<<"flatTrack: "<<flatTrack<<endl;
568 //cout<<"GetNumberOfTPCClusters before: "<<flatTrack->GetNumberOfTPCClusters()<<endl;
570 UInt_t nClustersTPC = tpcTrack->GetNumberOfPoints();
571 UInt_t nClustersITS = itsRefit ?itsRefit->GetNumberOfPoints() :0;
573 flatTrack->SetNumberOfITSClusters( nClustersITS );
574 //flatTrack->SetNumberOfTPCClusters(0);
576 //cout<<"GetNumberOfTPCClusters: "<<flatTrack->GetNumberOfTPCClusters()<<endl;
578 if( flatEsd->GetSize() + flatTrack->EstimateSize( kTRUE, nClustersTPC ) >= maxOutputSize ){
579 cout<<endl<<endl<<"NOT ENOUGH MEMORY!!!!"<<endl<<endl;
584 flatTrack->FillExternalTrackParam( itsRefit, NULL, tpcTrack, &outPar, cP.GetConstrainedParam(), itsOut);
586 if( fWriteClusters && tpcTrack->GetPoints() ){
587 const UInt_t* clusterIDs = tpcTrack->GetPoints();
588 for( UInt_t i=0; i<nClustersTPC; i++ ){
589 UInt_t id = clusterIDs[i];
590 UInt_t iSlice = AliHLTTPCSpacePointData::GetSlice(id);
591 UInt_t iPatch = AliHLTTPCSpacePointData::GetPatch(id);
592 UInt_t iCluster = AliHLTTPCSpacePointData::GetNumber(id);
593 if( iSlice >= kNSlices || iPatch>= kNPatches ){
594 HLTWarning("Wrong slice / patch number of TPC cluster");
597 const AliHLTTPCClusterData *clusterBlock = clustersTPC[iSlice][iPatch];
599 HLTWarning("no cluster block found for slice %d, patch %d",iSlice,iPatch);
602 if( iCluster>= clusterBlock->fSpacePointCnt ){
603 HLTWarning("no cluster block found for slice %d, patch %d, cluster %d",iSlice,iPatch,iCluster);
606 const AliHLTTPCSpacePointData &cIn = clusterBlock->fSpacePoints[iCluster];
608 AliFlatTPCCluster *c= flatTrack->GetTPCCluster( flatTrack->GetNumberOfTPCClusters() );;
609 new (c) AliFlatTPCCluster;
613 c->SetPadRow(cIn.GetPadRow() + AliHLTTPCTransform::GetFirstRow(iPatch));
614 c->SetSigmaY2(cIn.GetSigmaY2());
615 c->SetSigmaZ2(cIn.GetSigmaZ2());
616 c->SetCharge(cIn.GetCharge());
617 c->SetQMax(cIn.GetQMax());
618 flatTrack->StoreLastTPCCluster();
622 // cout<<"number of tpc clusters: "<<flatTrack->GetNumberOfTPCClusters()<<endl;
623 //cout<<"number of its clusters: "<<flatTrack->GetNumberOfITSClusters()<<endl;
625 flatEsd->StoreLastTrack();
627 if (fVerbosity>0) tpcTrack->Print();
635 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
636 if (pP && pP->fSize && pP->fPtr) {
637 fBenchmark.AddInput(pP->fSize);
638 const AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData*>(pP->fPtr);
639 const int* v0s = data->fTrackIndices + data->fNPrimTracks;
641 for (int i = 0; i < nV0s; ++i) {
642 AliFlatESDV0 *v0 = flatEsd->GetNextV0Pointer();
643 v0->fNegTrackID = v0s[2 * i];
644 v0->fPosTrackID = v0s[2 * i + 1];
645 flatEsd->StoreLastV0();
648 HLTWarning(" No V0 data block");
652 // Get ITS SPD vertex
653 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
654 fBenchmark.AddInput(i->fSize);
657 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut); i!=NULL; i=GetNextInputBlock() ){
658 fBenchmark.AddInput(i->fSize);
664 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
665 AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
666 pESD->SetPrimaryVertexSPD( vtx );
670 // update with vertices and vertex-fitted tracks
671 // output of the GlobalVertexerComponent
672 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
673 pBlock!=NULL; pBlock=GetNextInputBlock()) {
674 fBenchmark.AddInput(pBlock->fSize);
675 AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
678 // update with vertices and vertex-fitted tracks
679 // output of PrimaryVertexer and V0Finder components
680 TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
682 AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
684 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut);
685 if (pP && pP->fSize && pP->fPtr) {
686 const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut);
687 if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) {
688 const int* v0s = static_cast<const int*>(pV0->fPtr);
689 HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]);
691 AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL);
693 HLTWarning("Problem with primary finder's data block");
695 HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName());
698 // throw an error if there is a V0 data block which can not be handled without
699 // the AliKFVertex object
700 if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) {
701 ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s",
702 DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str());
708 // loop over all tracks and set the TPC refit flag by updating with the
709 // original TPC inner parameter if not yet set
710 // TODO: replace this by a proper refit
711 // code is comented for the moment as it does not fully solve the problems with
713 // - would set the main parameters to the TPC inner wall again, or
714 // - changes the inner param if the parameters are propagated, so we loose the track
715 // reference point for the display
716 // with the current sequence we have the latter case as the DCA operations above
717 // change the TPC inner parameters
719 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
720 if (!pESD->GetTrack(i) ||
721 !pESD->GetTrack(i)->GetTPCInnerParam() ||
722 pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
723 AliESDtrack* tESD=pESD->GetTrack(i);
724 AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
725 inner.SetLabel(tESD->GetLabel());
726 tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
732 AliHLTComponentBlockData outBlock;
733 FillBlockData( outBlock );
734 outBlock.fOffset = size;
735 outBlock.fSize = flatEsd->GetSize();
736 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
737 outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
739 outputBlocks.push_back( outBlock );
741 fBenchmark.AddOutput(outBlock.fSize);
743 size += outBlock.fSize;
747 HLTWarning( fBenchmark.GetStatistics() );
753 Double_t statistics[10];
755 fBenchmark.GetStatisticsData(statistics, names);
756 // statistics[5] = tracksTPC.size();
757 // statistics[7] = nV0s;
759 // FillBenchmarkHistos( statistics, names);
762 AliSysInfo::AddStamp("DoEvent.Stop", (int)(statistics[1]), (int)(statistics[2]) );