17 #include "CLHEP/Units/GlobalPhysicalConstants.h" 18 #include "CLHEP/Units/GlobalSystemOfUnits.h" 19 #include <unordered_set> 27 std::cout <<
"HGCalGeomParameters::HGCalGeomParameters() constructor\n";
33 std::cout <<
"HGCalGeomParameters::destructed!!!\n";
47 std::map<int,HGCalGeomParameters::layerParameters>
layers;
48 std::vector<HGCalParameters::hgtrform> trforms;
49 std::vector<bool> trformUse;
56 int nsiz = (
int)(copy.size());
57 int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
58 int zp = (nsiz > 2) ? copy[nsiz-3] : -1;
61 edm::LogError(
"HGCalGeom") <<
"Funny layer # " << lay <<
" zp " 62 << zp <<
" in " << nsiz <<
" components";
67 std::map<int,HGCalGeomParameters::layerParameters>::iterator itr = layers.find(lay);
68 if (itr == layers.end()) {
77 fv.
rotation().GetComponents( x, y, z ) ;
78 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
80 x.Z(), y.Z(), z.Z() );
86 const CLHEP::Hep3Vector h3v ( xx, yy, fv.
translation().Z() );
94 trforms.emplace_back(mytrf);
95 trformUse.emplace_back(
false);
104 std::unordered_map<int32_t,int32_t> copies;
106 std::vector<int32_t> wafer2copy;
107 std::vector<HGCalGeomParameters::cellParameters> wafers;
109 DDValue val1(attribute, sdTag2, 0.0);
115 <<
" not found but needed.";
117 <<
" not found but needed.";
120 std::unordered_set<std::string>
names;
125 int nsiz = (
int)(copy.size());
126 int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
127 int layer = (nsiz > 1) ? copy[nsiz-2] : 0;
129 edm::LogError(
"HGCalGeom") <<
"Funny wafer # " << wafer <<
" in " 130 << nsiz <<
" components";
133 std::unordered_map<int32_t,int32_t>::iterator itr = copies.find(wafer);
134 std::unordered_map<int32_t,int32_t>::iterator cpy =
135 copiesInLayers[layer].find(wafer);
136 if (itr != copies.end() && cpy == copiesInLayers[layer].end()) {
137 copiesInLayers[layer][wafer] = itr->second;
139 if (itr == copies.end()) {
140 copies[wafer] = wafer2copy.size();
141 copiesInLayers[layer][wafer] = wafer2copy.size();
146 wafer2copy.emplace_back(wafer);
149 wafers.emplace_back(cell);
150 if ( names.count(name) == 0 ) {
151 std::vector<double> zv, rv;
154 zv = polyhedra.
zVec();
162 double dz = 0.5*(zv[1]-zv[0]);
182 std::map<int,int> wafertype;
183 std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
184 DDValue val2(attribute, sdTag3, 0.0);
190 <<
" not found but needed.";
192 <<
" not found but needed.";
199 int nsiz = (
int)(copy.size());
200 int cellx= (nsiz > 0) ? copy[nsiz-1] : 0;
201 int wafer= (nsiz > 1) ? copy[nsiz-2] : 0;
202 int cell = cellx%1000;
203 int type = cellx/1000;
204 if (type != 1 && type != 2) {
205 edm::LogError(
"HGCalGeom") <<
"Funny cell # " << cell <<
" type " 206 << type <<
" in " << nsiz <<
" components";
209 std::map<int,int>::iterator ktr = wafertype.find(wafer);
210 if (ktr == wafertype.end()) wafertype[wafer] = type;
212 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
215 itr = cellsf.find(cell);
216 newc= (itr == cellsf.end());
218 itr = cellsc.find(cell);
219 newc= (itr == cellsc.end());
223 bool half = (name.find(
"Half") != std::string::npos);
232 std::cout <<
"Type " << type <<
" Cell " << cellx <<
" local " 233 << xx <<
":" << yy <<
" new " << p1 <<
":" << p2 <<
"\n";
248 if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) ||
250 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : number of cells " 251 << cellsf.size() <<
":" << cellsc.size()
252 <<
" wafers " << wafers.size() <<
" layers " 253 << layers.size() <<
" illegal";
255 <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells " 256 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
257 <<
" layers " << layers.size();
260 for (
unsigned int i=0;
i<layers.size(); ++
i) {
261 for (
auto & layer : layers) {
262 if (layer.first == (
int)(
i+1)) {
266 php.
zLayerHex_.emplace_back(layer.second.zpos);
271 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
272 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
273 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
276 trforms[i1].lay = (
i+1);
277 trformUse[i1] =
true;
280 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
281 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
285 trformUse[i2] =
true;
296 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i ) {
298 php.
waferPosX_.emplace_back(wafers[i].xyz.x());
299 php.
waferPosY_.emplace_back(wafers[i].xyz.y());
300 std::map<int,int>::iterator ktr = wafertype.find(wafer2copy[i]);
301 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
303 double r = wafers[
i].xyz.perp();
305 for (
int k=1;
k<4; ++
k) {
315 std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
316 for (
unsigned int i=0;
i<cellsf.size(); ++
i) {
317 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsf.find(
i);
318 if (itr == cellsf.end()) {
319 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 320 <<
" fine cell number " <<
i;
322 <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
324 double xx = (itr->second).xyz.x();
325 double yy = (itr->second).xyz.y();
326 int waf= (itr->second).wafer;
327 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
334 for (
unsigned int i=0;
i<cellsc.size(); ++
i) {
335 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsc.find(
i);
336 if (itr == cellsc.end()) {
337 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 338 <<
" coarse cell number " <<
i;
340 <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
342 double xx = (itr->second).xyz.x();
343 double yy = (itr->second).xyz.y();
344 int waf= (itr->second).wafer;
345 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
379 <<
" layers" << std::endl;
388 <<
" depths" <<std::endl;
391 std::cout <<
"Reco Layer[" <<
i <<
":" << k <<
"] First Layer " 400 <<
" and dimensions of the wafers:" << std::endl;
410 <<
" fine cells in a wafer" << std::endl;
415 <<
" coarse cells in a wafer" << std::endl;
420 <<
" transformation matrices" << std::endl;
435 std::cout <<
"Layer " <<
k <<
":" << theModules.size() << std::endl;
437 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
438 itr != theModules.end(); ++itr) {
439 std::cout <<
" " << itr->first <<
":" << itr->second;
441 if (k2 > 9) {
std::cout << std::endl; k2 = 0; }
460 std::cout <<
"HGCalGeomParameters: wafer radius ranges for cell grouping " 469 std::cout <<
"HGCalGeomParameters: Minimum/maximum R " 485 std::vector<double> slp =
getDDDArray(
"Slope",sv,nmin);
489 <<
" and layer groupings for the 3 ranges:" << std::endl;
490 for (
int k=0; k<nmin; ++
k)
518 std::cout <<
"HGCalGeomParameters: " << php.cellSize_.size()
519 <<
" cells of sizes:\n";
520 for (
unsigned int k=0;
k<php.cellSize_.size(); ++
k)
521 std::cout <<
" [" <<
k <<
"] " << php.cellSize_[
k] <<
"\n";
531 std::cout <<
"Input waferWidth " << waferW <<
":" << rmin
532 <<
" R Limits: " << rin <<
":" << rout
533 <<
" Fine " << rMaxFine <<
"\n";
541 double dx = 0.5*waferW;
542 double dy = 3.0*dx*
tan(30.0*CLHEP::deg);
543 double rr = 2.0*dx*
tan(30.0*CLHEP::deg);
544 int ncol = (
int)(2.0*rout/waferW) + 1;
545 int nrow = (
int)(rout/(waferW*
tan(30.0*CLHEP::deg))) + 1;
546 int incm(0), inrm(0), kount(0), ntot(0);
550 std::cout <<
"Row " << nrow <<
" Column " << ncol << std::endl;
552 for (
int nr=-nrow; nr <= nrow; ++nr) {
553 int inr = (nr >= 0) ? nr : -nr;
554 for (
int nc=-ncol; nc <=
ncol; ++nc) {
555 int inc = (nc >= 0) ? nc : -nc;
556 if (inr%2 == inc%2) {
559 xc[0] = xpos+
dx; yc[0] = ypos-0.5*
rr;
560 xc[1] = xpos+
dx; yc[1] = ypos+0.5*
rr;
561 xc[2] = xpos; yc[2] = ypos+
rr;
562 xc[3] = xpos-
dx; yc[3] = ypos+0.5*
rr;
563 xc[4] = xpos+
dx; yc[4] = ypos-0.5*
rr;
564 xc[5] = xpos; yc[5] = ypos-
rr;
565 bool cornerOne(
false);
566 bool cornerAll(
true);
567 for (
int k=0;
k<6; ++
k) {
569 if (rpos >= rin && rpos <= rout) cornerOne =
true;
570 else cornerAll =
false;
572 double rpos =
std::sqrt(xpos*xpos+ypos*ypos);
573 int typet = (rpos < rMaxFine) ? 1 : 2;
575 for (
int k=1;
k<4; ++
k) {
582 int copy = inr*100 + inc;
583 if (nc < 0) copy += 10000;
584 if (nr < 0) copy += 100000;
585 if (inc > incm) incm = inc;
586 if (inr > inrm) inrm = inr;
589 std::cout << kount <<
":" << ntot <<
" Copy " << copy
590 <<
" Type " << typel <<
":" << typet
591 <<
" Location " << cornerOne <<
":" << cornerAll
592 <<
" Position " << xpos <<
":" << ypos <<
"\n";
599 for (
unsigned int il=0; il<php.
layer_.size(); ++il) {
602 for (
int k=0;
k<6; ++
k) {
606 else cornerAll =
false;
609 std::unordered_map<int32_t,int32_t>::iterator cpy =
610 copiesInLayers[php.
layer_[il]].find(copy);
611 if (cpy == copiesInLayers[php.
layer_[il]].end())
612 copiesInLayers[php.
layer_[il]][copy] = cornerAll ? php.
waferCopy_.size() : -1;
622 std::cout <<
"HGCalWaferHexagon: # of columns " << incm <<
" # of rows " 623 << inrm <<
" and " << kount <<
":" << ntot <<
" wafers; R " 624 << rin <<
":" << rout << std::endl;
627 for (
unsigned int k=0;
k<copiesInLayers.size(); ++
k) {
628 const auto& theModules = copiesInLayers[
k];
629 std::cout <<
"Layer " <<
k <<
":" << theModules.size() << std::endl;
631 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
632 itr != theModules.end(); ++itr) {
633 std::cout <<
" " << itr->first <<
":" << itr->second;
635 if (k2 > 9) {
std::cout << std::endl; k2 = 0; }
658 <<
" rows for fine cells\n";
663 <<
" rows for coarse cells\n";
675 const std::vector<double> & fvec = value.
doubles();
676 int nval = fvec.size();
679 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
680 <<
" bins " << nval <<
" < " << nmin
682 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
685 if (nval < 1 && nmin == 0) {
686 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
687 <<
" bins " << nval <<
" < 1 ==> illegal" 688 <<
" (nmin=" << nmin <<
")";
689 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
696 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array " 698 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
700 std::vector<double> fvec;
706 std::pair<double,double>
708 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
709 int wafer,
double xx,
double yy) {
711 if (itrf == wafers.end()) {
712 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
713 itr != wafers.end(); ++itr) {
714 if (itr->wafer == wafer) {
721 if (itrf != wafers.end()) {
722 dx = (xx - itrf->xyz.x());
724 dy = (yy - itrf->xyz.y());
727 return std::pair<double,double>(
dx,
dy);
std::vector< double > waferPosY_
std::vector< int > layer_
std::vector< double > moduleDzR_
std::vector< int > depthLayerF_
std::vector< int > depth_
std::vector< double > moduleHR_
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
layer_map copiesInLayers_
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
std::vector< bool > cellCoarseHalf_
static const HistoName names[]
std::vector< bool > cellFineHalf_
std::vector< double > rMaxVec(void) const
std::vector< int > moduleLayR_
nav_type copyNumbers() const
return the stack of copy numbers
void loadSpecParsHexagon(const DDFilteredView &, HGCalParameters &, const DDCompactView *, const std::string &, const std::string &)
std::vector< int > cellFine_
std::vector< double > moduleHS_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
std::vector< double > trformTranY_
Global3DPoint GlobalPoint
std::vector< double > cellFineY_
std::vector< double > trformRotZY_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::vector< uint32_t > trformIndex_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< int > layerGroupM_
type of data representation of DDCompactView
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
std::vector< double > trformRotXX_
A DDSolid represents the shape of a part.
void fillTrForm(const hgtrform &mytr)
std::vector< double > trformRotZX_
std::vector< double > xVec(void) const
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
std::vector< double > cellCoarseX_
std::vector< int > cellCoarse_
std::vector< double > trformRotYZ_
std::pair< double, double > cellPosition(const std::vector< cellParameters > &wafers, std::vector< cellParameters >::const_iterator &itrf, int wafer, double xx, double yy)
std::vector< double > boundR_
std::vector< double > cellSize_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
std::vector< double > moduleDzS_
bool next()
set current node to the next node in the filtered tree
std::vector< int > layerIndex_
std::vector< double > moduleAlphaR_
void loadCellParsHexagon(const DDCompactView *cpv, HGCalParameters &php)
std::vector< double > trformRotXY_
Cos< T >::type cos(const T &t)
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::...
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, int &)
std::vector< double > trformRotYX_
hgtrap getModule(unsigned int k, bool reco) const
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::vector< std::unordered_map< int32_t, int32_t > > layer_map
std::vector< double > moduleBlR_
std::vector< double > rMinLayHex_
void fillModule(const hgtrap &mytr, bool reco)
std::vector< double > moduleTlS_
std::vector< double > zLayerHex_
std::vector< double > get(const std::string &)
void loadWaferHexagon(HGCalParameters &php)
std::vector< double > rMaxLayHex_
std::vector< double > trformTranX_
std::vector< double > zVec(void) const
std::vector< double > trformRotXZ_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > XYZPointD
point in space with cartesian internal representation
std::vector< double > zVec(void) const
std::vector< int > layerGroup_
DDsvalues_type mergedSpecifics() const
std::vector< double > trformRotYY_
std::vector< double > cellFineX_
std::vector< double > trformRotZZ_
std::vector< double > moduleAlphaS_
std::vector< int > layerGroupO_
std::vector< double > moduleBlS_
bool firstChild()
set the current node to the first child ...
std::vector< int > waferCopy_
const double k_ScaleFromDDD
std::vector< int > depthIndex_
std::vector< double > rLimit_
std::vector< int > waferTypeT_
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< double > cellCoarseY_
std::vector< int > moduleLayS_
std::vector< double > trformTranZ_
std::vector< double > waferPosX_
void addTrForm(const CLHEP::Hep3Vector &h3v)
std::vector< double > moduleTlR_
std::vector< int > waferTypeL_
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)