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 <boost/cstdint.hpp>
11 #include <map>
12 
13 class G4Step;
14 class G4String;
15 
17 public:
19  virtual ~FP420NumberingScheme();
20 
21  virtual unsigned int getUnitID(const G4Step* aStep) const;
22 
23  // Utilities to get detector levels during a step
24  virtual int detectorLevel(const G4Step*) const;
25  virtual void detectorLevel(const G4Step*, int&, int*, G4String*) const;
26 
27  //protected:
28 
29  static unsigned int packFP420Index(int det, int zside, int station, int superplane);
30 
31  static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& superplane);
32 
33  // private:
34  //
36  // int sn0, pn0, rn0;
37 
38  static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule) {
39  int zScale = (rn0 - 1); // rn0=3 - current --> for update rn0=7
40  int sScale = zScale * (pn0 - 1); //pn0=6
41  int dScale = sScale * (sn0 - 1); //sn0=3
42 
43  unsigned int intindex = dScale * (det - 1) + sScale * (sector - 1) + zScale * (zmodule - 1) + zside;
44  //
45  return intindex;
46  }
47 
48  static void unpackMYIndex(const int& idx, int rn0, int pn0, int sn0, int& det, int& zside, int& sector, int& zmodule) {
49  int zScale = (rn0 - 1), sScale = (rn0 - 1) * (pn0 - 1), dScale = (rn0 - 1) * (pn0 - 1) * (sn0 - 1);
50 
51  det = (idx - 1) / dScale + 1;
52  sector = (idx - 1 - dScale * (det - 1)) / sScale + 1;
53  zmodule = (idx - 1 - dScale * (det - 1) - sScale * (sector - 1)) / zScale + 1;
54  zside = idx - dScale * (det - 1) - sScale * (sector - 1) - zScale * (zmodule - 1);
55  }
56 
57  static int unpackLayerIndex(int rn0, int zside) {
58  // 1,2
59  int layerIndex = 1, b;
60  float a = (zside + 1) / 2.;
61  b = (int)a;
62  if (a - b != 0.)
63  layerIndex = 2;
64  //
65  if (zside > (rn0 - 1) || zside < 1)
66  layerIndex = 0;
67  return layerIndex;
68  }
69 
70  static int unpackCopyIndex(int rn0, int zside) {
71  // 1,2,3
72  int copyIndex = 0;
73  if (zside > (rn0 - 1) || zside < 1) {
74  } else {
75  int layerIndex = 1, b;
76  float a = (zside + 1) / 2.;
77  b = (int)a;
78  if (a - b != 0.)
79  layerIndex = 2;
80  if (layerIndex == 2)
81  copyIndex = zside / 2;
82  if (layerIndex == 1)
83  copyIndex = (zside + 1) / 2;
84  }
85 
86  return copyIndex;
87  }
88 
89  static int unpackOrientation(int rn0, int zside) {
90  // Front: Orientation= 1; Back: Orientation= 2
91  int Orientation = 2;
92  if (zside > (rn0 - 1) || zside < 1)
93  Orientation = 0;
94  if (zside == 1 || zside == 2)
95  Orientation = 1;
96  //
97  return Orientation;
98  }
99 
100  static int realzside(int rn0, int zsideinorder) {
101  // zsideinorder:1 2 3 4 5 6
102  //sensorsold 1 0 0 2 0 0
103  //sensorsnew 1 0 5 2 4 0 ???
104  //sensorsnew 1 3 0 2 0 6
105  //zside 1 3 5 2 4 6 over layers 1 and 2
106  int zside, zsidereal;
107  if (zsideinorder < 0) {
108  zside = 0;
109  } else if (zsideinorder < 4) {
110  zside = 2 * zsideinorder - 1;
111  } else if (zsideinorder < 7) {
112  zside = 2 * zsideinorder - 6;
113  } else {
114  zside = 0;
115  }
116  zsidereal = zside;
117  //
118  //old:
119  if (rn0 == 3) {
120  if (zside > 2)
121  zsidereal = 0;
122  }
123  //new:
124  if (rn0 == 7) {
125  // if(zside==3 || zside==6) zsidereal=0; // ????
126  if (zside == 4 || zside == 5)
127  zsidereal = 0;
128  }
129  //
130  return zsidereal;
131  }
132 };
133 
134 #endif
static int unpackCopyIndex(int rn0, int zside)
virtual int detectorLevel(const G4Step *) const
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)
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)
virtual unsigned int getUnitID(const G4Step *aStep) const
static unsigned int packFP420Index(int det, int zside, int station, int superplane)
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
static int unpackOrientation(int rn0, int zside)