CMS 3D CMS Logo

CaloSimInfo.cc
Go to the documentation of this file.
7 
8 #include "CLHEP/Units/PhysicalConstants.h"
9 #include "CLHEP/Units/SystemOfUnits.h"
10 
11 #include <iostream>
12 
13 //#define EDM_ML_DEBUG
14 
15 namespace spr {
16 
17  double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug) {
18  GlobalPoint point = (id.det() == DetId::Hcal)
19  ? (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(id)))->getPosition(id)
20  : geo->getPosition(id);
21  double R = point.mag();
22  double tmp = R / CLHEP::c_light / CLHEP::ns;
23 #ifdef EDM_ML_DEBUG
24  if (debug) {
25  DetId::Detector det = id.det();
26  int subdet = id.subdetId();
27  double eta = point.eta();
28  double theta = 2.0 * atan(exp(-std::abs(eta)));
29  double dist = 0;
30  if (det == DetId::Ecal) {
31  if (subdet == static_cast<int>(EcalBarrel)) {
32  const double rEB = spr::rFrontEB * CLHEP::cm;
33  dist = rEB / sin(theta);
34  } else if (subdet == static_cast<int>(EcalEndcap)) {
35  const double zEE = spr::zFrontEE * CLHEP::cm;
36  dist = zEE / cos(theta);
37  } else {
38  const double zES = spr::zFrontES * CLHEP::cm;
39  dist = zES / cos(theta);
40  }
41  } else if (det == DetId::Hcal) {
42  if (subdet == static_cast<int>(HcalBarrel)) {
43  const double rHB = spr::rFrontHB * CLHEP::cm;
44  dist = rHB / sin(theta);
45  } else if (subdet == static_cast<int>(HcalEndcap)) {
46  const double zHE = spr::zFrontHE * CLHEP::cm;
47  dist = zHE / cos(theta);
48  } else if (subdet == static_cast<int>(HcalOuter)) {
49  const double rHO = spr::rFrontHO * CLHEP::cm;
50  dist = rHO / sin(theta);
51  } else {
52  const double zHF = spr::zFrontHF * CLHEP::cm;
53  dist = zHF / cos(theta);
54  }
55  }
56  double tmp1 = dist / CLHEP::c_light / CLHEP::ns;
57 
58  std::cout << "Detector " << det << "/" << subdet << " Eta/Theta " << eta << "/" << theta / CLHEP::deg << " Dist "
59  << dist / CLHEP::cm << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
60  }
61 #endif
62  return tmp;
63  }
64 
65 } // 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 zFrontHE
Definition: CaloConstants.h:13
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
static const double zFrontHF
Definition: CaloConstants.h:19
static const double rFrontHB
Definition: CaloConstants.h:14
static const double zFrontEE
Definition: CaloConstants.h:9
T mag() const
Definition: PV3DBase.h:64
static const double rFrontEB
Definition: CaloConstants.h:10
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const double zFrontES
Definition: CaloConstants.h:11
Definition: DetId.h:17
#define debug
Definition: HDRShower.cc:19
Detector
Definition: DetId.h:24
T eta() const
Definition: PV3DBase.h:73
static const double rFrontHO
Definition: CaloConstants.h:18
tmp
align.sh
Definition: createJobs.py:716
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:17
*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