Allow to leave out coordinates in BDSIM field map format

Issue #290 new
Jochem Snuverink created an issue

From Hui Zhang:

I would also suggest the other simplification to save space. At present, the maps has a head in form of xmin, xmax, nx, ymin, ymax, ny, zmin, zmax, nz, and then the body in form of x, y, z, fx, fy, fz. I would suggest to leave out all, x, y, z coordinates, as it can be calculate from the min, max, and n. I even have the impression, BDSIM does not use x, y, z at all. Instead, it uses only min, max, and n to calculate coordinates.

Indeed the coordinates are not used, from BDSFieldLoaderBDSIM.cc:

// read all columns - indices shifted +1 for default value offset
for (unsigned long i = 1; i < nColumns+1; ++i)
  {
    liness >> value;
    if (i < xIndex)
    // x is the first field value - coordinates before that
       {value *= CLHEP::cm;}
       lineData[i] = value;
  }
  // Construct field value
  fv = BDSFieldValue(lineData[xIndex],lineData[yIndex],lineData[zIndex]);
}

This would be easy to implement, as it requires just a removal of the check on the number of columns. I can implement this if there are no objections.

Comments (4)

  1. Laurie Nevay

    Yes, this could certainly be done and you correctly identify that we don’t need this information. Until recently, it wasn’t really possible to visualise magnetic fields in the Geant4 visualiser so this was more for the user to validate their preparation of the fields - common mistakes are incorrect looping order on dimensions when preparing them.

    It so far hasn’t been too much of a problem as files can be compressed with gzip and read in compressed, but of course, the files could be smaller.

    We could make this an alternative format so both are accepted. We definitely have to be backwards compatible and it be clear from the input which format is being loaded for that particular file (maybe others in old format).

    The pybdsim Field classes should also be extended to write this format from a numpy array.

  2. Laurie Nevay

    This hasn’t been done yet, however, we now have the ability for various field reflections in bdsim in the develop version. Leaving issue open.

  3. Log in to comment