Belle II Software  release-05-02-19
MisalignmentCache.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Peter Kvasnicka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef VXD_MISALIGNMENT_CACHE_H
12 #define VXD_MISALIGNMENT_CACHE_H
13 
14 #include <vxd/dataobjects/VxdID.h>
15 #include <vxd/dataobjects/VXDTrueHit.h>
16 #include <unordered_map>
17 #include <tuple>
18 
19 #include <TGeoMatrix.h>
20 
21 namespace Belle2 {
27  namespace VXD {
31  class MisalignmentCache {
32  public:
33 
35  typedef std::unordered_map<Belle2::VxdID::baseType, TGeoHMatrix> MisalignmentMap;
37  typedef std::tuple<bool, double, double> MisalignmentShiftType;
38 
40  ~MisalignmentCache() { clear(); };
41 
43  void clear() { m_misalignments.clear(); m_isAlive = false; }
44 
47  void readMisalignmentsFromXml(const std::string& filename);
48 
54  void addMisalignment(Belle2::VxdID sensorID, const TGeoHMatrix& misalignment)
55  {
56  m_misalignments[sensorID] = misalignment;
57  m_isAlive = true;
58  }
59 
61  const MisalignmentMap& getMisalignments() const { return m_misalignments; }
62 
67  const TGeoHMatrix& getMisalignmentTransform(Belle2::VxdID id) const;
68 
75 
80  { return getInstance().getMisalignmentShift(hit); }
81 
84 
86  static bool isAlive()
87  { return getInstance().m_isAlive; }
88 
89  private:
90 
92  MisalignmentCache() {};
97 
99  bool m_isAlive{false};
102  };
103  }
105 } //Belle2 namespace
106 #endif
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::VXD::MisalignmentCache::operator=
MisalignmentCache & operator=(const MisalignmentCache &)=delete
Singleton class, no assignment.
Belle2::VXD::MisalignmentCache::getMisalignment
static MisalignmentShiftType getMisalignment(const VXDTrueHit *hit)
Return misalignment shift for a VXDTrueHit.
Definition: MisalignmentCache.h:87
Belle2::VXD::MisalignmentCache
Class to hold misalignment information.
Definition: MisalignmentCache.h:39
Belle2::VXDTrueHit
Class VXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: VXDTrueHit.h:38
Belle2::VXD::MisalignmentCache::readMisalignmentsFromXml
void readMisalignmentsFromXml(const std::string &filename)
Read misalignment data from an xml file and store sensor misalignments.
Definition: MisalignmentCache.cc:42
Belle2::VXD::MisalignmentCache::getInstance
static MisalignmentCache & getInstance()
Return a reference to the singleton instance.
Definition: MisalignmentCache.cc:124
Belle2::VXD::MisalignmentCache::isAlive
static bool isAlive()
Return alive status of the cache (are there misalignment data?
Definition: MisalignmentCache.h:94
Belle2::VXD::MisalignmentCache::getMisalignmentShift
MisalignmentShiftType getMisalignmentShift(const VXDTrueHit *hit)
Return misalignment shift for a VXDTrueHit.
Definition: MisalignmentCache.cc:102
Belle2::VXD::MisalignmentCache::getMisalignments
const MisalignmentMap & getMisalignments() const
Return the list of sensor misalignments.
Definition: MisalignmentCache.h:69
Belle2::VXD::MisalignmentCache::MisalignmentCache
MisalignmentCache()
Singleton class, hidden constructor.
Definition: MisalignmentCache.h:100
Belle2::VXD::MisalignmentCache::addMisalignment
void addMisalignment(Belle2::VxdID sensorID, const TGeoHMatrix &misalignment)
Add a new entry to the list of sensor misalignments.
Definition: MisalignmentCache.h:62
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VXD::MisalignmentCache::~MisalignmentCache
~MisalignmentCache()
destructor to clean up misalignment
Definition: MisalignmentCache.h:48
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_misalignments
MisalignmentMap m_misalignments
Map to hold solid body misalignments for sensors.
Definition: MisalignmentCache.h:109
Belle2::VXD::MisalignmentCache::m_isAlive
bool m_isAlive
Is the cache alive?
Definition: MisalignmentCache.h:107
Belle2::VXD::MisalignmentCache::clear
void clear()
clear cache data
Definition: MisalignmentCache.h:51
Belle2::VXD::MisalignmentCache::MisalignmentMap
std::unordered_map< Belle2::VxdID::baseType, TGeoHMatrix > MisalignmentMap
Hash map type to store existing misalignment transforms.
Definition: MisalignmentCache.h:43
Belle2::VXD::MisalignmentCache::MisalignmentShiftType
std::tuple< bool, double, double > MisalignmentShiftType
Misalignment shift information contains a validity flag (if false, the misaligned object falls outsid...
Definition: MisalignmentCache.h:45