Commit ea191194 authored by Renato Quagliani's avatar Renato Quagliani Committed by Paul Schütze
Browse files

add Cons passive model

parent 047a1860
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ description: "Simulation example with passive volumes in the geometry file"
This example showcases the definition of passive volumes in the geometry file.

The file `example_detector_passive.conf` contains a detector of the type `test`, as well as several passive objects, identified via the key-parameter pair `role = "passive"`.
The example shows the three basic objects implemented, while for the volume "sphere1" the "box1" is defined as `mother_volume`.
The example shows the four basic objects implemented, while for the volume "sphere1" the "box1" is defined as `mother_volume`.
This implies that the sphere is integrated into the box and that the given position (and orientation, if applicable) are interpreted as specifications relative to the position and orientation of the box mother volume.

Optionally, the `VisualizationGeant4` can be used to visualize these objects.
+15 −0
Original line number Diff line number Diff line
@@ -29,3 +29,18 @@ position = 0 0 50mm
orientation = 0 0 0
material = "copper"
role = "passive"


[cons1]
type = "cons"
outer_radius_pDz = 10mm
inner_radius_pDz =  9mm
outer_radius_mDz = 20mm
inner_radius_mDz =  9mm
starting_angle   = 0deg
arc_length       = 180deg
length = 30mm
position = 0 0 10mm
orientation = 0 0 0
material = "berillium"
role = "passive"
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "PassiveMaterialModel.hpp"
#include "passive_models/BoxModel.hpp"
#include "passive_models/CylinderModel.hpp"
#include "passive_models/ConsModel.hpp"
#include "passive_models/GDMLModel.hpp"
#include "passive_models/SphereModel.hpp"

@@ -43,6 +44,8 @@ std::shared_ptr<PassiveMaterialModel> allpix::PassiveMaterialModel::factory(cons
        return std::make_shared<CylinderModel>(config, geo_manager);
    } else if(type == "sphere") {
        return std::make_shared<SphereModel>(config, geo_manager);
    } else if(type == "cons"){
        return std::make_shared<ConsModel>(config, geo_manager);        
    } else if(type == "gdml") {
#ifdef Geant4_GDML
        return std::make_shared<GDMLModel>(config, geo_manager);
+18 −0
Original line number Diff line number Diff line
@@ -57,6 +57,24 @@ The necessary module errors and warnings have been included to make sure the use

Note: If the VisualizationGeant4 module is used in conjunction with and `arc_length_theta` different from 180deg, the Visualization GUI will show an error "Inconsistency in bounding boxes for solid". The origin of this error is unknown but the error can be ignored.

#### Cons:
A cone or partly made cone with an inner and outer radius at the (- half-length , + half-length)
 outer_radius_mDz : at - half-length the outer radius
                outer_radius_pDz : at + half-length the outer radius
                inner_radius_mDz : at - half-length the inner radius (must be smaller than outer_radius_mDz)
                inner_radius_pDz : at + half-length the inner radius (must be smaller than outer_radius_mDz)
                starting_angle   : start-angle ( default 0)
                arc_length       : length-of the arc (360 deg default)
* The `outer_radius_pDz` of the cone is the radius of the cone at the + half-lenght position
* The `outer_radius_mDz` of the cone is the radius of the cone at the - half-lenght position
* The `inner_radius_pDz` of the cone is the radius of the cone at the + half-lenght position
* The `inner_radius_mDz` of the cone is the radius of the cone at the - half-lenght position
* The `inner_radius_mDz` of the cone is the radius of the cone at the - half-lenght position
* The `length`  of the cone is the total length of the cone
* (Optional) The `starting_angle` of the cone is the azimuthal angle at which circumference of the cone will start in the XY-plane. 0 degrees refers to the point along the positive x-axis and the angle moves counter clockwise. Defaults to 0deg.
* (Optional) The `arc_length` of the cone is the arc-length of the cone that will be drawn
Note that `arc_length` works the same as the `arc_length` from the cylinder

#### GDML:
This model allows to load arbitrary GDML files \[[@gdml]\] as passive materials. All volumes from the GDML file which are contained within the world volume are processed and added to the geometry of the simulation.
The only parameter specific to this model is `file_name` which should provide the path to the GDML file to be read.
+115 −0
Original line number Diff line number Diff line
/**
 * @file
 * @brief Parameters of a CONS passive material model
 *
 * @copyright Copyright (c) 2017-2020 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_PASSIVE_MATERIAL_CONS_H
#define ALLPIX_PASSIVE_MATERIAL_CONS_H

#include <string>

#include <G4Cons.hh>

#include "PassiveMaterialModel.hpp"
#include "tools/geant4/geant4.h"

namespace allpix {
    class ConsModel : public PassiveMaterialModel {
    public:
        /**
         * @brief Constructs the Cons passive material model
         * @param config Configuration with description of the model
         * @param geo_manager Pointer to the global geometry manager
         */        
        explicit ConsModel(const Configuration& config, GeometryManager* geo_manager)
            : PassiveMaterialModel(config, geo_manager) {

            // Set the CONS specifications
            /*
            must-fill : 
                outer_radius_mDz : at - half-length the outer radius
                outer_radius_pDz : at + half-length the outer radius
                inner_radius_mDz : at - half-length the inner radius (must be smaller than outer_radius_mDz)
                inner_radius_pDz : at + half-length the inner radius (must be smaller than outer_radius_mDz)
                starting_angle   : start-angle ( default 0)
                arc_length       : length-of the arc (360 deg default)
            */
            setOuterRadius(  config_.get<double>("outer_radius_mDz"), config_.get<double>("outer_radius_pDz"));
            setInnerRadius(  config_.get<double>("inner_radius_mDz"), config_.get<double>("inner_radius_pDz"));            
            setLength(       config_.get<double>("length"));
            setStartingAngle(config_.get<double>("starting_angle", 0));
            setArcLength(    config_.get<double>("arc_length", 360 * CLHEP::deg));
            std::string name = config_.getName();
            // Limit the values that can be given
            if(inner_radius_mDz >= outer_radius_mDz) throw InvalidValueError(config_, "inner_radius_mDz", "inner_radius (-half Legth)  cannot be larger than the outer_radius (+ half Length)");            
            if(inner_radius_pDz >= outer_radius_pDz) throw InvalidValueError(config_, "inner_radius_pDz", "inner_radius (+half Length) cannot be larger than the outer_raidus (+ half Length)");                     
            if(arc_length_ > 360 * CLHEP::deg) {
                throw InvalidValueError(config_, "arc_length", "arc_length exceeds the maximum value of 360 degrees");
            }

            solid_ = make_shared_no_delete<G4Cons>(
                name + "_volume", inner_radius_mDz, outer_radius_mDz, 
                                  inner_radius_pDz, outer_radius_pDz, 
                                  length_ / 2., 
                                  starting_angle_, arc_length_);

            // Get the maximum of the size parameters
            max_size_ = std::max(2 * inner_radius_pDz, length_);

            LOG(DEBUG) << "Adding points for volume";
            add_points();
        }

        // Set the override functions of PassiveMaterialModel
        double getMaxSize() const override { return max_size_; }

    private:
        std::shared_ptr<G4VSolid> get_solid() const override { return solid_; }

        // G4VSolid returnables
        std::shared_ptr<G4VSolid> solid_;

        // G4VSolid specifications
        double inner_radius_pDz;
        double outer_radius_pDz;
        double inner_radius_mDz;
        double outer_radius_mDz;        

        double length_;
        double starting_angle_;
        double arc_length_;

        /**
         * @brief Set the inner radius of the CONS in the XY-plane at -halfLenght and +halfLength
         * @param val Inner radius of the CONS
         */
        void setInnerRadius(double val_mDz, double val_pDz ) { inner_radius_mDz = val_mDz; inner_radius_pDz = val_pDz; }
        /**
         * @brief Set the outer radius of the CONS in the XY-plane at -halfLenght and +halfLength
         * @param val Outer radius of the CONS
         */
        void setOuterRadius(double val_mDz, double val_pDz ) { outer_radius_mDz = val_mDz; outer_radius_pDz = val_pDz; }
        /**
         * @brief Set the length of the CONS in the Z-directior
         * @param val Offset from the pixel grid center
         */
        void setLength(double val) { length_ = val; }
        /**
         * @brief Set starting angle of the circumference of the CONS in degrees
         * @param val Starting angle of the CONS
         */
        void setStartingAngle(double val) { starting_angle_ = val; }
        /**
         * @brief Set arc length of the circumference in degrees
         * @param val Arc length of the CONS
         */
        void setArcLength(double val) { arc_length_ = val; }
    };
} // namespace allpix

#endif /* ALLPIX_PASSIVE_MATERIAL_CONS_H */