test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 DebugLog
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 
28 //
30  int module, int cell, int iz,
31  const G4ThreeVector &pos) {
32  // module is the sector # for square cell
33  // the copy number of the wafer as placed in the layer
34  int phiSector(0), icell(0), celltyp(0), wafer(0);
35  uint32_t index(0);
37  std::pair<int,int> phicell = hgcons_.assignCell(pos.x(),pos.y(),layer,0,false);
38  phiSector = phicell.first;
39  icell = phicell.second;
40 
41  //build the index
42  index = HGCalTestNumbering::packSquareIndex(iz,layer,module,phiSector,icell);
43  //check if it fits
44  if (!hgcons_.isValid(layer,module,icell,false)) {
45  index = 0;
46  }
47  } else {
48  wafer = hgcons_.waferFromCopy(module);
49  celltyp = cell/1000;
50  icell = cell%1000;
51  if (celltyp != 1) celltyp = 0;
52 
53  index = HGCalTestNumbering::packHexagonIndex((int)subdet,iz,layer,wafer,
54  celltyp,icell);
55  //check if it fits
56  if (!hgcons_.isValid(layer,wafer,icell,false)) {
57  index = 0;
58  edm::LogError("HGCSim") << "[HGCNumberingScheme] ID out of bounds :"
59  << " Subdet= " << subdet << " Zside= " << iz
60  << " Layer= " << layer << " Wafer= " << wafer
61  << " CellType= " << celltyp << " Cell= "
62  << icell;
63  }
64  }
65 #ifdef DebugLog
66  if (verbosity > 0) {
67  std::cout << "HGCNumberingScheme::i/p " << subdet << ":" << layer << ":"
68  << module << ":" << iz << ":";
70  std::cout << pos << " o/p " << phiSector << ":" << icell;
71  else
72  std::cout << wafer << ":" << celltyp << ":" << icell;
73  std::cout << ":" << std::hex << index << std::dec << std::endl;
74  }
75 #endif
76  return index;
77 }
78 
79 //
80 int HGCNumberingScheme::assignCell(float x, float y, int layer) {
81 
82  std::pair<int,int> phicell = hgcons_.assignCell(x,y,layer,0,false);
83  return phicell.second;
84 }
85 
86 //
87 std::pair<float,float> HGCNumberingScheme::getLocalCoords(int cell, int layer){
88 
89  return hgcons_.locateCell(cell,layer,0,false);
90 }
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
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
T x() const
Cartesian x coordinate.
HGCalGeometryMode geomMode() const
int waferFromCopy(int copy) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
tuple cout
Definition: gather_cfg.py:145
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
Definition: vlib.h:208
const HGCalDDDConstants & hgcons_