CMS 3D CMS Logo

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 //#define EDM_ML_DEBUG
12 
13 namespace spr{
14 
15  double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug) {
16 
17  double R = geo->getPosition(id).mag();
18  double tmp = R/CLHEP::c_light/CLHEP::ns;
19 #ifdef EDM_ML_DEBUG
20  if (debug) {
21  DetId::Detector det = id.det();
22  int subdet = id.subdetId();
23  double eta = geo->getPosition(id).eta();
24  double theta = 2.0*atan(exp(-std::abs(eta)));
25  double dist = 0;
26  if (det == DetId::Ecal) {
27  if (subdet == static_cast<int>(EcalBarrel)) {
28  const double rEB = spr::rFrontEB*CLHEP::cm;
29  dist = rEB/sin(theta);
30  } else if (subdet == static_cast<int>(EcalEndcap)) {
31  const double zEE = spr::zFrontEE*CLHEP::cm;
32  dist = zEE/cos(theta);
33  } else {
34  const double zES = spr::zFrontES*CLHEP::cm;
35  dist = zES/cos(theta);
36  }
37  } else if (det == DetId::Hcal) {
38  if (subdet == static_cast<int>(HcalBarrel)) {
39  const double rHB = spr::rFrontHB*CLHEP::cm;
40  dist = rHB/sin(theta);
41  } else if (subdet == static_cast<int>(HcalEndcap)) {
42  const double zHE = spr::zFrontHE*CLHEP::cm;
43  dist = zHE/cos(theta);
44  } else if (subdet == static_cast<int>(HcalOuter)) {
45  const double rHO = spr::rFrontHO*CLHEP::cm;
46  dist = rHO/sin(theta);
47  } else {
48  const double zHF = spr::zFrontHF*CLHEP::cm;
49  dist = zHF/cos(theta);
50  }
51  }
52  double tmp1 = dist/CLHEP::c_light/CLHEP::ns;
53 
54  std::cout << "Detector " << det << "/" << subdet << " Eta/Theta " << eta
55  << "/" << theta/CLHEP::deg << " Dist " << dist/CLHEP::cm
56  << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
57  }
58 #endif
59  return tmp;
60  }
61 
62 }
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:70
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
static const double rFrontHO
Definition: CaloConstants.h:18
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:15