Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-09 03:14:58

0001 #include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <iostream>
0004 
0005 HGCalTriggerBackendDetId::HGCalTriggerBackendDetId() : DetId() {}
0006 
0007 HGCalTriggerBackendDetId::HGCalTriggerBackendDetId(uint32_t rawid) : DetId(rawid) {}
0008 
0009 HGCalTriggerBackendDetId::HGCalTriggerBackendDetId(int zp, int type, int sector, int label)
0010     : DetId(Forward, HGCTrigger) {
0011   int classid = HGCalTriggerClassIdentifier::ModuleDetId;
0012   int zside = (zp < 0) ? 1 : 0;
0013   id_ |= (((label & kHGCalLabelMask) << kHGCalLabelOffset) | ((sector & kHGCalSectorMask) << kHGCalSectorOffset) |
0014           ((zside & kHGCalZsideMask) << kHGCalZsideOffset) | ((type & kHGCalTypeMask) << kHGCalTypeOffset) |
0015           ((classid & kHGCalTriggerClassIdentifierMask) << kHGCalTriggerClassIdentifierOffset));
0016 }
0017 
0018 HGCalTriggerBackendDetId::HGCalTriggerBackendDetId(const DetId& gen) {
0019   if (!gen.null()) {
0020     if (gen.det() != Forward) {
0021       throw cms::Exception("Invalid DetId")
0022           << "Cannot initialize HGCalTriggerBackendDetId from " << std::hex << gen.rawId() << std::dec;
0023     }
0024   }
0025   id_ = gen.rawId();
0026 }
0027 
0028 HGCalTriggerBackendDetId& HGCalTriggerBackendDetId::operator=(const DetId& gen) {
0029   if (!gen.null()) {
0030     if (gen.det() != Forward) {
0031       throw cms::Exception("Invalid DetId")
0032           << "Cannot assign HGCalTriggerBackendDetId from " << std::hex << gen.rawId() << std::dec;
0033     }
0034   }
0035   id_ = gen.rawId();
0036   return (*this);
0037 }
0038 
0039 std::ostream& operator<<(std::ostream& s, const HGCalTriggerBackendDetId& id) {
0040   return s << "HGCalTriggerBackendDetId::lpGBT:Stage1 FPGA:Stage2 FPGA= " << id.isLpGBT() << ":" << id.isStage1FPGA()
0041            << ":" << id.isStage1Link() << ":" << id.isStage2FPGA() << " z= " << id.zside() << " sector= " << id.sector()
0042            << " id= " << id.label();
0043 }