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) ? 0 : 1));
261 for (
int k=0;
k<sizew; ++
k) {
285 << yy <<
" wafer " << wafer <<
" flag " 286 << (wafer < sizew) <<
" Distance " <<
rmax_ 299 double xx = (z < 0) ? -x : x;
302 double phi = (r == 0. ? 0. : std::atan2(y,xx));
303 if (phi < 0) phi += (2.0*
M_PI);
313 int iphi = 1 + (
int)(phi/cell);
319 << y <<
":" << z <<
" Layer " << lay
320 <<
" Index " << indx <<
":" << type <<
" xx " 321 << xx <<
" R " << r <<
":" << irad <<
":" 324 <<
" Phi " << phi <<
":" << iphi <<
":" 325 << (iphi-0.5)*cell <<
" cell " << cell
326 <<
" Dphi " << dphi <<
" Dist " << dist
339 std::find_if(zLayerHex.begin()+1,zLayerHex.end(),[&
k,&
zz,&zLayerHex](
double zLayer){ ++
k;
return zz < 0.5*(zLayerHex[k-1]+zLayerHex[
k]);});
358 edm::LogWarning(
"HGCalGeom") <<
"Wafer no. out bound for index " << indx
362 <<
" ***** ERROR *****";
365 if (type > 0) --
type;
375 std::vector<HGCalParameters::hgtrap> mytrs;
383 std::vector<HGCalParameters::hgtrform> mytrs;
411 if (waferType < 1 || cell < 0)
return false;
418 bool result(
false), resultMod(
false);
425 const int32_t lay_idx = reco ? (lay-1)*3 + 1 : lay;
427 auto moditr = the_modules.find(copyNumber);
428 result = resultMod = (moditr != the_modules.end());
432 <<
":" << lay_idx <<
" Copy " 433 << copyNumber <<
":" << mod
437 if (moditr->second >= 0) {
440 << mod <<
" to be compared with " 442 <<
" ***** ERROR *****";
445 result = (cell >=0 && cell <= cellmax);
456 << (lay > 0 && (lay <= (
int)(
layers(reco))))
457 <<
" Module " << mod <<
":" << resultMod
458 <<
" Cell " << cell <<
":" << cellmax <<
":" 459 << (cell >=0 && cell <= cellmax)
472 if (!(jtr->second))
return false;
475 if ((cellU >= 0) && (cellU < 2*N) && (cellV >= 0) && (cellV < 2*N)) {
476 return (((cellV-cellU) <
N) && ((cellU-cellV) <=
N));
484 const auto & indx =
getIndex(layer,
true);
485 if (indx.first < 0)
return false;
487 (irad <= hgpar_->iradMaxBH_[indx.first]) &&
488 (iphi > 0) && (iphi <= hgpar_->scintCells(layer)));
514 float x(999999.),
y(999999.);
517 if (i < 0)
return std::make_pair(
x,y);
534 return std::make_pair(
x,y);
538 int waferV,
int cellU,
539 int cellV,
bool reco,
554 <<
":" << waferV <<
":" << indx <<
":" 558 int kndx = cellV*100 + cellU;
568 << kndx <<
":" <<
x <<
":" << y <<
":" 580 << kndx <<
":" <<
x <<
":" << y <<
":" 595 <<
xy.first <<
":" <<
xy.second;
598 return std::make_pair(
x,y);
615 return std::make_pair(
x,y);
619 int iphi,
bool reco)
const {
622 const auto & indx =
getIndex(lay,reco);
623 if (indx.first >= 0) {
626 double phi = (iphi-0.5)*indx.second;
630 std::pair<double,double> range =
rangeR(z,
true);
640 return std::make_pair(
x,y);
646 for (
unsigned int i = 0;
i<
layers(reco); ++
i) {
656 if (
index.first < 0)
return 0;
659 unsigned int cells(0);
664 if (cell > cells) cells = cell;
693 if (i < 0)
return kymax;
699 if (ky > kymax) kymax = ky;
717 if (
index.first < 0)
return nmod;
737 for (
unsigned k=0;
k<nlayer; ++
k) {
739 cells = std::accumulate(ncells.begin(),ncells.end(),cells);
748 std::vector<int> ncell;
756 ncell.emplace_back((
int)(cell));
762 ncell.emplace_back(nphi);
770 ncell.emplace_back(cell);
796 if (flag)
return (3*N*N);
801 double rmin(0), rmax(0),
zz(0);
830 <<
" R " << rmin <<
":" << rmax;
832 return std::pair<double,double>(rmin,rmax);
847 return std::pair<double,double>(zmin,zmax);
855 if ((copy/10000)%10 != 0) col = -col;
856 row = (copy/100)%100;
857 if ((copy/100000)%10 != 0) row = -row;
859 return std::make_pair(row,col);
867 return std::make_pair(cell,lay);
873 <<
" not in the list ***** ERROR *****";
874 return std::make_pair(-1,-1);
880 <<
" ***** ERROR *****";
881 return std::make_pair(-1,-1);
888 }
else if (type == 2) {
893 return std::make_pair(kx,depth);
901 for (
int k=0;
k<ncopies; ++
k) {
912 << ncopies <<
" members";
913 for (
int k=0;
k<ncopies; ++
k)
921 int& wafer,
int& icell,
922 int& celltyp)
const {
928 for (
int k=0;
k<size_; ++
k) {
951 edm::LogWarning(
"HGCalGeom") <<
"Cannot get wafer type corresponding to " 952 << x <<
":" << y <<
" " << xx <<
":" <<
yy;
957 << wafer <<
":" << size_ <<
" XX " << xx <<
":" 958 << yy <<
" Cell " << icell <<
" Type " << celltyp;
963 const int layer,
int& waferU,
964 int& waferV,
int& cellU,
int& cellV,
965 int& celltype,
double& wt,
bool 987 <<
":" << yy <<
" compared with " 990 <<
" difference " << dx <<
":" << dy
994 << waferU <<
":" << waferV <<
":" 1004 cellHex(xx, yy, celltype, cellU, cellV
1009 wt = ((celltype < 2) ?
1021 << x <<
":" << x1 <<
":" << xx <<
" Y " << y
1022 <<
":" << y1 <<
":" << yy <<
" Wafer " 1023 << waferU <<
":" << waferV <<
" Cell " 1024 << cellU <<
":" << cellV;
1031 << dx <<
":" << dy <<
":" << dx*
tan30deg_ 1032 <<
":" <<
hexside_-dy <<
" Paramerers " 1041 const auto & indx =
getIndex(lay, reco);
1042 if (indx.first < 0)
return false;
1047 const auto & indx =
getIndex(lay, reco);
1048 if (indx.first < 0)
return false;
1055 double xx(0),
yy(0);
1064 return std::make_pair(
xx,yy);
1071 double xx(0),
yy(0);
1082 return std::make_pair(
xx,yy);
1101 if (
index.first < 0)
return 0;
1110 for (
unsigned int i = 0;
i<
layers(
true); ++
i) {
1126 unsigned ity = (type > 0 && type <= 2) ? type : 0;
1127 wafer = (itr->second)[ity];
1137 const double& cellR,
1138 const std::vector<double>&
posX,
1139 const std::vector<double>&
posY)
const {
1141 const double tol(0.00001);
1143 for (
unsigned int k=0;
k<posX.size(); ++
k) {
1146 if (dx <= (cellR+tol) && dy <= (cellY+tol)) {
1147 double xmax = (dy<=0.5*cellY) ? cellR : (cellR-(dy-0.5*cellY)/
tan30deg_);
1148 if (dx <= (xmax+tol)) {
1158 int& cellU,
int& cellV,
bool 1164 double Rc = 2*
rmax_/(3*N);
1165 double rc = 0.5*Rc*
sqrt3_;
1166 double v0 = ((xloc/Rc -1.0)/1.5);
1167 int cv0 = (v0 > 0) ? (N + (
int)(v0+0.5)) : (N - (
int)(-v0+0.5));
1168 double u0 = (0.5*yloc/rc+0.5*cv0);
1169 int cu0 = (u0 > 0) ? (N/2 + (
int)(u0+0.5)) : (N/2 - (
int)(-u0+0.5));
1172 if (cv0-cu0 >= N) cv0 = cu0+N-1;
1176 << yloc <<
":" << cellType <<
" parameter " 1177 << rc <<
":" << Rc <<
" u0 " << u0 <<
":" 1178 << cu0 <<
" v0 " << v0 <<
":" << cv0;
1181 static const int shift[3] = {0,1,-1};
1182 for (
int i1=0; i1<3; ++i1) {
1183 cellU = cu0 + shift[i1];
1184 for (
int i2=0; i2<3; ++i2) {
1185 cellV = cv0 + shift[i2];
1186 if (((cellV-cellU) < N) && ((cellU-cellV) <= N) && (cellU >= 0) &&
1187 (cellV >= 0) && (cellU < 2*N) && (cellV < 2*N)) {
1188 double xc = (1.5*(cellV-
N)+1.0)*Rc;
1189 double yc = (2*cellU-cellV-
N)*rc;
1196 << yc <<
" difference " 1200 <<
" comparator " << rc <<
":" << Rc
1201 <<
" (u,v) = (" << cellU <<
"," 1204 found =
true;
break;
1210 if (!found) { cellU = cu0; cellV = cv0; }
1216 if (indx<0)
return std::make_pair(-1,0);
1229 return std::make_pair(indx,cell);
1245 double rr =
sqrt(x*x+y*y);
1247 (rr <= hgpar_->rMaxLayHex_[lay-1]) &&
1252 << cell <<
" Position " << x <<
":" << y
1253 <<
":" << rr <<
" Compare Limits " 1268 xc[2] = waferX; yc[2] = waferY+
hexside_;
1271 xc[5] = waferX; yc[5] = waferY-
hexside_;
1272 bool cornerOne(
false), cornerAll(
true);
1276 (rpos <= hgpar_->rMaxLayHex_[lay])) cornerOne =
true;
1277 else cornerAll =
false;
1279 bool in = full ? cornerOne : cornerAll;
1282 <<
" wafer " << wafer <<
" R-limits " 1285 << 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_
double cellThickness(int layer, int waferU, int waferV) const
unsigned int layersInit(bool reco) const
static int32_t waferV(const int32_t index)
static int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV)
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
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
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_
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
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
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_
T mod(const T &a, const T &b)
std::vector< int > waferTypeL_
double distFromEdgeHex(double x, double y, double z) const
std::array< int, 3 > HGCWaferParam
bool waferInLayer(int wafer, int lay, bool reco) const