CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HGCalNumberingScheme Class Reference

#include <HGCalNumberingScheme.h>

Public Member Functions

uint32_t getUnitID (int layer, int module, int cell, int iz, const G4ThreeVector &pos, double &wt)
 assigns the det id to a hit More...
 
 HGCalNumberingScheme (const HGCalDDDConstants &hgc, const DetId::Detector &det, const std::string &name)
 
 HGCalNumberingScheme ()=delete
 
 ~HGCalNumberingScheme ()
 

Private Member Functions

void checkPosition (uint32_t index, const G4ThreeVector &pos, bool matchOnly, bool debug) const
 

Private Attributes

DetId::Detector det_
 
const HGCalDDDConstantshgcons_
 
const HGCalGeometryMode::GeometryMode mode_
 
std::string name_
 

Detailed Description

Definition at line 16 of file HGCalNumberingScheme.h.

Constructor & Destructor Documentation

◆ HGCalNumberingScheme() [1/2]

HGCalNumberingScheme::HGCalNumberingScheme ( const HGCalDDDConstants hgc,
const DetId::Detector det,
const std::string &  name 
)

Definition at line 15 of file HGCalNumberingScheme.cc.

References det_, HGCalGeometryMode::Hexagon8, HGCalGeometryMode::Hexagon8File, HGCalGeometryMode::Hexagon8Full, HGCalGeometryMode::Hexagon8Module, mode_, name_, HGCalGeometryMode::Trapezoid, HGCalGeometryMode::TrapezoidFile, and HGCalGeometryMode::TrapezoidModule.

18  : hgcons_(hgc), mode_(hgc.geomMode()), det_(det), name_(name) {
19 #ifdef EDM_ML_DEBUG
20  edm::LogVerbatim("HGCSim") << "Creating HGCalNumberingScheme for " << name_ << " Det " << det_ << " Mode " << mode_
25 #endif
26 }
Log< level::Info, true > LogVerbatim
const HGCalGeometryMode::GeometryMode mode_
const HGCalDDDConstants & hgcons_

◆ HGCalNumberingScheme() [2/2]

HGCalNumberingScheme::HGCalNumberingScheme ( )
delete

◆ ~HGCalNumberingScheme()

HGCalNumberingScheme::~HGCalNumberingScheme ( )

Definition at line 28 of file HGCalNumberingScheme.cc.

28  {
29 #ifdef EDM_ML_DEBUG
30  edm::LogVerbatim("HGCSim") << "Deleting HGCalNumberingScheme";
31 #endif
32 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

◆ checkPosition()

void HGCalNumberingScheme::checkPosition ( uint32_t  index,
const G4ThreeVector &  pos,
bool  matchOnly,
bool  debug 
) const
private

Definition at line 110 of file HGCalNumberingScheme.cc.

References funct::abs(), debug, det_, HGC3DClusterGenMatchSelector_cfi::dR, PVValHelper::dx, PVValHelper::dy, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, hgcons_, LEDCalibrationChannels::iphi, HGCalDDDConstants::locateCell(), HGCalDDDConstants::locateCellTrap(), match(), convertSQLiteXML::ok, diffTwoXMLs::r1, diffTwoXMLs::r2, HGCalDDDConstants::rangeR(), HGCalDDDConstants::rangeZ(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, HGCalDDDConstants::waferFromPosition(), HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), HGCalDDDConstants::waferZ(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, testProducerWithPsetDescEmpty_cfi::z2, and TkClusParameters_cff::zrange.

Referenced by getUnitID().

110  {
111  std::pair<float, float> xy;
112  bool ok(false);
113  double z1(0), tolR(14.0), tolZ(1.0);
114  int lay(-1);
115  if (index == 0) {
116  } else if (DetId(index).det() == DetId::HGCalHSi) {
118  lay = id.layer();
119  xy = hgcons_.locateCell(lay, id.waferU(), id.waferV(), id.cellU(), id.cellV(), false, true);
120  z1 = hgcons_.waferZ(lay, false);
121  ok = true;
122  tolR = 14.0;
123  tolZ = 1.0;
124  } else if (DetId(index).det() == DetId::HGCalHSc) {
126  lay = id.layer();
127  xy = hgcons_.locateCellTrap(lay, id.ietaAbs(), id.iphi(), false);
128  z1 = hgcons_.waferZ(lay, false);
129  ok = true;
130  tolR = 50.0;
131  tolZ = 5.0;
132  }
133  if (ok) {
134  double r1 = std::sqrt(xy.first * xy.first + xy.second * xy.second);
135  double r2 = pos.perp();
136  double z2 = std::abs(pos.z());
137  std::pair<double, double> zrange = hgcons_.rangeZ(false);
138  std::pair<double, double> rrange = hgcons_.rangeR(z2, false);
139  bool match = (std::abs(r1 - r2) < tolR) && (std::abs(z1 - z2) < tolZ);
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 *****"
145  : "");
146  if (matchOnly && match)
147  ck = "";
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 << ":"
154  << xy.second;
155  if ((DetId(index).det() == DetId::HGCalEE) || (DetId(index).det() == DetId::HGCalHSi)) {
156  double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x());
157  int waferU, waferV, cellU, cellV, waferType;
158  hgcons_.waferFromPosition(xx, pos.y(), lay, waferU, waferV, cellU, cellV, waferType, wt, false, true);
159  xy = hgcons_.locateCell(lay, waferU, waferV, cellU, cellV, false, true, 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 *****" : "";
164  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme " << HGCSiliconDetId(index) << " original position " << xx
165  << ":" << pos.y() << " derived " << xy.first << ":" << xy.second << " Difference "
166  << dR << ck;
167  }
168  }
169  }
170 }
double waferZ(int layer, bool reco) const
Log< level::Info, true > LogVerbatim
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
std::pair< double, double > rangeZ(bool reco) const
int32_t waferU(const int32_t index)
const HGCalDDDConstants & hgcons_
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< double, double > rangeR(double z, bool reco) const
Definition: DetId.h:17
#define debug
Definition: HDRShower.cc:19
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
int32_t waferV(const int32_t index)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const

◆ getUnitID()

uint32_t HGCalNumberingScheme::getUnitID ( int  layer,
int  module,
int  cell,
int  iz,
const G4ThreeVector &  pos,
double &  wt 
)

assigns the det id to a hit

Definition at line 34 of file HGCalNumberingScheme.cc.

References HGCalDDDConstants::assignCellTrap(), checkPosition(), debug, TauDecayModes::dec, det_, HGCalDDDConstants::getLayerOffset(), HGCalTypes::getUnpackedCellU(), HGCalTypes::getUnpackedCellV(), HGCalTypes::getUnpackedType(), HGCalTypes::getUnpackedU(), HGCalTypes::getUnpackedV(), HGCalGeometryMode::Hexagon8, HGCalGeometryMode::Hexagon8File, HGCalGeometryMode::Hexagon8Module, HGCSiliconDetId::HGCalCoarseThick, hgcons_, phase1PixelTopology::layer, mode_, callgraph::module, name_, DetId::rawId(), HGCScintillatorDetId::setSiPM(), HGCScintillatorDetId::setType(), HGCalDDDConstants::tileSiPM(), HGCalDDDConstants::tileTrapezoid(), HGCalDDDConstants::tileType(), HGCalDDDConstants::waferFromPosition(), HGCalDDDConstants::waferHexagon8(), HGCalWaferIndex::waferIndex(), HGCalDDDConstants::waferType(), HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), and geometryCSVtoXML::xx.

34  {
35  // module is the copy number of the wafer as placed in the layer
36  uint32_t index(0);
37  wt = 1.0;
38 #ifdef EDM_ML_DEBUG
39  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme:: input Layer " << layer << " Module " << module << " Cell "
40  << cell << " iz " << iz << " Position " << pos;
41 #endif
42  if (hgcons_.waferHexagon8()) {
43  int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0);
44  if (cell >= 0) {
48  cellU = HGCalTypes::getUnpackedCellU(cell);
49  cellV = HGCalTypes::getUnpackedCellV(cell);
50  } else if (mode_ != HGCalGeometryMode::Hexagon8) {
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);
53  }
54  if (waferType >= 0) {
56  int type = hgcons_.waferType(layer, waferU, waferV, true);
57  if (type != waferType) {
58 #ifdef EDM_ML_DEBUG
59  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme:: " << name_ << " Layer|u|v|Index|module|cell " << layer
60  << ":" << waferU << ":" << waferV << ":"
62  << ":" << cell << " has a type mismatch " << waferType << ":" << type;
63 #endif
65  waferType = type;
66  }
67  }
68  index = HGCSiliconDetId(det_, iz, waferType, layer, waferU, waferV, cellU, cellV).rawId();
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell "
71  << cellU << ":" << cellV << " input " << cell << " wt " << wt << " Mode " << mode_;
72  } else {
73  edm::LogVerbatim("HGCSim") << "Bad WaferType " << waferType << " for Layer:u:v " << layer << ":" << waferU << ":"
74  << waferV;
75 #endif
76  }
77  } else if (hgcons_.tileTrapezoid()) {
78  std::array<int, 3> id = hgcons_.assignCellTrap(pos.x(), pos.y(), pos.z(), layer, false);
79  if (id[2] >= 0) {
80  std::pair<int, int> typm = hgcons_.tileType(layer, id[0], 0);
81  HGCScintillatorDetId detId(id[2], layer, iz * id[0], id[1], false, 0);
82  if (typm.first >= 0) {
83  detId.setType(typm.first);
84  detId.setSiPM(typm.second);
85  }
86  index = detId.rawId();
87 #ifdef EDM_ML_DEBUG
88  int lay = layer + hgcons_.getLayerOffset();
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;
92  } else {
93  edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2] << " Layer|iz " << layer
94  << ":" << iz << " ERROR";
95 #endif
96  }
97  }
98 #ifdef EDM_ML_DEBUG
99  bool matchOnly = (mode_ == HGCalGeometryMode::Hexagon8Module);
101  if (debug)
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;
105  checkPosition(index, pos, matchOnly, debug);
106 #endif
107  return index;
108 }
Log< level::Info, true > LogVerbatim
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
static int32_t getUnpackedCellU(int id)
Definition: HGCalTypes.cc:32
static int32_t getUnpackedU(int id)
Definition: HGCalTypes.cc:16
const HGCalGeometryMode::GeometryMode mode_
int32_t waferU(const int32_t index)
const HGCalDDDConstants & hgcons_
int getLayerOffset() const
static int32_t getUnpackedV(int id)
Definition: HGCalTypes.cc:22
bool waferHexagon8() const
constexpr std::array< uint8_t, layerIndexSize > layer
std::pair< int, int > tileType(int layer, int ring, int phi) const
int waferType(DetId const &id, bool fromFile=false) const
static int32_t getUnpackedType(int id)
Definition: HGCalTypes.cc:14
int tileSiPM(int sipm) const
bool tileTrapezoid() const
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
#define debug
Definition: HDRShower.cc:19
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void checkPosition(uint32_t index, const G4ThreeVector &pos, bool matchOnly, bool debug) const
static int32_t getUnpackedCellV(int id)
Definition: HGCalTypes.cc:34
int32_t waferV(const int32_t index)

Member Data Documentation

◆ det_

DetId::Detector HGCalNumberingScheme::det_
private

Definition at line 32 of file HGCalNumberingScheme.h.

Referenced by checkPosition(), getUnitID(), and HGCalNumberingScheme().

◆ hgcons_

const HGCalDDDConstants& HGCalNumberingScheme::hgcons_
private

Definition at line 30 of file HGCalNumberingScheme.h.

Referenced by checkPosition(), and getUnitID().

◆ mode_

const HGCalGeometryMode::GeometryMode HGCalNumberingScheme::mode_
private

Definition at line 31 of file HGCalNumberingScheme.h.

Referenced by getUnitID(), and HGCalNumberingScheme().

◆ name_

std::string HGCalNumberingScheme::name_
private

Definition at line 33 of file HGCalNumberingScheme.h.

Referenced by getUnitID(), and HGCalNumberingScheme().