CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
HGCalDDDConstants Class Reference

#include <HGCalDDDConstants.h>

Classes

struct  hgtrap
 
struct  hgtrform
 

Public Member Functions

std::pair< int, int > assignCell (float x, float y, int lay, int subSec, bool reco) const
 
std::pair< int, int > assignCell (float x, float y, float h, float bl, float tl, float alpha, float cellSize) const
 
std::pair< int, int > findCell (int cell, int lay, int subSec, bool reco) const
 
std::pair< int, int > findCell (int cell, float h, float bl, float tl, float alpha, float cellSize) const
 
std::vector< hgtrap >
::const_iterator 
getFirstModule (bool reco=false) const
 
std::vector< hgtrform >
::const_iterator 
getFirstTrForm () const
 
std::vector< hgtrap >
::const_iterator 
getLastModule (bool reco=false) const
 
std::vector< hgtrform >
::const_iterator 
getLastTrForm () const
 
 HGCalDDDConstants (const DDCompactView &cpv, std::string &name)
 
bool isValid (int lay, int mod, int cell, bool reco) const
 
unsigned int layers (bool reco) const
 
std::pair< float, float > locateCell (int cell, int lay, int subSec, bool reco) const
 
int maxCells (bool reco) const
 
int maxCells (int lay, bool reco) const
 
int maxCells (float h, float bl, float tl, float alpha, float cellSize) const
 
int maxRows (int lay, bool reco) const
 
std::pair< int, int > newCell (int cell, int layer, int sector, int subsector, int incrx, int incry, bool half) const
 
std::pair< int, int > newCell (int cell, int layer, int subsector, int incrz, bool half) const
 
int newCell (int kx, int ky, int lay, int subSec) const
 
std::vector< int > numberCells (int lay, bool reco) const
 
std::vector< int > numberCells (float h, float bl, float tl, float alpha, float cellSize) const
 
int sectors () const
 
std::pair< int, int > simToReco (int cell, int layer, bool half) const
 
 ~HGCalDDDConstants ()
 

Private Member Functions

std::vector< double > getDDDArray (const std::string &, const DDsvalues_type &, int &) const
 
std::pair< int, float > getIndex (int lay, bool reco) const
 
void initialize (const DDCompactView &cpv, std::string name)
 
void loadGeometry (const DDFilteredView &fv, const std::string &tag)
 
void loadSpecPars (const DDFilteredView &fv)
 

Private Attributes

std::vector< int > cellFactor_
 
std::vector< double > cellSize_
 
std::vector< int > depth_
 
std::vector< int > depthIndex
 
std::vector< int > layer_
 
std::vector< int > layerGroup_
 
std::vector< int > layerIndex
 
std::vector< hgtrapmoduler_
 
std::vector< hgtrapmodules_
 
int nCells
 
int nLayers
 
int nSectors
 
std::vector< hgtrformtrform_
 

Detailed Description

this class reads the constant section of the numbering xml-files of the high granulairy calorimeter

Date:
2014/03/20 00:06:50
Author
Sunanda Banerjee, SINP sunan.nosp@m.da.b.nosp@m.anerj.nosp@m.ee@c.nosp@m.ern.c.nosp@m.h

Definition at line 24 of file HGCalDDDConstants.h.

Constructor & Destructor Documentation

HGCalDDDConstants::HGCalDDDConstants ( const DDCompactView cpv,
std::string &  name 
)

Definition at line 19 of file HGCalDDDConstants.cc.

References gather_cfg::cout, initialize(), layers(), maxCells(), and sectors().

20  {
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 }
unsigned int layers(bool reco) const
void initialize(const DDCompactView &cpv, std::string name)
int sectors() const
tuple cout
Definition: gather_cfg.py:121
int maxCells(bool reco) const
HGCalDDDConstants::~HGCalDDDConstants ( )

Definition at line 30 of file HGCalDDDConstants.cc.

30 {}

Member Function Documentation

std::pair< int, int > HGCalDDDConstants::assignCell ( float  x,
float  y,
int  lay,
int  subSec,
bool  reco 
) const

Definition at line 32 of file HGCalDDDConstants.cc.

References alpha, getIndex(), h, i, cmsHarvester::index, moduler_, and modules_.

Referenced by HGCNumberingScheme::assignCell(), HGCalGeometry::getClosestCell(), HGCNumberingScheme::getUnitID(), and newCell().

33  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< hgtrap > moduler_
std::pair< int, float > getIndex(int lay, bool reco) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
std::vector< hgtrap > modules_
std::pair< int, int > HGCalDDDConstants::assignCell ( float  x,
float  y,
float  h,
float  bl,
float  tl,
float  alpha,
float  cellSize 
) const

Definition at line 60 of file HGCalDDDConstants.cc.

References a, b, h, and k_horizontalShift.

62  {
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 }
float alpha
Definition: AMPTWrapper.h:95
const double k_horizontalShift
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
std::pair< int, int > HGCalDDDConstants::findCell ( int  cell,
int  lay,
int  subSec,
bool  reco 
) const

Definition at line 103 of file HGCalDDDConstants.cc.

References alpha, getIndex(), h, i, cmsHarvester::index, moduler_, and modules_.

Referenced by locateCell(), newCell(), and simToReco().

104  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< hgtrap > moduler_
std::pair< int, int > findCell(int cell, int lay, int subSec, bool reco) const
std::pair< int, float > getIndex(int lay, bool reco) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< hgtrap > modules_
std::pair< int, int > HGCalDDDConstants::findCell ( int  cell,
float  h,
float  bl,
float  tl,
float  alpha,
float  cellSize 
) const

Definition at line 125 of file HGCalDDDConstants.cc.

References a, b, and k_horizontalShift.

127  {
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 }
float alpha
Definition: AMPTWrapper.h:95
const double k_horizontalShift
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
std::vector< double > HGCalDDDConstants::getDDDArray ( const std::string &  str,
const DDsvalues_type sv,
int &  nmin 
) const
private

Definition at line 597 of file HGCalDDDConstants.cc.

References DDfetch(), DDValue::doubles(), Exception, and relativeConstraints::value.

Referenced by loadSpecPars().

599  {
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 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
std::vector<hgtrap>::const_iterator HGCalDDDConstants::getFirstModule ( bool  reco = false) const
inline

Definition at line 73 of file HGCalDDDConstants.h.

References moduler_, modules_, and dt_dqm_sourceclient_common_cff::reco.

Referenced by HGCalGeometryLoader::build().

73 { return (reco ? moduler_.begin() : modules_.begin()); }
std::vector< hgtrap > moduler_
std::vector< hgtrap > modules_
std::vector<hgtrform>::const_iterator HGCalDDDConstants::getFirstTrForm ( ) const
inline

Definition at line 75 of file HGCalDDDConstants.h.

References trform_.

Referenced by HGCalGeometryLoader::build().

75 { return trform_.begin(); }
std::vector< hgtrform > trform_
std::pair< int, float > HGCalDDDConstants::getIndex ( int  lay,
bool  reco 
) const
private

Definition at line 633 of file HGCalDDDConstants.cc.

References depthIndex, i, layerIndex, moduler_, and modules_.

Referenced by assignCell(), findCell(), locateCell(), maxCells(), maxRows(), newCell(), numberCells(), and simToReco().

633  {
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 }
int i
Definition: DBlmapReader.cc:9
std::vector< hgtrap > moduler_
std::vector< int > depthIndex
std::vector< hgtrap > modules_
std::vector< int > layerIndex
std::vector<hgtrap>::const_iterator HGCalDDDConstants::getLastModule ( bool  reco = false) const
inline

Definition at line 74 of file HGCalDDDConstants.h.

References moduler_, modules_, and dt_dqm_sourceclient_common_cff::reco.

Referenced by HGCalGeometryLoader::build().

74 { return (reco ? moduler_.end() : modules_.end()); }
std::vector< hgtrap > moduler_
std::vector< hgtrap > modules_
std::vector<hgtrform>::const_iterator HGCalDDDConstants::getLastTrForm ( ) const
inline

Definition at line 76 of file HGCalDDDConstants.h.

References trform_.

Referenced by HGCalGeometryLoader::build().

76 { return trform_.end(); }
std::vector< hgtrform > trform_
void HGCalDDDConstants::initialize ( const DDCompactView cpv,
std::string  name 
)
private

Definition at line 377 of file HGCalDDDConstants.cc.

References DDFilteredView::addFilter(), equals, alcazmumu_cfi::filter, DDFilteredView::firstChild(), loadGeometry(), loadSpecPars(), mergeVDriftHistosByStation::name, nCells, nSectors, convertSQLiteXML::ok, DDSpecificsFilter::setCriteria(), AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by HGCalDDDConstants().

377  {
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 }
void loadGeometry(const DDFilteredView &fv, const std::string &tag)
void loadSpecPars(const DDFilteredView &fv)
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32
bool HGCalDDDConstants::isValid ( int  lay,
int  mod,
int  cell,
bool  reco 
) const

Definition at line 152 of file HGCalDDDConstants.cc.

References gather_cfg::cout, layers(), maxCells(), convertSQLiteXML::ok, and sectors().

Referenced by HGCNumberingScheme::getUnitID(), and core.AutoHandle.AutoHandle::ReallyLoad().

152  {
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 }
unsigned int layers(bool reco) const
int sectors() const
tuple cout
Definition: gather_cfg.py:121
int maxCells(bool reco) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
unsigned int HGCalDDDConstants::layers ( bool  reco) const
inline

Definition at line 54 of file HGCalDDDConstants.h.

References depthIndex, and layerIndex.

Referenced by HGCalDDDConstants(), HGCalTopology::HGCalTopology(), isValid(), maxCells(), and newCell().

54 {return (reco ? depthIndex.size() : layerIndex.size());}
std::vector< int > depthIndex
std::vector< int > layerIndex
void HGCalDDDConstants::loadGeometry ( const DDFilteredView fv,
const std::string &  tag 
)
private

Definition at line 399 of file HGCalDDDConstants.cc.

References DDTrap::alpha1(), cellFactor_, HGCalDDDConstants::hgtrap::cellSize, cellSize_, filterCSVwithJSON::copy, DDFilteredView::copyNumbers(), gather_cfg::cout, HLT_25ns14e33_v1_cff::depth, depth_, depthIndex, Exception, spr::find(), plotBeamSpotDB::first, DDTrap::halfZ(), AnalysisDataFormats_SUSYBSMObjects::hr, i, relval_steps::k, k_ScaleFromDDD, layer_, layerGroup_, layerIndex, DDFilteredView::logicalPart(), moduler_, modules_, mergeVDriftHistosByStation::name, DDBase< N, C >::name(), DDFilteredView::next(), nSectors, idealTransformation::rotation, DDFilteredView::rotation(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, DDFilteredView::translation(), trform_, x, DDTrap::x1(), DDTrap::x2(), y, DDTrap::y1(), DDTrap::y2(), and z.

Referenced by initialize().

400  {
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 }
int i
Definition: DBlmapReader.cc:9
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.
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
nav_type copyNumbers() const
return the stack of copy numbers
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
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
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
std::vector< int > depthIndex
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
bool next()
set current node to the next node in the filtered tree
susybsm::HSCParticleRef hr
Definition: classes.h:26
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_
std::vector< hgtrform > trform_
std::vector< int > layer_
std::vector< int > layerGroup_
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
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:177
double y2(void) const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:181
tuple cout
Definition: gather_cfg.py:121
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< hgtrap > modules_
std::vector< int > layerIndex
void HGCalDDDConstants::loadSpecPars ( const DDFilteredView fv)
private

Definition at line 555 of file HGCalDDDConstants.cc.

References cellFactor_, cellSize_, gather_cfg::cout, dbl_to_int(), getDDDArray(), i, layerGroup_, DDFilteredView::mergedSpecifics(), and nCells.

Referenced by initialize().

555  {
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 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > cellSize_
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
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
std::vector< int > cellFactor_
std::vector< int > layerGroup_
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, int &) const
DDsvalues_type mergedSpecifics() const
tuple cout
Definition: gather_cfg.py:121
std::pair< float, float > HGCalDDDConstants::locateCell ( int  cell,
int  lay,
int  subSec,
bool  reco 
) const

Definition at line 168 of file HGCalDDDConstants.cc.

References alpha, findCell(), getIndex(), h, i, cmsHarvester::index, moduler_, modules_, x, and y.

Referenced by HGCalGeometry::getCorners(), HGCNumberingScheme::getLocalCoords(), HGCalGeometry::getPosition(), and newCell().

169  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< hgtrap > moduler_
std::pair< int, int > findCell(int cell, int lay, int subSec, bool reco) const
std::pair< int, float > getIndex(int lay, bool reco) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< hgtrap > modules_
int HGCalDDDConstants::maxCells ( bool  reco) const

Definition at line 197 of file HGCalDDDConstants.cc.

References depth_, i, layer_, and layers().

Referenced by HGCalDDDConstants(), HGCalTopology::HGCalTopology(), isValid(), maxCells(), HGCalGeometry::newCell(), and newCell().

197  {
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 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > depth_
unsigned int layers(bool reco) const
std::vector< int > layer_
int maxCells(bool reco) const
int HGCalDDDConstants::maxCells ( int  lay,
bool  reco 
) const

Definition at line 207 of file HGCalDDDConstants.cc.

References alpha, getIndex(), h, i, cmsHarvester::index, maxCells(), moduler_, and modules_.

207  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< hgtrap > moduler_
std::pair< int, float > getIndex(int lay, bool reco) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< hgtrap > modules_
int maxCells(bool reco) const
int HGCalDDDConstants::maxCells ( float  h,
float  bl,
float  tl,
float  alpha,
float  cellSize 
) const

Definition at line 227 of file HGCalDDDConstants.cc.

References a, b, and k_horizontalShift.

228  {
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 }
float alpha
Definition: AMPTWrapper.h:95
const double k_horizontalShift
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
int HGCalDDDConstants::maxRows ( int  lay,
bool  reco 
) const

Definition at line 245 of file HGCalDDDConstants.cc.

References getIndex(), h, i, cmsHarvester::index, moduler_, modules_, and dt_dqm_sourceclient_common_cff::reco.

Referenced by newCell().

245  {
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 }
int i
Definition: DBlmapReader.cc:9
std::vector< hgtrap > moduler_
std::pair< int, float > getIndex(int lay, bool reco) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< hgtrap > modules_
std::pair< int, int > HGCalDDDConstants::newCell ( int  cell,
int  layer,
int  sector,
int  subsector,
int  incrx,
int  incry,
bool  half 
) const

Definition at line 255 of file HGCalDDDConstants.cc.

References findCell(), maxCells(), maxRows(), and nSectors.

Referenced by HGCalTopology::changeXY(), and HGCalTopology::changeZ().

257  {
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 }
int maxRows(int lay, bool reco) const
std::pair< int, int > findCell(int cell, int lay, int subSec, bool reco) const
std::pair< int, int > newCell(int cell, int layer, int sector, int subsector, int incrx, int incry, bool half) const
int maxCells(bool reco) const
std::pair< int, int > HGCalDDDConstants::newCell ( int  cell,
int  layer,
int  subsector,
int  incrz,
bool  half 
) const

Definition at line 280 of file HGCalDDDConstants.cc.

References assignCell(), layers(), locateCell(), and create_public_lumi_plots::xy.

281  {
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 }
unsigned int layers(bool reco) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int subSec, bool reco) const
int HGCalDDDConstants::newCell ( int  kx,
int  ky,
int  lay,
int  subSec 
) const

Definition at line 292 of file HGCalDDDConstants.cc.

References a, alpha, b, getIndex(), h, i, cmsHarvester::index, k_horizontalShift, maxCells(), moduler_, and modules_.

292  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< hgtrap > moduler_
std::pair< int, float > getIndex(int lay, bool reco) const
const double k_horizontalShift
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
std::vector< hgtrap > modules_
int maxCells(bool reco) const
std::vector< int > HGCalDDDConstants::numberCells ( int  lay,
bool  reco 
) const

Definition at line 310 of file HGCalDDDConstants.cc.

References alpha, getIndex(), h, i, cmsHarvester::index, moduler_, and modules_.

310  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::vector< int > numberCells(int lay, bool reco) const
std::vector< hgtrap > moduler_
std::pair< int, float > getIndex(int lay, bool reco) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< hgtrap > modules_
std::vector< int > HGCalDDDConstants::numberCells ( float  h,
float  bl,
float  tl,
float  alpha,
float  cellSize 
) const

Definition at line 334 of file HGCalDDDConstants.cc.

References a, b, and k_horizontalShift.

336  {
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 }
float alpha
Definition: AMPTWrapper.h:95
const double k_horizontalShift
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
int HGCalDDDConstants::sectors ( ) const
inline

Definition at line 70 of file HGCalDDDConstants.h.

References nSectors.

Referenced by HGCalDDDConstants(), HGCalTopology::HGCalTopology(), and isValid().

70 {return nSectors;}
std::pair< int, int > HGCalDDDConstants::simToReco ( int  cell,
int  layer,
bool  half 
) const

Definition at line 347 of file HGCalDDDConstants.cc.

References a, alpha, b, cellFactor_, gather_cfg::cout, HLT_25ns14e33_v1_cff::depth, findCell(), getIndex(), h, i, cmsHarvester::index, k_horizontalShift, layerGroup_, and modules_.

Referenced by HGCDigitizer::accumulate().

348  {
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 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
std::pair< int, int > findCell(int cell, int lay, int subSec, bool reco) const
std::pair< int, float > getIndex(int lay, bool reco) const
const double k_horizontalShift
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
std::vector< int > layerGroup_
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
std::vector< hgtrap > modules_

Member Data Documentation

std::vector<int> HGCalDDDConstants::cellFactor_
private

Definition at line 91 of file HGCalDDDConstants.h.

Referenced by loadGeometry(), loadSpecPars(), and simToReco().

std::vector<double> HGCalDDDConstants::cellSize_
private

Definition at line 87 of file HGCalDDDConstants.h.

Referenced by loadGeometry(), and loadSpecPars().

std::vector<int> HGCalDDDConstants::depth_
private

Definition at line 91 of file HGCalDDDConstants.h.

Referenced by loadGeometry(), and maxCells().

std::vector<int> HGCalDDDConstants::depthIndex
private

Definition at line 91 of file HGCalDDDConstants.h.

Referenced by getIndex(), layers(), and loadGeometry().

std::vector<int> HGCalDDDConstants::layer_
private

Definition at line 90 of file HGCalDDDConstants.h.

Referenced by loadGeometry(), and maxCells().

std::vector<int> HGCalDDDConstants::layerGroup_
private

Definition at line 91 of file HGCalDDDConstants.h.

Referenced by loadGeometry(), loadSpecPars(), and simToReco().

std::vector<int> HGCalDDDConstants::layerIndex
private

Definition at line 90 of file HGCalDDDConstants.h.

Referenced by getIndex(), layers(), and loadGeometry().

std::vector<hgtrap> HGCalDDDConstants::moduler_
private
std::vector<hgtrap> HGCalDDDConstants::modules_
private
int HGCalDDDConstants::nCells
private

Definition at line 86 of file HGCalDDDConstants.h.

Referenced by initialize(), and loadSpecPars().

int HGCalDDDConstants::nLayers
private

Definition at line 86 of file HGCalDDDConstants.h.

int HGCalDDDConstants::nSectors
private

Definition at line 86 of file HGCalDDDConstants.h.

Referenced by initialize(), loadGeometry(), newCell(), and sectors().

std::vector<hgtrform> HGCalDDDConstants::trform_
private

Definition at line 89 of file HGCalDDDConstants.h.

Referenced by getFirstTrForm(), getLastTrForm(), and loadGeometry().