Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:02

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: FP420NumberingScheme.h
0003 // Date: 02.2006
0004 // Description: Numbering scheme for FP420
0005 // Modifications:
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);           // rn0=3 - current --> for update  rn0=7
0027     int sScale = zScale * (pn0 - 1);  //pn0=6
0028     int dScale = sScale * (sn0 - 1);  //sn0=3
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     // 1,2
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     // 1,2,3
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     // Front: Orientation= 1; Back: Orientation= 2
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     // zsideinorder:1 2 3 4 5 6
0084     //sensorsold    1 0 0 2 0 0
0085     //sensorsnew    1 0 5 2 4 0 ???
0086     //sensorsnew    1 3 0 2 0 6
0087     //zside         1 3 5 2 4 6  over layers 1 and 2
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     //old:
0101     if (rn0 == 3) {
0102       if (zside > 2)
0103         zsidereal = 0;
0104     }
0105     //new:
0106     if (rn0 == 7) {
0107       if (zside == 4 || zside == 5)
0108         zsidereal = 0;
0109     }
0110     return zsidereal;
0111   }
0112 };
0113 
0114 #endif