Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:26

0001 #include "SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h"
0002 #include <ostream>
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 const AHCalDetId AHCalDetId::Undefined(0, 0, 0);
0006 
0007 AHCalDetId::AHCalDetId() : DetId() {}
0008 
0009 AHCalDetId::AHCalDetId(uint32_t rawid) : DetId(rawid) {}
0010 
0011 AHCalDetId::AHCalDetId(int row, int col, int depth) : DetId(Hcal, HcalOther) {
0012   int icol = (col > 0) ? col : kMaxRowCol - col;
0013   int irow = (row > 0) ? row : kMaxRowCol - row;
0014   id_ |= ((depth & kHcalDepthMask) << HcalDetId::kHcalDepthOffset1) | (HcalDetId::kHcalZsideMask1) |
0015          ((irow & HcalDetId::kHcalEtaMask1) << HcalDetId::kHcalEtaOffset1) | (icol & HcalDetId::kHcalPhiMask1);
0016 }
0017 
0018 AHCalDetId::AHCalDetId(const DetId& gen) {
0019   if (!gen.null()) {
0020     HcalSubdetector subdet = (HcalSubdetector(gen.subdetId()));
0021     if (gen.det() != Hcal || subdet != HcalOther) {
0022       throw cms::Exception("Invalid DetId")
0023           << "Cannot initialize AHCalDetId from " << std::hex << gen.rawId() << std::dec;
0024     }
0025   }
0026   id_ = gen.rawId();
0027 }
0028 
0029 int AHCalDetId::irow() const {
0030   int value = ((id_ >> HcalDetId::kHcalEtaOffset1) & HcalDetId::kHcalEtaMask1);
0031   if (value >= kMaxRowCol)
0032     value = (kMaxRowCol - value);
0033   return value;
0034 }
0035 
0036 int AHCalDetId::icol() const {
0037   int value = (id_ & HcalDetId::kHcalPhiMask1);
0038   if (value >= kMaxRowCol)
0039     value = (kMaxRowCol - value);
0040   return value;
0041 }
0042 
0043 int AHCalDetId::depth() const { return ((id_ >> HcalDetId::kHcalDepthOffset1) & kHcalDepthMask); }
0044 
0045 std::ostream& operator<<(std::ostream& s, const AHCalDetId& id) {
0046   return s << "(AHCal " << id.irow() << ',' << id.icol() << ',' << id.depth() << ')';
0047 }