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 
5 
11 #include "CLHEP/Units/GlobalPhysicalConstants.h"
12 #include "CLHEP/Units/GlobalSystemOfUnits.h"
13 
14 //#define DebugLog
15 
16 const double k_ScaleFromDDD = 0.1;
17 const double k_horizontalShift = 1.0;
18 
20  std::string& nam) {
21  initialize(cpv, nam);
22 #ifdef DebugLog
23  std::cout << "HGCalDDDConstants for " << nam << " initialized with "
24  << layers(false) << ":" << layers(true) << " layers and "
25  << sectors() << " sectors and maximum of " << maxCells(false)
26  << ":" << maxCells(true) << " cells" << std::endl;
27 #endif
28 }
29 
31 
32 std::pair<int,int> HGCalDDDConstants::assignCell(float x, float y, int lay,
33  int subSec, bool reco) const {
34 
35  std::pair<int,float> index = getIndex(lay, reco);
36  int i = index.first;
37  if (i < 0) return std::pair<int,int>(-1,-1);
38  float alpha, h, bl, tl;
39 
40  //set default values
41  std::pair<int,int> cellAssignment( (x>0)?1:0, -1 );
42  if (reco) {
43  h = moduler_[i].h;
44  bl = moduler_[i].bl;
45  tl = moduler_[i].tl;
46  alpha= moduler_[i].alpha;
47  if ((subSec>0 && alpha<0) || (subSec<=0 && alpha>0)) alpha = -alpha;
48  cellAssignment=assignCell(x, y, h, bl, tl, alpha, index.second);
49  } else {
50  h = modules_[i].h;
51  bl = modules_[i].bl;
52  tl = modules_[i].tl;
53  alpha= modules_[i].alpha;
54  cellAssignment=assignCell(x, y, h, bl, tl, alpha, index.second);
55  }
56 
57  return cellAssignment;
58 }
59 
60 std::pair<int,int> HGCalDDDConstants::assignCell(float x, float y, float h,
61  float bl,float tl,float alpha,
62  float cellSize) const {
63 
64  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
65  float b = 2*h*bl/(tl-bl);
66 
67  float x0(x);
68  int phiSector = (x0 > 0) ? 1 : 0;
69  if (alpha < 0) {x0 -= 0.5*(tl+bl); phiSector = 0;}
70  else if (alpha > 0) {x0 += 0.5*(tl+bl); phiSector = 1;}
71 
72 
73  //determine the i-y
74  int ky = floor((y+h)/cellSize);
75  if( ky*cellSize> y+h) ky--;
76  if(ky<0) return std::pair<int,int>(-1,-1);
77  if( (ky+1)*cellSize < (y+h) ) ky++;
78  int max_ky_allowed=floor(2*h/cellSize);
79  if(ky>max_ky_allowed-1) return std::pair<int,int>(-1,-1);
80 
81  //determine the i-x
82  //notice we substitute y by the top of the candidate cell to reduce the dead zones
83  int kx = floor(fabs(x0)/cellSize);
84  if( kx*cellSize > fabs(x0) ) kx--;
85  if(kx<0) return std::pair<int,int>(-1,-1);
86  if( (kx+1)*cellSize < fabs(x0) ) kx++;
87  int max_kx_allowed=floor( ((ky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize) );
88  if(kx>max_kx_allowed-1) return std::pair<int,int>(-1,-1);
89 
90  //count cells summing in rows until required height
91  //notice the bottom of the cell must be used
92  int icell(0);
93  for (int iky=0; iky<ky; ++iky) {
94  int cellsInRow( floor( ((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize) ) );
95  icell += cellsInRow;
96  }
97  icell += kx;
98 
99  //return result
100  return std::pair<int,int>(phiSector,icell);
101 }
102 
103 std::pair<int,int> HGCalDDDConstants::findCell(int cell, int lay, int subSec,
104  bool reco) const {
105 
106  std::pair<int,float> index = getIndex(lay, reco);
107  int i = index.first;
108  if (i < 0) return std::pair<int,int>(-1,-1);
109  float alpha, h, bl, tl;
110  if (reco) {
111  h = moduler_[i].h;
112  bl = moduler_[i].bl;
113  tl = moduler_[i].tl;
114  alpha= moduler_[i].alpha;
115  if ((subSec>0 && alpha<0) || (subSec<=0 && alpha>0)) alpha = -alpha;
116  } else {
117  h = modules_[i].h;
118  bl = modules_[i].bl;
119  tl = modules_[i].tl;
120  alpha= modules_[i].alpha;
121  }
122  return findCell(cell, h, bl, tl, alpha, index.second);
123 }
124 
125 std::pair<int,int> HGCalDDDConstants::findCell(int cell, float h, float bl,
126  float tl, float alpha,
127  float cellSize) const {
128 
129  //check if cell number is meaningful
130  if(cell<0) return std::pair<int,int>(-1,-1);
131 
132  //parameterization of the boundary of the trapezoid
133  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
134  float b = 2*h*bl/(tl-bl);
135  int kx(cell), ky(0);
136  int kymax( floor((2*h)/cellSize) );
137  int testCell(0);
138  for (int iky=0; iky<kymax; ++iky) {
139 
140  //check if adding all the cells in this row is above the required cell
141  //notice the top of the cell is used to maximize space
142  int cellsInRow( floor( ((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize) ) );
143  if (testCell+cellsInRow > cell) break;
144  testCell += cellsInRow;
145  ky++;
146  kx -= cellsInRow;
147  }
148 
149  return std::pair<int,int>(kx,ky);
150 }
151 
152 bool HGCalDDDConstants::isValid(int lay, int mod, int cell, bool reco) const {
153 
154  bool ok = ((lay > 0 && lay <= (int)(layers(reco))) &&
155  (mod > 0 && mod <= sectors()) &&
156  (cell >=0 && cell <= maxCells(lay,reco)));
157 
158 #ifdef DebugLog
159  if (!ok) std::cout << "HGCalDDDConstants: Layer " << lay << ":"
160  << (lay > 0 && (lay <= (int)(layers(reco)))) << " Module "
161  << mod << ":" << (mod > 0 && mod <= sectors()) << " Cell "
162  << cell << ":" << (cell >=0 && cell <= maxCells(lay,reco))
163  << ":" << maxCells(reco) << std::endl;
164 #endif
165  return ok;
166 }
167 
168 std::pair<float,float> HGCalDDDConstants::locateCell(int cell, int lay,
169  int subSec, bool reco) const {
170 
171  std::pair<int,float> index = getIndex(lay, reco);
172  int i = index.first;
173  if (i < 0) return std::pair<float,float>(999999.,999999.);
174  std::pair<int,int> kxy = findCell(cell, lay, subSec, reco);
175  float alpha, h, bl, tl;
176  if (reco) {
177  h = moduler_[i].h;
178  bl = moduler_[i].bl;
179  tl = moduler_[i].tl;
180  alpha= moduler_[i].alpha;
181  if ((subSec>0 && alpha<0) || (subSec<=0 && alpha>0)) alpha = -alpha;
182  } else {
183  h = modules_[i].h;
184  bl = modules_[i].bl;
185  tl = modules_[i].tl;
186  alpha= modules_[i].alpha;
187  }
188  float cellSize = index.second;
189  float x = (kxy.first+0.5)*cellSize;
190  if (alpha < 0) x -= 0.5*(tl+bl);
191  else if (alpha > 0) x -= 0.5*(tl+bl);
192  if (subSec != 1) x = -x;
193  float y = ((kxy.second+0.5)*cellSize-h);
194  return std::pair<float,float>(x,y);
195 }
196 
198 
199  int cells(0);
200  for (unsigned int i = 0; i<layers(reco); ++i) {
201  int lay = reco ? depth_[i] : layer_[i];
202  if (cells < maxCells(lay, reco)) cells = maxCells(lay, reco);
203  }
204  return cells;
205 }
206 
207 int HGCalDDDConstants::maxCells(int lay, bool reco) const {
208 
209  std::pair<int,float> index = getIndex(lay, reco);
210  int i = index.first;
211  if (i < 0) return 0;
212  float h, bl, tl, alpha;
213  if (reco) {
214  h = moduler_[i].h;
215  bl = moduler_[i].bl;
216  tl = moduler_[i].tl;
217  alpha= moduler_[i].alpha;
218  } else {
219  h = modules_[i].h;
220  bl = modules_[i].bl;
221  tl = modules_[i].tl;
222  alpha= modules_[i].alpha;
223  }
224  return maxCells(h, bl, tl, alpha, index.second);
225 }
226 
227 int HGCalDDDConstants::maxCells(float h, float bl, float tl, float alpha,
228  float cellSize) const {
229 
230  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
231  float b = 2*h*bl/(tl-bl);
232 
233  int ncells(0);
234  //always use the top of the cell to maximize space
235  int kymax = floor((2*h)/cellSize);
236  for (int iky=0; iky<kymax; ++iky)
237  {
238  int cellsInRow=floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize));
239  ncells += cellsInRow;
240  }
241 
242  return ncells;
243 }
244 
245 int HGCalDDDConstants::maxRows(int lay, bool reco) const {
246 
247  std::pair<int,float> index = getIndex(lay, reco);
248  int i = index.first;
249  if (i < 0) return 0;
250  float h = (reco) ? moduler_[i].h : modules_[i].h;
251  int kymax = floor((2*h)/index.second);
252  return kymax;
253 }
254 
255 std::pair<int,int> HGCalDDDConstants::newCell(int cell, int layer, int sector,
256  int subsector, int incrx,
257  int incry, bool half) const {
258 
259  int subSec = half ? subsector : 0;
260  std::pair<int,int> kxy = findCell(cell, layer, subSec, true);
261  int kx = kxy.first + incrx;
262  int ky = kxy.second + incry;
263  if (ky < 0 || ky > maxRows(layer, true)) {
264  cell = maxCells(true);
265  return std::pair<int,int>(cell,sector*subsector);
266  } else if (kx < 0) {
267  kx =-kx;
268  subsector =-subsector;
269  } else if (kx > maxCells(layer, true)) {
270  kx -= maxCells(layer, true);
271  sector += subsector;
272  subsector =-subsector;
273  if (sector < 1) sector = nSectors;
274  else if (sector > nSectors) sector = 1;
275  }
276  cell = newCell(kx, ky, layer, subSec);
277  return std::pair<int,int>(cell,sector*subsector);
278 }
279 
280 std::pair<int,int> HGCalDDDConstants::newCell(int cell, int lay, int subsector,
281  int incrz, bool half) const {
282 
283  int layer = lay + incrz;
284  if (layer <= 0 || layer > (int)(layers(true))) return std::pair<int,int>(cell,0);
285  int subSec = half ? subsector : 0;
286  std::pair<float,float> xy = locateCell(cell, lay, subSec, true);
287  std::pair<int,int> kcell = assignCell(xy.first, xy.second, layer, subSec,
288  true);
289  return std::pair<int,int>(kcell.second,layer);
290 }
291 
292 int HGCalDDDConstants::newCell(int kx, int ky, int lay, int subSec) const {
293 
294  std::pair<int,float> index = getIndex(lay, true);
295  int i = index.first;
296  if (i < 0) return maxCells(true);
297  float alpha = (subSec == 0) ? modules_[i].alpha : subSec;
298  float cellSize = index.second;
299  float a = (alpha==0) ?
300  (2*moduler_[i].h/(moduler_[i].tl-moduler_[i].bl)) :
301  (moduler_[i].h/(moduler_[i].tl-moduler_[i].bl));
302  float b = 2*moduler_[i].h*moduler_[i].bl/
303  (moduler_[i].tl-moduler_[i].bl);
304  int icell(kx);
305  for (int iky=0; iky<ky; ++iky)
306  icell += floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize));
307  return icell;
308 }
309 
310 std::vector<int> HGCalDDDConstants::numberCells(int lay, bool reco) const {
311 
312  std::pair<int,float> index = getIndex(lay, reco);
313  int i = index.first;
314  if (i >= 0) {
315  float h, bl, tl, alpha;
316  if (reco) {
317  h = moduler_[i].h;
318  bl = moduler_[i].bl;
319  tl = moduler_[i].tl;
320  alpha= moduler_[i].alpha;
321  } else {
322  h = modules_[i].h;
323  bl = modules_[i].bl;
324  tl = modules_[i].tl;
325  alpha= modules_[i].alpha;
326  }
327  return numberCells(h, bl, tl, alpha, index.second);
328  } else {
329  std::vector<int> ncell;
330  return ncell;
331  }
332 }
333 
334 std::vector<int> HGCalDDDConstants::numberCells(float h, float bl,
335  float tl, float alpha,
336  float cellSize) const {
337 
338  float a = (alpha==0) ? (2*h/(tl-bl)) : (h/(tl-bl));
339  float b = 2*h*bl/(tl-bl);
340  int kymax = floor((2*h)/cellSize);
341  std::vector<int> ncell;
342  for (int iky=0; iky<kymax; ++iky)
343  ncell.push_back(floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize)));
344  return ncell;
345 }
346 
347 std::pair<int,int> HGCalDDDConstants::simToReco(int cell, int lay,
348  bool half) const {
349 
350  std::pair<int,float> index = getIndex(lay, false);
351  int i = index.first;
352  if (i < 0) return std::pair<int,int>(-1,-1);
353  float h = modules_[i].h;
354  float bl = modules_[i].bl;
355  float tl = modules_[i].tl;
356  float cellSize = cellFactor_[i]*index.second;
357 
358  std::pair<int,int> kxy = findCell(cell, h, bl, tl, modules_[i].alpha, index.second);
359  int depth = layerGroup_[i];
360  if(depth<0) return std::pair<int,int>(-1,-1);
361  int kx = kxy.first/cellFactor_[i];
362  int ky = kxy.second/cellFactor_[i];
363 
364  float a = (half) ? (h/(tl-bl)) : (2*h/(tl-bl));
365  float b = 2*h*bl/(tl-bl);
366  for (int iky=0; iky<ky; ++iky)
367  kx += floor(((iky+1)*cellSize+b+k_horizontalShift*cellSize)/(a*cellSize));
368 
369 #ifdef DebugLog
370  std::cout << "simToReco: input " << cell << ":" << lay << ":" << half
371  << " kxy " << kxy.first << ":" << kxy.second << " output "
372  << kx << ":" << depth << " cell factor=" << cellFactor_[i] << std::endl;
373 #endif
374  return std::pair<int,int>(kx,depth);
375 }
376 
378 
379  nSectors = nCells = 0;
380 
381  std::string attribute = "Volume";
383  DDValue val(attribute, value, 0);
384 
386  filter.setCriteria(val, DDCompOp::equals);
387  DDFilteredView fv(cpv);
388  fv.addFilter(filter);
389  bool ok = fv.firstChild();
390 
391  if (ok) {
392  //Load the SpecPars
393  loadSpecPars(fv);
394  //Load the Geometry parameters
395  loadGeometry(fv, name);
396  }
397 }
398 
400  const std::string & sdTag) {
401 
402  DDFilteredView fv = _fv;
403  bool dodet(true), first(true);
404  int zpFirst(0);
405  std::vector<hgtrform> trforms;
406 
407  while (dodet) {
408  // DDTranslation t = fv.translation();
409  const DDSolid & sol = fv.logicalPart().solid();
410  std::string name = sol.name();
411  int isd = (name.find(sdTag) == std::string::npos) ? -1 : 1;
412  if (isd > 0) {
413  std::vector<int> copy = fv.copyNumbers();
414  int nsiz = (int)(copy.size());
415  int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
416  int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
417  int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
418  if (zp !=1 ) zp = -1;
419  if (first) {first = false; zpFirst = zp;}
420  const DDTrap & trp = static_cast<DDTrap>(sol);
421  HGCalDDDConstants::hgtrap mytr(lay,trp.x1(),trp.x2(),
422  0.5*(trp.y1()+trp.y2()),
423  trp.halfZ(),trp.alpha1());
424  int subs = (trp.alpha1()>0 ? 1 : 0);
425  if (std::find(layer_.begin(),layer_.end(),lay) == layer_.end()) {
426  for (unsigned int k=0; k<cellSize_.size(); ++k) {
427  if (lay == (int)(k+1)) {
428  mytr.cellSize = cellSize_[k];
429  break;
430  }
431  }
432  modules_.push_back(mytr);
433  if (layer_.size() == 0) nSectors = 1;
434  layer_.push_back(lay);
435  } else if (std::find(layer_.begin(),layer_.end(),lay) == layer_.begin()){
436  if (zp == zpFirst) ++nSectors;
437  }
438  DD3Vector x, y, z;
439  fv.rotation().GetComponents( x, y, z ) ;
440  const CLHEP::HepRep3x3 rotation ( x.X(), y.X(), z.X(),
441  x.Y(), y.Y(), z.Y(),
442  x.Z(), y.Z(), z.Z() );
443  const CLHEP::HepRotation hr ( rotation );
444  const CLHEP::Hep3Vector h3v ( fv.translation().X(),
445  fv.translation().Y(),
446  fv.translation().Z() ) ;
447  HGCalDDDConstants::hgtrform mytrf(zp,lay,sec,subs);
448  mytrf.h3v = h3v;
449  mytrf.hr = hr;
450  trforms.push_back(mytrf);
451  }
452  dodet = fv.next();
453  }
454  if (layer_.size() != cellSize_.size()) {
455  edm::LogError("HGCalGeom") << "HGCalDDDConstants : mismatch in # of bins "
456  << layer_.size() << ":" << cellSize_.size()
457  << " between geometry and specpar";
458  throw cms::Exception("DDException") << "HGCalDDDConstants: mismatch between geometry and specpar";
459  }
460  for (unsigned int i=0; i<layer_.size(); ++i) {
461  for (unsigned int k=0; k<layer_.size(); ++k) {
462  if (layer_[k] == (int)(i+1)) {
463  layerIndex.push_back(k);
464  break;
465  }
466  }
467  }
468 #ifdef DebugLog
469  std::cout << "HGCalDDDConstants finds " <<layerIndex.size() <<" modules for "
470  << sdTag << " with " << nSectors << " sectors and "
471  << trforms.size() << " transformation matrices" << std::endl;
472  for (unsigned int i=0; i<layerIndex.size(); ++i) {
473  int k = layerIndex[i];
474  std::cout << "Module[" << i << ":" << k << "] Layer " << layer_[k] << ":"
475  << modules_[k].lay << " dx " << modules_[k].bl << ":"
476  << modules_[k].tl << " dy " << modules_[k].h << " dz "
477  << modules_[k].dz << " alpha " << modules_[k].alpha << " cell "
478  << modules_[k].cellSize << std::endl;
479  }
480 #endif
481  int depth(0);
482  for (unsigned int i=0; i<layer_.size(); ++i) {
483  bool first(true);
484  float dz(0);
485  for (unsigned int k=0; k<layerGroup_.size(); ++k) {
486  if (layerGroup_[k] == (int)(i+1)) {
487  if (first) {
488  depth_.push_back(i+1);
489  depthIndex.push_back(depth);
490  depth++;
491  moduler_.push_back(modules_[k]);
492  moduler_.back().lay = depth;
493  moduler_.back().bl *= k_ScaleFromDDD;
494  moduler_.back().tl *= k_ScaleFromDDD;
495  moduler_.back().h *= k_ScaleFromDDD;
496  moduler_.back().dz *= k_ScaleFromDDD;
497  moduler_.back().cellSize *= (k_ScaleFromDDD*cellFactor_[k]);
498  dz = moduler_.back().dz;
499  first = false;
500  } else {
501  dz += (k_ScaleFromDDD*modules_[k].dz);
502  moduler_.back().dz = dz;
503  }
504  }
505  }
506  }
507 #ifdef DebugLog
508  std::cout << "HGCalDDDConstants has " << depthIndex.size() << " depths"
509  << std::endl;
510  for (unsigned int i=0; i<depthIndex.size(); ++i) {
511  int k = depthIndex[i];
512  std::cout << "Module[" << i << ":" << k << "] Depth " << depth_[k]
513  << ":" << moduler_[k].lay << " dx " << moduler_[k].bl << ":"
514  << moduler_[k].tl << " dy " << moduler_[k].h << " dz "
515  << moduler_[k].dz << " alpha " << moduler_[k].alpha << " cell "
516  << moduler_[k].cellSize << std::endl;
517  }
518 #endif
519  for (unsigned int i=0; i<layer_.size(); ++i) {
520  for (unsigned int i1=0; i1<trforms.size(); ++i1) {
521  if (!trforms[i1].used && layerGroup_[trforms[i1].lay-1] == (int)(i+1)) {
522  trform_.push_back(trforms[i1]);
523  trform_.back().h3v *= k_ScaleFromDDD;
524  trform_.back().lay = (i+1);
525  trforms[i1].used = true;
526  int nz(1);
527  for (unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
528  if (!trforms[i2].used && trforms[i2].zp == trforms[i1].zp &&
529  layerGroup_[trforms[i2].lay-1] == (int)(i+1) &&
530  trforms[i2].sec == trforms[i1].sec &&
531  trforms[i2].subsec == trforms[i1].subsec) {
532  trform_.back().h3v += (k_ScaleFromDDD*trforms[i2].h3v);
533  nz++;
534  trforms[i2].used = true;
535  }
536  }
537  if (nz > 0) {
538  trform_.back().h3v /= nz;
539  }
540  }
541  }
542  }
543 #ifdef DebugLog
544  std::cout << "Obtained " << trform_.size() << " transformation matrices"
545  << std::endl;
546  for (unsigned int k=0; k<trform_.size(); ++k) {
547  std::cout << "Matrix[" << k << "] (" << trform_[k].zp << ","
548  << trform_[k].sec << "," << trform_[k].subsec << ","
549  << trform_[k].lay << ") " << " Trnaslation " << trform_[k].h3v
550  << " Rotation " << trform_[k].hr;
551  }
552 #endif
553 }
554 
556 
558 
559  //Granularity in x-y plane
560  nCells = 0;
561  cellSize_ = getDDDArray("Granularity",sv,nCells);
562 #ifdef DebugLog
563  std::cout << "HGCalDDDConstants: " << nCells << " entries for cellSize_"
564  << std::endl;
565  for (int i=0; i<nCells; i++) {
566  std::cout << " [" << i << "] = " << cellSize_[i];
567  if (i%8 == 7) std::cout << std::endl;
568  }
569  if ((nCells-1)%8 != 7) std::cout << std::endl;
570 #endif
571 
572  //Grouping in the detector plane
573  cellFactor_ = dbl_to_int(getDDDArray("GroupingXY",sv,nCells));
574 #ifdef DebugLog
575  std::cout << "HGCalDDDConstants: " << nCells << " entries for cellFactor_"
576  << std::endl;
577  for (int i=0; i<nCells; i++) {
578  std::cout << " [" << i << "] = " << cellFactor_[i];
579  if (i%8 == 7) std::cout << std::endl;
580  }
581  if ((nCells-1)%8 != 7) std::cout << std::endl;
582 #endif
583 
584  //Grouping of layers
585  layerGroup_ = dbl_to_int(getDDDArray("GroupingZ",sv,nCells));
586 #ifdef DebugLog
587  std::cout << "HGCalDDDConstants: " << nCells << " entries for layerGroup_"
588  << std::endl;
589  for (int i=0; i<nCells; i++) {
590  std::cout << " [" << i << "] = " << layerGroup_[i];
591  if (i%8 == 7) std::cout << std::endl;
592  }
593  if ((nCells-1)%8 != 7) std::cout << std::endl;
594 #endif
595 }
596 
597 std::vector<double> HGCalDDDConstants::getDDDArray(const std::string & str,
598  const DDsvalues_type & sv,
599  int & nmin) const {
600  DDValue value(str);
601  if (DDfetch(&sv,value)) {
602  const std::vector<double> & fvec = value.doubles();
603  int nval = fvec.size();
604  if (nmin > 0) {
605  if (nval < nmin) {
606  edm::LogError("HGCalGeom") << "HGCalDDDConstants : # of " << str
607  << " bins " << nval << " < " << nmin
608  << " ==> illegal";
609  throw cms::Exception("DDException") << "HGCalDDDConstants: cannot get array " << str;
610  }
611  } else {
612  if (nval < 1 && nmin == 0) {
613  edm::LogError("HGCalGeom") << "HGCalDDDConstants : # of " << str
614  << " bins " << nval << " < 2 ==> illegal"
615  << " (nmin=" << nmin << ")";
616  throw cms::Exception("DDException") << "HGCalDDDConstants: cannot get array " << str;
617  }
618  }
619  nmin = nval;
620  return fvec;
621  } else {
622  if (nmin >= 0) {
623  edm::LogError("HGCalGeom") << "HGCalDDDConstants: cannot get array "
624  << str;
625  throw cms::Exception("DDException") << "HGCalDDDConstants: cannot get array " << str;
626  }
627  std::vector<double> fvec;
628  nmin = 0;
629  return fvec;
630  }
631 }
632 
633 std::pair<int,float> HGCalDDDConstants::getIndex(int lay, bool reco) const {
634 
635  if (lay<1 || lay>(int)(layerIndex.size())) return std::pair<int,float>(-1,0);
636  if (reco && lay>(int)(depthIndex.size())) return std::pair<int,float>(-1,0);
637  int i = (reco ? depthIndex[lay-1] : layerIndex[lay-1]);
638  float cell = (reco ? moduler_[i].cellSize : modules_[i].cellSize);
639  return std::pair<int,float>(i,cell);
640 }
641 
643 
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:167
const double k_ScaleFromDDD
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:139
bool isValid(int lay, int mod, int cell, bool reco) const
double x1(void) const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
Definition: DDSolid.cc:175
std::vector< double > cellSize_
const N & name() const
Definition: DDBase.h:78
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
nav_type copyNumbers() const
return the stack of copy numbers
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
int maxRows(int lay, bool reco) const
std::vector< int > numberCells(int lay, bool reco) const
std::vector< int > depth_
std::vector< hgtrap > moduler_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
type of data representation of DDCompactView
Definition: DDCompactView.h:77
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
std::vector< int > depthIndex
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.cc:4
T x() const
Cartesian x coordinate.
void loadGeometry(const DDFilteredView &fv, const std::string &tag)
unsigned int layers(bool reco) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
void initialize(const DDCompactView &cpv, std::string name)
bool next()
set current node to the next node in the filtered tree
std::pair< int, int > findCell(int cell, int lay, int subSec, bool reco) const
std::pair< int, float > getIndex(int lay, bool reco) const
susybsm::HSCParticleRef hr
Definition: classes.h:26
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
const double k_horizontalShift
Interface to a Trapezoid.
Definition: DDSolid.h:77
double y1(void) const
Half-length along y of the face at -pDz.
Definition: DDSolid.cc:173
std::vector< int > cellFactor_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void loadSpecPars(const DDFilteredView &fv)
int sectors() const
std::pair< int, int > simToReco(int cell, int layer, bool half) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:96
std::vector< hgtrform > trform_
std::vector< int > layer_
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, int &) const
std::vector< int > layerGroup_
double b
Definition: hdecay.h:120
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
Definition: DDSolid.cc:179
DDsvalues_type mergedSpecifics() const
HGCalDDDConstants(const DDCompactView &cpv, std::string &name)
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:177
std::pair< int, int > newCell(int cell, int layer, int sector, int subsector, int incrx, int incry, bool half) const
double a
Definition: hdecay.h:121
bool firstChild()
set the current node to the first child ...
double y2(void) const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:181
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
tuple cout
Definition: gather_cfg.py:121
const DDTranslation & translation() const
The absolute translation of the current node.
std::pair< float, float > locateCell(int cell, int lay, int subSec, bool reco) const
std::vector< hgtrap > modules_
int maxCells(bool reco) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
std::vector< int > layerIndex
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32