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]

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.
 
template<class EDetID >
void AddLayer (const GeoLayer< EDetID > &geoLayer)
 Adds material layer.
 
template<typename T >
Setup< T > MakeSetup (EFieldMode fldMode)
 Creates a setup instance.
 
void Reset ()
 Resets the instance.
 
void SetFieldFunction (const FieldFn_t &fieldFn, EFieldType fieldType)
 Sets magnetic field function.
 
template<typename T >
void SetFromSetup (const Setup< T > &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 T >
static Setup< T > Load (const std::string &fileName)
 Loads a serialized setup from a file.
 

Private Member Functions

void Init ()
 Initializes, validates and caches the parameters.
 
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< GeoLayer< int > > fGeoLayers {}
 Set of geo 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.
 
FieldFactory fFieldFactory
 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}
 
static constexpr double kTargetMaterialOffset {2.}
 
static constexpr double kTargetMaterialTransverseSizeMargin {1.3}
 
static constexpr double kTargetFieldInitStep {2.5}
 
static constexpr int kTargetMaterialMapNofBins {20}
 

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 64 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()

template<class EDetID >
void cbm::algo::kf::SetupBuilder::AddLayer ( const GeoLayer< EDetID > & geoLayer)

◆ Init()

◆ InitStatusMsg()

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

Prints initialization status message.

Definition at line 105 of file KfSetupBuilder.cxx.

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

◆ Load()

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

Loads a serialized setup from a file.

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

Definition at line 287 of file KfSetupBuilder.h.

References cbm::algo::kf::Intrpl.

Referenced by cbm::algo::ca::InitManager::ReadGeometrySetup().

◆ 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 119 of file KfSetupBuilder.cxx.

References fGeoHash, fsMaterialCacheFile, fTarget, fvMaterial, and cbm::algo::kf::Target< T >::SetMaterial().

Referenced by Init().

◆ MakeSetup()

◆ 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()

◆ 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

Definition at line 101 of file KfSetupBuilder.h.

References fbIfFieldFunctionSet, fbReady, fFieldFactory, kTargetFieldInitStep, cbm::algo::kf::FieldFactory::SetFieldFunction(), and cbm::algo::kf::FieldFactory::SetStep().

Referenced by cbm::kf::TrackingSetupBuilder::Init().

◆ SetFromSetup()

◆ 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 131 of file KfSetupBuilder.h.

References fGeoHash, and fsMaterialCacheFile.

Referenced by cbm::kf::TrackingSetupBuilder::SetMaterialCacheFile().

◆ 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 117 of file KfSetupBuilder.h.

References fbReady, and fpMaterialMapFactory.

Referenced by cbm::kf::TrackingSetupBuilder::Init().

◆ 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 170 of file KfSetupBuilder.cxx.

References fbIfTargetSet, fbReady, fFieldFactory, fTarget, cbm::algo::kf::Target< T >::SetDz(), cbm::algo::kf::Target< T >::SetR(), cbm::algo::kf::FieldFactory::SetTarget(), cbm::algo::kf::Target< T >::SetX(), cbm::algo::kf::Target< T >::SetY(), cbm::algo::kf::Target< T >::SetZ(), x, and y.

Referenced by cbm::kf::TrackingSetupBuilder::Init().

◆ 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 184 of file KfSetupBuilder.cxx.

Referenced by CbmL1::Init().

◆ StoreMaterial()

void SetupBuilder::StoreMaterial ( ) const
private

Stores material to file.

Definition at line 198 of file KfSetupBuilder.cxx.

References fGeoHash, fsMaterialCacheFile, fTarget, fvMaterial, and cbm::algo::kf::Target< T >::GetMaterial().

Referenced by Init().

Member Data Documentation

◆ fbIfFieldFunctionSet

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

Field function initialized.

Definition at line 201 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 200 of file KfSetupBuilder.h.

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

◆ fbIfSetFromSetup

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

Definition at line 202 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 199 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 203 of file KfSetupBuilder.h.

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

◆ fFieldFactory

FieldFactory cbm::algo::kf::SetupBuilder::fFieldFactory
private

Instance of field factory.

Definition at line 194 of file KfSetupBuilder.h.

Referenced by 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 196 of file KfSetupBuilder.h.

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

◆ fGeoLayers

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

Set of geo layers.

Definition at line 189 of file KfSetupBuilder.h.

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

◆ fMatMapNofBins

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

Number of bins in material maps.

Definition at line 197 of file KfSetupBuilder.h.

Referenced by Init().

◆ fModuleIndexFactory

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

Module index factory.

Definition at line 193 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 192 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 190 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 195 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 191 of file KfSetupBuilder.h.

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

◆ kTargetCenterOffset

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

Definition at line 183 of file KfSetupBuilder.h.

Referenced by Init().

◆ kTargetFieldInitStep

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

Definition at line 186 of file KfSetupBuilder.h.

Referenced by SetFieldFunction().

◆ kTargetMaterialMapNofBins

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

Definition at line 187 of file KfSetupBuilder.h.

Referenced by Init().

◆ kTargetMaterialOffset

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

Definition at line 184 of file KfSetupBuilder.h.

Referenced by Init().

◆ kTargetMaterialTransverseSizeMargin

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

Definition at line 185 of file KfSetupBuilder.h.

Referenced by Init().


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