Newer
Older
TB_Chris / TbKernel / src / .svn / text-base / TbClusterFinder.h.svn-base
  1. #pragma once
  2.  
  3. // Gaudi
  4. #include "GaudiAlg/GaudiTool.h"
  5.  
  6. // Local
  7. #include "TbKernel/ITbClusterFinder.h"
  8.  
  9. /** @class TbClusterFinder TbClusterFinder.h
  10. *
  11. * This small class is used to find a particular cluster (on a particular
  12. * chip) nearest a particular time. This is done using a variety of funky
  13. * algorithms and conditions - specifically, using the condition that during
  14. * this object's lifetime, whenever asked to retrieve clusters for particular
  15. * time, these times are always increasing. (ALWAYS). Otherwise, expect O(N)
  16. * performance.
  17. *
  18. * @author Dan Saunders
  19. */
  20.  
  21. class TbClusterFinder : public GaudiTool, virtual public ITbClusterFinder {
  22. public:
  23. typedef LHCb::TbClusters::const_iterator Iterator;
  24. enum SearchMethod {
  25. Seq = 1,
  26. AdapSeq = 2
  27. };
  28.  
  29. /// Standard constructor
  30. TbClusterFinder(const std::string& type, const std::string& name,
  31. const IInterface* parent);
  32. /// Destructor
  33. virtual ~TbClusterFinder() {}
  34.  
  35. virtual StatusCode initialize();
  36.  
  37. /// Find iterator to first cluster on a given plane above a given time.
  38. virtual Iterator getIterator(const double& t, const unsigned int& plane);
  39. /// (Re)set the stored iterators for a given plane.
  40. virtual void setClusters(LHCb::TbClusters* clusters,
  41. const unsigned int& plane);
  42. /// Set the search algorithm to be used.
  43. virtual void setSearchAlgorithm(const std::string& alg);
  44.  
  45. virtual Iterator first(const unsigned int& plane) const {
  46. return m_first[plane];
  47. }
  48. virtual Iterator end(const unsigned int& plane) const { return m_end[plane]; }
  49. virtual bool empty(const unsigned int& plane) const { return m_empty[plane]; }
  50.  
  51. private:
  52. unsigned int m_searchAlgo;
  53.  
  54. std::vector<Iterator> m_first;
  55. std::vector<Iterator> m_last;
  56. std::vector<Iterator> m_end;
  57. std::vector<unsigned int> m_nClusters;
  58. std::vector<bool> m_empty;
  59. std::vector<double> m_prev_ts;
  60. std::vector<Iterator> m_prev;
  61.  
  62. /// Sequential search method
  63. Iterator seq_search(const double& t, const unsigned int& plane);
  64. /// Adaptive sequential search method
  65. Iterator adap_seq_search(const double& t, const unsigned int& plane);
  66. };