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