CMS 3D CMS Logo

DD4hep_CSCNumberingScheme.cc
Go to the documentation of this file.
1 /*
2 // \class CSCNumberingScheme
3 //
4 // Description: CSC Numbering Scheme for DD4hep
5 //
6 //
7 // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
8 // Created: Thu, 05 March 2020
9 //
10 // Old DD version authors: Arno Straessner & Tim Cox
11 */
12 //
17 #include <cassert>
18 
19 using namespace cms;
20 
21 CSCNumberingScheme::CSCNumberingScheme(const MuonConstants& muonConstants) { initMe(muonConstants); }
22 
23 void CSCNumberingScheme::initMe(const MuonConstants& muonConstants) {
24  int theLevelPart = get("level", muonConstants);
25  assert(theLevelPart != 0);
26  theRegionLevel = get("me_region", muonConstants) / theLevelPart;
27  theStationLevel = get("me_station", muonConstants) / theLevelPart;
28  theSubringLevel = get("me_subring", muonConstants) / theLevelPart;
29  theSectorLevel = get("me_sector", muonConstants) / theLevelPart;
30  theRingLevel = get("me_ring", muonConstants) / theLevelPart;
31  theLayerLevel = get("me_layer", muonConstants) / theLevelPart;
32 }
33 
35  int fwbw_id = 0;
36  int station_id = 0;
37  int ring_id = 0;
38  int subring_id = 0;
39  int sector_id = 0;
40  int layer_id = 0;
41 
42  // Decode endcap levels
43  // We should be able to work with 6 (layer-level) or 5 (chamber-level)
44 
45  for (int level = 1; level <= num.getLevels(); level++) {
46  if (level == theRegionLevel) {
47  const int copyno = num.getBaseNo(level);
48  fwbw_id = copyno + 1;
49  } else if (level == theStationLevel) {
50  const int station_tag = num.getSuperNo(level);
51  station_id = station_tag;
52  } else if (level == theSubringLevel) {
53  const int copyno = num.getBaseNo(level);
54  subring_id = copyno + 1;
55  } else if (level == theSectorLevel) {
56  const int copyno = num.getBaseNo(level);
57  sector_id = copyno + 1;
58  } else if (level == theLayerLevel) {
59  const int copyno = num.getBaseNo(level);
60  layer_id = copyno + 1;
61  } else if (level == theRingLevel) {
62  const int ring_tag = num.getSuperNo(level);
63  ring_id = ring_tag;
64  }
65  }
66 
67  // find appropriate chamber label
68 
69  int chamber_id = chamberIndex(station_id, ring_id, subring_id, sector_id);
70 
71  // convert into raw id of appropriate DetId
72 
73  int intIndex = CSCDetId::rawIdMaker(fwbw_id, station_id, ring_id, chamber_id, layer_id);
74 
75  setDetId(intIndex);
76 }
77 
78 int CSCNumberingScheme::chamberIndex(int station_id, int ring_id, int subring_id, int sector_id) const {
79  int chamber_id = 0;
80 
81  // chamber label is related to sector_id but we need to
82  // adjust to real hardware labelling
83  // Tim confirms this works properly according to CMS IN 2000/004 Version 2.5 March 2007.
84 
85  if (ring_id == 3) {
86  chamber_id = sector_id;
87  } else {
88  if (subring_id == 1) {
89  chamber_id = 2 * sector_id - 1;
90  } else {
91  chamber_id = 2 * sector_id;
92  }
93  }
94 
95  return chamber_id;
96 }
97 
98 const int CSCNumberingScheme::get(const char* key, const MuonConstants& muonConstants) const {
99  int result(0);
100  auto const& it = (muonConstants.find(key));
101  if (it != end(muonConstants))
102  result = it->second;
103  return result;
104 }
personalPlayback.level
level
Definition: personalPlayback.py:22
cms::CSCNumberingScheme::CSCNumberingScheme
CSCNumberingScheme(const MuonConstants &muonConstants)
Definition: DD4hep_CSCNumberingScheme.cc:21
cms::CSCNumberingScheme::baseNumberToUnitNumber
void baseNumberToUnitNumber(const MuonBaseNumber &)
Definition: DD4hep_CSCNumberingScheme.cc:34
cms::CSCNumberingScheme::chamberIndex
int chamberIndex(int, int, int, int) const
Definition: DD4hep_CSCNumberingScheme.cc:78
cms::CSCNumberingScheme::initMe
void initMe(const MuonConstants &muonConstants)
Definition: DD4hep_CSCNumberingScheme.cc:23
cms::cuda::assert
assert(be >=bs)
cms::CSCNumberingScheme::theRegionLevel
int theRegionLevel
Definition: DD4hep_CSCNumberingScheme.h:33
CSCDetId::rawIdMaker
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:131
end
#define end
Definition: vmac.h:39
CSCDetId.h
DD4hep_CSCNumberingScheme.h
cms::CSCNumberingScheme::theStationLevel
int theStationLevel
Definition: DD4hep_CSCNumberingScheme.h:34
alignCSCRings.ring_id
string ring_id
Definition: alignCSCRings.py:79
cms::CSCNumberingScheme::setDetId
void setDetId(int idnew)
Definition: DD4hep_CSCNumberingScheme.h:29
cms::CSCNumberingScheme::theLayerLevel
int theLayerLevel
Definition: DD4hep_CSCNumberingScheme.h:37
MuonBaseNumber.h
cms::CSCNumberingScheme::theRingLevel
int theRingLevel
Definition: DD4hep_CSCNumberingScheme.h:38
cms::CSCNumberingScheme::theSubringLevel
int theSubringLevel
Definition: DD4hep_CSCNumberingScheme.h:35
cms::CSCNumberingScheme::theSectorLevel
int theSectorLevel
Definition: DD4hep_CSCNumberingScheme.h:36
DD4hep_MuonNumbering.h
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
MuonBaseNumber
Definition: MuonBaseNumber.h:21
mps_fire.result
result
Definition: mps_fire.py:303
crabWrapper.key
key
Definition: crabWrapper.py:19
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
cms::CSCNumberingScheme::get
const int get(const char *, const MuonConstants &) const
Definition: DD4hep_CSCNumberingScheme.cc:98
cms::MuonConstants
std::unordered_map< std::string_view, int > MuonConstants
Definition: DD4hep_MuonNumbering.h:35