Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:01

0001 /****************************************************************************
0002  * Author: Nicola Minafra
0003  *  March 2018
0004  ****************************************************************************/
0005 
0006 #include "DataFormats/CTPPSDetId/interface/TotemTimingDetId.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 
0009 //----------------------------------------------------------------------------------------------------
0010 
0011 TotemTimingDetId::TotemTimingDetId(uint32_t id) : CTPPSDetId(id) {
0012   if (!check(id)) {
0013     throw cms::Exception("InvalidDetId") << "TotemTimingDetId ctor:"
0014                                          << " channel: " << channel() << " subdet: " << subdetId()
0015                                          << " is not a valid Totem Timing id";
0016   }
0017 }
0018 
0019 //----------------------------------------------------------------------------------------------------
0020 
0021 TotemTimingDetId::TotemTimingDetId(
0022     uint32_t arm, uint32_t station, uint32_t romanPot, uint32_t plane, uint32_t channel, uint32_t subdet)
0023     : CTPPSDetId(subdet, arm, station, romanPot) {
0024   if (arm > maxArm || station > maxStation || romanPot > maxRP || plane > maxPlane || channel > maxChannel) {
0025     throw cms::Exception("InvalidDetId") << "TotemTimingDetId ctor:"
0026                                          << " Invalid parameters:"
0027                                          << " arm=" << arm << " station=" << station << " rp=" << romanPot
0028                                          << " plane=" << plane << " detector=" << channel << std::endl;
0029   }
0030 
0031   uint32_t ok = 0xfe000000;
0032   id_ &= ok;
0033 
0034   id_ |= ((arm & maskArm) << startArmBit);
0035   id_ |= ((station & maskStation) << startStationBit);
0036   id_ |= ((romanPot & maskRP) << startRPBit);
0037   id_ |= ((plane & maskPlane) << startPlaneBit);
0038   id_ |= ((channel & maskChannel) << startDetBit);
0039 }
0040 
0041 //----------------------------------------------------------------------------------------------------
0042 
0043 std::ostream& operator<<(std::ostream& os, const TotemTimingDetId& id) {
0044   return os << "arm=" << id.arm() << " station=" << id.station() << " rp=" << id.rp() << " plane=" << id.plane()
0045             << " Detector=" << id.channel();
0046 }