14 #include "../MdtVsTgcRawDataValAlg.h"
34 std::vector<const Muon::MuonSegment*> (&disqualifiedSegments)[2][4],
35 std::vector<SegmTrack> (&matchedSegments)[2]){
37 const float dRhoCutSegmentMatching = 1000;
38 const float dPhiCutSegmentMatching =
M_PI/8;
39 const float dPhiCutSegmentDirectionChecking[4][4]={{ 0,
M_PI/8, 0.1, 0.01},
41 { 0.06,
M_PI/8, 0, 0.01},
42 { 0.05,
M_PI/8, 0.05, 0}};
43 const float dTheCutSegmentDirectionChecking[4][4]={{ 0,
M_PI/8, 0.05, 0.06},
45 { 0.04,
M_PI/8, 0, 0.005},
46 { 0.02,
M_PI/8, 0.005, 0}};
49 bool skipSegm;
int nDisqualifiedSegm;
53 for(
int jMDT1=3;jMDT1>=0;jMDT1--){
55 int nSegm1=sortedSegments[
i][jMDT1].size();
58 for(
int n1=0;
n1<nSegm1;
n1++){
64 nDisqualifiedSegm=disqualifiedSegments[
i][jMDT1].size();
65 for(
int ndis=0;ndis<nDisqualifiedSegm;ndis++)
if(segm1==disqualifiedSegments[
i][jMDT1].at(ndis))skipSegm=
true;
71 float segm1PosPhi = segm1Pos.phi();
72 float segm1PosZ = segm1Pos.z();
73 if(segm1PosPhi<0)segm1PosPhi+=2*
M_PI;
77 float segm1DirThe = segm1Dir.theta();
78 float segm1DirPhi = segm1Dir.phi();
79 if(segm1DirThe>
M_PI/2) segm1DirThe=
M_PI-segm1DirThe;
80 if(segm1DirPhi<0) segm1DirPhi+=2*
M_PI;
83 bool stationMatchFound[4] = {
false,
false,
false,
false};
84 std::vector<const Muon::MuonSegment*> matchingSegments[4];
85 for(
int jMDT2=0;jMDT2<4;jMDT2++)matchingSegments[jMDT2] = std::vector<const Muon::MuonSegment*>();
86 matchingSegments[jMDT1].push_back(segm1);
89 for(
int jMDT2=3;jMDT2>=0;jMDT2--){
91 int nSegm2=sortedSegments[
i][jMDT2].size();
94 for(
int n2=0; n2<nSegm2;n2++){
97 if(segm1==segm2)
continue;
101 nDisqualifiedSegm=disqualifiedSegments[
i][jMDT2].size();
102 for(
int ndis=0;ndis<nDisqualifiedSegm;ndis++)
if(segm1==disqualifiedSegments[
i][jMDT2].at(ndis))skipSegm=
true;
103 if(skipSegm)
continue;
110 float segm2PosRho = std::abs(segm2Pos.perp());
111 float segm2PosPhi = segm2Pos.phi();
112 float segm2PosThe = segm2Pos.theta();
113 float segm2PosZ = segm2Pos.z();
114 if(segm2PosThe>
M_PI/2) segm2PosThe=
M_PI-segm2PosThe;
115 if(segm2PosPhi<0)segm2PosPhi+=2*
M_PI;
119 float dPhi_Segm1_Segm2 = segm1PosPhi-segm2PosPhi;
120 if(dPhi_Segm1_Segm2<-
M_PI)dPhi_Segm1_Segm2+=2*
M_PI;
121 if(dPhi_Segm1_Segm2>
M_PI)dPhi_Segm1_Segm2-=2*
M_PI;
122 if(std::abs(dPhi_Segm1_Segm2)>dPhiCutSegmentMatching)
continue;
125 float dZ = std::abs(segm2PosZ)-std::abs(segm1PosZ);
128 float extrPosRho = std::abs(extrPos.perp());
129 float extrPosThe = extrPos.theta();
130 float extrPosPhi = extrPos.phi();
131 if(extrPosThe>
M_PI/2) extrPosThe=
M_PI-extrPosThe;
132 if(extrPosPhi<0)extrPosPhi+=2*
M_PI;
135 float dRho_Extr_Segm2 = extrPosRho-segm2PosRho;
136 float dPhi_Extr_Segm2 = extrPosPhi-segm2PosPhi;
137 float dThe_Extr_Segm2 = extrPosThe-segm2PosThe;
138 if(dPhi_Extr_Segm2<-
M_PI)dPhi_Extr_Segm2+=2*
M_PI;
139 if(dPhi_Extr_Segm2>
M_PI)dPhi_Extr_Segm2-=2*
M_PI;
147 if(std::abs(dPhi_Extr_Segm2)>dPhiCutSegmentMatching)
continue;
148 if(std::abs(dRho_Extr_Segm2)>dRhoCutSegmentMatching)
continue;
156 float segm2DirThe = segm2Dir.theta();
157 float segm2DirPhi = segm2Dir.phi();
158 if(segm2DirThe>
M_PI/2) segm2DirThe=
M_PI-segm2DirThe;
159 if(segm2DirPhi<0) segm2DirPhi+=2*
M_PI;
166 if(jMDT2>jMDT1)segmVector = segm2Pos-segm1Pos;
167 else segmVector = segm1Pos-segm2Pos;
168 float segmVecThe = segmVector.theta();
169 float segmVecPhi = segmVector.phi();
170 if(segmVecThe>
M_PI/2) segmVecThe=
M_PI-segmVecThe;
171 if(segmVecPhi<0) segmVecPhi+=2*
M_PI;
174 float dThe_Vec_Segm1 = segmVecThe-segm1DirThe;
175 float dPhi_Vec_Segm1 = segmVecPhi-segm1DirPhi;
176 if(dPhi_Vec_Segm1<-
M_PI)dPhi_Vec_Segm1+=2*
M_PI;
177 if(dPhi_Vec_Segm1>
M_PI)dPhi_Vec_Segm1-=2*
M_PI;
178 float dThe_Vec_Segm2 = segmVecThe-segm2DirThe;
179 float dPhi_Vec_Segm2 = segmVecPhi-segm2DirPhi;
180 if(dPhi_Vec_Segm2<-
M_PI)dPhi_Vec_Segm2+=2*
M_PI;
181 if(dPhi_Vec_Segm2>
M_PI)dPhi_Vec_Segm2-=2*
M_PI;
190 else if(jMDT1<jMDT2){
198 float dTheDir_Segm1_Segm2 = segm1DirThe-segm2DirThe;
199 float dPhiDir_Segm1_Segm2 = segm1PosPhi-segm2PosPhi;
200 if(dPhiDir_Segm1_Segm2<-
M_PI)dPhiDir_Segm1_Segm2+=2*
M_PI;
201 if(dPhiDir_Segm1_Segm2>
M_PI)dPhiDir_Segm1_Segm2-=2*
M_PI;
205 if(dPhi_Vec_Segm1>dPhiCutSegmentDirectionChecking[jMDT1][jMDT2] ||
206 dThe_Vec_Segm1>dTheCutSegmentDirectionChecking[jMDT1][jMDT2] ||
207 dPhi_Vec_Segm2>dPhiCutSegmentDirectionChecking[jMDT2][jMDT1] ||
208 dThe_Vec_Segm2>dTheCutSegmentDirectionChecking[jMDT2][jMDT1])
continue;
211 matchingSegments[jMDT2].push_back(segm2);
214 if(matchingSegments[jMDT2].
size()==1){
215 stationMatchFound[jMDT2]=
true;
224 for(
int jMDT2=0;jMDT2<4;jMDT2++){
225 if(stationMatchFound[jMDT2]){
226 segmArray[jMDT2]=matchingSegments[jMDT2].at(0);
228 disqualifiedSegments[
i][jMDT2].push_back(matchingSegments[jMDT2].at(0));
232 matchedSegments[
i].push_back(newTrack);