CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes
BTLNumberingScheme Class Reference

#include <BTLNumberingScheme.h>

Inheritance diagram for BTLNumberingScheme:
MTDNumberingScheme

Public Member Functions

 BTLNumberingScheme ()
 
uint32_t getUnitID (const MTDBaseNumber &baseNumber) const override
 
 ~BTLNumberingScheme () override
 
- Public Member Functions inherited from MTDNumberingScheme
 MTDNumberingScheme ()
 
virtual ~MTDNumberingScheme ()
 

Static Public Attributes

static constexpr uint32_t kBTLcrystalLevel = 9
 
static constexpr uint32_t kBTLmoduleLevel = 8
 
static constexpr std::array< uint32_t, BTLDetId::kModulesPerRUV2negModCopy
 

Detailed Description

Definition at line 7 of file BTLNumberingScheme.h.

Constructor & Destructor Documentation

◆ BTLNumberingScheme()

BTLNumberingScheme::BTLNumberingScheme ( )

Definition at line 10 of file BTLNumberingScheme.cc.

References LogDebug.

10  : MTDNumberingScheme() {
11  LogDebug("MTDGeom") << "Creating BTLNumberingScheme";
12 }
#define LogDebug(id)

◆ ~BTLNumberingScheme()

BTLNumberingScheme::~BTLNumberingScheme ( )
override

Definition at line 14 of file BTLNumberingScheme.cc.

References LogDebug.

14 { LogDebug("MTDGeom") << "Deleting BTLNumberingScheme"; }
#define LogDebug(id)

Member Function Documentation

◆ getUnitID()

uint32_t BTLNumberingScheme::getUnitID ( const MTDBaseNumber baseNumber) const
overridevirtual

Implements MTDNumberingScheme.

Definition at line 16 of file BTLNumberingScheme.cc.

References BTLDetId::geographicalId(), MTDBaseNumber::getCopyNumber(), MTDBaseNumber::getLevelName(), MTDBaseNumber::getLevels(), BTLDetId::HALF_ROD, kBTLcrystalLevel, kBTLmoduleLevel, BTLDetId::kCrystalsPerModuleV2, BTLDetId::kModulesPerRUV2, BTLDetId::kRUPerTypeV2, LogDebug, negModCopy, DetId::rawId(), BTLDetId::v2, and ecaldqm::zside().

16  {
17  uint32_t intindex(0);
18  const uint32_t nLevels(baseNumber.getLevels());
19 
20  LogDebug("MTDGeom") << "BTLNumberingScheme geometry levels = " << nLevels;
21 
22  uint32_t zside(999), rodCopy(0), runitCopy(0), modCopy(0), modtyp(0), crystal(0);
23 
24  bool isDD4hepOK(false);
25  if (nLevels == kBTLcrystalLevel + 1) {
26  if (baseNumber.getLevelName(9) == "world_volume_1") {
27  isDD4hepOK = true;
28  }
29  }
30 
31  if (nLevels == kBTLcrystalLevel || isDD4hepOK) {
32  LogDebug("MTDGeom") << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
33  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
34  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
35  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7) << ", "
36  << baseNumber.getLevelName(8);
37 
38  // barphiflat scenario
39 
40  if (baseNumber.getLevelName(0).find("Timingactive") != std::string_view::npos) {
41  crystal = baseNumber.getCopyNumber(0);
42 
43  modCopy = baseNumber.getCopyNumber(2);
44  rodCopy = baseNumber.getCopyNumber(3);
45 
46  const std::string_view& modName(baseNumber.getLevelName(2)); // name of module volume
47  uint32_t pos = modName.find("Positive");
48 
49  zside = (pos <= modName.size() ? 1 : 0);
50  std::string_view baseName = modName.substr(modName.find(':') + 1);
51 
52  modtyp = ::atoi(&baseName.at(7));
53  if (modtyp == 17) {
54  modtyp = 2;
55  } else if (modtyp == 33) {
56  modtyp = 3;
57  }
58 
59  // error checking
60 
61  if (1 > crystal || 64 < crystal) {
62  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
63  << "****************** Bad crystal number = " << crystal
64  << ", Volume Number = " << baseNumber.getCopyNumber(0);
65  return 0;
66  }
67 
68  if (1 > modtyp || 3 < modtyp) {
69  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
70  << "****************** Bad module name = " << modName
71  << ", Volume Name = " << baseNumber.getLevelName(2);
72  return 0;
73  }
74 
75  if (1 > modCopy || 54 < modCopy) {
76  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
77  << "****************** Bad module copy = " << modCopy
78  << ", Volume Number = " << baseNumber.getCopyNumber(2);
79  return 0;
80  }
81 
82  if (1 > rodCopy || 36 < rodCopy) {
83  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
84  << "****************** Bad rod copy = " << rodCopy
85  << ", Volume Number = " << baseNumber.getCopyNumber(4);
86  return 0;
87  }
88 
89  if (1 < zside) {
90  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
91  << "****************** Bad side = " << zside
92  << ", Volume Name = " << baseNumber.getLevelName(2);
93  return 0;
94  }
95  } else if (baseNumber.getLevelName(0).find("BTLCrystal") != std::string_view::npos) {
96  // v2 scenario
97 
98  crystal = baseNumber.getCopyNumber(0);
99  modCopy = baseNumber.getCopyNumber(1);
100  runitCopy = baseNumber.getCopyNumber(2);
101  rodCopy = baseNumber.getCopyNumber(3);
102 
103  const std::string_view& rodName(baseNumber.getLevelName(3)); // name of module volume
104  uint32_t pos = rodName.find("Zpos");
105  zside = (pos <= rodName.size() ? 1 : 0);
106 
107  // for negative side swap module numbers betwee sides of the tray, so as to keep the same number for the same phi angle
108  // in the existing model. This introduces a misalignemtn between module number and volume copy for the negative side.
109  if (zside == 0) {
110  modCopy = negModCopy[modCopy - 1];
111  }
112 
113  modtyp = ::atoi(&baseNumber.getLevelName(2).back());
114 
115  // error checking
116 
117  if (1 > crystal || BTLDetId::kCrystalsPerModuleV2 < crystal) {
118  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
119  << "****************** Bad crystal number = " << crystal
120  << ", Volume Number = " << baseNumber.getCopyNumber(0);
121  return 0;
122  }
123 
124  if (1 > modtyp || 3 < modtyp) {
125  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
126  << "****************** Bad RU name, Volume Name = " << baseNumber.getLevelName(2);
127  return 0;
128  }
129 
130  if (1 > modCopy || BTLDetId::kModulesPerRUV2 < modCopy) {
131  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
132  << "****************** Bad module copy = " << modCopy
133  << ", Volume Number = " << baseNumber.getCopyNumber(1);
134  return 0;
135  }
136 
137  if (1 > runitCopy || BTLDetId::kRUPerTypeV2 < runitCopy) {
138  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
139  << "****************** Bad readout unit copy = " << runitCopy
140  << ", Volume Number = " << baseNumber.getCopyNumber(2);
141  return 0;
142  }
143 
144  if (1 > rodCopy || BTLDetId::HALF_ROD < rodCopy) {
145  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
146  << "****************** Bad rod copy = " << rodCopy
147  << ", Volume Number = " << baseNumber.getCopyNumber(3);
148  return 0;
149  }
150 
151  if (1 < zside) {
152  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
153  << "****************** Bad side = " << zside
154  << ", Volume Name = " << baseNumber.getLevelName(3);
155  return 0;
156  }
157  }
158 
159  // all inputs are fine. Go ahead and decode
160 
161  BTLDetId thisBTLdetid(zside, rodCopy, runitCopy, modCopy, modtyp, crystal);
162  intindex = thisBTLdetid.rawId();
163 
164  } else if (nLevels == kBTLmoduleLevel && baseNumber.getLevelName(0).find("BTLModule") != std::string_view::npos) {
165  // v2 scenario, geographicalId per module
166  // for tracking navigation geometry
167  LogDebug("MTDGeom") << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
168  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
169  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
170  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7);
171 
172  modCopy = baseNumber.getCopyNumber(0);
173  runitCopy = baseNumber.getCopyNumber(1);
174  rodCopy = baseNumber.getCopyNumber(2);
175 
176  const std::string_view& rodName(baseNumber.getLevelName(2)); // name of module volume
177  uint32_t pos = rodName.find("Zpos");
178  zside = (pos <= rodName.size() ? 1 : 0);
179 
180  // for negative side swap module numbers betwee sides of the tray, so as to keep the same number for the same phi angle
181  // in the existing model. This introduces a misalignemtn between module number and volume copy for the negative side.
182  if (zside == 0) {
183  modCopy = negModCopy[modCopy - 1];
184  }
185 
186  modtyp = ::atoi(&baseNumber.getLevelName(1).back());
187 
188  // error checking
189 
190  if (1 > modtyp || 3 < modtyp) {
191  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
192  << "****************** Bad RU name, Volume Name = " << baseNumber.getLevelName(1);
193  return 0;
194  }
195 
196  if (1 > modCopy || BTLDetId::kModulesPerRUV2 < modCopy) {
197  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
198  << "****************** Bad module copy = " << modCopy
199  << ", Volume Number = " << baseNumber.getCopyNumber(0);
200  return 0;
201  }
202 
203  if (1 > runitCopy || BTLDetId::kRUPerTypeV2 < runitCopy) {
204  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
205  << "****************** Bad readout unit copy = " << runitCopy
206  << ", Volume Number = " << baseNumber.getCopyNumber(1);
207  return 0;
208  }
209 
210  if (1 > rodCopy || BTLDetId::HALF_ROD < rodCopy) {
211  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
212  << "****************** Bad rod copy = " << rodCopy
213  << ", Volume Number = " << baseNumber.getCopyNumber(2);
214  return 0;
215  }
216 
217  if (1 < zside) {
218  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
219  << "****************** Bad side = " << zside
220  << ", Volume Name = " << baseNumber.getLevelName(2);
221  return 0;
222  }
223 
224  // all inputs are fine. Go ahead and decode
225 
226  BTLDetId thisBTLdetid(zside, rodCopy, runitCopy, modCopy, modtyp, 0);
227  intindex = thisBTLdetid.geographicalId(BTLDetId::CrysLayout::v2).rawId();
228 
229  } else {
230  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
231  << "Not enough levels found in MTDBaseNumber ( " << nLevels
232  << ") or not correct path. Returning 0";
233  return 0;
234  }
235 
236  LogDebug("MTDGeom") << "BTL Numbering scheme: "
237  << " zside = " << zside << " rod = " << rodCopy << " modtyp = " << modtyp << " RU = " << runitCopy
238  << " module = " << modCopy << " crystal = " << crystal << " Raw Id = " << intindex << "\n"
239  << BTLDetId(intindex);
240 
241  return intindex;
242 }
int getCopyNumber(int level) const
static constexpr std::array< uint32_t, BTLDetId::kModulesPerRUV2 > negModCopy
int getLevels() const
int zside(DetId const &)
std::string_view const & getLevelName(int level) const
static constexpr uint32_t HALF_ROD
range constants, need two sets for the time being (one for tiles and one for bars) ...
Definition: BTLDetId.h:31
static constexpr uint32_t kModulesPerRUV2
Definition: BTLDetId.h:35
static constexpr uint32_t kBTLcrystalLevel
static constexpr uint32_t kRUPerTypeV2
Definition: BTLDetId.h:34
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
static constexpr uint32_t kCrystalsPerModuleV2
Definition: BTLDetId.h:36
static constexpr uint32_t kBTLmoduleLevel
Log< level::Warning, false > LogWarning
#define LogDebug(id)

Member Data Documentation

◆ kBTLcrystalLevel

constexpr uint32_t BTLNumberingScheme::kBTLcrystalLevel = 9
static

Definition at line 9 of file BTLNumberingScheme.h.

Referenced by getUnitID().

◆ kBTLmoduleLevel

constexpr uint32_t BTLNumberingScheme::kBTLmoduleLevel = 8
static

Definition at line 10 of file BTLNumberingScheme.h.

Referenced by getUnitID().

◆ negModCopy

constexpr std::array<uint32_t, BTLDetId::kModulesPerRUV2> BTLNumberingScheme::negModCopy
static
Initial value:
{
{3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22}}

Definition at line 12 of file BTLNumberingScheme.h.

Referenced by getUnitID().