CbmRoot
Loading...
Searching...
No Matches
cbm::algo::kf::SetupBuilder Class Reference

Creates a valid initialized Setup instance. More...

#include <KfSetupBuilder.h>

Collaboration diagram for cbm::algo::kf::SetupBuilder:
[legend]

Classes

struct  LayerProperty
 A helper structure to store geometrical information of the layers. More...
 

Public Member Functions

 SetupBuilder ()=default
 Default constructor.
 
 SetupBuilder (const SetupBuilder &)=delete
 Copy constructor.
 
 SetupBuilder (SetupBuilder &&)=delete
 Move constructor.
 
virtual ~SetupBuilder ()=default
 Destructor.
 
SetupBuilderoperator= (const SetupBuilder &)=delete
 Copy assignment operator.
 
SetupBuilderoperator= (SetupBuilder &&)=delete
 Move assignment operator.
 
void AddLayer (LayerProperty geoLayer)
 Adds material layer.
 
const FieldFn_tGetFieldFunction () const
 Access to field funciton.
 
void Init ()
 Initializes, validates and caches the parameters.
 
template<typename F>
Setup< FMakeSetup (EFieldMode fldMode) const
 Creates a setup instance.
 
void Reset ()
 Resets the instance.
 
void SetFieldFunction (const FieldFn_t &fieldFn, EFieldType fieldType)
 Sets magnetic field function.
 
template<typename F>
void SetFromSetup (const Setup< F > &inSetup)
 Initializes the setup builder from existing setup.
 
void SetMaterialMapFactory (const std::shared_ptr< IMaterialMapFactory > &pMaterialFactory)
 Sets material map creator.
 
void SetMaterialCacheFile (const std::string &filename, size_t refHash)
 Sets the material budget cache file name.
 
void SetTargetProperty (double x, double y, double z, double dz, double r)
 Sets target initialization properties.
 

Static Public Member Functions

static void Store (const Setup< double > &setup, const std::string &fileName)
 Stores a serialized setup to a file.
 
template<typename F>
static Setup< FLoad (const std::string &fileName)
 Loads a serialized setup from a file.
 

Private Member Functions

std::string InitStatusMsg () const
 Prints initialization status message.
 
bool LoadMaterial ()
 Reads material from file.
 
void StoreMaterial () const
 Stores material to file.
 

Private Attributes

std::set< LayerPropertyfGeoLayers {}
 Set of geometrical layers.
 
std::string fsMaterialCacheFile {""}
 A cache file for the material.
 
std::vector< MaterialMapfvMaterial {}
 Material map container.
 
std::shared_ptr< IMaterialMapFactoryfpMaterialMapFactory {nullptr}
 Material map creator.
 
ModuleIndexMapFactory fModuleIndexFactory
 Module index factory.
 
FieldBuilder fFieldBuilder
 Instance of field factory.
 
Target< double > fTarget
 Target properties.
 
size_t fGeoHash {0}
 A hash of the geometry.
 
int fMatMapNofBins {100}
 Number of bins in material maps.
 
bool fbIfTargetSet {false}
 Target initialized.
 
bool fbIfGeoLayersInit {false}
 Geo layers initialized.
 
bool fbIfFieldFunctionSet {false}
 Field function initialized.
 
bool fbIfSetFromSetup {false}
 
bool fbReady {false}
 Instance is ready for setup generation.
 

Static Private Attributes

static constexpr double kTargetCenterOffset {0.05}
 Offset from target center [cm].
 
static constexpr double kTargetMaterialOffset {2.}
 Offset of the target material [in dz].
 
static constexpr double kTargetMaterialTransverseSizeMargin {1.3}
 Margin of target transverse size.
 
static constexpr double kTargetFieldInitStep
 Step between nodal points to determine field near target [cm].
 
static constexpr int kTargetMaterialMapNofBins {20}
 Number of bins along x- and y-axis in the target region;.
 

Detailed Description

Creates a valid initialized Setup instance.

Initialization scenarios: (a) Manual:

  • adding geometry layers one by one
  • setting target
  • setting field function (function + field type) (b) From setup:
  • adding source setup (material layers, field slices and target)
  • adding field function (if field – interpolated)

Definition at line 43 of file KfSetupBuilder.h.

Constructor & Destructor Documentation

◆ SetupBuilder() [1/3]

cbm::algo::kf::SetupBuilder::SetupBuilder ( )
default

Default constructor.

Referenced by operator=(), operator=(), SetupBuilder(), and SetupBuilder().

◆ SetupBuilder() [2/3]

cbm::algo::kf::SetupBuilder::SetupBuilder ( const SetupBuilder & )
delete

Copy constructor.

References SetupBuilder().

◆ SetupBuilder() [3/3]

cbm::algo::kf::SetupBuilder::SetupBuilder ( SetupBuilder && )
delete

Move constructor.

References SetupBuilder().

◆ ~SetupBuilder()

virtual cbm::algo::kf::SetupBuilder::~SetupBuilder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ AddLayer()

void SetupBuilder::AddLayer ( SetupBuilder::LayerProperty geoLayer)

Adds material layer.

Parameters
geoLayerA geometrical layer

Definition at line 33 of file KfSetupBuilder.cxx.

References fbReady, and fGeoLayers.

Referenced by SetFromSetup().

◆ GetFieldFunction()

const FieldFn_t & cbm::algo::kf::SetupBuilder::GetFieldFunction ( ) const
inline

Access to field funciton.

Definition at line 103 of file KfSetupBuilder.h.

References fFieldBuilder.

◆ Init()

void SetupBuilder::Init ( )

Initializes, validates and caches the parameters.

Exceptions
std::runtime_errorIf pre-initialization was incomplete
Note
Does not touch the field function and field type/mode

Definition at line 51 of file KfSetupBuilder.cxx.

References fbIfFieldFunctionSet, fbIfGeoLayersInit, fbIfSetFromSetup, fbIfTargetSet, fbReady, fFieldBuilder, fGeoLayers, fMatMapNofBins, fModuleIndexFactory, fpMaterialMapFactory, fsMaterialCacheFile, fTarget, fvMaterial, kTargetCenterOffset, kTargetMaterialMapNofBins, kTargetMaterialOffset, kTargetMaterialTransverseSizeMargin, LoadMaterial(), and StoreMaterial().

◆ InitStatusMsg()

std::string SetupBuilder::InitStatusMsg ( ) const
private

Prints initialization status message.

Definition at line 141 of file KfSetupBuilder.cxx.

References fbIfFieldFunctionSet, fbIfGeoLayersInit, fbIfSetFromSetup, fbIfTargetSet, and fpMaterialMapFactory.

◆ Load()

template<typename F>
Setup< F > cbm::algo::kf::SetupBuilder::Load ( const std::string & fileName)
static

Loads a serialized setup from a file.

Template Parameters
FUnderlying floating-point type for the output setup object
Parameters
fileNameInput file name
Exceptions
std::runtime_errorIf the fileName cannot be opened

Definition at line 308 of file KfSetupBuilder.h.

◆ LoadMaterial()

bool SetupBuilder::LoadMaterial ( )
private

Reads material from file.

Returns
true Material budget was read from file
false Material budget could not read (file does not exist or has incorrect properties)

Definition at line 155 of file KfSetupBuilder.cxx.

References fGeoHash, fsMaterialCacheFile, fTarget, and fvMaterial.

Referenced by Init().

◆ MakeSetup()

template<typename F>
Setup< F > cbm::algo::kf::SetupBuilder::MakeSetup ( EFieldMode fldMode) const

Creates a setup instance.

Template Parameters
FFloating point underlying type
Parameters
fldModeField mode of the setup
Exceptions
std::runtime_errorIf the setup is not initialized

Definition at line 287 of file KfSetupBuilder.h.

References F, fbReady, fFieldBuilder, fGeoLayers, fModuleIndexFactory, fTarget, and fvMaterial.

◆ operator=() [1/2]

SetupBuilder & cbm::algo::kf::SetupBuilder::operator= ( const SetupBuilder & )
delete

Copy assignment operator.

References SetupBuilder().

◆ operator=() [2/2]

SetupBuilder & cbm::algo::kf::SetupBuilder::operator= ( SetupBuilder && )
delete

Move assignment operator.

References SetupBuilder().

◆ Reset()

void SetupBuilder::Reset ( )

◆ SetFieldFunction()

void cbm::algo::kf::SetupBuilder::SetFieldFunction ( const FieldFn_t & fieldFn,
EFieldType fieldType )
inline

Sets magnetic field function.

Parameters
fieldFnMagnetic field function
fieldTypeMagnetic field type
Note
The fieldType, passed in this function is a global flag for the whole setup. When it is assigned to a geometrical layer (see. AddLayer)

Definition at line 125 of file KfSetupBuilder.h.

References fbIfFieldFunctionSet, fbReady, fFieldBuilder, and kTargetFieldInitStep.

◆ SetFromSetup()

template<typename F>
void cbm::algo::kf::SetupBuilder::SetFromSetup ( const Setup< F > & inSetup)

◆ SetMaterialCacheFile()

void cbm::algo::kf::SetupBuilder::SetMaterialCacheFile ( const std::string & filename,
size_t refHash )
inline

Sets the material budget cache file name.

Parameters
filenameMaterial budget cache file name
refHashReference hash of the geometry

If provided, the instance will try to read the material budget maps from the file. If the file does not exist,or the geometry hash was changed since the last time (reference hash differs from the one read from the file), a warning will be produced, the material budget maps will be recreated on the fly and they will be stored again to the file (meaning a new cache file will be generated over the existing one).

Definition at line 155 of file KfSetupBuilder.h.

References fGeoHash, and fsMaterialCacheFile.

◆ SetMaterialMapFactory()

void cbm::algo::kf::SetupBuilder::SetMaterialMapFactory ( const std::shared_ptr< IMaterialMapFactory > & pMaterialFactory)
inline

Sets material map creator.

Parameters
pMaterialFactoryPointer to the actual material map creator instance

Definition at line 141 of file KfSetupBuilder.h.

References fbReady, and fpMaterialMapFactory.

◆ SetTargetProperty()

void SetupBuilder::SetTargetProperty ( double x,
double y,
double z,
double dz,
double r )

Sets target initialization properties.

Parameters
xTarget x-coordinate [cm]
yTarget y-coordinate [cm]
zTarget z-coordinate [cm]
dzTarget half-thickness [cm]
rTarget transverse size (XYmax)

Definition at line 208 of file KfSetupBuilder.cxx.

References fbIfTargetSet, fbReady, fFieldBuilder, fTarget, x, and y.

◆ Store()

void SetupBuilder::Store ( const Setup< double > & setup,
const std::string & fileName )
static

Stores a serialized setup to a file.

Parameters
setupA reference to the Setup (NOTE: a double-Setup must be passed explicitly)
fileNameOutput file name

Only a Setup with T = double can be serialized, so if a particular setup instance has another floating-point type, it will be converted to the double-version. In the serialization only the interpolated magnetic field variant is stored, the original field version will be set to nullopt during the loading from the file.

Definition at line 222 of file KfSetupBuilder.cxx.

◆ StoreMaterial()

void SetupBuilder::StoreMaterial ( ) const
private

Stores material to file.

Definition at line 239 of file KfSetupBuilder.cxx.

References fGeoHash, fsMaterialCacheFile, fTarget, and fvMaterial.

Referenced by Init().

Member Data Documentation

◆ fbIfFieldFunctionSet

bool cbm::algo::kf::SetupBuilder::fbIfFieldFunctionSet {false}
private

Field function initialized.

Definition at line 223 of file KfSetupBuilder.h.

Referenced by Init(), InitStatusMsg(), Reset(), and SetFieldFunction().

◆ fbIfGeoLayersInit

bool cbm::algo::kf::SetupBuilder::fbIfGeoLayersInit {false}
private

Geo layers initialized.

Definition at line 222 of file KfSetupBuilder.h.

Referenced by Init(), InitStatusMsg(), Reset(), and SetFromSetup().

◆ fbIfSetFromSetup

bool cbm::algo::kf::SetupBuilder::fbIfSetFromSetup {false}
private

Definition at line 224 of file KfSetupBuilder.h.

Referenced by Init(), InitStatusMsg(), Reset(), and SetFromSetup().

◆ fbIfTargetSet

bool cbm::algo::kf::SetupBuilder::fbIfTargetSet {false}
private

Target initialized.

Definition at line 221 of file KfSetupBuilder.h.

Referenced by Init(), InitStatusMsg(), Reset(), SetFromSetup(), and SetTargetProperty().

◆ fbReady

bool cbm::algo::kf::SetupBuilder::fbReady {false}
private

Instance is ready for setup generation.

Definition at line 225 of file KfSetupBuilder.h.

Referenced by AddLayer(), Init(), MakeSetup(), Reset(), SetFieldFunction(), SetFromSetup(), SetMaterialMapFactory(), and SetTargetProperty().

◆ fFieldBuilder

FieldBuilder cbm::algo::kf::SetupBuilder::fFieldBuilder
private

Instance of field factory.

Definition at line 216 of file KfSetupBuilder.h.

Referenced by GetFieldFunction(), Init(), MakeSetup(), Reset(), SetFieldFunction(), SetFromSetup(), and SetTargetProperty().

◆ fGeoHash

size_t cbm::algo::kf::SetupBuilder::fGeoHash {0}
private

A hash of the geometry.

Definition at line 218 of file KfSetupBuilder.h.

Referenced by LoadMaterial(), SetMaterialCacheFile(), and StoreMaterial().

◆ fGeoLayers

std::set<LayerProperty> cbm::algo::kf::SetupBuilder::fGeoLayers {}
private

Set of geometrical layers.

Definition at line 211 of file KfSetupBuilder.h.

Referenced by AddLayer(), Init(), MakeSetup(), Reset(), and SetFromSetup().

◆ fMatMapNofBins

int cbm::algo::kf::SetupBuilder::fMatMapNofBins {100}
private

Number of bins in material maps.

Definition at line 219 of file KfSetupBuilder.h.

Referenced by Init().

◆ fModuleIndexFactory

ModuleIndexMapFactory cbm::algo::kf::SetupBuilder::fModuleIndexFactory
private

Module index factory.

Definition at line 215 of file KfSetupBuilder.h.

Referenced by Init(), MakeSetup(), Reset(), and SetFromSetup().

◆ fpMaterialMapFactory

std::shared_ptr<IMaterialMapFactory> cbm::algo::kf::SetupBuilder::fpMaterialMapFactory {nullptr}
private

Material map creator.

Definition at line 214 of file KfSetupBuilder.h.

Referenced by Init(), InitStatusMsg(), Reset(), and SetMaterialMapFactory().

◆ fsMaterialCacheFile

std::string cbm::algo::kf::SetupBuilder::fsMaterialCacheFile {""}
private

A cache file for the material.

Definition at line 212 of file KfSetupBuilder.h.

Referenced by Init(), LoadMaterial(), SetMaterialCacheFile(), and StoreMaterial().

◆ fTarget

Target<double> cbm::algo::kf::SetupBuilder::fTarget
private

Target properties.

Definition at line 217 of file KfSetupBuilder.h.

Referenced by Init(), LoadMaterial(), MakeSetup(), SetFromSetup(), SetTargetProperty(), and StoreMaterial().

◆ fvMaterial

std::vector<MaterialMap> cbm::algo::kf::SetupBuilder::fvMaterial {}
private

Material map container.

Definition at line 213 of file KfSetupBuilder.h.

Referenced by Init(), LoadMaterial(), MakeSetup(), Reset(), SetFromSetup(), and StoreMaterial().

◆ kTargetCenterOffset

double cbm::algo::kf::SetupBuilder::kTargetCenterOffset {0.05}
staticconstexprprivate

Offset from target center [cm].

Definition at line 204 of file KfSetupBuilder.h.

Referenced by Init().

◆ kTargetFieldInitStep

double cbm::algo::kf::SetupBuilder::kTargetFieldInitStep
staticconstexprprivate
Initial value:
{
2.5}

Step between nodal points to determine field near target [cm].

Definition at line 207 of file KfSetupBuilder.h.

Referenced by SetFieldFunction().

◆ kTargetMaterialMapNofBins

int cbm::algo::kf::SetupBuilder::kTargetMaterialMapNofBins {20}
staticconstexprprivate

Number of bins along x- and y-axis in the target region;.

Definition at line 209 of file KfSetupBuilder.h.

Referenced by Init().

◆ kTargetMaterialOffset

double cbm::algo::kf::SetupBuilder::kTargetMaterialOffset {2.}
staticconstexprprivate

Offset of the target material [in dz].

Definition at line 205 of file KfSetupBuilder.h.

Referenced by Init().

◆ kTargetMaterialTransverseSizeMargin

double cbm::algo::kf::SetupBuilder::kTargetMaterialTransverseSizeMargin {1.3}
staticconstexprprivate

Margin of target transverse size.

Definition at line 206 of file KfSetupBuilder.h.

Referenced by Init().


The documentation for this class was generated from the following files: