Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
In this package the `GeometricDet` tree of the `TrackerGeometry` object in the `TrackerDigiGeometryRecord` is created, the DetIds are assigned to the different components in the tree according to the schema which is defined in the xml description of trackerParameters.xml for the `TrackerGeometricDetESModule`, and the configuration of the `TrackerTopology` object is configured to be able to decode the DetIds using
the same schema.

The graph of the `GeometricDet` tree can be found in [this file](doc/GeometricDetBuilder.png)

## Available DetId Schemas
The predefined DetId schemas available in this package are:
* The Run 1 (aka _present_) detector DetId schema
* The Phase 1 detector DetId schema where the pixel detector is replaced by the upgraded one
* The Phase 2 upgrade detector DetId schema where both the strip and the pixel detectors are replaced by the upgraded ones - TDR-like
* The Phase 2 upgrade reordered detector DetId schema, where the strip detector is replaced by the upgraded one (TDR-like), as is the pixel detector. This differs from the full TDR-like Phase2 DetId schema to account for a re-ordering in the pixel endcaps.

In the table below the DetId levels which are in normal font represents _real_ hierarchy levels which are present 
also in the `GeometricDet` tree which is build in parallel to the DetId assignment. Those levels which are in _italic_ font are _fake_ levels and are not known by the GeometricDet tree.
When the name of the `TrackerTopology` method is written in _italic_, it means that its name does not reflect the actual attribute of the DetId which is returned. This is because, so far, the names of the methods are hardcoded and reflect the present Tracker detector. In addition two generic methods, `TrackerTopology::layer(id)` and `TrackerTopology::side(id)` can be used to determine the layer/disk number and the side of the endcap subdetectors.

### Run 1 Detector DetId schema
The Run 1 detector DetId schema profits of all the six available subdetectors (from 1 to 6) and it is defined as follows

* Subdetector 1 (`DetId::subDetId() == PixelSubdetector::PixelBarrel`): Pixel Barrel

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| _not used_ | 20 | 0x1F | 5 | | |
| Layer | 16 | 0xF | 4 | pxbLayer(id) or layer(id) | increasing r |
| Ladder | 8 | 0xFF | 8 | pxbLadder(id) | increasing phi |
| Module | 2 | 0x3F | 6 | pxbModule(id) | increasing z |
| _not used_ | 0 | 0x3 | 2 | | |

* Subdetector 2 (`DetId::subDetId() == PixelSubdetector::PixelEndcap`): Pixel Forward

| Name | start bit | hex mask | bit size | `TrackerToplogy` method | Notes |
|------|-----------|-----------|----|-----|-----|
| subdetector part | 23 | 0x3 | 2 | pxfSide(id) or side(id) | 1=FPIX- 2=FPIX+ |
| _not used_ | 20 | 0x7 | 3 | | |
| Disk | 16 | 0xF | 4 | pxfDisk(id) or layer(id) | increasing abs(z) |
| _Blade_ | 10 | 0x3F | 6 | pxfBlade(id) | increasing phi |
| Panel | 8 | 0x3 | 2 | pxfPanel(id) | 1=forward 2=backward |
| Module | 2 | 0x3F | 6 | pxfModule(id) | increasing r |
| _not used_ | 0 | 0x3 | 2 | | |

* Subdetector 3 (`DetId::subDetId() == StripSubdetector::TIB`): TIB

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| not used | 17 | 0xFF | 8 | | |
| Layer | 14 |0x7 | 3 | tibLayer(id) or layer(id) | increasing r |
| _subdetector part_ | 12 | 0x3 | 2 | tibSide(id) | 1=TIB- 2=TIB+ |
| _Layer side_ | 10 | 0x3 | 2 | tibOrder(id) | 1=internal 2=external |
| String | 4 | 0x3F | 6 | tibString(id) | increasing phi |
| Module | 2 | 0x3 | 2 | tibModule(id) | increasing abs(z) |
| Module type | 0 | 0x3 | 2 | tibStereo(id) or tibGlued(id) | 1=stereo, 2=rphi, 0=pair |

* Subdetector 4 (`DetId::subDetId() == StripSubdetector::TID`): TID

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| _not used_ | 15 | 0x3FF | 10 | | |
| subdetector part | 13 |0x3 | 2 | tidSide(id) or side(id) | 1=TID- 2=TID+ |
| Disk | 11 | 0x3 | 2 | tidWheel(id) or layer(id) | increasing abs(z) |
| Ring | 9 | 0x3 | 2 | tidRing(id) | increasing r |
| _Disk side_ | 7 | 0x3 | 2 | tidOrder(id) | 1=back 2=front |
| Module | 2 | 0x1F | 5 | tidModule(id) | increasing phi |
| Module type | 0 | 0x3 | 2 | tidStereo(id) or tidGlued(id) | 1=stereo, 2=rphi, 0=pair |

* Subdetector 5 (`DetId::subDetId() == StripSubdetector::TOB`): TOB 

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|----|
| _not used_ | 17 | 0xFF | 8 | | |
| Layer | 14 |0x7 | 3 | tobLayer(id) or layer(id) | increasing r |
| _subdetector part_ | 12 | 0x3 | 2 | tobSide(id) | 1=TIB- 2=TIB+ |
| Rod | 5 | 0x7F | 7 | tobRod(id) | increasing phi |
| Module | 2 | 0x7 | 3 | tobModule(id) | increasing abs(z) |
| Module type | 0 | 0x3 | 2 | tobStereo(id) or tobGlued(id) | 1=stereo, 2=rphi, 0=pair |

* Subdetector 6 (`DetId::subDetId() == StripSubdetector::TEC`): TEC

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|----|
| _not used_ | 20 | 0x3F | 5 | | |
| subdetector part | 18 |0x3 | 2 | tecSide(id) or side(id) | 1=TEC- 2=TEC+ |
| Wheel | 14 | 0xF | 4 | tecWheel(id) or layer(id) | increasing abs(z) |
| _Wheel side_ | 12 | 0x3 | 2 | tecOrder(id) | 1=back 2=front |
| Petal | 8 | 0xF | 4 | tecPetal(id) | increasing phi |
| Ring | 5 | 0x7 | 3 | tecRing(id) | increasing r |
| Module | 2 | 0x7 | 3 | tecModule(id) | increasing phi |
| Module type | 0 | 0x3 | 2 | tecStereo(id) or tecGlued(id) | 1=stereo, 2=rphi, 0=pair |

A more detailed description of the SiStrip Tracker DetId schema can be found in this CMS Internal Note: [http://cms.cern.ch/iCMS/jsp/openfile.jsp?type=IN&year=2007&files=IN2007_020.pdf]

The configuration names for this detid schema are `trackerNumberingGeometry_cfi` (to run on geometry built from xml files) or `trackerNumberingGeometryDB_cfi` (to run on geometry from DB) for `TrackerGeometricDetESModule` and `trackerTopologyConstants_cfi` for `TrackerTopology`
The xml description of tracker parameters for this detid schema is in [Geometry/TrackerCommonData/data/trackerParameters.xml](../TrackerCommonData/data/trackerParameters.xml)

### Phase 1 Upgrade Detector DetId schema
The phase 1 detector DetId schema differs from that of the Run 1 detector only in the first two subdetectors which
corresponds to the Pixel Barrel and Forward detector. Therefore only them will be repeated here:

* Subdetector 1 (`DetId::subDetId() == PixelSubdetector::PixelBarrel`): Phase1 Pixel Barrel

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| _not used_ | 24 | 0x1 | 1 | | |
| Layer | 20 | 0xF | 4 | pxbLayer(id) or layer(id) | increasing r |
| Ladder | 12 | 0xFF | 8 | pxbLadder(id) | increasing phi |
| Module | 2 | 0x3FF | 10 | pxbModule(id) | increasing z |
| _not used_ | 0 | 0x3 | 2 | | |

* Subdetector 2 (`DetId::subDetId() == PixelSubdetector::PixelEndcap`): Phase1 Pixel Forward

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|----|-----|-----|
| subdetector part | 23 | 0x3 | 2 | pxfSide(id) or side(id) | 1=FPIX- 2=FPIX+ |
| _not used_ | 22 | 0x1 | 1 | | |
| Disk | 18 | 0xF | 4 | pxfDisk(id) or layer(id) | increasing abs(z) |
| _Blade_ | 12 | 0x3F | 6 | pxfBlade(id) | increasing phi and r: first inner ring blades and the outer ring blades |
| Panel | 10 | 0x3 | 2 | pxfPanel(id) | 1=forward 2=backward |
| Module | 2 | 0xFF | 8 | pxfModule(id) | always = 1 |
| _not used_ | 0 | 0x3 | 2 | | |

Subdetectors 3 to 6 are as for the Run 1 detector since the SiStrip Tracker is the same in phase1.

The configuration names for this detid schema are `trackerNumberingGeometry_cfi` (to run on geometry built from xml files) or `trackerNumberingGeometryDB_cfi` (to run on geometry from DB) for `TrackerGeometricDetESModule` and `trackerTopology2017Constants_cfi` for `TrackerTopology`
The xml description of tracker parameters for this detid schema is in [Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml](../TrackerCommonData/data/PhaseI/trackerParameters.xml)

### Phase 2 Upgrade Detector DetId schema Flat or Tilted Geometry with new pixel detector for TDR (from Version V4021)
The phase 2 detector DetId schema for the pixel has been re-designed in order to have the correct hierarchy endcap-->disk-->ring-->module 
while the outer tracker, use, as in previous case, subdetector 5, for the barrel, and subdetector 4, for the endcap. In some cases the name of the `TrackerTopology` methods is not so meaningful. In particular, for the Outer Tracker, the methods DoubleSided is not implemented, firstly because there is no need, secondly because it is not possible, just looking at the DetId and without something hardcoded, to understand if the module is single or double. This is also valid for Run I and Phase I.
The OT tilted option has been introduced in the subdetector 5 with two bits (in the table referred with _subdetector part_ ) that correspond to the rings in the negative and positive part and the central barrel part. The order is thus changed respectevely for the three different subparts: ladders by increasing phi and rings by increasing |z|, same consistency for the modules order.

With this subdetector, the flat geometry is compatible using just the central barrel part of the subdetector 5.
 
* Subdetector 1: (`DetId::subDetId() == PixelSubdetector::PixelBarrel`): Phase2 Pixel Barrel

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| _not used_ | 24 | 0x1 | 1 | | |
| Layer | 20 | 0xF | 4 | pxbLayer(id) or layer(id) | increasing r |
| Ladder | 12 | 0xFF | 8 | pxbLadder(id) | increasing phi |
| Module | 2 | 0x3FF | 10 | pxbModule(id) | increasing z |
| _not used_ | 0 | 0x3 | 2 | | |

* Subdetector 2: (`DetId::subDetId() == PixelSubdetector::PixelEndcap`): Phase2 Pixel Forward

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|----|-----|-----|
| subdetector part | 23 | 0x3 | 2 | pxfSide(id) or side(id) | 1=FPIX- 2=FPIX+ |
| _not used_ | 22 | 0x1 | 1 | | |
| Disk | 18 | 0xF | 4 | pxfDisk(id) or layer(id) | increasing abs(z) |
| _Ring_ | 12 | 0x3F | 6 | pxfBlade(id) | increasing r |
| Panel | 10 | 0x3 | 2 | pxfPanel(id) | always 1 |
| Module | 2 | 0xFF | 8 | pxfModule(id) | increasing phi |
| _not used_ | 0 | 0x3 | 2 | | |

* Subdetector 5  (`DetId::subDetId() == StripSubdetector::TOB`): Phase2 Outer Tracker Barrel

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| _not used_ | 24 | 0x1 | 1 | | |
| Layer | 20 | 0xF | 4 | tobLayer(id) or layer(id) | increasing r |
| _subdetector part_ | 18| 0x3 | 2 | tobSide(id) | 1=rings- 2=rings+ 3=barrel0|
| Ladder | 10 | 0xFF | 8 | tobRod(id) | increasing abs(z) (rings) or phi(barrel) |
| Module | 2 | 0xFF | 8 | tobModule(id) | increasing phi (rings) or z(barrel) |
| Module type | 0 | 0x3 | 2 | tobLower(id) or tobUpper(id) | 1=lower in local s.o.r.(P sensor into PS), 2=upper in local s.o.r.(S sensor into PS), 0=pair |
* Subdetector 4  (`DetId::subDetId() == StripSubdetector::TID`): Phase2 Outer Tracker Endcap

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|----|-----|----|
| subdetector part | 23 | 0x3 | 2 | tidSide(id) or side(id) | 1=-ve 2=+ve |
| _not used_ | 22 | 0x1 | 1 | | |
| Disk | 18 | 0xF | 4 | tidDisk(id) or side(id) | increasing abs(z) |
| _Ring_ | 12 | 0x3F | 6 | tidRing(id) | increasing r |
| Panel | 10 | 0x3 | 2 | _tidOrder(id)_ | always = 1 |
| Module | 2 | 0xFF | 8 | tidModule(id) | increasing phi |
| Module type | 0 | 0x3 | 2 | tidLower(id) or tidUpper(id) | 1=lower in local s.o.r.(P sensor into PS), 2=upper in local s.o.r.(S sensor into PS), 0=pair |

The configuration names for this detid schema are `trackerNumberingGeometry_cfi` (to run on geometry built from xml files) or `trackerNumberingGeometryDB_cfi` (to run on geometry from DB) for `TrackerGeometricDetESModule` and `trackerTopology2023Constants_cfi` for `TrackerTopology`
The xml description of tracker parameters for this detid schema is in [Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml](../TrackerCommonData/data/PhaseII/trackerParameters.xml

### Phase 2 Upgrade Detector DetId schema modified to account for the re-ordering of the pixel 
Only the subdetector 2 schema is different wrt the original Phase 2 upgrade DetIdSchema
 
* Subdetector 2: (`DetId::subDetId() == PixelSubdetector::PixelEndcap`): Phase2 Pixel Forward

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|----|-----|-----|
| subdetector part | 23 | 0x3 | 2 | pxfSide(id) or side(id) | 1=FPIX- 2=FPIX+ |
| DoubleDisk | 19 | 0xF | 4 |pxfDisk(id) or layer(id) | increasing abs(z) |
| _SubDisk_ | 18 | 0x1 | 1 | | increasing abs(z) |
| _SingleRing_ | 12 | 0x3F | 6 | pxfBlade(id) | increasing r |
| Panel | 10 | 0x3 | 2 | pxfPanel(id) | always 1 |
| Module | 2 | 0xFF | 8 | pxfModule(id) | increasing phi |
| _not used_ | 0 | 0x3 | 2 | | |

The configuration names for this detid schema are `trackerNumberingGeometry_cfi` (to run on geometry built from xml files) or `trackerNumberingGeometryDB_cfi` (to run on geometry from DB) for `TrackerGeometricDetESModule` and `trackerTopology2023Constants_cfi` for `TrackerTopology`
The xml description of tracker parameters for this detid schema is in [Geometry/TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml](../TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml

### Phase 2 Upgrade Detector DetId schema modified to account for the re-ordering of the pixel + L1 split sensor 

From CMSSW_14_1_X on [Geometry/TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml](../TrackerCommonData/data/PhaseII/TFPXTEPXReordered/trackerParameters.xml) has been updated to reflect a single geometry merging the splitted sensors detID numbering and the detID rearrangement described above. 

* Subdetector 1: (`DetId::subDetId() == PixelSubdetector::PixelBarrel`): Phase2 Pixel Barrel

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|-----|----|-----|
| _not used_ | 24 | 0x1 | 1 | | |
| Layer | 20 | 0xF | 4 | pxbLayer(id) or layer(id) | increasing r |
| Ladder | 12 | 0xFF | 8 | pxbLadder(id) | increasing phi |
| Module | 2 | 0x3FF | 10 | pxbModule(id) | increasing z |
| Sensor | 0 | 0x3 | 2 |pxbSensor(id) | |

* Subdetector 2: (`DetId::subDetId() == PixelSubdetector::PixelEndcap`): Phase2 Pixel Forward

| Name | start bit | hex mask | bit size | `TrackerTopology` method | Notes |
|------|-----------|-----------|----|-----|-----|
| subdetector part | 23 | 0x3 | 2 | pxfSide(id) or side(id) | 1=FPIX- 2=FPIX+ |
| DoubleDisk | 19 | 0xF | 4 |pxfDisk(id) or layer(id) | increasing abs(z) |
| _SubDisk_ | 18 | 0x1 | 1 | | increasing abs(z) |
| _SingleRing_ | 12 | 0x3F | 6 | pxfBlade(id) | increasing r |
| Panel | 10 | 0x3 | 2 | pxfPanel(id) | always 1 |
| Module | 2 | 0xFF | 8 | pxfModule(id) | increasing phi |
| _not used_ | 0 | 0x3 | 2 | | |

### Subdetector `GeometricDet` Enumerators

The link between the subdetectors described in the geometry and the `DetId::subDetId()` is created by the `GeometricDet::GDEnumType` enumerators. Each subdetector name in the Tracker DDD is associated to a `GeometricDet::GDEnumType` enumerator which has to be of the form n*100+m where m is between 1 and 6 and it will correspond to the `DetId::subDetId()` value. The present link table is:

| Tk DDD name | `GeometricDet::GDEnumType` | `DetId::subDetId()` |
|-------------|------------------------|---------------------|
| PixelBarrel | `PixelBarrel`=1 | 1=`PixelSubdetector::PixelBarrel` |
| PixelEndcapSubDet | `PixelEndCap`=2 | 2=`PixelSubdetector::PixelEndcap` |
| TIB | `TIB`=3 | 3=`StripSubdetector::TIB` |
| TID | `TID`=4 | 4=`StripSubdetector::TID` |
| TOB | `TOB`=5 | 5=`StripSubdetector::TOB` |
| TEC | `TEC`=6 | 6=`StripSubdetector::TEC` |
| PixelPhase1Barrel | `PixelPhase1Barrel`=101 | 1=`PixelSubdetector::PixelBarrel` |
| PixelPhase1EndcapSubDet | `PixelPhase1EndCap`=102 | 2=`PixelSubdetector::PixelEndcap` |
| PixelPhase2Barrel | `PixelPhase2Barrel`=201 | 1=`PixelSubdetector::PixelBarrel` |
| PixelPhase2EndcapSubDet | `PixelPhase2EndCap`=202 | 2=`PixelSubdetector::PixelEndcap` |
| Phase2OTBarrel | `OTPhase2Barrel`=205 | 5=`StripSubdetector::TOB` |
| Phase2OTEndcap | `OTPhase2EndCap`=204 | 4=`StripSubdetector::TID` |