CMS 3D CMS Logo

CTPPSDetId.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of TOTEM offline software.
4  * Authors:
5  * Hubert Niewiadomski
6  * Jan Kašpar (jan.kaspar@gmail.com)
7  *
8  ****************************************************************************/
9 
10 
12 
14 
15 using namespace std;
16 
17 //----------------------------------------------------------------------------------------------------
18 
21 const uint32_t CTPPSDetId::startRPBit = 19, CTPPSDetId::maskRP = 0x7, CTPPSDetId::maxRP = 6, CTPPSDetId::lowMaskRP = 0x7FFFF;
22 
23 const string CTPPSDetId::subDetectorNames[] = { "", "", "", "ctpps_tr_strip", "ctpps_tr_pixel", "ctpps_ti_diamond", "ctpps_ti_fastsilicon" };
24 const string CTPPSDetId::subDetectorPaths[] = { "", "", "", "CTPPS/TrackingStrip", "CTPPS/TrackingPixel", "CTPPS/TimingDiamond", "CTPPS/TimingFastSilicon" };
25 const string CTPPSDetId::armNames[] = { "45", "56" };
26 const string CTPPSDetId::stationNames[] = { "210", "220cyl", "220" };
27 const string CTPPSDetId::rpNames[] = { "nr_tp", "nr_bt", "nr_hr", "fr_hr", "fr_tp", "fr_bt", "cyl_hr" };
28 
29 //----------------------------------------------------------------------------------------------------
30 
31 CTPPSDetId::CTPPSDetId(uint32_t id) : DetId(id)
32 {
33  bool inputOK = (det() == DetId::VeryForward);
34 
35  if (!inputOK)
36  {
37  throw cms::Exception("InvalidDetId") << "CTPPSDetId ctor:"
38  << " det: " << det()
39  << " subdet: " << subdetId()
40  << " is not a valid CTPPS id.";
41  }
42 }
43 
44 //----------------------------------------------------------------------------------------------------
45 
46 CTPPSDetId::CTPPSDetId(uint32_t SubDet, uint32_t Arm, uint32_t Station, uint32_t RomanPot) :
47  DetId(DetId::VeryForward, SubDet)
48 {
49  if (SubDet != sdTrackingStrip && SubDet != sdTrackingPixel && SubDet != sdTimingDiamond && SubDet != sdTimingFastSilicon)
50  {
51  throw cms::Exception("InvalidDetId") << "CTPPSDetId ctor: invalid sub-detector " << SubDet << ".";
52  }
53 
54  if (Arm > maxArm || Station > maxStation || RomanPot > maxRP)
55  {
56  throw cms::Exception("InvalidDetId") << "CTPPSDetId ctor:"
57  << " Invalid parameters:"
58  << " arm=" << Arm
59  << " station=" << Station
60  << " rp=" << RomanPot
61  << std::endl;
62  }
63 
64  uint32_t ok=0xfe000000;
65  id_ &= ok;
66 
67  id_ |= ((Arm & maskArm) << startArmBit);
68  id_ |= ((Station & maskStation) << startStationBit);
69  id_ |= ((RomanPot & maskRP) << startRPBit);
70 }
71 
72 //----------------------------------------------------------------------------------------------------
73 
74 std::ostream& operator << (std::ostream& os, const CTPPSDetId& id)
75 {
76  os
77  << "subDet=" << id.subdetId()
78  << " arm=" << id.arm()
79  << " station=" << id.station()
80  << " rp=" << id.rp();
81 
82  return os;
83 }
std::ostream & operator<<(std::ostream &os, const CTPPSDetId &id)
Definition: CTPPSDetId.cc:74
static const uint32_t maxStation
Definition: CTPPSDetId.h:47
static const uint32_t startRPBit
Definition: CTPPSDetId.h:48
static const uint32_t maskStation
Definition: CTPPSDetId.h:47
static const uint32_t maskRP
Definition: CTPPSDetId.h:48
static const std::string armNames[]
Definition: CTPPSDetId.h:154
static const uint32_t lowMaskStation
Definition: CTPPSDetId.h:47
static const uint32_t maskArm
Definition: CTPPSDetId.h:46
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
static const uint32_t maxArm
Definition: CTPPSDetId.h:46
static const std::string subDetectorPaths[]
Definition: CTPPSDetId.h:153
static const uint32_t maxRP
Definition: CTPPSDetId.h:48
static const std::string rpNames[]
Definition: CTPPSDetId.h:156
static const std::string subDetectorNames[]
Definition: CTPPSDetId.h:152
Definition: DetId.h:18
uint32_t id_
Definition: DetId.h:59
static const uint32_t startStationBit
Definition: CTPPSDetId.h:47
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
CTPPSDetId(uint32_t id)
Construct from a raw id.
Definition: CTPPSDetId.cc:31
static const uint32_t startArmBit
Definition: CTPPSDetId.h:46
static const std::string stationNames[]
Definition: CTPPSDetId.h:155
static const uint32_t lowMaskArm
Definition: CTPPSDetId.h:46
static const uint32_t lowMaskRP
Definition: CTPPSDetId.h:48
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39