18 #include "CLHEP/Units/GlobalPhysicalConstants.h" 19 #include "CLHEP/Units/GlobalSystemOfUnits.h" 22 #include <unordered_set> 51 std::map<int,HGCalGeomParameters::layerParameters>
layers;
52 std::vector<HGCalParameters::hgtrform> trforms;
53 std::vector<bool> trformUse;
59 int nsiz = (
int)(copy.size());
60 int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
61 int zp = (nsiz > 2) ? copy[nsiz-3] : -1;
64 throw cms::Exception(
"DDException") <<
"Funny layer # " << lay <<
" zp " 65 << zp <<
" in " << nsiz
70 auto itr = layers.find(lay);
71 if (itr == layers.end()) {
80 fv.
rotation().GetComponents( x, y, z ) ;
81 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
83 x.Z(), y.Z(), z.Z() );
89 const CLHEP::Hep3Vector h3v ( xx, yy, fv.
translation().Z() );
97 trforms.emplace_back(mytrf);
98 trformUse.emplace_back(
false);
107 std::unordered_map<int32_t,int32_t> copies;
109 std::vector<int32_t> wafer2copy;
110 std::vector<HGCalGeomParameters::cellParameters> wafers;
112 DDValue val1(attribute, sdTag2, 0.0);
118 <<
" not found but needed.";
120 <<
" not found but needed.";
123 std::unordered_set<std::string>
names;
128 int nsiz = (
int)(copy.size());
129 int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
130 int layer = (nsiz > 1) ? copy[nsiz-2] : 0;
132 edm::LogError(
"HGCalGeom") <<
"Funny wafer # " << wafer <<
" in " 133 << nsiz <<
" components";
136 auto itr = copies.find(wafer);
137 auto cpy = copiesInLayers[layer].find(wafer);
138 if (itr != copies.end() && cpy == copiesInLayers[layer].end()) {
139 copiesInLayers[layer][wafer] = itr->second;
141 if (itr == copies.end()) {
142 copies[wafer] = wafer2copy.size();
143 copiesInLayers[layer][wafer] = wafer2copy.size();
148 wafer2copy.emplace_back(wafer);
151 wafers.emplace_back(cell);
152 if ( names.count(name) == 0 ) {
153 std::vector<double> zv, rv;
156 zv = polyhedra.
zVec();
165 double dz = 0.5*(zv[1]-zv[0]);
186 std::map<int,int> wafertype;
187 std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
188 DDValue val2(attribute, sdTag3, 0.0);
194 <<
" not found but needed.";
196 <<
" not found but needed.";
203 int nsiz = (
int)(copy.size());
204 int cellx= (nsiz > 0) ? copy[nsiz-1] : 0;
205 int wafer= (nsiz > 1) ? copy[nsiz-2] : 0;
206 int cell = cellx%1000;
207 int type = cellx/1000;
208 if (type != 1 && type != 2) {
209 edm::LogError(
"HGCalGeom") <<
"Funny cell # " << cell <<
" type " 210 << type <<
" in " << nsiz <<
" components";
213 auto ktr = wafertype.find(wafer);
214 if (ktr == wafertype.end()) wafertype[wafer] = type;
216 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
219 itr = cellsf.find(cell);
220 newc= (itr == cellsf.end());
222 itr = cellsc.find(cell);
223 newc= (itr == cellsc.end());
227 bool half = (name.find(
"Half") != std::string::npos);
237 << cellx <<
" local " << xx <<
":" 238 << yy <<
" new " << p1 <<
":"<<
p2;
253 if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) ||
255 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : number of cells " 256 << cellsf.size() <<
":" << cellsc.size()
257 <<
" wafers " << wafers.size() <<
" layers " 258 << layers.size() <<
" illegal";
260 <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells " 261 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
262 <<
" layers " << layers.size();
265 for (
unsigned int i=0;
i<layers.size(); ++
i) {
266 for (
auto & layer : layers) {
271 php.
zLayerHex_.emplace_back(layer.second.zpos);
276 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
277 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
278 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
281 trforms[i1].lay = (
i+1);
282 trformUse[i1] =
true;
285 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
286 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
290 trformUse[i2] =
true;
301 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i ) {
303 php.
waferPosX_.emplace_back(wafers[i].xyz.x());
304 php.
waferPosY_.emplace_back(wafers[i].xyz.y());
305 auto ktr = wafertype.find(wafer2copy[i]);
306 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
308 double r = wafers[
i].xyz.perp();
310 for (
int k=1;
k<4; ++
k) {
320 std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
321 for (
unsigned int i=0;
i<cellsf.size(); ++
i) {
322 auto itr = cellsf.find(
i);
323 if (itr == cellsf.end()) {
324 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 325 <<
" fine cell number " <<
i;
327 <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
329 double xx = (itr->second).xyz.x();
330 double yy = (itr->second).xyz.y();
331 int waf= (itr->second).wafer;
332 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
339 for (
unsigned int i=0;
i<cellsc.size(); ++
i) {
340 auto itr = cellsc.find(
i);
341 if (itr == cellsc.end()) {
342 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 343 <<
" coarse cell number " <<
i;
345 <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
347 double xx = (itr->second).xyz.x();
348 double yy = (itr->second).xyz.y();
349 int waf= (itr->second).wafer;
350 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
389 << php.
layer_[
k] <<
"] with r = " 411 << php.
waferR_ <<
" and dimensions of the " 428 <<
" fine cells in a wafer";
435 <<
" coarse cells in a wafer";
441 <<
" transformation matrices";
466 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
467 itr != theModules.end(); ++itr, ++k2) {
481 std::map<int,HGCalGeomParameters::layerParameters>
layers;
488 int nsiz = (
int)(copy.size());
489 int lay = (nsiz > levelTop) ? copy[nsiz-4] : copy[nsiz-1];
491 if (zside != 1) zside = -1;
493 edm::LogError(
"HGCalGeom") <<
"Funny layer # " << lay <<
" zp " 494 << zside <<
" in " << nsiz <<
" components";
499 auto itr = layers.find(lay);
500 if (itr == layers.end()) {
506 layers[lay] = laypar;
508 if (trforms.find(std::make_pair(lay,zside)) == trforms.end()) {
510 fv.
rotation().GetComponents( x, y, z ) ;
511 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
513 x.Z(), y.Z(), z.Z() );
519 const CLHEP::Hep3Vector h3v (xx, yy, fv.
translation().Z());
527 trforms[std::make_pair(lay,zside)] = mytrf;
533 double rmin(0), rmax(0);
534 for (
unsigned int i=0;
i<layers.size(); ++
i) {
535 for (
auto & layer : layers) {
536 if (layer.first == (
int)(
i+firstLayer)) {
540 php.
zLayerHex_.emplace_back(layer.second.zpos);
542 rmin = layer.second.rmin; rmax = layer.second.rmax;
544 if (rmin > layer.second.rmin) rmin = layer.second.rmin;
545 if (rmax < layer.second.rmax) rmax = layer.second.rmax;
551 php.
rLimit_.emplace_back(rmin);
552 php.
rLimit_.emplace_back(rmax);
557 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
558 for (
auto & trform : trforms) {
559 if (trform.first.first == (
int)(
i+firstLayer)) {
573 << php.
layer_[
k] <<
"] with r = " 579 <<
" transformation matrices";
611 <<
" for cell grouping " << php.
boundR_[0]
612 <<
":" << php.
boundR_[1] <<
":" 634 << php.
slopeMin_[0] <<
" and layer groupings " 635 <<
"for the 3 ranges:";
665 << php.
cellSize_.size() <<
" cells of sizes:";
687 <<
"parameters for 120 to 200 micron " 697 <<
"parameters for 200 to 300 micron " 773 <<
" cellSize: " << php.
cellSize_[0] <<
":" 826 << rmin <<
" R Limits: " << rin <<
":" 827 << rout <<
" Fine " << rMaxFine;
835 double dx = 0.5*waferW;
836 double dy = 3.0*dx*
tan(30.0*CLHEP::deg);
837 double rr = 2.0*dx*
tan(30.0*CLHEP::deg);
838 int ncol = (
int)(2.0*rout/waferW) + 1;
839 int nrow = (
int)(rout/(waferW*
tan(30.0*CLHEP::deg))) + 1;
840 int incm(0), inrm(0), kount(0), ntot(0);
846 for (
int nr=-nrow; nr <= nrow; ++nr) {
847 int inr = (nr >= 0) ? nr : -nr;
848 for (
int nc=-ncol; nc <=
ncol; ++nc) {
849 int inc = (nc >= 0) ? nc : -nc;
850 if (inr%2 == inc%2) {
853 xc[0] = xpos+
dx; yc[0] = ypos-0.5*
rr;
854 xc[1] = xpos+
dx; yc[1] = ypos+0.5*
rr;
855 xc[2] = xpos; yc[2] = ypos+
rr;
856 xc[3] = xpos-
dx; yc[3] = ypos+0.5*
rr;
857 xc[4] = xpos+
dx; yc[4] = ypos-0.5*
rr;
858 xc[5] = xpos; yc[5] = ypos-
rr;
859 bool cornerOne(
false);
862 if (rpos >= rin && rpos <= rout) cornerOne =
true;
864 double rpos =
std::sqrt(xpos*xpos+ypos*ypos);
865 int typet = (rpos < rMaxFine) ? 1 : 2;
867 for (
int k=1;
k<4; ++
k) {
874 int copy = inr*100 + inc;
875 if (nc < 0) copy += 10000;
876 if (nr < 0) copy += 100000;
877 if (inc > incm) incm = inc;
878 if (inr > inrm) inrm = inr;
882 << copy <<
" Type " << typel <<
":" 883 << typet <<
" Location " << cornerOne
884 <<
" Position " << xpos <<
":" << ypos
885 <<
" Layers " << php.
layer_.size();
892 for (
unsigned int il=0; il<php.
layer_.size(); ++il) {
893 bool corner(
false), cornerAll(
true);
898 else cornerAll =
false;
901 auto cpy = copiesInLayers[php.
layer_[il]].find(copy);
902 if (cpy == copiesInLayers[php.
layer_[il]].end())
903 copiesInLayers[php.
layer_[il]][copy] = cornerAll ? php.
waferCopy_.size() : -1;
915 << incm <<
" # of rows " << inrm <<
" and " 916 << kount <<
":" << ntot <<
" wafers; R " 917 << rin <<
":" << rout;
920 for (
unsigned int k=0;
k<copiesInLayers.size(); ++
k) {
921 const auto& theModules = copiesInLayers[
k];
924 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
925 itr != theModules.end(); ++itr,++k2) {
948 << waferS <<
" R Max: " << rout;
956 double r = 0.5*(waferW+waferS);
959 int N = (r == 0) ? 3 : ((
int)(0.5*rout/
r) + 3);
960 int ns1 = (2*N+1)*(2*N+1);
964 <<
" sizes " << ns1 <<
":" << ns2;
965 std::vector<int> indtypes(ns1+1);
970 int ipos(0), lpos(0), uvmax(0);
971 std::vector<int> uvmx(php.
zLayerHex_.size(),0);
973 for (
int v = -N;
v <=
N; ++
v) {
974 for (
int u = -N; u <=
N; ++u) {
983 wafersInLayers[indx] = ipos;
985 xc[0] = xpos+
r; yc[0] = ypos+0.5*
R;
986 xc[1] = xpos; yc[1] = ypos+
R;
987 xc[2] = xpos-
r; yc[2] = ypos+0.5*
R;
988 xc[3] = xpos-
r; yc[3] = ypos-0.5*
R;
989 xc[4] = xpos; yc[4] = ypos-
R;
990 xc[5] = xpos+
r; yc[5] = ypos-0.5*
R;
991 bool cornerOne(
false), cornerAll(
true);
993 double rpos =
sqrt(xc[
k]*xc[
k]+yc[
k]*yc[
k]);
994 if (rpos <= rout) cornerOne =
true;
995 else cornerAll =
false;
997 if ((cornerAll) || (cornerOne && php.
defineFull_)) {
1006 typesInLayers[kndx] = lpos;
1009 indtypes.emplace_back(kndx);
1011 bool cornerOne(
false), cornerAll(
true);
1013 double rpos =
sqrt(xc[
k]*xc[
k]+yc[
k]*yc[
k]);
1015 else cornerAll =
false;
1017 if ((cornerAll) || (cornerOne && php.
defineFull_)) {
1061 int id = indtypes[
k];
1064 <<
" ID " << std::hex <<
id <<
std::dec 1089 <<
" rows for fine cells";
1094 <<
" rows for coarse cells";
1102 for (
unsigned k=0;
k<2; ++
k) {
1103 double rmax = ((
k == 0) ?
1107 double zv = ((
k == 0) ?
1115 <<
"\n[0] new R = " << rv <<
" Eta = " 1125 <<
" Eta = " <<
eta;
1134 std::vector<double>::iterator low, high;
1185 <<
" Low edge " << irlow <<
":" << drlow
1186 <<
" Top edge " << irhigh <<
":" << drhigh;
1200 << kk <<
" Radius range " 1210 mytr.
h = 0.5*(rmax-rmin);
1240 const std::vector<double> & fvec = value.
doubles();
1241 int nval = fvec.size();
1244 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
1245 <<
" bins " << nval <<
" < " << nmin
1247 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1250 if (nval < 1 && nmin == 0) {
1251 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
1252 <<
" bins " << nval <<
" < 1 ==> illegal" 1253 <<
" (nmin=" << nmin <<
")";
1254 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1260 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array " 1262 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1264 std::vector<double> fvec;
1269 std::pair<double,double>
1271 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
1272 int wafer,
double xx,
double yy) {
1274 if (itrf == wafers.end()) {
1275 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
1276 itr != wafers.end(); ++itr) {
1277 if (itr->wafer == wafer) {
1283 double dx(0),
dy(0);
1284 if (itrf != wafers.end()) {
1285 dx = (xx - itrf->xyz.x());
1287 dy = (yy - itrf->xyz.y());
1290 return std::pair<double,double>(
dx,
dy);
std::vector< int > iradMaxBH_
std::vector< double > waferPosY_
std::vector< int > layer_
std::vector< double > moduleDzR_
std::vector< int > depthLayerF_
std::vector< int > depth_
std::vector< double > zFrontMin_
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_
std::vector< bool > cellFineHalf_
std::vector< double > rMaxVec(void) const
int scintType(const int layer) 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_
static int32_t waferV(const int32_t index)
std::vector< double > moduleHS_
static int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV)
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_
Compact representation of the geometrical detector hierarchy.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
const std::string names[nVars_]
double scintCellSize(const int layer) const
std::vector< double > trformRotXX_
std::vector< int > nPhiBinBH_
void loadSpecParsHexagon8(const DDFilteredView &, HGCalParameters &)
A DDSolid represents the shape of a part.
void fillTrForm(const hgtrform &mytr)
wafer_map wafersInLayers_
std::vector< double > rMinLayerBH_
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 > firstModule_
std::vector< int > cellCoarse_
std::vector< double > trformRotYZ_
void loadCellTrapezoid(HGCalParameters &php)
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_
std::vector< int > waferUVMaxLayer_
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)
static double k_ScaleFromDDD
std::vector< double > trformRotXY_
std::vector< double > rMaxFront_
Cos< T >::type cos(const T &t)
std::vector< double > trformRotYX_
int scintCells(const int layer) const
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 > slopeTop_
static int32_t waferU(const int32_t index)
std::vector< double > moduleBlR_
void loadSpecParsTrapezoid(const DDFilteredView &, HGCalParameters &)
std::vector< double > rMinLayHex_
void loadGeometryHexagon8(const DDFilteredView &, HGCalParameters &, int)
void fillModule(const hgtrap &mytr, bool reco)
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, const int)
std::vector< double > moduleTlS_
static int32_t waferLayer(const int32_t index)
std::vector< double > zLayerHex_
std::vector< double > get(const std::string &)
void loadWaferHexagon(HGCalParameters &php)
std::vector< double > rMaxLayHex_
static uint32_t k_CornerSize
std::vector< double > trformTranX_
std::vector< double > zRanges_
std::vector< double > slopeMin_
std::vector< int > lastModule_
std::vector< double > zVec(void) const
std::vector< double > radiusMixBoundary_
std::vector< double > cellThickness_
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_
std::unordered_map< int32_t, int32_t > wafer_map
static double k_ScaleToDDD
std::vector< double > radius200to300_
std::vector< double > radius100to200_
DDsvalues_type mergedSpecifics() const
std::vector< double > rMinFront_
std::vector< int > iradMinBH_
std::vector< double > trformRotYY_
std::vector< double > cellFineX_
std::vector< double > trformRotZZ_
std::vector< double > moduleAlphaS_
std::vector< int > layerGroupO_
std::vector< double > moduleBlS_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
bool firstChild()
set the current node to the first child ...
std::vector< int > waferCopy_
std::vector< int > depthIndex_
std::vector< int > layerFrontBH_
std::vector< double > rLimit_
std::vector< double > zFrontTop_
std::vector< double > radiusLayer_[2]
std::vector< int > waferTypeT_
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< int > levelT_
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_
const std::string & name() const
Returns the name.
void loadWaferHexagon8(HGCalParameters &php)
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)