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 ()
 

Private Member Functions

void checkPosition (uint32_t index, const G4ThreeVector &pos) const
 
 HGCalNumberingScheme ()=delete
 

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::HGCalNumberingScheme ( const HGCalDDDConstants hgc,
const DetId::Detector det,
const std::string &  name 
)

Definition at line 12 of file HGCalNumberingScheme.cc.

References det_, and name_.

15  : hgcons_(hgc), mode_(hgc.geomMode()), det_(det), name_(name) {
16 #ifdef EDM_ML_DEBUG
17  edm::LogVerbatim("HGCSim") << "Creating HGCalNumberingScheme for " << name_ << " Det " << det_;
18 #endif
19 }
const HGCalGeometryMode::GeometryMode mode_
const HGCalDDDConstants & hgcons_
HGCalGeometryMode::GeometryMode geomMode() const
HGCalNumberingScheme::~HGCalNumberingScheme ( )

Definition at line 21 of file HGCalNumberingScheme.cc.

21  {
22 #ifdef EDM_ML_DEBUG
23  edm::LogVerbatim("HGCSim") << "Deleting HGCalNumberingScheme";
24 #endif
25 }
HGCalNumberingScheme::HGCalNumberingScheme ( )
privatedelete

Member Function Documentation

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

Definition at line 84 of file HGCalNumberingScheme.cc.

References funct::abs(), det_, 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(), HGCalDDDConstants::waferZ(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and testProducerWithPsetDescEmpty_cfi::z2.

Referenced by getUnitID().

84  {
85  std::pair<float, float> xy;
86  bool ok(false);
87  double z1(0), tolR(12.0), tolZ(1.0);
88  int lay(-1);
89  if (index == 0) {
90  } else if (DetId(index).det() == DetId::HGCalHSi) {
92  lay = id.layer();
93  xy = hgcons_.locateCell(lay, id.waferU(), id.waferV(), id.cellU(), id.cellV(), false, true);
94  z1 = hgcons_.waferZ(lay, false);
95  ok = true;
96  tolR = 12.0;
97  tolZ = 1.0;
98  } else if (DetId(index).det() == DetId::HGCalHSc) {
100  lay = id.layer();
101  xy = hgcons_.locateCellTrap(lay, id.ietaAbs(), id.iphi(), false);
102  z1 = hgcons_.waferZ(lay, false);
103  ok = true;
104  tolR = 50.0;
105  tolZ = 5.0;
106  }
107  if (ok) {
108  double r1 = std::sqrt(xy.first * xy.first + xy.second * xy.second);
109  double r2 = pos.perp();
110  double z2 = std::abs(pos.z());
111  std::pair<double, double> zrange = hgcons_.rangeZ(false);
112  std::pair<double, double> rrange = hgcons_.rangeR(z2, false);
113  bool match = (std::abs(r1 - r2) < tolR) && (std::abs(z1 - z2) < tolZ);
114  bool inok = ((r2 >= rrange.first) && (r2 <= rrange.second) && (z2 >= zrange.first) && (z2 <= zrange.second));
115  bool outok = ((r1 >= rrange.first) && (r1 <= rrange.second) && (z1 >= zrange.first) && (z1 <= zrange.second));
116  std::string ck = (((r1 < rrange.first - tolR) || (r1 > rrange.second + tolR) || (z1 < zrange.first - tolZ) ||
117  (z1 > zrange.second + tolZ))
118  ? "***** ERROR *****"
119  : "");
120  if (!(match && inok && outok)) {
121  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::Detector " << det_ << " Layer " << lay << " R " << r2 << ":"
122  << r1 << ":" << rrange.first << ":" << rrange.second << " Z " << z2 << ":" << z1 << ":"
123  << zrange.first << ":" << zrange.second << " Match " << match << ":" << inok << ":"
124  << outok << " " << ck;
125  edm::LogVerbatim("HGCSim") << "Original " << pos.x() << ":" << pos.y() << " return " << xy.first << ":"
126  << xy.second;
127  if (DetId(index).det() == DetId::HGCalHSi) {
128  double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x());
129  int waferU, waferV, cellU, cellV, waferType;
130  hgcons_.waferFromPosition(xx, pos.y(), lay, waferU, waferV, cellU, cellV, waferType, wt, true);
131  xy = hgcons_.locateCell(lay, waferU, waferV, cellU, cellV, false, true, true);
132  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme " << HGCSiliconDetId(index) << " position " << xy.first
133  << ":" << xy.second;
134  }
135  }
136  }
137 }
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
const HGCalDDDConstants & hgcons_
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
std::pair< double, double > rangeR(double z, bool reco) const
std::pair< double, double > rangeZ(bool reco) const
T sqrt(T t)
Definition: SSEVec.h:19
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double waferZ(int layer, bool reco) const
Definition: DetId.h:17
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
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 27 of file HGCalNumberingScheme.cc.

References HGCalDDDConstants::assignCellTrap(), checkPosition(), TauDecayModes::dec, det_, HGCalGeometryMode::Hexagon8, HGCalGeometryMode::Hexagon8Full, hgcons_, mode_, DetId::rawId(), HGCalGeometryMode::Trapezoid, HGCalDDDConstants::waferFromPosition(), and geometryCSVtoXML::xx.

27  {
28  // module is the copy number of the wafer as placed in the layer
29  uint32_t index(0);
30  wt = 1.0;
31 #ifdef EDM_ML_DEBUG
32  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme:: input Layer " << layer << " Module " << module << " Cell "
33  << cell << " iz " << iz << " Position " << pos << " Mode " << mode_ << ":"
36 #endif
38  int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0);
39  if (cell >= 0) {
40  waferType = module / 1000000;
41  waferU = module % 100;
42  if ((module / 10000) % 10 > 0)
43  waferU = -waferU;
44  waferV = (module / 100) % 100;
45  if ((module / 100000) % 10 > 0)
46  waferV = -waferV;
47  cellU = cell % 100;
48  cellV = (cell / 100) % 100;
49  } else if (mode_ == HGCalGeometryMode::Hexagon8Full) {
50  double xx = (pos.z() > 0) ? pos.x() : -pos.x();
51  hgcons_.waferFromPosition(xx, pos.y(), layer, waferU, waferV, cellU, cellV, waferType, wt);
52  }
53  if (waferType >= 0) {
54  index = HGCSiliconDetId(det_, iz, waferType, layer, waferU, waferV, cellU, cellV).rawId();
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell "
57  << cellU << ":" << cellV;
58  } else {
59  edm::LogVerbatim("HGCSim") << "Bad WaferType " << waferType;
60 #endif
61  }
62  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
63  std::array<int, 3> id = hgcons_.assignCellTrap(pos.x(), pos.y(), pos.z(), layer, false);
64  if (id[2] >= 0) {
65  index = HGCScintillatorDetId(id[2], layer, iz * id[0], id[1]).rawId();
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2] << " Layer|iz " << layer
68  << ":" << iz << " " << HGCScintillatorDetId(index);
69  } else {
70  edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2] << " Layer|iz " << layer
71  << ":" << iz << " ERROR";
72 #endif
73  }
74  }
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::i/p " << det_ << ":" << layer << ":" << module << ":" << cell
77  << ":" << iz << ":" << pos.x() << ":" << pos.y() << ":" << pos.z() << " ID " << std::hex
78  << index << std::dec << " wt " << wt;
80 #endif
81  return index;
82 }
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
const HGCalGeometryMode::GeometryMode mode_
const HGCalDDDConstants & hgcons_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void checkPosition(uint32_t index, const G4ThreeVector &pos) const
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
Definition: vlib.h:198

Member Data Documentation

DetId::Detector HGCalNumberingScheme::det_
private

Definition at line 32 of file HGCalNumberingScheme.h.

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

const HGCalDDDConstants& HGCalNumberingScheme::hgcons_
private

Definition at line 30 of file HGCalNumberingScheme.h.

Referenced by checkPosition(), and getUnitID().

const HGCalGeometryMode::GeometryMode HGCalNumberingScheme::mode_
private

Definition at line 31 of file HGCalNumberingScheme.h.

Referenced by getUnitID().

std::string HGCalNumberingScheme::name_
private

Definition at line 33 of file HGCalNumberingScheme.h.

Referenced by HGCalNumberingScheme().