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";
42 bool dodet(
true),
first(
true);
44 std::vector<HGCalParameters::hgtrform> trforms;
45 std::vector<bool> trformUse;
50 int isd = (name.find(sdTag) == std::string::npos) ? -1 : 1;
53 int nsiz = (
int)(copy.size());
54 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
55 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
56 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
58 if (first) {first =
false; zpFirst = zp;}
61 mytr.
lay = lay; mytr.
bl = trp.
x1(); mytr.
tl = trp.
x2();
64 int subs = (trp.
alpha1()>0 ? 1 : 0);
68 if (lay == (
int)(
k+1)) {
75 php.
layer_.emplace_back(lay);
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() );
96 trforms.emplace_back(mytrf);
97 trformUse.emplace_back(
false);
102 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : mismatch in # of bins " 104 <<
" between geometry and specpar";
105 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: mismatch between geometry and specpar";
107 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
108 for (
unsigned int k=0;
k<php.
layer_.size(); ++
k) {
117 <<
" modules for " << sdTag <<
" with " << php.
nSectors_ 118 <<
" sectors and " << trforms.size() <<
" transformation matrices" 131 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
160 <<
" depths" << std::endl;
163 std::cout <<
"Module[" <<
i <<
":" << k <<
"] First Layer " 171 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
172 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
173 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
176 trforms[i1].lay = (
i+1);
177 trformUse[i1] =
true;
180 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
181 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
183 trforms[i2].sec == trforms[i1].sec &&
184 trforms[i2].subsec == trforms[i1].subsec) {
187 trformUse[i2] =
true;
198 <<
" transformation matrices" << std::endl;
222 std::map<int,HGCalGeomParameters::layerParameters>
layers;
223 std::vector<HGCalParameters::hgtrform> trforms;
224 std::vector<bool> trformUse;
231 int nsiz = (
int)(copy.size());
232 int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
233 int zp = (nsiz > 2) ? copy[nsiz-3] : -1;
234 if (zp != 1) zp = -1;
236 edm::LogError(
"HGCalGeom") <<
"Funny layer # " << lay <<
" zp " 237 << zp <<
" in " << nsiz <<
" components";
242 std::map<int,HGCalGeomParameters::layerParameters>::iterator itr = layers.find(lay);
243 if (itr == layers.end()) {
249 layers[lay] = laypar;
252 fv.
rotation().GetComponents( x, y, z ) ;
253 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
255 x.Z(), y.Z(), z.Z() );
261 const CLHEP::Hep3Vector h3v ( xx, yy, fv.
translation().Z() );
269 trforms.emplace_back(mytrf);
270 trformUse.emplace_back(
false);
279 std::unordered_map<int32_t,int32_t> copies;
281 std::vector<int32_t> wafer2copy;
282 std::vector<HGCalGeomParameters::cellParameters> wafers;
284 DDValue val1(attribute, sdTag2, 0.0);
290 <<
" not found but needed.";
292 <<
" not found but needed.";
295 std::unordered_set<std::string>
names;
300 int nsiz = (
int)(copy.size());
301 int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
302 int layer = (nsiz > 1) ? copy[nsiz-2] : 0;
304 edm::LogError(
"HGCalGeom") <<
"Funny wafer # " << wafer <<
" in " 305 << nsiz <<
" components";
308 std::unordered_map<int32_t,int32_t>::iterator itr = copies.find(wafer);
309 std::unordered_map<int32_t,int32_t>::iterator cpy =
310 copiesInLayers[layer].find(wafer);
311 if (itr != copies.end() && cpy == copiesInLayers[layer].end()) {
312 copiesInLayers[layer][wafer] = itr->second;
314 if (itr == copies.end()) {
315 copies[wafer] = wafer2copy.size();
316 copiesInLayers[layer][wafer] = wafer2copy.size();
321 wafer2copy.emplace_back(wafer);
324 wafers.emplace_back(cell);
325 if ( names.count(name) == 0 ) {
326 std::vector<double> zv, rv;
329 zv = polyhedra.
zVec();
337 double dz = 0.5*(zv[1]-zv[0]);
357 std::map<int,int> wafertype;
358 std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
359 DDValue val2(attribute, sdTag3, 0.0);
365 <<
" not found but needed.";
367 <<
" not found but needed.";
374 int nsiz = (
int)(copy.size());
375 int cellx= (nsiz > 0) ? copy[nsiz-1] : 0;
376 int wafer= (nsiz > 1) ? copy[nsiz-2] : 0;
377 int cell = cellx%1000;
378 int type = cellx/1000;
379 if (type != 1 && type != 2) {
380 edm::LogError(
"HGCalGeom") <<
"Funny cell # " << cell <<
" type " 381 << type <<
" in " << nsiz <<
" components";
384 std::map<int,int>::iterator ktr = wafertype.find(wafer);
385 if (ktr == wafertype.end()) wafertype[wafer] = type;
387 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
390 itr = cellsf.find(cell);
391 newc= (itr == cellsf.end());
393 itr = cellsc.find(cell);
394 newc= (itr == cellsc.end());
398 bool half = (name.find(
"Half") != std::string::npos);
407 std::cout <<
"Type " << type <<
" Cell " << cellx <<
" local " 408 << xx <<
":" << yy <<
" new " << p1 <<
":" << p2 <<
"\n";
423 if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) ||
425 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : number of cells " 426 << cellsf.size() <<
":" << cellsc.size()
427 <<
" wafers " << wafers.size() <<
" layers " 428 << layers.size() <<
" illegal";
430 <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells " 431 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
432 <<
" layers " << layers.size();
435 for (
unsigned int i=0;
i<layers.size(); ++
i) {
436 for (
auto & layer : layers) {
437 if (layer.first == (
int)(
i+1)) {
441 php.
zLayerHex_.emplace_back(layer.second.zpos);
446 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
447 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
448 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
451 trforms[i1].lay = (
i+1);
452 trformUse[i1] =
true;
455 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
456 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
460 trformUse[i2] =
true;
471 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i ) {
473 php.
waferPosX_.emplace_back(wafers[i].xyz.x());
474 php.
waferPosY_.emplace_back(wafers[i].xyz.y());
475 std::map<int,int>::iterator ktr = wafertype.find(wafer2copy[i]);
476 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
478 double r = wafers[
i].xyz.perp();
480 for (
int k=1;
k<4; ++
k) {
490 std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
491 for (
unsigned int i=0;
i<cellsf.size(); ++
i) {
492 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsf.find(
i);
493 if (itr == cellsf.end()) {
494 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 495 <<
" fine cell number " <<
i;
497 <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
499 double xx = (itr->second).xyz.x();
500 double yy = (itr->second).xyz.y();
501 int waf= (itr->second).wafer;
502 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
509 for (
unsigned int i=0;
i<cellsc.size(); ++
i) {
510 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsc.find(
i);
511 if (itr == cellsc.end()) {
512 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 513 <<
" coarse cell number " <<
i;
515 <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
517 double xx = (itr->second).xyz.x();
518 double yy = (itr->second).xyz.y();
519 int waf= (itr->second).wafer;
520 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
554 <<
" layers" << std::endl;
563 <<
" depths" <<std::endl;
566 std::cout <<
"Reco Layer[" <<
i <<
":" << k <<
"] First Layer " 575 <<
" and dimensions of the wafers:" << std::endl;
585 <<
" fine cells in a wafer" << std::endl;
590 <<
" coarse cells in a wafer" << std::endl;
595 <<
" transformation matrices" << std::endl;
610 std::cout <<
"Layer " <<
k <<
":" << theModules.size() << std::endl;
612 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
613 itr != theModules.end(); ++itr) {
614 std::cout <<
" " << itr->first <<
":" << itr->second;
616 if (k2 > 9) {
std::cout << std::endl; k2 = 0; }
632 <<
" entries for cellSize_" << std::endl;
645 <<
" and " << php.
nCells_ <<
" entries for cellFactor_\n";
655 <<
" entries for layerGroup_" << std::endl;
674 std::cout <<
"HGCalGeomParameters: wafer radius ranges for cell grouping " 683 std::cout <<
"HGCalGeomParameters: Minimum/maximum R " 703 <<
" and layer groupings for the 3 ranges:" << std::endl;
704 for (
int k=0; k<nmin; ++
k)
732 std::cout <<
"HGCalGeomParameters: " << php.cellSize_.size()
733 <<
" cells of sizes:\n";
734 for (
unsigned int k=0;
k<php.cellSize_.size(); ++
k)
735 std::cout <<
" [" <<
k <<
"] " << php.cellSize_[
k] <<
"\n";
745 std::cout <<
"Input waferWidth " << waferW <<
":" << rmin
746 <<
" R Limits: " << rin <<
":" << rout
747 <<
" Fine " << rMaxFine <<
"\n";
755 double dx = 0.5*waferW;
756 double dy = 3.0*dx*
tan(30.0*CLHEP::deg);
757 double rr = 2.0*dx*
tan(30.0*CLHEP::deg);
758 int ncol = (
int)(2.0*rout/waferW) + 1;
759 int nrow = (
int)(rout/(waferW*
tan(30.0*CLHEP::deg))) + 1;
760 int incm(0), inrm(0), kount(0), ntot(0);
764 std::cout <<
"Row " << nrow <<
" Column " << ncol << std::endl;
766 for (
int nr=-nrow; nr <= nrow; ++nr) {
767 int inr = (nr >= 0) ? nr : -nr;
768 for (
int nc=-ncol; nc <=
ncol; ++nc) {
769 int inc = (nc >= 0) ? nc : -nc;
770 if (inr%2 == inc%2) {
773 xc[0] = xpos+
dx; yc[0] = ypos-0.5*
rr;
774 xc[1] = xpos+
dx; yc[1] = ypos+0.5*
rr;
775 xc[2] = xpos; yc[2] = ypos+
rr;
776 xc[3] = xpos-
dx; yc[3] = ypos+0.5*
rr;
777 xc[4] = xpos+
dx; yc[4] = ypos-0.5*
rr;
778 xc[5] = xpos; yc[5] = ypos-
rr;
779 bool cornerOne(
false);
780 bool cornerAll(
true);
781 for (
int k=0;
k<6; ++
k) {
783 if (rpos >= rin && rpos <= rout) cornerOne =
true;
784 else cornerAll =
false;
786 double rpos =
std::sqrt(xpos*xpos+ypos*ypos);
787 int typet = (rpos < rMaxFine) ? 1 : 2;
789 for (
int k=1;
k<4; ++
k) {
796 int copy = inr*100 + inc;
797 if (nc < 0) copy += 10000;
798 if (nr < 0) copy += 100000;
799 if (inc > incm) incm = inc;
800 if (inr > inrm) inrm = inr;
803 std::cout << kount <<
":" << ntot <<
" Copy " << copy
804 <<
" Type " << typel <<
":" << typet
805 <<
" Location " << cornerOne <<
":" << cornerAll
806 <<
" Position " << xpos <<
":" << ypos <<
"\n";
813 for (
unsigned int il=0; il<php.
layer_.size(); ++il) {
816 for (
int k=0;
k<6; ++
k) {
820 else cornerAll =
false;
823 std::unordered_map<int32_t,int32_t>::iterator cpy =
824 copiesInLayers[php.
layer_[il]].find(copy);
825 if (cpy == copiesInLayers[php.
layer_[il]].end())
826 copiesInLayers[php.
layer_[il]][copy] = cornerAll ? php.
waferCopy_.size() : -1;
836 std::cout <<
"HGCalWaferHexagon: # of columns " << incm <<
" # of rows " 837 << inrm <<
" and " << kount <<
":" << ntot <<
" wafers; R " 838 << rin <<
":" << rout << std::endl;
841 for (
unsigned int k=0;
k<copiesInLayers.size(); ++
k) {
842 const auto& theModules = copiesInLayers[
k];
843 std::cout <<
"Layer " <<
k <<
":" << theModules.size() << std::endl;
845 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
846 itr != theModules.end(); ++itr) {
847 std::cout <<
" " << itr->first <<
":" << itr->second;
849 if (k2 > 9) {
std::cout << std::endl; k2 = 0; }
872 <<
" rows for fine cells\n";
877 <<
" rows for coarse cells\n";
889 const std::vector<double> & fvec = value.
doubles();
890 int nval = fvec.size();
893 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
894 <<
" bins " << nval <<
" < " << nmin
896 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
899 if (nval < 1 && nmin == 0) {
900 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
901 <<
" bins " << nval <<
" < 1 ==> illegal" 902 <<
" (nmin=" << nmin <<
")";
903 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
910 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array " 912 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
914 std::vector<double> fvec;
920 std::pair<double,double>
922 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
923 int wafer,
double xx,
double yy) {
925 if (itrf == wafers.end()) {
926 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
927 itr != wafers.end(); ++itr) {
928 if (itr->wafer == wafer) {
935 if (itrf != wafers.end()) {
936 dx = (xx - itrf->xyz.x());
938 dy = (yy - itrf->xyz.y());
941 return std::pair<double,double>(
dx,
dy);
std::vector< double > waferPosY_
std::vector< int > layer_
std::vector< double > moduleDzR_
std::vector< int > depthLayerF_
double halfZ(void) const
half of the z-Axis
std::vector< int > depth_
std::vector< double > moduleCellR_
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_
double x1(void) const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
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< int > cellFactor_
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
Interface to a Trapezoid.
Tan< T >::type tan(const T &t)
double y1(void) const
Half-length along y of the face at -pDz.
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_
std::vector< double > moduleCellS_
void loadSpecParsSquare(const DDFilteredView &, HGCalParameters &)
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...
DDsvalues_type mergedSpecifics() const
std::vector< double > trformRotYY_
std::vector< double > cellFineX_
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
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 ...
double y2(void) const
Half-length along y of the face at +pDz.
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_
void loadGeometrySquare(const DDFilteredView &, HGCalParameters &, const std::string &)
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)