19 #include "CLHEP/Units/GlobalPhysicalConstants.h" 20 #include "CLHEP/Units/GlobalSystemOfUnits.h" 21 #include <unordered_set> 50 std::map<int,HGCalGeomParameters::layerParameters>
layers;
51 std::vector<HGCalParameters::hgtrform> trforms;
52 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;
489 int nsiz = (
int)(copy.size());
490 int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
491 int zside= (nsiz > 3) ? copy[3] : -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] <<
":" 636 << php.
slopeMin_ <<
" and layer groupings " 637 <<
"for the 3 ranges:";
638 for (
int k=0;
k<nmin; ++
k)
667 << php.
cellSize_.size() <<
" cells of sizes:";
689 <<
"parameters for 120 to 200 micron " 699 <<
"parameters for 200 to 300 micron " 736 for (
unsigned int k = 0;
k < php.
zFront_.size(); ++
k)
738 <<
"] Z = " << php.
zFront_[
k] <<
" Slope = " 772 <<
" cellSize: " << php.
cellSize_[0] <<
":" 792 for (
unsigned int k = 0;
k < php.
zFront_.size(); ++
k)
794 <<
"] Z = " << php.
zFront_[
k] <<
" Slope = " 814 << rmin <<
" R Limits: " << rin <<
":" 815 << rout <<
" Fine " << rMaxFine;
823 double dx = 0.5*waferW;
824 double dy = 3.0*dx*
tan(30.0*CLHEP::deg);
825 double rr = 2.0*dx*
tan(30.0*CLHEP::deg);
826 int ncol = (
int)(2.0*rout/waferW) + 1;
827 int nrow = (
int)(rout/(waferW*
tan(30.0*CLHEP::deg))) + 1;
828 int incm(0), inrm(0), kount(0), ntot(0);
834 for (
int nr=-nrow; nr <= nrow; ++nr) {
835 int inr = (nr >= 0) ? nr : -nr;
836 for (
int nc=-ncol; nc <=
ncol; ++nc) {
837 int inc = (nc >= 0) ? nc : -nc;
838 if (inr%2 == inc%2) {
841 xc[0] = xpos+
dx; yc[0] = ypos-0.5*
rr;
842 xc[1] = xpos+
dx; yc[1] = ypos+0.5*
rr;
843 xc[2] = xpos; yc[2] = ypos+
rr;
844 xc[3] = xpos-
dx; yc[3] = ypos+0.5*
rr;
845 xc[4] = xpos+
dx; yc[4] = ypos-0.5*
rr;
846 xc[5] = xpos; yc[5] = ypos-
rr;
847 bool cornerOne(
false);
850 if (rpos >= rin && rpos <= rout) cornerOne =
true;
852 double rpos =
std::sqrt(xpos*xpos+ypos*ypos);
853 int typet = (rpos < rMaxFine) ? 1 : 2;
855 for (
int k=1;
k<4; ++
k) {
862 int copy = inr*100 + inc;
863 if (nc < 0) copy += 10000;
864 if (nr < 0) copy += 100000;
865 if (inc > incm) incm = inc;
866 if (inr > inrm) inrm = inr;
870 << copy <<
" Type " << typel <<
":" 871 << typet <<
" Location " << cornerOne
872 <<
" Position " << xpos <<
":" << ypos
873 <<
" Layers " << php.
layer_.size();
880 for (
unsigned int il=0; il<php.
layer_.size(); ++il) {
881 bool corner(
false), cornerAll(
true);
886 else cornerAll =
false;
889 auto cpy = copiesInLayers[php.
layer_[il]].find(copy);
890 if (cpy == copiesInLayers[php.
layer_[il]].end())
891 copiesInLayers[php.
layer_[il]][copy] = cornerAll ? php.
waferCopy_.size() : -1;
903 << incm <<
" # of rows " << inrm <<
" and " 904 << kount <<
":" << ntot <<
" wafers; R " 905 << rin <<
":" << rout;
908 for (
unsigned int k=0;
k<copiesInLayers.size(); ++
k) {
909 const auto& theModules = copiesInLayers[
k];
912 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
913 itr != theModules.end(); ++itr,++k2) {
936 << waferS <<
" R Max: " << rout;
944 double r = 0.5*(waferW+waferS);
947 int N = (r == 0) ? 3 : ((
int)(0.5*rout/
r) + 3);
948 int ns1 = (2*N+1)*(2*N+1);
952 <<
" sizes " << ns1 <<
":" << ns2;
953 std::vector<int> indtypes(ns1+1);
958 int ipos(0), lpos(0), uvmax(0);
959 std::vector<int> uvmx(php.
zLayerHex_.size(),0);
961 for (
int v = -N;
v <=
N; ++
v) {
962 for (
int u = -N; u <=
N; ++u) {
971 wafersInLayers[indx] = ipos;
973 xc[0] = xpos+
r; yc[0] = ypos+0.5*
R;
974 xc[1] = xpos; yc[1] = ypos+
R;
975 xc[2] = xpos-
r; yc[2] = ypos+0.5*
R;
976 xc[3] = xpos-
r; yc[3] = ypos-0.5*
R;
977 xc[4] = xpos; yc[4] = ypos-
R;
978 xc[5] = xpos+
r; yc[5] = ypos-0.5*
R;
979 bool cornerOne(
false), cornerAll(
true);
981 double rpos =
sqrt(xc[
k]*xc[
k]+yc[
k]*yc[
k]);
982 if (rpos <= rout) cornerOne =
true;
983 else cornerAll =
false;
985 if ((cornerAll) || (cornerOne && php.
defineFull_)) {
994 typesInLayers[kndx] = lpos;
997 indtypes.emplace_back(kndx);
999 bool cornerOne(
false), cornerAll(
true);
1001 double rpos =
sqrt(xc[
k]*xc[
k]+yc[
k]*yc[
k]);
1003 else cornerAll =
false;
1005 if ((cornerAll) || (cornerOne && php.
defineFull_)) {
1049 int id = indtypes[
k];
1052 <<
" ID " << std::hex <<
id <<
std::dec 1077 <<
" rows for fine cells";
1082 <<
" rows for coarse cells";
1094 etaMin.emplace_back(eta1); etaMax.emplace_back(eta2);
1101 for (
unsigned k=0;
k<etaMin.size(); ++
k)
1103 << etaMin[
k] <<
":" << etaMax[
k];
1110 for (
unsigned int k=0;
k<etaMin.size(); ++
k) {
1119 <<
" vs " << etaMin[
k] <<
":" << etaMax[
k];
1122 for (
int ieta=ietaMin; ieta<=ietaMax; ++ ieta) {
1129 mytr.
h = 0.5*(rmax-rmin);
1139 if (ieta == ietaMin) php.
firstModule_.emplace_back(im);
1141 if (ieta == ietaMax-1) php.
lastModule_.emplace_back(im);
1158 const std::vector<double> & fvec = value.
doubles();
1159 int nval = fvec.size();
1162 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
1163 <<
" bins " << nval <<
" < " << nmin
1165 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1168 if (nval < 1 && nmin == 0) {
1169 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
1170 <<
" bins " << nval <<
" < 1 ==> illegal" 1171 <<
" (nmin=" << nmin <<
")";
1172 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1178 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array " 1180 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
1182 std::vector<double> fvec;
1187 std::pair<double,double>
1189 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
1190 int wafer,
double xx,
double yy) {
1192 if (itrf == wafers.end()) {
1193 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
1194 itr != wafers.end(); ++itr) {
1195 if (itr->wafer == wafer) {
1201 double dx(0),
dy(0);
1202 if (itrf != wafers.end()) {
1203 dx = (xx - itrf->xyz.x());
1205 dy = (yy - itrf->xyz.y());
1208 return std::pair<double,double>(
dx,
dy);
std::vector< double > waferPosY_
std::vector< int > layer_
std::vector< int > iEtaMinBH_
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_
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 *.
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 > 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< 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 > 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 > 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< 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 > 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_
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< int > levelT_
std::vector< double > cellCoarseY_
std::vector< int > moduleLayS_
std::vector< double > trformTranZ_
std::vector< double > dPhiEtaBH_
std::vector< double > waferPosX_
std::vector< double > zFront_
void addTrForm(const CLHEP::Hep3Vector &h3v)
std::vector< double > moduleTlR_
std::vector< int > waferTypeL_
void loadWaferHexagon8(HGCalParameters &php)
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)