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 
19  GlobalPoint point = (id.det() == DetId::Hcal) ?
20  (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(id)))->getPosition(id) : 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
59  << "/" << theta/CLHEP::deg << " Dist " << dist/CLHEP::cm
60  << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
61  }
62 #endif
63  return tmp;
64  }
65 
66 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
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:67
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:74
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const double zFrontES
Definition: CaloConstants.h:11
Definition: DetId.h:18
#define debug
Definition: HDRShower.cc:19
Detector
Definition: DetId.h:26
T eta() const
Definition: PV3DBase.h:76
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static const double rFrontHO
Definition: CaloConstants.h:18
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