From f9186b563f0479e35648f9745d3a970684b978cd Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 17 Oct 2023 20:32:10 +0200 Subject: [PATCH] Code check --- .../ForwardDetId/interface/HGCSiliconDetId.h | 36 +++++++++++-------- SimG4CMS/Calo/interface/HGCalSD.h | 4 +-- SimG4CMS/Calo/src/CaloSD.cc | 8 ++--- SimG4CMS/Calo/src/HGCalSD.cc | 8 +++-- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h b/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h index f6abdc8bd1efe..0ce56bd2b2b72 100644 --- a/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h +++ b/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h @@ -33,26 +33,28 @@ class HGCSiliconDetId : public DetId { /** Create cellid from raw id (0=invalid tower id) */ constexpr HGCSiliconDetId(uint32_t rawid) : DetId(rawid) {} /** Constructor from subdetector, zplus, layer, module, cell numbers */ - constexpr HGCSiliconDetId(DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV): DetId(det, ForwardEmpty) { + constexpr HGCSiliconDetId( + DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV) + : DetId(det, ForwardEmpty) { int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV)); int waferUsign = (waferU >= 0) ? 0 : 1; int waferVsign = (waferV >= 0) ? 0 : 1; int zside = (zp < 0) ? 1 : 0; id_ |= (((cellU & kHGCalCellUMask) << kHGCalCellUOffset) | ((cellV & kHGCalCellVMask) << kHGCalCellVOffset) | - ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) | - ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) | - ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) | - ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) | - ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) | - ((type & kHGCalTypeMask) << kHGCalTypeOffset)); + ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) | + ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) | + ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) | + ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) | + ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) | + ((type & kHGCalTypeMask) << kHGCalTypeOffset)); } /** Constructor from a generic cell id */ constexpr HGCSiliconDetId(const DetId& gen) { if (!gen.null()) { if ((gen.det() != HGCalEE) && (gen.det() != HGCalHSi)) { - throw cms::Exception("Invalid DetId") - << "Cannot initialize HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec; + throw cms::Exception("Invalid DetId") + << "Cannot initialize HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec; } } id_ = gen.rawId(); @@ -62,8 +64,8 @@ class HGCSiliconDetId : public DetId { constexpr HGCSiliconDetId& operator=(const DetId& gen) { if (!gen.null()) { if ((gen.det() != HGCalEE) && (gen.det() != HGCalHSi)) { - throw cms::Exception("Invalid DetId") - << "Cannot assign HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec; + throw cms::Exception("Invalid DetId") + << "Cannot assign HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec; } } id_ = gen.rawId(); @@ -71,7 +73,9 @@ class HGCSiliconDetId : public DetId { } /** Converter for a geometry cell id */ - constexpr HGCSiliconDetId geometryCell() const { return HGCSiliconDetId(det(), zside(), 0, layer(), waferU(), waferV(), 0, 0); } + constexpr HGCSiliconDetId geometryCell() const { + return HGCSiliconDetId(det(), zside(), 0, layer(), waferU(), waferV(), 0, 0); + } constexpr HGCSiliconDetId moduleId() const { return HGCSiliconDetId(det(), zside(), type(), layer(), waferU(), waferV(), 0, 0); } @@ -105,8 +109,12 @@ class HGCSiliconDetId : public DetId { /// get the wafer #'s in u,v or in x,y constexpr int waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; } constexpr int waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; } - constexpr int waferU() const { return (((id_ >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs()); } - constexpr int waferV() const { return (((id_ >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs()); } + constexpr int waferU() const { + return (((id_ >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs()); + } + constexpr int waferV() const { + return (((id_ >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs()); + } constexpr std::pair waferUV() const { return std::pair(waferU(), waferV()); } constexpr int waferX() const { return (-2 * waferU() + waferV()); } constexpr int waferY() const { return (2 * waferV()); } diff --git a/SimG4CMS/Calo/interface/HGCalSD.h b/SimG4CMS/Calo/interface/HGCalSD.h index 83099a88bd54c..a1b933a07ab9a 100644 --- a/SimG4CMS/Calo/interface/HGCalSD.h +++ b/SimG4CMS/Calo/interface/HGCalSD.h @@ -40,11 +40,11 @@ class HGCalSD : public CaloSD, public Observer { private: uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); bool isItinFidVolume(const G4ThreeVector &); - bool calibCell(const uint32_t& id, double& frac); + bool calibCell(const uint32_t &id, double &frac); std::string myName_; const HGCalDDDConstants *hgcons_; - edm::ParameterSet const& ps_; + edm::ParameterSet const &ps_; std::unique_ptr numberingScheme_; std::unique_ptr guardRing_; std::unique_ptr guardRingPartial_; diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index 4d6f65c092082..fd0de85fabc50 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -176,8 +176,8 @@ void CaloSD::newCollection(const std::string& name, edm::ParameterSet const& p) for (unsigned int k = 0; k < hcn_.size(); ++k) { if (name == hcn_[k]) { if (k < useResMap_.size() && useResMap_[k] > 0) { - meanResponse[1] = std::make_unique(p); - break; + meanResponse[1] = std::make_unique(p); + break; } } } @@ -367,7 +367,7 @@ bool CaloSD::isItFineCalo(const G4VTouchable* touch) { G4LogicalVolume* lv = touch->GetVolume(ii)->GetLogicalVolume(); ok = (lv == detector.lv); #ifdef EDM_ML_DEBUG - std::string name1 = (lv == 0) ? "Unknown" : lv->GetName(); + std::string name1 = (lv == nullptr) ? "Unknown" : lv->GetName(); edm::LogVerbatim("CaloSim") << "CaloSD: volume " << name1 << ":" << detector.name << " at Level " << detector.level << " Flag " << ok; #endif @@ -384,7 +384,7 @@ void CaloSD::Initialize(G4HCofThisEvent* HCE, int k) { if (k == 0) { detName_[0] = GetName(); collName_[0] = collectionName[0]; - } + } totalHits[k] = 0; #ifdef EDM_ML_DEBUG diff --git a/SimG4CMS/Calo/src/HGCalSD.cc b/SimG4CMS/Calo/src/HGCalSD.cc index 2089b0fc19068..c8ededa2311ed 100644 --- a/SimG4CMS/Calo/src/HGCalSD.cc +++ b/SimG4CMS/Calo/src/HGCalSD.cc @@ -318,8 +318,9 @@ void HGCalSD::update(const BeginOfJob* job) { throw cms::Exception("Unknown", "HGCalSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; } if (calibCells_) { - newCollection(("Calibration"+myName_), ps_); - cellOffset_ = std::make_unique(waferSize_, hgcons_->getUVMax(0), hgcons_->getUVMax(1), guardRingOffset_, mouseBiteCut_); + newCollection(("Calibration" + myName_), ps_); + cellOffset_ = std::make_unique( + waferSize_, hgcons_->getUVMax(0), hgcons_->getUVMax(1), guardRingOffset_, mouseBiteCut_); } } @@ -363,7 +364,8 @@ bool HGCalSD::calibCell(const uint32_t& id, double& frac) { flag = (std::find(calibCellPartLD_.begin(), calibCellPartLD_.end(), indx) != calibCellPartLD_.end()); } if (flag) { - int32_t place = HGCalCell::cellPlacementIndex(zside, HGCalTypes::layerFrontBack(hgcons_->layerType(layer)), info.orient); + int32_t place = + HGCalCell::cellPlacementIndex(zside, HGCalTypes::layerFrontBack(hgcons_->layerType(layer)), info.orient); int32_t type = hd ? 0 : 1; double num = hd ? (M_PI * calibCellRHD_ * calibCellRHD_) : (M_PI * calibCellRLD_ * calibCellRLD_); double bot = cellOffset_->cellAreaUV(cellU, cellV, place, type);