Belle II Software  release-05-02-19
DensityScalerModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <geometry/modules/DensityScalerModule.h>
12 #include <geometry/GeometryManager.h>
13 #include <geometry/Materials.h>
14 // we want std::set parameters
15 #include <framework/core/ModuleParam.templateDetails.h>
16 
17 using namespace Belle2;
18 
19 REG_MODULE(DensityScaler)
20 
22 {
23  // Set module properties
24  setDescription(R"DOC("Scale density of simulation/reconstruction geometry
25 
26 This is obviously only meant for systematic studies to scale the density in different
27 parts of the detector to estimate the effect on for example tracking performance.
28 
29 This module is to be placed **before** the Geometry module itself and will then
30 change the density of all materials which are created using the Materials service
31 
32 Warning:
33  This doesn't affect any materials created manually somewhere. A way to check is
34  to set a global scaling factor and then do a material scan with the :b2:mod:`MaterialScan`
35  module split by materials. The scaled materials will have a different name
36  starting with 'scaled:' followed by the scaling factor and the original name
37 )DOC");
38 
39  // Parameter definitions
40  addParam("scaling", m_scaling,
41  "The scale factor for each geometry component that should be scaled. '*' "
42  "can be used to scale all components by the same factor. If a component is "
43  "specified manually and '*' is present the result will be the product of both)");
44  addParam("ignoredMaterials", m_ignoredMaterials, "A set of material names which should "
45  "**not** be scaled, usually things like vaccum or air. To scale everything this "
46  "parameter should be set to an empty set (``{}`` or ``set()``)",
47  geometry::Materials::getInstance().getDensityScaleIgnoredMaterials());
48 }
49 
51 {
53  if(geometry::GeometryManager::getInstance().getTopVolume()) {
54  B2FATAL("Geometry already created, DensityScaler needs to come before the Geometry module");
55  }
57 }
Belle2::DensityScalerModule::m_scaling
std::map< std::string, double > m_scaling
The scale factor for each geometry component that should be scaled.
Definition: DensityScalerModule.h:51
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::DensityScalerModule::m_ignoredMaterials
std::set< std::string > m_ignoredMaterials
Set of material names to not scale.
Definition: DensityScalerModule.h:53
Belle2::geometry::GeometryManager::getInstance
static GeometryManager & getInstance()
Return a reference to the instance.
Definition: GeometryManager.cc:98
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::geometry::Materials::getInstance
static Materials & getInstance()
Get a reference to the singleton instance.
Definition: Materials.cc:87
Belle2::geometry::Materials::setDensityScaleIgnoredMaterials
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:150
Belle2::DensityScalerModule::initialize
virtual void initialize() override
Set the scaling.
Belle2::geometry::GeometryManager::setDensityScaling
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...
Definition: GeometryManager.h:136
Belle2::DensityScalerModule
Scale density of simulation/reconstruction geometry.
Definition: DensityScalerModule.h:38