CMS 3D CMS Logo

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