Belle II Software  release-06-01-15
GeoCache Class Reference

Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pitch size. More...

#include <GeoCache.h>

Collaboration diagram for GeoCache:

Public Member Functions

 ~GeoCache ()
 destructor to clean up structures
 
void clear ()
 Clean up internal structures.
 
void findVolumes (G4VPhysicalVolume *envelope)
 Search a given Geometry for Sensors. More...
 
void addSensor (SensorInfoBase *sensorinfo)
 Add a SensorInfo instance to the list of known sensors This method will manually add a SensorInfo instance to the list of known sensors. More...
 
const std::set< Belle2::VxdIDgetLayers (SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
 Return a set of all known Layers. More...
 
const std::set< Belle2::VxdID > & getLadders (Belle2::VxdID layer) const
 Return a set of all ladder IDs belonging to a given layer.
 
const std::set< Belle2::VxdID > & getSensors (Belle2::VxdID ladder) const
 Return a set of all sensor IDs belonging to a given ladder.
 
bool validSensorID (Belle2::VxdID id) const
 Check that id is a valid sensor number. More...
 
const std::vector< VxdIDgetListOfSensors () const
 Get list of all sensors. More...
 
const SensorInfoBasegetSensorInfo (Belle2::VxdID id) const
 Return a referecne to the SensorInfo of a given SensorID.
 
const std::map< VxdID, TGeoHMatrix > & getHalfShellPlacements () const
 Retrieve stored half-shell placements into world volume. More...
 
const std::vector< std::pair< VxdID, TGeoHMatrix > > & getLadderPlacements (VxdID halfShell) const
 Retrieve stored ladder placements into half-shell. More...
 
const std::vector< std::pair< VxdID, TGeoHMatrix > > & getSensorPlacements (VxdID ladder) const
 Retrieve stored sensor placements into ladders. More...
 
void addHalfShellPlacement (VxdID halfShell, const G4Transform3D &placement)
 Remember how half-shell is placed into world volume.
 
void addLadderPlacement (VxdID halfShell, VxdID ladder, const G4Transform3D &placement)
 Remember how ladder is placed into half-shell.
 
void addSensorPlacement (VxdID ladder, VxdID sensor, const G4Transform3D &placement)
 Remember how sensor is placed into ladder.
 
void setupReconstructionTransformations ()
 Initialize from DB for reconstruction Updates all SensorInfo transformations for reconstruction from DB object(s) (recalculating new global positions) and registers itself for subsequent updates of DB objects to keep the hierarchy up-to-date. More...
 
const GeoToolsgetGeoTools ()
 Return a raw pointer to a GeoTools object. More...
 

Static Public Member Functions

static TGeoHMatrix g4Transform3DToTGeo (const G4Transform3D &g4)
 Covenient function to convert G4Transform3D to TGeoHMatrix.
 
static TGeoHMatrix getTGeoFromRigidBodyParams (double dU, double dV, double dW, double dAlpha, double dBeta, double dGamma)
 Convert 6 rigid body params (alignment corrections) to corresponding TGeoHMatrix Angles in radians, length units in centimeters.
 
static const SensorInfoBaseget (Belle2::VxdID id)
 Return a reference to the SensorInfo of a given SensorID. More...
 
static GeoCachegetInstance ()
 Return a reference to the singleton instance.
 

Private Types

typedef std::unordered_map< VxdID::baseType, SensorInfoBase * > SensorInfoMap
 Hash map to store pointers to all existing SensorInfos with constant lookup complexity.
 
typedef std::map< Belle2::VxdID, std::set< Belle2::VxdID > > SensorHierachy
 Map to store a set of unique VxdIDs belonging to one VxdID. More...
 

Private Member Functions

 GeoCache ()
 Singleton class, hidden constructor.
 
 GeoCache (const GeoCache &)=delete
 Singleton class, hidden copy constructor.
 
GeoCacheoperator= (const GeoCache &)=delete
 Singleton class, hidden assignment operator.
 

Private Attributes

std::set< Belle2::VxdIDm_pxdLayers
 Set of all PXD layer IDs.
 
std::set< Belle2::VxdIDm_svdLayers
 Set of all SVD layer IDs.
 
std::set< Belle2::VxdIDm_telLayers
 Set of all Tel layer IDs.
 
SensorHierachy m_ladders
 Map of all Ladder IDs belonging to a given Layer ID.
 
SensorHierachy m_sensors
 Map of all Sensor IDs belonging to a given Ladder ID.
 
std::map< VxdID, TGeoHMatrix > m_halfShellPlacements {}
 Map of shell ids and their placements in top volume.
 
std::map< VxdID, std::vector< std::pair< VxdID, TGeoHMatrix > > > m_ladderPlacements {}
 Map of shell ids and their associated ladder ids and their placements.
 
std::map< VxdID, std::vector< std::pair< VxdID, TGeoHMatrix > > > m_sensorPlacements {}
 Map of ladder ids and their associated sensor ids and their placements.
 
SensorInfoMap m_sensorInfo
 Map to find the SensorInfo for a given Sensor ID.
 
std::unique_ptr< GeoToolsm_geoToolsPtr
 Pointer to a GeoTools object.
 
DBObjPtr< VXDAlignmentm_vxdAlignments
 DBObjPtr for the alignment.
 

Detailed Description

Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pitch size.

Definition at line 39 of file GeoCache.h.

Member Typedef Documentation

◆ SensorHierachy

typedef std::map<Belle2::VxdID, std::set<Belle2::VxdID> > SensorHierachy
private

Map to store a set of unique VxdIDs belonging to one VxdID.

Like ladders belong to layers, etc.

Definition at line 158 of file GeoCache.h.

Member Function Documentation

◆ addSensor()

void addSensor ( SensorInfoBase sensorinfo)

Add a SensorInfo instance to the list of known sensors This method will manually add a SensorInfo instance to the list of known sensors.

It should not be needed except for testing purposes.

Parameters
sensorinfoSensorInfoBase instance to add to the list of known sensors.

Definition at line 146 of file GeoCache.cc.

147  {
148  //Save pointer to the SensorInfo and update lists of all existing
149  //layers,ladders,sensors
150  VxdID sensorID = sensorinfo->getID();
151  VxdID ladderID = sensorID;
152  ladderID.setSensorNumber(0);
153  VxdID layerID = ladderID;
154  layerID.setLadderNumber(0);
155 
156  m_sensorInfo[sensorID] = sensorinfo;
157 
158  switch (sensorinfo->getType()) {
159  case SensorInfoBase::PXD:
160  m_pxdLayers.insert(layerID);
161  break;
162  case SensorInfoBase::SVD:
163  m_svdLayers.insert(layerID);
164  break;
165  case SensorInfoBase::TEL:
166  m_telLayers.insert(layerID);
167  break;
168  default:
169  B2FATAL("Cannot use anything else as SensorTypes PXD, SVD, or TEL when creating VXD Sensors");
170  }
171  m_ladders[layerID].insert(ladderID);
172  m_sensors[ladderID].insert(sensorID);
173  }
std::set< Belle2::VxdID > m_pxdLayers
Set of all PXD layer IDs.
Definition: GeoCache.h:168
std::set< Belle2::VxdID > m_telLayers
Set of all Tel layer IDs.
Definition: GeoCache.h:172
SensorHierachy m_sensors
Map of all Sensor IDs belonging to a given Ladder ID.
Definition: GeoCache.h:176
SensorInfoMap m_sensorInfo
Map to find the SensorInfo for a given Sensor ID.
Definition: GeoCache.h:185
SensorHierachy m_ladders
Map of all Ladder IDs belonging to a given Layer ID.
Definition: GeoCache.h:174
std::set< Belle2::VxdID > m_svdLayers
Set of all SVD layer IDs.
Definition: GeoCache.h:170
@ TEL
Testbeam telescope sensor.

◆ findVolumes()

void findVolumes ( G4VPhysicalVolume *  envelope)

Search a given Geometry for Sensors.

This method will search a given Physical Volume and add all sensitive Volumes where the SensitiveDetector implementation inherits from vxd::SensitiveDetector to the cache.

The given volume must be a volume placed directly in the top volume, otherwise the transformations cannot be determined correctly.

This method should be called by the geometry creator once all sensitive volumes are placed

Parameters
envelopeGeometry tree to search, usually the Envelope of PXD or SVD

Definition at line 77 of file GeoCache.cc.

◆ get()

static const SensorInfoBase& get ( Belle2::VxdID  id)
inlinestatic

Return a reference to the SensorInfo of a given SensorID.

This function is a shorthand for GeoCache::getInstance().getSensorInfo

Definition at line 139 of file GeoCache.h.

139 { return getInstance().getSensorInfo(id); }
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:66
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213

◆ getGeoTools()

const GeoTools* getGeoTools ( )
inline

Return a raw pointer to a GeoTools object.

Returns
const GeoTools* : raw pointer, no onwership transfer

Definition at line 147 of file GeoCache.h.

◆ getHalfShellPlacements()

const map< VxdID, TGeoHMatrix > & getHalfShellPlacements ( ) const

Retrieve stored half-shell placements into world volume.

Returns
map of VxdID for half-shell and its placement

Definition at line 238 of file GeoCache.cc.

◆ getLadderPlacements()

const vector< pair< VxdID, TGeoHMatrix > > & getLadderPlacements ( VxdID  halfShell) const

Retrieve stored ladder placements into half-shell.

Returns
vector of pairs, each pair contains a VxdID for ladder (layer.ladder.0) and its placement

Definition at line 249 of file GeoCache.cc.

◆ getLayers()

const set< VxdID > getLayers ( SensorInfoBase::SensorType  sensortype = SensorInfoBase::VXD)

Return a set of all known Layers.

Parameters
sensortypeWether to only return the layer IDs for PXD, SVD or all VXD layers (default)
Returns
a set containing all existing Layers with the requested type

Definition at line 175 of file GeoCache.cc.

◆ getListOfSensors()

const vector< VxdID > getListOfSensors ( ) const

Get list of all sensors.

Intended mostly for Python, where std::sets don't work.

Returns
vector of VxdIDs of all sensors in GeoCache.

Definition at line 58 of file GeoCache.cc.

◆ getSensorPlacements()

const vector< pair< VxdID, TGeoHMatrix > > & getSensorPlacements ( VxdID  ladder) const

Retrieve stored sensor placements into ladders.

Returns
vector of pairs, each pair contains a VxdID for sensor and its placement

Definition at line 240 of file GeoCache.cc.

◆ setupReconstructionTransformations()

void setupReconstructionTransformations ( )

Initialize from DB for reconstruction Updates all SensorInfo transformations for reconstruction from DB object(s) (recalculating new global positions) and registers itself for subsequent updates of DB objects to keep the hierarchy up-to-date.

So the hierarchy is as follows: Belle 2 / | | \ Ying Yang Pat Mat ... other sub-detectors / | / | | \ | \ ...... ladders ...... / / | / | | \ | \ \ ......... sensors ........

Definition at line 258 of file GeoCache.cc.

◆ validSensorID()

bool validSensorID ( Belle2::VxdID  id) const

Check that id is a valid sensor number.

Parameters
idsensor id to be checked against current GeoCache information
Returns
true if there is a SensorInfo associated with id, otherwise false.

Definition at line 51 of file GeoCache.cc.


The documentation for this class was generated from the following files: