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.
4 
5 #include "CLHEP/Units/PhysicalConstants.h"
6 #include "CLHEP/Units/SystemOfUnits.h"
7 
8 #include<iostream>
9 
10 namespace spr{
11 
12  double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug) {
13 
14  double R = geo->getPosition(id).mag();
15  double tmp = R/CLHEP::c_light/CLHEP::ns;
16  if (debug) {
17  DetId::Detector det = id.det();
18  int subdet = id.subdetId();
19  double eta = geo->getPosition(id).eta();
20  double theta = 2.0*atan(exp(-std::abs(eta)));
21  double dist = 0;
22  if (det == DetId::Ecal) {
23  if (subdet == static_cast<int>(EcalBarrel)) {
24  const double rEB = 1292*CLHEP::mm;
25  dist = rEB/sin(theta);
26  } else if (subdet == static_cast<int>(EcalEndcap)) {
27  const double zEE = 3192*CLHEP::mm;
28  dist = zEE/cos(theta);
29  } else {
30  const double zES = 3032*CLHEP::mm;
31  dist = zES/cos(theta);
32  }
33  } else if (det == DetId::Hcal) {
34  if (subdet == static_cast<int>(HcalBarrel)) {
35  const double rHB = 1807*CLHEP::mm;
36  dist = rHB/sin(theta);
37  } else if (subdet == static_cast<int>(HcalEndcap)) {
38  const double zHE = 4027*CLHEP::mm;
39  dist = zHE/cos(theta);
40  } else if (subdet == static_cast<int>(HcalOuter)) {
41  const double rHO = 3848*CLHEP::mm;
42  dist = rHO/sin(theta);
43  } else {
44  const double zHF = 11.15*CLHEP::m;
45  dist = zHF/cos(theta);
46  }
47  }
48  double tmp1 = dist/CLHEP::c_light/CLHEP::ns;
49 
50  std::cout << "Detector " << det << "/" << subdet << " Eta/Theta " << eta
51  << "/" << theta/CLHEP::deg << " Dist " << dist/CLHEP::cm
52  << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
53  }
54  return tmp;
55  }
56 
57 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
#define abs(x)
Definition: mlp_lapack.h:159
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T eta() const
T mag() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
Definition: DetId.h:20
Detector
Definition: DetId.h:26
T eta() const
Definition: PV3DBase.h:70
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:41
#define debug
Definition: MEtoEDMFormat.h:34
double timeOfFlight(DetId id, const CaloGeometry *geo, bool debug=false)
Definition: CaloSimInfo.cc:12