Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/ForwardDetId/interface/HGCalTriggerModuleDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <iostream>
0004 
0005 HGCalTriggerModuleDetId::HGCalTriggerModuleDetId() : DetId() {}
0006 
0007 HGCalTriggerModuleDetId::HGCalTriggerModuleDetId(uint32_t rawid) : DetId(rawid) {}
0008 
0009 HGCalTriggerModuleDetId::HGCalTriggerModuleDetId(
0010     HGCalTriggerSubdetector subdet, int zp, int type, int layer, int sector, int moduleU, int moduleV)
0011     : DetId(Forward, HGCTrigger) {
0012   int classid = HGCalTriggerClassIdentifier::ModuleDetId;
0013   int zside = (zp < 0) ? 1 : 0;
0014 
0015   id_ |=
0016       (((moduleU & kHGCalModuleUMask) << kHGCalModuleUOffset) | ((moduleV & kHGCalModuleVMask) << kHGCalModuleVOffset) |
0017        ((sector & kHGCalSectorMask) << kHGCalSectorOffset) | ((layer & kHGCalLayerMask) << kHGCalLayerOffset) |
0018        ((zside & kHGCalZsideMask) << kHGCalZsideOffset) | ((type & kHGCalTypeMask) << kHGCalTypeOffset) |
0019        ((subdet & kHGCalTriggerSubdetMask) << kHGCalTriggerSubdetOffset) |
0020        ((classid & kHGCalTriggerClassIdentifierMask) << kHGCalTriggerClassIdentifierOffset));
0021 }
0022 
0023 HGCalTriggerModuleDetId::HGCalTriggerModuleDetId(const DetId& gen) {
0024   if (!gen.null()) {
0025     if (gen.det() != Forward) {
0026       throw cms::Exception("Invalid DetId")
0027           << "Cannot initialize HGCalTriggerModuleDetId from " << std::hex << gen.rawId() << std::dec;
0028     }
0029   }
0030   id_ = gen.rawId();
0031 }
0032 
0033 HGCalTriggerModuleDetId& HGCalTriggerModuleDetId::operator=(const DetId& gen) {
0034   if (!gen.null()) {
0035     if (gen.det() != Forward) {
0036       throw cms::Exception("Invalid DetId")
0037           << "Cannot assign HGCalTriggerModuleDetId from " << std::hex << gen.rawId() << std::dec;
0038     }
0039   }
0040   id_ = gen.rawId();
0041   return (*this);
0042 }
0043 
0044 std::ostream& operator<<(std::ostream& s, const HGCalTriggerModuleDetId& id) {
0045   return s << "HGCalTriggerModuleDetId::HFNose:EE:HSil:HScin= " << id.isHFNose() << ":" << id.isEE() << ":"
0046            << id.isHSilicon() << ":" << id.isHScintillator() << " type= " << id.type() << " z= " << id.zside()
0047            << " layer= " << id.layer() << " sector= " << id.sector() << " module(u,v)= (" << id.moduleU() << ","
0048            << id.moduleV() << ")";
0049 }