15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 #include <unordered_set>
25 std::cout <<
"HGCalGeomParameters::HGCalGeomParameters() constructor" << std::endl;
31 std::cout <<
"HGCalGeomParameters::destructed!!!" << std::endl;
40 bool dodet(
true),
first(
true);
42 std::vector<HGCalParameters::hgtrform> trforms;
43 std::vector<bool> trformUse;
48 int isd = (name.find(sdTag) == std::string::npos) ? -1 : 1;
51 int nsiz = (int)(copy.size());
52 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
53 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
54 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
56 if (first) {first =
false; zpFirst = zp;}
59 mytr.
lay = lay; mytr.
bl = trp.
x1(); mytr.
tl = trp.
x2();
62 int subs = (trp.
alpha1()>0 ? 1 : 0);
66 if (lay == (
int)(
k+1)) {
79 fv.
rotation().GetComponents( x, y, z ) ;
80 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
82 x.Z(), y.Z(), z.Z() );
94 trforms.push_back(mytrf);
95 trformUse.push_back(
false);
100 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : mismatch in # of bins "
102 <<
" between geometry and specpar";
103 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: mismatch between geometry and specpar";
105 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
106 for (
unsigned int k=0;
k<php.
layer_.size(); ++
k) {
115 <<
" modules for " << sdTag <<
" with " << php.
nSectors_
116 <<
" sectors and " << trforms.size() <<
" transformation matrices"
128 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
157 <<
" depths" << std::endl;
160 std::cout <<
"Module[" <<
i <<
":" << k <<
"] First Layer "
168 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
169 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
170 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
173 trforms[i1].lay = (
i+1);
174 trformUse[i1] =
true;
177 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
178 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
180 trforms[i2].sec == trforms[i1].sec &&
181 trforms[i2].subsec == trforms[i1].subsec) {
184 trformUse[i2] =
true;
195 <<
" transformation matrices" << std::endl;
219 std::map<int,HGCalGeomParameters::layerParameters>
layers;
220 std::vector<HGCalParameters::hgtrform> trforms;
221 std::vector<bool> trformUse;
226 bool isd = (name.find(sdTag1) != std::string::npos);
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);
279 std::unordered_map<int32_t,int32_t> copies;
281 std::vector<int32_t> wafer2copy;
282 std::vector<GlobalPoint> wafers;
284 DDValue val1(attribute, sdTag2, 0.0);
293 <<
" not found but needed.";
295 <<
" not found but needed.";
298 std::unordered_set<std::string>
names;
302 bool isd = (name.find(sdTag2) != std::string::npos);
305 int nsiz = (int)(copy.size());
306 int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
307 int layer = (nsiz > 0) ? copy[nsiz-2] : 0;
309 edm::LogError(
"HGCalGeom") <<
"Funny wafer # " << wafer <<
" in "
310 << nsiz <<
" components";
313 std::unordered_map<int32_t,int32_t>::iterator itr =
315 std::unordered_map<int32_t,int32_t>::iterator cpy =
316 copiesInLayers[layer].find(wafer);
317 if( itr != copies.end() && cpy == copiesInLayers[layer].end() ) {
318 copiesInLayers[layer][wafer] = itr->second;
320 if (itr == copies.end()) {
321 copies[wafer] = wafer2copy.size();
322 copiesInLayers[layer][wafer] = wafer2copy.size();
327 wafer2copy.emplace_back(wafer);
329 if ( names.count(name) == 0 ) {
331 std::vector<double> zv = polyhedra.
zVec();
332 std::vector<double> rv = polyhedra.
rMaxVec();
335 double dz = 0.5*(zv[1]-zv[0]);
339 mytr.
dz = dz; mytr.
alpha = 0.0;
352 std::map<int,int> wafertype;
353 std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
354 double ymax = 2.0*rmax*
tan(30.0*CLHEP::deg);
355 DDValue val2(attribute, sdTag3, 0.0);
363 <<
" not found but needed.";
365 <<
" not found but needed.";
371 bool isd = (name.find(sdTag3) != std::string::npos);
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;
389 itr = cellsf.find(cell);
390 newc= (itr == cellsf.end());
392 itr = cellsc.find(cell);
393 newc= (itr == cellsc.end());
396 bool half = (name.find(
"Half") != std::string::npos);
412 if ((cellsf.size()==0) || (cellsc.size()==0) || (wafers.size()==0) ||
413 (layers.size()==0)) {
414 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : number of cells "
415 << cellsf.size() <<
":" << cellsc.size()
416 <<
" wafers " << wafers.size() <<
" layers "
417 << layers.size() <<
" illegal";
419 <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells "
420 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
421 <<
" layers " << layers.size();
424 for (
unsigned int i=0;
i<layers.size(); ++
i) {
425 for (std::map<int,HGCalGeomParameters::layerParameters>::iterator itr = layers.begin();
426 itr != layers.end(); ++itr) {
427 if (itr->first == (
int)(
i+1)) {
436 for (
unsigned int i=0;
i<php.
layer_.size(); ++
i) {
437 for (
unsigned int i1=0; i1<trforms.size(); ++i1) {
438 if (!trformUse[i1] && php.
layerGroup_[trforms[i1].lay-1] ==
441 trforms[i1].lay = (
i+1);
442 trformUse[i1] =
true;
445 for (
unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
446 if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
450 trformUse[i2] =
true;
461 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i ) {
465 std::map<int,int>::iterator ktr = wafertype.find(wafer2copy[i]);
466 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
468 double r = wafers[
i].perp();
470 for (
int k=1;
k<4; ++
k) {
480 std::vector<GlobalPoint>::const_iterator itrf = wafers.end();
481 for (
unsigned int i=0;
i<cellsf.size(); ++
i) {
482 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsf.find(
i);
483 if (itr == cellsf.end()) {
484 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for"
485 <<
" fine cell number " <<
i;
487 <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
489 double xx = (itr->second).xyz.x();
490 double yy = (itr->second).xyz.y();
491 std::pair<double,double>
xy =
cellPosition(wafers,itrf,
i,rmax,ymax,xx,yy,cellsf.size());
492 if ((itr->second).half) {
493 if (xy.first > 0) xy.first -= 0.001;
494 else xy.first += 0.001;
501 for (
unsigned int i=0;
i<cellsc.size(); ++
i) {
502 std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsc.find(
i);
503 if (itr == cellsc.end()) {
504 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: missing info for"
505 <<
" coarse cell number " <<
i;
507 <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
509 double xx = (itr->second).xyz.x();
510 double yy = (itr->second).xyz.y();
511 std::pair<double,double>
xy =
cellPosition(wafers,itrf,
i,rmax,ymax,xx,yy,cellsc.size());
512 if ((itr->second).half) {
513 if (xy.first > 0) xy.first -= 0.001;
514 else xy.first += 0.001;
547 std::cout <<
"HGCalGeomParameters: rmax = " << rmax <<
", ymax = " << ymax
550 <<
" layers" << std::endl;
559 <<
" depths" << std::endl;
562 std::cout <<
"Reco Layer[" <<
i <<
":" << k <<
"] First Layer "
574 <<
" 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;
618 std::cout <<
"HGCalGeomParameters: " << php.
nCells_ <<
" entries for cellSize_"
631 <<
" entries for cellFactor_" << std::endl;
643 <<
" entries for layerGroup_" << std::endl;
661 for (
unsigned int k=0;
k<php.
boundR_.size(); ++
k)
664 std::cout <<
"HGCalGeomParameters: wafer radius ranges for cell grouping "
675 std::cout <<
"HGCalGeomParameters: layer grouping for the 3 ranges:"
677 for (
int k=0;
k<nmin; ++
k)
684 DDValue val1(attribute, sdTag1, 0.0);
692 std::vector<double> dummy =
getDDDArray(
"WaferSize",sv,nmin);
700 DDValue val2(attribute, sdTag2, 0.0);
712 <<
" cells of sizes:";
725 const std::vector<double> & fvec = value.
doubles();
726 int nval = fvec.size();
729 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
730 <<
" bins " << nval <<
" < " << nmin
732 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " << str;
735 if (nval < 1 && nmin == 0) {
736 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters : # of " << str
737 <<
" bins " << nval <<
" < 2 ==> illegal"
738 <<
" (nmin=" << nmin <<
")";
739 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " << str;
746 edm::LogError(
"HGCalGeom") <<
"HGCalGeomParameters: cannot get array "
748 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " << str;
750 std::vector<double> fvec;
756 std::pair<double,double>
758 std::vector<GlobalPoint>::const_iterator& itrf,
759 unsigned int num,
double rmax,
double ymax,
760 double xx,
double yy,
unsigned int ncells) {
762 if (itrf == wafers.end()) {
763 for (std::vector<GlobalPoint>::const_iterator itr = wafers.begin();
764 itr != wafers.end(); ++itr) {
765 double dx =
std::abs(xx - itr->x());
766 double dy =
std::abs(yy - itr->y());
767 if (dx <= (rmax+0.0001) && dy <=
ymax) {
768 double xmax = (dy <= 0.5*
ymax) ? rmax : (rmax-(dy-0.5*ymax)/
tan(30.0*CLHEP::deg));
769 if ((dx <= (xmax+0.0001)) && ((yy-itr->y()>0) || (num<=ncells/2+8))) {
777 if (itrf != wafers.end()) {
778 dx = (xx - itrf->x());
780 dy = (yy - itrf->y());
783 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)
static const HistoName names[]
std::vector< double > rMaxVec(void) const
std::vector< int > moduleLayR_
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
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< 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< double > trformRotYZ_
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_
std::pair< double, double > cellPosition(const std::vector< GlobalPoint > &wafers, std::vector< GlobalPoint >::const_iterator &itrf, unsigned int num, double rmax, double ymax, double xx, double yy, unsigned int ncells)
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 > rMaxLayHex_
std::vector< double > trformTranX_
std::vector< double > trformRotXZ_
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_
std::vector< int > depthIndex_
void loadGeometryHexagon(const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &)
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_
for(const auto &isodef:isoDefs)
std::vector< double > waferPosX_
void addTrForm(const CLHEP::Hep3Vector &h3v)
std::vector< double > moduleTlR_
std::vector< int > waferTypeL_
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.