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 Int_t nTRDDataBlocks = 0;
184 Int_t nTPCDataBlocks = 0;
185 for ( ndx = 0; ndx < evtData.fBlockCnt && iResult>=0; ndx++ )
188 bIsTRDTrackDataBlock=kFALSE;
189 bIsTPCTrackDataBlock=kFALSE;
191 // check if TPC or TRD tracks
192 if(!(bIsTRDTrackDataBlock=(iter->fDataType==AliHLTTRDDefinitions::fgkTRDSATracksDataType)) &&
193 !(bIsTPCTrackDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkTracksDataType))) {
197 // collect TRD tracks from all SM
198 // one TClonesArray of tracks per SM
199 if(bIsTRDTrackDataBlock)
202 if(nTRDDataBlocks>1) continue;
203 for (TObject *pObj = (TObject *)GetFirstInputObject(AliHLTTRDDefinitions::fgkTRDSATracksDataType,"TClonesArray",0);
204 pObj !=0 && iResult>=0;
205 pObj = (TObject *)GetNextInputObject(0)) {
206 aTRDTracks = dynamic_cast<TClonesArray*>(pObj);
207 if (!aTRDTracks) continue;
209 HLTInfo("reading block %d, trdTracks %d", ndx, aTRDTracks->GetEntriesFast());
212 if (fGlobalTrackMerger->LoadTracks(aTRDTracks,fESD) == kFALSE) {
213 HLTError("Cannot load TRD tracks");
218 aTRDTracks->Delete();
221 // collect TPC tracks from whole TPC
222 if (bIsTPCTrackDataBlock)
225 if(nTPCDataBlocks>1) continue;
227 slice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
228 if(slice<minSlice) minSlice = slice;
229 if(slice>maxSlice) maxSlice = slice;
231 //minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
232 //maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification);
234 AliHLTTPCTrackArray tracks;
235 inPtr=(AliHLTTPCTrackletData*)iter->fPtr;
237 HLTInfo("reading block %d (slice %d): %d tracklets", ndx, slice, inPtr->fTrackletCnt);
239 // read TPC track segments from memory
240 if((iResult=tracks.FillTracksChecked(inPtr->fTracklets, inPtr->fTrackletCnt, iter->fSize, -1/*global track*/, 0/*don't rotate*/))>=0)
243 if (fGlobalTrackMerger->LoadTracks(&tracks,fESD) == kFALSE) {
244 HLTError("Cannot load TPC tracks");
252 // set magnetic field
253 fESD->SetMagneticField(AliTracker::GetBz());
256 Bool_t isMerged = fGlobalTrackMerger->Merge(fESD);
258 HLTInfo("No merged tracks");
261 // try to propagate all tracks to DCA to primary vertex
262 fGlobalTrackMerger->PropagateTracksToDCA(fESD);
264 // calculate specification
265 // AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 );
266 // HLTInfo("minSlice %d, maxSlice %d", minSlice, maxSlice);
269 //PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification);
270 PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC);
272 // clean ESD event content