-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
BTLDetId.h
118 lines (91 loc) · 5.16 KB
/
BTLDetId.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef DataFormats_BTLDetId_BTLDetId_h
#define DataFormats_BTLDetId_BTLDetId_h
#include "DataFormats/ForwardDetId/interface/MTDDetId.h"
#include <ostream>
#include <array>
/**
@class BTLDetId
@brief Detector identifier class for the Barrel Timing Layer.
The crystal count must start from 0, copy number must be scaled by 1 unit.
bit 15-10: module sequential number
bit 9-8 : crystal type (1 - 3)
bit 7-0 : crystal sequential number within a module ( 0 - 63 )
*/
class BTLDetId : public MTDDetId {
public:
static constexpr uint32_t kBTLmoduleOffset = 10;
static constexpr uint32_t kBTLmoduleMask = 0x3F;
static constexpr uint32_t kBTLmodTypeOffset = 8;
static constexpr uint32_t kBTLmodTypeMask = 0x3;
static constexpr uint32_t kBTLCrystalOffset = 0;
static constexpr uint32_t kBTLCrystalMask = 0x3F;
/// range constants, need two sets for the time being (one for tiles and one for bars)
static constexpr int kModulesPerROD = 54;
static constexpr int kModulesPerRODBarZflat = 42;
static constexpr std::array<int,4> kTypeBoundariesReference{ { 0, 18, 36, 54 } };
static constexpr std::array<int,4> kTypeBoundariesBarZflat{ { 0, 14, 28, 42 } };
static constexpr int kCrystalsInPhiTile = 16; // per module and ROD
static constexpr int kCrystalsInEtaTile = 4; // per module
static constexpr int kCrystalsInPhiBar = 4; // per module and ROD
static constexpr int kCrystalsInEtaBar = 16; // per module
static constexpr int kCrystalsInPhiBarZ = 64; // per module and ROD
static constexpr int kCrystalsInEtaBarZ = 1; // per module
static constexpr int kCrystalsPerROD = kModulesPerROD*kCrystalsInPhiTile*kCrystalsInEtaTile; // 64 crystals per module x 54 modules per rod, independent on geometry scenario Tile or Bar
static constexpr int kCrystalsPerRODBarZflat = kModulesPerRODBarZflat*kCrystalsInPhiBarZ*kCrystalsInEtaBarZ; // 64 crystals per module x 42 modules per rod, independent on geometry scenario Tile or Bar
static constexpr int MIN_ROD = 1;
static constexpr int MAX_ROD = 72;
static constexpr int HALF_ROD = 36;
static constexpr int MIN_IETA = 1;
static constexpr int MIN_IPHI = 1;
static constexpr int MAX_IETA_TILE = kCrystalsInEtaTile*kModulesPerROD;
static constexpr int MAX_IPHI_TILE = kCrystalsInPhiTile*HALF_ROD;
static constexpr int MAX_IETA_BAR = kCrystalsInEtaBar*kModulesPerROD;
static constexpr int MAX_IPHI_BAR = kCrystalsInPhiBar*HALF_ROD;
static constexpr int MAX_IETA_BARZ = kCrystalsInEtaBarZ*kModulesPerROD;
static constexpr int MAX_IPHI_BARZ = kCrystalsInPhiBarZ*HALF_ROD;
static constexpr int MAX_IETA_BARZFLAT = kCrystalsInEtaBarZ*kModulesPerRODBarZflat;
static constexpr int MAX_IPHI_BARZFLAT = kCrystalsInPhiBarZ*HALF_ROD;
static constexpr int MIN_HASH = 0; // always 0 ...
static constexpr int MAX_HASH = 2*MAX_IPHI_TILE*MAX_IETA_TILE-1; // the total amount is invariant per tile or bar)
static constexpr int kSizeForDenseIndexing = MAX_HASH + 1 ;
enum class CrysLayout { tile = 1 , bar = 2 , barzflat = 3} ;
// ---------- Constructors, enumerated types ----------
/** Construct a null id */
BTLDetId() : MTDDetId( DetId::Forward, ForwardSubdetector::FastTime ) { id_ |= ( MTDType::BTL& kMTDsubdMask ) << kMTDsubdOffset ;}
/** Construct from a raw value */
BTLDetId( const uint32_t& raw_id ) : MTDDetId( raw_id ) {;}
/** Construct from generic DetId */
BTLDetId( const DetId& det_id ) : MTDDetId( det_id.rawId() ) {;}
/** Construct and fill only the det and sub-det fields. */
BTLDetId( uint32_t zside,
uint32_t rod,
uint32_t module,
uint32_t modtyp,
uint32_t crystal ) : MTDDetId( DetId::Forward, ForwardSubdetector::FastTime ) {
id_ |= ( MTDType::BTL& kMTDsubdMask ) << kMTDsubdOffset |
( zside& kZsideMask ) << kZsideOffset |
( rod& kRodRingMask ) << kRodRingOffset |
( module& kBTLmoduleMask ) << kBTLmoduleOffset |
( modtyp& kBTLmodTypeMask ) << kBTLmodTypeOffset |
( (crystal-1)& kBTLCrystalMask ) << kBTLCrystalOffset ;
}
// ---------- Common methods ----------
/** Returns BTL module number. */
inline int module() const { return (id_>>kBTLmoduleOffset)&kBTLmoduleMask; }
/** Returns BTL crystal type number. */
inline int modType() const { return (id_>>kBTLmodTypeOffset)&kBTLmodTypeMask; }
/** Returns BTL crystal number. */
inline int crystal() const { return ((id_>>kBTLCrystalOffset)&kBTLCrystalMask) + 1; }
/** Returns BTL iphi index for crystal according to type tile or bar */
int iphi( CrysLayout lay ) const ;
/** Returns BTL ieta index for crystal according to type tile or bar */
int ietaAbs( CrysLayout lay ) const ;
int ieta( CrysLayout lay ) const { return zside()*ietaAbs( lay ); }
/** define a dense index of arrays from a DetId */
int hashedIndex( CrysLayout lay ) const ;
static bool validHashedIndex( uint32_t din ) { return ( din < kSizeForDenseIndexing ) ; }
/** get a DetId from a compact index for arrays */
BTLDetId getUnhashedIndex( int hi, CrysLayout lay ) const ;
};
std::ostream& operator<< ( std::ostream&, const BTLDetId& );
#endif // DataFormats_BTLDetId_BTLDetId_h