13 #include "CLHEP/Units/GlobalPhysicalConstants.h" 14 #include "CLHEP/Units/GlobalSystemOfUnits.h" 45 for (
int simreco = 0; simreco < 2; ++simreco) {
48 for (
unsigned int layer=1; layer <=
tot_layers_[simreco]; ++layer) {
66 << name <<
" with " <<
layers(
false) <<
":" 68 <<
":" << 2*
modHalf_ <<
" wafers with maximum " 70 <<
"maximum of " <<
maxCells(
false) <<
":" 77 int wminT(9999999), wmaxT(-9999999), kount1(0), kount2(0);
80 int wmin(9999999), wmax(-9999999), kount(0);
81 for (
int wafer=0; wafer<
sectors(); ++wafer) {
92 if (waferU < wmin) wmin = waferU;
93 if (waferU > wmax) wmax = waferU;
97 if (wminT > wmin) wminT = wmin;
98 if (wmaxT < wmax) wmaxT = wmax;
99 if (kount1 < kount) kount1= kount;
102 int lay1 =
getIndex(lay0,
true).first;
104 <<
":" << lay1 <<
" Wafer " << wmin
105 <<
":" << wmax <<
":" << kount;
110 waferMax_ = std::array<int,4>{ {wminT,wmaxT,kount1,kount2} };
113 <<
":" << wmaxT <<
":" << kount1 <<
":" 122 int subSec,
bool reco)
const {
124 if (
index.first < 0)
return std::make_pair(-1,-1);
137 <<
" ***** ERROR *****";
138 return std::make_pair(-1,-1);
144 return std::make_pair(wafer,
cellHex(xx, yy,
148 return std::make_pair(wafer,
cellHex(xx, yy,
153 return std::make_pair(-1,-1);
159 int waferU(0), waferV(0),
waferType(-1), cellU(0), cellV(0);
167 return std::array<int,5>{ {waferU,waferV,
waferType,cellU,cellV} };
174 int irad(-1), iphi(-1),
type(-1);
175 const auto & indx =
getIndex(layer,reco);
176 if (indx.first < 0)
return std::array<int,3>{ {irad,iphi,type} };
177 double xx = (z > 0) ? x : -x;
180 double phi = (r == 0. ? 0. : std::atan2(y,xx));
181 if (phi < 0) phi += (2.0*
M_PI);
188 iphi = 1 + (
int)(phi/indx.second);
191 <<
":" << z <<
":" << layer <<
":" << reco
192 <<
" x|r " << xx <<
":" << r <<
" phi " 193 << phi <<
" o/p " << irad <<
":" << iphi
196 return std::array<int,3>{ {irad,iphi,type} };
200 int cellV,
int lay,
bool reco)
const {
201 const auto & indx =
getIndex(lay,
true);
202 if (indx.first >= 0) {
209 locateCell(lay, waferU, waferV, cellU, cellV, reco,
true,
false) :
211 double rpos =
sqrt(
xy.first*
xy.first +
xy.second*
xy.second);
213 (rpos <= hgpar_->rMaxLayHex_[indx.first]));
244 ((type >= 1) ? 1 : 0) : ((type == 1) ? 1 : 0));
260 }
else if (cellV == 0) {
263 }
else if (cellU-cellV == N) {
266 }
else if (cellU == 2*N-1) {
269 }
else if (cellV == 2*N-1) {
272 }
else if (cellV-cellU == N-1) {
274 }
else if ((cellU > 2*N-1) || (cellV > 2*N-1) || (cellV >= (cellU+N)) ||
275 (cellU > (cellV+N))) {
294 for (
int k=0;
k<sizew; ++
k) {
318 << yy <<
" wafer " << wafer <<
" flag " 319 << (wafer < sizew) <<
" Distance " <<
rmax_ 332 double xx = (z < 0) ? -x : x;
335 double phi = (r == 0. ? 0. : std::atan2(y,xx));
336 if (phi < 0) phi += (2.0*
M_PI);
346 int iphi = 1 + (
int)(phi/cell);
352 << y <<
":" << z <<
" Layer " << lay
353 <<
" Index " << indx <<
":" << type <<
" xx " 354 << xx <<
" R " << r <<
":" << irad <<
":" 357 <<
" Phi " << phi <<
":" << iphi <<
":" 358 << (iphi-0.5)*cell <<
" cell " << cell
359 <<
" Dphi " << dphi <<
" Dist " << dist
372 std::find_if(zLayerHex.begin()+1,zLayerHex.end(),[&
k,&
zz,&zLayerHex](
double zLayer){ ++
k;
return zz < 0.5*(zLayerHex[k-1]+zLayerHex[
k]);});
391 edm::LogWarning(
"HGCalGeom") <<
"Wafer no. out bound for index " << indx
395 <<
" ***** ERROR *****";
398 if (type > 0) --
type;
408 std::vector<HGCalParameters::hgtrap> mytrs;
416 std::vector<HGCalParameters::hgtrform> mytrs;
444 if (waferType < 1 || cell < 0)
return false;
451 bool result(
false), resultMod(
false);
458 const int32_t lay_idx = reco ? (lay-1)*3 + 1 : lay;
460 auto moditr = the_modules.find(copyNumber);
461 result = resultMod = (moditr != the_modules.end());
465 <<
":" << lay_idx <<
" Copy " 466 << copyNumber <<
":" << mod
470 if (moditr->second >= 0) {
473 << mod <<
" to be compared with " 475 <<
" ***** ERROR *****";
479 result = (cell >=0 && cell <= cellmax);
490 << (lay > 0 && (lay <= (
int)(
layers(reco))))
491 <<
" Module " << mod <<
":" << resultMod
492 <<
" Cell " << cell <<
":" << cellmax <<
":" 493 << (cell >=0 && cell <= cellmax)
505 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalDDDConstants::isValidHex8:WaferType " 506 << layer <<
":" << modU <<
":" << modV <<
":" 514 << jtr->first <<
":" << jtr->second;
516 if (!(jtr->second))
return false;
521 << cellU <<
":" << cellV <<
":" << N
522 <<
" Tests " << (cellU >= 0) <<
":" 523 << (cellU < 2*N) <<
":" << (cellV >= 0) <<
":" 524 << (cellV < 2*N) <<
":" << ((cellV-cellU) < N)
525 <<
":" << ((cellU-cellV) <= N);
527 if ((cellU >= 0) && (cellU < 2*N) && (cellV >= 0) && (cellV < 2*N)) {
528 return (((cellV-cellU) <
N) && ((cellU-cellV) <=
N));
536 const auto & indx =
getIndex(layer,
true);
537 if (indx.first < 0)
return false;
539 (irad <= hgpar_->iradMaxBH_[indx.first]) &&
540 (iphi > 0) && (iphi <= hgpar_->scintCells(layer)));
570 float x(999999.),
y(999999.);
573 if (i < 0)
return std::make_pair(
x,y);
590 return std::make_pair(
x,y);
594 int waferV,
int cellU,
595 int cellV,
bool reco,
610 <<
":" << waferV <<
":" << indx <<
":" 614 int kndx = cellV*100 + cellU;
624 << kndx <<
":" <<
x <<
":" << y <<
":" 636 << kndx <<
":" <<
x <<
":" << y <<
":" 651 <<
xy.first <<
":" <<
xy.second;
654 return std::make_pair(
x,y);
671 return std::make_pair(
x,y);
675 int iphi,
bool reco)
const {
678 const auto & indx =
getIndex(lay,reco);
679 if (indx.first >= 0) {
682 double phi = (iphi-0.5)*indx.second;
686 std::pair<double,double> range =
rangeR(z,
true);
696 return std::make_pair(
x,y);
704 int N(0), layer(0), waferU(0), waferV(0), u(0),
v(0);
709 waferU =
id.waferU();
710 waferV =
id.waferV();
717 waferU =
id.waferU();
718 waferV =
id.waferV();
726 <<
" Wafer " << waferU <<
":" 727 << waferV <<
" Index " << wl <<
":" 731 int ncor = (itr->second).
first;
732 int fcor = (itr->second).
second;
733 if (ncor < corners) {
738 case(0): { mask = (v >=
N);
break; }
739 case(1): { mask = (u >=
N);
break; }
740 case(2): { mask = (u <=
v);
break; }
741 case(3): { mask = (v <
N);
break; }
742 case(4): { mask = (u <
N);
break; }
743 default: { mask = (u >
v);
break; }
749 mask = !((u > 2*
v) && (v <
N));
751 mask = ((u >=
N) && (v >=
N) && ((u+
v) > (3*
N-2)));
759 mask = ((u >=
N) && (u > v) && ((2*u-
v) > 2*
N));
765 mask = !((u < N) && (v > u) && (v > (2*u-1)));
767 mask = ((u > 2*
v) && (v <
N));
773 mask = !((v >= u) && ((2*v-u) > (2*
N-2)));
781 mask = !((u >=
N) && (v >=
N) && ((u+
v) > (3*
N-2)));
783 mask = ((u < N) && (v > u) && (v > (2*u-1)));
789 mask = !((u >=
N) && (u > v) && ((2*u-
v) > 2*
N));
791 mask = ((v >= u) && ((2*v-u) > (2*
N-2)));
799 <<
" N " <<
N <<
" u " << u <<
" v " 800 << v <<
" Mask " <<
mask;
812 for (
unsigned int i = 0;
i<
layers(reco); ++
i) {
822 if (
index.first < 0)
return 0;
825 unsigned int cells(0);
830 if (cell > cells) cells = cell;
859 if (i < 0)
return kymax;
865 if (ky > kymax) kymax = ky;
877 return (((type1==type2) || (type1*type2 !=0)) ? uv :
878 ((type1==0) ? (2*uv+1)/3 : (3*uv)/2));
889 if (
index.first < 0)
return nmod;
909 for (
unsigned k=0;
k<nlayer; ++
k) {
911 cells = std::accumulate(ncells.begin(),ncells.end(),
cells);
920 std::vector<int> ncell;
928 ncell.emplace_back((
int)(cell));
934 ncell.emplace_back(nphi);
942 ncell.emplace_back(cell);
968 if (flag)
return (3*N*N);
973 double rmin(0), rmax(0),
zz(0);
1002 << zz <<
" R " << rmin <<
":" << rmax;
1004 return std::pair<double,double>(rmin,rmax);
1012 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalDDDConstants:rangeZ: " << zmin <<
":" 1019 return std::pair<double,double>(zmin,zmax);
1027 if ((copy/10000)%10 != 0) col = -col;
1028 row = (copy/100)%100;
1029 if ((copy/100000)%10 != 0) row = -row;
1031 return std::make_pair(row,col);
1039 return std::make_pair(cell,lay);
1045 <<
" not in the list ***** ERROR *****";
1046 return std::make_pair(-1,-1);
1052 <<
" ***** ERROR *****";
1053 return std::make_pair(-1,-1);
1060 }
else if (type == 2) {
1065 return std::make_pair(kx,depth);
1073 for (
int k=0;
k<ncopies; ++
k) {
1083 edm::LogVerbatim(
"HGCalGeom") <<
"Cannot find " << copy <<
" in a list of " 1084 << ncopies <<
" members";
1085 for (
int k=0;
k<ncopies; ++
k)
1093 int& wafer,
int& icell,
1094 int& celltyp)
const {
1100 for (
int k=0;
k<size_; ++
k) {
1113 if (wafer < size_) {
1123 edm::LogWarning(
"HGCalGeom") <<
"Cannot get wafer type corresponding to " 1124 << x <<
":" << y <<
" " << xx <<
":" <<
yy;
1129 << wafer <<
":" << size_ <<
" XX " << xx <<
":" 1130 << yy <<
" Cell " << icell <<
" Type " << celltyp;
1135 const int layer,
int& waferU,
1136 int& waferV,
int& cellU,
int& cellV,
1137 int& celltype,
double& wt,
bool 1159 <<
":" << yy <<
" compared with " 1162 <<
" difference " << dx <<
":" << dy
1166 << waferU <<
":" << waferV <<
":" 1176 cellHex(xx, yy, celltype, cellU, cellV
1181 wt = ((celltype < 2) ?
1193 << x <<
":" << x1 <<
":" << xx <<
" Y " << y
1194 <<
":" << y1 <<
":" << yy <<
" Wafer " 1195 << waferU <<
":" << waferV <<
" Cell " 1196 << cellU <<
":" << cellV;
1203 << dx <<
":" << dy <<
":" << dx*
tan30deg_ 1204 <<
":" <<
hexside_-dy <<
" Paramerers " 1213 const auto & indx =
getIndex(lay, reco);
1214 if (indx.first < 0)
return false;
1219 const auto & indx =
getIndex(lay, reco);
1220 if (indx.first < 0)
return false;
1227 double xx(0),
yy(0);
1236 return std::make_pair(
xx,yy);
1243 double xx(0),
yy(0);
1254 return std::make_pair(
xx,yy);
1287 if (
index.first < 0)
return 0;
1296 for (
unsigned int i = 0;
i<
layers(
true); ++
i) {
1312 unsigned ity = (type > 0 && type <= 2) ? type : 0;
1313 wafer = (itr->second)[ity];
1323 const double& cellR,
1324 const std::vector<double>&
posX,
1325 const std::vector<double>&
posY)
const {
1327 const double tol(0.00001);
1329 for (
unsigned int k=0;
k<posX.size(); ++
k) {
1332 if (dx <= (cellR+tol) && dy <= (cellY+tol)) {
1333 double xmax = (dy<=0.5*cellY) ? cellR : (cellR-(dy-0.5*cellY)/
tan30deg_);
1334 if (dx <= (xmax+tol)) {
1344 int& cellU,
int& cellV,
bool 1350 double Rc = 2*
rmax_/(3*N);
1351 double rc = 0.5*Rc*
sqrt3_;
1352 double v0 = ((xloc/Rc -1.0)/1.5);
1353 int cv0 = (v0 > 0) ? (N + (
int)(v0+0.5)) : (N - (
int)(-v0+0.5));
1354 double u0 = (0.5*yloc/rc+0.5*cv0);
1355 int cu0 = (u0 > 0) ? (N/2 + (
int)(u0+0.5)) : (N/2 - (
int)(-u0+0.5));
1358 if (cv0-cu0 >= N) cv0 = cu0+N-1;
1362 << yloc <<
":" << cellType <<
" parameter " 1363 << rc <<
":" << Rc <<
" u0 " << u0 <<
":" 1364 << cu0 <<
" v0 " << v0 <<
":" << cv0;
1367 static const int shift[3] = {0,1,-1};
1368 for (
int i1=0; i1<3; ++i1) {
1369 cellU = cu0 + shift[i1];
1370 for (
int i2=0; i2<3; ++i2) {
1371 cellV = cv0 + shift[i2];
1372 if (((cellV-cellU) < N) && ((cellU-cellV) <= N) && (cellU >= 0) &&
1373 (cellV >= 0) && (cellU < 2*N) && (cellV < 2*N)) {
1374 double xc = (1.5*(cellV-
N)+1.0)*Rc;
1375 double yc = (2*cellU-cellV-
N)*rc;
1382 << yc <<
" difference " 1386 <<
" comparator " << rc <<
":" << Rc
1387 <<
" (u,v) = (" << cellU <<
"," 1390 found =
true;
break;
1396 if (!found) { cellU = cu0; cellV = cv0; }
1402 if (indx<0)
return std::make_pair(-1,0);
1415 return std::make_pair(indx,cell);
1431 double rr =
sqrt(x*x+y*y);
1433 (rr <= hgpar_->rMaxLayHex_[lay-1]) &&
1438 << cell <<
" Position " << x <<
":" << y
1439 <<
":" << rr <<
" Compare Limits " 1452 xc[0] = waferX; yc[0] = waferY+
hexside_;
1460 xc[3] = waferX; yc[3] = waferY-
hexside_;
1463 bool cornerOne(
false), cornerAll(
true);
1467 (rpos <= hgpar_->rMaxLayHex_[lay])) cornerOne =
true;
1468 else cornerAll =
false;
1470 bool in = full ? cornerOne : cornerAll;
1473 <<
" wafer " << wafer <<
" R-limits " 1476 << cornerOne <<
":" << cornerAll <<
" In "
std::vector< int > iradMaxBH_
bool isHalfCell(int waferType, int cell) const
std::vector< double > waferPosY_
std::vector< int > layer_
std::vector< int > depthLayerF_
bool isValidTrap(int lay, int ieta, int iphi) const
std::vector< int > depth_
std::vector< double > zFrontMin_
std::vector< double > moduleCellR_
int getTypeTrap(int layer) const
layer_map copiesInLayers_
int getLayer(double z, bool reco) const
std::vector< HGCalParameters::hgtrap > getModules() const
std::vector< bool > cellCoarseHalf_
std::vector< bool > cellFineHalf_
std::array< uint32_t, 2 > tot_layers_
int scintType(const int layer) const
std::map< int, HGCWaferParam > waferLayer_
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
int type() const
get the type
std::vector< int > moduleLayR_
double cellSizeHex(int type) const
int32_t maxWafersPerLayer_
HGCalParameters::hgtrform getTrForm(unsigned int k) const
Simrecovecs max_modules_layer_
int lastLayer(bool reco) const
double cellThickness(int layer, int waferU, int waferV) const
unsigned int layersInit(bool reco) const
static int32_t waferV(const int32_t index)
std::array< int, 4 > waferMax_
Sin< T >::type sin(const T &t)
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
int maxRows(int lay, bool reco) const
int getTypeHex(int layer, int waferU, int waferV) const
std::vector< double > cellFineY_
bool waferInLayerTest(int wafer, int lay, bool full) const
int modulesInit(int lay, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
std::vector< uint32_t > trformIndex_
bool isValidHex(int lay, int mod, int cell, bool reco) const
std::vector< int > layerGroupM_
HGCalGeometryMode::GeometryMode mode_
HGCalGeometryMode::GeometryMode mode_
double scintCellSize(const int layer) const
int cellHex(double xx, double yy, const double &cellR, const std::vector< double > &posX, const std::vector< double > &posY) const
int layerIndex(int lay, bool reco) const
wafer_map wafersInLayers_
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
U second(std::pair< T, U > const &p)
std::vector< double > cellCoarseX_
std::pair< double, double > rangeR(double z, bool reco) const
int modules(int lay, bool reco) const
std::vector< int > firstModule_
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
unsigned int getTrFormN() const
double distFromEdgeTrap(double x, double y, double z) const
std::pair< double, double > rangeZ(bool reco) const
unsigned int layers(bool reco) const
bool isValidHex8(int lay, int modU, int modV, int cellU, int cellV) const
int numberCellsHexagon(int wafer) const
std::vector< double > cellSize_
std::vector< int > waferUVMaxLayer_
std::vector< HGCalParameters::hgtrform > getTrForms() const
std::vector< int > layerIndex_
double mouseBite(bool reco) const
hgtrform getTrForm(unsigned int k) const
int type() const
get the type
std::pair< int, float > getIndex(int lay, bool reco) const
static double k_ScaleFromDDD
HGCalDDDConstants(const HGCalParameters *hp, const std::string &name)
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
std::vector< double > rMaxFront_
Cos< T >::type cos(const T &t)
int scintCells(const int layer) const
hgtrap getModule(unsigned int k, bool reco) const
CellType cellType(int type, int waferU, int waferV) const
Abs< T >::type abs(const T &t)
std::unordered_map< int32_t, bool > waferIn_
std::vector< double > slopeTop_
static int32_t waferU(const int32_t index)
bool isValidCell(int layindex, int wafer, int cell) const
int waferTypeL(int wafer) const
std::vector< double > rMinLayHex_
static int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
std::pair< int, int > rowColumnWafer(const int wafer) const
std::vector< double > zLayerHex_
double waferZ(int layer, bool reco) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
int waferType(DetId const &id) const
bool waferVirtual(int layer, int waferU, int waferV) const
std::vector< double > rMaxLayHex_
static uint32_t k_CornerSize
std::vector< double > slopeMin_
std::vector< int > lastModule_
int waferFromCopy(int copy) const
std::vector< double > radiusMixBoundary_
std::vector< double > cellThickness_
std::vector< int > layerGroup_
std::vector< double > moduleCellS_
static double k_ScaleToDDD
bool maskCell(const DetId &id, int corners) const
int numberCells(bool reco) const
wafer_map cellCoarseIndex_
bool waferFullInLayer(int wafer, int lay, bool reco) const
std::vector< double > rMinFront_
std::vector< int > iradMinBH_
std::vector< double > cellFineX_
std::vector< int > layerGroupO_
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco) const
std::vector< int > waferCopy_
static unsigned int const shift
std::vector< int > depthIndex_
std::pair< double, double > waferPosition(int wafer, bool reco) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
std::vector< double > zFrontTop_
std::vector< double > radiusLayer_[2]
std::vector< int > waferTypeT_
std::vector< double > cellCoarseY_
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
const HGCalParameters * hgpar_
int maxCells(bool reco) const
std::vector< double > waferPosX_
int modifyUV(int uv, int type1, int type2) const
T mod(const T &a, const T &b)
std::vector< int > waferTypeL_
int getUVMax(int type) const
double distFromEdgeHex(double x, double y, double z) const
std::array< int, 3 > HGCWaferParam
bool waferInLayer(int wafer, int lay, bool reco) const
constexpr Detector det() const
get the detector field from this detid