CMS 3D CMS Logo

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) {
21  subdet = EcalEndcap;
22  } else {
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));
38  else
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
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
const DetId findDetIdHCAL(const CaloGeometry *geo, double eta, double phi, bool debug=false)
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
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
Abs< T >::type abs(const T &t)
Definition: Abs.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
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
Geom::Theta< T > theta() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
*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