Newer
Older
TB_Chris / TbAlignment / src / .svn / text-base / TbAlignmentBase.h.svn-base
  1. #pragma once
  2.  
  3.  
  4. // Gaudi
  5. #include "GaudiAlg/GaudiHistoTool.h"
  6.  
  7. // Tb/TbKernel
  8. #include "TbKernel/ITbGeometrySvc.h"
  9. #include "TbKernel/TbAlignmentTrack.h"
  10. #include "TbKernel/TbModule.h"
  11. #include "TbKernel/ITbTrackFit.h"
  12.  
  13. static const InterfaceID IID_TbAlignmentBase("TbAlignmentBase", 1, 0);
  14.  
  15. class TbAlignmentBase : public GaudiHistoTool {
  16.  
  17. public:
  18. /// Return the interface ID
  19. static const InterfaceID& interfaceID() { return IID_TbAlignmentBase; }
  20. /// Constructor
  21. TbAlignmentBase(const std::string& type, const std::string& name,
  22. const IInterface* parent);
  23. /// Destructor
  24. ~TbAlignmentBase() {}
  25.  
  26. virtual StatusCode initialize();
  27.  
  28. /// Store tracks/clusters to be used for the alignment (called each event).
  29. virtual StatusCode execute(std::vector<TbAlignmentTrack*>& alignmentTracks);
  30. /// Alignment function (called after enough tracks have been collected).
  31. virtual void align(std::vector<TbAlignmentTrack*>& alignmentTracks) = 0;
  32.  
  33. bool clearTracks() const { return m_clearTracks; }
  34. /// Fill monitoring histograms.
  35. void plotResiduals(std::vector<TbAlignmentTrack*>& tracks,
  36. const std::string& tag);
  37.  
  38. protected:
  39. /// TES location of tracks.
  40. std::string m_trackLocation;
  41. /// Chi2 cut on tracks to be used for alignment
  42. double m_maxChi2;
  43. /// Degrees of freedom
  44. std::vector<bool> m_dofs;
  45. /// Default degrees of freedom
  46. std::vector<bool> m_dofsDefault;
  47. /// List of masked planes
  48. std::vector<unsigned int> m_maskedPlanes;
  49. /// Flags whether a plane is masked or not.
  50. std::vector<bool> m_masked;
  51. /// Flag to produce monitoring histograms.
  52. bool m_monitoring;
  53. /// Flag to reset the track store before collecting alignment tracks.
  54. bool m_clearTracks;
  55.  
  56. std::vector<TbModule*> m_modules;
  57. unsigned int m_nPlanes;
  58. /// Track fit tool
  59. ITbTrackFit* m_trackFit;
  60.  
  61. bool masked(const unsigned int plane) const {
  62. return plane < m_masked.size() ? m_masked[plane] : false;
  63. }
  64.  
  65. /// Pointer to the geometry service.
  66. mutable ITbGeometrySvc* m_geomSvc;
  67. /// On-demand access to the geometry service.
  68. ITbGeometrySvc* geomSvc() const {
  69. if (!m_geomSvc) m_geomSvc = svc<ITbGeometrySvc>("TbGeometrySvc", true);
  70. return m_geomSvc;
  71. }
  72. /// Determine whether a track passes the edge region of a plane.
  73. bool isEdge(const LHCb::TbTrack* track) {
  74. for (auto cluster : track->clusters()) {
  75. if (isEdge(cluster)) return true;
  76. }
  77. return false;
  78. }
  79. /// Determine whether a cluster is close to the edge region of a plane.
  80. bool isEdge(const LHCb::TbCluster* cluster) {
  81. return cluster->xloc() < 0.5 ||
  82. cluster->xloc() > 13.5 ||
  83. cluster->yloc() < 0.5 ||
  84. cluster->yloc() > 13.5 ;
  85. }
  86.  
  87.  
  88. };