Belle II Software light-2406-ragdoll
DensityScalerModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <geometry/modules/DensityScalerModule.h>
10#include <geometry/GeometryManager.h>
11#include <geometry/Materials.h>
12// we want std::set parameters
13#include <framework/core/ModuleParam.templateDetails.h>
14
15using namespace Belle2;
16
17REG_MODULE(DensityScaler);
18
20{
21 // Set module properties
22 setDescription(R"DOC(Scale density of simulation/reconstruction geometry
23
24This is obviously only meant for systematic studies to scale the density in different
25parts of the detector to estimate the effect on for example tracking performance.
26
27This module is to be placed **before** the Geometry module itself and will then
28change the density of all materials which are created using the Materials service
29
30Warning:
31 This doesn't affect any materials created manually somewhere. A way to check is
32 to set a global scaling factor and then do a material scan with the :b2:mod:`MaterialScan`
33 module split by materials. The scaled materials will have a different name
34 starting with 'scaled:' followed by the scaling factor and the original name
35)DOC");
36
37 // Parameter definitions
38 addParam("scaling", m_scaling,
39 "The scale factor for each geometry component that should be scaled. '*' "
40 "can be used to scale all components by the same factor. If a component is "
41 "specified manually and '*' is present the result will be the product of both)");
42 addParam("ignoredMaterials", m_ignoredMaterials, "A set of material names which should "
43 "**not** be scaled, usually things like vaccum or air. To scale everything this "
44 "parameter should be set to an empty set (``{}`` or ``set()``)",
45 geometry::Materials::getInstance().getDensityScaleIgnoredMaterials());
46}
47
49{
51 if(geometry::GeometryManager::getInstance().getTopVolume()) {
52 B2FATAL("Geometry already created, DensityScaler needs to come before the Geometry module");
53 }
55}
virtual void initialize() override
Set the scaling.
std::map< std::string, double > m_scaling
The scale factor for each geometry component that should be scaled.
DensityScalerModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::set< std::string > m_ignoredMaterials
Set of material names to not scale.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
static GeometryManager & getInstance()
Return a reference to the instance.
void setDensityScaling(const std::map< std::string, double > &components)
Set the density scaling: This is intended for systematic studies only and will scale the density of a...
void setDensityScaleIgnoredMaterials(const std::set< std::string > &ignored)
set the set of material names which will not be scaled in any way
Definition: Materials.h:149
static Materials & getInstance()
Get a reference to the singleton instance.
Definition: Materials.cc:85
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24