Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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/GlobalSystemOfUnits.h"
0005 #include <iostream>
0006 
0007 //#define EDM_ML_DEBUG
0008 
0009 HGCMouseBite::HGCMouseBite(const HGCalDDDConstants& hgc, const std::vector<double>& angle, double maxL, bool rot)
0010     : hgcons_(hgc), cut_(maxL), rot_(rot) {
0011   modeUV_ = hgcons_.waferHexagon8();
0012   for (auto ang : angle) {
0013     projXY_.push_back(std::pair<double, double>(cos(ang * CLHEP::deg), sin(ang * CLHEP::deg)));
0014   }
0015 #ifdef EDM_ML_DEBUG
0016   edm::LogVerbatim("HGCSim") << "Creating HGCMosueBite with cut at " << cut_ << " with mode " << modeUV_ << " along "
0017                              << angle.size() << " axes";
0018   for (unsigned int k = 0; k < angle.size(); ++k)
0019     edm::LogVerbatim("HGCSim") << "Axis[" << k << "] " << angle[k] << " with projections " << projXY_[k].first << ":"
0020                                << projXY_[k].second;
0021 #endif
0022 }
0023 
0024 bool HGCMouseBite::exclude(G4ThreeVector& point, int zside, int waferU, int waferV) {
0025   bool check(false);
0026   int lay = hgcons_.getLayer(point.z(), false);
0027   std::pair<double, double> xy =
0028       (modeUV_ ? hgcons_.waferPosition(lay, waferU, waferV, false) : hgcons_.waferPosition(waferU, false));
0029   double xx = (zside > 0) ? xy.first : -xy.first;
0030   double dx(0), dy(0);
0031   if (rot_) {
0032     dx = std::abs(point.y() - xy.second);
0033     dy = std::abs(point.x() - xx);
0034   } else {
0035     dx = std::abs(point.x() - xx);
0036     dy = std::abs(point.y() - xy.second);
0037   }
0038   for (auto proj : projXY_) {
0039     double dist = dx * proj.first + dy * proj.second;
0040     if (dist > cut_) {
0041       check = true;
0042       break;
0043     }
0044   }
0045 #ifdef EDM_ML_DEBUG
0046   edm::LogVerbatim("HGCSim") << "HGCMouseBite:: Point " << point << " zside " << zside << " wafer " << waferU << ":"
0047                              << waferV << " position " << xy.first << ":" << xx << ":" << xy.second << " dxy " << dx
0048                              << ":" << dy << " check " << check;
0049 #endif
0050   return check;
0051 }