CMS 3D CMS Logo

GEMNumberingScheme.cc
Go to the documentation of this file.
6 
7 //#define LOCAL_DEBUG
8 
9 GEMNumberingScheme::GEMNumberingScheme(const MuonDDDConstants& muonConstants) { initMe(muonConstants); }
10 
12  MuonDDDConstants muonConstants(cpv);
13  initMe(muonConstants);
14 }
15 
16 void GEMNumberingScheme::initMe(const MuonDDDConstants& muonConstants) {
17  int theLevelPart = muonConstants.getValue("level");
18  theRegionLevel = muonConstants.getValue("mg_region") / theLevelPart;
19  theStationLevel = muonConstants.getValue("mg_station") / theLevelPart;
20  theRingLevel = muonConstants.getValue("mg_ring") / theLevelPart;
21  theSectorLevel = muonConstants.getValue("mg_sector") / theLevelPart;
22  theRollLevel = muonConstants.getValue("mg_roll") / theLevelPart;
23 #ifdef LOCAL_DEBUG
24  edm::LogVerbatim("GEMNumberingScheme") << "Initialize GEMNumberingScheme"
25  << "\ntheRegionLevel " << theRegionLevel << "\ntheStationLevel "
26  << theStationLevel << "\ntheRingLevel " << theRingLevel << "\ntheSectorLevel "
27  << theSectorLevel << "\ntheRollLevel " << theRollLevel;
28 #endif
29 }
30 
32 #ifdef LOCAL_DEBUG
33  edm::LogVerbatim("GEMNumberingScheme") << "GEMNumbering " << num.getLevels();
34  for (int level = 1; level <= num.getLevels(); level++) {
35  edm::LogVerbatim("GEMNumberingScheme") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
36  }
37 #endif
38 
39  int maxLevel = theRollLevel;
40  if (num.getLevels() != maxLevel) {
41  edm::LogWarning("GEMNumberingScheme")
42  << "MuonGEMNumberingScheme::BNToUN: BaseNumber has " << num.getLevels() << " levels, need " << maxLevel;
43  return 0;
44  }
45 
46  int region(0), ring(0), station(0), layer(0), chamber(0), roll(0);
47 
48  //decode significant GEM levels
49 
50  if (num.getBaseNo(theRegionLevel) == 0)
51  region = 1;
52  else
53  region = -1;
54 
55  // All GEM super chambers in stations 1 and 2 are on ring 1.
56  // The long super chambers in station 2 are assigned *station 3* due
57  // to the current limitation in the definition of the GEMDetId,
58  // i.e. only 2 layers available per station.
59  // ring = num.getSuperNo(theRingLevel);
60  // GEM are only on the first ring
61  ring = 1;
63 #ifdef LOCAL_DEBUG
64  edm::LogVerbatim("GEMNumberingScheme") << "GEMNumbering: Ring " << ring << " Station "
65  << num.getSuperNo(theStationLevel) << ":" << station;
66 #endif
67 
68  roll = num.getBaseNo(theRollLevel) + 1;
69  const int copyno = num.getBaseNo(theSectorLevel) + 1;
70  if (copyno < 50) {
71  if (copyno % 2 == 0) {
72  layer = 2;
73  chamber = copyno - 1;
74  } else {
75  layer = 1;
76  chamber = copyno;
77  }
78  } else {
79  int copynp = copyno - 50;
80  if (copynp % 2 != 0) {
81  layer = 2;
82  chamber = copynp - 1;
83  } else {
84  layer = 1;
85  chamber = copynp;
86  }
87  }
88 
89  // collect all info
90 
91 #ifdef LOCAL_DEBUG
92  edm::LogVerbatim("GEMNumberingScheme") << "GEMNumberingScheme: Region " << region << " Ring " << ring << " Station "
93  << station << " Layer " << layer << " Chamber " << chamber << " Roll " << roll;
94 #endif
95 
96  // Build the actual numbering
97  GEMDetId id(region, ring, station, layer, chamber, roll);
98 
99 #ifdef LOCAL_DEBUG
100  edm::LogVerbatim("GEMNumberingScheme") << id.rawId() << " DetId " << id;
101 #endif
102 
103  return id.rawId();
104 }
void initMe(const MuonDDDConstants &muonConstants)
int getBaseNo(int level) const
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
int getValue(const std::string &name) const
int getLevels() const
int getSuperNo(int level) const
GEMNumberingScheme(const DDCompactView &cpv)
int baseNumberToUnitNumber(const MuonBaseNumber &) override