File indexing completed on 2024-04-06 12:04:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef DataFormats_CTPPSDetId_TotemRPDetId
0011 #define DataFormats_CTPPSDetId_TotemRPDetId
0012
0013 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0014
0015 #include "FWCore/Utilities/interface/Exception.h"
0016
0017 #include <iosfwd>
0018 #include <iostream>
0019 #include <string>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 class TotemRPDetId : public CTPPSDetId {
0031 public:
0032
0033
0034 explicit TotemRPDetId(uint32_t id);
0035
0036 TotemRPDetId(const CTPPSDetId& id) : CTPPSDetId(id) {}
0037
0038
0039 TotemRPDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot = 0, uint32_t Plane = 0, uint32_t Chip = 0);
0040
0041 static const uint32_t startPlaneBit, maskPlane, maxPlane, lowMaskPlane;
0042 static const uint32_t startChipBit, maskChip, maxChip, lowMaskChip;
0043
0044
0045
0046 uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
0047
0048 void setPlane(uint32_t det) {
0049 id_ &= ~(maskPlane << startPlaneBit);
0050 id_ |= ((det & maskPlane) << startPlaneBit);
0051 }
0052
0053 uint32_t chip() const { return ((id_ >> startChipBit) & maskChip); }
0054
0055 void setChip(uint32_t chip) {
0056 id_ &= ~(maskChip << startChipBit);
0057 id_ |= ((chip & maskChip) << startChipBit);
0058 }
0059
0060
0061
0062 TotemRPDetId planeId() const { return TotemRPDetId(rawId() & (~lowMaskPlane)); }
0063
0064
0065
0066 bool isStripsCoordinateUDirection() const { return plane() % 2; }
0067
0068 bool isStripsCoordinateVDirection() const { return !isStripsCoordinateUDirection(); }
0069
0070
0071
0072
0073 inline uint32_t rpDecimalId() const { return rp() + station() * 10 + arm() * 100; }
0074
0075 inline uint32_t planeDecimalId() const { return plane() + rpDecimalId() * 10; }
0076
0077
0078
0079 inline void planeName(std::string& name, NameFlag flag = nFull) const {
0080 switch (flag) {
0081 case nShort:
0082 name = "";
0083 break;
0084 case nFull:
0085 rpName(name, flag);
0086 name += "_";
0087 break;
0088 case nPath:
0089 rpName(name, flag);
0090 name += "/plane ";
0091 break;
0092 }
0093
0094 name += planeNames[plane()];
0095 }
0096
0097 inline void chipName(std::string& name, NameFlag flag = nFull) const {
0098 switch (flag) {
0099 case nShort:
0100 name = "";
0101 break;
0102 case nFull:
0103 planeName(name, flag);
0104 name += "_";
0105 break;
0106 case nPath:
0107 planeName(name, flag);
0108 name += "/chip ";
0109 break;
0110 }
0111
0112 name += chipNames[chip()];
0113 }
0114
0115 private:
0116 static const std::string planeNames[];
0117 static const std::string chipNames[];
0118 };
0119
0120 std::ostream& operator<<(std::ostream& os, const TotemRPDetId& id);
0121
0122 #endif