Newer
Older
Markus Frank
committed
//==========================================================================
Markus Frank
committed
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
Markus Frank
committed
// All rights reserved.
Pere Mato
committed
//
Markus Frank
committed
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
Pere Mato
committed
//
Markus Frank
committed
// Author : M.Frank
//
//==========================================================================
Pere Mato
committed
Markus Frank
committed
// Framework include files
Pere Mato
committed
#include "DD4hep/Segmentations.h"
Markus Frank
committed
#include "DD4hep/InstanceCount.h"
Markus Frank
committed
#include "DD4hep/Printout.h"
#include "DD4hep/detail/Handle.inl"
#include "DD4hep/detail/SegmentationsInterna.h"
Markus Frank
committed
// C/C++ include files
Pere Mato
committed
#include <iostream>
Pere Mato
committed
using namespace std;
using namespace dd4hep;
using namespace dd4hep::detail;
Pere Mato
committed
DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject);
/// Constructor to used when creating a new object
Segmentation::Segmentation(const string& typ, const string& nam, const BitFieldCoder* dec) : Handle<Object>()
string seg_type = "segmentation_constructor__"+typ;
SegmentationObject* obj = PluginService::Create<SegmentationObject*>(seg_type, dec);
if ( obj != 0 ) {
assign(obj, nam, typ);
if ( !nam.empty() ) obj->setName(nam);
// This is fatal and cannot be recovered. We need to throw an exception here.
except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str());
/// Accessor: Segmentation type
const char* Segmentation::name() const {
return access()->name().c_str();
}
std::string Segmentation::type() const {
return access()->type();
Pere Mato
committed
}
bool Segmentation::useForHitPosition() const {
return access()->useForHitPosition != 0;
DDSegmentation::Parameters Segmentation::parameters() const {
return access()->parameters();
DDSegmentation::Parameter Segmentation::parameter(const std::string& parameterName) const {
return access()->parameter(parameterName);
/// determine the local position based on the cell ID
Position Segmentation::position(const CellID& cell) const {
return Position(access()->segmentation->position(cell));
/// determine the cell ID based on the local position
CellID Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const CellID & volID) const {
return access()->segmentation->cellID(localPosition, globalPosition, volID);
Markus Frank
committed
/// Determine the volume ID from the full cell ID by removing all local fields
VolumeID Segmentation::volumeID(const CellID& cell) const {
return access()->segmentation->volumeID(cell);
Markus Frank
committed
}
/// Calculates the neighbours of the given cell ID and adds them to the list of neighbours
void Segmentation::neighbours(const CellID& cell, std::set<CellID>& nb) const {
access()->segmentation->neighbours(cell, nb);
Markus Frank
committed
}
/** \brief Returns a vector<double> of the cellDimensions of the given cell ID
* in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
*
* \param cellID cellID of the cell for which parameters are returned
* \return vector<double> in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
*/
std::vector<double> Segmentation::cellDimensions(const CellID& cell) const {
return access()->segmentation->cellDimensions(cell);
/// Access to the base DDSegmentation object. WARNING: Deprecated call!
DDSegmentation::Segmentation* Segmentation::segmentation() const {
return access()->segmentation;
/// Access the underlying decoder
const BitFieldCoder* Segmentation::decoder() const {
return access()->segmentation->decoder();
}
/// Set the underlying decoder
void Segmentation::setDecoder(const BitFieldCoder* decode) const {
access()->segmentation->setDecoder(decode);
Pere Mato
committed
}
Markus Frank
committed
/// Access the main detector element using this segmentation object
Markus Frank
committed
Handle<DetElementObject> Segmentation::detector() const {
return access()->detector;
Markus Frank
committed
}
/// Access the sensitive detector using this segmentation object
Markus Frank
committed
Handle<SensitiveDetectorObject> Segmentation::sensitive() const {
return access()->sensitive;
Markus Frank
committed
}
Markus Frank
committed
#include "DDSegmentation/NoSegmentation.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::NoSegmentation);
Markus Frank
committed
#include "DDSegmentation/CartesianGrid.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGrid);
Markus Frank
committed
#include "DDSegmentation/CartesianGridXY.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXY);
Markus Frank
committed
#include "DDSegmentation/CartesianGridXZ.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXZ);
Markus Frank
committed
#include "DDSegmentation/CartesianGridYZ.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridYZ);
Markus Frank
committed
#include "DDSegmentation/CartesianGridXYZ.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXYZ);
Markus Frank
committed
#include "DDSegmentation/CartesianStripX.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripX);
#include "DDSegmentation/CartesianStripY.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripY);
#include "DDSegmentation/CartesianStripZ.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripZ);
Markus Frank
committed
#include "DDSegmentation/TiledLayerGridXY.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::TiledLayerGridXY);
Markus Frank
committed
#include "DDSegmentation/MegatileLayerGridXY.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MegatileLayerGridXY);
Markus Frank
committed
#include "DDSegmentation/WaferGridXY.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::WaferGridXY);
Markus Frank
committed
#include "DDSegmentation/PolarGridRPhi.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi);
Markus Frank
committed
#include "DDSegmentation/PolarGridRPhi2.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi2);
Markus Frank
committed
#include "DDSegmentation/GridPhiEta.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridPhiEta);
#include "DDSegmentation/GridRPhiEta.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridRPhiEta);
Markus Frank
committed
#include "DDSegmentation/ProjectiveCylinder.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::ProjectiveCylinder);
Markus Frank
committed
Markus Frank
committed
#include "DDSegmentation/MultiSegmentation.h"
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MultiSegmentation);