CMS 3D CMS Logo

FP420NumberingScheme.h
Go to the documentation of this file.
1 // File: FP420NumberingScheme.h
3 // Date: 02.2006
4 // Description: Numbering scheme for FP420
5 // Modifications:
7 #ifndef FP420NumberingScheme_h
8 #define FP420NumberingScheme_h
9 
10 #include <map>
11 
12 class G4Step;
13 class G4String;
14 
16 public:
18  ~FP420NumberingScheme() = default;
19 
20  unsigned int getUnitID(const G4Step* aStep) const;
21 
22  static unsigned int packFP420Index(int det, int zside, int station, int superplane);
23  static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& superplane);
24 
25  static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule) {
26  int zScale = (rn0 - 1); // rn0=3 - current --> for update rn0=7
27  int sScale = zScale * (pn0 - 1); //pn0=6
28  int dScale = sScale * (sn0 - 1); //sn0=3
29  unsigned int intindex = dScale * (det - 1) + sScale * (sector - 1) + zScale * (zmodule - 1) + zside;
30  return intindex;
31  }
32 
33  static void unpackMYIndex(const int& idx, int rn0, int pn0, int sn0, int& det, int& zside, int& sector, int& zmodule) {
34  int zScale = (rn0 - 1), sScale = (rn0 - 1) * (pn0 - 1), dScale = (rn0 - 1) * (pn0 - 1) * (sn0 - 1);
35  det = (idx - 1) / dScale + 1;
36  sector = (idx - 1 - dScale * (det - 1)) / sScale + 1;
37  zmodule = (idx - 1 - dScale * (det - 1) - sScale * (sector - 1)) / zScale + 1;
38  zside = idx - dScale * (det - 1) - sScale * (sector - 1) - zScale * (zmodule - 1);
39  }
40 
41  static int unpackLayerIndex(int rn0, int zside) {
42  // 1,2
43  int layerIndex = 1, b;
44  float a = (zside + 1) / 2.;
45  b = (int)a;
46  if (a - b != 0.)
47  layerIndex = 2;
48  //
49  if (zside > (rn0 - 1) || zside < 1)
50  layerIndex = 0;
51  return layerIndex;
52  }
53 
54  static int unpackCopyIndex(int rn0, int zside) {
55  // 1,2,3
56  int copyIndex = 0;
57  if (zside <= (rn0 - 1) && zside >= 1) {
58  int layerIndex = 1;
59  float a = (zside + 1) / 2.;
60  int b = (int)a;
61  if (a - b != 0.)
62  layerIndex = 2;
63  if (layerIndex == 2)
64  copyIndex = zside / 2;
65  if (layerIndex == 1)
66  copyIndex = (zside + 1) / 2;
67  }
68  return copyIndex;
69  }
70 
71  static int unpackOrientation(int rn0, int zside) {
72  // Front: Orientation= 1; Back: Orientation= 2
73  int Orientation = 2;
74  if (zside > (rn0 - 1) || zside < 1)
75  Orientation = 0;
76  if (zside == 1 || zside == 2)
77  Orientation = 1;
78  //
79  return Orientation;
80  }
81 
82  static int realzside(int rn0, int zsideinorder) {
83  // zsideinorder:1 2 3 4 5 6
84  //sensorsold 1 0 0 2 0 0
85  //sensorsnew 1 0 5 2 4 0 ???
86  //sensorsnew 1 3 0 2 0 6
87  //zside 1 3 5 2 4 6 over layers 1 and 2
88  int zside, zsidereal;
89  if (zsideinorder < 0) {
90  zside = 0;
91  } else if (zsideinorder < 4) {
92  zside = 2 * zsideinorder - 1;
93  } else if (zsideinorder < 7) {
94  zside = 2 * zsideinorder - 6;
95  } else {
96  zside = 0;
97  }
98  zsidereal = zside;
99  //
100  //old:
101  if (rn0 == 3) {
102  if (zside > 2)
103  zsidereal = 0;
104  }
105  //new:
106  if (rn0 == 7) {
107  if (zside == 4 || zside == 5)
108  zsidereal = 0;
109  }
110  return zsidereal;
111  }
112 };
113 
114 #endif
static int unpackCopyIndex(int rn0, int zside)
static int realzside(int rn0, int zsideinorder)
static void unpackFP420Index(const unsigned int &idx, int &det, int &zside, int &station, int &superplane)
int zside(DetId const &)
static int unpackLayerIndex(int rn0, int zside)
~FP420NumberingScheme()=default
static void unpackMYIndex(const int &idx, int rn0, int pn0, int sn0, int &det, int &zside, int &sector, int &zmodule)
static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule)
static unsigned int packFP420Index(int det, int zside, int station, int superplane)
double b
Definition: hdecay.h:120
unsigned int getUnitID(const G4Step *aStep) const
double a
Definition: hdecay.h:121
static int unpackOrientation(int rn0, int zside)