Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:38:50

0001 /****************************************************************************
0002  *
0003  * This is a part of TOTEM offline software.
0004  * Authors:
0005  *  Hubert Niewiadomski
0006  *  Jan Kašpar (jan.kaspar@gmail.com)
0007  *
0008  ****************************************************************************/
0009 
0010 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0011 
0012 #include "FWCore/Utilities/interface/Exception.h"
0013 
0014 using namespace std;
0015 
0016 //----------------------------------------------------------------------------------------------------
0017 
0018 const uint32_t CTPPSDetId::startArmBit = 24, CTPPSDetId::maskArm = 0x1, CTPPSDetId::maxArm = 1,
0019                CTPPSDetId::lowMaskArm = 0xFFFFFF;
0020 const uint32_t CTPPSDetId::startStationBit = 22, CTPPSDetId::maskStation = 0x3, CTPPSDetId::maxStation = 2,
0021                CTPPSDetId::lowMaskStation = 0x3FFFFF;
0022 const uint32_t CTPPSDetId::startRPBit = 19, CTPPSDetId::maskRP = 0x7, CTPPSDetId::maxRP = 6,
0023                CTPPSDetId::lowMaskRP = 0x7FFFF;
0024 
0025 const string CTPPSDetId::subDetectorNames[] = {
0026     "", "", "", "ctpps_tr_strip", "ctpps_tr_pixel", "ctpps_ti_diamond", "ctpps_ti_fastsilicon", "totem_t2"};
0027 const string CTPPSDetId::subDetectorPaths[] = {"",
0028                                                "",
0029                                                "",
0030                                                "CTPPS/TrackingStrip",
0031                                                "CTPPS/TrackingPixel",
0032                                                "CTPPS/TimingDiamond",
0033                                                "CTPPS/TimingFastSilicon",
0034                                                "TotemT2"};
0035 const string CTPPSDetId::armNames[] = {"45", "56"};
0036 const string CTPPSDetId::stationNames[] = {"210", "220cyl", "220"};
0037 const string CTPPSDetId::rpNames[] = {"nr_tp", "nr_bt", "nr_hr", "fr_hr", "fr_tp", "fr_bt", "cyl_hr"};
0038 
0039 //----------------------------------------------------------------------------------------------------
0040 
0041 CTPPSDetId::CTPPSDetId(uint32_t id) : DetId(id) {
0042   bool inputOK = (det() == DetId::VeryForward);
0043 
0044   if (!inputOK) {
0045     throw cms::Exception("InvalidDetId") << "CTPPSDetId ctor:"
0046                                          << " det: " << det() << " subdet: " << subdetId()
0047                                          << " is not a valid CTPPS id.";
0048   }
0049 }
0050 
0051 //----------------------------------------------------------------------------------------------------
0052 
0053 CTPPSDetId::CTPPSDetId(uint32_t SubDet, uint32_t Arm, uint32_t Station, uint32_t RomanPot)
0054     : DetId(DetId::VeryForward, SubDet) {
0055   if (SubDet != sdTrackingStrip && SubDet != sdTrackingPixel && SubDet != sdTimingDiamond &&
0056       SubDet != sdTimingFastSilicon && SubDet != sdTotemT2) {
0057     throw cms::Exception("InvalidDetId") << "CTPPSDetId ctor: invalid sub-detector " << SubDet << ".";
0058   }
0059 
0060   if (Arm > maxArm || Station > maxStation || RomanPot > maxRP) {
0061     throw cms::Exception("InvalidDetId") << "CTPPSDetId ctor:"
0062                                          << " Invalid parameters:"
0063                                          << " arm=" << Arm << " station=" << Station << " rp=" << RomanPot << std::endl;
0064   }
0065 
0066   uint32_t ok = 0xfe000000;
0067   id_ &= ok;
0068 
0069   id_ |= ((Arm & maskArm) << startArmBit);
0070   id_ |= ((Station & maskStation) << startStationBit);
0071   id_ |= ((RomanPot & maskRP) << startRPBit);
0072 }
0073 
0074 //----------------------------------------------------------------------------------------------------
0075 
0076 std::ostream& operator<<(std::ostream& os, const CTPPSDetId& id) {
0077   os << "subDet=" << id.subdetId() << " arm=" << id.arm() << " station=" << id.station() << " rp=" << id.rp();
0078 
0079   return os;
0080 }