CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DetIdFromEtaPhi.cc
Go to the documentation of this file.
10 
11 #include <sstream>
12 
13 namespace spr {
14 
15  const DetId findDetIdECAL(const CaloGeometry* geo, double eta, double phi, bool debug) {
16  double radius = 0;
17  int subdet = 0;
18  double theta = 2.0 * std::atan(exp(-eta));
19  if (std::abs(eta) > spr::etaBEEcal) {
20  radius = spr::zFrontEE / std::abs(std::cos(theta));
21  subdet = EcalEndcap;
22  } else {
23  radius = spr::rFrontEB / std::sin(theta);
24  subdet = EcalBarrel;
25  }
26  const CaloSubdetectorGeometry* gECAL = geo->getSubdetectorGeometry(DetId::Ecal, subdet);
27  if (debug)
28  edm::LogVerbatim("IsoTrack") << "findDetIdECAL: eta " << eta << " theta " << theta << " phi " << phi << " radius "
29  << radius << " subdet " << subdet;
30  return spr::findDetIdCalo(gECAL, theta, phi, radius, debug);
31  }
32 
33  const DetId findDetIdHCAL(const CaloGeometry* geo, double eta, double phi, bool debug) {
34  double radius = 0;
35  double theta = 2.0 * std::atan(exp(-eta));
36  if (std::abs(eta) > spr::etaBEHcal)
37  radius = spr::zFrontHE / std::abs(std::cos(theta));
38  else
39  radius = spr::rFrontHB / std::sin(theta);
41  if (debug)
42  edm::LogVerbatim("IsoTrack") << "findDetIdHCAL: eta " << eta << " theta " << theta << " phi " << phi << " radius "
43  << radius;
44  return spr::findDetIdCalo(gHCAL, theta, phi, radius, debug);
45  }
46 
47  const DetId findDetIdCalo(const CaloSubdetectorGeometry* geo, double theta, double phi, double radius, bool debug) {
48  double rcyl = radius * std::sin(theta);
49  double z = radius * std::cos(theta);
50  GlobalPoint point(rcyl * std::cos(phi), rcyl * std::sin(phi), z);
51  const DetId cell = geo->getClosestCell(point);
52  if (debug) {
53  std::ostringstream st1;
54  if (cell.det() == DetId::Ecal) {
55  if (cell.subdetId() == EcalBarrel)
56  st1 << (EBDetId)(cell);
57  else
58  st1 << (EEDetId)(cell);
59  } else {
60  st1 << (HcalDetId)(cell);
61  }
62  edm::LogVerbatim("IsoTrack") << "findDetIdCalo: rcyl " << rcyl << " z " << z << " Point " << point << " DetId "
63  << st1.str();
64  }
65  return cell;
66  }
67 
68 } // namespace spr
Log< level::Info, true > LogVerbatim
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
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
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
*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