CMS 3D CMS Logo

DetIdFromEtaPhi.cc
Go to the documentation of this file.
9 
10 //#define EDM_ML_DEBUG
11 
12 namespace spr {
13 
14  const DetId findDetIdECAL(const CaloGeometry* geo, double eta, double phi, bool debug) {
15  double radius = 0;
16  int subdet = 0;
17  double theta = 2.0 * std::atan(exp(-eta));
18  if (std::abs(eta) > spr::etaBEEcal) {
19  radius = spr::zFrontEE / std::abs(std::cos(theta));
20  subdet = EcalEndcap;
21  } else {
22  radius = spr::rFrontEB / std::sin(theta);
23  subdet = EcalBarrel;
24  }
25  const CaloSubdetectorGeometry* gECAL = geo->getSubdetectorGeometry(DetId::Ecal, subdet);
26 #ifdef EDM_ML_DEBUG
27  if (debug)
28  std::cout << "findDetIdECAL: eta " << eta << " theta " << theta << " phi " << phi << " radius " << radius
29  << " subdet " << subdet << std::endl;
30 #endif
31  return spr::findDetIdCalo(gECAL, theta, phi, radius, debug);
32  }
33 
34  const DetId findDetIdHCAL(const CaloGeometry* geo, double eta, double phi, bool debug) {
35  double radius = 0;
36  double theta = 2.0 * std::atan(exp(-eta));
37  if (std::abs(eta) > spr::etaBEHcal)
38  radius = spr::zFrontHE / std::abs(std::cos(theta));
39  else
40  radius = spr::rFrontHB / std::sin(theta);
42 #ifdef EDM_ML_DEBUG
43  if (debug)
44  std::cout << "findDetIdHCAL: eta " << eta << " theta " << theta << " phi " << phi << " radius " << radius
45  << std::endl;
46 #endif
47  return spr::findDetIdCalo(gHCAL, theta, phi, radius, debug);
48  }
49 
51  double theta,
52  double phi,
53  double radius,
54  bool
55 #ifdef EDM_ML_DEBUG
56  debug
57 #endif
58  ) {
59 
60  double rcyl = radius * std::sin(theta);
61  double z = radius * std::cos(theta);
62  GlobalPoint point(rcyl * std::cos(phi), rcyl * std::sin(phi), z);
63  const DetId cell = geo->getClosestCell(point);
64 #ifdef EDM_ML_DEBUG
65  if (debug) {
66  std::cout << "findDetIdCalo: rcyl " << rcyl << " z " << z << " Point " << point << " DetId ";
67  if (cell.det() == DetId::Ecal) {
68  if (cell.subdetId() == EcalBarrel)
69  std::cout << (EBDetId)(cell);
70  else
71  std::cout << (EEDetId)(cell);
72  } else {
73  std::cout << (HcalDetId)(cell);
74  }
75  std::cout << std::endl;
76  }
77 #endif
78  return cell;
79  }
80 
81 } // namespace spr
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
static const double etaBEEcal
Definition: CaloConstants.h:12
const DetId findDetIdCalo(const CaloSubdetectorGeometry *geo, double theta, double phi, double radius, bool debug=false)
static const double etaBEHcal
Definition: CaloConstants.h:15
static const double zFrontHE
Definition: CaloConstants.h:13
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
const DetId findDetIdHCAL(const CaloGeometry *geo, double eta, double phi, bool debug=false)
static const double rFrontHB
Definition: CaloConstants.h:14
static const double zFrontEE
Definition: CaloConstants.h:9
static const double rFrontEB
Definition: CaloConstants.h:10
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const DetId findDetIdECAL(const CaloGeometry *geo, double eta, double phi, bool debug=false)
virtual DetId getClosestCell(const GlobalPoint &r) const
Definition: DetId.h:17
#define debug
Definition: HDRShower.cc:19
#define EDM_ML_DEBUG
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46