CMS 3D CMS Logo

BscNumberingScheme.cc
Go to the documentation of this file.
1 // File: BscNumberingScheme.cc
3 // Date: 02.2006
4 // Description: Numbering scheme for Bsc
5 // Modifications:
8 //
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 #include "globals.hh"
12 
13 BscNumberingScheme::BscNumberingScheme() { LogDebug("BscSim") << " Creating BscNumberingScheme"; }
14 
15 int BscNumberingScheme::detectorLevel(const G4Step* aStep) const {
16  //Find number of levels
17  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
18  return (touch) ? ((touch->GetHistoryDepth()) + 1) : 0;
19 }
20 
21 void BscNumberingScheme::detectorLevel(const G4Step* aStep, int& level, int* copyno, G4String* name) const {
22  //Get name and copy numbers
23  if (level > 0) {
24  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
25  for (int ii = 0; ii < level; ++ii) {
26  int i = level - ii - 1;
27  name[ii] = touch->GetVolume(i)->GetName();
28  copyno[ii] = touch->GetReplicaNumber(i);
29  }
30  }
31 }
32 
33 unsigned int BscNumberingScheme::getUnitID(const G4Step* aStep) const {
34  unsigned int intindex = 0;
35  int level = detectorLevel(aStep);
36 
37  LogDebug("BscSim") << "BscNumberingScheme number of levels= " << level;
38 
39  if (level > 0) {
40  int* copyno = new int[level];
41  G4String* name = new G4String[level];
42  detectorLevel(aStep, level, copyno, name);
43 
44  int det = 0;
45  int zside = 0;
46  int station = 0;
47  for (int ich = 0; ich < level; ich++) {
48  // new and old set up configurations are possible:
49  if (name[ich] == "BSC1" || name[ich] == "BSC2") {
50  zside = copyno[ich] - 1;
51  } else if (name[ich] == "BSCTrap") {
52  det = 0;
53  station = 2 * (copyno[ich] - 1);
54  } else if (name[ich] == "BSCTubs") {
55  det = 1;
56  station = copyno[ich] - 1;
57  } else if (name[ich] == "BSCTTop") {
58  ++station;
59  } else if (name[ich] == "BSC2Pad") {
60  det = 2;
61  station = copyno[ich] - 1;
62  }
63 
64  LogDebug("BscSim") << "BscNumberingScheme "
65  << "ich=" << ich << "copyno" << copyno[ich] << "name=" << name[ich];
66  }
67  intindex = packBscIndex(zside, det, station);
68  LogDebug("BscSim") << "BscNumberingScheme : det " << det << " zside " << zside << " station " << station
69  << " UnitID 0x" << std::hex << intindex << std::dec;
70 
71  for (int ich = 0; ich < level; ich++)
72  LogDebug("BscSim") << " name = " << name[ich] << " copy = " << copyno[ich];
73 
74  LogDebug("BscSim") << " packed index = 0x" << std::hex << intindex << std::dec;
75 
76  delete[] copyno;
77  delete[] name;
78  }
79 
80  return intindex;
81 }
82 
83 unsigned int BscNumberingScheme::packBscIndex(int zside, int det, int station) {
84  unsigned int idx = 6 << 28; // autre numero que les detecteurs existants
85  idx += (zside << 5) & 32; // vaut 0 ou 1 bit 5
86  idx += (det << 3) & 24; //bit 3-4 det:0-1-2 2 bits:0-1
87  idx += (station & 7); //bits 0-2 station:0-7=8-->2**3 =8 3 bits:0-2
88  LogDebug("BscSim") << "Bsc packing: det " << det << " zside " << zside << " station " << station << "-> 0x"
89  << std::hex << idx << std::dec;
90 
91  // unpackBscIndex(idx);
92  return idx;
93 }
94 
95 void BscNumberingScheme::unpackBscIndex(const unsigned int& idx) {
96  int zside, det, station;
97  zside = (idx & 32) >> 5;
98  det = (idx & 24) >> 3;
99  station = idx & 7;
100  LogDebug("BscSim") << " Bsc unpacking: 0x " << std::hex << idx << std::dec << " -> det " << det << " zside " << zside
101  << " station " << station;
102 }
personalPlayback.level
level
Definition: personalPlayback.py:22
mps_fire.i
i
Definition: mps_fire.py:355
BscNumberingScheme::detectorLevel
int detectorLevel(const G4Step *) const
Definition: BscNumberingScheme.cc:15
MessageLogger.h
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
relativeConstraints.station
station
Definition: relativeConstraints.py:67
BscNumberingScheme::BscNumberingScheme
BscNumberingScheme()
Definition: BscNumberingScheme.cc:13
BscNumberingScheme.h
training_settings.idx
idx
Definition: training_settings.py:16
BscNumberingScheme::unpackBscIndex
static void unpackBscIndex(const unsigned int &idx)
Definition: BscNumberingScheme.cc:95
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
BscNumberingScheme::getUnitID
unsigned int getUnitID(const G4Step *aStep) const
Definition: BscNumberingScheme.cc:33
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
BscNumberingScheme::packBscIndex
static unsigned int packBscIndex(int det, int zside, int station)
Definition: BscNumberingScheme.cc:83
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
cuy.ii
ii
Definition: cuy.py:590