Index: /trunk/FACT++/gui/RawEventsViewer/MasterList-v3.txt
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/MasterList-v3.txt	(revision 11540)
+++ /trunk/FACT++/gui/RawEventsViewer/MasterList-v3.txt	(revision 11540)
@@ -0,0 +1,1441 @@
+#SoftID	HardID	ContHardID	G-APD
+1348	0	0	414
+1419	1	1	415
+1249	2	2	428
+1349	3	3	417
+1420	4	4	1682
+1250	5	5	888
+1350	6	6	326
+1421	7	7	639
+1251	8	8	867
+1345	10	9	1819
+1416	11	10	1989
+1246	12	11	73
+1346	13	12	1935
+1417	14	13	236
+1247	15	14	524
+1347	16	15	23
+1418	17	16	707
+1248	18	17	723
+1025	20	18	1839
+917	21	19	1658
+1138	22	20	214
+1024	23	21	1258
+916	24	22	1877
+1137	25	23	531
+1023	26	24	238
+915	27	25	217
+1136	28	26	270
+1022	30	27	58
+914	31	28	77
+1135	32	29	60
+1021	33	30	1876
+913	34	31	740
+1134	35	32	1231
+1020	36	33	1368
+912	37	34	1778
+1133	38	35	1798
+1145	100	36	1874
+1031	101	37	1869
+1144	102	38	1920
+1030	103	39	13
+922	104	40	131
+1029	105	41	1791
+921	106	42	1713
+819	107	43	1748
+920	108	44	240
+1356	110	45	125
+1355	111	46	209
+1260	112	47	847
+1146	113	48	148
+1354	114	49	292
+1259	115	50	290
+1258	116	51	248
+1257	117	52	939
+1143	118	53	1294
+1256	120	54	1757
+1142	121	55	367
+1141	122	56	1281
+1255	123	57	1665
+1028	124	58	1669
+1027	125	59	221
+919	126	60	1683
+1026	127	61	1883
+918	128	62	1886
+1140	130	63	1361
+1254	131	64	634
+1139	132	65	1744
+1353	133	66	1301
+1253	134	67	535
+1352	135	68	86
+1252	136	69	194
+1438	137	70	1985
+1351	138	71	184
+1148	200	72	705
+1034	201	73	1786
+1147	202	74	1780
+1033	203	75	1779
+925	204	76	1777
+1032	205	77	1688
+924	206	78	468
+822	207	79	745
+923	208	80	626
+1424	210	81	993
+1359	211	82	1306
+1358	212	83	252
+1263	213	84	1045
+1423	214	85	1221
+1422	215	86	989
+1357	216	87	1118
+1262	217	88	1137
+1261	218	89	602
+821	220	90	1651
+725	221	91	565
+820	222	92	26
+724	223	93	52
+634	224	94	958
+723	225	95	1068
+633	226	96	1845
+549	227	97	1974
+632	228	98	393
+548	230	99	749
+470	231	100	135
+547	232	101	300
+469	233	102	349
+397	234	103	387
+546	235	104	971
+468	236	105	597
+396	237	106	1209
+545	238	107	127
+818	300	108	1292
+722	301	109	118
+817	302	110	655
+721	303	111	1629
+631	304	112	1754
+816	305	113	1823
+720	306	114	30
+630	307	115	140
+815	308	116	754
+719	310	117	10
+629	311	118	1146
+814	312	119	487
+718	313	120	100
+628	314	121	686
+813	315	122	1039
+717	316	123	1134
+627	317	124	1357
+812	318	125	2310
+716	320	126	2305
+626	321	127	666
+811	322	128	2314
+715	323	129	650
+625	324	130	1148
+810	325	131	1671
+714	326	132	289
+624	327	133	297
+809	328	134	388
+467	330	135	1967
+395	331	136	673
+544	332	137	1730
+466	333	138	129
+394	334	139	169
+543	335	140	372
+465	336	141	557
+393	337	142	609
+542	338	143	833
+1365	400	144	1241
+1429	401	145	40
+1364	402	146	255
+1363	403	147	1750
+1268	404	148	1255
+1362	405	149	1307
+1267	406	150	1315
+1266	407	151	1691
+1152	408	152	1836
+1428	410	153	175
+1427	411	154	2290
+1426	412	155	311
+1361	413	156	926
+1425	414	157	427
+1360	415	158	2293
+1265	416	159	171
+1264	417	160	442
+1149	418	161	163
+1151	420	162	706
+1037	421	163	1065
+1150	422	164	1298
+1036	423	165	1300
+928	424	166	1685
+1035	425	167	1712
+927	426	168	1715
+825	427	169	1770
+926	428	170	181
+824	430	171	599
+728	431	172	1000
+823	432	173	1813
+727	433	174	1956
+637	434	175	379
+726	435	176	1040
+636	436	177	1373
+552	437	178	1610
+635	438	179	22
+551	500	180	1074
+473	501	181	1206
+550	502	182	1218
+472	503	183	1275
+400	504	184	1293
+471	505	185	632
+399	506	186	1984
+333	507	187	335
+398	508	188	635
+332	510	189	436
+272	511	190	439
+331	512	191	444
+271	513	192	605
+217	514	193	1247
+330	515	194	1735
+270	516	195	425
+216	517	196	1331
+329	518	197	143
+269	520	198	780
+215	521	199	834
+328	522	200	839
+268	523	201	873
+214	524	202	872
+327	525	203	1649
+267	526	204	150
+213	527	205	772
+326	528	206	861
+464	530	207	752
+392	531	208	771
+541	532	209	955
+463	533	210	1026
+391	534	211	1046
+540	535	212	1323
+462	536	213	1609
+390	537	214	1736
+539	538	215	1739
+1273	600	216	275
+1367	601	217	371
+1272	602	218	272
+1158	603	219	81
+1366	604	220	6
+1271	605	221	1207
+1270	606	222	486
+1269	607	223	139
+1155	608	224	578
+1154	610	225	119
+1040	611	226	95
+1153	612	227	1847
+1039	613	228	527
+931	614	229	211
+1038	615	230	588
+930	616	231	612
+828	617	232	1282
+929	618	233	1800
+827	620	234	766
+731	621	235	1615
+826	622	236	1624
+730	623	237	1648
+640	624	238	1652
+729	625	239	584
+639	626	240	1365
+555	627	241	1655
+638	628	242	1656
+554	630	243	286
+476	631	244	398
+553	632	245	736
+475	633	246	812
+403	634	247	815
+474	635	248	852
+402	636	249	868
+336	637	250	830
+401	638	251	327
+335	700	252	511
+275	701	253	831
+334	702	254	865
+274	703	255	1038
+220	704	256	1289
+273	705	257	1720
+219	706	258	1726
+171	707	259	782
+218	708	260	814
+170	710	261	2295
+128	711	262	2296
+169	712	263	874
+127	713	264	421
+91	714	265	1168
+168	715	266	2298
+126	716	267	2300
+90	717	268	331
+167	718	269	781
+173	720	270	1106
+131	721	271	210
+172	722	272	456
+130	723	273	483
+94	724	274	791
+129	725	275	902
+93	726	276	909
+63	727	277	1051
+92	728	278	1157
+62	730	279	922
+38	731	280	899
+61	732	281	842
+37	733	282	1197
+19	734	283	513
+60	735	284	1198
+36	736	285	563
+18	737	286	465
+59	738	287	514
+1157	800	288	1933
+1043	801	289	1937
+1156	802	290	50
+1042	803	291	15
+934	804	292	41
+1041	805	293	193
+933	806	294	1884
+831	807	295	1889
+932	808	296	225
+830	810	297	396
+734	811	298	476
+829	812	299	490
+733	813	300	1036
+643	814	301	1208
+732	815	302	92
+642	816	303	121
+558	817	304	291
+641	818	305	500
+557	820	306	712
+479	821	307	1612
+556	822	308	133
+478	823	309	1224
+406	824	310	165
+477	825	311	309
+405	826	312	720
+339	827	313	728
+404	828	314	965
+338	830	315	1022
+278	831	316	420
+337	832	317	760
+277	833	318	1267
+223	834	319	146
+276	835	320	304
+222	836	321	1269
+174	837	322	389
+221	838	323	1963
+1160	900	324	106
+1161	901	325	269
+1159	902	326	1831
+1045	903	327	233
+1046	904	328	731
+1044	905	329	1841
+936	906	330	226
+937	907	331	400
+935	908	332	1771
+833	910	333	470
+834	911	334	479
+832	912	335	333
+736	913	336	360
+737	914	337	464
+735	915	338	480
+645	916	339	539
+646	917	340	566
+644	918	341	573
+560	920	342	854
+561	921	343	964
+559	922	344	757
+481	923	345	1225
+482	924	346	636
+480	925	347	972
+408	926	348	1126
+409	927	349	1144
+407	928	350	1654
+341	930	351	1229
+342	931	352	608
+340	932	353	1376
+280	933	354	624
+281	934	355	667
+279	935	356	974
+225	936	357	1217
+226	937	358	1341
+224	938	359	1681
+176	1000	360	934
+177	1001	361	2286
+175	1002	362	1162
+133	1003	363	806
+134	1004	364	1170
+132	1005	365	1037
+96	1006	366	173
+97	1007	367	2301
+95	1008	368	2283
+65	1010	369	904
+66	1011	370	458
+64	1012	371	314
+40	1013	372	159
+41	1014	373	157
+39	1015	374	1195
+21	1016	375	466
+22	1017	376	1177
+20	1018	377	1193
+68	1020	378	307
+69	1021	379	919
+42	1022	380	896
+43	1023	381	911
+44	1024	382	522
+23	1025	383	530
+24	1026	384	1085
+45	1027	385	556
+10	1028	386	906
+8	1030	387	915
+9	1031	388	777
+7	1032	389	1107
+1	1033	390	997
+2	1034	391	1087
+6	1035	392	977
+0	1036	393	957
+3	1037	394	844
+5	1038	395	923
+344	1100	396	381
+345	1101	397	431
+282	1102	398	1684
+283	1103	399	364
+284	1104	400	641
+227	1105	401	822
+228	1106	402	1021
+229	1107	403	354
+178	1108	404	871
+179	1110	405	1190
+180	1111	406	1186
+135	1112	407	1286
+136	1113	408	1332
+137	1114	409	933
+98	1115	410	1189
+99	1116	411	1343
+100	1117	412	1345
+67	1118	413	1382
+182	1120	414	2299
+183	1121	415	2284
+138	1122	416	2287
+139	1123	417	306
+140	1124	418	892
+101	1125	419	1143
+102	1126	420	2285
+141	1127	421	334
+70	1128	422	797
+103	1130	423	1104
+142	1131	424	1333
+71	1132	425	206
+104	1133	426	1091
+143	1134	427	1185
+72	1135	428	1335
+105	1136	429	1392
+144	1137	430	1180
+73	1138	431	1394
+1368	1200	432	254
+1274	1201	433	732
+1275	1202	434	536
+1162	1203	435	1666
+1369	1204	436	1372
+1276	1205	437	1253
+1277	1206	438	1833
+1278	1207	439	1850
+1165	1208	440	112
+1163	1210	441	506
+1164	1211	442	562
+1047	1212	443	1276
+1048	1213	444	576
+1049	1214	445	325
+938	1215	446	505
+939	1216	447	647
+940	1217	448	359
+835	1218	449	385
+836	1220	450	568
+837	1221	451	1030
+738	1222	452	1055
+739	1223	453	1668
+740	1224	454	1915
+647	1225	455	328
+648	1226	456	213
+649	1227	457	1903
+562	1228	458	1752
+563	1230	459	405
+564	1231	460	413
+483	1232	461	195
+484	1233	462	1202
+485	1234	463	432
+410	1235	464	628
+411	1236	465	1270
+412	1237	466	1953
+343	1238	467	1992
+1430	1300	468	1760
+1370	1301	469	36
+1371	1302	470	55
+1372	1303	471	57
+1373	1304	472	256
+1279	1305	473	268
+1280	1306	474	1885
+1281	1307	475	263
+1168	1308	476	716
+1166	1310	477	1788
+1167	1311	478	1722
+1050	1312	479	1941
+1051	1313	480	34
+1052	1314	481	182
+941	1315	482	1799
+942	1316	483	1785
+943	1317	484	1304
+838	1318	485	1284
+839	1320	486	1697
+840	1321	487	341
+741	1322	488	374
+742	1323	489	570
+743	1324	490	1049
+650	1325	491	855
+651	1326	492	1355
+652	1327	493	1358
+565	1328	494	656
+566	1330	495	352
+567	1331	496	838
+486	1332	497	357
+487	1333	498	779
+488	1334	499	1228
+413	1335	500	735
+414	1336	501	1201
+415	1337	502	801
+346	1338	503	1002
+350	1400	504	1278
+351	1401	505	351
+288	1402	506	1359
+289	1403	507	1718
+290	1404	508	1957
+233	1405	509	1965
+234	1406	510	1729
+291	1407	511	744
+184	1408	512	1212
+347	1410	513	825
+348	1411	514	1632
+285	1412	515	711
+286	1413	516	1133
+287	1414	517	346
+230	1415	518	1391
+231	1416	519	1317
+232	1417	520	1285
+181	1418	521	1342
+421	1420	522	1113
+496	1421	523	1139
+353	1422	524	1280
+422	1423	525	244
+497	1424	526	590
+354	1425	527	691
+423	1426	528	863
+498	1427	529	981
+355	1428	530	1028
+235	1430	531	803
+292	1431	532	1309
+185	1432	533	776
+236	1433	534	885
+293	1434	535	338
+186	1435	536	881
+237	1436	537	869
+294	1437	538	197
+187	1438	539	353
+1431	1500	540	792
+1432	1501	541	207
+1433	1502	542	347
+1374	1503	543	805
+1434	1504	544	1172
+1375	1505	545	1387
+1282	1506	546	348
+1283	1507	547	1395
+1171	1508	548	784
+1169	1510	549	560
+1170	1511	550	1871
+1053	1512	551	1882
+1054	1513	552	1851
+1055	1514	553	361
+944	1515	554	469
+945	1516	555	474
+946	1517	556	564
+841	1518	557	577
+842	1520	558	1948
+843	1521	559	2304
+744	1522	560	2306
+745	1523	561	2307
+746	1524	562	700
+653	1525	563	677
+654	1526	564	24
+655	1527	565	1124
+568	1528	566	709
+569	1530	567	983
+570	1531	568	1122
+489	1532	569	1370
+490	1533	570	1664
+491	1534	571	1033
+416	1535	572	1377
+417	1536	573	817
+418	1537	574	1674
+349	1538	575	613
+1435	1600	576	283
+1376	1601	577	277
+1377	1602	578	294
+1284	1603	579	1047
+1436	1604	580	1111
+1437	1605	581	122
+1378	1606	582	4
+1285	1607	583	1141
+1286	1608	584	741
+1172	1610	585	1782
+1173	1611	586	1721
+1056	1612	587	386
+1057	1613	588	526
+1058	1614	589	537
+947	1615	590	21
+948	1616	591	1075
+949	1617	592	1070
+844	1618	593	1371
+845	1620	594	525
+846	1621	595	614
+747	1622	596	1613
+748	1623	597	477
+749	1624	598	610
+656	1625	599	1067
+657	1626	600	1710
+658	1627	601	688
+571	1628	602	1925
+572	1630	603	390
+573	1631	604	280
+492	1632	605	606
+493	1633	606	440
+494	1634	607	1271
+419	1635	608	1288
+420	1636	609	1129
+495	1637	610	1663
+352	1638	611	1897
+1379	1700	612	1123
+1380	1701	613	990
+1287	1702	614	1366
+1174	1703	615	617
+1381	1704	616	282
+1288	1705	617	285
+1289	1706	618	1117
+1290	1707	619	931
+1177	1708	620	998
+1175	1710	621	186
+1176	1711	622	755
+1059	1712	623	1262
+1060	1713	624	1354
+1061	1714	625	1364
+950	1715	626	1818
+951	1716	627	747
+952	1717	628	219
+847	1718	629	1928
+1291	1720	630	1888
+1178	1721	631	62
+1179	1722	632	203
+1180	1723	633	266
+1062	1724	634	330
+1063	1725	635	1318
+953	1726	636	222
+954	1727	637	262
+850	1728	638	761
+848	1730	639	846
+849	1731	640	1080
+750	1732	641	1863
+751	1733	642	1864
+752	1734	643	1892
+659	1735	644	1908
+660	1736	645	1066
+753	1737	646	394
+574	1738	647	454
+661	1800	648	366
+754	1801	649	409
+575	1802	650	501
+662	1803	651	44
+755	1804	652	141
+576	1805	653	725
+663	1806	654	746
+756	1807	655	1138
+577	1808	656	1215
+664	1810	657	407
+757	1811	658	607
+578	1812	659	68
+665	1813	660	1630
+758	1814	661	1661
+579	1815	662	1947
+666	1816	663	2317
+759	1817	664	1226
+580	1818	665	589
+958	1820	666	1811
+1069	1821	667	571
+854	1822	668	737
+959	1823	669	1810
+1070	1824	670	1802
+855	1825	671	1901
+960	1826	672	1912
+1071	1827	673	1943
+856	1828	674	1352
+961	1830	675	461
+1072	1831	676	463
+857	1832	677	1249
+962	1833	678	1812
+1073	1834	679	1910
+858	1835	680	1917
+963	1836	681	63
+1074	1837	682	97
+859	1838	683	142
+1064	1900	684	257
+1181	1901	685	1264
+1292	1902	686	1853
+1065	1903	687	1837
+1182	1904	688	33
+1293	1905	689	49
+1439	1906	690	235
+1183	1907	691	110
+1294	1908	692	1859
+955	1910	693	520
+1066	1911	694	538
+851	1912	695	710
+956	1913	696	1246
+1067	1914	697	1311
+852	1915	698	1319
+957	1916	699	1694
+1068	1917	700	1705
+853	1918	701	1781
+1297	1920	702	1251
+1186	1921	703	795
+1384	1922	704	826
+1296	1923	705	966
+1185	1924	706	996
+1383	1925	707	1044
+1295	1926	708	1273
+1184	1927	709	1356
+1382	1928	710	1952
+1300	1930	711	1809
+1189	1931	712	5
+1387	1932	713	90
+1299	1933	714	103
+1188	1934	715	223
+1386	1935	716	224
+1298	1936	717	1310
+1187	1937	718	1827
+1385	1938	719	48
+1306	2000	720	114
+1195	2001	721	242
+1393	2002	722	586
+1305	2003	723	973
+1194	2004	724	992
+1392	2005	725	250
+1304	2006	726	319
+1193	2007	727	987
+1391	2008	728	1112
+1303	2010	729	65
+1192	2011	730	267
+1390	2012	731	201
+1302	2013	732	715
+1191	2014	733	1842
+1389	2015	734	1921
+1301	2016	735	204
+1190	2017	736	1701
+1388	2018	737	107
+967	2020	738	1234
+1078	2021	739	1245
+863	2022	740	1305
+968	2023	741	56
+1079	2024	742	1734
+864	2025	743	1808
+969	2026	744	1825
+1080	2027	745	1852
+865	2028	746	1875
+964	2030	747	59
+1075	2031	748	66
+860	2032	749	115
+965	2033	750	1868
+1076	2034	751	1923
+861	2035	752	1927
+966	2036	753	1931
+1077	2037	754	369
+862	2038	755	391
+769	2100	756	259
+868	2101	757	370
+770	2102	758	534
+869	2103	759	540
+974	2104	760	596
+870	2105	761	713
+975	2106	762	1878
+1086	2107	763	1880
+976	2108	764	1896
+1085	2110	765	1239
+1202	2111	766	1260
+1203	2112	767	1236
+1309	2113	768	1316
+1087	2114	769	1843
+1088	2115	770	329
+1204	2116	771	1835
+1310	2117	772	1254
+1205	2118	773	1677
+970	2120	774	1243
+866	2121	775	1807
+971	2122	776	229
+867	2123	777	1945
+972	2124	778	764
+973	2125	779	1272
+1084	2126	780	1873
+1200	2127	781	1930
+1201	2128	782	567
+1196	2130	783	12
+1307	2131	784	451
+1197	2132	785	1796
+1308	2133	786	1058
+1081	2134	787	1862
+1198	2135	788	622
+1082	2136	789	227
+1199	2137	790	748
+1083	2138	791	1922
+772	2200	792	1237
+871	2201	793	1297
+773	2202	794	1299
+872	2203	795	1302
+977	2204	796	1353
+873	2205	797	1679
+978	2206	798	1693
+1089	2207	799	1762
+979	2208	800	1857
+1090	2210	801	1283
+1206	2211	802	1745
+1091	2212	803	1732
+1207	2213	804	1846
+1311	2214	805	1266
+1312	2215	806	1660
+1394	2216	807	1659
+1313	2217	808	1252
+1395	2218	809	1675
+508	2220	810	2303
+589	2221	811	18
+509	2222	812	69
+590	2223	813	669
+677	2224	814	698
+591	2225	815	1152
+678	2226	816	1672
+771	2227	817	279
+679	2228	818	260
+430	2230	819	689
+505	2231	820	767
+362	2232	821	601
+431	2233	822	1147
+506	2234	823	1230
+363	2235	824	1653
+432	2236	825	1738
+507	2237	826	299
+433	2238	827	627
+673	2300	828	1363
+766	2301	829	1379
+587	2302	830	1709
+674	2303	831	1881
+767	2304	832	324
+588	2305	833	1950
+675	2306	834	502
+768	2307	835	504
+676	2308	836	507
+670	2310	837	593
+763	2311	838	1140
+584	2312	839	1616
+671	2313	840	1633
+764	2314	841	1686
+585	2315	842	1911
+672	2316	843	2309
+765	2317	844	1027
+586	2318	845	9
+427	2320	846	1214
+502	2321	847	1268
+359	2322	848	1728
+428	2323	849	411
+503	2324	850	665
+360	2325	851	793
+429	2326	852	816
+504	2327	853	819
+361	2328	854	1367
+667	2330	855	592
+760	2331	856	591
+581	2332	857	1064
+668	2333	858	2316
+761	2334	859	1149
+582	2335	860	1350
+669	2336	861	1753
+762	2337	862	648
+583	2338	863	144
+1094	2400	864	1390
+1210	2401	865	1383
+1211	2402	866	1626
+1317	2403	867	495
+1399	2404	868	813
+1318	2405	869	818
+1400	2406	870	1128
+1319	2407	871	1386
+1401	2408	872	823
+1208	2410	873	1098
+1209	2411	874	1327
+1093	2412	875	978
+1316	2413	876	928
+1315	2414	877	313
+1396	2415	878	903
+1397	2416	879	1109
+1314	2417	880	1062
+1398	2418	881	512
+775	2420	882	620
+874	2421	883	1024
+776	2422	884	1115
+875	2423	885	1938
+980	2424	886	1905
+876	2425	887	1932
+981	2426	888	687
+1092	2427	889	1689
+982	2428	890	485
+511	2430	891	980
+592	2431	892	1222
+512	2432	893	2311
+593	2433	894	587
+680	2434	895	678
+594	2435	896	685
+681	2436	897	975
+774	2437	898	1114
+682	2438	899	1339
+301	2500	900	1964
+364	2501	901	1969
+302	2502	902	1980
+365	2503	903	654
+434	2504	904	660
+366	2505	905	668
+435	2506	906	690
+510	2507	907	809
+436	2508	908	1330
+241	2510	909	649
+298	2511	910	1378
+191	2512	911	1611
+242	2513	912	1631
+299	2514	913	441
+192	2515	914	616
+243	2516	915	859
+300	2517	916	1321
+244	2518	917	1324
+238	2520	918	829
+295	2521	919	1127
+188	2522	920	200
+239	2523	921	858
+296	2524	922	172
+189	2525	923	176
+240	2526	924	208
+297	2527	925	355
+190	2528	926	1640
+424	2530	927	1955
+499	2531	928	1975
+356	2532	929	683
+425	2533	930	850
+500	2534	931	1322
+357	2535	932	1336
+426	2536	933	447
+501	2537	934	684
+358	2538	935	727
+1096	2600	936	1061
+1212	2601	937	459
+1097	2602	938	1084
+1213	2603	939	1095
+1214	2604	940	1099
+1320	2605	941	894
+1215	2606	942	1105
+1321	2607	943	152
+1322	2608	944	482
+778	2610	945	460
+877	2611	946	362
+779	2612	947	377
+878	2613	948	462
+983	2614	949	554
+879	2615	950	580
+984	2616	951	618
+1095	2617	952	638
+985	2618	953	703
+514	2620	954	403
+595	2621	955	642
+515	2622	956	742
+596	2623	957	750
+683	2624	958	1150
+597	2625	959	1204
+684	2626	960	1340
+777	2627	961	380
+685	2628	962	674
+304	2630	963	397
+367	2631	964	168
+305	2632	965	373
+368	2633	966	424
+437	2634	967	675
+369	2635	968	696
+438	2636	969	1213
+513	2637	970	1235
+439	2638	971	1621
+148	2700	972	798
+193	2701	973	1171
+149	2702	974	808
+194	2703	975	1169
+245	2704	976	1385
+195	2705	977	2282
+246	2706	978	800
+303	2707	979	301
+247	2708	980	303
+106	2710	981	491
+145	2711	982	773
+74	2712	983	310
+107	2713	984	918
+146	2714	985	166
+75	2715	986	170
+108	2716	987	356
+147	2717	988	429
+109	2718	989	1388
+49	2720	990	453
+76	2721	991	494
+50	2722	992	883
+77	2723	993	1082
+110	2724	994	1110
+78	2725	995	1093
+111	2726	996	467
+150	2727	997	1346
+112	2728	998	1325
+25	2730	999	802
+46	2731	1000	856
+11	2732	1001	1090
+26	2733	1002	916
+47	2734	1003	927
+12	2735	1004	1200
+27	2736	1005	954
+48	2737	1006	946
+28	2738	1007	932
+781	2800	1008	1814
+880	2801	1009	46
+782	2802	1010	515
+881	2803	1011	718
+986	2804	1012	1790
+882	2805	1013	1312
+987	2806	1014	401
+1098	2807	1015	1898
+988	2808	1016	1263
+517	2810	1017	658
+598	2811	1018	661
+518	2812	1019	489
+599	2813	1020	645
+686	2814	1021	1025
+600	2815	1022	1035
+687	2816	1023	1041
+780	2817	1024	664
+688	2818	1025	1145
+307	2820	1026	343
+370	2821	1027	582
+308	2822	1028	594
+371	2823	1029	662
+440	2824	1030	751
+372	2825	1031	785
+441	2826	1032	988
+516	2827	1033	1727
+442	2828	1034	1951
+151	2830	1035	2281
+196	2831	1036	199
+152	2832	1037	339
+197	2833	1038	345
+248	2834	1039	876
+198	2835	1040	884
+249	2836	1041	1135
+306	2837	1042	1156
+250	2838	1043	1161
+784	2900	1044	234
+883	2901	1045	1988
+885	2902	1046	85
+884	2903	1047	231
+991	2904	1048	258
+1105	2905	1049	375
+1104	2906	1050	559
+1219	2907	1051	739
+1218	2908	1052	1233
+1099	2910	1053	284
+989	2911	1054	1895
+1100	2912	1055	625
+1216	2913	1056	276
+990	2914	1057	8
+1101	2915	1058	1079
+1103	2916	1059	1043
+1217	2917	1060	1034
+1102	2918	1061	28
+520	2920	1062	74
+601	2921	1063	1900
+603	2922	1064	488
+602	2923	1065	492
+689	2924	1066	510
+691	2925	1067	517
+690	2926	1068	704
+783	2927	1069	1057
+785	2928	1070	1078
+310	2930	1071	1329
+373	2931	1072	841
+375	2932	1073	295
+374	2933	1074	1131
+443	2934	1075	448
+445	2935	1076	1203
+444	2936	1077	1667
+519	2937	1078	298
+521	2938	1079	395
+154	3000	1080	887
+199	3001	1081	416
+201	3002	1082	768
+200	3003	1083	1031
+251	3004	1084	1334
+253	3005	1085	1369
+252	3006	1086	1618
+309	3007	1087	337
+311	3008	1088	433
+52	3010	1089	1184
+79	3011	1090	156
+81	3012	1091	435
+80	3013	1092	1153
+113	3014	1093	1181
+115	3015	1094	890
+114	3016	1095	1154
+153	3017	1096	1159
+155	3018	1097	1192
+4	3020	1098	769
+13	3021	1099	1338
+15	3022	1100	985
+14	3023	1101	794
+29	3024	1102	1088
+31	3025	1103	778
+30	3026	1104	907
+51	3027	1105	937
+53	3028	1106	886
+35	3030	1107	929
+17	3031	1108	900
+58	3032	1109	986
+34	3033	1110	940
+16	3034	1111	898
+57	3035	1112	878
+33	3036	1113	561
+32	3037	1114	1089
+56	3038	1115	528
+157	3100	1116	1163
+156	3101	1117	789
+204	3102	1118	1973
+203	3103	1119	1954
+202	3104	1120	434
+256	3105	1121	788
+255	3106	1122	1032
+254	3107	1123	493
+314	3108	1124	796
+55	3110	1125	419
+54	3111	1126	799
+84	3112	1127	901
+83	3113	1128	941
+82	3114	1129	1158
+118	3115	1130	1174
+117	3116	1131	1188
+116	3117	1132	496
+158	3118	1133	1086
+122	3120	1134	2294
+86	3121	1135	942
+163	3122	1136	2297
+121	3123	1137	2291
+85	3124	1138	443
+162	3125	1139	497
+120	3126	1140	775
+119	3127	1141	1167
+161	3128	1142	179
+125	3130	1143	315
+89	3131	1144	445
+166	3132	1145	473
+124	3133	1146	807
+88	3134	1147	925
+165	3135	1148	1081
+123	3136	1149	1092
+87	3137	1150	1100
+164	3138	1151	1103
+1108	3200	1152	783
+1107	3201	1153	318
+1223	3202	1154	437
+1222	3203	1155	196
+1221	3204	1156	1182
+1220	3205	1157	509
+1325	3206	1158	882
+1324	3207	1159	1191
+1323	3208	1160	1389
+787	3210	1161	80
+786	3211	1162	729
+888	3212	1163	756
+887	3213	1164	1240
+886	3214	1165	1303
+994	3215	1166	1374
+993	3216	1167	1824
+992	3217	1168	1848
+1106	3218	1169	1867
+523	3220	1170	1940
+522	3221	1171	2308
+606	3222	1172	27
+605	3223	1173	1216
+604	3224	1174	733
+694	3225	1175	960
+693	3226	1176	1142
+692	3227	1177	1205
+788	3228	1178	1891
+313	3230	1179	344
+312	3231	1180	693
+378	3232	1181	828
+377	3233	1182	864
+376	3234	1183	995
+448	3235	1184	1211
+447	3236	1185	1279
+446	3237	1186	1344
+524	3238	1187	1647
+1110	3300	1188	820
+1225	3301	1189	1625
+1224	3302	1190	889
+1328	3303	1191	332
+1327	3304	1192	836
+1404	3305	1193	880
+1326	3306	1194	418
+1403	3307	1195	412
+1402	3308	1196	302
+790	3310	1197	1256
+789	3311	1198	1313
+891	3312	1199	1690
+890	3313	1200	1793
+889	3314	1201	1797
+997	3315	1202	1856
+996	3316	1203	663
+995	3317	1204	484
+1109	3318	1205	558
+526	3320	1206	1761
+525	3321	1207	758
+609	3322	1208	697
+608	3323	1209	1936
+607	3324	1210	293
+697	3325	1211	579
+696	3326	1212	583
+695	3327	1213	1946
+791	3328	1214	623
+316	3330	1215	643
+315	3331	1216	657
+381	3332	1217	694
+380	3333	1218	787
+379	3334	1219	849
+451	3335	1220	1023
+450	3336	1221	1290
+449	3337	1222	1634
+527	3338	1223	719
+263	3400	1224	1641
+209	3401	1225	449
+322	3402	1226	659
+262	3403	1227	1259
+208	3404	1228	827
+321	3405	1229	870
+261	3406	1230	877
+260	3407	1231	982
+320	3408	1232	1960
+160	3410	1233	1958
+159	3411	1234	1970
+207	3412	1235	2302
+206	3413	1236	1628
+205	3414	1237	1638
+259	3415	1238	1639
+258	3416	1239	1642
+257	3417	1240	180
+317	3418	1241	430
+461	3420	1242	1619
+389	3421	1243	1646
+538	3422	1244	1673
+460	3423	1245	646
+388	3424	1246	695
+537	3425	1247	832
+459	3426	1248	1360
+387	3427	1249	1991
+536	3428	1250	824
+266	3430	1251	340
+212	3431	1252	1029
+325	3432	1253	1961
+265	3433	1254	350
+211	3434	1255	422
+324	3435	1256	450
+264	3436	1257	857
+210	3437	1258	804
+323	3438	1259	1287
+1111	3500	1260	950
+1227	3501	1261	1083
+1226	3502	1262	161
+1329	3503	1263	895
+1331	3504	1264	1094
+1330	3505	1265	1173
+1407	3506	1266	205
+1406	3507	1267	472
+1405	3508	1268	891
+793	3510	1269	1257
+792	3511	1270	1291
+894	3512	1271	1794
+893	3513	1272	1866
+892	3514	1273	498
+1000	3515	1274	581
+999	3516	1275	730
+998	3517	1276	1076
+1112	3518	1277	410
+529	3520	1278	1635
+528	3521	1279	1977
+612	3522	1280	382
+611	3523	1281	615
+610	3524	1282	621
+700	3525	1283	84
+699	3526	1284	1966
+698	3527	1285	619
+794	3528	1286	1223
+319	3530	1287	676
+318	3531	1288	759
+384	3532	1289	670
+383	3533	1290	682
+382	3534	1291	598
+454	3535	1292	365
+453	3536	1293	652
+452	3537	1294	743
+530	3538	1295	994
+1114	3600	1296	1854
+1113	3601	1297	376
+1229	3602	1298	708
+1228	3603	1299	368
+1334	3604	1300	1308
+1333	3605	1301	1746
+1332	3606	1302	1755
+1409	3607	1303	1763
+1408	3608	1304	1838
+796	3610	1305	72
+795	3611	1306	475
+897	3612	1307	572
+896	3613	1308	714
+895	3614	1309	722
+1003	3615	1310	762
+1002	3616	1311	1861
+1001	3617	1312	630
+1115	3618	1313	1982
+532	3620	1314	404
+531	3621	1315	603
+615	3622	1316	653
+614	3623	1317	1295
+613	3624	1318	1314
+703	3625	1319	1614
+702	3626	1320	1783
+701	3627	1321	672
+797	3628	1322	717
+458	3630	1323	699
+386	3631	1324	1349
+535	3632	1325	963
+457	3633	1326	1048
+385	3634	1327	1050
+534	3635	1328	631
+456	3636	1329	765
+455	3637	1330	1116
+533	3638	1331	1003
+1119	3700	1332	851
+1233	3701	1333	821
+1232	3702	1334	770
+1336	3703	1335	897
+1117	3704	1336	1199
+1116	3705	1337	786
+1231	3706	1338	908
+1230	3707	1339	945
+1335	3708	1340	970
+799	3710	1341	1914
+798	3711	1342	70
+900	3712	1343	1232
+899	3713	1344	228
+898	3714	1345	671
+1006	3715	1346	1942
+1005	3716	1347	71
+1004	3717	1348	104
+1118	3718	1349	192
+1010	3720	1350	763
+902	3721	1351	1362
+1009	3722	1352	1773
+901	3723	1353	1829
+1008	3724	1354	1916
+1007	3725	1355	45
+1120	3726	1356	232
+1235	3727	1357	1817
+1234	3728	1358	215
+707	3730	1359	508
+617	3731	1360	1380
+802	3732	1361	1751
+706	3733	1362	20
+616	3734	1363	137
+801	3735	1364	281
+705	3736	1365	585
+704	3737	1366	633
+800	3738	1367	692
+710	3800	1368	1125
+620	3801	1369	1821
+805	3802	1370	1830
+709	3803	1371	1151
+619	3804	1372	1054
+804	3805	1373	1926
+708	3806	1374	1939
+618	3807	1375	1261
+803	3808	1376	278
+713	3810	1377	1120
+623	3811	1378	1219
+808	3812	1379	1296
+712	3813	1380	1620
+622	3814	1381	2312
+807	3815	1382	640
+711	3816	1383	967
+621	3817	1384	2315
+806	3818	1385	1742
+1016	3820	1386	392
+908	3821	1387	518
+1129	3822	1388	555
+1015	3823	1389	679
+907	3824	1390	1069
+1128	3825	1391	1741
+1014	3826	1392	1769
+906	3827	1393	1855
+1127	3828	1394	1865
+1019	3830	1395	478
+911	3831	1396	516
+1132	3832	1397	323
+1018	3833	1398	406
+910	3834	1399	1707
+1131	3835	1400	1826
+1017	3836	1401	1834
+909	3837	1402	47
+1130	3838	1403	253
+1239	3900	1404	701
+1338	3901	1405	452
+1238	3902	1406	1822
+1337	3903	1407	212
+1123	3904	1408	1872
+1237	3905	1409	1766
+1122	3906	1410	1806
+1236	3907	1411	378
+1121	3908	1412	113
+1013	3910	1413	237
+905	3911	1414	523
+1126	3912	1415	604
+1012	3913	1416	721
+904	3914	1417	1244
+1125	3915	1418	1803
+1011	3916	1419	109
+903	3917	1420	1879
+1124	3918	1421	1320
+1339	3920	1422	1004
+1410	3921	1423	959
+1240	3922	1424	811
+1340	3923	1425	317
+1411	3924	1426	962
+1241	3925	1427	147
+1341	3926	1428	1210
+1412	3927	1429	243
+1242	3928	1430	1063
+1342	3930	1431	724
+1413	3931	1432	1844
+1243	3932	1433	202
+1343	3933	1434	322
+1414	3934	1435	399
+1244	3935	1436	39
+1344	3936	1437	1849
+1415	3937	1438	1749
+1245	3938	1439	753
Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cpp
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cpp	(revision 11540)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cpp	(revision 11540)
@@ -0,0 +1,1478 @@
+/*
+ * QtGl.cpp
+ *
+ *  Created on: Jul 19, 2011
+ *      Author: lyard
+ */
+
+#include "RawEventsViewer.h"
+#include "RawEventsViewerUi.h"
+#include <math.h>
+#include <fstream>
+
+#ifdef LOAD_RAW
+int16_t eventsData[NUM_STORED_EVENTS][ACTUAL_NUM_PIXELS][1024];
+#include </home/lyard/Code/display.C>
+#endif
+
+#include <QtGui/QFileDialog>
+
+//Coordinates of an hexagon of radius 1 and center 0
+GLfloat hexcoords[6][2] = {{-0.577367206,  1},
+                           { 0.577367206,  1},
+                           { 1.154734411,  0},
+                           { 0.577367206, -1},
+                           {-0.577367206, -1},
+                           {-1.154734411,  0}};
+
+//bounding box for diplaying the impulse curve
+float bboxMin[2] = {-1,-0.9};
+float bboxMax[2] = {1,-0.3};
+/************************************************************
+ * UPDATE NEIGHBORS recalculate the neighbors of the current pixels.
+ * Only takes the previous pixels into account (and updates them, too)
+ ************************************************************/
+void RawDataViewer::updateNeighbors(int currentPixel)
+{
+    float squaredDistance = 0;
+    for (int i=0;i<currentPixel;i++)
+    {
+        squaredDistance = (pixelsCoords[i][0] - pixelsCoords[currentPixel][0])*
+                          (pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) +
+                          (pixelsCoords[i][1] - pixelsCoords[currentPixel][1])*
+                          (pixelsCoords[i][1] - pixelsCoords[currentPixel][1]);
+        if (squaredDistance < 4*hexRadius*hexRadius*(1.0f+hexTolerance))//neighbor !
+        {//ok, but which one ?
+            if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
+                pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//top
+                neighbors[i][0] = currentPixel;
+                neighbors[currentPixel][3] = i;
+                continue;}
+            if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
+                pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//bottom
+                neighbors[i][3] = currentPixel;
+                neighbors[currentPixel][0] = i;
+                continue;}
+            if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
+                pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top right
+                neighbors[i][4] = currentPixel;
+                neighbors[currentPixel][1] = i;
+                continue;}
+            if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
+                pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom right
+                neighbors[i][5] = currentPixel;
+                neighbors[currentPixel][2] = i;
+                continue;}
+            if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
+                pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top left
+                neighbors[i][2] = currentPixel;
+                neighbors[currentPixel][5] = i;
+                continue;}
+            if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
+                pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom left
+                neighbors[i][1] = currentPixel;
+                neighbors[currentPixel][4] = i;
+                continue;}
+        }
+    }
+}
+/************************************************************
+ * SKIP PIXELS skips a given number of pixels.
+ * Only update the pixel coordinates. i.e. update neighbors must
+ * called again afterwards.
+ ************************************************************/
+void RawDataViewer::skipPixels(int start, int howMany)
+{
+    for (int i=start;i<MAX_NUM_PIXELS-howMany;i++)
+    {
+        pixelsCoords[i][0] = pixelsCoords[i+howMany][0];
+        pixelsCoords[i][1] = pixelsCoords[i+howMany][1];
+    }
+}
+/************************************************************
+ * CALCULATE PIXELS COORDS as the name suggests
+ ************************************************************/
+void RawDataViewer::calculatePixelsCoords()
+{
+    pixelsCoords[0][0] = 0;
+    pixelsCoords[0][1] = 0.3;
+    pixelsCoords[0][2] = 0;
+    pixelsCoords[1][0] = 0;
+    pixelsCoords[1][1] = 0.3+2*hexRadius;
+    pixelsCoords[1][2] = 0;
+    neighbors[0][0] = 1;
+    neighbors[1][3] = 0;
+    //from which side of the previous hexagon are we coming from ?
+    int fromSide = 3;
+    //to which side are we heading to ?
+    int toSide = 0;
+    for (int i=2;i<MAX_NUM_PIXELS;i++)
+    {
+        toSide = fromSide-1;
+        if (toSide < 0)
+            toSide =5;
+        while (neighbors[i-1][toSide] >= 0)
+        {
+            toSide--;
+            if (toSide < 0)
+                toSide = 5;
+        }
+        fromSide = toSide + 3;
+        if (fromSide > 5)
+            fromSide -= 6;
+        //ok. now we now in which direction we're heading
+        pixelsCoords[i][0] = pixelsCoords[i-1][0];
+        pixelsCoords[i][1] = pixelsCoords[i-1][1];
+        pixelsCoords[i][2] = pixelsCoords[i-1][2];
+        switch (toSide)
+        {
+        case 0:
+            pixelsCoords[i][1] += 2*hexRadius;
+        break;
+        case 1:
+            pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
+            pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
+        break;
+        case 2:
+            pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
+            pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
+        break;
+        case 3:
+            pixelsCoords[i][1] -= 2*hexRadius;
+        break;
+        case 4:
+            pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
+            pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
+        break;
+        case 5:
+            pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
+            pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
+        break;
+        };
+
+        updateNeighbors(i);
+    }
+    //Ok. So now we've circled around all the way to MAX_NUM_PIXELS
+    //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels
+    skipPixels(1200, 1);
+    skipPixels(1218, 3);
+    skipPixels(1236, 1);
+    skipPixels(1256, 1);
+    skipPixels(1274, 3);
+    skipPixels(1292, 3);
+    skipPixels(1309, 6);
+    skipPixels(1323, 7);
+    skipPixels(1337, 6);
+    skipPixels(1354, 6);
+    skipPixels(1368, 7);
+    skipPixels(1382, 9);
+    skipPixels(1394, 12);
+    skipPixels(1402, 15);
+    skipPixels(1410, 12);
+    skipPixels(1422, 12);
+    skipPixels(1430, 15);
+}
+/************************************************************
+ * BUILD VERTICES LIST. from the coordinates of the camera pixels,
+ * calculate the list and coordinates of the vertices required to draw the
+ * entire camera.
+ ************************************************************/
+void RawDataViewer::buildVerticesList()
+{
+    numVertices = 0;
+    GLfloat cVertex[2];
+    for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+    {
+        for (int j=0;j<6;j++)
+        {
+            for (int k=0;k<2;k++)
+                cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
+            bool found = false;
+            for (int k=0;k<numVertices;k++)
+            {
+                if ((cVertex[0] - verticesList[k][0])*
+                    (cVertex[0] - verticesList[k][0]) +
+                    (cVertex[1] - verticesList[k][1])*
+                    (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
+                    {
+                        found = true;
+                        break;
+                    }
+            }
+            if (!found)
+            {
+                for (int k=0;k<2;k++)
+                    verticesList[numVertices][k] = cVertex[k];
+                numVertices++;
+            }
+        }
+    }
+    for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+    {
+        for (int j=0;j<6;j++)
+        {
+            for (int k=0;k<2;k++)
+                cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
+            for (int k=0;k<numVertices;k++)
+            {
+                if ((cVertex[0] - verticesList[k][0])*
+                     (cVertex[0] - verticesList[k][0]) +
+                     (cVertex[1] - verticesList[k][1])*
+                     (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
+                     {
+                        verticesIndices[i][j] = k;
+                        break;
+                     }
+            }
+        }
+    }
+}
+/************************************************************
+ * BUILD PATCHES INDICES. from the list of patches, crawls through
+ * the list of camera pixels and build the list of edges that should be kept
+ * in order to display the patches' contours.
+ ************************************************************/
+void RawDataViewer::buildPatchesIndices()
+{
+    vector<edge>::iterator it;
+    bool erased = false;
+    for (int i=0;i<NTMARK;i++)//for all patches
+    {
+        patchesIndices[i].clear();
+        for (int j=0;j<9;j++)//for all cells of the current patch
+        {
+            if (patches[i][j] == 690 ||
+                patches[i][j] == 70)
+                continue;
+            for (int k=0;k<6;k++)//for all sides of the current cell
+            {
+                int first = k-1;
+                int second = k;
+                if (first < 0)
+                    first = 5;
+                erased = false;
+                for (it=(patchesIndices[i]).begin(); it != (patchesIndices[i]).end(); it++)//check if this side is here already or not
+                {
+                    if (((*it).first == verticesIndices[patches[i][j]][first] &&
+                         (*it).second == verticesIndices[patches[i][j]][second]) ||
+                        ((*it).first == verticesIndices[patches[i][j]][second] &&
+                         (*it).second == verticesIndices[patches[i][j]][first]))
+                    {
+                        patchesIndices[i].erase(it);
+                        erased = true;
+                        break;
+                    }
+                }
+                if (!erased)
+                {
+                    edge temp;
+                    temp.first = verticesIndices[patches[i][j]][first];
+                    temp.second = verticesIndices[patches[i][j]][second];
+                    patchesIndices[i].push_back(temp);
+                }
+            }
+        }
+    }
+}
+/************************************************************
+ * CALC BLUR COLOR if in blur display mode, calculate the interpolated
+ * colour for a given vertex
+ ************************************************************/
+void RawDataViewer::calcBlurColor(int pixel,  int vertex)
+{
+    GLfloat color[3];
+    int first, second;
+    first = vertex-1;
+    second = vertex;
+    if (first < 0)
+        first = 5;
+    first = neighbors[pixel][first];
+    second = neighbors[pixel][second];
+    for (int i=0;i<3;i++)
+        color[i] = pixelsColor[pixel][i];
+    float divide = 1;
+    if (first != -1)
+    {
+        divide++;
+        for (int i=0;i<3;i++)
+            color[i] += pixelsColor[first][i];
+    }
+    if (second != -1)
+    {
+        divide++;
+        for (int i=0;i<3;i++)
+            color[i] += pixelsColor[second][i];
+    }
+    for (int i=0;i<3;i++)
+        color[i] /= divide;
+    glColor3fv(color);
+}
+/************************************************************
+ * DRAW BLURRY HEXAGON. draws a solid hexagon, with interpolated colours
+ ************************************************************/
+void RawDataViewer::drawBlurryHexagon(int index)
+{
+    GLfloat color[3];
+    for (int i=0;i<3;i++)
+        color[i] = pixelsColor[index][i];
+    glBegin(GL_TRIANGLES);
+    calcBlurColor(index, 0);
+    glVertex2fv(verticesList[verticesIndices[index][0]]);
+    glColor3fv(color);
+    glVertex2fv(pixelsCoords[index]);
+    calcBlurColor(index, 1);
+    glVertex2fv(verticesList[verticesIndices[index][1]]);
+
+    glVertex2fv(verticesList[verticesIndices[index][1]]);
+    glColor3fv(color);
+    glVertex2fv(pixelsCoords[index]);
+    calcBlurColor(index, 2);
+    glVertex2fv(verticesList[verticesIndices[index][2]]);
+
+    glVertex2fv(verticesList[verticesIndices[index][2]]);
+    glColor3fv(color);
+    glVertex2fv(pixelsCoords[index]);
+    calcBlurColor(index, 3);
+    glVertex2fv(verticesList[verticesIndices[index][3]]);
+
+    glVertex2fv(verticesList[verticesIndices[index][3]]);
+    glColor3fv(color);
+    glVertex2fv(pixelsCoords[index]);
+    calcBlurColor(index, 4);
+    glVertex2fv(verticesList[verticesIndices[index][4]]);
+
+    glVertex2fv(verticesList[verticesIndices[index][4]]);
+    glColor3fv(color);
+    glVertex2fv(pixelsCoords[index]);
+    calcBlurColor(index, 5);
+    glVertex2fv(verticesList[verticesIndices[index][5]]);
+
+    glVertex2fv(verticesList[verticesIndices[index][5]]);
+    glColor3fv(color);
+    glVertex2fv(pixelsCoords[index]);
+    calcBlurColor(index, 0);
+    glVertex2fv(verticesList[verticesIndices[index][0]]);
+    glEnd();
+
+    return;
+}
+/************************************************************
+ * DRAW HEXAGON. draws a single hexagon.
+ ************************************************************/
+void RawDataViewer::drawHexagon(int index, bool solid)
+{
+    if (solid)
+        glBegin(GL_POLYGON);
+    else
+        glBegin(GL_LINE_LOOP);
+
+    glVertex2fv(verticesList[verticesIndices[index][0]]);
+    glVertex2fv(verticesList[verticesIndices[index][1]]);
+    glVertex2fv(verticesList[verticesIndices[index][2]]);
+    glVertex2fv(verticesList[verticesIndices[index][3]]);
+    glVertex2fv(verticesList[verticesIndices[index][4]]);
+    glVertex2fv(verticesList[verticesIndices[index][5]]);
+    if (solid)
+        glVertex2fv(verticesList[verticesIndices[index][0]]);
+
+    glEnd();
+
+    return;
+}
+
+
+float ss[5] = {0.00, 0.25, 0.5, 0.75, 1.00};
+float rr[5] = {0.15, 0.00, 0.00, 1.00, 0.85};
+float gg[5] = {0.15, 0.00, 1.00, 0.00, 0.85};
+float bb[5] = {0.15, 1.00, 0.00, 0.00, 0.85};
+/*
+float ss[5] = {0., 0.47, 0.475, 0.48, 1.00};
+float rr[5] = {0., 0.35, 0.85, 1.00, 1.00};
+float gg[5] = {0., 0.10, 0.20, 0.73, 1.00};
+float bb[5] = {0., 0.03, 0.06, 0.00, 1.00};
+*/
+/************************************************************
+ * DRAW PATCHES. draws the clustering patches
+ ************************************************************/
+void RawDataViewer::drawPatches()
+{
+    glLineWidth(2.0f);
+    float backupRadius = hexRadius;
+    hexRadius *= 0.95;
+    glBegin(GL_LINES);
+    for (int i=0;i<NTMARK;i++)
+    {
+        glColor3fv(patchesColor[i]);
+        for (unsigned int j=0;j<patchesIndices[i].size();j++)
+        {
+            glVertex2fv(verticesList[patchesIndices[i][j].first]);
+            glVertex2fv(verticesList[patchesIndices[i][j].second]);
+        }
+    }
+    glEnd();
+    hexRadius = backupRadius;
+}
+/************************************************************
+ * DRAW CAMERA draws all the camera pixels
+ ************************************************************/
+void RawDataViewer::drawCamera(bool alsoWire)
+{
+    glColor3f(0.5,0.5,0.5);
+    glLineWidth(1.0);
+    float color;
+
+    for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+    {
+        if (!nRoi)
+          color = (float)(i)/(float)(ACTUAL_NUM_PIXELS);
+        else
+#ifdef LOAD_RAW
+        color = float(eventsData[eventNum][i][whichSlice]+32767)/65535.0f;
+#else
+        color = float(eventData[nRoi*i + whichSlice]+32767)/65535.0f;
+#endif
+        int index = 0;
+        while (ss[index] < color)
+            index++;
+        index--;
+        float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
+        float weight1 = 1.0f-weight0;
+        pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
+        pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
+        pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
+    }
+
+    for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+    {
+        if (i == 690 ||
+            i == 70)
+            continue;
+        glColor3fv(pixelsColor[i]);
+        glLoadName(i);
+if (drawBlur)
+    drawBlurryHexagon(i);
+else
+    drawHexagon(i,true);
+
+    }
+    if (!alsoWire)
+        return;
+    glColor3f(0.0f,0.0f,0.0f);
+    for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
+    {
+        if (i == 690 ||
+            i == 70)
+            continue;
+        drawHexagon(i, false);
+    }
+
+}
+
+/************************************************************
+ * TRIM. FIXME this should not be here but taken from an existing class (somewhere)
+ ************************************************************/
+string Trim(const string &str)
+{
+    // Trim Both leading and trailing spaces
+    const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
+    const size_t end   = str.find_last_not_of(' ');  // Find the first character position from reverse af
+
+    // if all spaces or empty return an empty string
+    if (string::npos==start || string::npos==end)
+        return string();
+
+    return str.substr(start, end-start+1);
+}
+/************************************************************
+ * DRAW PIXEL CURVE. draws the raw impulse curve of the currently selected pixel
+ ************************************************************/
+void RawDataViewer::drawPixelCurve()
+{
+    if (!nRoi)
+        return;
+    glBegin(GL_LINES);
+    glColor3f(0.5,0.5,0.5);
+    glVertex2f(bboxMin[0], bboxMin[1]);
+    glVertex2f(bboxMax[0], bboxMin[1]);
+    glVertex2f(bboxMin[0], bboxMin[1]);
+    glVertex2f(bboxMin[0], bboxMax[1]);
+
+    float xRange = bboxMax[0] - bboxMin[0];
+    float yRange = bboxMax[1] - bboxMin[1];
+    glColor3f(1.0,1.0,1.0);
+    for (int i=0;i<nRoi-1;i++)
+    {
+#ifdef LOAD_RAW
+        glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
+                   bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+32767) /65535.0);
+        glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
+                   bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+32767) /65535.0);
+#else
+        glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
+                   bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+32767) /65535.0);
+        glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
+                   bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+32767) /65535.0);
+#endif
+    }
+    glColor3f(1.0,0.0,0.0);
+    glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
+               bboxMin[1]);
+    glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
+               bboxMax[1]);
+
+    glEnd();
+}
+/************************************************************
+ * CONSTRUCTOR.
+ ************************************************************/
+RawDataViewer::RawDataViewer(QWidget *parent) : QGLWidget(parent)
+{
+    setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
+    hexRadius = 0.015f;
+    hexTolerance = hexRadius/100.0f;
+    viewSize = 1.0f;
+    whichSlice = 0;
+#ifdef LOAD_RAW
+    nRoi = 1024;
+#else
+    nRoi = 0;
+#endif
+    eventNum = 0;
+    rowNum = -1;
+    eventStep = 1;
+    selectedPixel = 0;
+    inputFile = NULL;
+    eventData = NULL;
+    drawPatch = false;
+    drawImpulse = false;
+    drawBlur = false;
+#ifdef LOAD_RAW
+    loadEvents("/scratch/00000043.001_T.bin");
+#endif
+    calculatePixelsCoords();
+
+    ifstream fin2("MasterList-v3.txt");
+    if (!fin2.is_open())
+    {
+        cout << "Error: file \"MasterList-v3\" missing. aborting." << endl;
+        exit(-1);
+    }
+    int l = 0;
+    string buf;
+    while (getline(fin2, buf, '\n'))
+    {
+        buf = Trim(buf);
+        if (buf[0]=='#')
+            continue;
+
+        unsigned int softid, hardid, dummy;
+
+        stringstream str(buf);
+
+        str >> softid;
+        str >> dummy;
+        str >> hardid;
+
+        if (softid>=1440)
+            continue;
+
+        hardwareMapping[softid] = hardid;
+
+        l++;
+    }
+    GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3];
+    for (int i=0;i<1440;i++)
+        for (int j=0;j<3;j++)
+            tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j];
+    for (int i=0;i<1440;i++)
+        for (int j=0;j<3;j++)
+            pixelsCoords[i][j] = tempPixelsCoords[i][j];
+    buildVerticesList();
+   ifstream fin1("Trigger-Patches.txt");
+   if (!fin1.is_open())
+   {
+       cout << "Error: file \"Trigger-Patches.txt\" missing. Aborting." << endl;
+       exit(-1);
+   }
+   l=0;
+    while (getline(fin1, buf, '\n'))
+    {
+        buf = Trim(buf);
+        if (buf[0]=='#')
+            continue;
+
+        stringstream str(buf);
+        for (int i=0; i<9; i++)
+        {
+            unsigned int n;
+            str >> n;
+
+            if (n>=1440)
+                continue;
+
+            patches[l][i] = hardwareMapping[n];
+        }
+        l++;
+    }
+    buildPatchesIndices();
+    float color[3];
+    for (int i=0;i<160;i++)
+    {
+        color[0] = 0.5; color[1] = 0.5; color[2] = 0.3;
+//        if (i==0 || i==2 || i==5 || i==126 || i==10 || i==23 || i==28 || i==38 || i==132 || i==42 || i==55 ||
+//           i==18 || i==21 || i==34 || i==136 || i==122 || i==8 || i==14 || i==32 || i==45 || i==51 || i==138 ||
+//            i==93 || i==75 || i==54 || i==158 || i==111 || i==105 || i==94 || i==82 || i==66 || i==61 || i==79 ||
+//            i==156 || i==115 || i==102 || i==89 || i==71 || i==63 || i==152 || i==98 || i==84)
+//        {
+//            color[0] = 102.f/255.f;
+//            color[1] = 0.f;
+//            color[2] = 153.f/255.f;
+//        }
+        for (int j=0;j<3;j++)
+            patchesColor[i][j] = color[j];
+    }
+
+    for (int i=0;i<1440;i++)
+        updateNeighbors(i);
+
+
+
+}
+/************************************************************
+ *  DESTRUCTOR
+ ************************************************************/
+RawDataViewer::~RawDataViewer()
+{
+    if (inputFile != NULL)
+    {
+        inputFile->close();
+        delete inputFile;
+    }
+    if (eventData != NULL)
+        delete[] eventData;
+}
+/************************************************************
+ * INITIALIZE GL. does not do much.
+ ************************************************************/
+void RawDataViewer::initializeGL()
+{
+    qglClearColor(QColor(25,25,38));
+    glShadeModel(GL_FLAT);
+    glDisable(GL_DEPTH_TEST);
+    glDisable(GL_CULL_FACE);
+//    glEnable(GL_LINE_SMOOTH);
+//    glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
+}
+
+/************************************************************
+ * RESIZE GL. reshapes the ortho projection to match the current window size
+ ************************************************************/
+void RawDataViewer::resizeGL(int width, int height)
+{
+    glViewport(0, 0, width, height);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    GLfloat windowRatio = (float)width/(float)height;
+    if (windowRatio < 1)
+    {
+        windowRatio = 1.0f/windowRatio;
+        gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
+        pixelSize = 2*viewSize/(float)width;
+        shownSizex = 2*viewSize;
+        shownSizey = 2*viewSize*windowRatio;
+    }
+    else
+    {
+        gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
+        pixelSize = 2*viewSize/(float)height;
+        shownSizex = 2*viewSize*windowRatio;
+        shownSizey = 2*viewSize;
+    }
+    glMatrixMode(GL_MODELVIEW);
+
+}
+
+/************************************************************
+ * PAINT GL. main drawing function.
+ ************************************************************/
+void RawDataViewer::paintGL()
+{
+    glClear(GL_COLOR_BUFFER_BIT);
+    glLoadIdentity();
+
+    if (!drawImpulse)
+    {
+        glTranslatef(0,-0.44,0);
+        glScalef(1.5,1.5,1);
+    }
+    if (drawBlur)
+    {
+        glShadeModel(GL_SMOOTH);
+        drawCamera(false);
+    }
+    else
+    {
+        glShadeModel(GL_FLAT);
+        drawCamera(true);
+    }
+    if (drawImpulse)
+    {
+        glLineWidth(2.0);
+        drawPixelCurve();
+    }
+    if (drawPatch)
+        drawPatches();
+
+    if (drawImpulse)
+    {
+        glLineWidth(1.0f);
+        glColor3f(1.0,1.0,1.0);
+        drawHexagon(selectedPixel, false);
+    }
+}
+
+/************************************************************
+ * MOUSE PRESS EVENT. mouse click handler.
+ ************************************************************/
+void RawDataViewer::mousePressEvent(QMouseEvent *event)
+{
+    lastPos = event->pos();
+    setCorrectSlice(event);
+    updateGL();
+}
+
+/************************************************************
+ * SET CORRECT SLICE. if displayed, figures out if the graph was
+ * clicked, and if so, which slice should be displayed
+ ************************************************************/
+void RawDataViewer::setCorrectSlice(QMouseEvent* event)
+{
+    if (!drawImpulse)
+        return;
+    float x = (float)event->x() * pixelSize - shownSizex/2;
+    float y = ((float)height()-(float)event->y())*pixelSize - shownSizey/2;
+    if (x < bboxMin[0] ||
+        x > bboxMax[0] ||
+        y < bboxMin[1] ||
+        y > bboxMax[1])
+        return;
+    whichSlice = (x - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
+    emit signalCurrentSlice(whichSlice);
+}
+
+/************************************************************
+ * MOUSE MOVE EVENT. used to track the dragging of slices display
+ ************************************************************/
+void RawDataViewer::mouseMoveEvent(QMouseEvent *event)
+{
+    if (event->buttons() & Qt::LeftButton) {
+        setCorrectSlice(event);
+        updateGL();
+    } else if (event->buttons() & Qt::RightButton) {
+        updateGL();
+    }
+    lastPos = event->pos();
+}
+
+/************************************************************
+ * MOUSE DOUBLE CLICK EVENT. used to select pixels
+ ************************************************************/
+void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *event)
+{
+    int face = PixelAtPosition(event->pos());
+    if (face != -1) {
+        selectedPixel = face;
+        updateGL();
+        }
+}
+
+/************************************************************
+ * PIXEL AT POSITION. figures out which camera pixel was clicked.
+ ************************************************************/
+int RawDataViewer::PixelAtPosition(const QPoint &pos)
+{
+    const int MaxSize = 512;
+    GLuint buffer[MaxSize];
+    GLint viewport[4];
+
+    makeCurrent();
+
+    glGetIntegerv(GL_VIEWPORT, viewport);
+    glSelectBuffer(MaxSize, buffer);
+    glRenderMode(GL_SELECT);
+
+    glInitNames();
+    glPushName(0);
+
+    glMatrixMode(GL_PROJECTION);
+    glPushMatrix();
+    glLoadIdentity();
+    GLfloat windowRatio = GLfloat(width()) / GLfloat(height());
+    gluPickMatrix(GLdouble(pos.x()), GLdouble(viewport[3] - pos.y()),
+            1.0, 1.0, viewport);
+
+    if (windowRatio < 1)
+     {
+         windowRatio = 1.0f/windowRatio;
+         gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
+     }
+     else
+     {
+         gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
+     }
+
+    glMatrixMode(GL_MODELVIEW);
+    drawCamera(false);
+    glMatrixMode(GL_PROJECTION);
+    glPopMatrix();
+
+    //for some reason that I cannot understand, the push/pop matrix doesn't do the trick here... bizarre
+    //ok, so re-do the resizeGL thing.
+    resizeGL(width(), height());
+
+    if (!glRenderMode(GL_RENDER))
+        return -1;
+
+    return buffer[3];
+}
+/************************************************************
+ * IS FITS. checks if a given file is a fits file.
+ ************************************************************/
+bool RawDataViewer::IsFits(const char *name)
+{
+    MZlib fin(name);
+    if (!fin)
+        return 0;
+
+    unsigned char c[6];
+    fin.read((char*)c, 6);
+    if (!fin)
+        return 0;
+
+    return memcmp(c, "SIMPLE", 6)==0;
+}
+/************************************************************
+ * OPEN FILE. opens a new fits file
+ ************************************************************/
+void RawDataViewer::openFile(string& file)
+{
+    if (!IsFits(file.c_str()))
+    {
+        cout << "File does not seem to be fits. aborting" << endl;
+        return;
+    }
+    if (inputFile)
+    {
+        inputFile->close();
+        delete inputFile;
+    }
+    inputFile = new MFits(file);
+    nRows = inputFile->GetInt("NAXIS2");
+    nRoi = inputFile->GetInt("NROI");
+    runNumber = -1;
+    nTM = inputFile->GetInt("NTM");
+    runType = inputFile->GetInt("RUNTYPE");
+    firstDataTime = -1;
+    lastDataTime = -1;
+
+    eventNum = 0;
+
+#ifdef LOAD_RAW
+    nRows = NUM_STORED_EVENTS;
+#endif
+
+    if (eventData != NULL)
+        delete[] eventData;
+    eventData = new int16_t[1440*nRoi];
+    inputFile->SetPtrAddress("Data", eventData);
+    inputFile->SetPtrAddress("EventNum", &eventNum);
+    inputFile->SetPtrAddress("TriggerType", &triggerType);
+    inputFile->SetPtrAddress("SoftTrig", &softTrig);
+    inputFile->SetPtrAddress("PCTime", &pcTime);
+    inputFile->SetPtrAddress("BoardTime", boardTime);
+    inputFile->SetPtrAddress("StartPix", startPix);
+    inputFile->SetPtrAddress("StartTM", startTM);
+    int backupStep = eventStep;
+    rowNum = -1;
+    eventStep = 1;
+    plusEvent();
+    eventStep = backupStep;
+    emit newFileLoaded();
+}
+
+/************************************************************
+ * PLUS EVENT
+ ************************************************************/
+void RawDataViewer::plusEvent()
+{
+    eventStepping(true);
+}
+/************************************************************
+ * MINUS EVENT
+ ************************************************************/
+void RawDataViewer::minusEvent()
+{
+    eventStepping(false);
+}
+/************************************************************
+ * SET EVENT STEP
+ ************************************************************/
+void RawDataViewer::setEventStep(int step)
+{
+    eventStep = step;
+}
+/************************************************************
+ * EVENT STEPPING
+ ************************************************************/
+void RawDataViewer::eventStepping(bool plus)
+{
+    if (plus)
+        rowNum += eventStep;
+    else
+        rowNum -= eventStep;
+    if (rowNum >= nRows)
+        rowNum -= nRows;
+    if (rowNum < 0)
+        rowNum += nRows;
+#ifdef LOAD_RAW
+    eventNum+=eventStep;
+#else
+    if (inputFile == NULL)
+        return;
+    inputFile->GetRow(rowNum);
+#endif
+    updateGL();
+    emit signalCurrentEvent(eventNum);
+}
+/************************************************************
+ * NEXT SLICE. deprec ?
+ ************************************************************/
+void RawDataViewer::nextSlice()
+{
+    whichSlice++;
+    if (whichSlice >= nRoi)
+        whichSlice=0;
+
+    emit signalCurrentSlice(whichSlice);
+    updateGL();
+}
+/************************************************************
+ * UICONNECTOR CONSTRUCTOR
+ ************************************************************/
+UIConnector::UIConnector(QWidget* parent)
+{
+    timer.setInterval(1000.0);
+    QObject::connect(&timer, SIGNAL(timeout()),
+                      this, SLOT(nextSlicePlease()));
+}
+/************************************************************
+ * DRAW PATCHES CHECK CHANGE. checkbox handler
+ ************************************************************/
+void UIConnector::drawPatchesCheckChange(int state)
+{
+    if (state)
+        viewer->drawPatch = true;
+    else
+        viewer->drawPatch = false;
+    viewer->updateGL();
+}
+/************************************************************
+ * DRAW IMPULSE CHECK CHANGE. checkbox handler
+ ************************************************************/
+void UIConnector::drawImpulseCheckChange(int state)
+{
+    if (state)
+        viewer->drawImpulse = true;
+    else
+        viewer->drawImpulse = false;
+    viewer->updateGL();
+}
+/************************************************************
+ * DRAW BLUR CHECK CHANGE. checkbox handler
+ ************************************************************/
+void UIConnector::drawBlurCheckChange(int state)
+{
+    if (state)
+        viewer->drawBlur = true;
+    else
+        viewer->drawBlur = false;
+    viewer->updateGL();
+}
+/************************************************************
+ * NEXT SLICE PLEASE
+ ************************************************************/
+void UIConnector::nextSlicePlease()
+{
+    viewer->nextSlice();
+}
+/************************************************************
+ * SET VIEWER.
+ ************************************************************/
+void UIConnector::setViewer(RawDataViewer* v)
+{
+    viewer = v;
+}
+/************************************************************
+ * SLICES PER SECOND CHANGED. timing ui handler
+ ************************************************************/
+void UIConnector::slicesPerSecondChanged(double value)
+{
+    timer.setInterval(1000.0/value);
+}
+/************************************************************
+ * RANGE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::rangeChanged0(double value)
+{
+    ss[0] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RANGE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::rangeChanged1(double value)
+{
+    ss[1] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RANGE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::rangeChanged2(double value)
+{
+    ss[2] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RANGE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::rangeChanged3(double value)
+{
+    ss[3] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RANGE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::rangeChanged4(double value)
+{
+    ss[4] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RANGE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::redChanged0(double value)
+{
+    rr[0] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RED CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::redChanged1(double value)
+{
+    rr[1] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RED CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::redChanged2(double value)
+{
+    rr[2] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RED CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::redChanged3(double value)
+{
+    rr[3] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * RED CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::redChanged4(double value)
+{
+    rr[4] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * GREEN CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::greenChanged0(double value)
+{
+    gg[0] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * GREEN CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::greenChanged1(double value)
+{
+    gg[1] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * GREEN CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::greenChanged2(double value)
+{
+    gg[2] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * GREEN CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::greenChanged3(double value)
+{
+    gg[3] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * GREEN CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::greenChanged4(double value)
+{
+    gg[4] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * BLUE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::blueChanged0(double value)
+{
+    bb[0] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * BLUE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::blueChanged1(double value)
+{
+    bb[1] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * BLUE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::blueChanged2(double value)
+{
+    bb[2] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * BLUE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::blueChanged3(double value)
+{
+    bb[3] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * BLUE CHANGED . colors tweaking handler
+ ************************************************************/
+void UIConnector::blueChanged4(double value)
+{
+    bb[4] = (float)value;
+    viewer->updateGL();
+}
+/************************************************************
+ * LOAD NEW FILE CLICKED. button handler
+ ************************************************************/
+void UIConnector::loadNewFileClicked()
+{
+    QFileDialog dialog;
+    dialog.setFileMode(QFileDialog::ExistingFile);
+    dialog.open(this, SLOT(fileSelected(QString)));
+    dialog.setVisible(true);
+    dialog.exec();
+}
+/************************************************************
+ * FILE SELECTED. return of the file open dialog handler
+ ************************************************************/
+void UIConnector::fileSelected(QString file)
+{
+    currentFile = file.toStdString();
+    if (currentFile != "")
+        viewer->openFile(currentFile);
+}
+/************************************************************
+ * NEW FILE LOADED. update of the UI after a new file has been loaded
+ ************************************************************/
+void UIConnector::newFileLoaded()
+{
+    ostringstream str;
+    str << "File loaded: " << currentFile;
+    fileLoadedLabel->setText(QString(str.str().c_str()));
+    str.str("");
+    str << "Run number: " << viewer->runNumber;
+    runNumberLabel->setText(QString(str.str().c_str()));
+    str.str("");
+    str << "Number of Events/Slices: " << viewer->nRows << "/" << viewer->nRoi;
+    numberOfSlicesLabel->setText(QString(str.str().c_str()));
+    str.str("");
+    str << "Number of Time Marks: " << viewer->nTM;
+    numberOfTimeMarksLabel->setText(QString(str.str().c_str()));
+    str.str("");
+    str << "Run Type: " << viewer->runType;
+    runTypeLabel->setText(QString(str.str().c_str()));
+    str.str("");
+    str << "Time of 1st data: " << viewer->firstDataTime;
+    firstTimeLabel->setText(QString(str.str().c_str()));
+    str.str("");
+    str << "Time of last data: " << viewer->lastDataTime;
+    lastTimeLabel->setText(QString(str.str().c_str()));
+}
+/************************************************************
+ * PLAY PAUSE CLICKED. ui handler
+ ************************************************************/
+void UIConnector::playPauseClicked()
+{
+    if (timer.isActive())
+        timer.stop();
+    else
+        timer.start();
+}
+/************************************************************
+ * CURRENT SLICE HAS CHANGE. ui handler
+ ************************************************************/
+void UIConnector::currentSliceHasChanged(int slice)
+{
+    ostringstream str;
+    str << "Displaying Slice " << slice;
+    QString qstr(str.str().c_str());
+    emit updateCurrentSliceDisplay(qstr);
+}
+/************************************************************
+ * CURRENT EVENT HAS CHANGED. ui handler
+ ************************************************************/
+void UIConnector::currentEventHasChanged(int event)
+{
+    ostringstream str;
+    str << "Displaying Event " << event;
+    QString qstr(str.str().c_str());
+    emit updateCurrentEventDisplay(qstr);
+    //retrieve the data that we want to display
+    str.str("");
+    str << "PC Time: " << viewer->pcTime;
+    qstr = qstr.fromStdString(str.str());
+    emit updateCurrentPCTime(qstr);
+
+    str.str("");
+    str << "Software Trigger: " << viewer->softTrig;
+    qstr = qstr.fromStdString(str.str());
+    emit updateCurrentSoftTrigger(qstr);
+
+    str.str("");
+    str << "Trigger Type: " << viewer->triggerType;
+    qstr = qstr.fromStdString(str.str());
+    emit updateCurrentTriggerType(qstr);
+
+    boardsTimeList->clear();
+    startPixelsList->clear();
+    startTimeMarksList->clear();
+    for (int i=0;i <NBOARDS; i++)
+    {
+        str.str("");
+        str << i;
+        if (i<10) str << " ";
+        if (i<100) str << " ";
+        if (i<1000) str << " ";
+        str << ": " << viewer->boardTime[i];
+        boardsTimeList->addItem(QString(str.str().c_str()));
+    }
+    for (int i=0;i <NPIX; i++)
+    {
+        str.str("");
+        str << i;
+        if (i<10) str << " ";
+        if (i<100) str << " ";
+        if (i<1000) str << " ";
+        str << ": " << viewer->startPix[i];
+        startPixelsList->addItem(QString(str.str().c_str()));
+    }
+    for (int i=0;i <NTMARK; i++)
+    {
+        str.str("");
+        str << i;
+        if (i<10) str << " ";
+        if (i<100) str << " ";
+        if (i<1000) str << " ";
+        str << ": " << viewer->startTM[i];
+        startTimeMarksList->addItem(QString(str.str().c_str()));
+    }
+
+}
+
+/************************************************************
+ * MAIN PROGRAM FUNCTION.
+ ************************************************************/
+int main(int argc, char *argv[])
+{
+    if (argc > 1)
+    {
+        cout << "Sorry, this program does not accept options (yet)." << endl;
+        cout << "Usage: just launch it without arguments." << endl;
+        cout << "Once launched, you can load a fits file (compressed: .fits.gz) using the \"Load New File\" button" << endl;
+        cout << "Events stepping lets you crawl the events inside the loaded file, while the number between the \"-\" and \"+\" buttons determines how many events are skipped at every button click" << endl;
+        cout << "Play/Pause start or stops the animation of the camera (looping over the current event's slices), while the \"slices per sec\" number determines how many slices are diplayed every second" << endl;
+        cout << "The ranges, Red, Green and Blue series of inputs can be used to tweak the displayed colours. The range goes from 0 to 1, which would map to -32768 and 32767 respectively" << endl;
+        cout << "Only 3 intermediate steps can be given, and the given colours are interpolated for the pixels accordingly" << endl;
+        cout << "Eventually, the Draw Impulse, Draw Patches and Blur pixels checkboxes can be used to change what is displayed." << endl;
+        cout << "when \"Draw Impulse\" is checked, it is possible to select a pixel by double clicking on it, and the current slice can be drag and dropped." << endl;
+        return 0;
+    }
+    QApplication app(argc, argv);
+
+    if (!QGLFormat::hasOpenGL()) {
+        std::cout << "This system has no OpenGL support" << std::endl;
+        return 1;
+    }
+
+    QMainWindow mainWindow;
+
+    Ui_MainWindow myUi;
+    myUi.setupUi(&mainWindow);
+
+    RawDataViewer *canvas = myUi.GLWindow;
+
+    QObject::connect(myUi.eventsMinusButton, SIGNAL(clicked()),
+                     canvas, SLOT(minusEvent()));
+    QObject::connect(myUi.eventsPlusButton, SIGNAL(clicked()),
+                     canvas, SLOT(plusEvent()));
+    QObject::connect(myUi.eventsStepBox, SIGNAL(valueChanged(int)),
+                     canvas, SLOT(setEventStep(int)));
+    myUi.colorRange0->setValue(ss[0]);
+    myUi.colorRange1->setValue(ss[1]);
+    myUi.colorRange2->setValue(ss[2]);
+    myUi.colorRange3->setValue(ss[3]);
+    myUi.colorRange4->setValue(ss[4]);
+    myUi.redValue0->setValue(rr[0]);
+    myUi.redValue1->setValue(rr[1]);
+    myUi.redValue2->setValue(rr[2]);
+    myUi.redValue3->setValue(rr[3]);
+    myUi.redValue4->setValue(rr[4]);
+    myUi.greenValue0->setValue(gg[0]);
+    myUi.greenValue1->setValue(gg[1]);
+    myUi.greenValue2->setValue(gg[2]);
+    myUi.greenValue3->setValue(gg[3]);
+    myUi.greenValue4->setValue(gg[4]);
+    myUi.blueValue0->setValue(bb[0]);
+    myUi.blueValue1->setValue(bb[1]);
+    myUi.blueValue2->setValue(bb[2]);
+    myUi.blueValue3->setValue(bb[3]);
+    myUi.blueValue4->setValue(bb[4]);
+
+    UIConnector connector;
+    connector.setViewer(canvas);
+    connector.boardsTimeList = myUi.boardsTimeList;
+    connector.startPixelsList = myUi.startPixelsList;
+    connector.startTimeMarksList = myUi.startTimeMarksList;
+    connector.fileLoadedLabel = myUi.fileLoadedLabel;
+    connector.runNumberLabel = myUi.runNumberLabel;
+    connector.numberOfSlicesLabel = myUi.numberOfSlicesLabel;
+    connector.numberOfTimeMarksLabel = myUi.numberOfTimeMarksLabel;
+    connector.runTypeLabel = myUi.runTypeLabel;
+    connector.firstTimeLabel = myUi.timeOfFirstDataLabel;
+    connector.lastTimeLabel = myUi.timeOfLastDataLabel;
+
+    QObject::connect(myUi.drawPatchCheckBox, SIGNAL(stateChanged(int)),
+                     &connector, SLOT(drawPatchesCheckChange(int)));
+    QObject::connect(myUi.drawImpulseCheckBox, SIGNAL(stateChanged(int)),
+                     &connector, SLOT(drawImpulseCheckChange(int)));
+    QObject::connect(myUi.drawBlurCheckBox, SIGNAL(stateChanged(int)),
+                     &connector, SLOT(drawBlurCheckChange(int)));
+    QObject::connect(canvas, SIGNAL(newFileLoaded()),
+                     &connector, SLOT(newFileLoaded()));
+
+    QObject::connect(myUi.loadNewFileButton, SIGNAL(clicked()),
+                     &connector, SLOT(loadNewFileClicked()));
+
+    QObject::connect(myUi.colorRange0, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(rangeChanged0(double)));
+
+    QObject::connect(myUi.colorRange1, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(rangeChanged1(double)));
+
+    QObject::connect(myUi.colorRange2, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(rangeChanged2(double)));
+
+    QObject::connect(myUi.colorRange3, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(rangeChanged3(double)));
+
+    QObject::connect(myUi.colorRange4, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(rangeChanged4(double)));
+
+    QObject::connect(myUi.redValue0, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(redChanged0(double)));
+
+    QObject::connect(myUi.redValue1, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(redChanged1(double)));
+
+    QObject::connect(myUi.redValue2, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(redChanged2(double)));
+
+    QObject::connect(myUi.redValue3, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(redChanged3(double)));
+
+    QObject::connect(myUi.redValue4, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(redChanged4(double)));
+
+    QObject::connect(myUi.greenValue0, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(greenChanged0(double)));
+
+    QObject::connect(myUi.greenValue1, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(greenChanged1(double)));
+
+    QObject::connect(myUi.greenValue2, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(greenChanged2(double)));
+
+    QObject::connect(myUi.greenValue3, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(greenChanged3(double)));
+
+    QObject::connect(myUi.greenValue4, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(greenChanged4(double)));
+
+    QObject::connect(myUi.blueValue0, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(blueChanged0(double)));
+
+    QObject::connect(myUi.blueValue1, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(blueChanged1(double)));
+
+    QObject::connect(myUi.blueValue2, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(blueChanged2(double)));
+
+    QObject::connect(myUi.blueValue3, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(blueChanged3(double)));
+
+    QObject::connect(myUi.blueValue4, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(blueChanged4(double)));
+
+    QObject::connect(myUi.slicesPerSecValue, SIGNAL(valueChanged(double)),
+                      &connector, SLOT(slicesPerSecondChanged(double)));
+    QObject::connect(myUi.playPauseButton, SIGNAL(clicked()),
+                     &connector, SLOT(playPauseClicked()));
+
+    QObject::connect(canvas, SIGNAL(signalCurrentSlice(int)),
+                     &connector, SLOT(currentSliceHasChanged(int)));
+    QObject::connect(canvas, SIGNAL(signalCurrentEvent(int)),
+                     &connector, SLOT(currentEventHasChanged(int)));
+
+    QObject::connect(&connector, SIGNAL(updateCurrentSliceDisplay(QString)),
+                     myUi.displayingSliceLabel, SLOT(setText(const QString)));
+    QObject::connect(&connector, SIGNAL(updateCurrentEventDisplay(QString)),
+                     myUi.displayingEventLabel, SLOT(setText(const QString)));
+    QObject::connect(&connector, SIGNAL(updateCurrentPCTime(QString)),
+                     myUi.PCTimeLabel, SLOT(setText(const QString)));
+    QObject::connect(&connector, SIGNAL(updateCurrentSoftTrigger(QString)),
+                     myUi.softwareTriggerLabel, SLOT(setText(const QString)));
+    QObject::connect(&connector, SIGNAL(updateCurrentTriggerType(QString)),
+                     myUi.triggerTypeLabel, SLOT(setText(const QString)));
+
+    mainWindow.show();
+
+    return app.exec();
+}
Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 11540)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h	(revision 11540)
@@ -0,0 +1,221 @@
+/*
+ * QtGl.h
+ *
+ *  Created on: Jul 20, 2011
+ *      Author: lyard
+ */
+
+#ifndef QTGL_H_
+#define QTGL_H_
+
+#define NBOARDS      40      // max. number of boards
+#define NPIX       1440      // max. number of pixels
+#define NTMARK      160      // max. number of timeMarker signals
+
+//#define LOAD_RAW
+
+#include <QtCore/QObject>
+#include <QtCore/QTimer>
+#include <QtGui/QLabel>
+#include <QtGui/QListWidget>
+#include <QtGui/QMainWindow>
+#include <QtOpenGL/QGLWidget>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QColorDialog>
+#include <QtGui/QApplication>
+#include <iostream>
+#include <GL/gl.h>
+
+#define __MARS__
+#include <MFits.h>
+#include <string>
+using namespace std;
+
+
+#define NUM_STORED_EVENTS 5
+#define MAX_NUM_PIXELS 1600
+#define ACTUAL_NUM_PIXELS 1440
+
+///structure for storing edges of hexagons (for blurry display)
+struct edge
+{
+    int first;
+    int second;
+};
+
+///structure for storing neighbors of pixels. For camera position calculation and blurry display
+struct PixelsNeighbors
+{
+    //neighbors. clockwise, starting from top
+    int neighbors[6];
+    PixelsNeighbors()
+    {
+        for (int i=0;i<6;i++)
+            neighbors[i] = -1;
+    }
+    int& operator[](int index){return neighbors[index];}
+};
+
+/*************************************************
+ * Class Raw Data Viewer. FACT raw data diplayer
+ *************************************************/
+class RawDataViewer : public QGLWidget
+{
+    Q_OBJECT
+
+    friend class UIConnector;
+public:
+    RawDataViewer(QWidget *parent = 0);
+    ~RawDataViewer();
+    void openFile(string& filename);
+
+public Q_SLOTS:
+    void plusEvent();
+    void minusEvent();
+    void setEventStep(int step);
+    void nextSlice();
+
+Q_SIGNALS:
+    void signalCurrentEvent(int event);
+    void signalCurrentSlice(int slice);
+    void newFileLoaded();
+
+protected:
+    void initializeGL();
+    void resizeGL(int width, int height);
+    void paintGL();
+    void mousePressEvent(QMouseEvent *event);
+    void mouseMoveEvent(QMouseEvent *event);
+    void mouseDoubleClickEvent(QMouseEvent *event);
+
+private:
+    void drawCamera(bool alsoWire);
+    void drawPixelCurve();
+    void drawPatches();
+    int PixelAtPosition(const QPoint &pos);
+    void updateNeighbors(int currentPixel);
+    void skipPixels(int start, int howMany);
+    void calculatePixelsCoords();
+    void drawHexagon(int index, bool solid);
+    void setCorrectSlice(QMouseEvent* event);
+    bool IsFits(const char* name);
+    void eventStepping(bool plus);
+    void buildVerticesList();
+    void buildPatchesIndices();
+    void calcBlurColor(int pixel, int vertex);
+    void drawBlurryHexagon(int index);
+    float hexRadius;
+    float hexTolerance;
+    float viewSize;
+    int whichSlice;
+    int selectedPixel;
+    float pixelSize;
+    float shownSizex;
+    float shownSizey;
+    bool drawPatch;
+    bool drawImpulse;
+    bool drawBlur;
+    //allocate the maximum size for one event
+    int16_t *eventData;
+    uint32_t boardTime[NBOARDS];
+    int16_t startPix[NPIX];
+    int16_t startTM[NTMARK];
+    uint32_t pcTime;
+    uint32_t softTrig;
+    uint16_t triggerType;
+    int nRows;
+    int rowNum;
+    int eventNum;
+    int nRoi;
+    int runNumber;
+    int nTM;
+    int runType;
+    int firstDataTime;
+    int lastDataTime;
+    int eventStep;
+
+    int hardwareMapping[1440];
+    int patches[160][9];
+    GLfloat patchesColor[160][3];
+    vector<edge> patchesIndices[160];
+    MFits* inputFile;
+
+    QPoint lastPos;
+
+    GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
+    PixelsNeighbors neighbors[MAX_NUM_PIXELS];
+    GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
+    GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
+    int verticesIndices[ACTUAL_NUM_PIXELS][6];
+    int numVertices;
+};
+/*************************************************
+ * Class UIConnector. used to connect the interface to the raw data displayer
+ *************************************************/
+class UIConnector : public QObject
+{
+    Q_OBJECT
+public:
+    UIConnector(QWidget *parent = 0);
+    void setViewer(RawDataViewer* v);
+
+public Q_SLOTS:
+    void loadNewFileClicked();
+    void fileSelected(QString file);
+    void drawPatchesCheckChange(int state);
+    void drawImpulseCheckChange(int state);
+    void drawBlurCheckChange(int state);
+    void newFileLoaded();
+    void playPauseClicked();
+    void slicesPerSecondChanged(double value);
+    void nextSlicePlease();
+    void currentSliceHasChanged(int slice);
+    void currentEventHasChanged(int event);
+    void rangeChanged0(double value);
+    void rangeChanged1(double value);
+    void rangeChanged2(double value);
+    void rangeChanged3(double value);
+    void rangeChanged4(double value);
+    void redChanged0(double value);
+    void redChanged1(double value);
+    void redChanged2(double value);
+    void redChanged3(double value);
+    void redChanged4(double value);
+    void greenChanged0(double value);
+    void greenChanged1(double value);
+    void greenChanged2(double value);
+    void greenChanged3(double value);
+    void greenChanged4(double value);
+    void blueChanged0(double value);
+    void blueChanged1(double value);
+    void blueChanged2(double value);
+    void blueChanged3(double value);
+    void blueChanged4(double value);
+
+Q_SIGNALS:
+    void updateCurrentSliceDisplay(QString);
+    void updateCurrentEventDisplay(QString);
+    void updateCurrentPCTime(QString);
+    void updateCurrentSoftTrigger(QString);
+    void updateCurrentTriggerType(QString);
+
+
+private:
+    RawDataViewer* viewer;
+    QTimer timer;
+    string currentFile;
+public:
+    QListWidget *boardsTimeList;
+    QListWidget* startPixelsList;
+    QListWidget* startTimeMarksList;
+    QLabel*      fileLoadedLabel;
+    QLabel*      runNumberLabel;
+    QLabel*      numberOfSlicesLabel;
+    QLabel*      numberOfTimeMarksLabel;
+    QLabel*      runTypeLabel;
+    QLabel*      firstTimeLabel;
+    QLabel*      lastTimeLabel;
+
+};
+
+#endif /* QTGL_H_ */
Index: /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.ui
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.ui	(revision 11540)
+++ /trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.ui	(revision 11540)
@@ -0,0 +1,551 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1125</width>
+    <height>928</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QGridLayout" name="gridLayout_2">
+    <item row="0" column="0">
+     <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="10,0">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0">
+        <property name="sizeConstraint">
+         <enum>QLayout::SetDefaultConstraint</enum>
+        </property>
+        <item>
+         <widget class="RawDataViewer" name="GLWindow" native="true"/>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0">
+        <property name="sizeConstraint">
+         <enum>QLayout::SetDefaultConstraint</enum>
+        </property>
+        <item>
+         <widget class="QLabel" name="label">
+          <property name="text">
+           <string>FACT - Raw events viewer - v0.1</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="fileLoadedLabel">
+          <property name="text">
+           <string>File loaded: none</string>
+          </property>
+          <property name="wordWrap">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="runNumberLabel">
+          <property name="text">
+           <string>Run number:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="numberOfSlicesLabel">
+          <property name="text">
+           <string>Number of Events/Slices:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="numberOfTimeMarksLabel">
+          <property name="text">
+           <string>Number of Time Marks:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="runTypeLabel">
+          <property name="text">
+           <string>Run Type:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="timeOfFirstDataLabel">
+          <property name="text">
+           <string>Time of 1st data:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="timeOfLastDataLabel">
+          <property name="text">
+           <string>Time of last data:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_5">
+          <item>
+           <widget class="QLabel" name="label_8">
+            <property name="font">
+             <font>
+              <pointsize>12</pointsize>
+              <weight>75</weight>
+              <bold>true</bold>
+             </font>
+            </property>
+            <property name="text">
+             <string>Arrays data</string>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="label_9">
+            <property name="text">
+             <string>Boards times</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QListWidget" name="boardsTimeList">
+            <property name="font">
+             <font>
+              <family>FreeMono</family>
+             </font>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="label_13">
+            <property name="text">
+             <string>Start Pixels</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QListWidget" name="startPixelsList">
+            <property name="font">
+             <font>
+              <family>FreeMono</family>
+             </font>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="StartTimeMarksList">
+            <property name="text">
+             <string>Start Time Marks</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QListWidget" name="startTimeMarksList">
+            <property name="font">
+             <font>
+              <family>FreeMono</family>
+             </font>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_4">
+          <property name="spacing">
+           <number>2</number>
+          </property>
+          <item>
+           <widget class="QLabel" name="label_7">
+            <property name="font">
+             <font>
+              <pointsize>12</pointsize>
+              <weight>75</weight>
+              <bold>true</bold>
+             </font>
+            </property>
+            <property name="text">
+             <string>Current Event Information</string>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="displayingEventLabel">
+            <property name="text">
+             <string>Displaying Event 0</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="displayingSliceLabel">
+            <property name="text">
+             <string>Displaying Slice 0</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="triggerTypeLabel">
+            <property name="text">
+             <string>Trigger Type:</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="softwareTriggerLabel">
+            <property name="text">
+             <string>Software Trigger: </string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="PCTimeLabel">
+            <property name="text">
+             <string>PC Time:</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_3"/>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </item>
+    <item row="1" column="0">
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="6">
+       <widget class="QDoubleSpinBox" name="colorRange4">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="6">
+       <widget class="QDoubleSpinBox" name="greenValue4">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="6">
+       <widget class="QDoubleSpinBox" name="redValue4">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="7">
+       <widget class="QPushButton" name="playPauseButton">
+        <property name="text">
+         <string>Play/Pause</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="6">
+       <widget class="QDoubleSpinBox" name="blueValue4">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="5">
+       <widget class="QDoubleSpinBox" name="redValue3">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="7">
+       <widget class="QPushButton" name="loadNewFileButton">
+        <property name="text">
+         <string>Load New File</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="4">
+       <widget class="QDoubleSpinBox" name="redValue2">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="3">
+       <widget class="QDoubleSpinBox" name="redValue1">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2">
+       <widget class="QDoubleSpinBox" name="redValue0">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLabel" name="label_20">
+        <property name="text">
+         <string>Red</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QLabel" name="label_21">
+        <property name="text">
+         <string>Ranges</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QLabel" name="label_22">
+        <property name="text">
+         <string>Green</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1">
+       <widget class="QLabel" name="label_23">
+        <property name="text">
+         <string>Blue</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <widget class="QDoubleSpinBox" name="colorRange0">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="2">
+       <widget class="QDoubleSpinBox" name="greenValue0">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="2">
+       <widget class="QDoubleSpinBox" name="blueValue0">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="3">
+       <widget class="QDoubleSpinBox" name="colorRange1">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="3">
+       <widget class="QDoubleSpinBox" name="greenValue1">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="3">
+       <widget class="QDoubleSpinBox" name="blueValue1">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="4">
+       <widget class="QDoubleSpinBox" name="colorRange2">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="4">
+       <widget class="QDoubleSpinBox" name="greenValue2">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="4">
+       <widget class="QDoubleSpinBox" name="blueValue2">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="5">
+       <widget class="QDoubleSpinBox" name="colorRange3">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="5">
+       <widget class="QDoubleSpinBox" name="greenValue3">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="5">
+       <widget class="QDoubleSpinBox" name="blueValue3">
+        <property name="decimals">
+         <number>3</number>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="7">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QLabel" name="label_24">
+          <property name="text">
+           <string>Slices per sec</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QDoubleSpinBox" name="slicesPerSecValue">
+          <property name="maximum">
+           <double>1000.000000000000000</double>
+          </property>
+          <property name="singleStep">
+           <double>1.000000000000000</double>
+          </property>
+          <property name="value">
+           <double>1.000000000000000</double>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item row="1" column="7">
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <widget class="QLabel" name="label_2">
+          <property name="text">
+           <string>Events stepping</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="eventsMinusButton">
+          <property name="text">
+           <string>-</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="eventsStepBox">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+          <property name="maximum">
+           <number>9999</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="eventsPlusButton">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>+</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item row="0" column="0">
+       <widget class="QCheckBox" name="drawImpulseCheckBox">
+        <property name="layoutDirection">
+         <enum>Qt::RightToLeft</enum>
+        </property>
+        <property name="text">
+         <string>Draw Impulse</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0">
+       <widget class="QCheckBox" name="drawBlurCheckBox">
+        <property name="layoutDirection">
+         <enum>Qt::RightToLeft</enum>
+        </property>
+        <property name="text">
+         <string>Blur pixels</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QCheckBox" name="drawPatchCheckBox">
+        <property name="layoutDirection">
+         <enum>Qt::RightToLeft</enum>
+        </property>
+        <property name="text">
+         <string>Draw Patches</string>
+        </property>
+        <property name="tristate">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QGLWidget</class>
+   <extends>QWidget</extends>
+   <header>QtOpenGL/QGLWidget</header>
+  </customwidget>
+  <customwidget>
+   <class>RawDataViewer</class>
+   <extends>QGLWidget</extends>
+   <header>RawEventsViewer.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
Index: /trunk/FACT++/gui/RawEventsViewer/Trigger-Patches.txt
===================================================================
--- /trunk/FACT++/gui/RawEventsViewer/Trigger-Patches.txt	(revision 11540)
+++ /trunk/FACT++/gui/RawEventsViewer/Trigger-Patches.txt	(revision 11540)
@@ -0,0 +1,161 @@
+#Trigger Patches (SoftID), sorted by PatchHardID [110610, TPK]
+1348	1419	1249	1349	1420	1250	1350	1421	1251
+1345	1416	1246	1346	1417	1247	1347	1418	1248
+1025	917	1138	1024	916	1137	1023	915	1136
+1022	914	1135	1021	913	1134	1020	912	1133
+1145	1031	1144	1030	922	1029	921	819	920
+1356	1355	1260	1146	1354	1259	1258	1257	1143
+1256	1142	1141	1255	1028	1027	919	1026	918
+1140	1254	1139	1353	1253	1352	1252	1438	1351
+1148	1034	1147	1033	925	1032	924	822	923
+1424	1359	1358	1263	1423	1422	1357	1262	1261
+821	725	820	724	634	723	633	549	632
+548	470	547	469	397	546	468	396	545
+818	722	817	721	631	816	720	630	815
+719	629	814	718	628	813	717	627	812
+716	626	811	715	625	810	714	624	809
+467	395	544	466	394	543	465	393	542
+1365	1429	1364	1363	1268	1362	1267	1266	1152
+1428	1427	1426	1361	1425	1360	1265	1264	1149
+1151	1037	1150	1036	928	1035	927	825	926
+824	728	823	727	637	726	636	552	635
+551	473	550	472	400	471	399	333	398
+332	272	331	271	217	330	270	216	329
+269	215	328	268	214	327	267	213	326
+464	392	541	463	391	540	462	390	539
+1273	1367	1272	1158	1366	1271	1270	1269	1155
+1154	1040	1153	1039	931	1038	930	828	929
+827	731	826	730	640	729	639	555	638
+554	476	553	475	403	474	402	336	401
+335	275	334	274	220	273	219	171	218
+170	128	169	127	91	168	126	90	167
+173	131	172	130	94	129	93	63	92
+62	38	61	37	19	60	36	18	59
+1157	1043	1156	1042	934	1041	933	831	932
+830	734	829	733	643	732	642	558	641
+557	479	556	478	406	477	405	339	404
+338	278	337	277	223	276	222	174	221
+1160	1161	1159	1045	1046	1044	936	937	935
+833	834	832	736	737	735	645	646	644
+560	561	559	481	482	480	408	409	407
+341	342	340	280	281	279	225	226	224
+176	177	175	133	134	132	96	97	95
+65	66	64	40	41	39	21	22	20
+68	69	42	43	44	23	24	45	10
+8	9	7	1	2	6	0	3	5
+344	345	282	283	284	227	228	229	178
+179	180	135	136	137	98	99	100	67
+182	183	138	139	140	101	102	141	70
+103	142	71	104	143	72	105	144	73
+1368	1274	1275	1162	1369	1276	1277	1278	1165
+1163	1164	1047	1048	1049	938	939	940	835
+836	837	738	739	740	647	648	649	562
+563	564	483	484	485	410	411	412	343
+1430	1370	1371	1372	1373	1279	1280	1281	1168
+1166	1167	1050	1051	1052	941	942	943	838
+839	840	741	742	743	650	651	652	565
+566	567	486	487	488	413	414	415	346
+350	351	288	289	290	233	234	291	184
+347	348	285	286	287	230	231	232	181
+421	496	353	422	497	354	423	498	355
+235	292	185	236	293	186	237	294	187
+1431	1432	1433	1374	1434	1375	1282	1283	1171
+1169	1170	1053	1054	1055	944	945	946	841
+842	843	744	745	746	653	654	655	568
+569	570	489	490	491	416	417	418	349
+1435	1376	1377	1284	1436	1437	1378	1285	1286
+1172	1173	1056	1057	1058	947	948	949	844
+845	846	747	748	749	656	657	658	571
+572	573	492	493	494	419	420	495	352
+1379	1380	1287	1174	1381	1288	1289	1290	1177
+1175	1176	1059	1060	1061	950	951	952	847
+1291	1178	1179	1180	1062	1063	953	954	850
+848	849	750	751	752	659	660	753	574
+661	754	575	662	755	576	663	756	577
+664	757	578	665	758	579	666	759	580
+958	1069	854	959	1070	855	960	1071	856
+961	1072	857	962	1073	858	963	1074	859
+1064	1181	1292	1065	1182	1293	1439	1183	1294
+955	1066	851	956	1067	852	957	1068	853
+1297	1186	1384	1296	1185	1383	1295	1184	1382
+1300	1189	1387	1299	1188	1386	1298	1187	1385
+1306	1195	1393	1305	1194	1392	1304	1193	1391
+1303	1192	1390	1302	1191	1389	1301	1190	1388
+967	1078	863	968	1079	864	969	1080	865
+964	1075	860	965	1076	861	966	1077	862
+769	868	770	869	974	870	975	1086	976
+1085	1202	1203	1309	1087	1088	1204	1310	1205
+970	866	971	867	972	973	1084	1200	1201
+1196	1307	1197	1308	1081	1198	1082	1199	1083
+772	871	773	872	977	873	978	1089	979
+1090	1206	1091	1207	1311	1312	1394	1313	1395
+508	589	509	590	677	591	678	771	679
+430	505	362	431	506	363	432	507	433
+673	766	587	674	767	588	675	768	676
+670	763	584	671	764	585	672	765	586
+427	502	359	428	503	360	429	504	361
+667	760	581	668	761	582	669	762	583
+1094	1210	1211	1317	1399	1318	1400	1319	1401
+1208	1209	1093	1316	1315	1396	1397	1314	1398
+775	874	776	875	980	876	981	1092	982
+511	592	512	593	680	594	681	774	682
+301	364	302	365	434	366	435	510	436
+241	298	191	242	299	192	243	300	244
+238	295	188	239	296	189	240	297	190
+424	499	356	425	500	357	426	501	358
+1096	1212	1097	1213	1214	1320	1215	1321	1322
+778	877	779	878	983	879	984	1095	985
+514	595	515	596	683	597	684	777	685
+304	367	305	368	437	369	438	513	439
+148	193	149	194	245	195	246	303	247
+106	145	74	107	146	75	108	147	109
+49	76	50	77	110	78	111	150	112
+25	46	11	26	47	12	27	48	28
+781	880	782	881	986	882	987	1098	988
+517	598	518	599	686	600	687	780	688
+307	370	308	371	440	372	441	516	442
+151	196	152	197	248	198	249	306	250
+784	883	885	884	991	1105	1104	1219	1218
+1099	989	1100	1216	990	1101	1103	1217	1102
+520	601	603	602	689	691	690	783	785
+310	373	375	374	443	445	444	519	521
+154	199	201	200	251	253	252	309	311
+52	79	81	80	113	115	114	153	155
+4	13	15	14	29	31	30	51	53
+35	17	58	34	16	57	33	32	56
+157	156	204	203	202	256	255	254	314
+55	54	84	83	82	118	117	116	158
+122	86	163	121	85	162	120	119	161
+125	89	166	124	88	165	123	87	164
+1108	1107	1223	1222	1221	1220	1325	1324	1323
+787	786	888	887	886	994	993	992	1106
+523	522	606	605	604	694	693	692	788
+313	312	378	377	376	448	447	446	524
+1110	1225	1224	1328	1327	1404	1326	1403	1402
+790	789	891	890	889	997	996	995	1109
+526	525	609	608	607	697	696	695	791
+316	315	381	380	379	451	450	449	527
+263	209	322	262	208	321	261	260	320
+160	159	207	206	205	259	258	257	317
+461	389	538	460	388	537	459	387	536
+266	212	325	265	211	324	264	210	323
+1111	1227	1226	1329	1331	1330	1407	1406	1405
+793	792	894	893	892	1000	999	998	1112
+529	528	612	611	610	700	699	698	794
+319	318	384	383	382	454	453	452	530
+1114	1113	1229	1228	1334	1333	1332	1409	1408
+796	795	897	896	895	1003	1002	1001	1115
+532	531	615	614	613	703	702	701	797
+458	386	535	457	385	534	456	455	533
+1119	1233	1232	1336	1117	1116	1231	1230	1335
+799	798	900	899	898	1006	1005	1004	1118
+1010	902	1009	901	1008	1007	1120	1235	1234
+707	617	802	706	616	801	705	704	800
+710	620	805	709	619	804	708	618	803
+713	623	808	712	622	807	711	621	806
+1016	908	1129	1015	907	1128	1014	906	1127
+1019	911	1132	1018	910	1131	1017	909	1130
+1239	1338	1238	1337	1123	1237	1122	1236	1121
+1013	905	1126	1012	904	1125	1011	903	1124
+1339	1410	1240	1340	1411	1241	1341	1412	1242
+1342	1413	1243	1343	1414	1244	1344	1415	1245
