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)) {
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.push_back(mytrf);
97 trformUse.push_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;
221 std::map<int,HGCalGeomParameters::layerParameters>
layers;
222 std::vector<HGCalParameters::hgtrform> trforms;
223 std::vector<bool> trformUse;
230 int nsiz = (
int)(copy.size());
231 int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
232 int zp = (nsiz > 2) ? copy[nsiz-3] : -1;
233 if (zp != 1) zp = -1;
235 edm::LogError(
"HGCalGeom") <<
"Funny layer # " << lay <<
" zp " 236 << zp <<
" in " << nsiz <<
" components";
241 std::map<int,HGCalGeomParameters::layerParameters>::iterator itr = layers.find(lay);
242 if (itr == layers.end()) {
248 layers[lay] = laypar;
251 fv.
rotation().GetComponents( x, y, z ) ;
252 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
254 x.Z(), y.Z(), z.Z() );
260 const CLHEP::Hep3Vector h3v ( xx, yy, fv.
translation().Z() );
268 trforms.push_back(mytrf);
269 trformUse.push_back(
false);
278 std::unordered_map<int32_t,int32_t> copies;
280 std::vector<int32_t> wafer2copy;
281 std::vector<HGCalGeomParameters::cellParameters> wafers;
283 DDValue val1(attribute, sdTag2, 0.0);
289 <<
" not found but needed.";
291 <<
" not found but needed.";
294 std::unordered_set<std::string>
names;
299 int nsiz = (
int)(copy.size());
300 int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
301 int layer = (nsiz > 1) ? copy[nsiz-2] : 0;
303 edm::LogError(
"HGCalGeom") <<
"Funny wafer # " << wafer <<
" in " 304 << nsiz <<
" components";
307 std::unordered_map<int32_t,int32_t>::iterator itr = copies.find(wafer);
308 std::unordered_map<int32_t,int32_t>::iterator cpy =
309 copiesInLayers[layer].find(wafer);
310 if (itr != copies.end() && cpy == copiesInLayers[layer].end()) {
311 copiesInLayers[layer][wafer] = itr->second;
313 if (itr == copies.end()) {
314 copies[wafer] = wafer2copy.size();
315 copiesInLayers[layer][wafer] = wafer2copy.size();
320 wafer2copy.emplace_back(wafer);
323 wafers.emplace_back(cell);
324 if ( names.count(name) == 0 ) {
326 std::vector<double> zv = polyhedra.
zVec();
327 std::vector<double> rv = polyhedra.
rMaxVec();
329 double dz = 0.5*(zv[1]-zv[0]);
345 std::map<int,int> wafertype;
346 std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
347 DDValue val2(attribute, sdTag3, 0.0);
353 <<
" not found but needed.";
355 <<
" not found but needed.";
362 int nsiz = (
int)(copy.size());
363 int cellx= (nsiz > 0) ? copy[nsiz-1] : 0;
364 int wafer= (nsiz > 1) ? copy[nsiz-2] : 0;
365 int cell = cellx%1000;
366 int type = cellx/1000;
367 if (type != 1 && type != 2) {
368 edm::LogError(
"HGCalGeom") <<
"Funny cell # " << cell <<
" type " 369 << type <<
" in " << nsiz <<
" components";
372 std::map<int,int>::iterator ktr = wafertype.find(wafer);
373 if (ktr == wafertype.end()) wafertype[wafer] = type;
375 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
378 itr = cellsf.find(cell);
379 newc= (itr == cellsf.end());
381 itr = cellsc.find(cell);
382 newc= (itr == cellsc.end());
386 bool half = (name.find(
"Half") != std::string::npos);
395 std::cout <<
"Type " << type <<
" Cell " << cellx <<
" local " 396 << xx <<
":" << yy <<
" new " << p1 <<
":" << p2 <<
"\n";
411 if (((cellsf.size()+cellsc.size())==0) || (wafers.size()==0) ||
412 (layers.size()==0)) {
413 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : number of cells " 414 << cellsf.size() <<
":" << cellsc.size()
415 <<
" wafers " << wafers.size() <<
" layers " 416 << layers.size() <<
" illegal";
418 <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells " 419 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
420 <<
" layers " << layers.size();
423 for (
unsigned int i=0;
i<layers.size(); ++
i) {
424 for (std::map<int,HGCalGeomParameters::layerParameters>::iterator itr = layers.begin();
425 itr != layers.end(); ++itr) {
426 if (itr->first == (
int)(
i+1)) {
435 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
436 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
437 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
440 trforms[i1].lay = (
i+1);
441 trformUse[i1] =
true;
444 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
445 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
449 trformUse[i2] =
true;
460 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i ) {
464 std::map<int,int>::iterator ktr = wafertype.find(wafer2copy[i]);
465 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
467 double r = wafers[
i].xyz.perp();
469 for (
int k=1;
k<4; ++
k) {
479 std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
480 for (
unsigned int i=0;
i<cellsf.size(); ++
i) {
481 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsf.find(
i);
482 if (itr == cellsf.end()) {
483 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 484 <<
" fine cell number " <<
i;
486 <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
488 double xx = (itr->second).xyz.x();
489 double yy = (itr->second).xyz.y();
490 int waf= (itr->second).wafer;
491 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
498 for (
unsigned int i=0;
i<cellsc.size(); ++
i) {
499 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsc.find(
i);
500 if (itr == cellsc.end()) {
501 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for" 502 <<
" coarse cell number " <<
i;
504 <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
506 double xx = (itr->second).xyz.x();
507 double yy = (itr->second).xyz.y();
508 int waf= (itr->second).wafer;
509 std::pair<double,double>
xy =
cellPosition(wafers,itrf,waf,xx,yy);
543 <<
" layers" << std::endl;
552 <<
" depths" <<std::endl;
555 std::cout <<
"Reco Layer[" <<
i <<
":" << k <<
"] First Layer " 564 <<
" and dimensions of the wafers:" << std::endl;
574 <<
" fine cells in a wafer" << std::endl;
579 <<
" coarse cells in a wafer" << std::endl;
584 <<
" transformation matrices" << std::endl;
599 std::cout <<
"Layer " <<
k <<
":" << theModules.size() << std::endl;
601 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
602 itr != theModules.end(); ++itr) {
603 std::cout <<
" " << itr->first <<
":" << itr->second;
605 if (k2 > 9) {
std::cout << std::endl; k2 = 0; }
621 <<
" entries for cellSize_" << std::endl;
630 std::vector<double> slp =
getDDDArray(
"Slope",sv,nmin);
634 <<
" and " << php.
nCells_ <<
" entries for cellFactor_\n";
644 <<
" entries for layerGroup_" << std::endl;
660 for (
unsigned int k=0;
k<php.
boundR_.size(); ++
k)
663 std::cout <<
"HGCalGeomParameters: wafer radius ranges for cell grouping " 669 for (
unsigned int k=0;
k<php.
rLimit_.size(); ++
k)
672 std::cout <<
"HGCalGeomParameters: Minimum/maximum R " 688 std::vector<double> slp =
getDDDArray(
"Slope",sv,nmin);
692 <<
" and layer groupings for the 3 ranges:" << std::endl;
693 for (
int k=0;
k<nmin; ++
k)
721 std::cout <<
"HGCalGeomParameters: " << php.cellSize_.size()
722 <<
" cells of sizes:\n";
723 for (
unsigned int k=0;
k<php.cellSize_.size(); ++
k)
724 std::cout <<
" [" <<
k <<
"] " << php.cellSize_[
k] <<
"\n";
734 std::cout <<
"Input waferWidth " << waferW <<
":" << rmin
735 <<
" R Limits: " << rin <<
":" << rout
736 <<
" Fine " << rMaxFine <<
"\n";
744 double dx = 0.5*waferW;
745 double dy = 3.0*dx*
tan(30.0*CLHEP::deg);
746 double rr = 2.0*dx*
tan(30.0*CLHEP::deg);
747 int ncol = (
int)(2.0*rout/waferW) + 1;
748 int nrow = (
int)(rout/(waferW*
tan(30.0*CLHEP::deg))) + 1;
749 int incm(0), inrm(0), kount(0), ntot(0);
753 std::cout <<
"Row " << nrow <<
" Column " << ncol << std::endl;
755 for (
int nr=-nrow; nr <= nrow; ++nr) {
756 int inr = (nr >= 0) ? nr : -nr;
757 for (
int nc=-ncol; nc <=
ncol; ++nc) {
758 int inc = (nc >= 0) ? nc : -nc;
759 if (inr%2 == inc%2) {
762 xc[0] = xpos+dx; yc[0] = ypos-0.5*
rr;
763 xc[1] = xpos+dx; yc[1] = ypos+0.5*
rr;
764 xc[2] = xpos; yc[2] = ypos+
rr;
765 xc[3] = xpos-dx; yc[3] = ypos+0.5*
rr;
766 xc[4] = xpos+dx; yc[4] = ypos-0.5*
rr;
767 xc[5] = xpos; yc[5] = ypos-
rr;
768 bool cornerOne(
false);
769 bool cornerAll(
true);
770 for (
int k=0;
k<6; ++
k) {
772 if (rpos >= rin && rpos <= rout) cornerOne =
true;
773 else cornerAll =
false;
775 double rpos =
std::sqrt(xpos*xpos+ypos*ypos);
776 int typet = (rpos < rMaxFine) ? 1 : 2;
778 for (
int k=1;
k<4; ++
k) {
785 int copy = inr*100 + inc;
786 if (nc < 0) copy += 10000;
787 if (nr < 0) copy += 100000;
788 if (inc > incm) incm = inc;
789 if (inr > inrm) inrm = inr;
792 std::cout << kount <<
":" << ntot <<
" Copy " << copy
793 <<
" Type " << typel <<
":" << typet
794 <<
" Location " << cornerOne <<
":" << cornerAll
795 <<
" Position " << xpos <<
":" << ypos <<
"\n";
802 for (
unsigned int il=0; il<php.
layer_.size(); ++il) {
805 for (
int k=0;
k<6; ++
k) {
809 else cornerAll =
false;
812 std::unordered_map<int32_t,int32_t>::iterator cpy =
813 copiesInLayers[php.
layer_[il]].find(copy);
814 if (cpy == copiesInLayers[php.
layer_[il]].end())
815 copiesInLayers[php.
layer_[il]][copy] = cornerAll ? php.
waferCopy_.size() : -1;
825 std::cout <<
"HGCalWaferHexagon: # of columns " << incm <<
" # of rows " 826 << inrm <<
" and " << kount <<
":" << ntot <<
" wafers; R " 827 << rin <<
":" << rout << std::endl;
830 for (
unsigned int k=0;
k<copiesInLayers.size(); ++
k) {
831 const auto& theModules = copiesInLayers[
k];
832 std::cout <<
"Layer " <<
k <<
":" << theModules.size() << std::endl;
834 for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
835 itr != theModules.end(); ++itr) {
836 std::cout <<
" " << itr->first <<
":" << itr->second;
838 if (k2 > 9) {
std::cout << std::endl; k2 = 0; }
861 <<
" rows for fine cells\n";
866 <<
" rows for coarse cells\n";
878 const std::vector<double> & fvec = value.
doubles();
879 int nval = fvec.size();
882 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
883 <<
" bins " << nval <<
" < " << nmin
885 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
888 if (nval < 1 && nmin == 0) {
889 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
890 <<
" bins " << nval <<
" < 1 ==> illegal" 891 <<
" (nmin=" << nmin <<
")";
892 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
899 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array " 901 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
903 std::vector<double> fvec;
909 std::pair<double,double>
911 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
912 int wafer,
double xx,
double yy) {
914 if (itrf == wafers.end()) {
915 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
916 itr != wafers.end(); ++itr) {
917 if (itr->wafer == wafer) {
924 if (itrf != wafers.end()) {
925 dx = (xx - itrf->xyz.x());
927 dy = (yy - itrf->xyz.y());
930 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< 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 > 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_
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &)
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_