Skip to content

Commit a9eb3f0

Browse files
authored
Merge pull request #47115 from fabiocos/fc-tmpbtlrevert20250116
MTD geometry: temporarily revert the BTL numbering scheme update
2 parents 403d6b0 + f400f7c commit a9eb3f0

File tree

13 files changed

+216
-551
lines changed

13 files changed

+216
-551
lines changed

DataFormats/ForwardDetId/interface/BTLDetId.h

Lines changed: 41 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
#define DataFormats_BTLDetId_BTLDetId_h
33

44
#include "DataFormats/ForwardDetId/interface/MTDDetId.h"
5-
#include <iostream>
65
#include <ostream>
76
#include <array>
8-
#include <bitset>
97

108
/**
119
@class BTLDetId
@@ -16,59 +14,29 @@
1614
bit 9-8 : crystal type (1 - 3)
1715
bit 7-6 : readout unit sequential number within a type ( 1 - 2 )
1816
bit 5-0 : crystal sequential number within a module ( 0 - 15 )
19-
20-
// Geometry v3 new DetID (all type 1 modules)
21-
bit 15: kBTLNewFormat (0 - old BTLDetID, 1 - new BTLDetID)
22-
bit 12-10: Readout unit number ( 1 - 6 )
23-
bit 9-6 : Detector Module ( 1 - 12 )
24-
bit 5 : Sensor Module inside DM ( 0 - 1 )
25-
bit 4-0 : Crystal number in a SM ( 1 - 16 )
2617
*/
2718

2819
class BTLDetId : public MTDDetId {
2920
public:
30-
// old BTLDetID RU and module number scheme
31-
static constexpr uint32_t kBTLoldModuleOffset = 10;
32-
static constexpr uint32_t kBTLoldModuleMask = 0x3F;
33-
static constexpr uint32_t kBTLoldModTypeOffset = 8;
34-
static constexpr uint32_t kBTLoldModTypeMask = 0x3;
35-
static constexpr uint32_t kBTLoldRUOffset = 6;
36-
static constexpr uint32_t kBTLoldRUMask = 0x3;
37-
38-
// New BTLDetID
39-
static constexpr uint32_t kBTLRodOffset = 16;
40-
static constexpr uint32_t kBTLRodMask = 0x3F;
41-
static constexpr uint32_t kBTLRUOffset = 10;
42-
static constexpr uint32_t kBTLRUMask = 0x7;
43-
static constexpr uint32_t kBTLdetectorModOffset = 6;
44-
static constexpr uint32_t kBTLdetectorModMask = 0xF;
45-
static constexpr uint32_t kBTLsensorModOffset = 5;
46-
static constexpr uint32_t kBTLsensorModMask = 0x1;
21+
static constexpr uint32_t kBTLmoduleOffset = 10;
22+
static constexpr uint32_t kBTLmoduleMask = 0x3F;
23+
static constexpr uint32_t kBTLmodTypeOffset = 8;
24+
static constexpr uint32_t kBTLmodTypeMask = 0x3;
25+
static constexpr uint32_t kBTLRUOffset = 6;
26+
static constexpr uint32_t kBTLRUMask = 0x3;
4727
static constexpr uint32_t kBTLCrystalOffset = 0;
48-
static constexpr uint32_t kBTLCrystalMask = 0x1F;
28+
static constexpr uint32_t kBTLCrystalMask = 0x3F;
4929

5030
/// range constants, need two sets for the time being (one for tiles and one for bars)
5131
static constexpr uint32_t HALF_ROD = 36;
5232
static constexpr uint32_t kModulesPerRODBarPhiFlat = 48;
5333
static constexpr uint32_t kModulePerTypeBarPhiFlat = 48 / 3;
5434
static constexpr uint32_t kRUPerTypeV2 = 2;
55-
static constexpr uint32_t kRUPerRod = 6;
5635
static constexpr uint32_t kModulesPerRUV2 = 24;
57-
static constexpr uint32_t kDModulesPerRU = 12;
58-
static constexpr uint32_t kSModulesPerDM = 2;
59-
static constexpr uint32_t kDModulesInRUCol = 3;
60-
static constexpr uint32_t kDModulesInRURow = 4;
61-
static constexpr uint32_t kSModulesInDM = 2;
6236
static constexpr uint32_t kCrystalsPerModuleV2 = 16;
6337
static constexpr uint32_t kModulesPerTrkV2 = 3;
6438
static constexpr uint32_t kCrystalTypes = 3;
6539

66-
// conversion
67-
static constexpr uint32_t kBTLoldFieldMask = 0x3FFFFF;
68-
static constexpr uint32_t kBTLNewFormat = 1 << 15;
69-
70-
//
71-
7240
// Number of crystals in BTL according to TDR design, valid also for barphiflat scenario:
7341
// 16 crystals x 24 modules x 2 readout units/type x 3 types x 36 rods/side x 2 sides
7442
//
@@ -82,125 +50,67 @@ class BTLDetId : public MTDDetId {
8250
/** Construct a null id */
8351
BTLDetId() : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
8452
id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset;
85-
id_ |= kBTLNewFormat;
8653
}
8754

8855
/** Construct from a raw value */
89-
BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) {
90-
uint32_t tmpId = raw_id;
91-
if ((tmpId & kBTLNewFormat) == 0) {
92-
tmpId = newForm(tmpId);
93-
}
94-
id_ = MTDDetId(tmpId).rawId();
95-
}
56+
BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) { ; }
9657

9758
/** Construct from generic DetId */
98-
BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) {
99-
uint32_t tmpId = det_id.rawId();
100-
if ((tmpId & kBTLNewFormat) == 0) {
101-
tmpId = newForm(tmpId);
102-
}
103-
id_ = MTDDetId(tmpId).rawId();
104-
}
59+
BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) { ; }
10560

106-
/** Construct from complete geometry information, v2, v3 **/
107-
/** Geometry v1 is obsolete and not supported **/
108-
BTLDetId(uint32_t zside, uint32_t rod, uint32_t runit, uint32_t dmodule, uint32_t smodule, uint32_t crystal)
61+
/** Construct from complete geometry information, v1 **/
62+
BTLDetId(uint32_t zside, uint32_t rod, uint32_t module, uint32_t modtyp, uint32_t crystal)
10963
: MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
110-
//RU, DM, SM & Xtal numbers start from 0
11164
id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset |
112-
(rod & kRodRingMask) << kRodRingOffset | (runit & kBTLRUMask) << kBTLRUOffset |
113-
(dmodule & kBTLdetectorModMask) << kBTLdetectorModOffset |
114-
(smodule & kBTLsensorModMask) << kBTLsensorModOffset | (crystal & kBTLCrystalMask) << kBTLCrystalOffset;
115-
id_ |= kBTLNewFormat;
65+
(rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset |
66+
(modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | ((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset;
11667
}
11768

118-
// ---------- Common methods ----------
119-
120-
/** Returns BTL crystal number. */
121-
inline int crystal() const { return ((id_ >> kBTLCrystalOffset) & kBTLCrystalMask); }
122-
123-
/** Returns BTL crystal number in construction database. */
124-
inline int crystalConsDB() const {
125-
if (crystal() == kCrystalsPerModuleV2)
126-
return -1;
127-
if (smodule() == 0)
128-
return kCrystalsPerModuleV2 - 1 - crystal();
129-
else
130-
return crystal();
69+
/** Construct from complete geometry information, v2 **/
70+
BTLDetId(uint32_t zside, uint32_t rod, uint32_t runit, uint32_t module, uint32_t modtyp, uint32_t crystal)
71+
: MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
72+
id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset |
73+
(rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset |
74+
(modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | (runit & kBTLRUMask) << kBTLRUOffset |
75+
((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset;
13176
}
13277

133-
/** Returns BTL detector module number. */
134-
inline int dmodule() const { return ((id_ >> kBTLdetectorModOffset) & kBTLdetectorModMask); }
78+
// ---------- Common methods ----------
13579

136-
/** Returns BTL sensor module number. */
137-
inline int smodule() const { return ((id_ >> kBTLsensorModOffset) & kBTLsensorModMask); }
80+
/** Returns BTL module number. */
81+
inline int module() const { return (id_ >> kBTLmoduleOffset) & kBTLmoduleMask; }
13882

139-
/** Returns BTL module number [1-24] (OLD BTL NUMBERING). */
140-
inline int module() const {
141-
int mod = ((dmodule() % kDModulesInRURow) * (kSModulesInDM * kDModulesInRUCol) + int(dmodule() / kDModulesInRURow) +
142-
kDModulesInRUCol * smodule()) +
143-
1;
144-
return mod;
145-
}
83+
/** Returns BTL crystal type number. */
84+
inline int modType() const { return (id_ >> kBTLmodTypeOffset) & kBTLmodTypeMask; }
14685

147-
/** Returns BTL crystal type number [1-3] (OLD BTL NUMBERING). */
148-
inline int modType() const {
149-
int gRU = runit();
150-
return int(gRU / kRUPerTypeV2 + 1);
151-
}
86+
/** Returns BTL crystal number. */
87+
inline int crystal() const { return ((id_ >> kBTLCrystalOffset) & kBTLCrystalMask) + 1; }
15288

153-
/** Returns BTL readout unit number per type [1-2], from Global RU number [1-6]. */
154-
inline int runitByType() const { return (runit() % kRUPerTypeV2); }
89+
/** Returns BTL readout unit number per type. */
90+
inline int runit() const { return (id_ >> kBTLRUOffset) & kBTLRUMask; }
15591

15692
/** Returns BTL global readout unit number. */
157-
inline int runit() const { return ((id_ >> kBTLRUOffset) & kBTLRUMask); }
93+
inline int globalRunit() const {
94+
if (runit() == 0) {
95+
// pre-V2: build a RU identifier from available information
96+
return (module() - 1) / kModulePerTypeBarPhiFlat / kRUPerTypeV2 + 1;
97+
} else if (runit() > 0 && modType() > 0) {
98+
// V2/V3: build global RU identifier from RU per type and type
99+
return (modType() - 1) * kRUPerTypeV2 + runit();
100+
}
101+
return 0;
102+
}
158103

159104
/** return the row in GeomDet language **/
160105
inline int row(unsigned nrows = kCrystalsPerModuleV2) const {
161-
return crystal() % nrows; // anything else for now
106+
return (crystal() - 1) % nrows; // anything else for now
162107
}
163108

164109
/** return the column in GeomDetLanguage **/
165-
inline int column(unsigned nrows = kCrystalsPerModuleV2) const { return crystal() / nrows; }
110+
inline int column(unsigned nrows = kCrystalsPerModuleV2) const { return (crystal() - 1) / nrows; }
166111

167112
/** create a Geographical DetId for Tracking **/
168113
BTLDetId geographicalId(CrysLayout lay) const;
169-
170-
/** conversion from old to new BTLDetID**/
171-
uint32_t newForm(const uint32_t& rawid) {
172-
uint32_t fixedP = rawid & (0xFFFFFFFF - kBTLoldFieldMask); // unchanged part of id
173-
174-
// convert old tray number into new tray nymber
175-
uint32_t oldTray = (rawid >> kBTLRodOffset) & kBTLRodMask;
176-
uint32_t newTray = oldTray - 1;
177-
178-
// convert old module number into detector module + sensor module numbers
179-
uint32_t oldModule = (rawid >> kBTLoldModuleOffset) & kBTLoldModuleMask;
180-
uint32_t detModule = int((oldModule - 1) % (kDModulesInRUCol)) * kDModulesInRURow +
181-
int((oldModule - 1) / (kDModulesInRUCol * kSModulesInDM));
182-
uint32_t senModule = int((oldModule - 1) / kDModulesInRUCol) % kSModulesInDM;
183-
184-
// change detector module number if on the negative side
185-
int zside = int(mtdSide());
186-
if (zside < 1)
187-
detModule = detModule - 2 * kDModulesInRURow * (int(detModule / kDModulesInRURow) - 1);
188-
189-
// convert old RU and type number into new RU number
190-
uint32_t oldRU = (rawid >> kBTLoldRUOffset) & kBTLoldRUMask;
191-
uint32_t oldType = (rawid >> kBTLoldModTypeOffset) & kBTLoldModTypeMask;
192-
uint32_t newRU = ((oldType - 1) * kRUPerTypeV2) + (oldRU - 1);
193-
194-
// get crystal number
195-
uint32_t crystal = (rawid & kBTLCrystalMask) >> kBTLCrystalOffset;
196-
197-
// return new BTLDetID for v3 geom
198-
return (fixedP | (newTray & kBTLRodMask) << kBTLRodOffset | (newRU & kBTLRUMask) << kBTLRUOffset |
199-
(detModule & kBTLdetectorModMask) << kBTLdetectorModOffset |
200-
(senModule & kBTLsensorModMask) << kBTLsensorModOffset |
201-
((crystal & kBTLCrystalMask) << kBTLCrystalOffset)) |
202-
kBTLNewFormat;
203-
}
204114
};
205115

206116
std::ostream& operator<<(std::ostream&, const BTLDetId&);
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "DataFormats/ForwardDetId/interface/BTLDetId.h"
2-
#include "FWCore/MessageLogger/interface/MessageLogger.h"
32

43
BTLDetId BTLDetId::geographicalId(CrysLayout lay) const {
54
// For tracking geometry navigation
6-
// v2,v3: set number of crystals to 17 to distinguish from crystal BTLDetId
7-
// v1: obsolete and not supported
85

9-
if (lay == CrysLayout::v2 || lay == CrysLayout::v3) {
10-
return BTLDetId(mtdSide(), mtdRR(), runit(), dmodule(), smodule(), kCrystalsPerModuleV2);
11-
} else {
12-
edm::LogWarning("MTDGeom") << "CrysLayout could only be v2 or v3";
6+
if (lay == CrysLayout::barphiflat) {
7+
// barphiflat: count modules in a rod, combining all types
8+
return BTLDetId(mtdSide(), mtdRR(), module() + kModulePerTypeBarPhiFlat * (modType() - 1), 0, 1);
9+
} else if (lay == CrysLayout::v2 || lay == CrysLayout::v3) {
10+
// v2: set number of crystals to 17 to distinguish from crystal BTLDetId
11+
// v3: set number of crystals to 17 to distinguish from crystal BTLDetId, build V2-like type and RU number as in BTLNumberingScheme
12+
return BTLDetId(mtdSide(), mtdRR(), runit(), module(), modType(), kCrystalsPerModuleV2 + 1);
1313
}
1414

1515
return 0;
@@ -20,15 +20,12 @@ BTLDetId BTLDetId::geographicalId(CrysLayout lay) const {
2020
std::ostream& operator<<(std::ostream& os, const BTLDetId& id) {
2121
os << (MTDDetId&)id;
2222
os << " BTL " << std::endl
23-
<< " Side : " << id.mtdSide() << std::endl
24-
<< " Rod : " << id.mtdRR() << std::endl
25-
<< " Crystal type : " << id.modType() << std::endl // crystal type in v1 geometry scheme
26-
<< " Runit by Type : " << id.runitByType() << std::endl
27-
<< " Readout unit : " << id.runit() << std::endl
28-
<< " Detector module: " << id.dmodule() << std::endl
29-
<< " Sensor module : " << id.smodule() << std::endl
30-
<< " Module : " << id.module() << std::endl
31-
<< " Crystal : " << id.crystal() << std::endl
32-
<< " Crystal in ConsDB: " << id.crystalConsDB() << std::endl;
23+
<< " Side : " << id.mtdSide() << std::endl
24+
<< " Rod : " << id.mtdRR() << std::endl
25+
<< " Crystal type: " << id.modType() << std::endl
26+
<< " Readout unit: " << id.runit() << std::endl
27+
<< " Global RU : " << id.globalRunit() << std::endl
28+
<< " Module : " << id.module() << std::endl
29+
<< " Crystal : " << id.crystal() << std::endl;
3330
return os;
3431
}

DataFormats/ForwardDetId/src/classes_def.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,8 @@
2323
<class name="MTDDetId" ClassVersion="3">
2424
<version ClassVersion="3" checksum="1210976889"/>
2525
</class>
26-
<class name="BTLDetId" ClassVersion="4">
27-
<version ClassVersion="4" checksum="1515591716"/>
26+
<class name="BTLDetId" ClassVersion="3">
2827
<version ClassVersion="3" checksum="1515591716"/>
29-
<ioread sourceClass = "BTLDetId" version="[-3]" targetClass="BTLDetId" source="" target="">
30-
<![CDATA[
31-
BTLDetId tmp(newObj->newForm(newObj->rawId()));
32-
*newObj=tmp;
33-
]]>
34-
</ioread>
3528
</class>
3629
<class name="ETLDetId" ClassVersion="4">
3730
<version ClassVersion="4" checksum="1644731879"/>

DataFormats/TrackReco/src/HitPattern.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace {
143143
MTDDetId mtdid(id);
144144
switch (mtdid.mtdSubDetector()) {
145145
case MTDDetId::BTL:
146-
layer = BTLDetId(id).runit();
146+
layer = BTLDetId(id).globalRunit();
147147
break;
148148
case MTDDetId::ETL:
149149
layer = ETLDetId(id).mtdRR();

Geometry/MTDCommonData/interface/BTLElectronicsMapping.h

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)