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  ((HcalGeometry*)(geo->getSubdetectorGeometry(id)))->getPosition(id) :
21  geo->getPosition(id);
22  double R = point.mag();
23  double tmp = R/CLHEP::c_light/CLHEP::ns;
24 #ifdef EDM_ML_DEBUG
25  if (debug) {
26  DetId::Detector det = id.det();
27  int subdet = id.subdetId();
28  double eta = point.eta();
29  double theta = 2.0*atan(exp(-std::abs(eta)));
30  double dist = 0;
31  if (det == DetId::Ecal) {
32  if (subdet == static_cast<int>(EcalBarrel)) {
33  const double rEB = spr::rFrontEB*CLHEP::cm;
34  dist = rEB/sin(theta);
35  } else if (subdet == static_cast<int>(EcalEndcap)) {
36  const double zEE = spr::zFrontEE*CLHEP::cm;
37  dist = zEE/cos(theta);
38  } else {
39  const double zES = spr::zFrontES*CLHEP::cm;
40  dist = zES/cos(theta);
41  }
42  } else if (det == DetId::Hcal) {
43  if (subdet == static_cast<int>(HcalBarrel)) {
44  const double rHB = spr::rFrontHB*CLHEP::cm;
45  dist = rHB/sin(theta);
46  } else if (subdet == static_cast<int>(HcalEndcap)) {
47  const double zHE = spr::zFrontHE*CLHEP::cm;
48  dist = zHE/cos(theta);
49  } else if (subdet == static_cast<int>(HcalOuter)) {
50  const double rHO = spr::rFrontHO*CLHEP::cm;
51  dist = rHO/sin(theta);
52  } else {
53  const double zHF = spr::zFrontHF*CLHEP::cm;
54  dist = zHF/cos(theta);
55  }
56  }
57  double tmp1 = dist/CLHEP::c_light/CLHEP::ns;
58 
59  std::cout << "Detector " << det << "/" << subdet << " Eta/Theta " << eta
60  << "/" << theta/CLHEP::deg << " Dist " << dist/CLHEP::cm
61  << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
62  }
63 #endif
64  return tmp;
65  }
66 
67 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
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: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