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
|
/****************************************************************************
* Author: Seyed Mohsen Etesami
* Spetember 2016
****************************************************************************/
#include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
#include "FWCore/Utilities/interface/Exception.h"
using namespace std;
//----------------------------------------------------------------------------------------------------
const uint32_t CTPPSDiamondDetId::startPlaneBit = 17, CTPPSDiamondDetId::maskPlane = 0x3,
CTPPSDiamondDetId::maxPlane = 3, CTPPSDiamondDetId::lowMaskPlane = 0x1FFFF;
const uint32_t CTPPSDiamondDetId::startDetBit = 12, CTPPSDiamondDetId::maskChannel = 0x1F,
CTPPSDiamondDetId::maxChannel = 31, CTPPSDiamondDetId::lowMaskChannel = 0xFFF;
//----------------------------------------------------------------------------------------------------
CTPPSDiamondDetId::CTPPSDiamondDetId(uint32_t id) : CTPPSDetId(id) {
if (!check(id)) {
throw cms::Exception("InvalidDetId") << "CTPPSDiamondDetId ctor:"
<< " channel: " << channel() << " subdet: " << subdetId()
<< " is not a valid CTPPS Timing Diamond id";
}
}
//----------------------------------------------------------------------------------------------------
CTPPSDiamondDetId::CTPPSDiamondDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot, uint32_t Plane, uint32_t Channel)
: CTPPSDetId(sdTimingDiamond, Arm, Station, RomanPot) {
if (Arm > maxArm || Station > maxStation || RomanPot > maxRP || Plane > maxPlane || Channel > maxChannel) {
throw cms::Exception("InvalidDetId") << "CTPPSDiamondDetId ctor:"
<< " Invalid parameters:"
<< " arm=" << Arm << " station=" << Station << " rp=" << RomanPot
<< " plane=" << Plane << " detector=" << Channel << std::endl;
}
uint32_t ok = 0xfe000000;
id_ &= ok;
id_ |= ((Arm & maskArm) << startArmBit);
id_ |= ((Station & maskStation) << startStationBit);
id_ |= ((RomanPot & maskRP) << startRPBit);
id_ |= ((Plane & maskPlane) << startPlaneBit);
id_ |= ((Channel & maskChannel) << startDetBit);
}
//----------------------------------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, const CTPPSDiamondDetId& id) {
os << "arm=" << id.arm() << " station=" << id.station() << " rp=" << id.rp() << " plane=" << id.plane()
<< " Detector=" << id.channel();
return os;
}
|