Cluster.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // $Id$
  2. // Author: artur 2016/04/07
  3. #ifndef __CLUSTER_H__
  4. #define __CLUSTER_H__
  5. #include <TNamed.h>
  6. #include <map>
  7. #include <set>
  8. #include "ClusterElement.h"
  9. ////////////////////////////////////////////////////////////////////////////////
  10. // //
  11. // Cluster //
  12. // //
  13. // simplest data memebers interpretation: //
  14. // //
  15. // id[0]: unique id //
  16. // id[1], id[2]: mother particle & track number //
  17. // //
  18. // value[0]: deposit //
  19. // value[1], value[2]: exact position it 2D-map //
  20. // //
  21. // CollectionsID: collections to which the cluster belongs //
  22. // //
  23. ////////////////////////////////////////////////////////////////////////////////
  24. typedef std::map<Int_t,ClusterElement*> CL_ESET;
  25. class Cluster: public TNamed {
  26. public:
  27. Cluster();
  28. Cluster(Int_t uid);
  29. virtual ~Cluster() {}
  30. virtual void clear(); // clear own data only
  31. virtual void print(Int_t opt = 0) const;
  32. //------------------------------------------------------------
  33. virtual void SetId(Int_t i, Int_t id); // !!! i > 0 !!!
  34. virtual void SetValue(Double_t v) { Value_[0] = v; }
  35. virtual void AddValue(Double_t v) { Value_[0] += v; }
  36. virtual void SetValue(Int_t i, Double_t v);
  37. virtual void AddValue(Int_t i, Double_t v);
  38. //------------------------------------------------------------
  39. Int_t GetId() const { return Id_[0]; }
  40. Double_t GetValue() const { return Value_[0]; }
  41. Int_t GetId(Int_t i) const { return Id_[i]; }
  42. Double_t GetValue(Int_t i) const { return Value_[i]; }
  43. const CL_ESET& GetElements() const { return Elements_; }
  44. const CL_IDS& GetCollsID() const { return CollectionsID_; }
  45. Int_t GetNElements() const { return Elements_.size(); }
  46. Int_t GetNCollections() const { return CollectionsID_.size(); }
  47. Int_t* GetElementsID() const;
  48. Int_t* GetCollectionsID() const;
  49. const ClusterElement* GetElement(Int_t id) const;
  50. //------------------------------------------------------------
  51. virtual Bool_t FindElement(const ClusterElement* elem) const;
  52. virtual Bool_t FindElement(Int_t id) const;
  53. virtual Bool_t FindCollection(Int_t id) const;
  54. virtual Bool_t AddElement(ClusterElement* elem);
  55. virtual Bool_t RemoveElement(ClusterElement* elem);
  56. virtual Bool_t RemoveElement(Int_t id);
  57. virtual void RemoveElements();
  58. protected:
  59. TArrayI Id_; // id
  60. TArrayD Value_; // own data
  61. CL_ESET Elements_; // <element ID, element>
  62. CL_IDS CollectionsID_; // <collection ID>
  63. /***** used in ClusterCollection *****/
  64. virtual Bool_t AddCollection(Int_t id);
  65. virtual Bool_t RemoveCollection(Int_t id);
  66. friend class ClusterCollection;
  67. ClassDef(Cluster,1)
  68. };
  69. #endif /* __CLUSTER_H__ */