Go to the documentation of this file.00001 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00002 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00003 #include "Calibration/IsolatedParticles/interface/CaloSimInfo.h"
00004
00005 #include "CLHEP/Units/PhysicalConstants.h"
00006 #include "CLHEP/Units/SystemOfUnits.h"
00007
00008 #include<iostream>
00009
00010 namespace spr{
00011
00012 double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug) {
00013
00014 double R = geo->getPosition(id).mag();
00015 double tmp = R/CLHEP::c_light/CLHEP::ns;
00016 if (debug) {
00017 DetId::Detector det = id.det();
00018 int subdet = id.subdetId();
00019 double eta = geo->getPosition(id).eta();
00020 double theta = 2.0*atan(exp(-std::abs(eta)));
00021 double dist = 0;
00022 if (det == DetId::Ecal) {
00023 if (subdet == static_cast<int>(EcalBarrel)) {
00024 const double rEB = 1292*CLHEP::mm;
00025 dist = rEB/sin(theta);
00026 } else if (subdet == static_cast<int>(EcalEndcap)) {
00027 const double zEE = 3192*CLHEP::mm;
00028 dist = zEE/cos(theta);
00029 } else {
00030 const double zES = 3032*CLHEP::mm;
00031 dist = zES/cos(theta);
00032 }
00033 } else if (det == DetId::Hcal) {
00034 if (subdet == static_cast<int>(HcalBarrel)) {
00035 const double rHB = 1807*CLHEP::mm;
00036 dist = rHB/sin(theta);
00037 } else if (subdet == static_cast<int>(HcalEndcap)) {
00038 const double zHE = 4027*CLHEP::mm;
00039 dist = zHE/cos(theta);
00040 } else if (subdet == static_cast<int>(HcalOuter)) {
00041 const double rHO = 3848*CLHEP::mm;
00042 dist = rHO/sin(theta);
00043 } else {
00044 const double zHF = 11.15*CLHEP::m;
00045 dist = zHF/cos(theta);
00046 }
00047 }
00048 double tmp1 = dist/CLHEP::c_light/CLHEP::ns;
00049
00050 std::cout << "Detector " << det << "/" << subdet << " Eta/Theta " << eta
00051 << "/" << theta/CLHEP::deg << " Dist " << dist/CLHEP::cm
00052 << " R " << R << " TOF " << tmp << ":" << tmp1 << std::endl;
00053 }
00054 return tmp;
00055 }
00056
00057 }