 	    }
 	}
       
-      dim3 grid(25, 40, 24);
-      dim3 block(2, 1, 50);
+      dim3 grid(1, 400, 24);
+      dim3 block(1, 7, 50);
 
       spherer.rfactor = 0.005;
       spherer.roffset = -10;
-      spherer.baseoffsetx = NX / 2 - 30 - 0.5;
-      spherer.baseoffsety = NY / 2 - 10 - 0.5;
+      spherer.baseoffsetx = NX / 2 + 70 - 0.5; // good val -10
+      spherer.baseoffsety = NY / 2 + 70 - 0.5; // good val +10
       dPhotons.assign(photonVals.data(), photonVals.data() + NY * NX);
       dLambdas.assign(lambdaVals.data(), lambdaVals.data() + NY * NX);
       

	}
	if (hIntensity[k] < minval) minval = hIntensity[k];
}
	int maxR = maxidx / 40 / 50;
	int maxX = maxidx % 50;
	int maxY = (maxidx / 50) % 40;

      printf("%d %d %lf %g %g %g %d %d %d %d %g\n", img, psum, lsum, minval, maxval, hIntensity[0], maxR, maxX, maxY, cudaGetLastError(), maxint);
      fflush(stdout);

target[idx] = -1e10;
intens[idx] = 0;
}
  intensityfactor *= pow(1.01, blockIdx.y - gridDim.y * 0.5);
  likelihood likelihooder(myspherer, intensityfactor);
  float likelihood1 = thrust::reduce(thrust::seq,
				   thrust::make_transform_iterator(thrust::make_counting_iterator(0), likelihooder),
				   thrust::make_transform_iterator(thrust::make_counting_iterator(NY * NX), likelihooder));

  target[idx] = likelihood1;
  intens[idx] = likelihooder.factor;
}

int main()
