CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimG4CMS/FP420/interface/FP420NumberingScheme.h

Go to the documentation of this file.
00001 
00002 // File: FP420NumberingScheme.h
00003 // Date: 02.2006
00004 // Description: Numbering scheme for FP420
00005 // Modifications:
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   // Utilities to get detector levels during a step
00027   virtual int  detectorLevel(const G4Step*) const;
00028   virtual void detectorLevel(const G4Step*, int&, int*, G4String*) const;
00029   
00030   //protected:
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   //  private:
00038   //
00040   // int sn0, pn0, rn0;   
00041   
00042   unsigned packMYIndex(int rn0, int pn0, int sn0, 
00043                        int det, int zside, int sector,int zmodule){
00044     int zScale=(rn0-1); // rn0=3 - current --> for update  rn0=7
00045     int sScale = zScale*(pn0-1);//pn0=6
00046     int dScale = sScale*(sn0-1);//sn0=3
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     // 1,2
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     // 1,2,3
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     // Front: Orientation= 1; Back: Orientation= 2
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     // zsideinorder:1 2 3 4 5 6
00103     //sensorsold    1 0 0 2 0 0 
00104     //sensorsnew    1 0 5 2 4 0 ???
00105     //sensorsnew    1 3 0 2 0 6 
00106     //zside         1 3 5 2 4 6  over layers 1 and 2
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     //old:
00115     if(rn0==3){
00116       if(zside>2) zsidereal=0;
00117     }
00118     //new:
00119     if(rn0==7){
00120       //    if(zside==3 || zside==6) zsidereal=0; // ????
00121       if(zside==4 || zside==5) zsidereal=0;
00122     }
00123     //
00124     return zsidereal;
00125   }
00126   
00127   
00128   
00129 };
00130 
00131 
00132 #endif