20 double lowery,
double lengthx,
double lengthy) : mNx{Nx},
22 mLxOfCell{lengthx / Nx},
23 mLyOfCell{lengthy / Ny},
24 mInvLxOfCell{1. / mLxOfCell},
25 mInvLyOfCell{1. / mLyOfCell},
29 mImageData.resize(Nx);
30 for (
int x = 0;
x < Nx; ++
x) {
31 mImageData[
x].resize(Ny);
34 std::cout <<
" Image initialized with " << mNx <<
" x " << mNy <<
" pixels ";
39 const int xpixel = (
int)(std::floor((
x - mLowerX) * mInvLxOfCell));
40 const int ypixel = (
int)(std::floor((
y - mLowerY) * mInvLyOfCell));
42 std::cerr <<
"negative photon number\n";
45 if (xpixel < 0 || xpixel >= mNx) {
46 std::cerr <<
"X-PIXEL OUT OF RANGE " << xpixel <<
" " <<
x <<
" , " <<
y <<
"\n";
49 if (ypixel < 0 || ypixel >= mNy) {
50 std::cerr <<
"Y-PIXEL OUT OF RANGE " << ypixel <<
" " <<
x <<
" , " <<
y <<
"\n";
53 mImageData[xpixel][ypixel] += nphotons;
54 mPhotonSum += nphotons;
60 std::cout <<
"Response START " << mPhotonSum <<
" ----\n";
61 for (
int y = mNy - 1;
y >= 0; --
y) {
63 for (
int x = 0;
x < mNx; ++
x) {
64 const auto val = mImageData[
x][
y];
66 std::cerr <<
"SHIT\n";
73 std::cout <<
"Response END ----\n";
79 for (
int x = 0;
x < mNx; ++
x) {
81 for (
int y = 0;
y < mNy; ++
y) {
92 std::array<int, 5> photonsum = {0, 0, 0, 0, 0};
93 if (mPhotonSum == 0) {
97 if (mDetectorID == -1) {
98 std::cerr <<
"SpatialPhotonResponse has no detectorID ";
102 auto determineChannel = [](
int detector,
int x,
int y,
int Nx,
int Ny) {
103 if ((
x +
y) % 2 == 0) {
124 auto i = (
int)(4.f *
x / Nx);
131 for (
int x = 0;
x < mNx; ++
x) {
133 for (
int y = 0;
y < mNy; ++
y) {
135 int channel = determineChannel(mDetectorID,
x,
y, mNx, mNy);
136 photonsum[channel] += mImageData[
x][
y];
145void SpatialPhotonResponse::printErrMsg(
const char*
str)
const
147 std::cerr <<
str <<
"\n";
Visualizing spatial photon response in ZDC neutron and proton calorimeters.
void printToScreen() const
void addPhoton(double x, double y, int nphotons)
SpatialPhotonResponse()=default
std::array< int, 5 > getPhotonsPerChannel() const
float sum(float s, o2::dcs::DataPointValue v)
std::string to_string(gsl::span< T, Size > span)