Belle II Software  release-08-01-10
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 29 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
sensorIDSensor identifier.
misalignment3D transform to add to the list of sensor misalignments.

Definition at line 53 of file MisalignmentCache.h.

54  {
55  m_misalignments[sensorID] = misalignment;
56  m_isAlive = true;
57  }
bool m_isAlive
Is the cache alive?
MisalignmentMap m_misalignments
Map to hold solid body misalignments for sensors.

◆ 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 78 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
hitpointer to the TrueHit to misalign
Returns
std::pair<double, double> of misalignment shifts

Definition at line 100 of file MisalignmentCache.cc.

101  {
102  if (!m_isAlive || !hit) return make_tuple(false, 0.0, 0.0);
103  VxdID sensorID = hit->getSensorID();
104  const TGeoHMatrix& transform = getMisalignmentTransform(sensorID);
105  // 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.
106  const double xea[3] = {hit->getEntryU(), hit->getEntryV(), 0.0};
107  ROOT::Math::XYZVector tev(hit->getEntryMomentum().Unit());
108  const double tea[3] = {tev.X(), tev.Y(), tev.Z()};
109  double xca[3], tca[3];
110  transform.MasterToLocal(xea, xca);
111  transform.MasterToLocalVect(tea, tca);
112  if (abs(tca[2]) > 0.0) {
113  double factor = - xca[2] / tca[2];
114  double dx = xca[0] + factor * tca[0] - xea[0];
115  double dy = xca[1] + factor * tca[1] - xea[1];
116  return make_tuple(true, dx, dy);
117  } else {
118  return make_tuple(false, 0.0, 0.0);
119  }
120  }
const TGeoHMatrix & getMisalignmentTransform(Belle2::VxdID id) const
Return the misalignment transform for a given sensor.

◆ 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 29 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 40 of file MisalignmentCache.cc.


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