Belle II Software  release-05-02-19
MisalignmentCache Class Reference

Class to hold misalignment information. More...

#include <MisalignmentCache.h>

Collaboration diagram for MisalignmentCache:

Public Types

typedef std::unordered_map< Belle2::VxdID::baseType, TGeoHMatrix > MisalignmentMap
 Hash map type to store existing misalignment transforms.
 
typedef std::tuple< bool, double, double > MisalignmentShiftType
 Misalignment shift information contains a validity flag (if false, the misaligned object falls outside its sensor) and shifts in u and v.
 

Public Member Functions

 ~MisalignmentCache ()
 destructor to clean up misalignment
 
void clear ()
 clear cache data
 
void readMisalignmentsFromXml (const std::string &filename)
 Read misalignment data from an xml file and store sensor misalignments. More...
 
void addMisalignment (Belle2::VxdID sensorID, const TGeoHMatrix &misalignment)
 Add a new entry to the list of sensor misalignments. More...
 
const MisalignmentMapgetMisalignments () const
 Return the list of sensor misalignments.
 
const TGeoHMatrix & getMisalignmentTransform (Belle2::VxdID id) const
 Return the misalignment transform for a given sensor. More...
 
MisalignmentShiftType getMisalignmentShift (const VXDTrueHit *hit)
 Return misalignment shift for a VXDTrueHit. More...
 

Static Public Member Functions

static MisalignmentShiftType getMisalignment (const VXDTrueHit *hit)
 Return misalignment shift for a VXDTrueHit. More...
 
static MisalignmentCachegetInstance ()
 Return a reference to the singleton instance.
 
static bool isAlive ()
 Return alive status of the cache (are there misalignment data?
 

Private Member Functions

 MisalignmentCache ()
 Singleton class, hidden constructor.
 
 MisalignmentCache (const MisalignmentCache &)=delete
 Singleton class, no copying.
 
MisalignmentCacheoperator= (const MisalignmentCache &)=delete
 Singleton class, no assignment.
 

Private Attributes

bool m_isAlive {false}
 Is the cache alive?
 
MisalignmentMap m_misalignments
 Map to hold solid body misalignments for sensors.
 

Detailed Description

Class to hold misalignment information.

Definition at line 39 of file MisalignmentCache.h.

Member Function Documentation

◆ addMisalignment()

void addMisalignment ( Belle2::VxdID  sensorID,
const TGeoHMatrix &  misalignment 
)
inline

Add a new entry to the list of sensor misalignments.

This method will manually add a new (VxdID, Transform3D) pair to the list.

Parameters
misalignment3D transform to add to the list of sensor misalignments.

Definition at line 62 of file MisalignmentCache.h.

◆ getMisalignment()

static MisalignmentShiftType getMisalignment ( const VXDTrueHit hit)
inlinestatic

Return misalignment shift for a VXDTrueHit.

This is a shorthand for MisalignmentCache::getInstance().getMisalignmentShift.

Definition at line 87 of file MisalignmentCache.h.

◆ getMisalignmentShift()

MisalignmentCache::MisalignmentShiftType getMisalignmentShift ( const VXDTrueHit hit)

Return misalignment shift for a VXDTrueHit.

This is the principal misalignment method, used to misalign TrueHits or Clusters (via relation to their TrueHits.

Parameters
truehitpointer to the TrueHit to misalign
Returns
std::pair<double, double> of misalignment shifts

Definition at line 102 of file MisalignmentCache.cc.

103  {
104  if (!m_isAlive || !hit) return make_tuple(false, 0.0, 0.0);
105  VxdID sensorID = hit->getSensorID();
106  const TGeoHMatrix& transform = getMisalignmentTransform(sensorID);
107  // We need entry point as a reference - the point on the original track unaffected by passage through the sensor. We also don't care for w and set it to zero.
108  const double xea[3] = {hit->getEntryU(), hit->getEntryV(), 0.0};
109  TVector3 tev(hit->getEntryMomentum().Unit());
110  const double tea[3] = {tev.X(), tev.Y(), tev.Z()};
111  double xca[3], tca[3];
112  transform.MasterToLocal(xea, xca);
113  transform.MasterToLocalVect(tea, tca);
114  if (abs(tca[2]) > 0.0) {
115  double factor = - xca[2] / tca[2];
116  double dx = xca[0] + factor * tca[0] - xea[0];
117  double dy = xca[1] + factor * tca[1] - xea[1];
118  return make_tuple(true, dx, dy);
119  } else {
120  return make_tuple(false, 0.0, 0.0);
121  }
122  }

◆ getMisalignmentTransform()

const TGeoHMatrix & getMisalignmentTransform ( Belle2::VxdID  id) const

Return the misalignment transform for a given sensor.

Parameters
idVxdID of the desired sensor
Returns
identity transform if no data found.

Definition at line 31 of file MisalignmentCache.cc.

◆ readMisalignmentsFromXml()

void readMisalignmentsFromXml ( const std::string &  filename)

Read misalignment data from an xml file and store sensor misalignments.

Parameters
filenamename of the xml file

Definition at line 42 of file MisalignmentCache.cc.


The documentation for this class was generated from the following files:
Belle2::VXD::MisalignmentCache::getMisalignmentTransform
const TGeoHMatrix & getMisalignmentTransform(Belle2::VxdID id) const
Return the misalignment transform for a given sensor.
Definition: MisalignmentCache.cc:31
Belle2::VXD::MisalignmentCache::m_isAlive
bool m_isAlive
Is the cache alive?
Definition: MisalignmentCache.h:107