Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /****************************************************************************
0002  * Author: Seyed Mohsen Etesami 
0003  * Spetember 2016
0004  ****************************************************************************/
0005 
0006 #include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
0007 
0008 #include "FWCore/Utilities/interface/Exception.h"
0009 
0010 using namespace std;
0011 
0012 //----------------------------------------------------------------------------------------------------
0013 
0014 const uint32_t CTPPSDiamondDetId::startPlaneBit = 17, CTPPSDiamondDetId::maskPlane = 0x3,
0015                CTPPSDiamondDetId::maxPlane = 3, CTPPSDiamondDetId::lowMaskPlane = 0x1FFFF;
0016 const uint32_t CTPPSDiamondDetId::startDetBit = 12, CTPPSDiamondDetId::maskChannel = 0x1F,
0017                CTPPSDiamondDetId::maxChannel = 31, CTPPSDiamondDetId::lowMaskChannel = 0xFFF;
0018 
0019 //----------------------------------------------------------------------------------------------------
0020 
0021 CTPPSDiamondDetId::CTPPSDiamondDetId(uint32_t id) : CTPPSDetId(id) {
0022   if (!check(id)) {
0023     throw cms::Exception("InvalidDetId") << "CTPPSDiamondDetId ctor:"
0024                                          << " channel: " << channel() << " subdet: " << subdetId()
0025                                          << " is not a valid CTPPS Timing Diamond id";
0026   }
0027 }
0028 
0029 //----------------------------------------------------------------------------------------------------
0030 
0031 CTPPSDiamondDetId::CTPPSDiamondDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot, uint32_t Plane, uint32_t Channel)
0032     : CTPPSDetId(sdTimingDiamond, Arm, Station, RomanPot) {
0033   if (Arm > maxArm || Station > maxStation || RomanPot > maxRP || Plane > maxPlane || Channel > maxChannel) {
0034     throw cms::Exception("InvalidDetId") << "CTPPSDiamondDetId ctor:"
0035                                          << " Invalid parameters:"
0036                                          << " arm=" << Arm << " station=" << Station << " rp=" << RomanPot
0037                                          << " plane=" << Plane << " detector=" << Channel << std::endl;
0038   }
0039 
0040   uint32_t ok = 0xfe000000;
0041   id_ &= ok;
0042 
0043   id_ |= ((Arm & maskArm) << startArmBit);
0044   id_ |= ((Station & maskStation) << startStationBit);
0045   id_ |= ((RomanPot & maskRP) << startRPBit);
0046   id_ |= ((Plane & maskPlane) << startPlaneBit);
0047   id_ |= ((Channel & maskChannel) << startDetBit);
0048 }
0049 
0050 //----------------------------------------------------------------------------------------------------
0051 
0052 std::ostream& operator<<(std::ostream& os, const CTPPSDiamondDetId& id) {
0053   os << "arm=" << id.arm() << " station=" << id.station() << " rp=" << id.rp() << " plane=" << id.plane()
0054      << " Detector=" << id.channel();
0055 
0056   return os;
0057 }