File indexing completed on 2024-05-10 02:21:17
0001 #include "SimG4CMS/Calo/interface/HGCMouseBite.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0004 #include <CLHEP/Units/SystemOfUnits.h>
0005 #include <iostream>
0006
0007
0008
0009 HGCMouseBite::HGCMouseBite(const HGCalDDDConstants& hgc, const std::vector<double>& angle, double maxL, bool rot)
0010 : hgcons_(&hgc), hgTBcons_(nullptr), ifTB_(false), cut_(maxL), rot_(rot) {
0011 modeUV_ = hgcons_->waferHexagon8();
0012 init(angle);
0013 }
0014
0015 HGCMouseBite::HGCMouseBite(const HGCalTBDDDConstants& hgc, const std::vector<double>& angle, double maxL, bool rot)
0016 : hgcons_(nullptr), hgTBcons_(&hgc), ifTB_(true), cut_(maxL), rot_(rot) {
0017 modeUV_ = false;
0018 init(angle);
0019 }
0020
0021 void HGCMouseBite::init(const std::vector<double>& angle) {
0022 for (auto ang : angle) {
0023 projXY_.push_back(std::pair<double, double>(cos(ang * CLHEP::deg), sin(ang * CLHEP::deg)));
0024 }
0025 #ifdef EDM_ML_DEBUG
0026 edm::LogVerbatim("HGCSim") << "Creating HGCMosueBite with cut at " << cut_ << " with mode " << modeUV_ << " along "
0027 << angle.size() << " axes TB Flag " << ifTB_ << " Rot " << rot_;
0028 for (unsigned int k = 0; k < angle.size(); ++k)
0029 edm::LogVerbatim("HGCSim") << "Axis[" << k << "] " << angle[k] << " with projections " << projXY_[k].first << ":"
0030 << projXY_[k].second;
0031 #endif
0032 }
0033
0034 bool HGCMouseBite::exclude(G4ThreeVector& point, int zside, int lay, int waferU, int waferV) {
0035 bool check(false);
0036 double dx(0), dy(0);
0037 if (point == G4ThreeVector()) {
0038 std::pair<double, double> xy;
0039 if (ifTB_)
0040 xy = hgTBcons_->waferPosition(waferU, false);
0041 else
0042 xy =
0043 (modeUV_ ? hgcons_->waferPosition(lay, waferU, waferV, false, false) : hgcons_->waferPosition(waferU, false));
0044 double xx = (zside > 0) ? xy.first : -xy.first;
0045 if (rot_) {
0046 dx = std::abs(point.y() - xy.second);
0047 dy = std::abs(point.x() - xx);
0048 } else {
0049 dx = std::abs(point.x() - xx);
0050 dy = std::abs(point.y() - xy.second);
0051 }
0052 } else {
0053 dx = std::abs(point.x());
0054 dy = std::abs(point.y());
0055 }
0056 for (auto proj : projXY_) {
0057 double dist = dx * proj.first + dy * proj.second;
0058 if (dist > cut_) {
0059 check = true;
0060 break;
0061 }
0062 }
0063 #ifdef EDM_ML_DEBUG
0064 edm::LogVerbatim("HGCSim") << "HGCMouseBite:: Point " << point << " zside " << zside << " wafer " << waferU << ":"
0065 << waferV << " position " << dx << ":" << dy << " check " << check;
0066 #endif
0067 return check;
0068 }