CMS 3D CMS Logo

FP420NumberingScheme.cc
Go to the documentation of this file.
1 // File: FP420NumberingScheme.cc
3 // Date: 02.2006
4 // Description: Numbering scheme for FP420
5 // Modifications: 08.2008 mside and fside added
9 //
10 #include "CLHEP/Units/GlobalSystemOfUnits.h"
11 #include "globals.hh"
12 #include "G4Step.hh"
13 #include <iostream>
14 
15 //#define EDM_ML_DEBUG
16 
18  // sn0=3, pn0=6, rn0=7;
19 }
20 
21 unsigned int FP420NumberingScheme::getUnitID(const G4Step* aStep) const {
22  unsigned intindex = 0;
23  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
24  int level = (nullptr != touch) ? touch->GetHistoryDepth() + 1 : 0;
25 
26 #ifdef EDM_ML_DEBUG
27  edm::LogVerbatim("FP420") << "FP420NumberingScheme number of levels= " << level;
28 #endif
29  if (level > 0) {
30  int det = 1;
31  int stationgen = 0;
32  int zside = 0;
33  int station = 0;
34  int plane = 0;
35  for (int ich = 0; ich < level; ich++) {
36  int i = level - ich - 1;
37  const G4String& name = touch->GetVolume(i)->GetName();
38  int copyno = touch->GetReplicaNumber(i);
39 
40  // new and old set up configurations are possible:
41  if (name == "FP420E") {
42  det = copyno;
43  } else if (name == "HPS240E") {
44  det = copyno + 2;
45  } else if (name == "FP420Ex1" || name == "HPS240Ex1") {
46  stationgen = 1;
47  } else if (name == "FP420Ex3" || name == "HPS240Ex3") {
48  stationgen = 2; // was =3
49  } else if (name == "SISTATION" || name == "HPS240SISTATION") {
50  station = stationgen;
51  } else if (name == "SIPLANE" || name == "HPS240SIPLANE") {
52  plane = copyno;
53  // SIDETL (or R) can be ether X or Y type in next schemes of readout
54  // !!! (=...) zside
55  //
56  // 1 2 <---copyno
57  // Front(=2) Empty(=4) Back(=6) <--SIDETR OR SENSOR2
58  // 1 2 <---copyno
59  // Front(=1) Back(=3) Empty(=5) <--SIDETL OR SENSOR1
60  //
61  } else if (name == "SENSOR2" || name == "HPS240SENSOR2") {
62  zside = 3 * copyno; //= 3 6 (copyno=1,2)
63  } else if (name == "SENSOR1" || name == "HPS240SENSOR1") {
64  zside = copyno; //= 1 2 (copyno=1,2)
65  }
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("FP420") << "FP420NumberingScheme "
68  << "ich=" << ich << " copyno=" << copyno << " name=" << name;
69 #endif
70  }
71  // det = 1 for +FP420 , = 2 for -FP420 / (det-1) = 0,1
72  // det = 3 for +HPS240 , = 4 for -HPS240 / (det-1) = 2,3
73  // 0 is as default for every below:
74  // Z index
75  // station number 1 - 8 (in reality just 2 ones)
76  // superplane(superlayer) number 1 - 16 (in reality just 5 ones)
77 
78  intindex = packFP420Index(det, zside, station, plane);
79  //
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("FP420") << "FP420NumberingScheme det=" << det << " zside=" << zside << " station=" << station
82  << " plane=" << plane;
83 #endif
84  }
85  return intindex;
86 }
87 
88 unsigned FP420NumberingScheme::packFP420Index(int det, int zside, int station, int plane) {
89  unsigned int idx = ((det - 1) & 3) << 19; //bit 19-20 (det-1):0- 3 = 4-->2**2 = 4 -> 4-1 ->((det-1)&3) 2 bit: 0-1
90  idx += (zside & 7) << 7; //bits 7- 9 zside:0- 7 = 8-->2**3 = 8 -> 8-1 -> (zside&7) 3 bits:0-2
91  idx += (station & 7) << 4; //bits 4- 6 station:0- 7 = 8-->2**3 = 8 -> 8-1 ->(station&7) 3 bits:0-2
92  idx += (plane & 15); //bits 0- 3 plane:0-15 =16-->2**4 =16 ->16-1 -> (plane&15) 4 bits:0-3
93 
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("FP420") << "FP420 packing: det " << det << " zside " << zside << " station " << station
96  << " plane " << plane << " idx " << idx;
97 #endif
98 
99  return idx;
100 }
101 
102 void FP420NumberingScheme::unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& plane) {
103  det = (idx >> 19) & 3;
104  det += 1;
105  zside = (idx >> 7) & 7;
106  station = (idx >> 4) & 7;
107  plane = idx & 15;
108  //
109 
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("FP420") << " FP420unpacking: idx=" << idx << " zside " << zside << " station " << station
112  << " plane " << plane;
113 #endif
114  //
115 }
Log< level::Info, true > LogVerbatim
static void unpackFP420Index(const unsigned int &idx, int &det, int &zside, int &station, int &superplane)
int zside(DetId const &)
static unsigned int packFP420Index(int det, int zside, int station, int superplane)
unsigned int getUnitID(const G4Step *aStep) const