ClusterElement.cxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // $Id$
  2. // Author: artur 2016/04/07
  3. //_____________________________________________________________________________
  4. //
  5. // ClusterElement
  6. //_____________________________________________________________________________
  7. #include "ClusterElement.h"
  8. #include <iostream>
  9. using std::cout;
  10. using std::endl;
  11. ClassImp(ClusterElement)
  12. //_____________________________________________________________________________
  13. ClusterElement::ClusterElement():TNamed("element","")
  14. {
  15. Id_.Set(3);
  16. Value_.Set(3);
  17. }
  18. //_____________________________________________________________________________
  19. ClusterElement::ClusterElement(Int_t uid):TNamed("element","")
  20. {
  21. Id_.Set(3);
  22. Value_.Set(3);
  23. Id_[0]= uid;
  24. }
  25. //_____________________________________________________________________________
  26. ClusterElement::ClusterElement(Int_t uid, Int_t id1, Int_t id2):TNamed("element","")
  27. {
  28. Id_.Set(3);
  29. Value_.Set(3);
  30. Id_[0]= uid;
  31. Id_[1]= id1;
  32. Id_[2]= id2;
  33. }
  34. //_____________________________________________________________________________
  35. void ClusterElement::clear()
  36. {
  37. Value_.Set(3);
  38. Value_.Reset(0);
  39. }
  40. //_____________________________________________________________________________
  41. void ClusterElement::SetId(Int_t i, Int_t id)
  42. {
  43. if (i < 1) return;
  44. if (i < Id_.fN) { Id_[i] = id; return; }
  45. Id_.Set(i+1);
  46. Id_[i] = id;
  47. }
  48. //_____________________________________________________________________________
  49. void ClusterElement::SetValue(Int_t i, Double_t v)
  50. {
  51. if (i < 0) return;
  52. if (i < Value_.fN) { Value_[i] = v; return; }
  53. Value_.Set(i+1);
  54. Value_[i] = v;
  55. }
  56. //_____________________________________________________________________________
  57. void ClusterElement::AddValue(Int_t i, Double_t v)
  58. {
  59. if (i < 0) return;
  60. if (i < Value_.fN) { Value_[i] += v; return; }
  61. Value_.Set(i+1);
  62. Value_[i] = v;
  63. }
  64. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  65. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  66. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  67. //_____________________________________________________________________________
  68. Int_t ClusterElement::GetNClusters() const
  69. {
  70. return ClustersID_.size();
  71. }
  72. //_____________________________________________________________________________
  73. Int_t* ClusterElement::GetClustersID() const
  74. {
  75. Int_t n = ClustersID_.size();
  76. if (n < 1) return 0;
  77. Int_t* ids = new Int_t[n];
  78. CL_IDS::const_iterator it = ClustersID_.begin();
  79. for ( n = 0; it != ClustersID_.end(); it++) ids[n++] = *it;
  80. return ids;
  81. }
  82. //_____________________________________________________________________________
  83. Bool_t ClusterElement::FindCluster(Int_t id) const
  84. {
  85. CL_IDS::const_iterator it = ClustersID_.find(id);
  86. return (it != ClustersID_.end());
  87. }
  88. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  89. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  90. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  91. //_____________________________________________________________________________
  92. Bool_t ClusterElement::AddCluster(Int_t id)
  93. {
  94. if (GetId() < 1) return kFALSE;
  95. if (id < 1) return kFALSE;
  96. std::pair<CL_IDS::iterator,Bool_t> it = ClustersID_.insert(id);
  97. return it.second;
  98. }
  99. //_____________________________________________________________________________
  100. Bool_t ClusterElement::RemoveCluster(Int_t id)
  101. {
  102. Int_t n = ClustersID_.erase(id);
  103. return (n > 0);
  104. }
  105. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  106. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  107. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  108. //_____________________________________________________________________________
  109. void ClusterElement::print(Int_t opt) const
  110. {
  111. }