CMS 3D CMS Logo

BHMNumberingScheme.cc
Go to the documentation of this file.
3 #include "CLHEP/Units/GlobalSystemOfUnits.h"
4 #include "globals.hh"
5 
6 BHMNumberingScheme::BHMNumberingScheme() { LogDebug("BHMSim") << " Creating BHMNumberingScheme"; }
7 
8 int BHMNumberingScheme::detectorLevel(const G4Step* aStep) const {
9  //Find number of levels
10  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
11  return (touch) ? ((touch->GetHistoryDepth()) + 1) : 0;
12 }
13 
14 void BHMNumberingScheme::detectorLevel(const G4Step* aStep, int& level, int* copyno, G4String* name) const {
15  //Get name and copy numbers
16  if (level > 0) {
17  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
18  for (int ii = 0; ii < level; ++ii) {
19  int i = level - ii - 1;
20  name[ii] = touch->GetVolume(i)->GetName();
21  copyno[ii] = touch->GetReplicaNumber(i);
22  }
23  }
24 }
25 
26 unsigned int BHMNumberingScheme::getUnitID(const G4Step* aStep) const {
27  unsigned intindex = 0;
28  int level = detectorLevel(aStep);
29 
30  LogDebug("BHMSim") << "BHMNumberingScheme number of levels= " << level;
31  if (level > 0) {
32  int* copyno = new int[level];
33  G4String* name = new G4String[level];
34  detectorLevel(aStep, level, copyno, name);
35 
36  if (level > 3) {
37  int subdet = copyno[0];
38  int zside = copyno[3];
39  int station = copyno[1];
40  intindex = packIndex(subdet, zside, station);
41  LogDebug("BHMSim") << "BHMNumberingScheme : subdet " << subdet << " zside " << zside << " station " << station;
42  }
43  delete[] copyno;
44  delete[] name;
45  }
46  LogDebug("BHMSim") << "BHMNumberingScheme : UnitID 0x" << std::hex << intindex << std::dec;
47 
48  return intindex;
49 }
50 
51 unsigned int BHMNumberingScheme::packIndex(int subdet, int zside, int station) {
52  unsigned int idx = ((6 << 28) | (subdet & 0x7) << 25); // Use 6 as the detector name
53  idx |= ((zside & 0x3) << 5) | (station & 0x1F); // bits 0-4:station 5-6:side
54  LogDebug("BHMSim") << "BHM packing: subdet " << subdet << " zside " << zside << " station " << station << "-> 0x"
55  << std::hex << idx << std::dec;
56  return idx;
57 }
58 
59 void BHMNumberingScheme::unpackIndex(const unsigned int& idx, int& subdet, int& zside, int& station) {
60  subdet = (idx >> 25) >> 0x7;
61  zside = (idx >> 5) & 0x3;
62  station = idx & 0x1F;
63  LogDebug("BHMSim") << " Bsc unpacking: 0x " << std::hex << idx << std::dec << " -> subdet " << subdet << " zside "
64  << zside << " station " << station;
65 }
personalPlayback.level
level
Definition: personalPlayback.py:22
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
BHMNumberingScheme.h
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
relativeConstraints.station
station
Definition: relativeConstraints.py:67
BHMNumberingScheme::getUnitID
unsigned int getUnitID(const G4Step *aStep) const
Definition: BHMNumberingScheme.cc:26
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
BHMNumberingScheme::BHMNumberingScheme
BHMNumberingScheme()
Definition: BHMNumberingScheme.cc:6
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
BHMNumberingScheme::packIndex
static unsigned int packIndex(int subdet, int zside, int station)
Definition: BHMNumberingScheme.cc:51
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
BHMNumberingScheme::unpackIndex
static void unpackIndex(const unsigned int &idx, int &subdet, int &zside, int &station)
Definition: BHMNumberingScheme.cc:59
BHMNumberingScheme::detectorLevel
int detectorLevel(const G4Step *) const
Definition: BHMNumberingScheme.cc:8
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
cuy.ii
ii
Definition: cuy.py:590