CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalNumberingFromPS.cc
Go to the documentation of this file.
1 // to make hits in EB/EE/HC
5 
6 #include <cmath>
7 #include <iostream>
8 #include <iomanip>
9 
10 //#define EDM_ML_DEBUG
11 using namespace geant_units::operators;
12 
14  etaTable_ = conf.getParameter<std::vector<double> >("EtaTable");
15  phibin_ = conf.getParameter<std::vector<double> >("PhiBin");
16  phioff_ = conf.getParameter<std::vector<double> >("PhiOffset");
17  etaMin_ = conf.getParameter<std::vector<int> >("EtaMin");
18  etaMax_ = conf.getParameter<std::vector<int> >("EtaMax");
19  etaHBHE_ = conf.getParameter<int>("EtaHBHE");
20  depthHBHE_ = conf.getParameter<std::vector<int> >("DepthHBHE");
21  depth29Mx_ = conf.getParameter<int>("Depth29Max");
22  rMinHO_ = conf.getParameter<double>("RMinHO");
23  zHO_ = conf.getParameter<std::vector<double> >("ZHO");
24  const double deg = M_PI / 180.0;
25  for (auto& phi : phibin_)
26  phi *= deg;
27  for (auto& phi : phioff_)
28  phi *= deg;
29 #ifdef EDM_ML_DEBUG
30  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: EtaTable with " << etaTable_.size() << " elements";
31  for (unsigned k = 0; k < etaTable_.size(); ++k)
32  edm::LogVerbatim("HcalSim") << "EtaTable[" << k << "] = " << etaTable_[k];
33  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: PhiBin with " << phibin_.size() << " elements";
34  for (unsigned k = 0; k < phibin_.size(); ++k)
35  edm::LogVerbatim("HcalSim") << "PhiBin[" << k << "] = " << phibin_[k];
36  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: PhiOff with " << phioff_.size() << " elements";
37  for (unsigned k = 0; k < phioff_.size(); ++k)
38  edm::LogVerbatim("HcalSim") << "PhiOff[" << k << "] = " << phioff_[k];
39  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: EtaMin/EtaMax with " << etaMin_.size() << ":" << etaMax_.size()
40  << " elements";
41  for (unsigned k = 0; k < etaMin_.size(); ++k)
42  edm::LogVerbatim("HcalSim") << "EtaMin[" << k << "] = " << etaMin_[k] << " EtaMax[" << k << "] = " << etaMax_[k];
43  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: EtaHBHE " << etaHBHE_ << " DepthHBHE " << depthHBHE_[0] << ":"
44  << depthHBHE_[1] << " RMinHO " << rMinHO_ << " zHO with " << zHO_.size() << " elements";
45  for (unsigned k = 0; k < zHO_.size(); ++k)
46  edm::LogVerbatim("HcalSim") << "ZHO[" << k << "] = " << zHO_[k];
47 #endif
48 
49  segmentation_.resize(nEtas_);
50  for (int ring = 0; ring < nEtas_; ++ring) {
51  char name[10];
52  snprintf(name, 10, "Eta%d", ring + 1);
53  if (ring > 0) {
54  segmentation_[ring] = conf.getUntrackedParameter<std::vector<int> >(name, segmentation_[ring - 1]);
55  } else {
56  segmentation_[ring] = conf.getUntrackedParameter<std::vector<int> >(name);
57  }
58 #ifdef EDM_ML_DEBUG
59  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: Ring " << ring + 1 << " with " << segmentation_[ring].size()
60  << " layers";
61  for (unsigned int k = 0; k < segmentation_[ring].size(); ++k)
62  edm::LogVerbatim("HcalSim") << "Layer[" << k << "] = " << segmentation_[ring][k];
63 #endif
64  }
65 }
66 
68  int layer,
69  int depth,
70  const math::XYZVectorD& pos) const {
71  int subdet = ((det == 3) ? static_cast<int>(HcalBarrel) : static_cast<int>(HcalEndcap));
72  std::pair<int, int> deteta = getEta(subdet, pos);
73  std::pair<int, int> iphi = getPhi(deteta.first, deteta.second, pos.Phi());
74  int newDepth(depth);
75  int zside = ((pos.z() > 0) ? 1 : 0);
76  if (deteta.first == static_cast<int>(HcalBarrel)) {
77  newDepth = segmentation_[deteta.second - 1][layer - 1];
78  if ((deteta.second == etaHBHE_) && (newDepth > depthHBHE_[0]))
79  newDepth = depthHBHE_[0];
80  } else if (deteta.first == static_cast<int>(HcalEndcap)) {
81  newDepth = segmentation_[deteta.second - 1][layer - 1];
82  if ((deteta.second == etaHBHE_) && (newDepth < depthHBHE_[1]))
83  newDepth = depthHBHE_[1];
84  if ((deteta.second == etaMax_[1]) && (newDepth > depth29Mx_))
85  --(deteta.second);
86  } else if (deteta.first == static_cast<int>(HcalOuter)) {
87  newDepth = 4;
88  }
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: det " << det << ":" << subdet << ":" << deteta.first
91  << "\t Eta " << pos.Eta() << ":" << deteta.second << "\t Phi " << pos.Phi() << ":"
92  << iphi.first << ":" << iphi.second << "\t Layer|Depth " << layer << ":" << depth << ":"
93  << newDepth;
94 #endif
95  return HcalNumberingFromDDD::HcalID(deteta.first, zside, newDepth, deteta.second, iphi.first, iphi.second, layer);
96 }
97 
98 std::pair<int, int> HcalNumberingFromPS::getEta(const int& det, const math::XYZVectorD& pos) const {
99  int ieta(1);
100  int subdet(det);
101  double eta = std::abs(pos.Eta());
102  if (pos.Rho() > rMinHO_) {
103  subdet = static_cast<int>(HcalOuter);
104  double z = std::abs(pos.z());
105  if (z > zHO_[3]) {
106  if (eta <= etaTable_[10])
107  eta = etaTable_[10] + 0.001;
108  } else if (z > zHO_[1]) {
109  if (eta <= etaTable_[4])
110  eta = etaTable_[4] + 0.001;
111  }
112  }
113  for (unsigned int i = 1; i < etaTable_.size(); i++) {
114  if (eta < etaTable_[i]) {
115  ieta = i;
116  break;
117  }
118  }
119 
120  if ((subdet == static_cast<int>(HcalBarrel)) || (subdet == static_cast<int>(HcalOuter))) {
121  if (ieta > etaMax_[0])
122  ieta = etaMax_[0];
123  } else if (det == static_cast<int>(HcalEndcap)) {
124  if (ieta <= etaMin_[1])
125  ieta = etaMin_[1];
126  }
127  return std::make_pair(subdet, ieta);
128 }
129 
130 std::pair<int, int> HcalNumberingFromPS::getPhi(const int& det, const int& ieta, const double& phi) const {
131  double fioff = ((det == static_cast<int>(HcalEndcap)) ? phioff_[1] : phioff_[0]);
132  double fibin = phibin_[ieta - 1];
133  int nphi = int((2._pi + 0.1 * fibin) / fibin);
134  double hphi = phi + fioff;
135  if (hphi < 0)
136  hphi += (2._pi);
137  int iphi = int(hphi / fibin) + 1;
138  if (iphi > nphi)
139  iphi = 1;
140  const double fiveDegInRad = 5._deg;
141  int units = int(fibin / fiveDegInRad + 0.5);
142  if (units < 1)
143  units = 1;
144  int iphi_skip = iphi;
145  if (units == 2)
146  iphi_skip = (iphi - 1) * 2 + 1;
147  else if (units == 4)
148  iphi_skip = (iphi - 1) * 4 - 1;
149  if (iphi_skip < 0)
150  iphi_skip += 72;
151  return std::make_pair(iphi, iphi_skip);
152 }
Log< level::Info, true > LogVerbatim
const int nphi
T getUntrackedParameter(std::string const &, T const &) const
HcalNumberingFromDDD::HcalID unitID(int det, int layer, int depth, const math::XYZVectorD &pos) const
int zside(DetId const &)
etaMax_(conf.getParameter< double >("etaMax"))
std::pair< int, int > getPhi(const int &det, const int &ieta, const double &phi) const
constexpr std::array< uint8_t, layerIndexSize > layer
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deteta(const Fourvec &v, double zvert)
NOT USED ANYMORE: Get the detector (D0-specific), requires z-vertex.
Definition: fourvec.cc:205
#define M_PI
HcalNumberingFromPS(const edm::ParameterSet &)
std::pair< int, int > getEta(const int &det, const math::XYZVectorD &pos) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TString units(TString variable, Char_t axis)
etaMin_(conf.getParameter< double >("etaMin"))