11 #include "CLHEP/Units/GlobalPhysicalConstants.h" 12 #include "CLHEP/Units/GlobalSystemOfUnits.h" 42 for (
int simreco = 0; simreco < 2; ++simreco) {
45 for (
unsigned int layer=1; layer <=
tot_layers_[simreco]; ++layer) {
62 << name <<
" with " <<
layers(
false) <<
":" 64 <<
":" << 2*
modHalf_ <<
" wafers with maximum " 66 <<
"maximum of " <<
maxCells(
false) <<
":" 73 int wminT(9999999), wmaxT(-9999999), kount1(0), kount2(0);
76 int wmin(9999999), wmax(-9999999), kount(0);
77 for (
int wafer=0; wafer<
sectors(); ++wafer) {
88 if (waferU < wmin) wmin = waferU;
89 if (waferU > wmax) wmax = waferU;
93 if (wminT > wmin) wminT = wmin;
94 if (wmaxT < wmax) wmaxT = wmax;
95 if (kount1 < kount) kount1= kount;
98 int lay1 =
getIndex(lay0,
true).first;
100 <<
":" << lay1 <<
" Wafer " << wmin
101 <<
":" << wmax <<
":" << kount;
106 waferMax_ = std::array<int,4>{ {wminT,wmaxT,kount1,kount2} };
109 <<
":" << wmaxT <<
":" << kount1 <<
":" 118 int subSec,
bool reco)
const {
120 if (
index.first < 0)
return std::make_pair(-1,-1);
133 <<
" ***** ERROR *****";
134 return std::make_pair(-1,-1);
140 return std::make_pair(wafer,
cellHex(xx, yy,
144 return std::make_pair(wafer,
cellHex(xx, yy,
149 return std::make_pair(-1,-1);
155 int waferU(0), waferV(0),
waferType(-1), cellU(0), cellV(0);
163 return std::array<int,5>{ {waferU,waferV,
waferType,cellU,cellV} };
170 int ieta(-1), iphi(-1),
type(-1);
171 const auto & indx =
getIndex(layer,reco);
172 if (indx.first < 0)
return std::array<int,3>{ {ieta,iphi,type} };
173 double xx = (z > 0) ? x : -x;
179 double phi = (r*stheta == 0. ? 0. : std::atan2(y,xx));
180 if (phi < 0) phi += (2.0*
M_PI);
183 iphi = 1 + (
int)(phi/indx.second);
187 <<
":" << z <<
":" << layer <<
":" << reco
188 <<
" x|z|r " << xx <<
":" << zz <<
":" << r
189 <<
" theta|phi " << theta <<
":" << stheta
190 <<
":" << phi <<
" o/p " << ieta <<
":" 191 << iphi <<
":" <<
type;
193 return std::array<int,3>{ {ieta,iphi,type} };
197 int cellV,
int lay,
bool reco)
const {
198 const auto & indx =
getIndex(lay,
true);
199 if (indx.first >= 0) {
206 locateCell(lay, waferU, waferV, cellU, cellV, reco,
true) :
208 double rpos =
sqrt(
xy.first*
xy.first +
xy.second*
xy.second);
210 (rpos <= hgpar_->rMaxLayHex_[indx.first]));
241 ((type >= 1) ? 1 : 0) : ((type == 1) ? 0 : 1));
255 for (
int k=0;
k<sizew; ++
k) {
278 << yy <<
" wafer " << wafer <<
" flag " 279 << (wafer < sizew) <<
" Distance " <<
rmax_ 290 double xx = (z < 0) ? -x : x;
296 double phi = (r*stheta == 0. ? 0. : std::atan2(y,xx));
297 if (phi < 0) phi += (2.0*
M_PI);
301 int iphi = 1 + (
int)(phi/cell);
309 << y <<
":" << z <<
" Layer " << lay
310 <<
" Index " << indx <<
" xx|zz " << xx <<
":" 311 << zz <<
" Eta " << eta <<
":"<< ieta <<
":" 313 <<
" Phi " << phi <<
":" << iphi <<
":" 314 << (iphi-0.5)*cell <<
" cell " << cell <<
" R " 315 << rr <<
" Dphi " << dphi <<
" Dist " << dist
316 <<
":" << rr*dphi <<
":" 329 std::find_if(zLayerHex.begin()+1,zLayerHex.end(),[&
k,&
zz,&zLayerHex](
double zLayer){ ++
k;
return zz < 0.5*(zLayerHex[k-1]+zLayerHex[
k]);});
348 edm::LogWarning(
"HGCalGeom") <<
"Wafer no. out bound for index " << indx
352 <<
" ***** ERROR *****";
355 if (type > 0) --
type;
365 std::vector<HGCalParameters::hgtrap> mytrs;
373 std::vector<HGCalParameters::hgtrform> mytrs;
402 if (waferType < 1 || cell < 0)
return false;
409 bool result(
false), resultMod(
false);
416 const int32_t lay_idx = reco ? (lay-1)*3 + 1 : lay;
418 auto moditr = the_modules.find(copyNumber);
419 result = resultMod = (moditr != the_modules.end());
423 <<
":" << lay_idx <<
" Copy " 424 << copyNumber <<
":" << mod
428 if (moditr->second >= 0) {
431 << mod <<
" to be compared with " 433 <<
" ***** ERROR *****";
436 result = (cell >=0 && cell <= cellmax);
447 << (lay > 0 && (lay <= (
int)(
layers(reco))))
448 <<
" Module " << mod <<
":" << resultMod
449 <<
" Cell " << cell <<
":" << cellmax <<
":" 450 << (cell >=0 && cell <= cellmax)
462 if (!(jtr->second))
return false;
465 if ((cellU >= 0) && (cellU < 2*N) && (cellV >= 0) && (cellV < 2*N)) {
466 return (((cellV-cellU) <
N) && ((cellU-cellV) <=
N));
473 const auto & indx =
getIndex(layer,
true);
474 if (indx.first < 0)
return false;
479 (iphi > 0) && (iphi <= hgpar_->nPhiBinBH_[indx.first]));
505 float x(999999.),
y(999999.);
508 if (i < 0)
return std::make_pair(
x,y);
525 return std::make_pair(
x,y);
529 int waferV,
int cellU,
530 int cellV,
bool reco,
538 int kndx = cellV*100 + cellU;
561 return std::make_pair(
x,y);
578 return std::make_pair(
x,y);
582 int iphi,
bool reco)
const {
585 const auto & indx =
getIndex(lay,reco);
586 if (indx.first >= 0) {
589 double phi = (iphi-0.5)*indx.second;
599 return std::make_pair(
x,y);
605 for (
unsigned int i = 0;
i<
layers(reco); ++
i) {
615 if (
index.first < 0)
return 0;
618 unsigned int cells(0);
623 if (cell > cells) cells = cell;
652 if (i < 0)
return kymax;
658 if (ky > kymax) kymax = ky;
676 if (
index.first < 0)
return nmod;
696 for (
unsigned k=0;
k<nlayer; ++
k) {
698 cells = std::accumulate(ncells.begin(),ncells.end(),cells);
707 std::vector<int> ncell;
715 ncell.emplace_back((
int)(cell));
721 ncell.emplace_back(nphi);
729 ncell.emplace_back(cell);
755 if (flag)
return (3*N*N);
764 if ((copy/10000)%10 != 0) col = -col;
765 row = (copy/100)%100;
766 if ((copy/100000)%10 != 0) row = -row;
768 return std::make_pair(row,col);
776 return std::make_pair(cell,lay);
782 <<
" not in the list ***** ERROR *****";
783 return std::make_pair(-1,-1);
789 <<
" ***** ERROR *****";
790 return std::make_pair(-1,-1);
797 }
else if (type == 2) {
802 return std::make_pair(kx,depth);
810 for (
int k=0;
k<ncopies; ++
k) {
821 << ncopies <<
" members";
822 for (
int k=0;
k<ncopies; ++
k)
830 int& wafer,
int& icell,
831 int& celltyp)
const {
837 for (
int k=0;
k<size_; ++
k) {
860 edm::LogWarning(
"HGCalGeom") <<
"Cannot get wafer type corresponding to " 861 << x <<
":" << y <<
" " << xx <<
":" <<
yy;
866 << wafer <<
":" << size_ <<
" XX " << xx <<
":" 867 << yy <<
" Cell " << icell <<
" Type " << celltyp;
872 const int layer,
int& waferU,
873 int& waferV,
int& cellU,
int& cellV,
874 int& celltype,
double& wt)
const {
896 cellHex(xx, yy, celltype, cellU, cellV);
897 wt = ((celltype < 2) ?
909 << x <<
":" << x1 <<
":" << xx <<
" Y " << y
910 <<
":" << y1 <<
":" << yy <<
" Wafer " 911 << waferU <<
":" << waferV <<
" Cell " 912 << cellU <<
":" << cellV;
919 << dx <<
":" << dy <<
":" << dx*
tan30deg_ 920 <<
":" <<
hexside_-dy <<
" Paramerers " 929 const auto & indx =
getIndex(lay, reco);
930 if (indx.first < 0)
return false;
935 const auto & indx =
getIndex(lay, reco);
936 if (indx.first < 0)
return false;
952 return std::make_pair(
xx,yy);
970 return std::make_pair(
xx,yy);
988 if (
index.first < 0)
return 0;
997 for (
unsigned int i = 0;
i<
layers(
true); ++
i) {
1013 unsigned ity = (type > 0 && type <= 2) ? type : 0;
1014 wafer = (itr->second)[ity];
1024 const double& cellR,
1025 const std::vector<double>&
posX,
1026 const std::vector<double>&
posY)
const {
1028 const double tol(0.00001);
1030 for (
unsigned int k=0;
k<posX.size(); ++
k) {
1033 if (dx <= (cellR+tol) && dy <= (cellY+tol)) {
1034 double xmax = (dy<=0.5*cellY) ? cellR : (cellR-(dy-0.5*cellY)/
tan30deg_);
1035 if (dx <= (xmax+tol)) {
1045 int& cellU,
int& cellV)
const {
1047 double Rc = 2*
rmax_/(3*N);
1048 double rc = 0.5*Rc*
sqrt3_;
1049 double v0 = ((xloc/Rc -1.0)/1.5);
1050 int cv0 = (v0 > 0) ? (N + (
int)(v0+0.5)) : (N - (
int)(-v0+0.5));
1051 double u0 = (0.5*yloc/rc+0.5*cv0);
1052 int cu0 = (u0 > 0) ? (N/2 + (
int)(u0+0.5)) : (N/2 - (
int)(-u0+0.5));
1054 static const int shift[3] = {0,1,-1};
1055 for (
int i1=0; i1<3; ++i1) {
1056 cellU = cu0 + shift[i1];
1057 for (
int i2=0; i2<3; ++i2) {
1058 cellV = cv0 + shift[i2];
1059 double xc = (1.5*(cellV-
N)+1.0)*Rc;
1060 double yc = (2*cellU-cellV-
N)*rc;
1064 found =
true;
break;
1069 if (!found) { cellU = cu0; cellV = cv0; }
1075 if (indx<0)
return std::make_pair(-1,0);
1088 return std::make_pair(indx,cell);
1104 double rr =
sqrt(x*x+y*y);
1106 (rr <= hgpar_->rMaxLayHex_[lay-1]) &&
1111 << cell <<
" Position " << x <<
":" << y
1112 <<
":" << rr <<
" Compare Limits " 1127 xc[2] = waferX; yc[2] = waferY+
hexside_;
1130 xc[5] = waferX; yc[5] = waferY-
hexside_;
1131 bool cornerOne(
false), cornerAll(
true);
1135 (rpos <= hgpar_->rMaxLayHex_[lay])) cornerOne =
true;
1136 else cornerAll =
false;
1138 bool in = full ? cornerOne : cornerAll;
1141 <<
" wafer " << wafer <<
" R-limits " 1144 << cornerOne <<
":" << cornerAll <<
" In "
bool isHalfCell(int waferType, int cell) const
std::vector< double > waferPosY_
std::vector< int > layer_
std::vector< int > iEtaMinBH_
std::vector< int > depthLayerF_
bool isValidTrap(int lay, int ieta, int iphi) const
std::vector< int > depth_
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_
std::map< int, HGCWaferParam > waferLayer_
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
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
Geom::Theta< T > theta() 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_
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
std::vector< int > nPhiBinBH_
wafer_map wafersInLayers_
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::vector< double > cellCoarseX_
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
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
Cos< T >::type cos(const T &t)
hgtrap getModule(unsigned int k, bool reco) const
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::unordered_map< int32_t, bool > waferIn_
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_
int scintType(const float dPhi) const
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< int > lastModule_
int waferFromCopy(int copy) const
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 > 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< int > waferTypeT_
std::vector< double > cellCoarseY_
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
const HGCalParameters * hgpar_
std::vector< double > dPhiEtaBH_
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