CMS 3D CMS Logo

HFFibre.cc
Go to the documentation of this file.
1 // File: HFFibre.cc
3 // Description: Loads the table for attenuation length and calculates it
5 
8 
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 #include "CLHEP/Units/GlobalPhysicalConstants.h"
11 #include <iostream>
12 #include <sstream>
13 
14 //#define EDM_ML_DEBUG
15 HFFibre::Params::Params(double iFractionOfSpeedOfLightInFibre,
16  const HcalDDDSimConstants* hcons,
17  const HcalSimulationParameters* hps)
18  : fractionOfSpeedOfLightInFibre_{iFractionOfSpeedOfLightInFibre},
19  gParHF_{hcons->getGparHF()},
20  rTableHF_{hcons->getRTableHF()},
21  shortFibreLength_{hps->shortFiberLength_},
22  longFibreLength_{hps->longFiberLength_},
23  attenuationLength_{hps->attenuationLength_},
24  lambdaLimits_{{static_cast<double>(hps->lambdaLimits_[0]), static_cast<double>(hps->lambdaLimits_[1])}} {}
25 
27  : HFFibre(Params(p.getParameter<edm::ParameterSet>("HFShower")
28  .getParameter<edm::ParameterSet>("HFShowerBlock")
29  .getParameter<double>("CFibre"),
30  hcons,
31  hps)) {}
32 
34  : cFibre_(c_light * iP.fractionOfSpeedOfLightInFibre_),
35  gpar_(std::move(iP.gParHF_)),
36  radius_(std::move(iP.rTableHF_)),
37  shortFL_(std::move(iP.shortFibreLength_)),
38  longFL_(std::move(iP.longFibreLength_)),
39  attL_(std::move(iP.attenuationLength_)),
40  lambLim_(iP.lambdaLimits_) {
41  edm::LogVerbatim("HFShower") << "HFFibre:: Speed of light in fibre " << cFibre_ / (CLHEP::m / CLHEP::ns) << " m/ns";
42  // Attenuation length
43  nBinAtt_ = static_cast<int>(attL_.size());
44 
45  edm::LogVerbatim("HFShower").log([&](auto& logger) {
46  logger << "HFFibre: " << nBinAtt_ << " attL(1/cm): ";
47  for (int it = 0; it < nBinAtt_; it++) {
48  if (it / 10 * 10 == it) {
49  logger << "\n";
50  }
51  logger << " " << attL_[it] * CLHEP::cm;
52  }
53  });
54  edm::LogVerbatim("HFShower") << "HFFibre: Limits on lambda " << lambLim_[0] << " and " << lambLim_[1];
55  // Fibre Lengths
56  edm::LogVerbatim("HFShower").log([&](auto& logger) {
57  logger << "HFFibre: " << longFL_.size() << " Long Fibre Length(cm):";
58  for (unsigned int it = 0; it < longFL_.size(); it++) {
59  if (it / 10 * 10 == it) {
60  logger << "\n";
61  }
62  logger << " " << longFL_[it] / CLHEP::cm;
63  }
64  });
65  edm::LogVerbatim("HFShower").log([&](auto& logger) {
66  logger << "HFFibre: " << shortFL_.size() << " Short Fibre Length(cm):";
67  for (unsigned int it = 0; it < shortFL_.size(); it++) {
68  if (it / 10 * 10 == it) {
69  logger << "\n";
70  }
71  logger << " " << shortFL_[it] / CLHEP::cm;
72  }
73  });
74  // Now geometry parameters
75 
76  nBinR_ = static_cast<int>(radius_.size());
77  edm::LogVerbatim("HFShower").log([&](auto& logger) {
78  logger << "HFFibre: " << radius_.size() << " rTable(cm):";
79  for (int i = 0; i < nBinR_; ++i) {
80  if (i / 10 * 10 == i) {
81  logger << "\n";
82  }
83  logger << " " << radius_[i] / CLHEP::cm;
84  }
85  });
86 
87  edm::LogVerbatim("HFShower").log([&](auto& logger) {
88  logger << "HFFibre: " << gpar_.size() << " gParHF:";
89  for (std::size_t i = 0; i < gpar_.size(); ++i) {
90  if (i / 10 * 10 == i) {
91  logger << "\n";
92  }
93  logger << " " << gpar_[i];
94  }
95  });
96 }
97 
98 double HFFibre::attLength(double lambda) const {
99  int i = int(nBinAtt_ * (lambda - lambLim_[0]) / (lambLim_[1] - lambLim_[0]));
100 
101  int j = i;
102  if (i >= nBinAtt_)
103  j = nBinAtt_ - 1;
104  else if (i < 0)
105  j = 0;
106  double att = attL_[j];
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("HFShower") << "HFFibre::attLength for Lambda " << lambda << " index " << i << " " << j
109  << " Att. Length " << att;
110 #endif
111  return att;
112 }
113 
114 double HFFibre::tShift(const G4ThreeVector& point, int depth, int fromEndAbs) const {
115  double zFibre = zShift(point, depth, fromEndAbs);
116  double time = zFibre / cFibre_;
117 #ifdef EDM_ML_DEBUG
118  edm::LogVerbatim("HFShower") << "HFFibre::tShift for point " << point << " ( depth = " << depth
119  << ", traversed length = " << zFibre / CLHEP::cm << " cm) = " << time / CLHEP::ns
120  << " ns";
121 #endif
122  return time;
123 }
124 
125 double HFFibre::zShift(const G4ThreeVector& point, int depth, int fromEndAbs) const { // point is z-local
126 
127  double zFibre = 0;
128  int ieta = 0;
129  double length = 250 * CLHEP::cm;
130  double hR = sqrt((point.x()) * (point.x()) + (point.y()) * (point.y()));
131 
132  // Defines the Radius bin by radial subdivision
133  if (fromEndAbs >= 0) {
134  for (int i = nBinR_ - 1; i > 0; --i)
135  if (hR < radius_[i])
136  ieta = nBinR_ - i - 1;
137  }
138 
139  // Defines the full length of the fibre
140  if (depth == 2) {
141  if (static_cast<int>(shortFL_.size()) > ieta)
142  length = shortFL_[ieta] + gpar_[0];
143  } else {
144  if (static_cast<int>(longFL_.size()) > ieta)
145  length = longFL_[ieta];
146  }
147  zFibre = length; // from beginning of abs (full length)
148 
149  if (fromEndAbs > 0) {
150  zFibre -= gpar_[1]; // length from end of HF
151  } else {
152  double zz = 0.5 * gpar_[1] + point.z(); // depth of point of photon emission (from beginning of HF)
153  zFibre -= zz; // length of fiber from point of photon emission
154  }
155 
156 #ifdef EDM_ML_DEBUG
157  edm::LogVerbatim("HFShower") << "HFFibre::zShift for point " << point << " (R = " << hR / CLHEP::cm
158  << " cm, Index = " << ieta << ", depth = " << depth
159  << ", Fibre Length = " << length / CLHEP::cm << " cm = " << zFibre / CLHEP::cm << " cm)";
160 #endif
161  return zFibre;
162 }
std::vector< double > radius_
Definition: HFFibre.h:46
std::vector< double > shortFL_
Definition: HFFibre.h:47
Log< level::Info, true > LogVerbatim
double zShift(const G4ThreeVector &point, int depth, int fromEndAbs=0) const
Definition: HFFibre.cc:125
std::vector< double > longFL_
Definition: HFFibre.h:47
Params()=default
int nBinR_
Definition: HFFibre.h:49
HFFibre(const HcalDDDSimConstants *hcons, const HcalSimulationParameters *hps, edm::ParameterSet const &p)
Definition: HFFibre.cc:26
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< double > gpar_
Definition: HFFibre.h:46
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0) const
Definition: HFFibre.cc:114
Definition: logger.py:1
double cFibre_
Definition: HFFibre.h:45
HLT enums.
int nBinAtt_
Definition: HFFibre.h:49
std::vector< double > attL_
Definition: HFFibre.h:48
std::array< double, 2 > lambLim_
Definition: HFFibre.h:50
def move(src, dest)
Definition: eostools.py:511
*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
double attLength(double lambda) const
Definition: HFFibre.cc:98