CMS 3D CMS Logo

HGCNumberingScheme.cc
Go to the documentation of this file.
1 // File: HGCNumberingScheme.cc
3 // Description: Numbering scheme for High Granularity Calorimeter
10 
12 
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 #include <iostream>
15 
16 //#define EDM_ML_DEBUG
17 
19  std::string & name ) :
20  hgcons_(hgc) {
21  edm::LogInfo("HGCSim") << "Creating HGCNumberingScheme for " << name;
22 }
23 
25  edm::LogInfo("HGCSim") << "Deleting HGCNumberingScheme";
26 }
27 
29  int module, int cell, int iz,
30  const G4ThreeVector &pos) {
31  // module is the copy number of the wafer as placed in the layer
32  int icell(0), celltyp(0), wafer(0);
33  uint32_t index(0);
35  if (cell >= 0) {
36  wafer = hgcons_.waferFromCopy(module);
37  celltyp = cell/1000;
38  icell = cell%1000;
39  } else {
40  hgcons_.waferFromPosition(pos.x(),pos.y(),wafer,icell,celltyp);
41  }
42  if (celltyp != 1) celltyp = 0;
43  index = HGCalTestNumbering::packHexagonIndex((int)subdet,iz,layer,wafer,
44  celltyp,icell);
46  wafer = hgcons_.waferFromCopy(module);
47  celltyp = cell/1000;
48  icell = cell%1000;
49  if (celltyp != 1) celltyp = 0;
50 
51  index = HGCalTestNumbering::packHexagonIndex((int)subdet,iz,layer,wafer,
52  celltyp,icell);
53  //check if it fits
54  if (!hgcons_.isValid(layer,wafer,icell,false)) {
55  index = 0;
56  edm::LogError("HGCSim") << "[HGCNumberingScheme] ID out of bounds :"
57  << " Subdet= " << subdet << " Zside= " << iz
58  << " Layer= " << layer << " Wafer= " << wafer
59  << ":" << module << " CellType= " << celltyp
60  << " Cell= " << icell;
61  }
62  }
63 #ifdef EDM_ML_DEBUG
64  std::cout << "HGCNumberingScheme::i/p " << subdet << ":" << layer << ":"
65  << module << ":" << iz << ":" << wafer << ":" << celltyp << ":"
66  << icell << ":" << std::hex << index << std::dec << std::endl;
67 #endif
68  return index;
69 }
70 
71 int HGCNumberingScheme::assignCell(float x, float y, int layer) {
72 
73  std::pair<int,int> phicell = hgcons_.assignCell(x,y,layer,0,false);
74  return phicell.second;
75 }
76 
77 std::pair<float,float> HGCNumberingScheme::getLocalCoords(int cell, int layer){
78 
79  return hgcons_.locateCell(cell,layer,0,false);
80 }
bool isValid(int lay, int mod, int cell, bool reco) const
int assignCell(float x, float y, int layer)
maps a hit position to a sequential cell in a trapezoid surface defined by h,b,t
std::pair< float, float > getLocalCoords(int cell, int layer)
inverts the cell number in a trapezoid surface to local coordinates
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
static uint32_t packHexagonIndex(int subdet, int z, int lay, int wafer, int celltyp, int cell)
uint32_t getUnitID(ForwardSubdetector subdet, int layer, int module, int cell, int iz, const G4ThreeVector &pos)
assigns the det id to a hit
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
ForwardSubdetector
HGCNumberingScheme()=delete
HGCalGeometryMode::GeometryMode geomMode() const
int waferFromCopy(int copy) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
Definition: vlib.h:208
const HGCalDDDConstants & hgcons_