CMS 3D CMS Logo

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