Commit 4f0c8811 authored by Daniil Rastorguev's avatar Daniil Rastorguev Committed by Simon Spannagel
Browse files

Laser: user specification for optical properties

(cherry picked from commit 85d2e221)
parent 484b27e2
Loading
Loading
Loading
Loading
+42 −38
Original line number Diff line number Diff line
@@ -96,30 +96,16 @@ DepositionLaserModule::DepositionLaserModule(Configuration& config, Messenger* m
}

void DepositionLaserModule::initialize() {

    // Check for unsupported detector materials, warn user if present

    std::vector<std::shared_ptr<Detector>> detectors = geo_manager_->getDetectors();
    for(auto& detector : detectors) {
        auto material = detector->getModel()->getSensorMaterial();
        if(material != SensorMaterial::SILICON) {
            LOG(WARNING) << "Detector " << detector->getName() << " has unsupported material and will be ignored";
        }
    }
    // Check for incompatible passive objects, warn user if there are any
    auto passive_configs = geo_manager_->getPassiveElements();
    for(const auto& item : passive_configs) {
        auto shape = item.get<std::string>("type");
        if(shape != "box") {
            LOG(WARNING) << item.getName() << " passive object has unsupported type (" << shape << ") and will be ignored";
        }
    }

    // Check if there are user-specified optical properties for materials
    is_user_optics_ = (config_.count({"absorption_length", "refractive_index"}) == 2);
    if(is_user_optics_) {
        absorption_length_ = config_.get<double>("absorption_length");
        refractive_index_ = config_.get<double>("refractive_index");
        LOG(DEBUG) << "Setting user-defined optical properties for sensor material";
    } else {
        // Load data
        std::string laser_data_path = ALLPIX_LASER_DATA_DIRECTORY;

        std::ifstream f(std::filesystem::path(laser_data_path) / "silicon_photoabsorption.data");

        // wavelength: {absorption_length, refractive_index}
        std::map<double, std::pair<double, double>> optics_lut;
        double wl = 0;
@@ -130,7 +116,7 @@ void DepositionLaserModule::initialize() {
            optics_lut[Units::get(wl, "nm")] = {abs_length, refr_ind};
        }

    LOG(DEBUG) << "Loading absorption data: " << laser_data_path;
        LOG(DEBUG) << "Loading optical properties for sensor material from LUT: " << laser_data_path;

        // Find or interpolate absorption depth for given wavelength

@@ -146,11 +132,29 @@ void DepositionLaserModule::initialize() {
            refractive_index_ =
                (optics_lut[wl1].second * (wl2 - wavelength_) + optics_lut[wl2].second * (wavelength_ - wl1)) / (wl2 - wl1);
        }

    }
    LOG(DEBUG) << "Wavelength = " << Units::display(wavelength_, "nm")
               << ", absorption length: " << Units::display(absorption_length_, {"um", "mm"})
               << ", refractive index: " << refractive_index_;

    // Check for unsupported detector materials, warn user if present

    std::vector<std::shared_ptr<Detector>> detectors = geo_manager_->getDetectors();
    for(auto& detector : detectors) {
        auto material = detector->getModel()->getSensorMaterial();
        if(material != SensorMaterial::SILICON && !is_user_optics_) {
            LOG(WARNING) << "Detector " << detector->getName() << " has unsupported material and will be ignored";
        }
    }
    // Check for incompatible passive objects, warn user if there are any
    auto passive_configs = geo_manager_->getPassiveElements();
    for(const auto& item : passive_configs) {
        auto shape = item.get<std::string>("type");
        if(shape != "box") {
            LOG(WARNING) << item.getName() << " passive object has unsupported type (" << shape << ") and will be ignored";
        }
    }

    // Create Histograms
    if(output_plots_) {
        LOG(DEBUG) << "Initializing histograms";
@@ -481,7 +485,7 @@ std::optional<DepositionLaserModule::PhotonHit> DepositionLaserModule::track(con
    std::vector<std::pair<std::shared_ptr<Detector>, std::pair<double, double>>> intersection_segments;

    for(auto& detector : detectors) {
        if(detector->getModel()->getSensorMaterial() != SensorMaterial::SILICON) {
        if(detector->getModel()->getSensorMaterial() != SensorMaterial::SILICON && !is_user_optics_) {
            continue;
        }
        auto intersection = intersect_with_sensor(detector, position, direction);
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ namespace allpix {
        double absorption_length_;
        double refractive_index_;
        double pulse_duration_;
        bool is_user_optics_;

        // Histograms
        bool output_plots_;