Skip to content

Commit 9497df2

Browse files
committed
Revert "Implementing std::hash specialization for MCCompLabel"
This reverts commit b8470f8. It breaks compilation on MacOS which needs to fixed first.
1 parent 3cd6298 commit 9497df2

3 files changed

Lines changed: 11 additions & 24 deletions

File tree

DataFormats/simulation/include/SimulationDataFormat/MCCompLabel.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class MCCompLabel
2525

2626
ULong64_t mLabel = NotSet; ///< MC label encoding MCtrack ID and MCevent origin
2727

28+
void checkFieldConsistensy();
29+
2830
public:
2931
// number of bits reserved for MC track ID, DON'T modify this, since the
3032
// track ID might be negative
@@ -33,11 +35,6 @@ class MCCompLabel
3335
static constexpr int nbitsSrcID = 8; // number of bits reserved for MC source ID
3436
// the rest of the bits is reserved at the moment
3537

36-
// check if the fields are defined consistently
37-
static_assert(nbitsTrackID == sizeof(int) * 8, "TrackID must have int size");
38-
static_assert(nbitsTrackID + nbitsEvID + nbitsSrcID <= sizeof(ULong64_t) * 8,
39-
"Fields cannot be stored in 64 bits");
40-
4138
// mask to extract MC track ID
4239
static constexpr ULong64_t maskTrackID = (ul0x1 << nbitsTrackID) - 1;
4340
// mask to extract MC track ID
@@ -105,17 +102,4 @@ class MCCompLabel
105102

106103
std::ostream& operator<<(std::ostream& os, const o2::MCCompLabel& c);
107104

108-
namespace std
109-
{
110-
// defining std::hash for MCCompLabel in order to be used with unordered_maps
111-
template <>
112-
struct hash<o2::MCCompLabel> {
113-
public:
114-
size_t operator()(o2::MCCompLabel const& label) const
115-
{
116-
return static_cast<uint64_t>(label);
117-
}
118-
};
119-
} // namespace std
120-
121105
#endif

DataFormats/simulation/src/MCCompLabel.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ std::ostream& operator<<(std::ostream& os, const o2::MCCompLabel& c)
3737
}
3838
return os;
3939
}
40+
41+
//_____________________________________________
42+
void MCCompLabel::checkFieldConsistensy()
43+
{
44+
// check if the fields are defined consistently
45+
static_assert(nbitsTrackID==sizeof(int)*8, "TrackID must have int size");
46+
static_assert(nbitsTrackID+nbitsEvID+nbitsSrcID<=sizeof(ULong64_t)*8,
47+
"Fields cannot be stored in 64 bits");
48+
}

DataFormats/simulation/test/testMCCompLabel.cxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,16 @@ BOOST_AUTO_TEST_CASE(MCCompLabel_test)
2525
BOOST_CHECK(!lbUndef.isSet()); // test invalid label status
2626

2727
int ev = 200, src = 10;
28-
std::unordered_map<MCCompLabel, int> labelMap;
2928
for (int tr=-100;tr<200;tr+=150) {
3029
MCCompLabel lb(tr, ev, src);
3130
std::cout << "Input: [" << src << '/' << ev << '/'
3231
<< std::setw(6) << tr << ']' << std::endl;
3332
std::cout << "Encoded: " << lb << " (packed: " << ULong_t(lb) << ")" << std::endl;
34-
labelMap[lb] = tr;
3533
int trE, evE, srcE;
3634
lb.get(trE, evE, srcE);
3735
std::cout << "Decoded: [" << srcE << '/' << evE << '/'
3836
<< std::setw(6) << trE << ']' << std::endl;
3937

4038
BOOST_CHECK(tr == trE && ev == evE && src == srcE);
4139
}
42-
43-
for (auto& [key, value] : labelMap) {
44-
BOOST_CHECK(key.getTrackID() == value);
45-
}
4640
}

0 commit comments

Comments
 (0)