Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-13 09:27:17

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   virtual ~FP420NumberingScheme();
0019 
0020   virtual unsigned int getUnitID(const G4Step* aStep) const;
0021 
0022   // Utilities to get detector levels during a step
0023   virtual int detectorLevel(const G4Step*) const;
0024   virtual void detectorLevel(const G4Step*, int&, int*, G4String*) const;
0025 
0026   //protected:
0027 
0028   static unsigned int packFP420Index(int det, int zside, int station, int superplane);
0029 
0030   static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& superplane);
0031 
0032   //  private:
0033   //
0034 
0035   static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule) {
0036     int zScale = (rn0 - 1);           // rn0=3 - current --> for update  rn0=7
0037     int sScale = zScale * (pn0 - 1);  //pn0=6
0038     int dScale = sScale * (sn0 - 1);  //sn0=3
0039 
0040     unsigned int intindex = dScale * (det - 1) + sScale * (sector - 1) + zScale * (zmodule - 1) + zside;
0041     //
0042     return intindex;
0043   }
0044 
0045   static void unpackMYIndex(const int& idx, int rn0, int pn0, int sn0, int& det, int& zside, int& sector, int& zmodule) {
0046     int zScale = (rn0 - 1), sScale = (rn0 - 1) * (pn0 - 1), dScale = (rn0 - 1) * (pn0 - 1) * (sn0 - 1);
0047 
0048     det = (idx - 1) / dScale + 1;
0049     sector = (idx - 1 - dScale * (det - 1)) / sScale + 1;
0050     zmodule = (idx - 1 - dScale * (det - 1) - sScale * (sector - 1)) / zScale + 1;
0051     zside = idx - dScale * (det - 1) - sScale * (sector - 1) - zScale * (zmodule - 1);
0052   }
0053 
0054   static int unpackLayerIndex(int rn0, int zside) {
0055     // 1,2
0056     int layerIndex = 1, b;
0057     float a = (zside + 1) / 2.;
0058     b = (int)a;
0059     if (a - b != 0.)
0060       layerIndex = 2;
0061     //
0062     if (zside > (rn0 - 1) || zside < 1)
0063       layerIndex = 0;
0064     return layerIndex;
0065   }
0066 
0067   static int unpackCopyIndex(int rn0, int zside) {
0068     // 1,2,3
0069     int copyIndex = 0;
0070     if (zside > (rn0 - 1) || zside < 1) {
0071     } else {
0072       int layerIndex = 1, b;
0073       float a = (zside + 1) / 2.;
0074       b = (int)a;
0075       if (a - b != 0.)
0076         layerIndex = 2;
0077       if (layerIndex == 2)
0078         copyIndex = zside / 2;
0079       if (layerIndex == 1)
0080         copyIndex = (zside + 1) / 2;
0081     }
0082 
0083     return copyIndex;
0084   }
0085 
0086   static int unpackOrientation(int rn0, int zside) {
0087     // Front: Orientation= 1; Back: Orientation= 2
0088     int Orientation = 2;
0089     if (zside > (rn0 - 1) || zside < 1)
0090       Orientation = 0;
0091     if (zside == 1 || zside == 2)
0092       Orientation = 1;
0093     //
0094     return Orientation;
0095   }
0096 
0097   static int realzside(int rn0, int zsideinorder) {
0098     // zsideinorder:1 2 3 4 5 6
0099     //sensorsold    1 0 0 2 0 0
0100     //sensorsnew    1 0 5 2 4 0 ???
0101     //sensorsnew    1 3 0 2 0 6
0102     //zside         1 3 5 2 4 6  over layers 1 and 2
0103     int zside, zsidereal;
0104     if (zsideinorder < 0) {
0105       zside = 0;
0106     } else if (zsideinorder < 4) {
0107       zside = 2 * zsideinorder - 1;
0108     } else if (zsideinorder < 7) {
0109       zside = 2 * zsideinorder - 6;
0110     } else {
0111       zside = 0;
0112     }
0113     zsidereal = zside;
0114     //
0115     //old:
0116     if (rn0 == 3) {
0117       if (zside > 2)
0118         zsidereal = 0;
0119     }
0120     //new:
0121     if (rn0 == 7) {
0122       //    if(zside==3 || zside==6) zsidereal=0; // ????
0123       if (zside == 4 || zside == 5)
0124         zsidereal = 0;
0125     }
0126     //
0127     return zsidereal;
0128   }
0129 };
0130 
0131 #endif