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 11 of file HGCalNumberingScheme.cc.

References det_, and name_.

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

Definition at line 20 of file HGCalNumberingScheme.cc.

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

Member Function Documentation

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

Definition at line 90 of file HGCalNumberingScheme.cc.

References funct::abs(), det_, pfClusterIsolation_cfi::drMax, dzMax, DetId::HGCalHSc, DetId::HGCalHSi, hgcons_, 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, and geometryCSVtoXML::xy.

Referenced by getUnitID().

90  {
91  std::pair<float, float> xy;
92  bool ok(false);
93  double z1(0), drMax(10.0), dzMax(1.0);
94  int lay(-1);
95  if (index == 0) {
96  } else if (DetId(index).det() == DetId::HGCalHSi) {
98  lay = id.layer();
99  xy = hgcons_.locateCell(lay, id.waferU(), id.waferV(), id.cellU(), id.cellV(), false, true);
100  z1 = hgcons_.waferZ(lay, false);
101  ok = true;
102  drMax = 10.0;
103  dzMax = 1.0;
104  } else if (DetId(index).det() == DetId::HGCalHSc) {
106  lay = id.layer();
107  xy = hgcons_.locateCellTrap(lay, id.ietaAbs(), id.iphi(), false);
108  z1 = hgcons_.waferZ(lay, false);
109  ok = true;
110  drMax = 50.0;
111  dzMax = 5.0;
112  }
113  if (ok) {
114  double r1 = std::sqrt(xy.first * xy.first + xy.second * xy.second);
115  double r2 = pos.perp();
116  double z2 = std::abs(pos.z());
117  std::pair<double, double> zrange = hgcons_.rangeZ(false);
118  std::pair<double, double> rrange = hgcons_.rangeR(z2, false);
119  bool match = (std::abs(r1 - r2) < drMax) && (std::abs(z1 - z2) < dzMax);
120  bool inok = ((r2 >= rrange.first) && (r2 <= rrange.second) && (z2 >= zrange.first) && (z2 <= zrange.second));
121  bool outok = ((r1 >= rrange.first) && (r1 <= rrange.second) && (z1 >= zrange.first) && (z1 <= zrange.second));
122  std::string ck = (((r1 < rrange.first - 10.0) || (r1 > rrange.second +10.0) ||
123  (z1 < zrange.first - 5.0) || (z1 > zrange.second + 5.0)) ?
124  "***** ERROR *****" : "");
125  if (!(match && inok && outok)) {
126  edm::LogVerbatim("HGCSim")
127  << "HGCalNumberingScheme::Detector " << det_ << " Layer " << lay << " R "
128  << r2 << ":" << r1 << ":" << rrange.first << ":" << rrange.second << " Z "
129  << z2 << ":" << z1 << ":" << zrange.first << ":" << zrange.second
130  << " Match " << match << ":" << inok << ":" << outok << " " << ck;
131  edm::LogVerbatim("HGCSim")
132  << "Original " << pos.x() << ":" << pos.y() << " return " << xy.first
133  << ":" << xy.second;
134  if (DetId(index).det() == DetId::HGCalHSi) {
135  double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x());
136  int waferU, waferV, cellU, cellV, waferType;
137  hgcons_.waferFromPosition(xx, pos.y(), lay, waferU, waferV, cellU, cellV, waferType, wt, true);
138  xy = hgcons_.locateCell(lay, waferU, waferV, cellU, cellV, false, true, true);
139  edm::LogVerbatim("HGCSim")
140  << "HGCalNumberingScheme " << HGCSiliconDetId(index) << " position "
141  << xy.first << ":" << xy.second;
142  }
143  }
144  }
145 }
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:18
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:18
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 26 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.

26  {
27  // module is the copy number of the wafer as placed in the layer
28  uint32_t index(0);
29  wt = 1.0;
30 #ifdef EDM_ML_DEBUG
31  edm::LogVerbatim("HGCSim")
32  << "HGCalNumberingScheme:: input Layer " << layer << " Module " << module
33  << " Cell " << cell << " iz " << iz << " Position " << pos << " Mode "
34  << mode_ << ":" << HGCalGeometryMode::Hexagon8Full << ":"
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")
57  << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV
58  << " Cell " << cellU << ":" << cellV;
59  } else {
60  edm::LogVerbatim("HGCSim") << "Bad WaferType " << waferType;
61 #endif
62  }
63  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
64  std::array<int, 3> id = hgcons_.assignCellTrap(pos.x(), pos.y(), pos.z(), layer, false);
65  if (id[2] >= 0) {
66  index = HGCScintillatorDetId(id[2], layer, iz * id[0], id[1]).rawId();
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HGCSim")
69  << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2]
70  << " Layer|iz " << layer << ":" << iz << " "
72  } else {
73  edm::LogVerbatim("HGCSim")
74  << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2]
75  << " Layer|iz " << layer << ":" << iz << " ERROR";
76 #endif
77  }
78  }
79 #ifdef EDM_ML_DEBUG
80  edm::LogVerbatim("HGCSim")
81  << "HGCalNumberingScheme::i/p " << det_ << ":" << layer << ":" << module
82  << ":" << cell << ":" << iz << ":" << pos.x() << ":" << pos.y() << ":"
83  << pos.z() << " ID " << std::hex << index << std::dec << " wt " << wt;
85  }
86 #endif
87  return index;
88 }
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:50
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:208

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