CMS 3D CMS Logo

TotemTimingDetId.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Author: Nicola Minafra
3  * March 2018
4  ****************************************************************************/
5 
6 #ifndef DataFormats_CTPPSDetId_TotemTimingDetId
7 #define DataFormats_CTPPSDetId_TotemTimingDetId
8 
10 
12 
13 #include <iosfwd>
14 #include <iostream>
15 #include <string>
16 
28 {
29  public:
30  enum { ID_NOT_SET = 28 };
31 
33  explicit TotemTimingDetId( uint32_t id );
34  TotemTimingDetId( const CTPPSDetId&id ) : CTPPSDetId( id ) {}
35 
37  TotemTimingDetId( uint32_t arm, uint32_t station, uint32_t romanPot = 0, uint32_t plane = 0, uint32_t channel = 0 );
38 
39  static constexpr uint32_t startPlaneBit = 17, maskPlane = 0x3, maxPlane = 3, lowMaskPlane = 0x1FFFF;
40  static constexpr uint32_t startDetBit = 12, maskChannel = 0x1F, maxChannel = 31, lowMaskChannel = 0xFFF;
41 
43  static bool check( unsigned int raw )
44  {
45  return ( ( ( raw >> DetId::kDetOffset ) & 0xF ) == DetId::VeryForward
46  && ( ( raw >> DetId::kSubdetOffset ) & 0x7 ) == sdTimingFastSilicon );
47  }
48  //-------------------- getting and setting methods --------------------
49 
50  uint32_t plane() const
51  {
52  return ( ( id_ >> startPlaneBit ) & maskPlane );
53  }
54 
55  void setPlane( uint32_t channel )
56  {
57  id_ &= ~( maskPlane << startPlaneBit );
58  id_ |= ( ( channel & maskPlane ) << startPlaneBit );
59  }
60 
61  uint32_t channel() const
62  {
63  return ( ( id_ >> startDetBit ) & maskChannel );
64  }
65 
66  void setChannel( uint32_t channel )
67  {
68  id_ &= ~( maskChannel << startDetBit );
69  id_ |= ( ( channel & maskChannel ) << startDetBit );
70  }
71 
72  //-------------------- id getters for higher-level objects --------------------
73 
75  {
76  return TotemTimingDetId( rawId() & ( ~lowMaskPlane ) );
77  }
78 
79  //-------------------- name methods --------------------
80 
81  inline void planeName( std::string& name, NameFlag flag = nFull ) const
82  {
83  switch ( flag ) {
84  case nShort: name = ""; break;
85  case nFull: rpName( name, flag ); name += "_"; break;
86  case nPath: rpName( name, flag ); name += "/plane "; break;
87  }
88  name += std::to_string( plane() );
89  }
90 
91  inline void channelName( std::string& name, NameFlag flag = nFull ) const
92  {
93  switch ( flag ) {
94  case nShort: name = ""; break;
95  case nFull: planeName( name, flag ); name += "_"; break;
96  case nPath: planeName( name, flag ); name += "/channel "; break;
97  }
98  name += std::to_string( channel() );
99  }
100 };
101 
102 std::ostream& operator<<( std::ostream& os, const TotemTimingDetId& id );
103 
104 #endif
105 
uint32_t station() const
Definition: CTPPSDetId.h:63
void channelName(std::string &name, NameFlag flag=nFull) const
static uint32_t lowMaskPlane
void setChannel(uint32_t channel)
static uint32_t startPlaneBit
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:105
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
uint32_t channel() const
static const int kSubdetOffset
Definition: DetId.h:23
static uint32_t maskPlane
#define constexpr
TotemTimingDetId getPlaneId() const
void setPlane(uint32_t channel)
static uint32_t lowMaskChannel
TotemTimingDetId(const CTPPSDetId &id)
TotemTimingDetId(uint32_t id)
Construct from a raw id.
static uint32_t maxChannel
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:139
uint32_t arm() const
Definition: CTPPSDetId.h:52
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
static uint32_t maxPlane
uint32_t plane() const
static uint32_t startDetBit
uint32_t id_
Definition: DetId.h:62
static uint32_t maskChannel
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::ostream & operator<<(std::ostream &os, const TotemTimingDetId &id)
static const int kDetOffset
Definition: DetId.h:22
void planeName(std::string &name, NameFlag flag=nFull) const
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...