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  }
26 #ifdef EDM_ML_DEBUG
27  if (debug) std::cout << "findDetIdECAL: eta " << eta << " theta " << theta <<" phi " << phi << " radius " << radius << " subdet " << subdet << std::endl;
28 #endif
29  return spr::findDetIdCalo (gECAL, theta, phi, radius, debug);
30  }
31 
32  const DetId findDetIdHCAL( const CaloGeometry* geo, double eta, double phi, bool debug) {
33  double radius=0;
34  double theta=2.0*std::atan(exp(-eta));
35  if (std::abs(eta) > spr::etaBEHcal)
36  radius = spr::zFrontHE/std::abs(std::cos(theta));
37  else
38  radius = spr::rFrontHB/std::sin(theta);
40  #ifdef EDM_ML_DEBUG
41  if (debug) std::cout << "findDetIdHCAL: eta " << eta <<" theta "<<theta<< " phi " << phi << " radius " << radius << std::endl;
42 #endif
43  return spr::findDetIdCalo (gHCAL, theta, phi, radius, debug);
44  }
45 
46  const DetId findDetIdCalo( const CaloSubdetectorGeometry* geo, double theta,
47  double phi, double radius, bool
48 #ifdef EDM_ML_DEBUG
49  debug
50 #endif
51  ) {
52 
53  double rcyl = radius*std::sin(theta);
54  double z = radius*std::cos(theta);
55  GlobalPoint point (rcyl*std::cos(phi),rcyl*std::sin(phi),z);
56  const DetId cell = geo->getClosestCell(point);
57 #ifdef EDM_ML_DEBUG
58  if (debug) {
59  std::cout << "findDetIdCalo: rcyl " << rcyl << " z " << z << " Point " << point << " DetId ";
60  if (cell.det() == DetId::Ecal) {
61  if (cell.subdetId() == EcalBarrel) std::cout << (EBDetId)(cell);
62  else std::cout << (EEDetId)(cell);
63  } else {
64  std::cout << (HcalDetId)(cell);
65  }
66  std::cout << std::endl;
67  }
68 #endif
69  return cell;
70  }
71 
72 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
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
#define EDM_ML_DEBUG
Definition: MPUnpacker.cc:1
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
const DetId findDetIdECAL(const CaloGeometry *geo, double eta, double phi, bool debug=false)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
virtual DetId getClosestCell(const GlobalPoint &r) const
Definition: DetId.h:18
#define debug
Definition: HDRShower.cc:19
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
*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