]>
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() | |
e419b223 | 41 | : |
42 | fPatch(0), | |
43 | fRowMin(0), | |
44 | fRowMax(0) | |
a6c02c85 | 45 | { |
46 | //Default constructor | |
47 | InitMerger(1); | |
48 | Is2Global(kFALSE); | |
49 | // SetParameter(2,2,.3,.3,.3); | |
50 | SetParameter(1,0.5,0.0005,0.05,0.1); | |
a6c02c85 | 51 | } |
52 | ||
53 | ||
54 | AliHLTTPCInterMerger::~AliHLTTPCInterMerger(){ | |
55 | //Destructor | |
56 | ||
57 | } | |
58 | ||
59 | void AliHLTTPCInterMerger::SlowMerge(){ | |
60 | Int_t nrow= fRowMax-fRowMin+1; | |
61 | void *ntuple=GetNtuple(); | |
62 | AliHLTTPCTrackArray * tracks = GetInTracks(0); | |
63 | const Int_t kNIn =tracks->GetNTracks(); | |
64 | AliHLTTPCTrack *tr[2]; | |
65 | Bool_t merge = kTRUE; | |
66 | for(Int_t in=0;in<kNIn;in++) | |
1c9853d3 | 67 | if (tracks->GetCheckedTrack(in)) tracks->GetCheckedTrack(in)->CalculateHelix(); |
a6c02c85 | 68 | while(merge){ |
69 | Int_t inmin=-1,outmin=-1; | |
70 | Double_t min=10; | |
71 | for(Int_t out=0;out<kNIn;out++){ | |
72 | AliHLTTPCTrack *outertrack=tracks->GetCheckedTrack(out); | |
73 | if(!outertrack) continue; | |
74 | for(Int_t in=0;in<kNIn;in++){ | |
75 | if(in==out) continue; | |
76 | AliHLTTPCTrack *innertrack=tracks->GetCheckedTrack(in); | |
77 | if(!innertrack) continue; | |
78 | if(outertrack->GetNHits()+innertrack->GetNHits()>nrow) continue; | |
79 | ||
80 | Double_t diff = TrackDiff(innertrack,outertrack); | |
81 | ||
82 | if(diff>=0&&diff<min){ | |
83 | min=diff; | |
84 | inmin=in; | |
85 | outmin=out; | |
86 | } | |
87 | } | |
88 | } | |
89 | if(inmin>=0&&outmin>=0){ | |
90 | AliHLTTPCTrack *outertrack=tracks->GetTrack(outmin); | |
91 | AliHLTTPCTrack *innertrack=tracks->GetTrack(inmin); | |
92 | tr[0]=innertrack; | |
93 | tr[1]=outertrack; | |
94 | SortTracks(tr,2); | |
95 | MultiMerge(tracks,tr,2); | |
96 | outertrack->CalculatePoint(tr[0]->GetLastPointX()); | |
97 | innertrack->CalculatePoint(tr[0]->GetLastPointX()); | |
98 | PrintDiff(innertrack,outertrack); | |
99 | FillNtuple(ntuple,innertrack,outertrack); | |
100 | tracks->Remove(outmin); | |
101 | tracks->Remove(inmin); | |
102 | } | |
103 | else merge = kFALSE; | |
104 | } | |
105 | LOG(AliHLTTPCLog::kInformational,"AliHLTTPCInterMerger::SlowMerge","Result") | |
106 | <<AliHLTTPCLog::kDec<<"Merged Tracks: "<<tracks->GetNTracks()-kNIn<<ENDLOG; | |
107 | ||
1c9853d3 | 108 | const int namelen=256; |
109 | char name[namelen]; | |
110 | snprintf(name,namelen,"ntuple_i_%d.root",fPatch); | |
a6c02c85 | 111 | WriteNtuple(name,ntuple); |
112 | } | |
113 | ||
114 | void AliHLTTPCInterMerger::MMerge(){ | |
9d5f00ad | 115 | while(Merge()) {/*empty body*/}; |
a6c02c85 | 116 | GetOutTracks()->AddTracks(GetInTracks(0)); |
117 | } | |
118 | ||
119 | Int_t AliHLTTPCInterMerger::Merge(){ | |
120 | Int_t nrow= fRowMax-fRowMin+1; | |
121 | Double_t xval =AliHLTTPCTransform::Row2X((fRowMax+fRowMin)/2); | |
122 | AliHLTTPCTrackArray * tracks = GetInTracks(0); | |
123 | const Int_t kNIn =tracks->GetNTracks(); | |
124 | AliHLTTPCTrack *tr[2]; | |
125 | for(Int_t in=0;in<kNIn;in++){ | |
126 | AliHLTTPCTrack *t = tracks->GetCheckedTrack(in); | |
127 | if(t){ | |
128 | t->CalculateHelix(); | |
129 | t->CalculatePoint(xval); | |
130 | } | |
131 | } | |
132 | for(Int_t out=0;out<kNIn;out++){ | |
133 | AliHLTTPCTrack *outertrack=tracks->GetCheckedTrack(out); | |
134 | if(!outertrack) continue; | |
135 | for(Int_t in=0;in<kNIn;in++){ | |
136 | if(in==out) continue; | |
137 | AliHLTTPCTrack *innertrack=tracks->GetCheckedTrack(in); | |
138 | if(!innertrack) continue; | |
139 | if(outertrack->GetNHits()+innertrack->GetNHits()>nrow) continue; | |
140 | ||
141 | if(IsTrack(innertrack,outertrack)){ | |
142 | tr[0]=innertrack; | |
143 | tr[1]=outertrack; | |
144 | SortGlobalTracks(tr,2); | |
145 | ||
146 | Double_t r0 = pow(tr[0]->GetLastPointX(),2)+ | |
147 | pow(tr[0]->GetLastPointY(),2); | |
148 | Double_t r1 = pow(tr[1]->GetFirstPointX(),2)+ | |
149 | pow(tr[1]->GetFirstPointY(),2); | |
150 | if(r0<r1){ | |
151 | MultiMerge(tracks,tr,2); | |
152 | tracks->Remove(out); | |
153 | tracks->Remove(in); | |
154 | break; | |
155 | } | |
156 | } | |
157 | } | |
158 | } | |
159 | Int_t nmerged = tracks->GetNTracks()-kNIn; | |
160 | LOG(AliHLTTPCLog::kInformational,"AliHLTTPCInterMerger::Merge","Result") | |
161 | <<AliHLTTPCLog::kDec<<"Merged Tracks: "<<nmerged<<ENDLOG; | |
162 | //add in tracks | |
163 | // GetOutTracks()->AddTracks(GetInTracks(0)); | |
164 | ||
165 | return nmerged; | |
166 | } | |
167 | ||
168 |