CbmRoot
CbmLink.h
Go to the documentation of this file.
1 
9 #ifndef CBMLINK_H_
10 #define CBMLINK_H_
11 
12 #include <Rtypes.h> // for THashConsistencyHolder, ClassDef
13 #include <RtypesCore.h> // for Int_t, Float_t, Bool_t
14 #include <TObject.h> // for TObject
15 
16 #include <string> // for string
17 
18 class CbmLink : public TObject {
19 public:
23  CbmLink();
24 
28  CbmLink(Float_t weight, Int_t index, Int_t entry = -1, Int_t file = -1);
29 
33  virtual ~CbmLink();
34 
35  /* Modifiers */
36  Int_t GetFile() const { return fFile; }
37  Int_t GetEntry() const { return fEntry; }
38  Int_t GetIndex() const { return fIndex; }
39  Float_t GetWeight() const { return fWeight; }
40 
41  /* Accessors */
42  void SetFile(Int_t file) { fFile = file; }
43  void SetEntry(Int_t entry) { fEntry = entry; }
44  void SetIndex(Int_t index) { fIndex = index; }
45  void SetWeight(Float_t weight) { fWeight = weight; }
46 
47  void AddWeight(Float_t weight) { fWeight += weight; }
48 
53  virtual std::string ToString() const;
54 
55  friend Bool_t operator==(const CbmLink& lhs, const CbmLink& rhs) {
56  return (lhs.GetFile() == rhs.GetFile() && lhs.GetEntry() == rhs.GetEntry()
57  && lhs.GetIndex() == rhs.GetIndex());
58  }
59 
61  friend Bool_t operator<(const CbmLink& l, const CbmLink& r) {
62  if (l.GetFile() == r.GetFile()) {
63  if (l.GetEntry() == r.GetEntry()) return l.GetIndex() < r.GetIndex();
64  return l.GetEntry() < r.GetEntry();
65  }
66  return l.GetFile() < r.GetFile();
67  }
68 
69  friend Bool_t operator>(const CbmLink& l, const CbmLink& r) {
70  if (l.GetFile() == r.GetFile()) {
71  if (l.GetEntry() == r.GetEntry()) return l.GetIndex() > r.GetIndex();
72  return l.GetEntry() > r.GetEntry();
73  }
74  return l.GetFile() > r.GetFile();
75  }
76 
77 
78 private:
79  Int_t fFile; // File ID
80  Int_t fEntry; // Entry number
81  Int_t fIndex; // Index in array
82  Float_t fWeight; // Weight
83 
84  ClassDef(CbmLink, 1)
85 };
86 
87 #endif /* CBMLINK_H_ */