Belle II Software  release-08-01-10
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 147 of file GeoCache.cc.

148  {
149  //Save pointer to the SensorInfo and update lists of all existing
150  //layers,ladders,sensors
151  VxdID sensorID = sensorinfo->getID();
152  VxdID ladderID = sensorID;
153  ladderID.setSensorNumber(0);
154  VxdID layerID = ladderID;
155  layerID.setLadderNumber(0);
156 
157  m_sensorInfo[sensorID] = sensorinfo;
158 
159  switch (sensorinfo->getType()) {
160  case SensorInfoBase::PXD:
161  m_pxdLayers.insert(layerID);
162  break;
163  case SensorInfoBase::SVD:
164  m_svdLayers.insert(layerID);
165  break;
166  case SensorInfoBase::TEL:
167  m_telLayers.insert(layerID);
168  break;
169  default:
170  B2FATAL("Cannot use anything else as SensorTypes PXD, SVD, or TEL when creating VXD Sensors");
171  }
172  m_ladders[layerID].insert(ladderID);
173  m_sensors[ladderID].insert(sensorID);
174  }
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 78 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:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214

◆ 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 239 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 250 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 176 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 59 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 241 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 259 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 52 of file GeoCache.cc.


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