Skip to content

Commit a607bee

Browse files
committed
Add operators for + and +=
1 parent c73ffe5 commit a607bee

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

its/Digit.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ fLabels()
2828

2929
Digit::~Digit(){}
3030

31+
Digit &Digit::operator+=(const Digit &other){
32+
fCharge += other.fCharge;
33+
return *this;
34+
}
35+
36+
const Digit Digit::operator+(const Digit &other){
37+
Digit result(*this);
38+
result += other;
39+
return result;
40+
}
41+
42+
3143
std::ostream &Digit::Print(std::ostream &output) const{
3244
output << "ITS Digit of chip index [" << fChipIndex << "] and pixel [" << fPixelIndex << "]with charge " << fCharge << " at time stamp" << fTimeStamp;
3345
return output;

its/Digit.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
namespace AliceO2{
1717
namespace ITS{
1818

19+
/// \class Digit
20+
/// \brief Digit class for the ITS
21+
///
1922
class Digit : public FairTimeStamp {
2023
public:
2124

@@ -32,6 +35,19 @@ namespace AliceO2{
3235
/// Destructor
3336
virtual ~Digit();
3437

38+
/// Addition operator
39+
/// Adds the charge of 2 digits
40+
/// @param lhs First digit for addition (also serves as time stamp)
41+
/// @param rhs Second digit for addition
42+
/// @return Digit with the summed charge of two digits and the time stamp of the first one
43+
const Digit operator+(const Digit &other);
44+
45+
/// Operator +=
46+
/// Adds charge in other digit to this digit
47+
/// @param other Digit added to this digit
48+
/// @return Digit after addition
49+
Digit &operator+=(const Digit &other);
50+
3551
/// Get the index of the chip
3652
/// @return Index of the chip
3753
ULong_t GetChipIndex() const { return fChipIndex; }

0 commit comments

Comments
 (0)