File indexing completed on 2024-04-06 12:30:02
0001
0002
0003
0004
0005
0006
0007 #ifndef FP420NumberingScheme_h
0008 #define FP420NumberingScheme_h
0009
0010 #include <map>
0011
0012 class G4Step;
0013 class G4String;
0014
0015 class FP420NumberingScheme {
0016 public:
0017 FP420NumberingScheme();
0018 ~FP420NumberingScheme() = default;
0019
0020 unsigned int getUnitID(const G4Step* aStep) const;
0021
0022 static unsigned int packFP420Index(int det, int zside, int station, int superplane);
0023 static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& superplane);
0024
0025 static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule) {
0026 int zScale = (rn0 - 1);
0027 int sScale = zScale * (pn0 - 1);
0028 int dScale = sScale * (sn0 - 1);
0029 unsigned int intindex = dScale * (det - 1) + sScale * (sector - 1) + zScale * (zmodule - 1) + zside;
0030 return intindex;
0031 }
0032
0033 static void unpackMYIndex(const int& idx, int rn0, int pn0, int sn0, int& det, int& zside, int& sector, int& zmodule) {
0034 int zScale = (rn0 - 1), sScale = (rn0 - 1) * (pn0 - 1), dScale = (rn0 - 1) * (pn0 - 1) * (sn0 - 1);
0035 det = (idx - 1) / dScale + 1;
0036 sector = (idx - 1 - dScale * (det - 1)) / sScale + 1;
0037 zmodule = (idx - 1 - dScale * (det - 1) - sScale * (sector - 1)) / zScale + 1;
0038 zside = idx - dScale * (det - 1) - sScale * (sector - 1) - zScale * (zmodule - 1);
0039 }
0040
0041 static int unpackLayerIndex(int rn0, int zside) {
0042
0043 int layerIndex = 1, b;
0044 float a = (zside + 1) / 2.;
0045 b = (int)a;
0046 if (a - b != 0.)
0047 layerIndex = 2;
0048
0049 if (zside > (rn0 - 1) || zside < 1)
0050 layerIndex = 0;
0051 return layerIndex;
0052 }
0053
0054 static int unpackCopyIndex(int rn0, int zside) {
0055
0056 int copyIndex = 0;
0057 if (zside <= (rn0 - 1) && zside >= 1) {
0058 int layerIndex = 1;
0059 float a = (zside + 1) / 2.;
0060 int b = (int)a;
0061 if (a - b != 0.)
0062 layerIndex = 2;
0063 if (layerIndex == 2)
0064 copyIndex = zside / 2;
0065 if (layerIndex == 1)
0066 copyIndex = (zside + 1) / 2;
0067 }
0068 return copyIndex;
0069 }
0070
0071 static int unpackOrientation(int rn0, int zside) {
0072
0073 int Orientation = 2;
0074 if (zside > (rn0 - 1) || zside < 1)
0075 Orientation = 0;
0076 if (zside == 1 || zside == 2)
0077 Orientation = 1;
0078
0079 return Orientation;
0080 }
0081
0082 static int realzside(int rn0, int zsideinorder) {
0083
0084
0085
0086
0087
0088 int zside, zsidereal;
0089 if (zsideinorder < 0) {
0090 zside = 0;
0091 } else if (zsideinorder < 4) {
0092 zside = 2 * zsideinorder - 1;
0093 } else if (zsideinorder < 7) {
0094 zside = 2 * zsideinorder - 6;
0095 } else {
0096 zside = 0;
0097 }
0098 zsidereal = zside;
0099
0100
0101 if (rn0 == 3) {
0102 if (zside > 2)
0103 zsidereal = 0;
0104 }
0105
0106 if (rn0 == 7) {
0107 if (zside == 4 || zside == 5)
0108 zsidereal = 0;
0109 }
0110 return zsidereal;
0111 }
0112 };
0113
0114 #endif