]>
Commit | Line | Data |
---|---|---|
a6c02c85 | 1 | // @(#) $Id$ |
4aa41877 | 2 | // Original: AliHLTInterMerger.cxx,v 1.8 2005/06/14 10:55:21 cvetan |
a6c02c85 | 3 | |
2a083ac4 | 4 | /************************************************************************** |
9be2600f | 5 | * This file is property of and copyright by the ALICE HLT Project * |
6 | * ALICE Experiment at CERN, All rights reserved. * | |
2a083ac4 | 7 | * * |
9be2600f | 8 | * Primary Authors: Uli Frankenfeld, maintained by * |
9 | * Matthias Richter <Matthias.Richter@ift.uib.no> * | |
10 | * for The ALICE HLT Project. * | |
2a083ac4 | 11 | * * |
12 | * Permission to use, copy, modify and distribute this software and its * | |
13 | * documentation strictly for non-commercial purposes is hereby granted * | |
14 | * without fee, provided that the above copyright notice appears in all * | |
15 | * copies and that both the copyright notice and this permission notice * | |
16 | * appear in the supporting documentation. The authors make no claims * | |
17 | * about the suitability of this software for any purpose. It is * | |
18 | * provided "as is" without express or implied warranty. * | |
19 | **************************************************************************/ | |
20 | ||
21 | /** @file AliHLTTPCInterMerger.cxx | |
22 | @author Uli Frankenfeld, maintained by Matthias Richter | |
23 | @date | |
24 | @brief The HLT TPC track segment merger | |
25 | */ | |
a6c02c85 | 26 | |
a6c02c85 | 27 | #include "AliHLTTPCLogging.h" |
28 | #include "AliHLTTPCInterMerger.h" | |
29 | #include "AliHLTTPCTrack.h" | |
30 | #include "AliHLTTPCTrackSegmentData.h" | |
31 | #include "AliHLTTPCTransform.h" | |
32 | #include "AliHLTTPCTrackArray.h" | |
33 | ||
a6c02c85 | 34 | #if __GNUC__ >= 3 |
35 | using namespace std; | |
36 | #endif | |
37 | ||
38 | ClassImp(AliHLTTPCInterMerger) | |
39 | ||
40 | AliHLTTPCInterMerger::AliHLTTPCInterMerger() | |
41 | { | |
42 | //Default constructor | |
43 | InitMerger(1); | |
44 | Is2Global(kFALSE); | |
45 | // SetParameter(2,2,.3,.3,.3); | |
46 | SetParameter(1,0.5,0.0005,0.05,0.1); | |
47 | fRowMax = fRowMin = 0; | |
48 | } | |
49 | ||
50 | ||
51 | AliHLTTPCInterMerger::~AliHLTTPCInterMerger(){ | |
52 | //Destructor | |
53 | ||
54 | } | |
55 | ||
56 | void AliHLTTPCInterMerger::SlowMerge(){ | |
57 | Int_t nrow= fRowMax-fRowMin+1; | |
58 | void *ntuple=GetNtuple(); | |
59 | AliHLTTPCTrackArray * tracks = GetInTracks(0); | |
60 | const Int_t kNIn =tracks->GetNTracks(); | |
61 | AliHLTTPCTrack *tr[2]; | |
62 | Bool_t merge = kTRUE; | |
63 | for(Int_t in=0;in<kNIn;in++) | |
64 | tracks->GetCheckedTrack(in)->CalculateHelix(); | |
65 | while(merge){ | |
66 | Int_t inmin=-1,outmin=-1; | |
67 | Double_t min=10; | |
68 | for(Int_t out=0;out<kNIn;out++){ | |
69 | AliHLTTPCTrack *outertrack=tracks->GetCheckedTrack(out); | |
70 | if(!outertrack) continue; | |
71 | for(Int_t in=0;in<kNIn;in++){ | |
72 | if(in==out) continue; | |
73 | AliHLTTPCTrack *innertrack=tracks->GetCheckedTrack(in); | |
74 | if(!innertrack) continue; | |
75 | if(outertrack->GetNHits()+innertrack->GetNHits()>nrow) continue; | |
76 | ||
77 | Double_t diff = TrackDiff(innertrack,outertrack); | |
78 | ||
79 | if(diff>=0&&diff<min){ | |
80 | min=diff; | |
81 | inmin=in; | |
82 | outmin=out; | |
83 | } | |
84 | } | |
85 | } | |
86 | if(inmin>=0&&outmin>=0){ | |
87 | AliHLTTPCTrack *outertrack=tracks->GetTrack(outmin); | |
88 | AliHLTTPCTrack *innertrack=tracks->GetTrack(inmin); | |
89 | tr[0]=innertrack; | |
90 | tr[1]=outertrack; | |
91 | SortTracks(tr,2); | |
92 | MultiMerge(tracks,tr,2); | |
93 | outertrack->CalculatePoint(tr[0]->GetLastPointX()); | |
94 | innertrack->CalculatePoint(tr[0]->GetLastPointX()); | |
95 | PrintDiff(innertrack,outertrack); | |
96 | FillNtuple(ntuple,innertrack,outertrack); | |
97 | tracks->Remove(outmin); | |
98 | tracks->Remove(inmin); | |
99 | } | |
100 | else merge = kFALSE; | |
101 | } | |
102 | LOG(AliHLTTPCLog::kInformational,"AliHLTTPCInterMerger::SlowMerge","Result") | |
103 | <<AliHLTTPCLog::kDec<<"Merged Tracks: "<<tracks->GetNTracks()-kNIn<<ENDLOG; | |
104 | ||
105 | char name[256]; | |
106 | sprintf(name,"ntuple_i_%d.root",fPatch); | |
107 | WriteNtuple(name,ntuple); | |
108 | } | |
109 | ||
110 | void AliHLTTPCInterMerger::MMerge(){ | |
111 | while(Merge()); | |
112 | GetOutTracks()->AddTracks(GetInTracks(0)); | |
113 | } | |
114 | ||
115 | Int_t AliHLTTPCInterMerger::Merge(){ | |
116 | Int_t nrow= fRowMax-fRowMin+1; | |
117 | Double_t xval =AliHLTTPCTransform::Row2X((fRowMax+fRowMin)/2); | |
118 | AliHLTTPCTrackArray * tracks = GetInTracks(0); | |
119 | const Int_t kNIn =tracks->GetNTracks(); | |
120 | AliHLTTPCTrack *tr[2]; | |
121 | for(Int_t in=0;in<kNIn;in++){ | |
122 | AliHLTTPCTrack *t = tracks->GetCheckedTrack(in); | |
123 | if(t){ | |
124 | t->CalculateHelix(); | |
125 | t->CalculatePoint(xval); | |
126 | } | |
127 | } | |
128 | for(Int_t out=0;out<kNIn;out++){ | |
129 | AliHLTTPCTrack *outertrack=tracks->GetCheckedTrack(out); | |
130 | if(!outertrack) continue; | |
131 | for(Int_t in=0;in<kNIn;in++){ | |
132 | if(in==out) continue; | |
133 | AliHLTTPCTrack *innertrack=tracks->GetCheckedTrack(in); | |
134 | if(!innertrack) continue; | |
135 | if(outertrack->GetNHits()+innertrack->GetNHits()>nrow) continue; | |
136 | ||
137 | if(IsTrack(innertrack,outertrack)){ | |
138 | tr[0]=innertrack; | |
139 | tr[1]=outertrack; | |
140 | SortGlobalTracks(tr,2); | |
141 | ||
142 | Double_t r0 = pow(tr[0]->GetLastPointX(),2)+ | |
143 | pow(tr[0]->GetLastPointY(),2); | |
144 | Double_t r1 = pow(tr[1]->GetFirstPointX(),2)+ | |
145 | pow(tr[1]->GetFirstPointY(),2); | |
146 | if(r0<r1){ | |
147 | MultiMerge(tracks,tr,2); | |
148 | tracks->Remove(out); | |
149 | tracks->Remove(in); | |
150 | break; | |
151 | } | |
152 | } | |
153 | } | |
154 | } | |
155 | Int_t nmerged = tracks->GetNTracks()-kNIn; | |
156 | LOG(AliHLTTPCLog::kInformational,"AliHLTTPCInterMerger::Merge","Result") | |
157 | <<AliHLTTPCLog::kDec<<"Merged Tracks: "<<nmerged<<ENDLOG; | |
158 | //add in tracks | |
159 | // GetOutTracks()->AddTracks(GetInTracks(0)); | |
160 | ||
161 | return nmerged; | |
162 | } | |
163 | ||
164 |