Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #ifndef FP420NumberingScheme_h
00008 #define FP420NumberingScheme_h
00009
00010 #include "G4Step.hh"
00011 #include <boost/cstdint.hpp>
00012 #include "G4ThreeVector.hh"
00013 #include <map>
00014
00015
00016
00017
00018 class FP420NumberingScheme {
00019
00020 public:
00021 FP420NumberingScheme();
00022 virtual ~FP420NumberingScheme();
00023
00024 virtual unsigned int getUnitID(const G4Step* aStep) const;
00025
00026
00027 virtual int detectorLevel(const G4Step*) const;
00028 virtual void detectorLevel(const G4Step*, int&, int*, G4String*) const;
00029
00030
00031
00032 static unsigned int packFP420Index(int det, int zside, int station, int superplane);
00033
00034 static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station,int& superplane);
00035
00036
00037
00038
00040
00041
00042 unsigned packMYIndex(int rn0, int pn0, int sn0,
00043 int det, int zside, int sector,int zmodule){
00044 int zScale=(rn0-1);
00045 int sScale = zScale*(pn0-1);
00046 int dScale = sScale*(sn0-1);
00047
00048 unsigned int intindex = dScale*(det - 1)+sScale*(sector - 1)+zScale*(zmodule - 1)+zside;
00049
00050 return intindex;
00051 }
00052
00053 void unpackMYIndex(const int& idx,
00054 int rn0, int pn0, int sn0,
00055 int& det, int& zside, int& sector,int& zmodule) {
00056 int zScale=(rn0-1), sScale = (rn0-1)*(pn0-1), dScale = (rn0-1)*(pn0-1)*(sn0-1);
00057
00058 det = (idx-1)/dScale + 1;
00059 sector = (idx-1- dScale*(det - 1))/sScale + 1;
00060 zmodule = (idx-1- dScale*(det - 1)- sScale*(sector - 1) )/ zScale + 1;
00061 zside = idx - dScale*(det - 1) - sScale*(sector - 1) - zScale*(zmodule - 1);
00062 }
00063
00064 int unpackLayerIndex(int rn0, int zside){
00065
00066 int layerIndex = 1, b;
00067 float a = (zside+1)/2.;
00068 b = (int)a;
00069 if(a-b != 0.) layerIndex = 2;
00070
00071 if(zside>(rn0-1) || zside<1) layerIndex = 0;
00072 return layerIndex;
00073 }
00074
00075 int unpackCopyIndex(int rn0, int zside){
00076
00077 int copyIndex = 0;
00078 if(zside>(rn0-1) || zside<1) {
00079 }
00080 else {
00081 int layerIndex = 1, b;
00082 float a = (zside+1)/2.;
00083 b = (int)a;
00084 if(a-b != 0.) layerIndex = 2;
00085 if(layerIndex==2) copyIndex = zside/2;
00086 if(layerIndex==1) copyIndex = (zside+1)/2;
00087 }
00088
00089 return copyIndex;
00090 }
00091
00092 int unpackOrientation(int rn0, int zside){
00093
00094 int Orientation = 2;
00095 if(zside>(rn0-1) || zside<1) Orientation = 0;
00096 if(zside==1 || zside==2) Orientation = 1;
00097
00098 return Orientation;
00099 }
00100
00101 int realzside(int rn0, int zsideinorder){
00102
00103
00104
00105
00106
00107 int zside,zsidereal;
00108 if(zsideinorder<0) {zside = 0;}
00109 else if(zsideinorder<4) {zside = 2*zsideinorder-1;}
00110 else if(zsideinorder<7) {zside = 2*zsideinorder-6;}
00111 else{zside = 0;}
00112 zsidereal=zside;
00113
00114
00115 if(rn0==3){
00116 if(zside>2) zsidereal=0;
00117 }
00118
00119 if(rn0==7){
00120
00121 if(zside==4 || zside==5) zsidereal=0;
00122 }
00123
00124 return zsidereal;
00125 }
00126
00127
00128
00129 };
00130
00131
00132 #endif