33 std::vector<const Muon::MuonSegment*> (&disqualifiedSegments)[2][4],
34 std::vector<SegmTrack> (&matchedSegments)[2]){
36 const float dRhoCutSegmentMatching = 1000;
37 const float dPhiCutSegmentMatching =
M_PI/8;
38 const float dPhiCutSegmentDirectionChecking[4][4]={{ 0,
M_PI/8, 0.1, 0.01},
40 { 0.06,
M_PI/8, 0, 0.01},
41 { 0.05,
M_PI/8, 0.05, 0}};
42 const float dTheCutSegmentDirectionChecking[4][4]={{ 0,
M_PI/8, 0.05, 0.06},
44 { 0.04,
M_PI/8, 0, 0.005},
45 { 0.02,
M_PI/8, 0.005, 0}};
48 bool skipSegm;
int nDisqualifiedSegm;
52 for(
int jMDT1=3;jMDT1>=0;jMDT1--){
54 int nSegm1=sortedSegments[i][jMDT1].size();
57 for(
int n1=0; n1<nSegm1;n1++){
63 nDisqualifiedSegm=disqualifiedSegments[i][jMDT1].size();
64 for(
int ndis=0;ndis<nDisqualifiedSegm;ndis++)
if(segm1==disqualifiedSegments[i][jMDT1].at(ndis))skipSegm=
true;
70 float segm1PosPhi = segm1Pos.phi();
71 float segm1PosZ = segm1Pos.z();
72 if(segm1PosPhi<0)segm1PosPhi+=2*
M_PI;
76 float segm1DirThe = segm1Dir.theta();
77 float segm1DirPhi = segm1Dir.phi();
78 if(segm1DirThe>
M_PI/2) segm1DirThe=
M_PI-segm1DirThe;
79 if(segm1DirPhi<0) segm1DirPhi+=2*
M_PI;
82 bool stationMatchFound[4] = {
false,
false,
false,
false};
83 std::vector<const Muon::MuonSegment*> matchingSegments[4];
84 for(
int jMDT2=0;jMDT2<4;jMDT2++)matchingSegments[jMDT2] = std::vector<const Muon::MuonSegment*>();
85 matchingSegments[jMDT1].push_back(segm1);
88 for(
int jMDT2=3;jMDT2>=0;jMDT2--){
90 int nSegm2=sortedSegments[i][jMDT2].size();
93 for(
int n2=0; n2<nSegm2;n2++){
96 if(segm1==segm2)
continue;
100 nDisqualifiedSegm=disqualifiedSegments[i][jMDT2].size();
101 for(
int ndis=0;ndis<nDisqualifiedSegm;ndis++)
if(segm1==disqualifiedSegments[i][jMDT2].at(ndis))skipSegm=
true;
102 if(skipSegm)
continue;
109 float segm2PosRho = std::abs(segm2Pos.perp());
110 float segm2PosPhi = segm2Pos.phi();
111 float segm2PosThe = segm2Pos.theta();
112 float segm2PosZ = segm2Pos.z();
113 if(segm2PosThe>
M_PI/2) segm2PosThe=
M_PI-segm2PosThe;
114 if(segm2PosPhi<0)segm2PosPhi+=2*
M_PI;
118 float dPhi_Segm1_Segm2 = segm1PosPhi-segm2PosPhi;
119 if(dPhi_Segm1_Segm2<-
M_PI)dPhi_Segm1_Segm2+=2*
M_PI;
120 if(dPhi_Segm1_Segm2>
M_PI)dPhi_Segm1_Segm2-=2*
M_PI;
121 if(std::abs(dPhi_Segm1_Segm2)>dPhiCutSegmentMatching)
continue;
124 float dZ = std::abs(segm2PosZ)-std::abs(segm1PosZ);
127 float extrPosRho = std::abs(extrPos.perp());
128 float extrPosThe = extrPos.theta();
129 float extrPosPhi = extrPos.phi();
130 if(extrPosThe>
M_PI/2) extrPosThe=
M_PI-extrPosThe;
131 if(extrPosPhi<0)extrPosPhi+=2*
M_PI;
134 float dRho_Extr_Segm2 = extrPosRho-segm2PosRho;
135 float dPhi_Extr_Segm2 = extrPosPhi-segm2PosPhi;
136 float dThe_Extr_Segm2 = extrPosThe-segm2PosThe;
137 if(dPhi_Extr_Segm2<-
M_PI)dPhi_Extr_Segm2+=2*
M_PI;
138 if(dPhi_Extr_Segm2>
M_PI)dPhi_Extr_Segm2-=2*
M_PI;
146 if(std::abs(dPhi_Extr_Segm2)>dPhiCutSegmentMatching)
continue;
147 if(std::abs(dRho_Extr_Segm2)>dRhoCutSegmentMatching)
continue;
155 float segm2DirThe = segm2Dir.theta();
156 float segm2DirPhi = segm2Dir.phi();
157 if(segm2DirThe>
M_PI/2) segm2DirThe=
M_PI-segm2DirThe;
158 if(segm2DirPhi<0) segm2DirPhi+=2*
M_PI;
165 if(jMDT2>jMDT1)segmVector = segm2Pos-segm1Pos;
166 else segmVector = segm1Pos-segm2Pos;
167 float segmVecThe = segmVector.theta();
168 float segmVecPhi = segmVector.phi();
169 if(segmVecThe>
M_PI/2) segmVecThe=
M_PI-segmVecThe;
170 if(segmVecPhi<0) segmVecPhi+=2*
M_PI;
173 float dThe_Vec_Segm1 = segmVecThe-segm1DirThe;
174 float dPhi_Vec_Segm1 = segmVecPhi-segm1DirPhi;
175 if(dPhi_Vec_Segm1<-
M_PI)dPhi_Vec_Segm1+=2*
M_PI;
176 if(dPhi_Vec_Segm1>
M_PI)dPhi_Vec_Segm1-=2*
M_PI;
177 float dThe_Vec_Segm2 = segmVecThe-segm2DirThe;
178 float dPhi_Vec_Segm2 = segmVecPhi-segm2DirPhi;
179 if(dPhi_Vec_Segm2<-
M_PI)dPhi_Vec_Segm2+=2*
M_PI;
180 if(dPhi_Vec_Segm2>
M_PI)dPhi_Vec_Segm2-=2*
M_PI;
189 else if(jMDT1<jMDT2){
197 float dTheDir_Segm1_Segm2 = segm1DirThe-segm2DirThe;
198 float dPhiDir_Segm1_Segm2 = segm1PosPhi-segm2PosPhi;
199 if(dPhiDir_Segm1_Segm2<-
M_PI)dPhiDir_Segm1_Segm2+=2*
M_PI;
200 if(dPhiDir_Segm1_Segm2>
M_PI)dPhiDir_Segm1_Segm2-=2*
M_PI;
204 if(dPhi_Vec_Segm1>dPhiCutSegmentDirectionChecking[jMDT1][jMDT2] ||
205 dThe_Vec_Segm1>dTheCutSegmentDirectionChecking[jMDT1][jMDT2] ||
206 dPhi_Vec_Segm2>dPhiCutSegmentDirectionChecking[jMDT2][jMDT1] ||
207 dThe_Vec_Segm2>dTheCutSegmentDirectionChecking[jMDT2][jMDT1])
continue;
210 matchingSegments[jMDT2].push_back(segm2);
213 if(matchingSegments[jMDT2].
size()==1){
214 stationMatchFound[jMDT2]=
true;
223 for(
int jMDT2=0;jMDT2<4;jMDT2++){
224 if(stationMatchFound[jMDT2]){
225 segmArray[jMDT2]=matchingSegments[jMDT2].at(0);
227 disqualifiedSegments[i][jMDT2].push_back(matchingSegments[jMDT2].at(0));
231 matchedSegments[i].push_back(newTrack);