Changeset 19365
- Timestamp:
- 11/08/18 16:01:17 (6 years ago)
- Location:
- trunk/FACT++/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/BasicGlCamera.cc
r18984 r19365 77 77 78 78 79 hexRadius = 0.015f;80 hexTolerance = hexRadius/100.0f;81 79 viewSize = 1.0f; 82 calculatePixelsCoords();83 84 buildVerticesList();85 80 /* 86 81 ifstream fin1("Trigger-Patches.txt"); … … 256 251 { 257 252 } 253 bool BasicGlCamera::isFACT() const 254 { 255 return hexRadius<0.02; 256 } 258 257 void BasicGlCamera::assignPixelMap(const PixelMap& map) 259 258 { 260 259 fPixelMap = map; 261 260 261 int cnt = 0; 262 262 for (auto it=fPixelMap.begin(); it!=fPixelMap.end(); it++) 263 263 { 264 264 hardwareMapping[it->index] = it->hw(); 265 265 softwareMapping[it->hw()] = it->index; 266 } 266 if (it->gapd>0) 267 cnt++; 268 } 269 270 if (cnt==64) 271 { 272 cout << "INFO: 64 SiPMs found -- assuming HAWC's Eye geometry." << endl; 273 hexRadius = 0.065f; 274 } 275 else 276 hexRadius = 0.015f; 267 277 268 278 //now construct the correspondance between pixels and patches … … 896 906 void BasicGlCamera::updateNeighbors(int currentPixel) 897 907 { 908 hexTolerance = hexRadius/100.0f; 909 898 910 float squaredDistance = 0; 899 911 for (int i=0;i<currentPixel;i++) … … 948 960 void BasicGlCamera::calculatePixelsCoords() 949 961 { 950 if ( pixelsCoords[0][1] >= (0.299999-hexRadius) && pixelsCoords[0][1] <= (0.300001-hexRadius))962 if (fabs(pixelsCoords[0][1])>0.000001) 951 963 return; 952 pixelsCoords[0][0] = 0; 953 pixelsCoords[0][1] = 0.3 - hexRadius; 954 pixelsCoords[0][2] = 0; 955 pixelsCoords[1][0] = 0; 956 pixelsCoords[1][1] = 0.3+hexRadius; 957 pixelsCoords[1][2] = 0; 958 neighbors[0][0] = 1; 959 neighbors[1][3] = 0; 960 //from which side of the previous hexagon are we coming from ? 961 int fromSide = 3; 962 //to which side are we heading to ? 963 int toSide = 0; 964 for (int i=2;i<MAX_NUM_PIXELS;i++) 965 { 966 toSide = fromSide-1; 967 if (toSide < 0) 968 toSide =5; 969 while (neighbors[i-1][toSide] >= 0) 964 965 /****************** HAWC's Eye camera layout **************************/ 966 if (!isFACT()) 967 { 968 static const double gsSin60 = sqrt(3.)/2; 969 970 pixelsCoords[0][0] = 0; 971 pixelsCoords[0][1] = 0; 972 973 uint32_t cnt = 1; 974 for (int32_t ring=1; ring<=4; ring++) 970 975 { 971 toSide--; 976 for (int32_t s=0; s<6; s++) 977 { 978 for (int i=1; i<=ring; i++) 979 { 980 switch (s) 981 { 982 case 0: // Direction South East 983 pixelsCoords[cnt][0] = ring-i; 984 pixelsCoords[cnt][1] = (ring+i)*0.5; 985 break; 986 987 case 1: // Direction North East 988 pixelsCoords[cnt][0] = -i; 989 pixelsCoords[cnt][1] = ring-i*0.5; 990 break; 991 992 case 2: // Direction North 993 pixelsCoords[cnt][0] = -ring; 994 pixelsCoords[cnt][1] = ring*0.5-i; 995 break; 996 997 case 3: // Direction North West 998 pixelsCoords[cnt][0] = -(ring-i); 999 pixelsCoords[cnt][1] = -(ring+i)*0.5; 1000 break; 1001 1002 case 4: // Direction South West 1003 pixelsCoords[cnt][0] = i; 1004 pixelsCoords[cnt][1] = 0.5*i-ring; 1005 break; 1006 1007 case 5: // Direction South 1008 pixelsCoords[cnt][0] = ring; 1009 pixelsCoords[cnt][1] = i-ring*0.5; 1010 break; 1011 1012 } 1013 cnt++; 1014 } 1015 } 1016 } 1017 1018 pixelsCoords[cnt][0] = -4; 1019 pixelsCoords[cnt][1] = -4; 1020 1021 cnt++; 1022 1023 pixelsCoords[cnt][0] = 4; 1024 pixelsCoords[cnt][1] = -4; 1025 1026 cnt++; 1027 1028 pixelsCoords[cnt][0] = 4; 1029 pixelsCoords[cnt][1] = 4; 1030 1031 cnt++; 1032 1033 for (int i=0; i<8; i++) 1034 { 1035 pixelsCoords[cnt+i][0] = i-3.5; 1036 pixelsCoords[cnt+i][1] = 7.5 + i%2; 1037 } 1038 1039 cnt += 8; 1040 1041 for (;cnt<MAX_NUM_PIXELS; cnt++) 1042 { 1043 pixelsCoords[cnt][0] = 1000; 1044 pixelsCoords[cnt][1] = 1000; 1045 } 1046 1047 for (int i=0; i<MAX_NUM_PIXELS; i++) 1048 { 1049 if (i<64) 1050 { 1051 pixelsCoords[i][1] += 1; 1052 pixelsCoords[i][0] *= gsSin60; 1053 } 1054 1055 pixelsCoords[i][0] *= 2*hexRadius; 1056 pixelsCoords[i][1] *= 2*hexRadius; 1057 pixelsCoords[i][2] = 0; 1058 } 1059 } 1060 else 1061 { 1062 /************************ FACT Camera layout **************************/ 1063 pixelsCoords[0][0] = 0; 1064 pixelsCoords[0][1] = 0.3 - hexRadius; 1065 pixelsCoords[0][2] = 0; 1066 pixelsCoords[1][0] = 0; 1067 pixelsCoords[1][1] = 0.3+hexRadius; 1068 pixelsCoords[1][2] = 0; 1069 neighbors[0][0] = 1; 1070 neighbors[1][3] = 0; 1071 //from which side of the previous hexagon are we coming from ? 1072 int fromSide = 3; 1073 //to which side are we heading to ? 1074 int toSide = 0; 1075 for (int i=2;i<MAX_NUM_PIXELS;i++) 1076 { 1077 toSide = fromSide-1; 972 1078 if (toSide < 0) 973 toSide = 5; 1079 toSide =5; 1080 while (neighbors[i-1][toSide] >= 0) 1081 { 1082 toSide--; 1083 if (toSide < 0) 1084 toSide = 5; 974 1085 } 975 fromSide = toSide + 3; 976 if (fromSide > 5) 977 fromSide -= 6; 978 //ok. now we now in which direction we're heading 979 pixelsCoords[i][0] = pixelsCoords[i-1][0]; 980 pixelsCoords[i][1] = pixelsCoords[i-1][1]; 981 pixelsCoords[i][2] = pixelsCoords[i-1][2]; 982 switch (toSide) 983 { 984 case 0: 985 pixelsCoords[i][1] += 2*hexRadius; 986 break; 987 case 1: 988 pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0); 989 pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0); 990 break; 991 case 2: 992 pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0); 993 pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0); 994 break; 995 case 3: 996 pixelsCoords[i][1] -= 2*hexRadius; 997 break; 998 case 4: 999 pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0); 1000 pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0); 1001 break; 1002 case 5: 1003 pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0); 1004 pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0); 1005 break; 1006 }; 1007 // pixelsCoords[i][1] -= hexRadius; 1008 1009 updateNeighbors(i); 1010 } 1011 //Ok. So now we've circled around all the way to MAX_NUM_PIXELS 1012 //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels 1013 //remember the location pixels 1438 and 1439, and re-assign them later on 1014 GLfloat backupCoords[4]; 1015 skipPixels(1200, 1); 1016 skipPixels(1218, 3); 1017 skipPixels(1236, 1); 1018 skipPixels(1256, 1); 1019 skipPixels(1274, 3); 1020 skipPixels(1292, 3); 1021 skipPixels(1309, 6); 1022 skipPixels(1323, 7); 1023 skipPixels(1337, 6); 1024 skipPixels(1354, 6); 1025 skipPixels(1368, 7); 1026 //la c'est dans 1390 qu'il y a 1439 1027 backupCoords[0] = pixelsCoords[1390][0]; 1028 backupCoords[1] = pixelsCoords[1390][1]; 1029 skipPixels(1382, 9); 1030 skipPixels(1394, 12); 1031 skipPixels(1402, 15); 1032 skipPixels(1410, 12); 1033 //la c'est dans 1422 qu'il y a 1438 1034 backupCoords[2] = pixelsCoords[1422][0]; 1035 backupCoords[3] = pixelsCoords[1422][1]; 1036 skipPixels(1422, 12); 1037 skipPixels(1430, 15); 1038 1039 pixelsCoords[1438][0] = backupCoords[2]; 1040 pixelsCoords[1438][1] = backupCoords[3]; 1041 pixelsCoords[1439][0] = backupCoords[0]; 1042 pixelsCoords[1439][1] = backupCoords[1]; 1043 } 1086 fromSide = toSide + 3; 1087 if (fromSide > 5) 1088 fromSide -= 6; 1089 //ok. now we now in which direction we're heading 1090 pixelsCoords[i][0] = pixelsCoords[i-1][0]; 1091 pixelsCoords[i][1] = pixelsCoords[i-1][1]; 1092 pixelsCoords[i][2] = pixelsCoords[i-1][2]; 1093 switch (toSide) 1094 { 1095 case 0: 1096 pixelsCoords[i][1] += 2*hexRadius; 1097 break; 1098 case 1: 1099 pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0); 1100 pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0); 1101 break; 1102 case 2: 1103 pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0); 1104 pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0); 1105 break; 1106 case 3: 1107 pixelsCoords[i][1] -= 2*hexRadius; 1108 break; 1109 case 4: 1110 pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0); 1111 pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0); 1112 break; 1113 case 5: 1114 pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0); 1115 pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0); 1116 break; 1117 }; 1118 // pixelsCoords[i][1] -= hexRadius; 1119 1120 updateNeighbors(i); 1121 } 1122 //Ok. So now we've circled around all the way to MAX_NUM_PIXELS 1123 //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels 1124 //remember the location pixels 1438 and 1439, and re-assign them later on 1125 GLfloat backupCoords[4]; 1126 skipPixels(1200, 1); 1127 skipPixels(1218, 3); 1128 skipPixels(1236, 1); 1129 skipPixels(1256, 1); 1130 skipPixels(1274, 3); 1131 skipPixels(1292, 3); 1132 skipPixels(1309, 6); 1133 skipPixels(1323, 7); 1134 skipPixels(1337, 6); 1135 skipPixels(1354, 6); 1136 skipPixels(1368, 7); 1137 //la c'est dans 1390 qu'il y a 1439 1138 backupCoords[0] = pixelsCoords[1390][0]; 1139 backupCoords[1] = pixelsCoords[1390][1]; 1140 skipPixels(1382, 9); 1141 skipPixels(1394, 12); 1142 skipPixels(1402, 15); 1143 skipPixels(1410, 12); 1144 //la c'est dans 1422 qu'il y a 1438 1145 backupCoords[2] = pixelsCoords[1422][0]; 1146 backupCoords[3] = pixelsCoords[1422][1]; 1147 skipPixels(1422, 12); 1148 skipPixels(1430, 15); 1149 1150 pixelsCoords[1438][0] = backupCoords[2]; 1151 pixelsCoords[1438][1] = backupCoords[3]; 1152 pixelsCoords[1439][0] = backupCoords[0]; 1153 pixelsCoords[1439][1] = backupCoords[1]; 1154 } 1155 } 1156 1044 1157 void BasicGlCamera::buildVerticesList() 1045 1158 { 1159 hexTolerance = hexRadius/100.0f; 1160 1046 1161 numVertices = 0; 1047 1162 GLfloat cVertex[2]; -
trunk/FACT++/gui/BasicGlCamera.h
r15251 r19365 172 172 bool autoRefresh; 173 173 174 bool isFACT() const; 175 174 176 private: 175 177 void skipPixels(int start, int howMany);
Note:
See TracChangeset
for help on using the changeset viewer.