CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloSimInfo.cc
Go to the documentation of this file.
5 
6 #include "CLHEP/Units/PhysicalConstants.h"
7 #include "CLHEP/Units/SystemOfUnits.h"
8 
9 #include<iostream>
10 
11 namespace spr{
12 
13  double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug) {
14 
15  double R = geo->getPosition(id).mag();
16  double tmp = R/CLHEP::c_light/CLHEP::ns;
17  if (debug) {
18  DetId::Detector det = id.det();
19  int subdet = id.subdetId();
20  double eta = geo->getPosition(id).eta();
21  double theta = 2.0*atan(exp(-std::abs(eta)));
22  double dist = 0;
23  if (det == DetId::Ecal) {
24  if (subdet == static_cast<int>(EcalBarrel)) {
25  const double rEB = spr::rFrontEB*CLHEP::cm;
26  dist = rEB/sin(theta);
27  } else if (subdet == static_cast<int>(EcalEndcap)) {
28  const double zEE = spr::zFrontEE*CLHEP::cm;
29  dist = zEE/cos(theta);
30  } else {
31  const double zES = spr::zFrontES*CLHEP::cm;
32  dist = zES/cos(theta);
33  }
34  } else if (det == DetId::Hcal) {
35  if (subdet == static_cast<int>(HcalBarrel)) {
36  const double rHB = spr::rFrontHB*CLHEP::cm;
37  dist = rHB/sin(theta);
38  } else if (subdet == static_cast<int>(HcalEndcap)) {
39  const double zHE = spr::zFrontHE*CLHEP::cm;
40  dist = zHE/cos(theta);
41  } else if (subdet == static_cast<int>(HcalOuter)) {
42  const double rHO = spr::rFrontHO*CLHEP::cm;
43  dist = rHO/sin(theta);
44  } else {
45  const double zHF = spr::zFrontHF*CLHEP::cm;
46  dist = zHF/cos(theta);
47  }
48  }
49  double tmp1 = dist/CLHEP::c_light/CLHEP::ns;
50 
51  std::cout << "Detector " << det << "/" << subdet << " Eta/Theta " << eta
52  << "/" << theta/CLHEP::deg << " Dist " << dist/CLHEP::cm
53  << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
54  }
55  return tmp;
56  }
57 
58 }
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
static const double zFrontES
Definition: CaloConstants.h:11
Definition: DetId.h:18
#define debug
Definition: HDRShower.cc:19
Detector
Definition: DetId.h:24
T eta() const
Definition: PV3DBase.h:76
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:145
static const double rFrontHO
Definition: CaloConstants.h:18
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:13