CMS 3D CMS Logo

FP420NumberingScheme.h
Go to the documentation of this file.
1 // File: FP420NumberingScheme.h
3 // Date: 02.2006
4 // Description: Numbering scheme for FP420
5 // Modifications:
7 #ifndef FP420NumberingScheme_h
8 #define FP420NumberingScheme_h
9 
10 #include <boost/cstdint.hpp>
11 #include <map>
12 
13 class G4Step;
14 class G4String;
15 
17 
18  public:
20  virtual ~FP420NumberingScheme();
21 
22  virtual unsigned int getUnitID(const G4Step* aStep) const;
23 
24  // Utilities to get detector levels during a step
25  virtual int detectorLevel(const G4Step*) const;
26  virtual void detectorLevel(const G4Step*, int&, int*, G4String*) const;
27 
28  //protected:
29 
30  static unsigned int packFP420Index(int det, int zside, int station, int superplane);
31 
32  static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station,int& superplane);
33 
34 
35  // private:
36  //
38  // int sn0, pn0, rn0;
39 
40  static unsigned packMYIndex(int rn0, int pn0, int sn0,
41  int det, int zside, int sector,int zmodule) {
42  int zScale=(rn0-1); // rn0=3 - current --> for update rn0=7
43  int sScale = zScale*(pn0-1);//pn0=6
44  int dScale = sScale*(sn0-1);//sn0=3
45 
46  unsigned int intindex = dScale*(det - 1)+sScale*(sector - 1)+zScale*(zmodule - 1)+zside;
47  //
48  return intindex;
49  }
50 
51  static void unpackMYIndex(const int& idx,
52  int rn0, int pn0, int sn0,
53  int& det, int& zside, int& sector,int& zmodule) {
54  int zScale=(rn0-1), sScale = (rn0-1)*(pn0-1), dScale = (rn0-1)*(pn0-1)*(sn0-1);
55 
56  det = (idx-1)/dScale + 1;
57  sector = (idx-1- dScale*(det - 1))/sScale + 1;
58  zmodule = (idx-1- dScale*(det - 1)- sScale*(sector - 1) )/ zScale + 1;
59  zside = idx - dScale*(det - 1) - sScale*(sector - 1) - zScale*(zmodule - 1);
60  }
61 
62  static int unpackLayerIndex(int rn0, int zside){
63  // 1,2
64  int layerIndex = 1, b;
65  float a = (zside+1)/2.;
66  b = (int)a;
67  if(a-b != 0.) layerIndex = 2;
68  //
69  if(zside>(rn0-1) || zside<1) layerIndex = 0;
70  return layerIndex;
71  }
72 
73  static int unpackCopyIndex(int rn0, int zside){
74  // 1,2,3
75  int copyIndex = 0;
76  if(zside>(rn0-1) || zside<1) {
77  }
78  else {
79  int layerIndex = 1, b;
80  float a = (zside+1)/2.;
81  b = (int)a;
82  if(a-b != 0.) layerIndex = 2;
83  if(layerIndex==2) copyIndex = zside/2;
84  if(layerIndex==1) copyIndex = (zside+1)/2;
85  }
86 
87  return copyIndex;
88  }
89 
90  static int unpackOrientation(int rn0, int zside){
91  // Front: Orientation= 1; Back: Orientation= 2
92  int Orientation = 2;
93  if(zside>(rn0-1) || zside<1) Orientation = 0;
94  if(zside==1 || zside==2) Orientation = 1;
95  //
96  return Orientation;
97  }
98 
99  static int realzside(int rn0, int zsideinorder){
100  // zsideinorder:1 2 3 4 5 6
101  //sensorsold 1 0 0 2 0 0
102  //sensorsnew 1 0 5 2 4 0 ???
103  //sensorsnew 1 3 0 2 0 6
104  //zside 1 3 5 2 4 6 over layers 1 and 2
105  int zside,zsidereal;
106  if(zsideinorder<0) {zside = 0;}
107  else if(zsideinorder<4) {zside = 2*zsideinorder-1;}
108  else if(zsideinorder<7) {zside = 2*zsideinorder-6;}
109  else{zside = 0;}
110  zsidereal=zside;
111  //
112  //old:
113  if(rn0==3){
114  if(zside>2) zsidereal=0;
115  }
116  //new:
117  if(rn0==7){
118  // if(zside==3 || zside==6) zsidereal=0; // ????
119  if(zside==4 || zside==5) zsidereal=0;
120  }
121  //
122  return zsidereal;
123  }
124 
125 
126 
127 };
128 
129 
130 #endif
static int unpackCopyIndex(int rn0, int zside)
virtual int detectorLevel(const G4Step *) const
static int realzside(int rn0, int zsideinorder)
static void unpackFP420Index(const unsigned int &idx, int &det, int &zside, int &station, int &superplane)
static int unpackLayerIndex(int rn0, int zside)
static void unpackMYIndex(const int &idx, int rn0, int pn0, int sn0, int &det, int &zside, int &sector, int &zmodule)
static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule)
virtual unsigned int getUnitID(const G4Step *aStep) const
static unsigned int packFP420Index(int det, int zside, int station, int superplane)
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
static int unpackOrientation(int rn0, int zside)