CMS 3D CMS Logo

HGCalTBParameters.cc
Go to the documentation of this file.
3 
4 #include <array>
5 
6 //#define EDM_ML_DEBUG
7 
8 HGCalTBParameters::HGCalTBParameters(const std::string& nam) : name_(nam), nCells_(0) {
9 #ifdef EDM_ML_DEBUG
10  edm::LogVerbatim("HGCalGeom") << "Construct HGCalTBParameters for " << name_;
11 #endif
12 }
13 
15  if (reco) {
16  moduleLayR_.emplace_back(mytr.lay);
17  moduleBlR_.emplace_back(mytr.bl);
18  moduleTlR_.emplace_back(mytr.tl);
19  moduleHR_.emplace_back(mytr.h);
20  moduleDzR_.emplace_back(mytr.dz);
21  moduleAlphaR_.emplace_back(mytr.alpha);
22  moduleCellR_.emplace_back(mytr.cellSize);
23  } else {
24  moduleLayS_.emplace_back(mytr.lay);
25  moduleBlS_.emplace_back(mytr.bl);
26  moduleTlS_.emplace_back(mytr.tl);
27  moduleHS_.emplace_back(mytr.h);
28  moduleDzS_.emplace_back(mytr.dz);
29  moduleAlphaS_.emplace_back(mytr.alpha);
30  moduleCellS_.emplace_back(mytr.cellSize);
31  }
32 }
33 
36  if (reco) {
37  if (k < moduleLayR_.size()) {
38  mytr.lay = moduleLayR_[k];
39  mytr.bl = moduleBlR_[k];
40  mytr.tl = moduleTlR_[k];
41  mytr.h = moduleHR_[k];
42  mytr.dz = moduleDzR_[k];
43  mytr.alpha = moduleAlphaR_[k];
44  mytr.cellSize = moduleCellR_[k];
45  } else {
46  mytr.lay = -1;
47  mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0;
48  }
49  } else {
50  if (k < moduleLayS_.size()) {
51  mytr.lay = moduleLayS_[k];
52  mytr.bl = moduleBlS_[k];
53  mytr.tl = moduleTlS_[k];
54  mytr.h = moduleHS_[k];
55  mytr.dz = moduleDzS_[k];
56  mytr.alpha = moduleAlphaS_[k];
57  mytr.cellSize = moduleCellS_[k];
58  } else {
59  mytr.lay = -1;
60  mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0;
61  }
62  }
63  return mytr;
64 }
65 
67  int zp = (mytr.zp == 1) ? 1 : 0;
68  uint32_t indx = ((zp & kMaskZside) << kShiftZside);
69  indx |= ((mytr.lay & kMaskLayer) << kShiftLayer);
70  indx |= ((mytr.sec & kMaskSector) << kShiftSector);
71  indx |= ((mytr.subsec & kMaskSubSec) << kShiftSubSec);
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HGCalGeom") << "ZP " << zp << ":" << kMaskZside << ":" << kShiftZside
74  << ((zp & kMaskZside) << kShiftZside) << " Lay " << mytr.lay << ":" << kMaskLayer << ":"
75  << kShiftLayer << ":" << ((mytr.lay & kMaskLayer) << kShiftLayer) << " Sector "
76  << mytr.sec << ":" << kMaskSector << ":" << kShiftSector << ":"
77  << ((mytr.sec & kMaskSector) << kShiftSector) << " SubSec " << mytr.subsec << ":"
78  << kMaskSubSec << ":" << kShiftSubSec << ":"
79  << ((mytr.subsec & kMaskSubSec) << kShiftSubSec) << " Index " << std::hex << indx
80  << std::dec;
81 #endif
82  trformIndex_.emplace_back(indx);
83  trformTranX_.emplace_back(mytr.h3v.x());
84  trformTranY_.emplace_back(mytr.h3v.y());
85  trformTranZ_.emplace_back(mytr.h3v.z());
86  trformRotXX_.emplace_back((std::abs(mytr.hr.xx()) > tol) ? mytr.hr.xx() : 0);
87  trformRotYX_.emplace_back((std::abs(mytr.hr.yx()) > tol) ? mytr.hr.yx() : 0);
88  trformRotZX_.emplace_back((std::abs(mytr.hr.zx()) > tol) ? mytr.hr.zx() : 0);
89  trformRotXY_.emplace_back((std::abs(mytr.hr.xy()) > tol) ? mytr.hr.xy() : 0);
90  trformRotYY_.emplace_back((std::abs(mytr.hr.yy()) > tol) ? mytr.hr.yy() : 0);
91  trformRotZY_.emplace_back((std::abs(mytr.hr.zy()) > tol) ? mytr.hr.zy() : 0);
92  trformRotXZ_.emplace_back((std::abs(mytr.hr.xz()) > tol) ? mytr.hr.xz() : 0);
93  trformRotYZ_.emplace_back((std::abs(mytr.hr.yz()) > tol) ? mytr.hr.yz() : 0);
94  trformRotZZ_.emplace_back((std::abs(mytr.hr.zz()) > tol) ? mytr.hr.zz() : 0);
95 #ifdef EDM_ML_DEBUG
96  unsigned int k = trformIndex_.size() - 1;
97  edm::LogVerbatim("HGCalGeom") << "HGCalTBParameters[" << k << "] Index " << std::hex << trformIndex_[k] << std::dec
98  << " (" << mytr.zp << ", " << mytr.lay << ", " << mytr.sec << ", " << mytr.subsec
99  << ") Translation (" << trformTranX_[k] << ", " << trformTranY_[k] << ", "
100  << trformTranZ_[k] << ") Rotation (" << trformRotXX_[k] << ", " << trformRotYX_[k]
101  << ", " << trformRotZX_[k] << ", " << trformRotXY_[k] << ", " << trformRotYY_[k] << ", "
102  << trformRotZY_[k] << ", " << trformRotXZ_[k] << ", " << trformRotYZ_[k] << ", "
103  << trformRotZZ_[k];
104 #endif
105 }
106 
109  if (k < trformIndex_.size()) {
110  const auto& id = getID(k);
111  mytr.zp = id[0];
112  mytr.lay = id[1];
113  mytr.sec = id[2];
114  mytr.subsec = id[3];
115  mytr.h3v = CLHEP::Hep3Vector(trformTranX_[k], trformTranY_[k], trformTranZ_[k]);
116  const CLHEP::HepRep3x3 rotation(trformRotXX_[k],
117  trformRotXY_[k],
118  trformRotXZ_[k],
119  trformRotYX_[k],
120  trformRotYY_[k],
121  trformRotYZ_[k],
122  trformRotZX_[k],
123  trformRotZY_[k],
124  trformRotZZ_[k]);
125  mytr.hr = CLHEP::HepRotation(rotation);
126  } else {
127  mytr.zp = mytr.lay = mytr.sec = mytr.subsec = 0;
128  }
129 #ifdef EDM_ML_DEBUG
130  edm::LogVerbatim("HGCalGeom") << "HGCalTBParameters[" << k << "] Index " << std::hex << trformIndex_[k] << std::dec
131  << " (" << mytr.zp << ", " << mytr.lay << ", " << mytr.sec << ", " << mytr.subsec
132  << ") Translation (" << mytr.h3v.x() << ", " << mytr.h3v.y() << ", " << mytr.h3v.z()
133  << ") Rotation (" << mytr.hr.xx() << ", " << mytr.hr.yx() << ", " << mytr.hr.zx()
134  << ", " << mytr.hr.xy() << ", " << mytr.hr.yy() << ", " << mytr.hr.zy() << ", "
135  << mytr.hr.xz() << ", " << mytr.hr.yz() << ", " << mytr.hr.zz();
136 #endif
137  return mytr;
138 }
139 
140 void HGCalTBParameters::addTrForm(const CLHEP::Hep3Vector& h3v) {
141  unsigned int k = trformTranX_.size();
142  if (k > 0) {
143  trformTranX_[k - 1] += h3v.x();
144  trformTranY_[k - 1] += h3v.y();
145  trformTranZ_[k - 1] += h3v.z();
146  }
147 }
148 
150  unsigned int k = trformTranX_.size();
151  if (k > 0) {
152  trformTranX_[k - 1] *= scale;
153  trformTranY_[k - 1] *= scale;
154  trformTranZ_[k - 1] *= scale;
155  }
156 }
157 
158 std::array<int, 4> HGCalTBParameters::getID(unsigned int k) const {
159  int zp = ((trformIndex_[k] >> kShiftZside) & kMaskZside);
160  if (zp != 1)
161  zp = -1;
162  int lay = ((trformIndex_[k] >> kShiftLayer) & kMaskLayer);
163  int sec = ((trformIndex_[k] >> kShiftSector) & kMaskSector);
164  int subsec = ((trformIndex_[k] >> kShiftSubSec) & kMaskSubSec);
165  return std::array<int, 4>{{zp, lay, sec, subsec}};
166 }
167 
169 
std::vector< double > moduleCellR_
std::vector< double > moduleBlS_
Log< level::Info, true > LogVerbatim
static constexpr int kMaskLayer
std::vector< double > trformRotZY_
std::vector< double > moduleHS_
std::vector< double > trformRotZX_
std::vector< double > moduleTlS_
std::vector< double > trformTranX_
std::vector< int > moduleLayR_
void scaleTrForm(double)
std::vector< double > moduleHR_
static constexpr int kMaskSubSec
std::vector< double > moduleAlphaR_
std::vector< double > trformRotYZ_
hgtrform getTrForm(unsigned int k) const
std::vector< double > moduleAlphaS_
static constexpr double tol
void fillTrForm(const hgtrform &mytr)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > moduleDzR_
static constexpr int kShiftSector
static constexpr int kMaskSector
std::array< int, 4 > getID(unsigned int k) const
std::vector< double > trformTranZ_
std::vector< double > moduleBlR_
std::vector< int > moduleLayS_
std::vector< double > trformRotXX_
void fillModule(const hgtrap &mytr, bool reco)
std::vector< double > trformRotYX_
std::vector< double > trformRotZZ_
std::vector< double > trformRotYY_
void addTrForm(const CLHEP::Hep3Vector &h3v)
std::vector< double > trformTranY_
std::vector< uint32_t > trformIndex_
static constexpr int kShiftLayer
fixed size matrix
static constexpr int kShiftSubSec
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
std::vector< double > trformRotXY_
static constexpr int kShiftZside
std::vector< double > moduleTlR_
HGCalTBParameters(const std::string &nam)
std::vector< double > trformRotXZ_
static constexpr int kMaskZside
std::vector< double > moduleDzS_
std::vector< double > moduleCellS_
hgtrap getModule(unsigned int k, bool reco) const