CMS 3D CMS Logo

HGCalParameters.cc
Go to the documentation of this file.
4 //#define EDM_ML_DEBUG
5 
7 #ifdef EDM_ML_DEBUG
8  edm::LogVerbatim("HGCalGeom") << "Construct HGCalParameters for " << name_;
9 #endif
10  }
11 
13 
15  bool reco) {
16 
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 
71  int zp = (mytr.zp == 1) ? 1 : 0;
72  uint32_t indx = ((zp & kMaskZside) << kShiftZside);
73  indx |= ((mytr.lay & kMaskLayer) << kShiftLayer);
74  indx |= ((mytr.sec & kMaskSector) << kShiftSector);
75  indx |= ((mytr.subsec & kMaskSubSec) << kShiftSubSec);
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("HGCalGeom") << "ZP " << zp << ":" << kMaskZside << ":"
78  << kShiftZside
79  << ((zp & kMaskZside) << kShiftZside)
80  << " Lay " << mytr.lay << ":" << kMaskLayer
81  << ":" << kShiftLayer << ":"
82  << ((mytr.lay & kMaskLayer) << kShiftLayer)
83  << " Sector " << mytr.sec << ":"
84  << kMaskSector << ":" << kShiftSector << ":"
85  << ((mytr.sec & kMaskSector) << kShiftSector)
86  << " SubSec " << mytr.subsec << ":"
87  << kMaskSubSec << ":" << kShiftSubSec << ":"
88  <<((mytr.subsec & kMaskSubSec) << kShiftSubSec)
89  << " Index " << std::hex << indx << std::dec;
90 #endif
91  trformIndex_.emplace_back(indx);
92  trformTranX_.emplace_back(mytr.h3v.x());
93  trformTranY_.emplace_back(mytr.h3v.y());
94  trformTranZ_.emplace_back(mytr.h3v.z());
95  trformRotXX_.emplace_back(mytr.hr.xx());
96  trformRotYX_.emplace_back(mytr.hr.yx());
97  trformRotZX_.emplace_back(mytr.hr.zx());
98  trformRotXY_.emplace_back(mytr.hr.xy());
99  trformRotYY_.emplace_back(mytr.hr.yy());
100  trformRotZY_.emplace_back(mytr.hr.zy());
101  trformRotXZ_.emplace_back(mytr.hr.xz());
102  trformRotYZ_.emplace_back(mytr.hr.yz());
103  trformRotZZ_.emplace_back(mytr.hr.zz());
104 #ifdef EDM_ML_DEBUG
105  unsigned int k = trformIndex_.size() - 1;
106  edm::LogVerbatim("HGCalGeom") << "HGCalParameters[" << k << "] Index "
107  << std::hex << trformIndex_[k] << std::dec
108  << " (" << mytr.zp << ", "<< mytr.lay
109  << ", " << mytr.sec << ", " << mytr.subsec
110  << ") Translation (" << trformTranX_[k] << ", "
111  << trformTranY_[k] << ", " << trformTranZ_[k]
112  << ") Rotation (" << trformRotXX_[k] << ", "
113  << trformRotYX_[k] << ", " << trformRotZX_[k]
114  << ", " << trformRotXY_[k] << ", "
115  << trformRotYY_[k] << ", " << trformRotZY_[k]
116  << ", " << trformRotXZ_[k] << ", "
117  << trformRotYZ_[k] << ", " << trformRotZZ_[k];
118 #endif
119 }
120 
122 
124  if (k < trformIndex_.size()) {
125  const auto & id = getID(k);
126  mytr.zp = id[0];
127  mytr.lay = id[1];
128  mytr.sec = id[2];
129  mytr.subsec= id[3];
130  mytr.h3v = CLHEP::Hep3Vector(trformTranX_[k],trformTranY_[k],trformTranZ_[k]);
131  const CLHEP::HepRep3x3 rotation(trformRotXX_[k],trformRotXY_[k],trformRotXZ_[k],
134  mytr.hr = CLHEP::HepRotation(rotation);
135  } else {
136  mytr.zp = mytr.lay = mytr.sec = mytr.subsec = 0;
137  }
138 #ifdef EDM_ML_DEBUG
139  edm::LogVerbatim("HGCalGeom") << "HGCalParameters[" << k << "] Index "
140  << std::hex << trformIndex_[k] << std::dec
141  << " (" << mytr.zp << ", "<< mytr.lay
142  << ", " << mytr.sec << ", " << mytr.subsec
143  << ") Translation (" << mytr.h3v.x() << ", "
144  << mytr.h3v.y() << ", " << mytr.h3v.z()
145  << ") Rotation (" << mytr.hr.xx() << ", "
146  << mytr.hr.yx() << ", " << mytr.hr.zx() << ", "
147  << mytr.hr.xy() << ", " << mytr.hr.yy()
148  << ", " << mytr.hr.zy() << ", " << mytr.hr.xz()
149  << ", " << mytr.hr.yz() <<", " << mytr.hr.zz();
150 #endif
151  return mytr;
152 }
153 
154 void HGCalParameters::addTrForm(const CLHEP::Hep3Vector& h3v) {
155 
156  unsigned int k = trformTranX_.size();
157  if (k > 0) {
158  trformTranX_[k-1] += h3v.x();
159  trformTranY_[k-1] += h3v.y();
160  trformTranZ_[k-1] += h3v.z();
161  }
162 }
163 
165  unsigned int k = trformTranX_.size();
166  if (k > 0) {
167  trformTranX_[k-1] *= scale;
168  trformTranY_[k-1] *= scale;
169  trformTranZ_[k-1] *= scale;
170  }
171 }
172 
173 std::array<int,4> HGCalParameters::getID(unsigned int k) const {
174 
175  int zp = ((trformIndex_[k] >> kShiftZside) & kMaskZside);
176  if (zp != 1) zp = -1;
177  int lay = ((trformIndex_[k] >> kShiftLayer) & kMaskLayer);
178  int sec = ((trformIndex_[k] >> kShiftSector) & kMaskSector);
179  int subsec = ((trformIndex_[k] >> kShiftSubSec) & kMaskSubSec);
180  return std::array<int,4>{ {zp,lay,sec,subsec} };
181 }
182 
184 
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:96
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