Commit 1806b499 authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Changing header_config to config

parents 95d63851 fbeda69d
Loading
Loading
Loading
Loading
+23 −24
Original line number Diff line number Diff line
@@ -29,12 +29,12 @@ namespace allpix {
    public:
        /**
         * Detector assembly constructor
         * @param header_config Configuration reference holding the unnamed section fo detector configuration
         * @param config Configuration reference holding the unnamed section of detector configuration
         */
        explicit DetectorAssembly(Configuration& header_config) {
        explicit DetectorAssembly(Configuration& config) {

            // Chip thickness
            thickness_ = header_config.get<double>("chip_thickness", 0);
            thickness_ = config.get<double>("chip_thickness", 0);
        }

        ///@{
@@ -81,27 +81,26 @@ namespace allpix {
    public:
        /**
         * Constructor for hybrid assemblies
         * @param header_config  Configuration reference holding the unnamed section fo detector configuration
         * @param config  Configuration reference holding the unnamed section of detector configuration
         */
        explicit HybridAssembly(Configuration& header_config) : DetectorAssembly(header_config) {
        explicit HybridAssembly(Configuration& config) : DetectorAssembly(config) {

            // Excess around the chip from the pixel grid
            auto default_assembly_excess = header_config.get<double>("chip_excess", 0);
            excess_.at(0) = header_config.get<double>("chip_excess_top", default_assembly_excess);
            excess_.at(1) = header_config.get<double>("chip_excess_right", default_assembly_excess);
            excess_.at(2) = header_config.get<double>("chip_excess_bottom", default_assembly_excess);
            excess_.at(3) = header_config.get<double>("chip_excess_left", default_assembly_excess);
            auto default_assembly_excess = config.get<double>("chip_excess", 0);
            excess_.at(0) = config.get<double>("chip_excess_top", default_assembly_excess);
            excess_.at(1) = config.get<double>("chip_excess_right", default_assembly_excess);
            excess_.at(2) = config.get<double>("chip_excess_bottom", default_assembly_excess);
            excess_.at(3) = config.get<double>("chip_excess_left", default_assembly_excess);

            // Set bump parameters
            bump_cylinder_radius_ = header_config.get<double>("bump_cylinder_radius");
            bump_height_ = header_config.get<double>("bump_height");
            bump_sphere_radius_ = header_config.get<double>("bump_sphere_radius", 0);
            bump_cylinder_radius_ = config.get<double>("bump_cylinder_radius");
            bump_height_ = config.get<double>("bump_height");
            bump_sphere_radius_ = config.get<double>("bump_sphere_radius", 0);

            auto pitch = header_config.get<ROOT::Math::XYVector>("pixel_size");
            bump_offset_ = header_config.get<ROOT::Math::XYVector>("bump_offset", {0, 0});
            auto pitch = config.get<ROOT::Math::XYVector>("pixel_size");
            bump_offset_ = config.get<ROOT::Math::XYVector>("bump_offset", {0, 0});
            if(std::fabs(bump_offset_.x()) > pitch.x() / 2.0 || std::fabs(bump_offset_.y()) > pitch.y() / 2.0) {
                throw InvalidValueError(
                    header_config, "bump_offset", "bump bond offset cannot be larger than half pixel pitch");
                throw InvalidValueError(config, "bump_offset", "bump bond offset cannot be larger than half pixel pitch");
            }
        }

@@ -152,16 +151,16 @@ namespace allpix {
    public:
        /**
         * Constructor for monolithic assemblies
         * @param header_config Configuration reference holding the unnamed section fo detector configuration
         * @param config Configuration reference holding the unnamed section of detector configuration
         */
        explicit MonolithicAssembly(Configuration& header_config) : DetectorAssembly(header_config) {
        explicit MonolithicAssembly(Configuration& config) : DetectorAssembly(config) {

            // Excess around the chip is copied from sensor size
            auto default_assembly_excess = header_config.get<double>("sensor_excess", 0);
            excess_.at(0) = header_config.get<double>("sensor_excess_top", default_assembly_excess);
            excess_.at(1) = header_config.get<double>("sensor_excess_right", default_assembly_excess);
            excess_.at(2) = header_config.get<double>("sensor_excess_bottom", default_assembly_excess);
            excess_.at(3) = header_config.get<double>("sensor_excess_left", default_assembly_excess);
            auto default_assembly_excess = config.get<double>("sensor_excess", 0);
            excess_.at(0) = config.get<double>("sensor_excess_top", default_assembly_excess);
            excess_.at(1) = config.get<double>("sensor_excess_right", default_assembly_excess);
            excess_.at(2) = config.get<double>("sensor_excess_bottom", default_assembly_excess);
            excess_.at(3) = config.get<double>("sensor_excess_left", default_assembly_excess);
        }
    };
} // namespace allpix
+27 −29
Original line number Diff line number Diff line
@@ -22,50 +22,49 @@
using namespace allpix;

std::shared_ptr<DetectorModel> DetectorModel::factory(const std::string& name, const ConfigReader& reader) {
    Configuration header_config = reader.getHeaderConfiguration();
    Configuration config = reader.getHeaderConfiguration();

    // Sensor geometry
    // FIXME we might want to deprecate this default at some point?
    if(!header_config.has("geometry")) {
        LOG(WARNING) << "Model file " << header_config.getFilePath()
                     << " does not provide a geometry parameter, using default";
    if(!config.has("geometry")) {
        LOG(WARNING) << "Model file " << config.getFilePath() << " does not provide a geometry parameter, using default";
    }
    auto geometry = header_config.get<std::string>("geometry", "pixel");
    auto geometry = config.get<std::string>("geometry", "pixel");

    // Assembly type
    if(!header_config.has("type")) {
        LOG(FATAL) << "Model file " << header_config.getFilePath() << " does not provide a type parameter";
    if(!config.has("type")) {
        LOG(FATAL) << "Model file " << config.getFilePath() << " does not provide a type parameter";
    }
    auto type = header_config.get<std::string>("type");
    auto type = config.get<std::string>("type");

    std::shared_ptr<DetectorAssembly> assembly;
    if(type == "hybrid") {
        assembly = std::make_shared<HybridAssembly>(header_config);
        assembly = std::make_shared<HybridAssembly>(config);
    } else if(type == "monolithic") {
        assembly = std::make_shared<MonolithicAssembly>(header_config);
        assembly = std::make_shared<MonolithicAssembly>(config);
    } else {
        LOG(FATAL) << "Model file " << header_config.getFilePath() << " type parameter is not valid";
        throw InvalidValueError(header_config, "type", "model type is not supported");
        LOG(FATAL) << "Model file " << config.getFilePath() << " type parameter is not valid";
        throw InvalidValueError(config, "type", "model type is not supported");
    }

    // Instantiate the correct detector model
    std::shared_ptr<DetectorModel> model;
    if(geometry == "pixel") {
        model = std::make_shared<PixelDetectorModel>(name, assembly, reader, header_config);
        model = std::make_shared<PixelDetectorModel>(name, assembly, reader, config);
    } else if(geometry == "radial_strip") {
        model = std::make_shared<RadialStripDetectorModel>(name, assembly, reader, header_config);
        model = std::make_shared<RadialStripDetectorModel>(name, assembly, reader, config);
    } else if(geometry == "hexagonal") {
        model = std::make_shared<HexagonalPixelDetectorModel>(name, assembly, reader, header_config);
        model = std::make_shared<HexagonalPixelDetectorModel>(name, assembly, reader, config);
    } else {
        LOG(FATAL) << "Model file " << header_config.getFilePath() << " geometry parameter is not valid";
        LOG(FATAL) << "Model file " << config.getFilePath() << " geometry parameter is not valid";
        // FIXME: The model can probably be silently ignored if we have more model readers later
        throw InvalidValueError(header_config, "geometry", "model geometry is not supported");
        throw InvalidValueError(config, "geometry", "model geometry is not supported");
    }

    // Validate the detector model - we call this here because validation might depend on derived class properties:
    model->validate();

    auto unused_keys = header_config.getUnusedKeys();
    auto unused_keys = config.getUnusedKeys();
    if(!unused_keys.empty()) {
        std::stringstream st;
        st << "Unused configuration keys in global section in sensor geometry definition:";
@@ -81,27 +80,26 @@ std::shared_ptr<DetectorModel> DetectorModel::factory(const std::string& name, c
DetectorModel::DetectorModel(std::string type,
                             std::shared_ptr<DetectorAssembly> assembly,
                             ConfigReader reader,
                             Configuration& header_config)
                             Configuration& config)
    : type_(std::move(type)), assembly_(std::move(assembly)), reader_(std::move(reader)) {
    using namespace ROOT::Math;

    // Sensor thickness
    setSensorThickness(header_config.get<double>("sensor_thickness"));
    setSensorThickness(config.get<double>("sensor_thickness"));

    // Excess around the sensor from the pixel grid
    auto default_sensor_excess = header_config.get<double>("sensor_excess", 0);
    setSensorExcessTop(header_config.get<double>("sensor_excess_top", default_sensor_excess));
    setSensorExcessBottom(header_config.get<double>("sensor_excess_bottom", default_sensor_excess));
    setSensorExcessLeft(header_config.get<double>("sensor_excess_left", default_sensor_excess));
    setSensorExcessRight(header_config.get<double>("sensor_excess_right", default_sensor_excess));
    auto default_sensor_excess = config.get<double>("sensor_excess", 0);
    setSensorExcessTop(config.get<double>("sensor_excess_top", default_sensor_excess));
    setSensorExcessBottom(config.get<double>("sensor_excess_bottom", default_sensor_excess));
    setSensorExcessLeft(config.get<double>("sensor_excess_left", default_sensor_excess));
    setSensorExcessRight(config.get<double>("sensor_excess_right", default_sensor_excess));

    // Sensor material:
    sensor_material_ = header_config.get<SensorMaterial>("sensor_material", SensorMaterial::SILICON);
    sensor_material_ = config.get<SensorMaterial>("sensor_material", SensorMaterial::SILICON);

    // Issue a warning for pre-3.0 implant definitions:
    if(header_config.has("implant_size")) {
        LOG(WARNING) << "Parameter \"implant_size\" of model " << header_config.getFilePath() << " not supported,"
                     << std::endl
    if(config.has("implant_size")) {
        LOG(WARNING) << "Parameter \"implant_size\" of model " << config.getFilePath() << " not supported," << std::endl
                     << "Individual [implant] sections must be used for implant definitions";
    }

+2 −2
Original line number Diff line number Diff line
@@ -180,12 +180,12 @@ namespace allpix {
         * @param type Name of the model type
         * @param assembly Detector assembly object with information about ASIC and packaging
         * @param reader Configuration reader with description of the model
         * @param header_config Configuration holding the empty section of the configuration file
         * @param config Configuration holding the empty section of the configuration file
         */
        explicit DetectorModel(std::string type,
                               std::shared_ptr<DetectorAssembly> assembly,
                               ConfigReader reader,
                               Configuration& header_config);
                               Configuration& config);

        /**
         * @brief Essential virtual destructor
+5 −6
Original line number Diff line number Diff line
@@ -17,15 +17,14 @@ using namespace allpix;
HexagonalPixelDetectorModel::HexagonalPixelDetectorModel(std::string type,
                                                         const std::shared_ptr<DetectorAssembly>& assembly,
                                                         const ConfigReader& reader,
                                                         Configuration& header_config)
    : PixelDetectorModel(std::move(type), assembly, reader, header_config) {
                                                         Configuration& config)
    : PixelDetectorModel(std::move(type), assembly, reader, config) {

    // Select shape orientation
    pixel_type_ = header_config.get<Pixel::Type>("pixel_type");
    pixel_type_ = config.get<Pixel::Type>("pixel_type");
    if(pixel_type_ != Pixel::Type::HEXAGON_FLAT && pixel_type_ != Pixel::Type::HEXAGON_POINTY) {
        throw InvalidValueError(header_config,
                                "pixel_type",
                                "for this model, only pixel types 'hexagon_pointy' and 'hexagon_flat' are available");
        throw InvalidValueError(
            config, "pixel_type", "for this model, only pixel types 'hexagon_pointy' and 'hexagon_flat' are available");
    }
}

+2 −2
Original line number Diff line number Diff line
@@ -30,12 +30,12 @@ namespace allpix {
         * @param type   Name of the model type
         * @param assembly Detector assembly object with information about ASIC and packaging
         * @param reader Configuration reader with description of the model
         * @param header_config Configuration reference holding the unnamed section fo detector configuration
         * @param config Configuration reference holding the unnamed section of detector configuration
         */
        explicit HexagonalPixelDetectorModel(std::string type,
                                             const std::shared_ptr<DetectorAssembly>& assembly,
                                             const ConfigReader& reader,
                                             Configuration& header_config);
                                             Configuration& config);

        /**
         * @brief Essential virtual destructor
Loading