CMS 3D CMS Logo

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