forked from sPHENIX-Collaboration/coresoftware
/
MicromegasDefs.cc
90 lines (73 loc) · 2.48 KB
/
MicromegasDefs.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*!
* \file MicromegasDefs.cc
* \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
*/
#include "MicromegasDefs.h"
namespace
{
//* converninece trait for underlying type
template<class T>
using underlying_type_t = typename std::underlying_type<T>::type;
//* convert an strong type enum to integral type
template<class T>
constexpr underlying_type_t<T>
to_underlying_type(T value) noexcept
{ return static_cast<underlying_type_t<T>>(value);}
}
namespace MicromegasDefs
{
//________________________________________________________________
TrkrDefs::hitsetkey genHitSetKey(uint8_t layer, SegmentationType type, uint8_t tile )
{
TrkrDefs::hitsetkey key = TrkrDefs::genHitSetKey(TrkrDefs::TrkrId::micromegasId, layer);
TrkrDefs::hitsetkey tmp = to_underlying_type(type);
key |= (tmp << kBitShiftSegmentation);
tmp = tile;
key |= (tmp << kBitShiftTileId);
return key;
}
//________________________________________________________________
SegmentationType getSegmentationType(TrkrDefs::hitsetkey key)
{
TrkrDefs::hitsetkey tmp = (key >> kBitShiftSegmentation);
return static_cast<SegmentationType>(tmp);
}
//________________________________________________________________
uint8_t getTileId(TrkrDefs::hitsetkey key)
{
TrkrDefs::hitsetkey tmp = (key >> kBitShiftTileId);
return tmp;
}
//________________________________________________________________
TrkrDefs::hitkey genHitKey(uint16_t strip)
{
TrkrDefs::hitkey key = strip << kBitShiftStrip;
return key;
}
//________________________________________________________________
uint16_t getStrip( TrkrDefs::hitkey key )
{
TrkrDefs::hitkey tmp = (key >> kBitShiftStrip);
return tmp;
}
//________________________________________________________________
TrkrDefs::cluskey genClusterKey(TrkrDefs::hitsetkey hitsetkey, uint32_t clusid)
{
TrkrDefs::cluskey tmp = hitsetkey;
TrkrDefs::cluskey key = (tmp << TrkrDefs::kBitShiftClusId);
key |= clusid;
return key;
}
//________________________________________________________________
SegmentationType getSegmentationType(TrkrDefs::cluskey key)
{
TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
return getSegmentationType( tmp );
}
//________________________________________________________________
uint8_t getTileId(TrkrDefs::cluskey key)
{
TrkrDefs::hitsetkey tmp = (key >> TrkrDefs::kBitShiftClusId);
return getTileId( tmp );
}
}