Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/ForwardDetId/interface/FastTimeDetId.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <ostream>
0004 #include <iostream>
0005 
0006 const FastTimeDetId FastTimeDetId::Undefined(0, 0, 0, 0);
0007 
0008 FastTimeDetId::FastTimeDetId() : DetId() {}
0009 
0010 FastTimeDetId::FastTimeDetId(uint32_t rawid) : DetId(rawid) {}
0011 
0012 FastTimeDetId::FastTimeDetId(int module_type, int module_iz, int module_iphi, int module_zside)
0013     : DetId(Forward, FastTime) {
0014   int zsid = (module_zside > 0) ? (kFastTimeZsideMask) : (0);
0015   id_ |= (((module_type & kFastTimeTypeMask) << kFastTimeTypeOffset) |
0016           ((module_iz & kFastTimeCellZMask) << kFastTimeCellZOffset) |
0017           ((module_iphi & kFastTimeCellPhiMask) << kFastTimeCellPhiOffset) | (zsid << kFastTimeZsideOffset));
0018 }
0019 
0020 FastTimeDetId::FastTimeDetId(const DetId& gen) {
0021   if (!gen.null()) {
0022     ForwardSubdetector subdet = (ForwardSubdetector(gen.subdetId()));
0023     if (gen.det() != Forward || (subdet != FastTime)) {
0024       throw cms::Exception("Invalid DetId")
0025           << "Cannot initialize FastTimeDetId from " << std::hex << gen.rawId() << std::dec;
0026     }
0027   }
0028   id_ = gen.rawId();
0029 }
0030 
0031 FastTimeDetId& FastTimeDetId::operator=(const DetId& gen) {
0032   if (!gen.null()) {
0033     ForwardSubdetector subdet = (ForwardSubdetector(gen.subdetId()));
0034     if (gen.det() != Forward || (subdet != FastTime)) {
0035       throw cms::Exception("Invalid DetId")
0036           << "Cannot assign FastTimeDetId from " << std::hex << gen.rawId() << std::dec;
0037     }
0038   }
0039   id_ = gen.rawId();
0040   return (*this);
0041 }
0042 
0043 std::ostream& operator<<(std::ostream& s, const FastTimeDetId& id) {
0044   return s << "(FastTime " << id.type() << ", iz " << ((id.zside() > 0) ? ("+ ") : ("- ")) << " iz/ieta " << id.iz()
0045            << ", iphi " << id.iphi() << ")";
0046 }