30 int dphi[6] = {-999,-999,-999,-999,-999,-999};
31 int dtmp[6] = {-999,-999,-999,-999,-999,-999};
32 int dtmpi[6] = {-999,-999,-999,-999,-999,-999};
33 int dth[6][4] = {{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999}};
36 for(
int s1=0;s1<3;s1++){
38 for(
int s2=s1+1;
s2<4;
s2++){
44 if((s1 == 0) && (phmatch[zone][winner][s1].
Phi() != -999) && (phmatch[zone][winner][
s2].
Phi() != -999)){
46 dphi[
s2-1] = phmatch[zone][winner][s1].Phi() - phmatch[zone][winner][
s2].Phi();
48 else if((s1 != 0) && (phmatch[zone][winner][s1].
Phi() != -999) && (phmatch[zone][winner][
s2].
Phi() != -999)){
50 dphi[s1+
s2] = phmatch[zone][winner][s1].Phi() - phmatch[zone][winner][
s2].Phi();
63 int thi = thmatch[zone][winner][s1][
i].Theta();
64 int thj = thmatch[zone][winner][
s2][
j].Theta();
65 int deltath = thi - thj;
68 if((s1 == 0) && (thi != -999) && (thj != -999)){
70 if(!
i){dth[
s2-1][
i+
j] = deltath;}
71 else{dth[
s2-1][
i+
j+1] = deltath;}
75 else if((s1 != 0) && (thi != -999) && (thj != -999)){
77 if(!
i){dth[s1+
s2][
i+
j] = deltath;}
78 else{dth[s1+
s2][
i+
j+1] = deltath;}
88 int vmask[3] = {0,0,0};
89 const unsigned int mask[6] = {0x3,0x5,0x9,0x6,0xa,0xc};
102 const unsigned int mindex[6] = {0,0,0,1,1,2};
104 for(
int p=0;
p<6;
p++){
109 for(
int l=0;
l<4;
l++){
113 if(
abs(dth[
p][
l]) < fabs(dtmp[
p])){
124 if((
abs(dtmp[
p]) <= 4) && (dtmp[p] != -999)){
128 vmask[mindex[
p]] |= mask[
p];
138 unsigned int vstat = vmask[0];
142 if( !vstat || (vstat & vmask[1])){vstat |= vmask[1];}
146 if( !vstat || (vstat & vmask[2])){vstat |= vmask[2];}
150 const unsigned int vstatindex[11] = {0xc,0xa,0x6,0xe,0x9,0x5,0xd,0x3,0xb,0x7,0xf};
168 const unsigned int viindex[2][11] = {{5,4,3,3,2,1,1,0,0,0,0},{5,4,3,5,2,1,5,0,4,3,3}};
170 std::vector<int>
d (2,-999);
171 std::vector<std::vector<int>>
deltas (2,d);
175 for(
int c=0;
c<11;
c++){
177 if(vstat == vstatindex[
c]){
179 deltas[0][0] = dphi[viindex[0][
c]];
180 deltas[0][1] = dphi[viindex[1][
c]];
181 deltas[1][0] = dtmp[viindex[0][
c]];
182 deltas[1][1] = dtmp[viindex[1][
c]];
191 phi = phmatch[zone][winner][1].Phi();
200 theta = thmatch[zone][winner][1][id].Theta();
202 else if(dtmp[3] != -999){
208 theta = thmatch[zone][winner][1][id].Theta();
210 else if(dtmp[4] != -999){
216 theta = thmatch[zone][winner][1][id].Theta();
222 phi = phmatch[zone][winner][2].Phi();
230 theta = thmatch[zone][winner][2][id].Theta();
232 else if(dtmp[5] != -999){
238 theta = thmatch[zone][winner][2][id].Theta();
243 phi = phmatch[zone][winner][3].Phi();
250 theta = thmatch[zone][winner][3][id].Theta();
257 int rank = (Mout.
Winners()[zone][winner].Rank()<<1);
261 if(vstat & 8){rank |= 1;}
else{rank &= 0x7e;}
262 if(vstat & 4){rank |= 2;}
else{rank &= 0x7d;}
263 if(vstat & 2){rank |= 8;}
else{rank &= 0x77;}
264 if(vstat & 1){rank |= 32;}
else{rank &= 0x5f;}
266 if(vstat == 0 || vstat == 1 || vstat == 2 || vstat == 4 || vstat == 8){rank = 0;}
284 std::vector<DeltaOutput>
o (3,output);
285 std::vector<std::vector<DeltaOutput>>
out (4,o);
287 for(
int zone=0;zone<4;zone++){
289 for(
int winner=0;winner<3;winner++){
292 out[zone][winner] =
Deltas(Mout, zone, winner);
DeltaOutput Deltas(MatchingOutput Mout, int zone, int winner)
void SetPhOut(PhOutput ph_output)
std::vector< std::vector< Winner > > Winners()
Geom::Theta< T > theta() const
std::vector< std::vector< std::vector< std::vector< ConvertedHit > > > > ThOutput
Abs< T >::type abs(const T &t)
void SetValues(MatchingOutput Mout, std::vector< std::vector< int >> Deltas, int Phi, int Theta, Winner winner)
Geom::Phi< T > phi() const
std::vector< std::vector< DeltaOutput > > CalcDeltas(MatchingOutput Mout)
std::vector< std::vector< std::vector< ConvertedHit > > > PhOutput