19 #include "CLHEP/Units/GlobalPhysicalConstants.h" 20 #include "CLHEP/Units/GlobalSystemOfUnits.h" 23 #include <unordered_set> 52 std::map<int,HGCalGeomParameters::layerParameters>
layers;
53 std::vector<HGCalParameters::hgtrform> trforms;
54 std::vector<bool> trformUse;
60 int nsiz = (
int)(copy.size());
61 int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
62 int zp = (nsiz > 2) ? copy[nsiz-3] : -1;
65 throw cms::Exception(
"DDException") <<
"Funny layer # " << lay <<
" zp " 66 << zp <<
" in " << nsiz
71 auto itr = layers.find(lay);
72 if (itr == layers.end()) {
81 fv.
rotation().GetComponents( x, y, z ) ;
82 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
84 x.Z(), y.Z(), z.Z() );
90 const CLHEP::Hep3Vector h3v ( xx, yy, fv.
translation().Z() );
98 trforms.emplace_back(mytrf);
99 trformUse.emplace_back(
false);
108 std::unordered_map<int32_t,int32_t> copies;
110 std::vector<int32_t> wafer2copy;
111 std::vector<HGCalGeomParameters::cellParameters> wafers;
113 DDValue val1(attribute, sdTag2, 0.0);
119 <<
" not found but needed.";
121 <<
" not found but needed.";
124 std::unordered_set<std::string>
names;
129 int nsiz = (
int)(copy.size());
130 int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
131 int layer = (nsiz > 1) ? copy[nsiz-2] : 0;
133 edm::LogError(
"HGCalGeom") <<
"Funny wafer # " << wafer <<
" in " 134 << nsiz <<
" components";
137 auto itr = copies.find(wafer);
138 auto cpy = copiesInLayers[layer].find(wafer);
139 if (itr != copies.end() && cpy == copiesInLayers[layer].end()) {
140 copiesInLayers[layer][wafer] = itr->second;
142 if (itr == copies.end()) {
143 copies[wafer] = wafer2copy.size();
144 copiesInLayers[layer][wafer] = wafer2copy.size();
149 wafer2copy.emplace_back(wafer);
152 wafers.emplace_back(cell);
153 if ( names.count(name) == 0 ) {
154 std::vector<double> zv, rv;
157 zv = polyhedra.
zVec();
166 double dz = 0.5*(zv[1]-zv[0]);
187 std::map<int,int> wafertype;
188 std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
189 DDValue val2(attribute, sdTag3, 0.0);
195 <<
" not found but needed.";
197 <<
" not found but needed.";
204 int nsiz = (
int)(copy.size());
205 int cellx= (nsiz > 0) ? copy[nsiz-1] : 0;
206 int wafer= (nsiz > 1) ? copy[nsiz-2] : 0;
207 int cell = cellx%1000;
208 int type = cellx/1000;
209 if (type != 1 && type != 2) {
210 edm::LogError(
"HGCalGeom") <<
"Funny cell # " << cell <<
" type " 211 << type <<
" in " << nsiz <<
" components";
214 auto ktr = wafertype.find(wafer);
215 if (ktr == wafertype.end()) wafertype[wafer] = type;
217 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
220 itr = cellsf.find(cell);
221 newc= (itr == cellsf.end());
223 itr = cellsc.find(cell);
224 newc= (itr == cellsc.end());
228 bool half = (name.find(
"Half") != std::string::npos);
238 << cellx <<
" local " << xx <<
":" 239 << yy <<
" new " << p1 <<
":"<<
p2;
254 if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) ||
256 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : number of cells " 257 << cellsf.size() <<
":" << cellsc.size()
258 <<
" wafers " << wafers.size() <<
" layers " 259 << layers.size() <<
" illegal";
261 <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells " 262 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
263 <<
" layers " << layers.size();
266 for (
unsigned int i=0;
i<layers.size(); ++
i) {
267 for (
auto & layer : layers) {
272 php.
zLayerHex_.emplace_back(layer.second.zpos);
277 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
278 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
279 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
282 trforms[i1].lay = (
i+1);
283 trformUse[i1] =
true;
286 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
287 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
291 trformUse[i2] =
true;
302 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i ) {
304 php.
waferPosX_.emplace_back(wafers[i].xyz.x());
305 php.
waferPosY_.emplace_back(wafers[i].xyz.y());
306 auto ktr = wafertype.find(wafer2copy[i]);
307 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
309 double r = wafers[
i].xyz.perp();
311 for (
int k=1;
k<4; ++
k) {
321 std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
322 for (
unsigned int i=0;
i<cellsf.size(); ++
i) {
323 auto itr = cellsf.find(
i);
324 if (itr == cellsf.end()) {
325 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 326 <<
" fine cell number " <<
i;
328 <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
330 double xx = (itr->second).xyz.x();
331 double yy = (itr->second).xyz.y();
332 int waf= (itr->second).wafer;
333 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
340 for (
unsigned int i=0;
i<cellsc.size(); ++
i) {
341 auto itr = cellsc.find(
i);
342 if (itr == cellsc.end()) {
343 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 344 <<
" coarse cell number " <<
i;
346 <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
348 double xx = (itr->second).xyz.x();
349 double yy = (itr->second).xyz.y();
350 int waf= (itr->second).wafer;
351 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
390 << php.
layer_[
k] <<
"] with r = " 412 << php.
waferR_ <<
" and dimensions of the " 429 <<
" fine cells in a wafer";
436 <<
" coarse cells in a wafer";
442 <<
" transformation matrices";
467 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
468 itr != theModules.end(); ++itr, ++k2) {
482 std::map<int,HGCalGeomParameters::layerParameters>
layers;
489 int nsiz = (
int)(copy.size());
490 int lay = (nsiz > levelTop) ? copy[nsiz-4] : copy[nsiz-1];
492 if (zside != 1) zside = -1;
494 edm::LogError(
"HGCalGeom") <<
"Funny layer # " << lay <<
" zp " 495 << zside <<
" in " << nsiz <<
" components";
500 auto itr = layers.find(lay);
501 if (itr == layers.end()) {
507 layers[lay] = laypar;
509 if (trforms.find(std::make_pair(lay,zside)) == trforms.end()) {
511 fv.
rotation().GetComponents( x, y, z ) ;
512 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
514 x.Z(), y.Z(), z.Z() );
520 const CLHEP::Hep3Vector h3v (xx, yy, fv.
translation().Z());
528 trforms[std::make_pair(lay,zside)] = mytrf;
534 double rmin(0), rmax(0);
535 for (
unsigned int i=0;
i<layers.size(); ++
i) {
536 for (
auto & layer : layers) {
537 if (layer.first == (
int)(
i+firstLayer)) {
541 php.
zLayerHex_.emplace_back(layer.second.zpos);
543 rmin = layer.second.rmin; rmax = layer.second.rmax;
545 if (rmin > layer.second.rmin) rmin = layer.second.rmin;
546 if (rmax < layer.second.rmax) rmax = layer.second.rmax;
552 php.
rLimit_.emplace_back(rmin);
553 php.
rLimit_.emplace_back(rmax);
558 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
559 for (
auto & trform : trforms) {
560 if (trform.first.first == (
int)(
i+firstLayer)) {
574 << php.
layer_[
k] <<
"] with r = " 580 <<
" transformation matrices";
612 <<
" for cell grouping " << php.
boundR_[0]
613 <<
":" << php.
boundR_[1] <<
":" 635 << php.
slopeMin_[0] <<
" and layer groupings " 636 <<
"for the 3 ranges:";
666 << php.
cellSize_.size() <<
" cells of sizes:";
688 <<
"parameters for 120 to 200 micron " 698 <<
"parameters for 200 to 300 micron " 774 <<
" cellSize: " << php.
cellSize_[0] <<
":" 827 << rmin <<
" R Limits: " << rin <<
":" 828 << rout <<
" Fine " << rMaxFine;
836 double dx = 0.5*waferW;
837 double dy = 3.0*dx*
tan(30.0*CLHEP::deg);
838 double rr = 2.0*dx*
tan(30.0*CLHEP::deg);
839 int ncol = (
int)(2.0*rout/waferW) + 1;
840 int nrow = (
int)(rout/(waferW*
tan(30.0*CLHEP::deg))) + 1;
841 int ns2 = (2*ncol+1)*(2*nrow+1)*php.
layer_.size();
842 int incm(0), inrm(0), kount(0), ntot(0);
848 for (
int nr=-nrow; nr <= nrow; ++nr) {
849 int inr = (nr >= 0) ? nr : -nr;
850 for (
int nc=-ncol; nc <=
ncol; ++nc) {
851 int inc = (nc >= 0) ? nc : -nc;
852 if (inr%2 == inc%2) {
855 std::pair<int,int>
corner =
857 double rpos =
std::sqrt(xpos*xpos+ypos*ypos);
858 int typet = (rpos < rMaxFine) ? 1 : 2;
860 for (
int k=1;
k<4; ++
k) {
866 if (corner.first > 0) {
867 int copy = inr*100 + inc;
868 if (nc < 0) copy += 10000;
869 if (nr < 0) copy += 100000;
870 if (inc > incm) incm = inc;
871 if (inr > inrm) inrm = inr;
875 << copy <<
" Type " << typel <<
":" 876 << typet <<
" Location " << corner.first
877 <<
" Position " << xpos <<
":" << ypos
878 <<
" Layers " << php.
layer_.size();
885 for (
unsigned int il=0; il<php.
layer_.size(); ++il) {
886 std::pair<int,int> corner =
890 if (corner.first > 0) {
891 auto cpy = copiesInLayers[php.
layer_[il]].find(copy);
892 if (cpy == copiesInLayers[php.
layer_[il]].end())
895 if ((corner.first > 0) &&
898 waferTypes[wl] = std::make_pair(corner.first,corner.second);
911 << incm <<
" # of rows " << inrm <<
" and " 912 << kount <<
":" << ntot <<
" wafers; R " 913 << rin <<
":" << rout;
916 for (
unsigned int k=0;
k<copiesInLayers.size(); ++
k) {
917 const auto& theModules = copiesInLayers[
k];
920 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
921 itr != theModules.end(); ++itr,++k2) {
944 << waferS <<
" R Max: " << rout;
952 double r = 0.5*(waferW+waferS);
955 int N = (r == 0) ? 3 : ((
int)(0.5*rout/
r) + 3);
956 int ns1 = (2*N+1)*(2*N+1);
960 <<
" sizes " << ns1 <<
":" << ns2;
961 std::vector<int> indtypes(ns1+1);
967 int ipos(0), lpos(0), uvmax(0);
968 std::vector<int> uvmx(php.
zLayerHex_.size(),0);
969 for (
int v = -N;
v <=
N; ++
v) {
970 for (
int u = -N; u <=
N; ++u) {
979 wafersInLayers[indx] = ipos;
981 std::pair<int,int>
corner =
993 typesInLayers[kndx] = lpos;
996 indtypes.emplace_back(kndx);
998 std::pair<int,int> corner =
1008 << u <<
" v " << v <<
" with " 1009 << corner.first <<
" corners";
1017 (corner.first > 0)) {
1020 <<
":" << v <<
" with " 1021 << corner.first <<
" corners First " 1025 waferTypes[wl] = std::make_pair(corner.first,corner.second);
1069 int id = indtypes[
k];
1072 <<
" ID " << std::hex <<
id <<
std::dec 1097 <<
" rows for fine cells";
1102 <<
" rows for coarse cells";
1110 for (
unsigned k=0;
k<2; ++
k) {
1111 double rmax = ((
k == 0) ?
1115 double zv = ((
k == 0) ?
1123 <<
"\n[0] new R = " << rv <<
" Eta = " 1133 <<
" Eta = " <<
eta;
1142 std::vector<double>::iterator low, high;
1193 <<
" Low edge " << irlow <<
":" << drlow
1194 <<
" Top edge " << irhigh <<
":" << drhigh;
1208 << kk <<
" Radius range " 1218 mytr.
h = 0.5*(rmax-rmin);
1248 const std::vector<double> & fvec = value.
doubles();
1249 int nval = fvec.size();
1252 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
1253 <<
" bins " << nval <<
" < " << nmin
1255 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1258 if (nval < 1 && nmin == 0) {
1259 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
1260 <<
" bins " << nval <<
" < 1 ==> illegal" 1261 <<
" (nmin=" << nmin <<
")";
1262 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1268 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array " 1270 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1272 std::vector<double> fvec;
1277 std::pair<double,double>
1279 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
1280 int wafer,
double xx,
double yy) {
1282 if (itrf == wafers.end()) {
1283 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
1284 itr != wafers.end(); ++itr) {
1285 if (itr->wafer == wafer) {
1291 double dx(0),
dy(0);
1292 if (itrf != wafers.end()) {
1293 dx = (xx - itrf->xyz.x());
1295 dy = (yy - itrf->xyz.y());
1298 return std::make_pair(
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::unordered_map< int32_t, std::pair< int32_t, int32_t > > waferT_map
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_
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)
static int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
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)