3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3StandardIncludes.h"
8 #include "AliL3Logging.h"
9 #include "AliL3HoughIntMerger.h"
10 #include "AliL3HoughTrack.h"
11 #include "AliL3TrackSegmentData.h"
12 #include "AliL3Transform.h"
13 #include "AliL3TrackArray.h"
19 //_____________________________________________________________
21 // Merging of multiple reconstructed tracks
23 ClassImp(AliL3HoughIntMerger)
25 AliL3HoughIntMerger::AliL3HoughIntMerger()
28 InitMerger(1,"AliL3HoughTrack");
29 fRowMax = fRowMin = 0;
30 SetParameters(0.001,0.05,10);
35 AliL3HoughIntMerger::~AliL3HoughIntMerger()
41 void AliL3HoughIntMerger::SetParameters(Double_t maxkappa, Double_t maxphi0, Double_t maxtgl)
49 void AliL3HoughIntMerger::FillTracks(AliL3TrackArray *tracks)
51 //Fills tracks into merger
52 if(tracks->GetNTracks()==0)
53 LOG(AliL3Log::kWarning,"AliL3HoughIntMerger::FillTracks","Track Array")
54 <<"Adding empty track array"<<ENDLOG;
56 GetInTracks(0)->AddTracks(tracks,kFALSE);//Copy tracks
57 printf("Filling %d tracks to intermerger\n",tracks->GetNTracks());
60 Bool_t AliL3HoughIntMerger::IsTrack(AliL3Track *innertrack,AliL3Track *outertrack)
62 //Check if the tracks can be merged, called by the track merger
64 AliL3HoughTrack *tr1 = (AliL3HoughTrack*)innertrack;
65 AliL3HoughTrack *tr2 = (AliL3HoughTrack*)outertrack;
67 if(abs(tr1->GetEtaIndex() - tr2->GetEtaIndex()) > 1) return kFALSE;
68 if(tr1->GetCharge()!=tr2->GetCharge()) return kFALSE;
69 if(fabs(tr1->GetKappa()-tr2->GetKappa()) >fMaxKappa) return kFALSE;
70 if(fabs(tr1->GetPhi0()-tr2->GetPhi0()) > fMaxPhi0) return kFALSE;
72 return kTRUE;//Tracks could be merged
75 AliL3Track *AliL3HoughIntMerger::MultiMerge(AliL3TrackArray *mergedtrack,AliL3Track **tracks, Int_t /*ntrack*/)
77 //Called by the track merger
79 AliL3HoughTrack *newtrack = (AliL3HoughTrack*)mergedtrack->NextTrack();
80 AliL3HoughTrack **trs = (AliL3HoughTrack**)tracks;
82 AliL3HoughTrack *tpt=trs[0];//this is the "best" track
83 //AliL3HoughTrack *tpl=trs[ntrack-1];
85 return (AliL3Track*)newtrack;
90 void AliL3HoughIntMerger::MMerge()
93 GetInTracks(0)->QSort();
95 GetOutTracks()->AddTracks(GetInTracks(0));
98 Int_t AliL3HoughIntMerger::Merge()
101 AliL3TrackArray * tracks = GetInTracks(0);
102 const Int_t kNIn =tracks->GetNTracks();
105 for(Int_t out=0;out<kNIn;out++)
107 AliL3HoughTrack *outertrack=(AliL3HoughTrack*)tracks->GetCheckedTrack(out);
108 if(!outertrack) continue;
109 for(Int_t in=0;in<kNIn;in++)
111 if(in==out) continue;
112 AliL3HoughTrack *innertrack=(AliL3HoughTrack*)tracks->GetCheckedTrack(in);
113 if(!innertrack) continue;
114 if(IsTrack(innertrack,outertrack))
120 MultiMerge(tracks,tr,2);
127 Int_t nmerged = tracks->GetNTracks()-kNIn;
128 LOG(AliL3Log::kInformational,"AliL3HoughIntMerger::Merge","Result")
129 <<AliL3Log::kDec<<"Merged Tracks: "<<nmerged<<ENDLOG;
132 //GetOutTracks()->AddTracks(GetInTracks(0));
137 void AliL3HoughIntMerger::Print(AliL3Track **tracks)
139 //Prints merger results
140 AliL3HoughTrack *tr1 = (AliL3HoughTrack*)tracks[0];
141 AliL3HoughTrack *tr2 = (AliL3HoughTrack*)tracks[1];
142 Double_t kappadiff = fabs(tr1->GetKappa()-tr2->GetKappa());
143 Double_t phi0diff = fabs(tr1->GetPhi0()-tr2->GetPhi0());
144 cout << "---------Difference in intermerged tracks---------"<<endl;
145 cout << "Kappa: "<<kappadiff<<" Phi0 : "<<phi0diff<<endl;
149 void AliL3HoughIntMerger::SortTracks(AliL3Track **trs, Int_t ntrack) const
151 //Sort the tracks according to their weight
153 AliL3HoughTrack **tracks = (AliL3HoughTrack**)trs;
154 AliL3HoughTrack **tmp = new AliL3HoughTrack*[ntrack];
155 for(Int_t i=0;i<ntrack;i++) tmp[i] = (AliL3HoughTrack*)tracks[i];
156 Int_t *t = new Int_t[ntrack];
157 for(Int_t i=0;i<ntrack;i++) t[i]=-1;
159 for(Int_t j=0;j<ntrack;j++)
163 for(Int_t i=0;i<ntrack;i++)
165 if(!tracks[i]) continue;
166 if(tracks[i]->GetWeight() > maxw)
168 maxw=tracks[i]->GetWeight();
175 for(Int_t i=0;i<ntrack;i++) tracks[i] = tmp[t[i]];