18 : hgcons_(hgc), mode_(hgc.geomMode()), det_(det), name_(name) {
39 edm::LogVerbatim(
"HGCSim") <<
"HGCalNumberingScheme:: input Layer " << layer <<
" Module " << module <<
" Cell "
40 << cell <<
" iz " << iz <<
" Position " << pos;
43 int cellU(0), cellV(0), waferType(-1),
waferU(0),
waferV(0);
51 double xx = (pos.z() > 0) ? pos.x() : -pos.x();
52 hgcons_.
waferFromPosition(xx, pos.y(),
layer,
waferU,
waferV, cellU, cellV, waferType, wt,
false,
false);
57 if (type != waferType) {
59 edm::LogVerbatim(
"HGCSim") <<
"HGCalNumberingScheme:: " <<
name_ <<
" Layer|u|v|Index|module|cell " << layer
60 <<
":" <<
waferU <<
":" << waferV <<
":"
62 <<
":" << cell <<
" has a type mismatch " << waferType <<
":" <<
type;
70 edm::LogVerbatim(
"HGCSim") <<
"OK WaferType " << waferType <<
" Wafer " <<
waferU <<
":" << waferV <<
" Cell "
71 << cellU <<
":" << cellV <<
" input " << cell <<
" wt " << wt <<
" Mode " <<
mode_;
73 edm::LogVerbatim(
"HGCSim") <<
"Bad WaferType " << waferType <<
" for Layer:u:v " << layer <<
":" <<
waferU <<
":"
82 if (typm.first >= 0) {
86 index = detId.
rawId();
89 edm::LogVerbatim(
"HGCSim") <<
"Radius/Phi " <<
id[0] <<
":" <<
id[1] <<
" Type " <<
id[2] <<
":" << typm.first
90 <<
" SiPM " << typm.second <<
":" <<
hgcons_.
tileSiPM(typm.second) <<
" Layer "
91 << layer <<
":" << lay <<
" z " << iz <<
" " << detId;
93 edm::LogVerbatim(
"HGCSim") <<
"Radius/Phi " <<
id[0] <<
":" <<
id[1] <<
" Type " <<
id[2] <<
" Layer|iz " << layer
94 <<
":" << iz <<
" ERROR";
102 edm::LogVerbatim(
"HGCSim") <<
"HGCalNumberingScheme::i/p " <<
det_ <<
":" << layer <<
":" << module <<
":" << cell
103 <<
":" << iz <<
":" << pos.x() <<
":" << pos.y() <<
":" << pos.z() <<
" ID " << std::hex
104 << index <<
std::dec <<
" wt " << wt;
111 std::pair<float, float>
xy;
113 double z1(0), tolR(14.0), tolZ(1.0);
134 double r1 =
std::sqrt(xy.first * xy.first + xy.second * xy.second);
135 double r2 = pos.perp();
138 std::pair<double, double> rrange =
hgcons_.
rangeR(z2,
false);
140 bool inok = ((r2 >= rrange.first) && (r2 <= rrange.second) && (z2 >= zrange.first) && (z2 <= zrange.second));
141 bool outok = ((r1 >= rrange.first) && (r1 <= rrange.second) && (z1 >= zrange.first) && (z1 <= zrange.second));
142 std::string ck = (((r1 < rrange.first - tolR) || (r1 > rrange.second + tolR) || (z1 < zrange.first - tolZ) ||
143 (z1 > zrange.second + tolZ))
144 ?
"***** ERROR *****"
146 if (matchOnly && match)
148 if (!(match && inok && outok) ||
debug) {
149 edm::LogVerbatim(
"HGCSim") <<
"HGCalNumberingScheme::Detector " <<
det_ <<
" Layer " << lay <<
" R " << r2 <<
":"
150 << r1 <<
":" << rrange.first <<
":" << rrange.second <<
" Z " << z2 <<
":" << z1 <<
":"
151 << zrange.first <<
":" << zrange.second <<
" Match " << match <<
":" << inok <<
":"
152 << outok <<
" " << ck;
153 edm::LogVerbatim(
"HGCSim") <<
"Original " << pos.x() <<
":" << pos.y() <<
" return " << xy.first <<
":"
156 double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x());
158 hgcons_.
waferFromPosition(xx, pos.y(), lay,
waferU,
waferV, cellU, cellV, waferType, wt,
false,
true);
160 double dx = (xx - xy.first);
161 double dy = (pos.y() - xy.second);
162 double dR =
std::sqrt(dx * dx + dy * dy);
163 ck = (dR > tolR) ?
" ***** ERROR *****" :
"";
165 <<
":" << pos.y() <<
" derived " << xy.first <<
":" << xy.second <<
" Difference "
Log< level::Info, true > LogVerbatim
HGCalNumberingScheme()=delete
void checkPosition(uint32_t index, const G4ThreeVector &pos, bool matchOnly, bool debug) const
static int32_t getUnpackedCellU(int id)
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
int tileSiPM(int sipm) const
static int32_t getUnpackedU(int id)
const HGCalGeometryMode::GeometryMode mode_
int32_t waferU(const int32_t index)
const HGCalDDDConstants & hgcons_
constexpr uint32_t rawId() const
get the raw id
static int32_t getUnpackedV(int id)
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
constexpr std::array< uint8_t, layerIndexSize > layer
std::pair< double, double > rangeR(double z, bool reco) const
std::pair< double, double > rangeZ(bool reco) const
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
bool tileTrapezoid() const
Abs< T >::type abs(const T &t)
static int32_t getUnpackedType(int id)
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
double waferZ(int layer, bool reco) const
Basic2DVector< T > xy() const
uint32_t getUnitID(int layer, int module, int cell, int iz, const G4ThreeVector &pos, double &wt)
assigns the det id to a hit
static int32_t getUnpackedCellV(int id)
int32_t waferV(const int32_t index)
bool waferHexagon8() const
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::pair< int, int > tileType(int layer, int ring, int phi) const
int getLayerOffset() const
int waferType(DetId const &id, bool fromFile=false) const