827{
828
829 std::vector<size_t> dose_map(
nxy);
830 std::vector<size_t> sumx_map(
nxy);
831 std::vector<size_t> sumy_map(
nxy);
832 std::vector<uint16_t> frame(camera_spec->nx_cam * camera_spec->ny_cam);
833 std::vector<uint16_t> *p_frame = &frame;
834
836
837
840
841 std::array<float, 2> com_xy = {0.0, 0.0};
842 std::array<float, 2> *p_com_xy = &com_xy;
843 std::array<float, 2> com_xy_sum = {0.0, 0.0};
844
845 int ix = 0;
846 int iy = 0;
847 int acc_cbed = 0;
848 int acc_idx = 0;
849
850 size_t img_num = 0;
851 size_t first_frame = img_num *
nxy;
852 size_t end_frame = (img_num + 1) *
nxy;
853 size_t fr_total_u = (size_t)
fr_total;
854
857
858 dose_map.assign(
nxy, 0);
859 sumx_map.assign(
nxy, 0);
860 sumy_map.assign(
nxy, 0);
861 reinit_vectors_limits();
862
863 while (true)
864 {
865
866
867 int idxx = prog_mon.fr_count -
nxy * img_num - 2;
868
869 ++prog_mon;
871
873 {
874
875 if (acc_cbed == 0)
876 {
877 frame.assign(camera_spec->nx_cam * camera_spec->ny_cam, 0);
879 }
880 camera_spec->read_frame_com_cbed(prog_mon.fr_count,
881 dose_map, sumx_map, sumy_map,
885 first_frame, end_frame);
886 acc_cbed++;
887 }
888 else
889 {
890 camera_spec->read_frame_com(prog_mon.fr_count,
891 dose_map, sumx_map, sumy_map,
894 first_frame, end_frame);
895 }
896
897 if (idxx >= 0)
898 {
899
900 if (dose_map[idxx] == 0)
901 {
904 }
905 else
906 {
907
908 com_xy[0] = static_cast<float>(sumx_map[idxx]) / static_cast<float>(dose_map[idxx]);
909 com_xy[1] = static_cast<float>(sumy_map[idxx]) / static_cast<float>(dose_map[idxx]);
910 }
913 com_xy_sum[0] += com_xy[0];
914 com_xy_sum[1] += com_xy[1];
915
917 iy = floor(idxx /
nx);
918
920 {
922 { icom(com_xy, ix, iy); });
923 }
924 else
925 {
926 icom(p_com_xy, ix, iy);
927 }
929 {
930 compute_electric_field(com_xy, idxx);
931 }
932 }
933
934 if (prog_mon.report_set)
935 {
936 update_surfaces(iy, p_frame);
938 {
939
940 acc_cbed = 0;
941 }
943 rescales_recomputes();
944 for (int i = 0; i < 2; i++)
945 {
946 com_public[i] = com_xy_sum[i] / prog_mon.fr_count_i;
947 com_xy_sum[i] = 0;
948 }
949 prog_mon.reset_flags();
951 }
952
953 if (prog_mon.fr_count >= end_frame)
954 {
955 if (prog_mon.fr_count != fr_total_u)
956 {
957 img_num++;
958 first_frame = img_num *
nxy;
959 end_frame = (img_num + 1) *
nxy;
960 reinit_vectors_limits();
961 dose_map.assign(
nxy, 0);
962 sumx_map.assign(
nxy, 0);
963 sumy_map.assign(
nxy, 0);
964 }
965
967 {
970 }
971 }
972
973 if (prog_mon.fr_count == fr_total_u ||
rc_quit)
974 {
977 return;
978 }
979 }
981}
void init(int n_threads, int limit)
void push_task(const T &task)
void wait_for_completion()
std::array< float, 2 > radius2