8 #ifndef DDSegmentation_SEGMENTATION_H_
9 #define DDSegmentation_SEGMENTATION_H_
22 namespace DDSegmentation {
37 typedef long long int CellID;
43 Vector3D(
double x_val = 0.,
double y_val = 0.,
double z_val = 0.) :
44 X(x_val),
Y(y_val),
Z(z_val) {
89 virtual const std::string&
name()
const {
93 virtual void setName(
const std::string& value) {
97 virtual const std::string&
type()
const {
133 bool isOpt =
false) {
137 void registerIdentifier(
const std::string& nam,
const std::string& desc, std::string& ident,
138 const std::string& defaultVal);
146 static double binToPosition(
CellID bin, std::vector<double>
const& cellBoundaries,
double offset = 0.);
148 static int positionToBin(
double position, std::vector<double>
const& cellBoundaries,
double offset = 0.);
170 #define REGISTER_SEGMENTATION(classname) \
171 static const SegmentationCreator<classname> classname##_creator(#classname);
long long int CellID
Useful typedefs to differentiate cell IDs and volume IDs.
Vector3D(const T &v)
Constructor using a foreign vector class. Requires methods x(), y() and z()
double x() const
Access to x value (required for use with ROOT GenVector)
void registerIdentifier(const std::string &nam, const std::string &desc, std::string &ident, const std::string &defaultVal)
Add a cell identifier to this segmentation. Used by derived classes to define their required identifi...
virtual VolumeID volumeID(const CellID &cellID) const
Determine the volume ID from the full cell ID by removing all local fields.
std::map< std::string, StringParameter > _indexIdentifiers
The indices used for the encoding.
virtual void neighbours(const CellID &cellID, std::set< CellID > &neighbours) const
Calculates the neighbours of the given cell ID and adds them to the list of neighbours.
virtual BitField64 * decoder() const
Access the underlying decoder.
TypedSegmentationParameter< std::vector< float > > * FloatVecParameter
TypedSegmentationParameter< double > * DoubleParameter
virtual Parameters parameters() const
Access to all parameters.
virtual const std::string & name() const
Access the segmentation name.
BitField64 * _decoder
The cell ID encoder and decoder.
double y() const
Access to y value (required for use with ROOT GenVector)
UnitType
Defines the parameter unit type (useful to convert to default set of units)
TypedSegmentationParameter< std::vector< int > > * IntVecParameter
std::vector< Parameter > Parameters
TypedSegmentationParameter< std::vector< double > > * DoubleVecParameter
virtual Vector3D position(const CellID &cellID) const =0
Determine the local position based on the cell ID.
virtual void setParameters(const Parameters ¶meters)
Set all parameters from an existing set of parameters.
Segmentation(const std::string &cellEncoding="")
Default constructor used by derived classes passing the encoding string.
virtual std::vector< double > cellDimensions(const CellID &cellID) const
Returns a vector<double> of the cellDimensions of the given cell ID in natural order of dimensions...
Simple container for a physics vector.
bool _ownsDecoder
Keeps track of the decoder ownership.
std::map< std::string, Parameter > _parameters
The parameters for this segmentation.
std::string _description
The description of the segmentation.
TypedSegmentationParameter< int > * IntParameter
Base class for all segmentations.
virtual CellID cellID(const Vector3D &localPosition, const Vector3D &globalPosition, const VolumeID &volumeID) const =0
Determine the cell ID based on the position.
double z() const
Access to z value (required for use with ROOT GenVector)
static int positionToBin(double position, double cellSize, double offset=0.)
Helper method to convert a 1D position to a cell ID.
Vector3D(double x_val=0., double y_val=0., double z_val=0.)
Default constructor.
TypedSegmentationParameter< std::vector< std::string > > * StringVecParameter
void registerParameter(const std::string &nam, const std::string &desc, TYPE ¶m, const TYPE &defaultVal, UnitType unitTyp=SegmentationParameter::NoUnit, bool isOpt=false)
Add a parameter to this segmentation. Used by derived classes to define their parameters.
virtual Parameter parameter(const std::string ¶meterName) const
Access to parameter by name.
std::string fieldDescription() const
std::string _type
The segmentation type.
virtual void addSubsegmentation(long key_min, long key_max, Segmentation *entry)
Add subsegmentation. Call only valid for Multi-segmentations. Default implementation throws an except...
virtual void setDecoder(BitField64 *decoder)
Set the underlying decoder.
virtual void setName(const std::string &value)
Set the segmentation name.
std::string _name
The segmentation name.
virtual ~Segmentation()
Destructor.
virtual const std::string & type() const
Access the segmentation type.
Class to hold a segmentation parameter with its description.
TypedSegmentationParameter< std::string > * StringParameter
SegmentationParameter * Parameter
static double binToPosition(CellID bin, double cellSize, double offset=0.)
Helper method to convert a bin number to a 1D position.
virtual const std::string & description() const
Access the description of the segmentation.
TypedSegmentationParameter< float > * FloatParameter
virtual std::string fieldDescription() const
Access the encoding string.
SegmentationParameter::UnitType UnitType