CbmRoot
Loading...
Searching...
No Matches
SetupBuilder Class Reference

Creates a valid initialized Setup instance. More...

#include <KfSetupBuilder.h>

Collaboration diagram for 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< IMaterialMapFactory > fpMaterialMapFactory {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.

◆ SetupBuilder() [2/3]

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

Copy constructor.

◆ SetupBuilder() [3/3]

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

Move constructor.

◆ ~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.

◆ GetFieldFunction()

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

Access to field funciton.

Definition at line 103 of file KfSetupBuilder.h.

◆ 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.

◆ InitStatusMsg()

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

Prints initialization status message.

Definition at line 141 of file KfSetupBuilder.cxx.

◆ 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.

◆ 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.

◆ operator=() [1/2]

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

Copy assignment operator.

◆ operator=() [2/2]

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

Move assignment operator.

◆ Reset()

void SetupBuilder::Reset ( )

Resets the instance.

Definition at line 192 of file KfSetupBuilder.cxx.

◆ 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.

◆ SetFromSetup()

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

Initializes the setup builder from existing setup.

Template Parameters
FUnderlying data type of the setup
Parameters
inSetup

Definition at line 237 of file KfSetupBuilder.h.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

Member Data Documentation

◆ fbIfFieldFunctionSet

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

Field function initialized.

Definition at line 223 of file KfSetupBuilder.h.

◆ fbIfGeoLayersInit

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

Geo layers initialized.

Definition at line 222 of file KfSetupBuilder.h.

◆ fbIfSetFromSetup

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

Definition at line 224 of file KfSetupBuilder.h.

◆ fbIfTargetSet

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

Target initialized.

Definition at line 221 of file KfSetupBuilder.h.

◆ fbReady

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

Instance is ready for setup generation.

Definition at line 225 of file KfSetupBuilder.h.

◆ fFieldBuilder

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

Instance of field factory.

Definition at line 216 of file KfSetupBuilder.h.

◆ fGeoHash

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

A hash of the geometry.

Definition at line 218 of file KfSetupBuilder.h.

◆ fGeoLayers

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

Set of geometrical layers.

Definition at line 211 of file KfSetupBuilder.h.

◆ fMatMapNofBins

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

Number of bins in material maps.

Definition at line 219 of file KfSetupBuilder.h.

◆ fModuleIndexFactory

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

Module index factory.

Definition at line 215 of file KfSetupBuilder.h.

◆ fpMaterialMapFactory

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

Material map creator.

Definition at line 214 of file KfSetupBuilder.h.

◆ fsMaterialCacheFile

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

A cache file for the material.

Definition at line 212 of file KfSetupBuilder.h.

◆ fTarget

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

Target properties.

Definition at line 217 of file KfSetupBuilder.h.

◆ fvMaterial

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

Material map container.

Definition at line 213 of file KfSetupBuilder.h.

◆ kTargetCenterOffset

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

Offset from target center [cm].

Definition at line 204 of file KfSetupBuilder.h.

◆ 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.

◆ 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.

◆ kTargetMaterialOffset

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

Offset of the target material [in dz].

Definition at line 205 of file KfSetupBuilder.h.

◆ kTargetMaterialTransverseSizeMargin

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

Margin of target transverse size.

Definition at line 206 of file KfSetupBuilder.h.


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