Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:11

0001 /*
0002   Author: F.Ferro INFN Genova
0003   October 2016
0004 */
0005 
0006 #include <DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h>
0007 #include <FWCore/Utilities/interface/Exception.h>
0008 
0009 // VeryForward =7, Tracker = 4
0010 
0011 const uint32_t CTPPSPixelDetId::startPlaneBit = 16, CTPPSPixelDetId::maskPlane = 0x7, CTPPSPixelDetId::maxPlane = 5;
0012 
0013 CTPPSPixelDetId::CTPPSPixelDetId(uint32_t id) : CTPPSDetId(id) {
0014   if (!check(id)) {
0015     throw cms::Exception("InvalidDetId") << "CTPPSPixelDetId ctor:"
0016                                          << " det: " << det() << " subdet: " << subdetId()
0017                                          << " is not a valid CTPPS Pixel id";
0018   }
0019 }
0020 
0021 CTPPSPixelDetId::CTPPSPixelDetId(unsigned int Arm, unsigned int Station, unsigned int RP, unsigned int Plane)
0022     : CTPPSDetId(sdTrackingPixel, Arm, Station, RP) {
0023   this->init(Arm, Station, RP, Plane);
0024 }
0025 
0026 void CTPPSPixelDetId::init(unsigned int Arm, unsigned int Station, unsigned int RP, unsigned int Plane) {
0027   if (Arm > maxArm || Station > maxStation || RP > maxRP || Plane > maxPlane) {
0028     throw cms::Exception("InvalidDetId") << "CTPPSPixelDetId ctor:"
0029                                          << " Invalid parameterss: "
0030                                          << " Arm " << Arm << " Station " << Station << " RP " << RP << " Plane "
0031                                          << Plane << std::endl;
0032   }
0033 
0034   uint32_t ok = 0xfe000000;
0035   id_ &= ok;
0036 
0037   id_ |= ((Arm & maskArm) << startArmBit);
0038   id_ |= ((Station & maskStation) << startStationBit);
0039   id_ |= ((RP & maskRP) << startRPBit);
0040   id_ |= ((Plane & maskPlane) << startPlaneBit);
0041 }
0042 
0043 std::ostream& operator<<(std::ostream& os, const CTPPSPixelDetId& id) {
0044   os << " Arm " << id.arm() << " Station " << id.station() << " RP " << id.rp() << " Plane " << id.plane();
0045 
0046   return os;
0047 }