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 <map>
11 
12 class G4Step;
13 class G4String;
14 
16 public:
18  virtual ~FP420NumberingScheme();
19 
20  virtual unsigned int getUnitID(const G4Step* aStep) const;
21 
22  // Utilities to get detector levels during a step
23  virtual int detectorLevel(const G4Step*) const;
24  virtual void detectorLevel(const G4Step*, int&, int*, G4String*) const;
25 
26  //protected:
27 
28  static unsigned int packFP420Index(int det, int zside, int station, int superplane);
29 
30  static void unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& superplane);
31 
32  // private:
33  //
35  // int sn0, pn0, rn0;
36 
37  static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule) {
38  int zScale = (rn0 - 1); // rn0=3 - current --> for update rn0=7
39  int sScale = zScale * (pn0 - 1); //pn0=6
40  int dScale = sScale * (sn0 - 1); //sn0=3
41 
42  unsigned int intindex = dScale * (det - 1) + sScale * (sector - 1) + zScale * (zmodule - 1) + zside;
43  //
44  return intindex;
45  }
46 
47  static void unpackMYIndex(const int& idx, int rn0, int pn0, int sn0, int& det, int& zside, int& sector, int& zmodule) {
48  int zScale = (rn0 - 1), sScale = (rn0 - 1) * (pn0 - 1), dScale = (rn0 - 1) * (pn0 - 1) * (sn0 - 1);
49 
50  det = (idx - 1) / dScale + 1;
51  sector = (idx - 1 - dScale * (det - 1)) / sScale + 1;
52  zmodule = (idx - 1 - dScale * (det - 1) - sScale * (sector - 1)) / zScale + 1;
53  zside = idx - dScale * (det - 1) - sScale * (sector - 1) - zScale * (zmodule - 1);
54  }
55 
56  static int unpackLayerIndex(int rn0, int zside) {
57  // 1,2
58  int layerIndex = 1, b;
59  float a = (zside + 1) / 2.;
60  b = (int)a;
61  if (a - b != 0.)
62  layerIndex = 2;
63  //
64  if (zside > (rn0 - 1) || zside < 1)
65  layerIndex = 0;
66  return layerIndex;
67  }
68 
69  static int unpackCopyIndex(int rn0, int zside) {
70  // 1,2,3
71  int copyIndex = 0;
72  if (zside > (rn0 - 1) || zside < 1) {
73  } else {
74  int layerIndex = 1, b;
75  float a = (zside + 1) / 2.;
76  b = (int)a;
77  if (a - b != 0.)
78  layerIndex = 2;
79  if (layerIndex == 2)
80  copyIndex = zside / 2;
81  if (layerIndex == 1)
82  copyIndex = (zside + 1) / 2;
83  }
84 
85  return copyIndex;
86  }
87 
88  static int unpackOrientation(int rn0, int zside) {
89  // Front: Orientation= 1; Back: Orientation= 2
90  int Orientation = 2;
91  if (zside > (rn0 - 1) || zside < 1)
92  Orientation = 0;
93  if (zside == 1 || zside == 2)
94  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) {
107  zside = 0;
108  } else if (zsideinorder < 4) {
109  zside = 2 * zsideinorder - 1;
110  } else if (zsideinorder < 7) {
111  zside = 2 * zsideinorder - 6;
112  } else {
113  zside = 0;
114  }
115  zsidereal = zside;
116  //
117  //old:
118  if (rn0 == 3) {
119  if (zside > 2)
120  zsidereal = 0;
121  }
122  //new:
123  if (rn0 == 7) {
124  // if(zside==3 || zside==6) zsidereal=0; // ????
125  if (zside == 4 || zside == 5)
126  zsidereal = 0;
127  }
128  //
129  return zsidereal;
130  }
131 };
132 
133 #endif
FP420NumberingScheme::FP420NumberingScheme
FP420NumberingScheme()
Definition: FP420NumberingScheme.cc:16
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
relativeConstraints.station
station
Definition: relativeConstraints.py:67
FP420NumberingScheme::unpackOrientation
static int unpackOrientation(int rn0, int zside)
Definition: FP420NumberingScheme.h:88
training_settings.idx
idx
Definition: training_settings.py:16
FP420NumberingScheme::unpackMYIndex
static void unpackMYIndex(const int &idx, int rn0, int pn0, int sn0, int &det, int &zside, int &sector, int &zmodule)
Definition: FP420NumberingScheme.h:47
FP420NumberingScheme::unpackFP420Index
static void unpackFP420Index(const unsigned int &idx, int &det, int &zside, int &station, int &superplane)
Definition: FP420NumberingScheme.cc:163
FP420NumberingScheme::packFP420Index
static unsigned int packFP420Index(int det, int zside, int station, int superplane)
Definition: FP420NumberingScheme.cc:143
FP420NumberingScheme::unpackCopyIndex
static int unpackCopyIndex(int rn0, int zside)
Definition: FP420NumberingScheme.h:69
FP420NumberingScheme::getUnitID
virtual unsigned int getUnitID(const G4Step *aStep) const
Definition: FP420NumberingScheme.cc:45
FP420NumberingScheme::~FP420NumberingScheme
virtual ~FP420NumberingScheme()
Definition: FP420NumberingScheme.cc:20
b
double b
Definition: hdecay.h:118
FP420NumberingScheme::packMYIndex
static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule)
Definition: FP420NumberingScheme.h:37
a
double a
Definition: hdecay.h:119
FP420NumberingScheme::realzside
static int realzside(int rn0, int zsideinorder)
Definition: FP420NumberingScheme.h:99
FP420NumberingScheme::unpackLayerIndex
static int unpackLayerIndex(int rn0, int zside)
Definition: FP420NumberingScheme.h:56
createfilelist.int
int
Definition: createfilelist.py:10
FP420NumberingScheme::detectorLevel
virtual int detectorLevel(const G4Step *) const
Definition: FP420NumberingScheme.cc:24
FP420NumberingScheme
Definition: FP420NumberingScheme.h:15