Commit 1b9442a5 authored by Sam Wood's avatar Sam Wood Committed by Simon Spannagel
Browse files

Remove unnecessary dimensionality checks

Checks already exist in src/tools/field_parser.h
parent ce29cc0b
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -68,19 +68,11 @@ void MagneticFieldReaderModule::initialize() {
        auto fallback_field = config_.get<ROOT::Math::XYZVector>("magnetic_field_fallback", ROOT::Math::XYZVector());
        auto field_data = read_field();

        auto dims = field_data.getDimensionality(); // Vector dimensionality of the field (should be 3 for B-field)
        if(dims != 3) {
            throw std::invalid_argument("B-field vectors were not three dimensional.");
        }

        auto dims = field_data.getDimensionality(); // Vector dimensionality of the field (will be 3 for B-field)
        auto cellsize = field_data.getSize();       // Physical dimensions for each cell in the field mesh
        auto ncells = field_data.getDimensions();   // Number of cells in each direction of the field mesh
        auto field_mesh = field_data.getData();     // The field mesh B-field data as a flattened array

        if(ncells[0] * ncells[1] * ncells[2] * dims != field_mesh->size()) {
            throw std::invalid_argument("B-field does not span the given dimensions");
        }

        MagneticFieldFunction function =
            [fallback_field, field_mesh, cellsize, ncells, dims](const ROOT::Math::XYZPoint& coord) {
                // Find the nearest field mesh cell to the given input coordinate (assuming the mesh is centred about the