]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
2 | ||
b661165c | 3 | // Author: Uli Frankenfeld <mailto:franken@fi.uib.no> |
3e87ef69 | 4 | //*-- Copyright © ALICE HLT Group |
108615fc | 5 | |
4aa41877 | 6 | #include "AliHLTStandardIncludes.h" |
118c26c3 | 7 | |
4aa41877 | 8 | #include "AliHLTLogging.h" |
9 | #include "AliHLTInterMerger.h" | |
10 | #include "AliHLTTrack.h" | |
11 | #include "AliHLTTrackSegmentData.h" | |
12 | #include "AliHLTTransform.h" | |
13 | #include "AliHLTTrackArray.h" | |
108615fc | 14 | |
4aa41877 | 15 | /** \class AliHLTInterMerger |
3e87ef69 | 16 | <pre> |
108615fc | 17 | //_____________________________________________________________ |
4aa41877 | 18 | // AliHLTInterMerger |
108615fc | 19 | // |
20 | // The L3 track segment merger | |
21 | // | |
3e87ef69 | 22 | </pre> |
23 | */ | |
108615fc | 24 | |
5929c18d | 25 | #if __GNUC__ >= 3 |
26 | using namespace std; | |
27 | #endif | |
28 | ||
4aa41877 | 29 | ClassImp(AliHLTInterMerger) |
108615fc | 30 | |
4aa41877 | 31 | AliHLTInterMerger::AliHLTInterMerger() |
0a86fbb7 | 32 | { |
108615fc | 33 | //Default constructor |
0a86fbb7 | 34 | InitMerger(1); |
108615fc | 35 | Is2Global(kFALSE); |
3ea3b9f9 | 36 | // SetParameter(2,2,.3,.3,.3); |
37 | SetParameter(1,0.5,0.0005,0.05,0.1); | |
108615fc | 38 | fRowMax = fRowMin = 0; |
39 | } | |
40 | ||
41 | ||
4aa41877 | 42 | AliHLTInterMerger::~AliHLTInterMerger(){ |
108615fc | 43 | //Destructor |
44 | ||
45 | } | |
46 | ||
4aa41877 | 47 | void AliHLTInterMerger::SlowMerge(){ |
108615fc | 48 | Int_t nrow= fRowMax-fRowMin+1; |
49 | void *ntuple=GetNtuple(); | |
4aa41877 | 50 | AliHLTTrackArray * tracks = GetInTracks(0); |
108615fc | 51 | const Int_t kNIn =tracks->GetNTracks(); |
4aa41877 | 52 | AliHLTTrack *tr[2]; |
108615fc | 53 | Bool_t merge = kTRUE; |
54 | for(Int_t in=0;in<kNIn;in++) | |
55 | tracks->GetCheckedTrack(in)->CalculateHelix(); | |
56 | while(merge){ | |
57 | Int_t inmin=-1,outmin=-1; | |
58 | Double_t min=10; | |
59 | for(Int_t out=0;out<kNIn;out++){ | |
4aa41877 | 60 | AliHLTTrack *outertrack=tracks->GetCheckedTrack(out); |
108615fc | 61 | if(!outertrack) continue; |
62 | for(Int_t in=0;in<kNIn;in++){ | |
63 | if(in==out) continue; | |
4aa41877 | 64 | AliHLTTrack *innertrack=tracks->GetCheckedTrack(in); |
108615fc | 65 | if(!innertrack) continue; |
66 | if(outertrack->GetNHits()+innertrack->GetNHits()>nrow) continue; | |
67 | ||
68 | Double_t diff = TrackDiff(innertrack,outertrack); | |
69 | ||
70 | if(diff>=0&&diff<min){ | |
71 | min=diff; | |
72 | inmin=in; | |
73 | outmin=out; | |
74 | } | |
75 | } | |
76 | } | |
77 | if(inmin>=0&&outmin>=0){ | |
4aa41877 | 78 | AliHLTTrack *outertrack=tracks->GetTrack(outmin); |
79 | AliHLTTrack *innertrack=tracks->GetTrack(inmin); | |
108615fc | 80 | tr[0]=innertrack; |
81 | tr[1]=outertrack; | |
82 | SortTracks(tr,2); | |
83 | MultiMerge(tracks,tr,2); | |
84 | outertrack->CalculatePoint(tr[0]->GetLastPointX()); | |
85 | innertrack->CalculatePoint(tr[0]->GetLastPointX()); | |
86 | PrintDiff(innertrack,outertrack); | |
87 | FillNtuple(ntuple,innertrack,outertrack); | |
88 | tracks->Remove(outmin); | |
89 | tracks->Remove(inmin); | |
90 | } | |
91 | else merge = kFALSE; | |
92 | } | |
4aa41877 | 93 | LOG(AliHLTLog::kInformational,"AliHLTInterMerger::SlowMerge","Result") |
94 | <<AliHLTLog::kDec<<"Merged Tracks: "<<tracks->GetNTracks()-kNIn<<ENDLOG; | |
108615fc | 95 | |
96 | char name[256]; | |
97 | sprintf(name,"ntuple_i_%d.root",fPatch); | |
98 | WriteNtuple(name,ntuple); | |
99 | } | |
100 | ||
4aa41877 | 101 | void AliHLTInterMerger::MMerge(){ |
108615fc | 102 | while(Merge()); |
103 | GetOutTracks()->AddTracks(GetInTracks(0)); | |
104 | } | |
105 | ||
4aa41877 | 106 | Int_t AliHLTInterMerger::Merge(){ |
108615fc | 107 | Int_t nrow= fRowMax-fRowMin+1; |
4aa41877 | 108 | Double_t xval =AliHLTTransform::Row2X((fRowMax+fRowMin)/2); |
109 | AliHLTTrackArray * tracks = GetInTracks(0); | |
108615fc | 110 | const Int_t kNIn =tracks->GetNTracks(); |
4aa41877 | 111 | AliHLTTrack *tr[2]; |
108615fc | 112 | for(Int_t in=0;in<kNIn;in++){ |
4aa41877 | 113 | AliHLTTrack *t = tracks->GetCheckedTrack(in); |
108615fc | 114 | if(t){ |
115 | t->CalculateHelix(); | |
116 | t->CalculatePoint(xval); | |
117 | } | |
118 | } | |
119 | for(Int_t out=0;out<kNIn;out++){ | |
4aa41877 | 120 | AliHLTTrack *outertrack=tracks->GetCheckedTrack(out); |
108615fc | 121 | if(!outertrack) continue; |
122 | for(Int_t in=0;in<kNIn;in++){ | |
123 | if(in==out) continue; | |
4aa41877 | 124 | AliHLTTrack *innertrack=tracks->GetCheckedTrack(in); |
108615fc | 125 | if(!innertrack) continue; |
126 | if(outertrack->GetNHits()+innertrack->GetNHits()>nrow) continue; | |
127 | ||
128 | if(IsTrack(innertrack,outertrack)){ | |
129 | tr[0]=innertrack; | |
130 | tr[1]=outertrack; | |
3ea3b9f9 | 131 | SortGlobalTracks(tr,2); |
132 | ||
133 | Double_t r0 = pow(tr[0]->GetLastPointX(),2)+ | |
134 | pow(tr[0]->GetLastPointY(),2); | |
135 | Double_t r1 = pow(tr[1]->GetFirstPointX(),2)+ | |
136 | pow(tr[1]->GetFirstPointY(),2); | |
137 | if(r0<r1){ | |
108615fc | 138 | MultiMerge(tracks,tr,2); |
139 | tracks->Remove(out); | |
140 | tracks->Remove(in); | |
141 | break; | |
142 | } | |
143 | } | |
144 | } | |
145 | } | |
146 | Int_t nmerged = tracks->GetNTracks()-kNIn; | |
4aa41877 | 147 | LOG(AliHLTLog::kInformational,"AliHLTInterMerger::Merge","Result") |
148 | <<AliHLTLog::kDec<<"Merged Tracks: "<<nmerged<<ENDLOG; | |
108615fc | 149 | //add in tracks |
150 | // GetOutTracks()->AddTracks(GetInTracks(0)); | |
151 | ||
152 | return nmerged; | |
153 | } | |
154 | ||
155 |