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: Jacek Otwinowski <Jacek.Otwinowski@gsi.de> *
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 AliHLTGlobalTrackMergerComponent.cxx
20 @author Jacek Otwinowski
22 @brief HLT global track merger component.
28 #include "AliHLTTPCTransform.h"
29 #include "AliHLTTPCGlobalMerger.h"
30 #include "AliHLTTPCVertex.h"
31 #include "AliHLTTPCVertexData.h"
32 #include "AliHLTTPCTrack.h"
34 //#include "AliHLTTPCSpacePointData.h"
35 //#include "AliHLTTPCClusterDataFormat.h"
36 #include "AliHLTTPCTrackletDataFormat.h"
37 #include "AliHLTTPCTrackSegmentData.h"
38 #include "AliHLTTPCTrackArray.h"
39 #include "AliHLTTPCDefinitions.h"
40 #include "AliHLTTRDDefinitions.h"
44 #include "AliESDEvent.h"
45 #include "AliTracker.h"
46 #include "AliTRDtrackV1.h"
47 #include "AliHLTGlobalTrackMerger.h"
49 #include "AliHLTGlobalTrackMergerComponent.h"
51 /** ROOT macro for the implementation of ROOT specific class methods */
52 ClassImp(AliHLTGlobalTrackMergerComponent);
54 //_____________________________________________________________________________
55 AliHLTGlobalTrackMergerComponent::AliHLTGlobalTrackMergerComponent() : AliHLTProcessor(),
56 fGlobalTrackMerger(0),
61 //_____________________________________________________________________________
62 AliHLTGlobalTrackMergerComponent::~AliHLTGlobalTrackMergerComponent()
64 // see header file for class documentation
67 //_____________________________________________________________________________
68 const char* AliHLTGlobalTrackMergerComponent::GetComponentID()
70 // see header file for class documentation
71 return "GlobalTrackMerger";
74 //_____________________________________________________________________________
75 void AliHLTGlobalTrackMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
77 // see header file for class documentation
79 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
80 list.push_back( AliHLTTRDDefinitions::fgkTRDSATracksDataType );
83 //_____________________________________________________________________________
84 AliHLTComponentDataType AliHLTGlobalTrackMergerComponent::GetOutputDataType()
86 // see header file for class documentation
87 return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC;
90 //_____________________________________________________________________________
91 void AliHLTGlobalTrackMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
93 // see header file for class documentation
94 // XXX TODO: Find more realistic values.
96 inputMultiplier = 1.0;
99 //_____________________________________________________________________________
100 AliHLTComponent* AliHLTGlobalTrackMergerComponent::Spawn()
102 // see header file for class documentation
103 return new AliHLTGlobalTrackMergerComponent;
106 //_____________________________________________________________________________
107 void AliHLTGlobalTrackMergerComponent::SetMergerParameters(Double_t maxy,Double_t maxz,Double_t maxkappa,Double_t maxpsi,Double_t maxtgl)
109 // see header file for class documentation
110 fGlobalTrackMerger->SetParameter( maxy, maxz, maxkappa, maxpsi, maxtgl );
113 //_____________________________________________________________________________
114 int AliHLTGlobalTrackMergerComponent::DoInit( int /*argc*/, const char** /*argv*/ )
116 // see header file for class documentation
120 fGlobalTrackMerger = new AliHLTGlobalTrackMerger();
122 // output of the component
123 fESD = new AliESDEvent();
125 fESD->CreateStdContent();
128 if (!fGlobalTrackMerger || !fESD ) {
129 HLTError("failed creating internal objects");
134 SetMergerParameters();
139 //_____________________________________________________________________________
140 int AliHLTGlobalTrackMergerComponent::DoDeinit()
142 // see header file for class documentation
143 if(fGlobalTrackMerger) delete fGlobalTrackMerger; fGlobalTrackMerger =0;
144 if(fESD) delete fESD; fESD = 0;
148 //_____________________________________________________________________________
149 int AliHLTGlobalTrackMergerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
150 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/,
151 AliHLTUInt32_t& /*size*/, AliHLTComponentBlockDataList& /*outputBlocks*/ )
154 // global track merger function
155 // takes TRD and TPC tracks and merges them
157 HLTInfo("DoEvent processing data");
159 // see header file for class documentation
162 if(!fGlobalTrackMerger || !fESD) {
163 HLTError("component not initialized");
169 HLTError("no blocks");
174 const AliHLTComponentBlockData* iter=0;
175 AliHLTTPCTrackletData* inPtr=0;
176 Bool_t bIsTRDTrackDataBlock=kFALSE;
177 Bool_t bIsTPCTrackDataBlock=kFALSE;
178 TClonesArray *aTRDTracks=0;
179 Int_t minSlice = INT_MAX, maxSlice = 0;
183 for ( ndx = 0; ndx < evtData.fBlockCnt && iResult>=0; ndx++ )
186 bIsTRDTrackDataBlock=kFALSE;
187 bIsTPCTrackDataBlock=kFALSE;
189 // check if TPC or TRD tracks
190 if(!(bIsTRDTrackDataBlock=(iter->fDataType==AliHLTTRDDefinitions::fgkTRDSATracksDataType)) &&
191 !(bIsTPCTrackDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkTracksDataType))) {
195 // collect TRD tracks from all SM
196 // one TClonesArray of tracks per SM
197 if(bIsTRDTrackDataBlock)
199 for (TObject *pObj = (TObject *)GetFirstInputObject(AliHLTTRDDefinitions::fgkTRDSATracksDataType,"TClonesArray",0);
200 pObj !=0 && iResult>=0;
201 pObj = (TObject *)GetNextInputObject(0)) {
202 aTRDTracks = dynamic_cast<TClonesArray*>(pObj);
203 if (!aTRDTracks) continue;
205 HLTDebug("reading block %d, trdTracks %d", ndx, aTRDTracks->GetEntriesFast());
207 // load TRD tracks by global track merger
208 if (fGlobalTrackMerger->LoadTracks(aTRDTracks,fESD) == kFALSE) {
209 HLTError("Cannot load TRD tracks");
214 aTRDTracks->Delete();
217 // collect TPC tracks from whole TPC
218 if (bIsTPCTrackDataBlock)
220 slice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
221 if(slice<minSlice) minSlice = slice;
222 if(slice>maxSlice) maxSlice = slice;
224 //minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
225 //maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification);
227 AliHLTTPCTrackArray tracks;
228 inPtr=(AliHLTTPCTrackletData*)iter->fPtr;
230 HLTDebug("reading block %d (slice %d): %d tracklets", ndx, slice, inPtr->fTrackletCnt);
232 // read TPC track segments from memory
233 if((iResult=tracks.FillTracksChecked(inPtr->fTracklets, inPtr->fTrackletCnt, iter->fSize, -1/*global track*/, 0/*don't rotate*/))>=0) {
235 // load TPC tracks by global track merger
236 if (fGlobalTrackMerger->LoadTracks(&tracks,fESD) == kFALSE) {
237 HLTError("Cannot load TPC tracks");
245 // set magnetic field
246 fESD->SetMagneticField(AliTracker::GetBz());
249 Bool_t isMerged = fGlobalTrackMerger->Merge(fESD);
251 HLTWarning("No merged tracks");
254 // try to propagate all tracks to DCA to primary vertex
255 fGlobalTrackMerger->PropagateTracksToDCA(fESD);
257 // calculate specification
258 // AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 );
259 // HLTInfo("minSlice %d, maxSlice %d", minSlice, maxSlice);
262 //PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification);
263 PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC);