Commit 6ab2663f authored by Stephan Lachnit's avatar Stephan Lachnit
Browse files

Merge branch 'b-gdml-rot' into 'v2.4-stable'

[v2.4-stable]  GDML processing code fixes and visualisation rotations

See merge request allpix-squared/allpix-squared!934
parents 33c8014c 0c823a63
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -96,8 +96,13 @@ namespace allpix {

                // Add offset and rotation to current daughter location
                G4ThreeVector position_vector = toG4Vector(position_);
                auto* rotation_matrix = new G4RotationMatrix(*gdml_daughter->GetRotation() * *rotation_);
                gdml_daughter->SetTranslation(gdml_daughter->GetTranslation() + position_vector);
                auto* daughter_rotation = gdml_daughter->GetRotation();
                // It seems that in the case of a trivial rotation the daughter_rotation can be a nullptr
                auto* rotation_matrix =
                    ((daughter_rotation != nullptr) ? new G4RotationMatrix(*daughter_rotation * *rotation_)
                                                    : new G4RotationMatrix(*rotation_));
                LOG(TRACE) << "Rotation matrix: " << *rotation_matrix;
                gdml_daughter->SetTranslation((rotation_->inverse()) * gdml_daughter->GetTranslation() + position_vector);
                gdml_daughter->SetRotation(rotation_matrix);

                // Check if color information is available and set it to the daughter volume
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ This module requires an installation of Geant4.
* `draw_hits` : Determines if hits in the detector should be displayed. Defaults to false. Option is only useful if Geant4 hits are generated in a module.
* `macro_init` : Optional Geant4 macro to execute during initialization. Whenever possible, the configuration parameters above should be used instead of this option.
* `display_limit` : Sets the `displayListLimit` of the visualization GUI, in case the geometry which has to be loaded is too complex for the GUI to be displayed with the current size Display List. Defaults to 1000000.
* `viewpoint_thetaphi` : Sets the theta and phi angles for the viewpoint. Defaults to -70deg 20deg.

### Usage
An example configuration providing a wireframe viewing style with the same color for every particle and displaying the result after every event for 2s is provided below:
+10 −1
Original line number Diff line number Diff line
@@ -277,7 +277,16 @@ void VisualizationGeant4Module::set_visualization_settings() {
    }

    // Set default viewer orientation
    UI->ApplyCommand("/vis/viewer/set/viewpointThetaPhi -70 20");
    auto viewpoint_angles =
        config_.getArray<double>("viewpoint_thetaphi", {Units::get<double>(-70, "deg"), Units::get<double>(20, "deg")});
    if(viewpoint_angles.size() != 2) {
        LOG(FATAL)
            << "Parameter viewpoint_thetaphi VisualizationGeant4Module is not valid. Must be two angles (theta, phi).";
        throw InvalidValueError(config_, "viewpoint_thetaphi", "invalid number of parameters given, must be two");
    }
    auto viewpoint_cmd = "/vis/viewer/set/viewpointThetaPhi " + std::to_string(Units::convert(viewpoint_angles[0], "deg")) +
                         " " + std::to_string(Units::convert(viewpoint_angles[1], "deg"));
    UI->ApplyCommand(viewpoint_cmd);

    // Do auto refresh if not accumulating and start viewer already
    if(!accumulate) {