Skip to content

Commit e966db8

Browse files
wiechuladavidrohr
authored andcommitted
TPC: add operator= for pad calibration classes
1 parent bd1744b commit e966db8

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

Detectors/TPC/base/include/TPCBase/CalArray.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifndef ALICEO2_TPC_CALARRAY_H_
1313
#define ALICEO2_TPC_CALARRAY_H_
1414

15+
#include <algorithm>
1516
#include <memory>
1617
#include <vector>
1718
#include <string>
@@ -133,6 +134,13 @@ class CalArray
133134
/// Divide value on all channels
134135
const CalArray& operator/=(const T& val);
135136

137+
/// assigment to all channls
138+
const CalArray& operator=(const T& val)
139+
{
140+
std::fill(mData.begin(), mData.end(), val);
141+
return *this;
142+
}
143+
136144
private:
137145
std::string mName;
138146
// better to use std::array?

Detectors/TPC/base/include/TPCBase/CalDet.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class CalDet
8888
const CalDet& operator*=(const T& val);
8989
const CalDet& operator/=(const T& val);
9090

91+
const CalDet& operator=(const T& val);
92+
9193
template <class U>
9294
friend CalDet<U> operator+(const CalDet<U>&, const CalDet<U>&);
9395

@@ -339,6 +341,16 @@ inline const CalDet<T>& CalDet<T>::operator/=(const T& val)
339341
return *this;
340342
}
341343

344+
//______________________________________________________________________________
345+
template <class T>
346+
inline const CalDet<T>& CalDet<T>::operator=(const T& val)
347+
{
348+
for (auto& cal : mData) {
349+
cal = val;
350+
}
351+
return *this;
352+
}
353+
342354
//______________________________________________________________________________
343355
template <class T>
344356
CalDet<T> operator+(const CalDet<T>& c1, const CalDet<T>& c2)

Detectors/TPC/base/test/testTPCCalDet.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
#include <algorithm>
1213
#define BOOST_TEST_MODULE Test TPC CalDet class
1314
#define BOOST_TEST_MAIN
1415
#define BOOST_TEST_DYN_LINK
@@ -302,6 +303,13 @@ BOOST_AUTO_TEST_CASE(CalDet_Arithmetics)
302303
}
303304
}
304305
BOOST_CHECK_EQUAL(isEqual, true);
306+
307+
// = operator
308+
isEqual = true;
309+
padCmp = 10.f;
310+
for (const auto& calArr : padCmp.getData()) {
311+
isEqual &= std::all_of(calArr.getData().begin(), calArr.getData().end(), [](const auto val) { return isEqualAbs(val, 10.f); });
312+
}
305313
}
306314

307315
} // namespace tpc

Detectors/TPC/qc/src/Clusters.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ void Clusters::denormalize()
123123
//______________________________________________________________________________
124124
void Clusters::reset()
125125
{
126-
mNClusters *= 0;
127-
mQMax *= 0;
128-
mQTot *= 0;
129-
mSigmaTime *= 0;
130-
mSigmaPad *= 0;
131-
mTimeBin *= 0;
126+
mNClusters = 0;
127+
mQMax = 0;
128+
mQTot = 0;
129+
mSigmaTime = 0;
130+
mSigmaPad = 0;
131+
mTimeBin = 0;
132132
}
133133

134134
//______________________________________________________________________________

Detectors/TPC/workflow/src/CalDetMergerPublisherSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class CalDetMergerPublisherSpec : public o2::framework::Task
9898
sendOutput(pc.outputs());
9999
// reset calibration objects
100100
for (auto& [type, object] : mMergedCalDets) {
101-
object *= 0;
101+
object = 0;
102102
}
103103
mCalibDumped = false;
104104
}

0 commit comments

Comments
 (0)