Skip to content
Snippets Groups Projects
Segmentations.cpp 4.05 KiB
Newer Older
//====================================================================
//  AIDA Detector description implementation for LCD
//--------------------------------------------------------------------
//
//  Author     : M.Frank
//
//====================================================================

#include "DD4hep/Segmentations.h"
Markus Frank's avatar
Markus Frank committed
#include "DD4hep/Handle.inl"
#include <stdexcept>
using namespace DD4hep;
using DD4hep::DDSegmentation::Parameter;
using DD4hep::DDSegmentation::Parameters;
using DD4hep::DDSegmentation::SegmentationParameter;
Markus Frank's avatar
Markus Frank committed
DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject);

Markus Frank's avatar
Markus Frank committed
SegmentationObject::SegmentationObject(BaseSegmentation* s)
  : magic(magic_word()), useForHitPosition(0), segmentation(s) {
Markus Frank's avatar
Markus Frank committed
SegmentationObject::~SegmentationObject() {
/// determine the local position based on the cell ID
DDSegmentation::Vector3D SegmentationObject::position(const long64& cell) const {
  return segmentation->position(cell);
}

/// determine the cell ID based on the local position
long64 SegmentationObject::cellID(const DDSegmentation::Vector3D& localPosition, const DDSegmentation::Vector3D& globalPosition, const long64& volID) const {
  return segmentation->cellID(localPosition, globalPosition, volID);
Markus Frank's avatar
Markus Frank committed
string SegmentationObject::fieldDescription() const {
  return segmentation->fieldDescription();
Markus Frank's avatar
Markus Frank committed
const string& SegmentationObject::name() const {
  return segmentation->name();
Markus Frank's avatar
Markus Frank committed
void SegmentationObject::setName(const string& value) {
  segmentation->setName(value);
Markus Frank's avatar
Markus Frank committed
const string& SegmentationObject::type() const {
  return segmentation->type();
/// Access the description of the segmentation
Markus Frank's avatar
Markus Frank committed
const string& SegmentationObject::description() const {
  return segmentation->description();
Markus Frank's avatar
Markus Frank committed
BitField64* SegmentationObject::decoder() {
  return segmentation->decoder();
void SegmentationObject::setDecoder(BitField64* ptr_decoder) {
  segmentation->setDecoder(ptr_decoder);
Markus Frank's avatar
Markus Frank committed
Parameter SegmentationObject::parameter(const string& parameterName) const {
  return segmentation->parameter(parameterName);
Markus Frank's avatar
Markus Frank committed
Parameters SegmentationObject::parameters() const {
  return segmentation->parameters();
/// Set all parameters from an existing set of parameters
void SegmentationObject::setParameters(const Parameters& params) {
  segmentation->setParameters(params);
}

/// Constructor to used when creating a new object
Segmentation::Segmentation(const string& typ, const string& nam) :
  BaseSegmentation* s = DDSegmentation::SegmentationFactory::instance()->create(typ);
    assign(new Object(s), nam, "");
    throw runtime_error("FAILED to create segmentation: " + typ + ". Missing factory method for: " + typ + "!");
/// Accessor: Segmentation type
std::string Segmentation::type() const {
bool Segmentation::useForHitPosition() const {
  return data<Object>()->useForHitPosition != 0;
/// Access to the parameters
Parameters Segmentation::parameters() const {
  return data<Object>()->parameters();
/// Access segmentation object
DDSegmentation::Segmentation* Segmentation::segmentation() const {
  return data<Object>()->segmentation;
/// determine the local position based on the cell ID
Position Segmentation::position(const long64& cell) const {
  return Position(segmentation()->position(cell));
/// determine the cell ID based on the local position
long64 Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const long64& volID) const {
  return segmentation()->cellID(localPosition, globalPosition, volID);