CbmRoot
Loading...
Searching...
No Matches
CbmLink.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Volker Friese */
4
13#ifndef CBMLINK_H_
14#define CBMLINK_H_
15
16#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
17#include <TObject.h> // for TObject
18
19#include <cstdint>
20#include <string> // for string
21
22class CbmLink : public TObject {
23 public:
27 CbmLink();
28
32 CbmLink(float weight, int32_t index, int32_t entry = -1, int32_t file = -1);
33
37 virtual ~CbmLink();
38
39 /* Modifiers */
40 int32_t GetFile() const { return fFile; }
41 int32_t GetEntry() const { return fEntry; }
42 int32_t GetIndex() const { return fIndex; }
43 float GetWeight() const { return fWeight; }
44
45 /* Accessors */
46 void SetFile(int32_t file) { fFile = file; }
47 void SetEntry(int32_t entry) { fEntry = entry; }
48 void SetIndex(int32_t index) { fIndex = index; }
49 void SetWeight(float weight) { fWeight = weight; }
50
51 void AddWeight(float weight) { fWeight += weight; }
52
57 virtual std::string ToString() const;
58
59 friend bool operator==(const CbmLink& lhs, const CbmLink& rhs)
60 {
61 return (lhs.GetFile() == rhs.GetFile() && lhs.GetEntry() == rhs.GetEntry() && lhs.GetIndex() == rhs.GetIndex());
62 }
63
64 friend Bool_t operator!=(const CbmLink& lhs, const CbmLink& rhs) { return !(lhs == rhs); }
65
67 friend bool operator<(const CbmLink& l, const CbmLink& r)
68 {
69 if (l.GetFile() == r.GetFile()) {
70 if (l.GetEntry() == r.GetEntry()) return l.GetIndex() < r.GetIndex();
71 return l.GetEntry() < r.GetEntry();
72 }
73 return l.GetFile() < r.GetFile();
74 }
75
76 friend bool operator>(const CbmLink& l, const CbmLink& r)
77 {
78 if (l.GetFile() == r.GetFile()) {
79 if (l.GetEntry() == r.GetEntry()) return l.GetIndex() > r.GetIndex();
80 return l.GetEntry() > r.GetEntry();
81 }
82 return l.GetFile() > r.GetFile();
83 }
84
85 bool IsNoise() const
86 {
87 bool retval{false};
88 if (fFile < 0 || fEntry < 0 || fIndex < 0) retval = true;
89 return retval;
90 }
91
92 private:
93 int32_t fFile; // File ID
94 int32_t fEntry; // Entry number
95 int32_t fIndex; // Index in array
96 float fWeight; // Weight
97
98 ClassDef(CbmLink, 1)
99};
100
101#endif /* CBMLINK_H_ */