CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions
FP420NumberingScheme Class Reference

#include <FP420NumberingScheme.h>

Public Member Functions

virtual int detectorLevel (const G4Step *) const
 
virtual void detectorLevel (const G4Step *, int &, int *, G4String *) const
 
 FP420NumberingScheme ()
 
virtual unsigned int getUnitID (const G4Step *aStep) const
 
unsigned packMYIndex (int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule)
 
int realzside (int rn0, int zsideinorder)
 
int unpackCopyIndex (int rn0, int zside)
 
int unpackLayerIndex (int rn0, int zside)
 
void unpackMYIndex (const int &idx, int rn0, int pn0, int sn0, int &det, int &zside, int &sector, int &zmodule)
 
int unpackOrientation (int rn0, int zside)
 
virtual ~FP420NumberingScheme ()
 

Static Public Member Functions

static unsigned int packFP420Index (int det, int zside, int station, int superplane)
 
static void unpackFP420Index (const unsigned int &idx, int &det, int &zside, int &station, int &superplane)
 

Detailed Description

Definition at line 18 of file FP420NumberingScheme.h.

Constructor & Destructor Documentation

FP420NumberingScheme::FP420NumberingScheme ( )

Definition at line 15 of file FP420NumberingScheme.cc.

15  {
16 // sn0=3, pn0=6, rn0=7;
17 }
FP420NumberingScheme::~FP420NumberingScheme ( )
virtual

Definition at line 19 of file FP420NumberingScheme.cc.

19  {
20  // std::cout << " Deleting FP420NumberingScheme" << std::endl;
21 }

Member Function Documentation

int FP420NumberingScheme::detectorLevel ( const G4Step *  aStep) const
virtual

Definition at line 24 of file FP420NumberingScheme.cc.

References testEve_cfg::level.

Referenced by getUnitID().

24  {
25 
26  //Find number of levels
27  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
28  int level = 0;
29  if (touch) level = ((touch->GetHistoryDepth())+1);
30  return level;
31 }
tuple level
Definition: testEve_cfg.py:34
void FP420NumberingScheme::detectorLevel ( const G4Step *  aStep,
int &  level,
int *  copyno,
G4String *  name 
) const
virtual

Definition at line 33 of file FP420NumberingScheme.cc.

References i, and testEve_cfg::level.

34  {
35 
36  //Get name and copy numbers
37  if (level > 0) {
38  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
39  for (int ii = 0; ii < level; ii++) {
40  int i = level - ii - 1;
41  name[ii] = touch->GetVolume(i)->GetName();
42  copyno[ii] = touch->GetReplicaNumber(i);
43  }
44  }
45 }
int i
Definition: DBlmapReader.cc:9
tuple level
Definition: testEve_cfg.py:34
unsigned int FP420NumberingScheme::getUnitID ( const G4Step *  aStep) const
virtual

Definition at line 50 of file FP420NumberingScheme.cc.

References detectorLevel(), testEve_cfg::level, mergeVDriftHistosByStation::name, packFP420Index(), and relativeConstraints::station.

Referenced by FP420SD::setDetUnitId().

50  {
51 
52  unsigned intindex=0;
53  int level = detectorLevel(aStep);
54 
55  // std::cout << "FP420NumberingScheme number of levels= " << level << std::endl;
56 
57  // unsigned int intIndex = 0;
58  if (level > 0) {
59  int* copyno = new int[level];
60  G4String* name = new G4String[level];
61  detectorLevel(aStep, level, copyno, name);
62 
63  // int det = static_cast<int>(FP420);;
64 
65  int det = 1;
66  int stationgen = 0;
67  int zside = 0;
68  int station = 0;
69  int plane = 0;
70  for (int ich=0; ich < level; ich++) {
71  /*
72  // old set up configuration with equidistant stations
73  if(name[ich] == "FP420Ex") {
74  stationgen = copyno[ich];
75  } else if(name[ich] == "SISTATION") {
76  station = stationgen;
77  } else if(name[ich] == "SIPLANE") {
78  plane = copyno[ich];
79  } else if(name[ich] == "SIDETL") {
80  zside = 1;
81  } else if(name[ich] == "SIDETR") {
82  zside = 2;
83  }
84  */
85  // new and old set up configurations are possible:
86  if(name[ich] == "FP420E") {
87  det = copyno[ich];
88  } else if(name[ich] == "HPS240E") {
89  det = copyno[ich] + 2 ;
90  } else if(name[ich] == "FP420Ex1" || name[ich] == "HPS240Ex1") {
91  stationgen = 1;
92  // } else if(name[ich] == "FP420Ex2") {
93  // stationgen = 2;
94  } else if(name[ich] == "FP420Ex3" || name[ich] == "HPS240Ex3") {
95  stationgen = 2;// was =3
96  } else if(name[ich] == "SISTATION" || name[ich] == "HPS240SISTATION") {
97  station = stationgen;
98  } else if(name[ich] == "SIPLANE" || name[ich] == "HPS240SIPLANE") {
99  plane = copyno[ich];
100  // SIDETL (or R) can be ether X or Y type in next schemes of readout
101  // !!! (=...) zside
102  //
103  // 1 2 <---copyno
104  // Front(=2) Empty(=4) Back(=6) <--SIDETR OR SENSOR2
105  // 1 2 <---copyno
106  // Front(=1) Back(=3) Empty(=5) <--SIDETL OR SENSOR1
107  //
108  } else if(name[ich] == "SENSOR2" || name[ich] == "HPS240SENSOR2") {
109  // } else if(name[ich] == "SIDETR") {
110  // zside = 4 * copyno[ich] - 2 ;//= 2 6 (copyno=1,2)
111  zside = 3 * copyno[ich];//= 3 6 (copyno=1,2)
112  } else if(name[ich] == "SENSOR1" || name[ich] == "HPS240SENSOR1") {
113  // } else if(name[ich] == "SIDETL") {
114  // zside = 2 * copyno[ich] - 1 ;//= 1 3 (copyno=1,2)
115  zside = copyno[ich];//= 1 2 (copyno=1,2)
116  }
117  //
118  // std::cout << "FP420NumberingScheme " << "ich=" << ich << "copyno" << copyno[ich] << "name=" << name[ich] << std::endl;
119  //
120  }
121  // det = 1 for +FP420 , = 2 for -FP420 / (det-1) = 0,1
122  // det = 3 for +HPS240 , = 4 for -HPS240 / (det-1) = 2,3
123  // 0 is as default for every below:
124  // Z index
125  // station number 1 - 8 (in reality just 2 ones)
126  // superplane(superlayer) number 1 - 16 (in reality just 5 ones)
127 
128  // intindex = myPacker.packEcalIndex (det, zside, station, plane);// see examples
129  // intindex = myPacker.packCastorIndex (det, zside, station, plane);// see examples
130  intindex = packFP420Index (det, zside, station, plane);
131  /*
132  //
133  std::cout << "FP420NumberingScheme det=" << det << " zside=" << zside << " station=" <<station << " plane=" << plane << std::endl;
134 
135  for (int ich = 0; ich < level; ich++) {
136  std::cout <<" name = " << name[ich] <<" copy = " << copyno[ich] << std::endl;
137  std::cout << " packed index = intindex" << intindex << std::endl;
138  }
139  //
140  */
141 
142 
143  delete[] copyno;
144  delete[] name;
145  }
146 
147  return intindex;
148 
149 }
virtual int detectorLevel(const G4Step *) const
static unsigned int packFP420Index(int det, int zside, int station, int superplane)
tuple level
Definition: testEve_cfg.py:34
unsigned FP420NumberingScheme::packFP420Index ( int  det,
int  zside,
int  station,
int  superplane 
)
static

Definition at line 151 of file FP420NumberingScheme.cc.

Referenced by getUnitID(), and FP420Test::update().

151  {
152  //
153  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
154  // 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
155  idx += (zside&7)<<7; //bits 7- 9 zside:0- 7 = 8-->2**3 = 8 -> 8-1 -> (zside&7) 3 bits:0-2
156  // idx += (zside&3)<<7; //bits 7- 8 zside:0- 3 = 4-->2**2 = 4 -> 4-1 -> (zside&3) 2 bits:0-1
157  idx += (station&7)<<4; //bits 4- 6 station:0- 7 = 8-->2**3 = 8 -> 8-1 ->(station&7) 3 bits:0-2
158  idx += (plane&15); //bits 0- 3 plane:0-15 =16-->2**4 =16 ->16-1 -> (plane&15) 4 bits:0-3
159 
160  //
161 
162  // std::cout << "FP420 packing: det " << det << " zside " << zside << " station " << station << " plane " << plane << " idx " << idx << std::endl;
163  // int newdet, newzside, newstation,newplane;
164  // unpackFP420Index(idx, newdet, newzside, newstation,newplane);
165 
166  //
167 
168  return idx;
169 }
unsigned FP420NumberingScheme::packMYIndex ( int  rn0,
int  pn0,
int  sn0,
int  det,
int  zside,
int  sector,
int  zmodule 
)
inline

Definition at line 42 of file FP420NumberingScheme.h.

43  {
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  }
int FP420NumberingScheme::realzside ( int  rn0,
int  zsideinorder 
)
inline

Definition at line 101 of file FP420NumberingScheme.h.

101  {
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  }
int FP420NumberingScheme::unpackCopyIndex ( int  rn0,
int  zside 
)
inline

Definition at line 75 of file FP420NumberingScheme.h.

References a, and b.

75  {
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  }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void FP420NumberingScheme::unpackFP420Index ( const unsigned int &  idx,
int &  det,
int &  zside,
int &  station,
int &  superplane 
)
static

Definition at line 173 of file FP420NumberingScheme.cc.

Referenced by ChargeDividerFP420::DeconvolutionShape(), ChargeDividerFP420::PeakShape(), cms::DigitizerFP420::produce(), and FP420Test::update().

175  {
176  det = (idx>>19)&3;
177  //det = (idx>>20)&1;
178  det += 1;
179  zside = (idx>>7)&7;
180  // zside = (idx>>7)&3;
181  station = (idx>>4)&7;
182  plane = idx&15;
183  //
184 
185  // std::cout << " FP420unpacking: idx=" << idx << " zside " << zside << " station " << station << " plane " << plane << std::endl;
186 
187  //
188 }
int FP420NumberingScheme::unpackLayerIndex ( int  rn0,
int  zside 
)
inline

Definition at line 64 of file FP420NumberingScheme.h.

References a, and b.

64  {
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  }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void FP420NumberingScheme::unpackMYIndex ( const int &  idx,
int  rn0,
int  pn0,
int  sn0,
int &  det,
int &  zside,
int &  sector,
int &  zmodule 
)
inline

Definition at line 53 of file FP420NumberingScheme.h.

55  {
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  }
int FP420NumberingScheme::unpackOrientation ( int  rn0,
int  zside 
)
inline

Definition at line 92 of file FP420NumberingScheme.h.

92  {
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  }