15#include <boost/archive/binary_iarchive.hpp>
16#include <boost/archive/binary_oarchive.hpp>
29 template<
class EDetID>
31 GeoLayer(EDetID detID,
int iLoc,
double zRef,
double zMin,
double zMax,
double xMax,
double yMax)
87 template<
class EDetID>
214 template<
class EDetID>
221 std::stringstream msg;
222 msg <<
"SetupBuilder::AddLayer: attempt of adding a duplicating geometry layer: ";
223 msg <<
"DetID = " <<
static_cast<int>(geoLayer.
fDetID) <<
", localID = " << geoLayer.
fLocID
224 <<
"fZref = " << geoLayer.
fZref <<
", fZmin = " << geoLayer.
fZmin <<
", fZmax = " << geoLayer.
fZmax
225 <<
", fXmax = " << geoLayer.
fXmax <<
", fYmax = " << geoLayer.
fYmax
226 <<
".\nThe next layers were already added:";
228 msg <<
"\n\t- DetID = " <<
static_cast<int>(el.fDetID) <<
", localID = " << el.fLocID <<
"fZref = " << el.fZref
229 <<
", fZmin = " << el.fZmin <<
", fZmax = " << el.fZmax <<
", fXmax = " << el.fXmax
230 <<
", fYmax = " << el.fYmax;
232 throw std::logic_error(msg.str());
253 for (
int iLayer{0}; iLayer < inSetup.GetNofMaterialLayers(); ++iLayer) {
257 const auto& [iDetExt, iLoc] = inSetup.
GetIndexMap().template GlobalToLocal<int>(iLayer);
276 for (
const auto& material : this->
fvMaterial) {
290 std::ifstream ifs(fileName, std::ios::binary);
292 std::stringstream msg;
293 msg <<
"kf::SetupBuilder::Load: intput setup file \"" << fileName <<
"\" was not found";
294 throw std::runtime_error(msg.str());
297 boost::archive::binary_iarchive ia(ifs);
300 catch (
const std::exception& err) {
301 std::stringstream msg;
302 msg <<
"kf::SetupBuilder::Load: input setup file \"" << fileName
303 <<
"\" has inconsistent format or was "
304 "corrupted. The exception message: "
306 throw std::runtime_error(msg.str());
Interface to the material map creator.
Setup representation for the Kalman-filter framework (header)
A helper class to instantiate a Field object.
void SetStep(double step=2.5)
Sets a step for the primary vertex field region estimation.
Field< T > MakeField() const
Create field.
void ResetSliceReferences()
Resets slicer references.
void SetFieldFunction(const FieldFn_t &fieldFn, EFieldType fldType)
Sets magnetic field function.
void AddSliceReference(double halfSizeX, double halfSizeY, double refZ)
Adds a slice reference.
Creates a valid module mapper.
void Reset()
Resets the instance.
ModuleIndexMap MakeIndexMap() const
Creates a module index map.
void AddComponent(EDetID detId, int locId, double z)
Adds component info.
Creates a valid initialized Setup instance.
void AddLayer(const GeoLayer< EDetID > &geoLayer)
Adds material layer.
void Reset()
Resets the instance.
static constexpr double kTargetFieldInitStep
SetupBuilder()=default
Default constructor.
int fMatMapNofBins
Number of bins in material maps.
std::string fsMaterialCacheFile
A cache file for the material.
static constexpr double kTargetMaterialOffset
std::string InitStatusMsg() const
Prints initialization status message.
bool fbIfFieldFunctionSet
Field function initialized.
static constexpr double kTargetMaterialTransverseSizeMargin
Setup< T > MakeSetup(EFieldMode fldMode)
Creates a setup instance.
static Setup< T > Load(const std::string &fileName)
Loads a serialized setup from a file.
std::set< GeoLayer< int > > fGeoLayers
Set of geo layers.
FieldFactory fFieldFactory
Instance of field factory.
ModuleIndexMapFactory fModuleIndexFactory
Module index factory.
Target< double > fTarget
Target properties.
virtual ~SetupBuilder()=default
Destructor.
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.
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.
void SetTargetProperty(double x, double y, double z, double dz, double r)
Sets target initialization properties.
static constexpr int kTargetMaterialMapNofBins
static constexpr double kTargetCenterOffset
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.
void SetFromSetup(const Setup< T > &inSetup)
Initializes the setup builder from existing setup.
KF-framework representation of the detector setup.
const ModuleIndexMap & GetIndexMap() const
Gets module index map.
Field< T > fField
Interpolated field (NOTE: maybe make optional)
ModuleIndexMap fModuleIndexMap
Index map (internal->external)
std::string ToString(int verbosity=1, int indentLevel=0) const
String representation of the class contents.
const MaterialMap & GetMaterial(int iLayer) const
Gets material layer.
std::vector< MaterialMap > fvMaterialLayers
Container of the material maps.
Target< T > fTarget
Target layer.
A geometry layer in the target region.
EFieldMode
Enumiration for the magnetic field representation variants in the track fitting algorithm.
@ Intrpl
Interpolated magnetic field.
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 fZmax
Upper z-coordinate boundary [cm].
GeoLayer(EDetID detID, int iLoc, double zRef, double zMin, double zMax, double xMax, double yMax)
double fXmax
Half size of the layer in the x-direction [cm].
double fYmax
Half size of the layer in the y-direction [cm].
int fLocID
Local index of the detector module.
EDetID fDetID
Index of detector subsystem.
bool operator<(const GeoLayer &rhs) const
double fZmin
Lower z-coordinate boundary [cm].
double fZref
Reference z-coordinate [cm].