Commit 087be98b authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Geometry: move support layer to separate file

parent f78f57af
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ ROOT::Math::XYZVector DetectorModel::getSize() const {
    return size;
}

std::vector<DetectorModel::SupportLayer> DetectorModel::getSupportLayers() const {
std::vector<SupportLayer> DetectorModel::getSupportLayers() const {
    auto ret_layers = support_layers_;

    auto sensor_offset = -getSensorSize().z() / 2.0;
+2 −86
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@
#include "objects/Pixel.hpp"
#include "tools/ROOT.h"

#include "SupportLayer.hpp"

namespace allpix {
    /**
     * @brief Sensor materials
@@ -181,92 +183,6 @@ namespace allpix {
        private:
        };

        /**
         * @brief Helper class to hold support layers for a detector model
         */
        class SupportLayer {
            friend class DetectorModel;

        public:
            /**
             * @brief Get the center of the support layer
             * @return Center of the support layer
             */
            ROOT::Math::XYZPoint getCenter() const { return center_; }
            /**
             * @brief Get the size of the support layer
             * @return Size of the support layer
             */
            ROOT::Math::XYZVector getSize() const { return size_; }
            /**
             * @brief Get the material of the support layer
             * @return Support material
             */
            std::string getMaterial() const { return material_; }
            /**
             * @brief Return if the support layer contains a hole
             * @return True if the support layer has a hole, false otherwise
             */
            bool hasHole() { return hole_size_.x() > 1e-9 && hole_size_.y() > 1e-9; }

            /**
             * @brief Return the support layer hole type
             * @return support layer hole type
             */
            std::string getHoleType() { return type_; }

            /**
             * @brief Get the center of the hole in the support layer
             * @return Center of the hole
             */
            ROOT::Math::XYZPoint getHoleCenter() const {
                return center_ + ROOT::Math::XYZVector(hole_offset_.x(), hole_offset_.y(), 0);
            }
            /**
             * @brief Get the full size of the hole in the support layer
             * @return Size of the hole
             */
            ROOT::Math::XYZVector getHoleSize() const { return hole_size_; }
            /**
             * @brief Get the location of the support layer
             */
            std::string getLocation() const { return location_; }

        private:
            /**
             * @brief Constructs a support layer, used in \ref DetectorModel::addSupportLayer
             * @param size Size of the support layer
             * @param offset Offset of the support layer from the center
             * @param material Material of the support layer
             * @param type Type of the hole
             * @param location Location of the support material
             * @param hole_size Size of an optional hole (zero vector if no hole)
             * @param hole_offset Offset of the optional hole from the center of the support layer
             */
            SupportLayer(ROOT::Math::XYZVector size,
                         ROOT::Math::XYZVector offset,
                         std::string material,
                         std::string type,
                         std::string location,
                         ROOT::Math::XYZVector hole_size,
                         ROOT::Math::XYVector hole_offset)
                : size_(std::move(size)), material_(std::move(material)), type_(std::move(type)),
                  hole_size_(std::move(hole_size)), offset_(std::move(offset)), hole_offset_(std::move(hole_offset)),
                  location_(std::move(location)) {}

            // Actual parameters returned
            ROOT::Math::XYZPoint center_;
            ROOT::Math::XYZVector size_;
            std::string material_;
            std::string type_;
            ROOT::Math::XYZVector hole_size_;

            // Internal parameters to calculate return parameters
            ROOT::Math::XYZVector offset_;
            ROOT::Math::XYVector hole_offset_;
            std::string location_;
        };

        /**
         * @brief Constructs the base detector model
         * @param type Name of the model type
+107 −0
Original line number Diff line number Diff line
/**
 * @file
 * @brief Definition of support layer
 *
 * @copyright Copyright (c) 2017 CERN and the Allpix Squared authors.
 * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md".
 * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an
 * Intergovernmental Organization or submit itself to any jurisdiction.
 */

#ifndef ALLPIX_SUPPORT_LAYER_H
#define ALLPIX_SUPPORT_LAYER_H

#include <Math/Point2D.h>
#include <Math/Point3D.h>
#include <Math/Vector2D.h>
#include <Math/Vector3D.h>

/**
 * @brief Helper class to hold support layers for a detector model
 */
namespace allpix {
    class SupportLayer {
        friend class DetectorModel;

    public:
        /**
         * @brief Get the center of the support layer
         * @return Center of the support layer
         */
        ROOT::Math::XYZPoint getCenter() const { return center_; }
        /**
         * @brief Get the size of the support layer
         * @return Size of the support layer
         */
        ROOT::Math::XYZVector getSize() const { return size_; }
        /**
         * @brief Get the material of the support layer
         * @return Support material
         */
        std::string getMaterial() const { return material_; }
        /**
         * @brief Return if the support layer contains a hole
         * @return True if the support layer has a hole, false otherwise
         */
        bool hasHole() { return hole_size_.x() > 1e-9 && hole_size_.y() > 1e-9; }

        /**
         * @brief Return the support layer hole type
         * @return support layer hole type
         */
        std::string getHoleType() { return type_; }

        /**
         * @brief Get the center of the hole in the support layer
         * @return Center of the hole
         */
        ROOT::Math::XYZPoint getHoleCenter() const {
            return center_ + ROOT::Math::XYZVector(hole_offset_.x(), hole_offset_.y(), 0);
        }
        /**
         * @brief Get the full size of the hole in the support layer
         * @return Size of the hole
         */
        ROOT::Math::XYZVector getHoleSize() const { return hole_size_; }
        /**
         * @brief Get the location of the support layer
         */
        std::string getLocation() const { return location_; }

    private:
        /**
         * @brief Constructs a support layer, used in \ref DetectorModel::addSupportLayer
         * @param size Size of the support layer
         * @param offset Offset of the support layer from the center
         * @param material Material of the support layer
         * @param type Type of the hole
         * @param location Location of the support material
         * @param hole_size Size of an optional hole (zero vector if no hole)
         * @param hole_offset Offset of the optional hole from the center of the support layer
         */
        SupportLayer(ROOT::Math::XYZVector size,
                     ROOT::Math::XYZVector offset,
                     std::string material,
                     std::string type,
                     std::string location,
                     ROOT::Math::XYZVector hole_size,
                     ROOT::Math::XYVector hole_offset)
            : size_(std::move(size)), material_(std::move(material)), type_(std::move(type)),
              hole_size_(std::move(hole_size)), offset_(std::move(offset)), hole_offset_(std::move(hole_offset)),
              location_(std::move(location)) {}

        // Actual parameters returned
        ROOT::Math::XYZPoint center_;
        ROOT::Math::XYZVector size_;
        std::string material_;
        std::string type_;
        ROOT::Math::XYZVector hole_size_;

        // Internal parameters to calculate return parameters
        ROOT::Math::XYZVector offset_;
        ROOT::Math::XYVector hole_offset_;
        std::string location_;
    };
} // namespace allpix

#endif // ALLPIX_SUPPORT_LAYER_H