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
8 //
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 #include "globals.hh"
11 #include "G4Step.hh"
12 #include <iostream>
13 
14 //UserVerbosity FP420NumberingScheme::cout("FP420NumberingScheme","silent","FP420NumberingScheme");
15 
17  // sn0=3, pn0=6, rn0=7;
18 }
19 
21  // std::cout << " Deleting FP420NumberingScheme" << std::endl;
22 }
23 
24 int FP420NumberingScheme::detectorLevel(const G4Step* aStep) const {
25  //Find number of levels
26  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
27  int level = 0;
28  if (touch)
29  level = ((touch->GetHistoryDepth()) + 1);
30  return level;
31 }
32 
33 void FP420NumberingScheme::detectorLevel(const G4Step* aStep, int& level, int* copyno, G4String* name) const {
34  //Get name and copy numbers
35  if (level > 0) {
36  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
37  for (int ii = 0; ii < level; ii++) {
38  int i = level - ii - 1;
39  name[ii] = touch->GetVolume(i)->GetName();
40  copyno[ii] = touch->GetReplicaNumber(i);
41  }
42  }
43 }
44 
45 unsigned int FP420NumberingScheme::getUnitID(const G4Step* aStep) const {
46  unsigned intindex = 0;
47  int level = detectorLevel(aStep);
48 
49  // std::cout << "FP420NumberingScheme number of levels= " << level << std::endl;
50 
51  // unsigned int intIndex = 0;
52  if (level > 0) {
53  int* copyno = new int[level];
54  G4String* name = new G4String[level];
55  detectorLevel(aStep, level, copyno, name);
56 
57  // int det = static_cast<int>(FP420);;
58 
59  int det = 1;
60  int stationgen = 0;
61  int zside = 0;
62  int station = 0;
63  int plane = 0;
64  for (int ich = 0; ich < level; ich++) {
65  /*
66  // old set up configuration with equidistant stations
67  if(name[ich] == "FP420Ex") {
68  stationgen = copyno[ich];
69  } else if(name[ich] == "SISTATION") {
70  station = stationgen;
71  } else if(name[ich] == "SIPLANE") {
72  plane = copyno[ich];
73  } else if(name[ich] == "SIDETL") {
74  zside = 1;
75  } else if(name[ich] == "SIDETR") {
76  zside = 2;
77  }
78  */
79  // new and old set up configurations are possible:
80  if (name[ich] == "FP420E") {
81  det = copyno[ich];
82  } else if (name[ich] == "HPS240E") {
83  det = copyno[ich] + 2;
84  } else if (name[ich] == "FP420Ex1" || name[ich] == "HPS240Ex1") {
85  stationgen = 1;
86  // } else if(name[ich] == "FP420Ex2") {
87  // stationgen = 2;
88  } else if (name[ich] == "FP420Ex3" || name[ich] == "HPS240Ex3") {
89  stationgen = 2; // was =3
90  } else if (name[ich] == "SISTATION" || name[ich] == "HPS240SISTATION") {
91  station = stationgen;
92  } else if (name[ich] == "SIPLANE" || name[ich] == "HPS240SIPLANE") {
93  plane = copyno[ich];
94  // SIDETL (or R) can be ether X or Y type in next schemes of readout
95  // !!! (=...) zside
96  //
97  // 1 2 <---copyno
98  // Front(=2) Empty(=4) Back(=6) <--SIDETR OR SENSOR2
99  // 1 2 <---copyno
100  // Front(=1) Back(=3) Empty(=5) <--SIDETL OR SENSOR1
101  //
102  } else if (name[ich] == "SENSOR2" || name[ich] == "HPS240SENSOR2") {
103  // } else if(name[ich] == "SIDETR") {
104  // zside = 4 * copyno[ich] - 2 ;//= 2 6 (copyno=1,2)
105  zside = 3 * copyno[ich]; //= 3 6 (copyno=1,2)
106  } else if (name[ich] == "SENSOR1" || name[ich] == "HPS240SENSOR1") {
107  // } else if(name[ich] == "SIDETL") {
108  // zside = 2 * copyno[ich] - 1 ;//= 1 3 (copyno=1,2)
109  zside = copyno[ich]; //= 1 2 (copyno=1,2)
110  }
111  //
112  // std::cout << "FP420NumberingScheme " << "ich=" << ich << "copyno" << copyno[ich] << "name=" << name[ich] << std::endl;
113  //
114  }
115  // det = 1 for +FP420 , = 2 for -FP420 / (det-1) = 0,1
116  // det = 3 for +HPS240 , = 4 for -HPS240 / (det-1) = 2,3
117  // 0 is as default for every below:
118  // Z index
119  // station number 1 - 8 (in reality just 2 ones)
120  // superplane(superlayer) number 1 - 16 (in reality just 5 ones)
121 
122  // intindex = myPacker.packEcalIndex (det, zside, station, plane);// see examples
123  // intindex = myPacker.packCastorIndex (det, zside, station, plane);// see examples
124  intindex = packFP420Index(det, zside, station, plane);
125  /*
126  //
127  std::cout << "FP420NumberingScheme det=" << det << " zside=" << zside << " station=" <<station << " plane=" << plane << std::endl;
128 
129  for (int ich = 0; ich < level; ich++) {
130  std::cout <<" name = " << name[ich] <<" copy = " << copyno[ich] << std::endl;
131  std::cout << " packed index = intindex" << intindex << std::endl;
132  }
133  //
134  */
135 
136  delete[] copyno;
137  delete[] name;
138  }
139 
140  return intindex;
141 }
142 
143 unsigned FP420NumberingScheme::packFP420Index(int det, int zside, int station, int plane) {
144  //
145  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
146  // unsigned int idx = ((det-1)&1)<<20;//bit 20-20 (det-1):0- 1 = 2-->2**1 = 2 -> 2-1 ->((det-1)&1) 1 bit: 0
147  idx += (zside & 7) << 7; //bits 7- 9 zside:0- 7 = 8-->2**3 = 8 -> 8-1 -> (zside&7) 3 bits:0-2
148  // idx += (zside&3)<<7; //bits 7- 8 zside:0- 3 = 4-->2**2 = 4 -> 4-1 -> (zside&3) 2 bits:0-1
149  idx += (station & 7) << 4; //bits 4- 6 station:0- 7 = 8-->2**3 = 8 -> 8-1 ->(station&7) 3 bits:0-2
150  idx += (plane & 15); //bits 0- 3 plane:0-15 =16-->2**4 =16 ->16-1 -> (plane&15) 4 bits:0-3
151 
152  //
153 
154  // std::cout << "FP420 packing: det " << det << " zside " << zside << " station " << station << " plane " << plane << " idx " << idx << std::endl;
155  // int newdet, newzside, newstation,newplane;
156  // unpackFP420Index(idx, newdet, newzside, newstation,newplane);
157 
158  //
159 
160  return idx;
161 }
162 
163 void FP420NumberingScheme::unpackFP420Index(const unsigned int& idx, int& det, int& zside, int& station, int& plane) {
164  det = (idx >> 19) & 3;
165  //det = (idx>>20)&1;
166  det += 1;
167  zside = (idx >> 7) & 7;
168  // zside = (idx>>7)&3;
169  station = (idx >> 4) & 7;
170  plane = idx & 15;
171  //
172 
173  // std::cout << " FP420unpacking: idx=" << idx << " zside " << zside << " station " << station << " plane " << plane << std::endl;
174 
175  //
176 }
personalPlayback.level
level
Definition: personalPlayback.py:22
FP420NumberingScheme::FP420NumberingScheme
FP420NumberingScheme()
Definition: FP420NumberingScheme.cc:16
mps_fire.i
i
Definition: mps_fire.py:355
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
relativeConstraints.station
station
Definition: relativeConstraints.py:67
FP420NumberingScheme.h
training_settings.idx
idx
Definition: training_settings.py:16
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::getUnitID
virtual unsigned int getUnitID(const G4Step *aStep) const
Definition: FP420NumberingScheme.cc:45
FP420NumberingScheme::~FP420NumberingScheme
virtual ~FP420NumberingScheme()
Definition: FP420NumberingScheme.cc:20
FP420NumberingScheme::detectorLevel
virtual int detectorLevel(const G4Step *) const
Definition: FP420NumberingScheme.cc:24
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
cuy.ii
ii
Definition: cuy.py:590