Commit 07cb33b7 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'dopingImportFix' into 'master'

Fixed mesh_converter so that it can handle coordinate system replacement of scalar fields properly

See merge request allpix-squared/allpix-squared!819
parents c9f8c0a0 97119e4d
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -240,7 +240,6 @@ int main(int argc, char** argv) {
            throw std::runtime_error("Field and grid file do not match, found " + std::to_string(points.size()) + " and " +
                                     std::to_string(field.size()) + " data points, respectively.");
        }

        auto points_temp = points;
        auto field_temp = field;
        if(rot.at(0) == "-y" || rot.at(0) == "y") {
@@ -496,12 +495,23 @@ int main(int argc, char** argv) {
            for(unsigned int j = 0; j < divisions.y(); ++j) {
                for(unsigned int k = 0; k < divisions.z(); ++k) {
                    auto& point = e_field_new_mesh[i * divisions.y() * divisions.z() + j * divisions.z() + k];
                    // We need to convert to framework-internal units:
                    data->push_back(Units::get(point.x, units));
                    LOG(DEBUG) << "Values of data point (" << i << ", " << j << ", " << k << "): " << point;
                    // For a vector field, we push three values:
                    if(quantity == FieldQuantity::VECTOR) {
                        // We need to convert to framework-internal units:
                        data->push_back(Units::get(point.x, units));
                        data->push_back(Units::get(point.y, units));
                        data->push_back(Units::get(point.z, units));
                    } else {
                        // For a scalar field, we need to push only one value, but which one depends on the field rotation.
                        // We need the original x-position, as that is the only filled one in the parsed field
                        if(rot.at(1) == "-x" || rot.at(1) == "x") {
                            data->push_back(Units::get(point.y, units));
                        } else if(rot.at(2) == "-x" || rot.at(2) == "x") {
                            data->push_back(Units::get(point.z, units));
                        } else {
                            data->push_back(Units::get(point.x, units));
                        }
                    }
                }
            }
+7 −4
Original line number Diff line number Diff line
@@ -261,13 +261,16 @@ int main(int argc, char** argv) {
                            plot_x,
                            plot_y,
                            sqrt(pow(data->at(base + 0), 2) + pow(data->at(base + 1), 2) + pow(data->at(base + 2), 2)));
                        exfield_map->Fill(plot_x, plot_y, data->at(base + 0));
                        eyfield_map->Fill(plot_x, plot_y, data->at(base + 1));
                        ezfield_map->Fill(plot_x, plot_y, data->at(base + 2));
                        exfield_map->Fill(plot_x, plot_y, static_cast<double>(Units::convert(data->at(base + 0), units)));
                        eyfield_map->Fill(plot_x, plot_y, static_cast<double>(Units::convert(data->at(base + 1), units)));
                        ezfield_map->Fill(plot_x, plot_y, static_cast<double>(Units::convert(data->at(base + 2), units)));

                    } else {
                        // Fill one map with the scalar quantity
                        efield_map->Fill(plot_x, plot_y, data->at(x * ydiv * zdiv + y * zdiv + z));
                        efield_map->Fill(
                            plot_x,
                            plot_y,
                            static_cast<double>(Units::convert(data->at(x * ydiv * zdiv + y * zdiv + z), units)));
                    }
                }
            }