Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-12-05 03:12:24

0001 #include "SimG4CMS/Calo/interface/HGCGuardRingPartial.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Geometry/HGCalCommonData/interface/HGCalWaferMask.h"
0004 #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h"
0005 #include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
0006 #include <iostream>
0007 #include <array>
0008 
0009 //#define EDM_ML_DEBUG
0010 
0011 HGCGuardRingPartial::HGCGuardRingPartial(const HGCalDDDConstants& hgc)
0012     : hgcons_(hgc),
0013       modeUV_(hgcons_.geomMode()),
0014       v17OrLess_(hgcons_.v17OrLess()),
0015       waferSize_(hgcons_.waferSize(false)),
0016       guardRingOffset_(hgcons_.getParameter()->guardRingOffset_) {
0017   offset_ = guardRingOffset_;
0018   c22_ = (v17OrLess_) ? HGCalTypes::c22O : HGCalTypes::c22;
0019   c27_ = (v17OrLess_) ? HGCalTypes::c27O : HGCalTypes::c27;
0020 #ifdef EDM_ML_DEBUG
0021   edm::LogVerbatim("HGCSim") << "Creating HGCGuardRingPartial with wafer size " << waferSize_ << ", Offsets "
0022                              << ":" << guardRingOffset_ << ":" << offset_ << ", and mode " << modeUV_
0023                              << " coefficients " << c22_ << ":" << c27_;
0024 #endif
0025 }
0026 
0027 bool HGCGuardRingPartial::exclude(G4ThreeVector& point, int zside, int frontBack, int layer, int waferU, int waferV) {
0028   bool check(false);
0029   if ((modeUV_ == HGCalGeometryMode::Hexagon8Cassette) || (modeUV_ == HGCalGeometryMode::Hexagon8CalibCell)) {
0030     int index = HGCalWaferIndex::waferIndex(layer, waferU, waferV);
0031     int partial = HGCalWaferType::getPartial(index, hgcons_.getParameter()->waferInfoMap_);
0032     int type = HGCalWaferType::getType(index, hgcons_.getParameter()->waferInfoMap_);
0033     if (partial == HGCalTypes::WaferFull) {
0034       return (check);
0035     } else {
0036       int orient = HGCalWaferType::getOrient(index, hgcons_.getParameter()->waferInfoMap_);
0037       int placement = HGCalCell::cellPlacementIndex(zside, frontBack, orient);
0038       double dx = point.x();
0039       double dy = point.y();
0040       if (type > 0) {
0041         for (int ii = HGCalTypes::WaferPartLDOffset;
0042              ii < (HGCalTypes::WaferPartLDOffset + HGCalTypes::WaferPartLDCount);
0043              ii++) {
0044           std::array<double, 4> criterion = HGCalWaferMask::maskCut(ii, placement, waferSize_, offset_, v17OrLess_);
0045           check |= std::abs(criterion[0] * dy + criterion[1] * dx + criterion[2]) < criterion[3];
0046         }
0047       } else {
0048         for (int ii = HGCalTypes::WaferPartHDOffset;
0049              ii < (HGCalTypes::WaferPartHDOffset + HGCalTypes::WaferPartHDCount);
0050              ii++) {
0051           std::array<double, 4> criterion = HGCalWaferMask::maskCut(ii, placement, waferSize_, offset_, v17OrLess_);
0052           check |= std::abs(criterion[0] * dy + criterion[1] * dx + criterion[2]) < criterion[3];
0053         }
0054       }
0055     }
0056 #ifdef EDM_ML_DEBUG
0057     edm::LogVerbatim("HGCSim") << "HGCGuardRingPartial:: Point " << point << " zside " << zside << " layer " << layer
0058                                << " wafer " << waferU << ":" << waferV << " partial type " << partial << " type "
0059                                << type << " check " << check;
0060 #endif
0061   }
0062   return check;
0063 }