CMS 3D CMS Logo

HFNoseNumberingScheme.cc
Go to the documentation of this file.
1 // File: HFNoseNumberingScheme.cc
3 // Description: Numbering scheme for HFNose detector
8 #include <iostream>
9 
10 //#define EDM_ML_DEBUG
11 
13 #ifdef EDM_ML_DEBUG
14  edm::LogVerbatim("HGCSim") << "Creating HFNoseNumberingScheme";
15 #endif
16 }
17 
19  int layer, int module, int cell, int iz, const G4ThreeVector& pos, double& wt) {
20  // module is the copy number of the wafer as placed in the layer
21  uint32_t index(0);
22  wt = 1.0;
23  int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0);
24  if (cell >= 0) {
28  cellU = HGCalTypes::getUnpackedCellU(cell);
29  cellV = HGCalTypes::getUnpackedCellV(cell);
30  } else if (mode_ == HGCalGeometryMode::Hexagon8Full) {
31  double xx = (pos.z() > 0) ? pos.x() : -pos.x();
32  hgcons_.waferFromPosition(xx, pos.y(), layer, waferU, waferV, cellU, cellV, waferType, wt);
33  }
34  if (waferType >= 0) {
35  index = HFNoseDetId(iz, waferType, layer, waferU, waferV, cellU, cellV).rawId();
36 #ifdef EDM_ML_DEBUG
37  edm::LogVerbatim("HFNSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell "
38  << cellU << ":" << cellV;
39  } else {
40  edm::LogVerbatim("HFNSim") << "Bad WaferType " << waferType;
41 #endif
42  }
43 #ifdef EDM_ML_DEBUG
44  edm::LogVerbatim("HFNSim") << "HFNoseNumberingScheme::i/p " << layer << ":" << module << ":" << cell << ":" << iz
45  << ":" << pos.x() << ":" << pos.y() << ":" << pos.z() << " ID " << std::hex << index
46  << std::dec << " wt " << wt;
48 #endif
49  return index;
50 }
51 
52 void HFNoseNumberingScheme::checkPosition(uint32_t index, const G4ThreeVector& pos) const {
53  std::pair<float, float> xy;
54  bool ok(false);
55  double z1(0), tolR(10.0), tolZ(1.0);
56  int lay(-1);
57  if (index == 0) {
58  } else if ((DetId(index).det() == DetId::Forward) && (DetId(index).subdetId() == static_cast<int>(HFNose))) {
60  lay = id.layer();
61  xy = hgcons_.locateCell(lay, id.waferU(), id.waferV(), id.cellU(), id.cellV(), false, true);
62  z1 = hgcons_.waferZ(lay, false);
63  ok = true;
64  }
65  if (ok) {
66  double r1 = std::sqrt(xy.first * xy.first + xy.second * xy.second);
67  double r2 = pos.perp();
68  double z2 = std::abs(pos.z());
69  std::pair<double, double> zrange = hgcons_.rangeZ(false);
70  std::pair<double, double> rrange = hgcons_.rangeR(z2, false);
71  bool match = (std::abs(r1 - r2) < tolR) && (std::abs(z1 - z2) < tolZ);
72  bool inok = ((r2 >= rrange.first) && (r2 <= rrange.second) && (z2 >= zrange.first) && (z2 <= zrange.second));
73  bool outok = ((r1 >= rrange.first) && (r1 <= rrange.second) && (z1 >= zrange.first) && (z1 <= zrange.second));
74  std::string ck = (((r1 < rrange.first - tolR) || (r1 > rrange.second + tolR) || (z1 < zrange.first - tolZ) ||
75  (z1 > zrange.second + tolZ))
76  ? "***** ERROR *****"
77  : "");
78  if (!(match && inok && outok)) {
79  edm::LogVerbatim("HGCSim") << "HFNoseNumberingScheme::Detector " << DetId(index).det() << " Layer " << lay
80  << " R " << r2 << ":" << r1 << ":" << rrange.first << ":" << rrange.second << " Z "
81  << z2 << ":" << z1 << ":" << zrange.first << ":" << zrange.second << " Match " << match
82  << ":" << inok << ":" << outok << " " << ck;
83  edm::LogVerbatim("HGCSim") << "Original " << pos.x() << ":" << pos.y() << " return " << xy.first << ":"
84  << xy.second;
85  if ((DetId(index).det() == DetId::Forward) && (DetId(index).subdetId() == static_cast<int>(HFNose))) {
86  double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x());
87  int waferU, waferV, cellU, cellV, waferType;
88  hgcons_.waferFromPosition(xx, pos.y(), lay, waferU, waferV, cellU, cellV, waferType, wt, true);
89  xy = hgcons_.locateCell(lay, waferU, waferV, cellU, cellV, false, true, true);
90  edm::LogVerbatim("HGCSim") << "HFNoseNumberingScheme " << HFNoseDetId(index) << " position " << xy.first << ":"
91  << xy.second;
92  }
93  }
94  }
95 }
MessageLogger.h
HFNoseNumberingScheme::checkPosition
void checkPosition(uint32_t index, const G4ThreeVector &pos) const
Definition: HFNoseNumberingScheme.cc:52
HFNoseNumberingScheme.h
TkClusParameters_cff.zrange
zrange
Definition: TkClusParameters_cff.py:7
HGCalDDDConstants::waferFromPosition
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
Definition: HGCalDDDConstants.cc:1089
HGCalDDDConstants::rangeZ
std::pair< double, double > rangeZ(bool reco) const
Definition: HGCalDDDConstants.cc:1011
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
pos
Definition: PixelAliasList.h:18
HGCalDDDConstants::waferZ
double waferZ(int layer, bool reco) const
Definition: HGCalDDDConstants.cc:1412
HGCalWaferIndex::waferU
int32_t waferU(const int32_t index)
Definition: HGCalWaferIndex.cc:27
HFNoseNumberingScheme::mode_
const HGCalGeometryMode::GeometryMode mode_
Definition: HFNoseNumberingScheme.h:29
HFNoseDetId
Definition: HFNoseDetId.h:22
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
HGCalDDDConstants
Definition: HGCalDDDConstants.h:27
hgc_digi
Definition: HGCDigitizerTypes.h:10
HFNoseNumberingScheme::HFNoseNumberingScheme
HFNoseNumberingScheme()=delete
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
HGCalTypes::getUnpackedCellV
static int32_t getUnpackedCellV(int id)
Definition: HGCalTypes.cc:34
DetId
Definition: DetId.h:17
HFNose
Definition: ForwardSubdetector.h:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalWaferIndex::waferV
int32_t waferV(const int32_t index)
Definition: HGCalWaferIndex.cc:32
HGCalDDDConstants::rangeR
std::pair< double, double > rangeR(double z, bool reco) const
Definition: HGCalDDDConstants.cc:966
HFNoseNumberingScheme::hgcons_
const HGCalDDDConstants & hgcons_
Definition: HFNoseNumberingScheme.h:28
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
HGCalTypes::getUnpackedU
static int32_t getUnpackedU(int id)
Definition: HGCalTypes.cc:16
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
HGCalGeometryMode::Hexagon8Full
Definition: HGCalGeometryMode.h:30
HFNoseNumberingScheme::getUnitID
uint32_t getUnitID(int layer, int module, int cell, int iz, const G4ThreeVector &pos, double &wt)
assigns the det id to a hit
Definition: HFNoseNumberingScheme.cc:18
HGCalTypes::getUnpackedV
static int32_t getUnpackedV(int id)
Definition: HGCalTypes.cc:22
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
callgraph.module
module
Definition: callgraph.py:61
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HGCalTypes::getUnpackedCellU
static int32_t getUnpackedCellU(int id)
Definition: HGCalTypes.cc:32
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalDDDConstants::locateCell
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
Definition: HGCalDDDConstants.cc:596
DetId::Forward
Definition: DetId.h:30
HGCalTypes.h
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
HGCalTypes::getUnpackedType
static int32_t getUnpackedType(int id)
Definition: HGCalTypes.cc:14