15#include <boost/archive/binary_iarchive.hpp>
16#include <boost/archive/binary_oarchive.hpp>
25#include <fmt/format.h>
239 LOG(debug) <<
"kf::SetupBuilder: setting properties from input setup: " << inSetup.
ToString(2);
252 for (
int iLayer{0}; iLayer < inSetup.
GetNofLayers(); ++iLayer) {
256 fFieldBuilder.AddSliceReference(material.GetXYmax(), material.GetXYmax(), material.GetZref());
257 const auto& [iDetExt, iLoc] = inSetup.
GetIndexMap().template GlobalToLocal<int>(iLayer);
266 .xMinFull = -material.GetXYMax(),
267 .xMaxFull = +material.GetXYMax(),
268 .yMinFull = -material.GetXYMax(),
269 .yMaxFull = +material.GetXYMax(),
274 .fieldType = actLayer.GetFieldType(),
275 .timeInfo = actLayer.IsTimeMeasured()}));
290 throw std::runtime_error(
291 "kf::SetupBuilder is not ready to build a setup. Please, provide all setters and call the "
296 std::vector<ActiveLayer<F>> vActiveLayers;
299 [](
const auto& in) ->
ActiveLayer<F> { return in.template CreateActiveLayer<F>(); });
311 std::ifstream ifs(fileName, std::ios::binary);
313 throw std::runtime_error(fmt::format(
"kf::SetupBuilder::Load: intput setup file \"{}\" was not found", fileName));
316 boost::archive::binary_iarchive ia(ifs);
319 catch (
const std::exception& err) {
320 throw std::runtime_error(fmt::format(
"kf::SetupBuilder::Load: input setup file \"{}\" has inconsistent format or "
321 "was corrupted. The exception message: ",
322 fileName, err.what()));
324 if constexpr (std::is_same_v<F, double>) {
Interface to the material map creator.
Setup representation for the Kalman-filter framework (header)
Properties of an active surface of the layer.
A builder class for kf::Field.
Creates a valid module mapper.
Setup< F > MakeSetup(EFieldMode fldMode) const
Creates a setup instance.
void Reset()
Resets the instance.
static constexpr double kTargetFieldInitStep
Step between nodal points to determine field near target [cm].
SetupBuilder()=default
Default constructor.
int fMatMapNofBins
Number of bins in material maps.
std::string fsMaterialCacheFile
A cache file for the material.
std::set< LayerProperty > fGeoLayers
Set of geometrical layers.
void SetFromSetup(const Setup< F > &inSetup)
Initializes the setup builder from existing setup.
static constexpr double kTargetMaterialOffset
Offset of the target material [in dz].
std::string InitStatusMsg() const
Prints initialization status message.
bool fbIfFieldFunctionSet
Field function initialized.
static constexpr double kTargetMaterialTransverseSizeMargin
Margin of target transverse size.
ModuleIndexMapFactory fModuleIndexFactory
Module index factory.
Target< double > fTarget
Target properties.
virtual ~SetupBuilder()=default
Destructor.
FieldBuilder fFieldBuilder
Instance of field factory.
bool fbIfGeoLayersInit
Geo layers initialized.
bool LoadMaterial()
Reads material from file.
void StoreMaterial() const
Stores material to file.
SetupBuilder & operator=(SetupBuilder &&)=delete
Move assignment operator.
static Setup< F > Load(const std::string &fileName)
Loads a serialized setup from a file.
void SetMaterialMapFactory(const std::shared_ptr< IMaterialMapFactory > &pMaterialFactory)
Sets material map creator.
void SetFieldFunction(const FieldFn_t &fieldFn, EFieldType fieldType)
Sets magnetic field function.
void Init()
Initializes, validates and caches the parameters.
SetupBuilder(const SetupBuilder &)=delete
Copy constructor.
const FieldFn_t & GetFieldFunction() const
Access to field funciton.
void AddLayer(LayerProperty geoLayer)
Adds material layer.
void SetTargetProperty(double x, double y, double z, double dz, double r)
Sets target initialization properties.
static constexpr int kTargetMaterialMapNofBins
Number of bins along x- and y-axis in the target region;.
static constexpr double kTargetCenterOffset
Offset from target center [cm].
void SetMaterialCacheFile(const std::string &filename, size_t refHash)
Sets the material budget cache file name.
SetupBuilder(SetupBuilder &&)=delete
Move constructor.
std::vector< MaterialMap > fvMaterial
Material map container.
SetupBuilder & operator=(const SetupBuilder &)=delete
Copy assignment operator.
bool fbIfTargetSet
Target initialized.
bool fbReady
Instance is ready for setup generation.
static void Store(const Setup< double > &setup, const std::string &fileName)
Stores a serialized setup to a file.
std::shared_ptr< IMaterialMapFactory > fpMaterialMapFactory
Material map creator.
size_t fGeoHash
A hash of the geometry.
KF-framework representation of the detector setup.
Target< F > fTarget
Target layer.
std::string ToString(int verbosity=1, int indentLevel=0) const
String representation of the class contents.
int GetNofLayers() const
Gets number of geometry layers.
const ModuleIndexMap & GetIndexMap() const
Gets module index map.
const MaterialMap & GetMaterial(int iLayer) const
Gets material layer.
const ActiveLayer< F > & GetActiveLayer(int iLayer) const
Gets active layer instance.
A geometry layer in the target region.
DataOut Cast(const DataT &val)
Converts a value of type DataT to type DataOut.
EFieldMode
Enumiration for the magnetic field representation variants in the track fitting algorithm.
EFieldType
Magnetic field type in different setup regions.
std::function< std::tuple< double, double, double >(double, double, double)> FieldFn_t
Magnetic field function type Signature: tuple<Bx, By, Bz>(x, y, z);.
A helper structure to store geometrical information of the layers.
double xMaxAct
Upper x-coordinate boundary of active volume [cm].
bool timeInfo
If a layer stores time information.
double yMinAct
Lower x-coordinate boundary of active volume [cm].
std::string ToString() const
String representation of the class.
double zMin
Lower z-coordinate boundary [cm].
int locId
Local index of the detector module.
double xMaxFull
Upper x-coordinate boundary of full volume [cm].
double yMinFull
Lower x-coordinate boundary of full volume [cm].
bool operator<(const LayerProperty &rhs) const
Comparison method (for sorting layers)
double zMax
Upper z-coordinate boundary [cm].
double zRef
Reference z-coordinate [cm].
EFieldType fieldType
Type of the magnetic field.
double xMinAct
Lower x-coordinate boundary of active volume [cm].
ActiveLayer< F > CreateActiveLayer() const
Constructs an active layer.
double xMinFull
Lower x-coordinate boundary of full volume [cm].
double yMaxFull
Upper x-coordinate boundary of full volume [cm].
double yMaxAct
Upper x-coordinate boundary of active volume [cm].