Commit adc7051d authored by Stephan Lachnit's avatar Stephan Lachnit
Browse files

Merge branch 'b-laser' into 'v2.4-stable'

[v2.4-stable] DepositionLaser module

See merge request allpix-squared/allpix-squared!924
parents b8743478 96bc0878
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -899,3 +899,16 @@ doi = {https://doi.org/10.1016/0883-2889(91)90002-I},
url = {https://www.sciencedirect.com/science/article/pii/088328899190002I},
author = {S. Croft and D.S. Bond}
}

@article{optical_properties,
author = {Green, Martin A. and Keevers, Mark J.},
title = {Optical properties of intrinsic silicon at 300 K},
journal = {Progress in Photovoltaics: Research and Applications},
volume = {3},
number = {3},
pages = {189-192},
doi = {https://doi.org/10.1002/pip.4670030303},
url = {https://onlinelibrary.wiley.com/doi/abs/10.1002/pip.4670030303},
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1002/pip.4670030303},
year = {1995}
}
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#ifndef ALLPIX_RANDOM_DISTRIBUTIONS_H
#define ALLPIX_RANDOM_DISTRIBUTIONS_H

#include <boost/random/exponential_distribution.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/piecewise_linear_distribution.hpp>
#include <boost/random/poisson_distribution.hpp>
@@ -20,6 +21,7 @@ namespace allpix {
    template <typename T> using piecewise_linear_distribution = boost::random::piecewise_linear_distribution<T>;
    template <typename T> using poisson_distribution = boost::random::poisson_distribution<T>;
    template <typename T> using uniform_real_distribution = boost::random::uniform_real_distribution<T>;
    template <typename T> using exponential_distribution = boost::random::exponential_distribution<T>;
} // namespace allpix

#endif // ALLPIX_RANDOM_DISTRIBUTIONS_H
+45 −0
Original line number Diff line number Diff line
# SPDX-FileCopyrightText: 2017-2022 CERN and the Allpix Squared authors
# SPDX-License-Identifier: MIT

# Define module and return the generated name as MODULE_NAME
ALLPIX_UNIQUE_MODULE(MODULE_NAME)

# Prefer local data files if not installed to other location
GET_FILENAME_COMPONENT(ABSOLUTE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} ABSOLUTE)
IF(ABSOLUTE_INSTALL_PREFIX STREQUAL PROJECT_SOURCE_DIR)
    # Use local data directory (unless other is given)
    SET(LASER_DATA_DIRECTORY
        "${CMAKE_CURRENT_SOURCE_DIR}/data"
        CACHE PATH "Laser data directory" FORCE)
ELSE()
    # Set the install path to share
    SET(LASER_DATA_DIRECTORY
        "share/${CMAKE_PROJECT_NAME}/data"
        CACHE PATH "Laser data directory" FORCE)
ENDIF()

IF(NOT IS_ABSOLUTE ${LASER_DATA_DIRECTORY})
    SET(LASER_DATA_DIRECTORY
        "${CMAKE_INSTALL_PREFIX}/${LASER_DATA_DIRECTORY}"
        CACHE PATH "Laser data directory" FORCE)
ENDIF()

# Install the files to the data directory
# NOTE: With default install path this does not change anything
INSTALL(
    DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/
    DESTINATION ${LASER_DATA_DIRECTORY}
    FILES_MATCHING
    PATTERN "*.data")

ADD_DEFINITIONS(-DALLPIX_LASER_DATA_DIRECTORY="${LASER_DATA_DIRECTORY}")


# Add source files to library
ALLPIX_MODULE_SOURCES(${MODULE_NAME} DepositionLaserModule.cpp)

# Register module tests
ALLPIX_MODULE_TESTS(${MODULE_NAME} "tests")

# Provide standard install target
ALLPIX_MODULE_INSTALL(${MODULE_NAME})
+644 −0

File added.

Preview size limit exceeded, changes collapsed.

+146 −0
Original line number Diff line number Diff line
/**
 * @file
 * @brief Definition of [DepositionLaser] module
 *
 * @copyright Copyright (c) 2022 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.
 * SPDX-License-Identifier: MIT
 *
 * Contains minimal dummy module to use as a start for the development of your own module
 *
 * Refer to the User's Manual for more details.
 */

#include <map>
#include <optional>
#include <string>
#include <utility>

#include "core/config/Configuration.hpp"
#include "core/geometry/GeometryManager.hpp"
#include "core/messenger/Messenger.hpp"
#include "core/module/Event.hpp"
#include "core/module/Module.hpp"

#include "TH1D.h"
#include "TH2D.h"
#include "TH3D.h"
#include "tools/ROOT.h"

namespace allpix {
    /**
     * @ingroup Modules
     * @brief Module to do function
     *
     * More detailed explanation of module
     */
    class DepositionLaserModule : public Module {

        enum class BeamGeometry {
            CYLINDRICAL,
            CONVERGING,
        };

        // Data to return from tracking algorithms
        struct PhotonHit { // NOLINT
            std::shared_ptr<Detector> detector;
            ROOT::Math::XYZPoint entry_global;
            ROOT::Math::XYZPoint hit_global;
            double time_to_entry;
            double time_to_hit;
        };

    public:
        /**
         * @brief Constructor for this unique module
         * @param config Configuration object for this module as retrieved from the steering file
         * @param messenger Pointer to the messenger object to allow binding to messages on the bus
         * @param geo_manager Pointer to the geometry manager, containing the detectors
         */
        DepositionLaserModule(Configuration& config, Messenger* messenger, GeometryManager* geo_manager);

        /**
         * @brief Initialization method of the module
         */
        void initialize() override;

        /**
         * @brief Run method of the module
         */
        void run(Event* event) override;

        /**
         * @brief Finalize and write optional histograms
         */
        void finalize() override;

    private:
        /**
         * @brief Check intersection of the given track with the given detector
         * This is a wrapper around LiangBarsky::intersectionDistances,
         * which properly transforms coordinates to make it work
         */
        std::optional<std::pair<double, double>> intersect_with_sensor(const std::shared_ptr<const Detector>& detector,
                                                                       const ROOT::Math::XYZPoint& position_global,
                                                                       const ROOT::Math::XYZVector& direction_global) const;

        /**
         * @brief Check intersection with passive objects if there is any
         * Only works for boxes
         */
        std::optional<std::pair<double, std::string>>
        intersect_with_passives(const ROOT::Math::XYZPoint& position_global,
                                const ROOT::Math::XYZVector& direction_global) const;

        /**
         * @brief Get a normal vector for a point where the given track enters the given detector
         * Returns a normal vector to sensor face, closest to the hit_point
         */
        ROOT::Math::XYZVector intersection_normal_vector(const std::shared_ptr<const Detector>& detector,
                                                         const ROOT::Math::XYZPoint& position_global) const;

        /**
         * @brief Generate starting position and direction for a single photon, obeying the set beam geometry
         * @param event is passed to get proper RNGs
         * Also fills histograms
         */
        std::pair<ROOT::Math::XYZPoint, ROOT::Math::XYZVector> generate_photon_geometry(Event* event);

        /**
         * @brief Track a photon, starting at the given point
         * version 2: refraction
         */
        std::optional<PhotonHit>
        track(const ROOT::Math::XYZPoint& position, const ROOT::Math::XYZVector& direction, double penetration_depth) const;

        // General module members
        GeometryManager* geo_manager_;
        Messenger* messenger_;

        // Laser parameters
        ROOT::Math::XYZPoint source_position_{};
        ROOT::Math::XYZVector beam_direction_{};
        double beam_waist_;

        BeamGeometry beam_geometry_{};
        double beam_convergence_angle_;
        double focal_distance_;

        size_t number_of_photons_;
        double wavelength_;
        double absorption_length_;
        double refractive_index_;
        double pulse_duration_;

        // Histograms
        bool output_plots_;
        Histogram<TH2D> h_intensity_sourceplane_{};
        Histogram<TH2D> h_intensity_focalplane_{};
        Histogram<TH1D> h_angular_phi_{};
        Histogram<TH1D> h_angular_theta_{};
        Histogram<TH1D> h_pulse_shape_{};
        std::map<const std::shared_ptr<Detector>, Histogram<TH3D>> h_deposited_charge_shapes_;
    };
} // namespace allpix
Loading