Skip to content

Commit

Permalink
Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Nov 2, 2023
1 parent 28c0ab2 commit 95c7bc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
18 changes: 11 additions & 7 deletions DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,23 @@ class HGCScintillatorDetId : public DetId {
/** Create cellid from raw id (0=invalid tower id) */
constexpr HGCScintillatorDetId(uint32_t rawid) : DetId(rawid) {}
/** Constructor from subdetector, zplus, layer, module, cell numbers */
constexpr HGCScintillatorDetId(int type, int layer, int ring, int phi, bool trigger = false, int sipm = 0) : DetId(HGCalHSc, ForwardEmpty) {
constexpr HGCScintillatorDetId(int type, int layer, int ring, int phi, bool trigger = false, int sipm = 0)
: DetId(HGCalHSc, ForwardEmpty) {
int zside = (ring < 0) ? 1 : 0;
int itrig = trigger ? 1 : 0;
int ringAbs = std::abs(ring);
id_ |= (((type & kHGCalTypeMask) << kHGCalTypeOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) | ((sipm & kHGCalSiPMMask) << kHGCalSiPMOffset) | ((itrig & kHGCalTriggerMask) << kHGCalTriggerOffset) | ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((ringAbs & kHGCalRadiusMask) << kHGCalRadiusOffset) | ((phi & kHGCalPhiMask) << kHGCalPhiOffset));
id_ |= (((type & kHGCalTypeMask) << kHGCalTypeOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) |
((sipm & kHGCalSiPMMask) << kHGCalSiPMOffset) | ((itrig & kHGCalTriggerMask) << kHGCalTriggerOffset) |
((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((ringAbs & kHGCalRadiusMask) << kHGCalRadiusOffset) |
((phi & kHGCalPhiMask) << kHGCalPhiOffset));
}

/** Constructor from a generic cell id */
constexpr HGCScintillatorDetId(const DetId& gen) {
if (!gen.null()) {
if (gen.det() != HGCalHSc) {
throw cms::Exception("Invalid DetId")
<< "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
throw cms::Exception("Invalid DetId")
<< "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
}
}
id_ = gen.rawId();
Expand All @@ -50,8 +54,8 @@ class HGCScintillatorDetId : public DetId {
constexpr HGCScintillatorDetId& operator=(const DetId& gen) {
if (!gen.null()) {
if (gen.det() != HGCalHSc) {
throw cms::Exception("Invalid DetId")
<< "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
throw cms::Exception("Invalid DetId")
<< "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
}
}
id_ = gen.rawId();
Expand Down Expand Up @@ -107,7 +111,7 @@ class HGCScintillatorDetId : public DetId {

/// get/set the sipm size
constexpr int sipm() const { return (id_ >> kHGCalSiPMOffset) & kHGCalSiPMMask; }
constexpr void setSiPM(int sipm) {
constexpr void setSiPM(int sipm) {
id_ &= kHGCalSiPMMask0;
id_ |= ((sipm & kHGCalSiPMMask) << kHGCalSiPMOffset);
}
Expand Down
26 changes: 13 additions & 13 deletions DataFormats/ForwardDetId/src/HGCScintillatorDetId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
const HGCScintillatorDetId HGCScintillatorDetId::Undefined(0, 0, 0, 0, false);

std::vector<HGCScintillatorDetId> HGCScintillatorDetId::detectorCells() const {
std::vector<HGCScintillatorDetId> cells;
int irad = ring();
int ifi = iphi();
int iz = zside();
if (trigger()) {
cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi - 1, false));
cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi - 1, false));
cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi, false));
cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi, false));
} else {
cells.emplace_back(HGCScintillatorDetId(type(), layer(), irad * iz, ifi, false));
}
return cells;
std::vector<HGCScintillatorDetId> cells;
int irad = ring();
int ifi = iphi();
int iz = zside();
if (trigger()) {
cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi - 1, false));
cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi - 1, false));
cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi, false));
cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi, false));
} else {
cells.emplace_back(HGCScintillatorDetId(type(), layer(), irad * iz, ifi, false));
}
return cells;
}

std::ostream& operator<<(std::ostream& s, const HGCScintillatorDetId& id) {
return s << " HGCScintillatorDetId::EE:HE= " << id.isEE() << ":" << id.isHE() << " trigger= " << id.trigger()
Expand Down

0 comments on commit 95c7bc2

Please sign in to comment.