CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCalDDDConstants.cc
Go to the documentation of this file.
2 
6 
12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
15 //#define DebugLog
16 
19 
21  const std::string name) : hgpar_(hp) {
24  rmax_ = 0;
25 
26  for( int simreco = 0; simreco < 2; ++simreco ) {
27  tot_layers_[simreco] = layersInit((bool)simreco);
28  }
29 
30  edm::LogInfo("HGCalGeom") << "HGCalDDDConstants initialized for " << name
31  << " with " << layers(false) << ":" <<layers(true)
32  << " layers, " << sectors() << " sectors and "
33  << "maximum of " << maxCells(false) << ":"
34  << maxCells(true) << " cells";
35 #ifdef DebugLog
36  std::cout << "HGCalDDDConstants initialized for " << name << " with "
37  << layers(false) << ":" << layers(true) << " layers, "
38  << sectors() << " sectors and maximum of " << maxCells(false)
39  << ":" << maxCells(true) << " cells" << std::endl;
40 #endif
41  } else {
42  rmax_ = k_ScaleFromDDD * (hgpar_->waferR_) * std::cos(30.0*CLHEP::deg);
43 
44  // init maps and constants
45  for( int simreco = 0; simreco < 2; ++simreco ) {
46  tot_layers_[simreco] = layersInit((bool)simreco);
47  max_modules_layer_[simreco].resize(tot_layers_[simreco]+1);
48  for( unsigned int layer = 1; layer <= tot_layers_[simreco]; ++layer ) {
49  max_modules_layer_[simreco][layer] = modulesInit(layer,(bool)simreco);
50  }
51  }
52  tot_wafers_ = wafers();
53 
54  edm::LogInfo("HGCalGeom") << "HGCalDDDConstants initialized for " << name
55  << " with " << layers(false) << ":" <<layers(true)
56  << " layers, " << wafers() << " wafers and "
57  << "maximum of " << maxCells(false) << ":"
58  << maxCells(true) << " cells";
59 
60 #ifdef DebugLog
61  std::cout << "HGCalDDDConstants initialized for " << name << " with "
62  << layers(false) << ":" << layers(true) << " layers, "
63  << wafers() << " wafers and " << "maximum of " << maxCells(false)
64  << ":" << maxCells(true) << " cells" << std::endl;
65 #endif
66 
67  }
68 
69 }
70 
72 
73 std::pair<int,int> HGCalDDDConstants::assignCell(float x, float y, int lay,
74  int subSec, bool reco) const {
75  std::pair<int,float> index = getIndex(lay, reco);
76  std::pair<int,int> cellAssignment(-1,-1);
77  int i = index.first;
78  if (i < 0) return cellAssignment;
80  float alpha, h, bl, tl;
81  getParameterSquare(i,subSec,reco,h,bl,tl,alpha);
82  cellAssignment = assignCellSquare(x, y, h, bl, tl, alpha, index.second);
83  } else {
84  float xx = (reco) ? x : k_ScaleFromDDD*x;
85  float yy = (reco) ? y : k_ScaleFromDDD*y;
86  cellAssignment = assignCellHexagon(xx,yy);
87  }
88  return cellAssignment;
89 }
90 
91 std::pair<int,int> HGCalDDDConstants::assignCellSquare(float x, float y,
92  float h, float bl,
93  float tl, float alpha,
94  float cellSize) const {
95 
96  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
97  float b = 2*h*bl/(tl-bl);
98 
99  float x0(x);
100  int phiSector = (x0 > 0) ? 1 : 0;
101  if (alpha < 0) {x0 -= 0.5*(tl+bl); phiSector = 0;}
102  else if (alpha > 0) {x0 += 0.5*(tl+bl); phiSector = 1;}
103 
104  //determine the i-y
105  int ky = floor((y+h)/cellSize);
106  if (ky*cellSize> y+h) ky--;
107  if (ky<0) return std::pair<int,int>(-1,-1);
108  if ((ky+1)*cellSize < (y+h) ) ky++;
109  int max_ky_allowed=floor(2*h/cellSize);
110  if (ky>max_ky_allowed-1) return std::pair<int,int>(-1,-1);
111 
112  //determine the i-x
113  //notice we substitute y by the top of the candidate cell to reduce the dead zones
114  int kx = floor(fabs(x0)/cellSize);
115  if (kx*cellSize > fabs(x0) ) kx--;
116  if (kx<0) return std::pair<int,int>(-1,-1);
117  if ((kx+1)*cellSize < fabs(x0)) kx++;
118  int max_kx_allowed=floor( ((ky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize) );
119  if (kx>max_kx_allowed-1) return std::pair<int,int>(-1,-1);
120 
121  //count cells summing in rows until required height
122  //notice the bottom of the cell must be used
123  int icell(0);
124  for (int iky=0; iky<ky; ++iky) {
125  int cellsInRow( floor( ((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize) ) );
126  icell += cellsInRow;
127  }
128  icell += kx;
129 
130  //return result
131  return std::pair<int,int>(phiSector,icell);
132 }
133 
134 std::pair<int,int> HGCalDDDConstants::assignCellHexagon(float x,
135  float y) const {
136  double xx(x), yy(y);
137  //First the wafer
138  int wafer = cellHex(xx, yy, rmax_, hgpar_->waferPosX_, hgpar_->waferPosY_);
139  // Now the cell
140  xx -= hgpar_->waferPosX_[wafer];
141  yy -= hgpar_->waferPosY_[wafer];
142  int cell(0);
143  if (hgpar_->waferTypeT_[wafer] == 1)
145  else
147  return std::pair<int,int>(wafer,cell);
148 }
149 
151  int indx = (type == 1) ? 0 : 1;
152  double cell = (0.5*k_ScaleFromDDD*hgpar_->cellSize_[indx]);
153  return cell;
154 }
155 
156 unsigned int HGCalDDDConstants::layers(bool reco) const {
157  return tot_layers_[(int)reco];
158 }
159 
160 unsigned int HGCalDDDConstants::layersInit(bool reco) const {
161  return (reco ? hgpar_->depthIndex_.size() : hgpar_->layerIndex_.size());
162 }
163 
164 std::pair<int,int> HGCalDDDConstants::findCell(int cell, int lay, int subSec,
165  bool reco) const {
166 
167  std::pair<int,float> index = getIndex(lay, reco);
168  int i = index.first;
169  if (i < 0) return std::pair<int,int>(-1,-1);
171  return std::pair<int,int>(-1,-1);
172  } else {
173  float alpha, h, bl, tl;
174  getParameterSquare(i,subSec,reco,h,bl,tl,alpha);
175  return findCellSquare(cell, h, bl, tl, alpha, index.second);
176  }
177 }
178 
179 std::pair<int,int> HGCalDDDConstants::findCellSquare(int cell, float h,
180  float bl, float tl,
181  float alpha,
182  float cellSize) const {
183 
184  //check if cell number is meaningful
185  if(cell<0) return std::pair<int,int>(-1,-1);
186 
187  //parameterization of the boundary of the trapezoid
188  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
189  float b = 2*h*bl/(tl-bl);
190  int kx(cell), ky(0);
191  int kymax( floor((2*h)/cellSize) );
192  int testCell(0);
193  for (int iky=0; iky<kymax; ++iky) {
194 
195  //check if adding all the cells in this row is above the required cell
196  //notice the top of the cell is used to maximize space
197  int cellsInRow(floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize)));
198  if (testCell+cellsInRow > cell) break;
199  testCell += cellsInRow;
200  ky++;
201  kx -= cellsInRow;
202  }
203 
204  return std::pair<int,int>(kx,ky);
205 }
206 
208  bool hexType,
209  bool reco) const {
210 
212  if (hexType) {
213  unsigned int type = (indx < hgpar_->waferTypeL_.size()) ?
214  hgpar_->waferTypeL_[indx] : 3;
215  if (type > 0) --type;
216  mytr = hgpar_->getModule(type, true);
217  } else {
218  if (reco) mytr = hgpar_->getModule(indx,true);
219  else mytr = hgpar_->getModule(indx,false);
220  }
221  return mytr;
222 }
223 
224 std::vector<HGCalParameters::hgtrap> HGCalDDDConstants::getModules() const {
225 
226  std::vector<HGCalParameters::hgtrap> mytrs;
227  for (unsigned int k=0; k<hgpar_->moduleLayR_.size(); ++k)
228  mytrs.push_back(hgpar_->getModule(k,true));
229  return mytrs;
230 }
231 
232 std::vector<HGCalParameters::hgtrform> HGCalDDDConstants::getTrForms() const {
233 
234  std::vector<HGCalParameters::hgtrform> mytrs;
235  for (unsigned int k=0; k<hgpar_->trformIndex_.size(); ++k)
236  mytrs.push_back(hgpar_->getTrForm(k));
237  return mytrs;
238 }
239 
240 bool HGCalDDDConstants::isValid(int lay, int mod, int cell, bool reco) const {
241 
242  bool ok(false);
243  int cellmax(0), modmax(0);
245  cellmax = maxCells(lay,reco);
246  modmax = sectors();
247  ok = ((lay > 0 && lay <= (int)(layers(reco))) &&
248  (mod > 0 && mod <= modmax) &&
249  (cell >=0 && cell <= cellmax));
250  } else {
251  int32_t copyNumber = hgpar_->waferCopy_[mod];
252 
253 
254  ok = ((lay > 0 && lay <= (int)(layers(reco))));
255  if( ok ) {
256  const int32_t lay_idx = reco ? (lay-1)*3 + 1 : lay;
257  const auto& the_modules = hgpar_->copiesInLayers_[lay_idx];
258  auto moditr = the_modules.find(copyNumber);
259  ok = (moditr != the_modules.end());
260  if (ok) {
261  cellmax = (hgpar_->waferTypeT_[mod]==1) ?
262  (int)(hgpar_->cellFineX_.size()) : (int)(hgpar_->cellCoarseX_.size());
263  ok = (cell >=0 && cell <= cellmax);
264  }
265  }
266  }
267 
268 #ifdef DebugLog
269  if (!ok) std::cout << "HGCalDDDConstants: Layer " << lay << ":"
270  << (lay > 0 && (lay <= (int)(layers(reco)))) << " Module "
271  << mod << ":" << (mod > 0 && mod <= modmax) << " Cell "
272  << cell << ":" << (cell >=0 && cell <= cellmax)
273  << ":" << maxCells(reco) << std::endl;
274 #endif
275  return ok;
276 }
277 
278 std::pair<float,float> HGCalDDDConstants::locateCell(int cell, int lay,
279  int type, bool reco) const {
280  // type refers to subsector # for square cell and wafer # for hexagon cell
281  float x(999999.), y(999999.);
282  std::pair<int,float> index = getIndex(lay, reco);
283  int i = index.first;
284  if (i < 0) return std::pair<float,float>(x,y);
286  std::pair<int,int> kxy = findCell(cell, lay, type, reco);
287  float alpha, h, bl, tl;
288  getParameterSquare(i,type,reco,h,bl,tl,alpha);
289  float cellSize = index.second;
290  x = (kxy.first+0.5)*cellSize;
291  if (alpha < 0) x -= 0.5*(tl+bl);
292  else if (alpha > 0) x -= 0.5*(tl+bl);
293  if (type != 1) x = -x;
294  y = ((kxy.second+0.5)*cellSize-h);
295  } else {
296  x = hgpar_->waferPosX_[type];
297  y = hgpar_->waferPosY_[type];
298  if (hgpar_->waferTypeT_[type] == 1) {
299  x += hgpar_->cellFineX_[cell];
300  y += hgpar_->cellFineY_[cell];
301  } else {
302  x += hgpar_->cellCoarseX_[cell];
303  y += hgpar_->cellCoarseY_[cell];
304  }
305  if (!reco) {
306  x /= k_ScaleFromDDD;
307  y /= k_ScaleFromDDD;
308  }
309  }
310  return std::pair<float,float>(x,y);
311 }
312 
313 std::pair<float,float> HGCalDDDConstants::locateCellHex(int cell, int wafer,
314  bool reco) const {
315  float x(0), y(0);
316  if (hgpar_->waferTypeT_[wafer] == 1) {
317  x = hgpar_->cellFineX_[cell];
318  y = hgpar_->cellFineY_[cell];
319  } else {
320  x = hgpar_->cellCoarseX_[cell];
321  y = hgpar_->cellCoarseY_[cell];
322  }
323  if (!reco) {
324  x /= k_ScaleFromDDD;
325  y /= k_ScaleFromDDD;
326  }
327  return std::pair<float,float>(x,y);
328 }
329 
331 
332  int cells(0);
333  for (unsigned int i = 0; i<layers(reco); ++i) {
334  int lay = reco ? hgpar_->depth_[i] : hgpar_->layer_[i];
335  if (cells < maxCells(lay, reco)) cells = maxCells(lay, reco);
336  }
337  return cells;
338 }
339 
340 int HGCalDDDConstants::maxCells(int lay, bool reco) const {
341 
342  std::pair<int,float> index = getIndex(lay, reco);
343  int i = index.first;
344  if (i < 0) return 0;
346  float h, bl, tl, alpha;
347  getParameterSquare(i,0,reco,h,bl,tl,alpha);
348  return maxCellsSquare(h, bl, tl, alpha, index.second);
349  } else {
350  unsigned int cells(0);
351  for (unsigned int k=0; k<hgpar_->waferTypeT_.size(); ++k) {
352  if (waferInLayer(k,index.first)) {
353  unsigned int cell = (hgpar_->waferTypeT_[k]==1) ?
354  (hgpar_->cellFineX_.size()) : (hgpar_->cellCoarseX_.size());
355  if (cell > cells) cells = cell;
356  }
357  }
358  return (int)(cells);
359  }
360 }
361 
362 int HGCalDDDConstants::maxCellsSquare(float h, float bl, float tl,
363  float alpha, float cellSize) const {
364 
365  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
366  float b = 2*h*bl/(tl-bl);
367 
368  int ncells(0);
369  //always use the top of the cell to maximize space
370  int kymax = floor((2*h)/cellSize);
371  for (int iky=0; iky<kymax; ++iky) {
372  int cellsInRow=floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize));
373  ncells += cellsInRow;
374  }
375 
376  return ncells;
377 }
378 
379 int HGCalDDDConstants::maxRows(int lay, bool reco) const {
380 
381  int kymax(0);
382  std::pair<int,float> index = getIndex(lay, reco);
383  int i = index.first;
384  if (i < 0) return kymax;
386  float h = (reco) ? hgpar_->moduleHR_[i] : hgpar_->moduleHS_[i];
387  kymax = floor((2*h)/index.second);
388  } else {
389  for (unsigned int k=0; k<hgpar_->waferCopy_.size(); ++k) {
390  if (waferInLayer(k,i)) {
391  int ky = ((hgpar_->waferCopy_[k])/100)%100;
392  if (ky > kymax) kymax = ky;
393  }
394  }
395  }
396  return kymax;
397 }
398 
399 int HGCalDDDConstants::modules(int lay, bool reco) const {
400  if( getIndex(lay,reco).first < 0 ) return 0;
401  return max_modules_layer_[(int)reco][lay];
402 }
403 
404 int HGCalDDDConstants::modulesInit(int lay, bool reco) const {
405  int nmod(0);
406  std::pair<int,float> index = getIndex(lay, reco);
407  if (index.first < 0) return nmod;
408  for (unsigned int k=0; k<hgpar_->waferPosX_.size(); ++k) {
409  if (waferInLayer(k,index.first)) ++nmod;
410  }
411  return nmod;
412 }
413 
414 std::pair<int,int> HGCalDDDConstants::newCell(int cell, int layer, int sector,
415  int subsector, int incrx,
416  int incry, bool half) const {
417 
418  int subSec = half ? subsector : 0;
419  std::pair<int,int> kxy = findCell(cell, layer, subSec, true);
420  int kx = kxy.first + incrx;
421  int ky = kxy.second + incry;
422  if (ky < 0 || ky > maxRows(layer, true)) {
423  cell = maxCells(true);
424  return std::pair<int,int>(cell,sector*subsector);
425  } else if (kx < 0) {
426  kx =-kx;
427  subsector =-subsector;
428  } else if (kx > maxCells(layer, true)) {
429  kx -= maxCells(layer, true);
430  sector += subsector;
431  subsector =-subsector;
432  if (sector < 1) sector = hgpar_->nSectors_;
433  else if (sector > hgpar_->nSectors_) sector = 1;
434  }
435  cell = newCell(kx, ky, layer, subSec);
436  return std::pair<int,int>(cell,sector*subsector);
437 }
438 
439 std::pair<int,int> HGCalDDDConstants::newCell(int cell, int lay, int subsector,
440  int incrz, bool half) const {
441 
442  int layer = lay + incrz;
443  if (layer <= 0 || layer > (int)(layers(true))) return std::pair<int,int>(cell,0);
444  int subSec = half ? subsector : 0;
445  std::pair<float,float> xy = locateCell(cell, lay, subSec, true);
446  std::pair<int,int> kcell = assignCell(xy.first, xy.second, layer, subSec,
447  true);
448  return std::pair<int,int>(kcell.second,layer);
449 }
450 
451 int HGCalDDDConstants::newCell(int kx, int ky, int lay, int subSec) const {
452 
453  std::pair<int,float> index = getIndex(lay, true);
454  int i = index.first;
455  if (i < 0) return maxCells(true);
456  float alpha = (subSec == 0) ? hgpar_->moduleAlphaS_[i] : subSec;
457  float cellSize = index.second;
458  float a = (alpha==0) ?
461  float b = 2*hgpar_->moduleHR_[i]*hgpar_->moduleBlR_[i]/
463  int icell(kx);
464  for (int iky=0; iky<ky; ++iky)
465  icell += floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize));
466  return icell;
467 }
468 
469 std::vector<int> HGCalDDDConstants::numberCells(int lay, bool reco) const {
470 
471  std::pair<int,float> index = getIndex(lay, reco);
472  int i = index.first;
473  std::vector<int> ncell;
474  if (i >= 0) {
476  float h, bl, tl, alpha;
477  getParameterSquare(i,0,reco,h,bl,tl,alpha);
478  return numberCellsSquare(h, bl, tl, alpha, index.second);
479  } else {
480  for (unsigned int k=0; k<hgpar_->waferTypeT_.size(); ++k) {
481  if (waferInLayer(k,i)) {
482  unsigned int cell = (hgpar_->waferTypeT_[k]==1) ?
483  (hgpar_->cellFineX_.size()) : (hgpar_->cellCoarseX_.size());
484  ncell.push_back((int)(cell));
485  }
486  }
487  }
488  }
489  return ncell;
490 }
491 
492 std::vector<int> HGCalDDDConstants::numberCellsSquare(float h, float bl,
493  float tl, float alpha,
494  float cellSize) const {
495 
496  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
497  float b = 2*h*bl/(tl-bl);
498  int kymax = floor((2*h)/cellSize);
499  std::vector<int> ncell;
500  for (int iky=0; iky<kymax; ++iky)
501  ncell.push_back(floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize)));
502  return ncell;
503 }
504 
506 
507  int ncell(0);
508  if (wafer >= 0 && wafer < (int)(hgpar_->waferTypeT_.size())) {
509  if (hgpar_->waferTypeT_[wafer]==1)
510  ncell = (int)(hgpar_->cellFineX_.size());
511  else
512  ncell = (int)(hgpar_->cellCoarseX_.size());
513  }
514  return ncell;
515 }
516 
517 std::pair<int,int> HGCalDDDConstants::simToReco(int cell, int lay, int mod,
518  bool half) const {
519 
520  std::pair<int,float> index = getIndex(lay, false);
521  int i = index.first;
522  if (i < 0) return std::pair<int,int>(-1,-1);
523  int kx(-1), depth(-1);
525  float h = hgpar_->moduleHS_[i];
526  float bl = hgpar_->moduleBlS_[i];
527  float tl = hgpar_->moduleTlS_[i];
528  float cellSize = hgpar_->cellFactor_[i]*index.second;
529 
530  std::pair<int,int> kxy = findCellSquare(cell, h, bl, tl, hgpar_->moduleAlphaS_[i], index.second);
531  depth = hgpar_->layerGroup_[i];
532  if (depth<0) return std::pair<int,int>(-1,-1);
533  kx = kxy.first/hgpar_->cellFactor_[i];
534  int ky = kxy.second/hgpar_->cellFactor_[i];
535 
536  float a = (half) ? (h/(tl-bl)) : (2*h/(tl-bl));
537  float b = 2*h*bl/(tl-bl);
538  for (int iky=0; iky<ky; ++iky)
539  kx += floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize));
540 #ifdef DebugLog
541  std::cout << "simToReco: input " << cell << ":" << lay << ":" << half
542  << " kxy " << kxy.first << ":" << kxy.second << " output "
543  << kx << ":" << depth << " cell factor="
544  << hgpar_->cellFactor_[i] << std::endl;
545 #endif
546  } else {
547  kx = cell;
548  int type = hgpar_->waferTypeL_[mod];
549  if (type == 1) {
550  depth = hgpar_->layerGroup_[i];
551  } else if (type == 2) {
552  depth = hgpar_->layerGroupM_[i];
553  } else {
554  depth = hgpar_->layerGroupO_[i];
555  }
556  }
557  return std::pair<int,int>(kx,depth);
558 }
559 
561  const int ncopies = hgpar_->waferCopy_.size();
562  int wafer = ncopies;
563  for (int k=0; k<ncopies; ++k) {
564  if (copy == hgpar_->waferCopy_[k]) {
565  wafer = k;
566  break;
567  }
568  }
569  return wafer;
570 }
571 
572 bool HGCalDDDConstants::waferInLayer(int wafer, int lay, bool reco) const {
573 
574  std::pair<int,float> indx = getIndex(lay, reco);
575  if (indx.first < 0) return false;
576  return waferInLayer(wafer,indx.first);
577 }
578 
579 std::pair<double,double> HGCalDDDConstants::waferPosition(int wafer) const {
580 
581  std::pair<double,double> xy;
582  if (wafer >= 0 && wafer < (int)(hgpar_->waferPosX_.size())) {
583  xy = std::pair<double,double>(hgpar_->waferPosX_[wafer],hgpar_->waferPosY_[wafer]);
584  } else {
585  xy = std::pair<double,double>(0,0);
586  }
587  return xy;
588 }
589 
590 double HGCalDDDConstants::waferZ(int lay, bool reco) const {
591  std::pair<int,float> index = getIndex(lay, reco);
592  int i = index.first;
593  if (i < 0) return 0;
594  else return hgpar_->zLayerHex_[i];
595 }
596 
598 
599  int wafer(0);
600  for (unsigned int i = 0; i<layers(true); ++i) {
601  int lay = hgpar_->depth_[i];
602  wafer += modules(lay, true);
603  }
604  return wafer;
605 }
606 
607 int HGCalDDDConstants::cellHex(double xx, double yy,
608  const double& cellR,
609  const std::vector<double>& posX,
610  const std::vector<double>& posY) const {
611  int num(0);
612  const double tol(0.00001);
613  double cellY = 2.0*cellR*tan30deg_;
614  for (unsigned int k=0; k<posX.size(); ++k) {
615  double dx = std::abs(xx - posX[k]);
616  double dy = std::abs(yy - posY[k]);
617  if (dx <= (cellR+tol) && dy <= (cellY+tol)) {
618  double xmax = (dy<=0.5*cellY) ? cellR : (cellR-(dy-0.5*cellY)/tan30deg_);
619  if (dx <= (xmax+tol)) {
620  num = k;
621  break;
622  }
623  }
624  }
625  return num;
626 }
627 
628 std::pair<int,float> HGCalDDDConstants::getIndex(int lay, bool reco) const {
629 
630  if (lay<1 || lay>(int)(hgpar_->layerIndex_.size())) return std::pair<int,float>(-1,0);
631  if (reco && lay>(int)(hgpar_->depthIndex_.size())) return std::pair<int,float>(-1,0);
632  int indx(0);
633  float cell(0);
635  indx = (reco ? hgpar_->depthIndex_[lay-1] : hgpar_->layerIndex_[lay-1]);
636  cell = (reco ? hgpar_->moduleCellR_[indx] : hgpar_->moduleCellS_[indx]);
637  } else {
638  indx = (reco ? hgpar_->depthLayerF_[lay-1] : hgpar_->layerIndex_[lay-1]);
639  cell = (reco ? hgpar_->moduleCellR_[0] : hgpar_->moduleCellS_[0]);
640  }
641  return std::pair<int,float>(indx,cell);
642 }
643 
644 void HGCalDDDConstants::getParameterSquare(int lay, int subSec, bool reco,
645  float& h, float& bl, float& tl,
646  float& alpha) const {
647  if (reco) {
648  h = hgpar_->moduleHR_[lay];
649  bl = hgpar_->moduleBlR_[lay];
650  tl = hgpar_->moduleTlR_[lay];
651  alpha= hgpar_->moduleAlphaR_[lay];
652  if ((subSec>0 && alpha<0) || (subSec<=0 && alpha>0)) alpha = -alpha;
653  } else {
654  h = hgpar_->moduleHS_[lay];
655  bl = hgpar_->moduleBlS_[lay];
656  tl = hgpar_->moduleTlS_[lay];
657  alpha= hgpar_->moduleAlphaS_[lay];
658  }
659 }
660 
661 bool HGCalDDDConstants::waferInLayer(int wafer, int lay) const {
662 
663  const double rr = 2*rmax_*tan30deg_;
664  const double waferX = hgpar_->waferPosX_[wafer];
665  const double waferY = hgpar_->waferPosY_[wafer];
666  const double rpos = std::sqrt(waferX*waferX+waferY*waferY);
667  const bool in = (rpos-rr >= hgpar_->rMinLayHex_[lay] &&
668  rpos+rr <= hgpar_->rMaxLayHex_[lay]);
669  return in;
670 }
671 
673 
std::vector< double > waferPosY_
type
Definition: HCALResponse.h:21
std::vector< int > layer_
int i
Definition: DBlmapReader.cc:9
double k_horizontalShift
std::vector< int > depthLayerF_
float alpha
Definition: AMPTWrapper.h:95
std::vector< int > depth_
std::vector< double > moduleCellR_
std::vector< double > moduleHR_
bool isValid(int lay, int mod, int cell, bool reco) const
layer_map copiesInLayers_
std::vector< int > numberCellsSquare(float h, float bl, float tl, float alpha, float cellSize) const
std::vector< HGCalParameters::hgtrap > getModules() const
int maxCellsSquare(float h, float bl, float tl, float alpha, float cellSize) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::array< uint32_t, 2 > tot_layers_
std::vector< int > moduleLayR_
double cellSizeHex(int type) const
unsigned int layersInit(bool reco) const
std::vector< double > moduleHS_
HGCalDDDConstants(const HGCalParameters *hp, const std::string name)
int maxRows(int lay, bool reco) const
std::vector< int > numberCells(int lay, bool reco) const
std::vector< double > cellFineY_
std::pair< int, int > findCellSquare(int cell, float h, float bl, float tl, float alpha, float cellSize) const
static const int modmax
Definition: herwig.h:133
std::pair< int, int > assignCellSquare(float x, float y, float h, float bl, float tl, float alpha, float cellSize) const
int modulesInit(int lay, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
std::vector< uint32_t > trformIndex_
std::vector< int > layerGroupM_
#define constexpr
std::vector< int > cellFactor_
int cellHex(double xx, double yy, const double &cellR, const std::vector< double > &posX, const std::vector< double > &posY) const
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::vector< double > cellCoarseX_
T x() const
Cartesian x coordinate.
int modules(int lay, bool reco) const
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
unsigned int layers(bool reco) const
int numberCellsHexagon(int wafer) const
std::vector< double > cellSize_
std::vector< HGCalParameters::hgtrform > getTrForms() const
std::pair< int, int > assignCellHexagon(float x, float y) const
std::vector< int > layerIndex_
std::vector< double > moduleAlphaR_
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
hgtrform getTrForm(unsigned int k) const
T sqrt(T t)
Definition: SSEVec.h:18
std::pair< int, int > findCell(int cell, int lay, int subSec, bool reco) const
std::pair< int, float > getIndex(int lay, bool reco) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
hgtrap getModule(unsigned int k, bool reco) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > moduleBlR_
int sectors() const
std::pair< double, double > waferPosition(int wafer) const
std::vector< double > rMinLayHex_
std::vector< double > moduleTlS_
HGCalGeometryMode
std::vector< double > zLayerHex_
double waferZ(int layer, bool reco) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:96
std::vector< double > rMaxLayHex_
int waferFromCopy(int copy) const
void getParameterSquare(int lay, int subSec, bool reco, float &h, float &bl, float &tl, float &alpha) const
std::vector< int > layerGroup_
std::vector< double > moduleCellS_
double b
Definition: hdecay.h:120
HGCalGeometryMode mode_
std::vector< double > cellFineX_
std::pair< int, int > newCell(int cell, int layer, int sector, int subsector, int incrx, int incry, bool half) const
simrecovecs max_modules_layer_
std::vector< double > moduleAlphaS_
std::vector< int > layerGroupO_
std::vector< double > moduleBlS_
if(dp >Float(M_PI)) dp-
double a
Definition: hdecay.h:121
std::vector< int > waferCopy_
std::vector< int > depthIndex_
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
double k_ScaleFromDDD
tuple cout
Definition: gather_cfg.py:145
std::vector< int > waferTypeT_
std::vector< double > cellCoarseY_
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
const HGCalParameters * hgpar_
int maxCells(bool reco) const
std::vector< double > waferPosX_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::vector< double > moduleTlR_
std::vector< int > waferTypeL_
static double tan30deg_
bool waferInLayer(int wafer, int lay, bool reco) const