Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTD geometry: temporarily revert the BTL numbering scheme update #47115

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 41 additions & 131 deletions DataFormats/ForwardDetId/interface/BTLDetId.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
#define DataFormats_BTLDetId_BTLDetId_h

#include "DataFormats/ForwardDetId/interface/MTDDetId.h"
#include <iostream>
#include <ostream>
#include <array>
#include <bitset>

/**
@class BTLDetId
Expand All @@ -16,59 +14,29 @@
bit 9-8 : crystal type (1 - 3)
bit 7-6 : readout unit sequential number within a type ( 1 - 2 )
bit 5-0 : crystal sequential number within a module ( 0 - 15 )

// Geometry v3 new DetID (all type 1 modules)
bit 15: kBTLNewFormat (0 - old BTLDetID, 1 - new BTLDetID)
bit 12-10: Readout unit number ( 1 - 6 )
bit 9-6 : Detector Module ( 1 - 12 )
bit 5 : Sensor Module inside DM ( 0 - 1 )
bit 4-0 : Crystal number in a SM ( 1 - 16 )
*/

class BTLDetId : public MTDDetId {
public:
// old BTLDetID RU and module number scheme
static constexpr uint32_t kBTLoldModuleOffset = 10;
static constexpr uint32_t kBTLoldModuleMask = 0x3F;
static constexpr uint32_t kBTLoldModTypeOffset = 8;
static constexpr uint32_t kBTLoldModTypeMask = 0x3;
static constexpr uint32_t kBTLoldRUOffset = 6;
static constexpr uint32_t kBTLoldRUMask = 0x3;

// New BTLDetID
static constexpr uint32_t kBTLRodOffset = 16;
static constexpr uint32_t kBTLRodMask = 0x3F;
static constexpr uint32_t kBTLRUOffset = 10;
static constexpr uint32_t kBTLRUMask = 0x7;
static constexpr uint32_t kBTLdetectorModOffset = 6;
static constexpr uint32_t kBTLdetectorModMask = 0xF;
static constexpr uint32_t kBTLsensorModOffset = 5;
static constexpr uint32_t kBTLsensorModMask = 0x1;
static constexpr uint32_t kBTLmoduleOffset = 10;
static constexpr uint32_t kBTLmoduleMask = 0x3F;
static constexpr uint32_t kBTLmodTypeOffset = 8;
static constexpr uint32_t kBTLmodTypeMask = 0x3;
static constexpr uint32_t kBTLRUOffset = 6;
static constexpr uint32_t kBTLRUMask = 0x3;
static constexpr uint32_t kBTLCrystalOffset = 0;
static constexpr uint32_t kBTLCrystalMask = 0x1F;
static constexpr uint32_t kBTLCrystalMask = 0x3F;

/// range constants, need two sets for the time being (one for tiles and one for bars)
static constexpr uint32_t HALF_ROD = 36;
static constexpr uint32_t kModulesPerRODBarPhiFlat = 48;
static constexpr uint32_t kModulePerTypeBarPhiFlat = 48 / 3;
static constexpr uint32_t kRUPerTypeV2 = 2;
static constexpr uint32_t kRUPerRod = 6;
static constexpr uint32_t kModulesPerRUV2 = 24;
static constexpr uint32_t kDModulesPerRU = 12;
static constexpr uint32_t kSModulesPerDM = 2;
static constexpr uint32_t kDModulesInRUCol = 3;
static constexpr uint32_t kDModulesInRURow = 4;
static constexpr uint32_t kSModulesInDM = 2;
static constexpr uint32_t kCrystalsPerModuleV2 = 16;
static constexpr uint32_t kModulesPerTrkV2 = 3;
static constexpr uint32_t kCrystalTypes = 3;

// conversion
static constexpr uint32_t kBTLoldFieldMask = 0x3FFFFF;
static constexpr uint32_t kBTLNewFormat = 1 << 15;

//

// Number of crystals in BTL according to TDR design, valid also for barphiflat scenario:
// 16 crystals x 24 modules x 2 readout units/type x 3 types x 36 rods/side x 2 sides
//
Expand All @@ -82,125 +50,67 @@ class BTLDetId : public MTDDetId {
/** Construct a null id */
BTLDetId() : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset;
id_ |= kBTLNewFormat;
}

/** Construct from a raw value */
BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) {
uint32_t tmpId = raw_id;
if ((tmpId & kBTLNewFormat) == 0) {
tmpId = newForm(tmpId);
}
id_ = MTDDetId(tmpId).rawId();
}
BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) { ; }

/** Construct from generic DetId */
BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) {
uint32_t tmpId = det_id.rawId();
if ((tmpId & kBTLNewFormat) == 0) {
tmpId = newForm(tmpId);
}
id_ = MTDDetId(tmpId).rawId();
}
BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) { ; }

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

// ---------- Common methods ----------

/** Returns BTL crystal number. */
inline int crystal() const { return ((id_ >> kBTLCrystalOffset) & kBTLCrystalMask); }

/** Returns BTL crystal number in construction database. */
inline int crystalConsDB() const {
if (crystal() == kCrystalsPerModuleV2)
return -1;
if (smodule() == 0)
return kCrystalsPerModuleV2 - 1 - crystal();
else
return crystal();
/** Construct from complete geometry information, v2 **/
BTLDetId(uint32_t zside, uint32_t rod, uint32_t runit, uint32_t module, uint32_t modtyp, uint32_t crystal)
: MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset |
(rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset |
(modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | (runit & kBTLRUMask) << kBTLRUOffset |
((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset;
}

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

/** Returns BTL sensor module number. */
inline int smodule() const { return ((id_ >> kBTLsensorModOffset) & kBTLsensorModMask); }
/** Returns BTL module number. */
inline int module() const { return (id_ >> kBTLmoduleOffset) & kBTLmoduleMask; }

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

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

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

/** Returns BTL global readout unit number. */
inline int runit() const { return ((id_ >> kBTLRUOffset) & kBTLRUMask); }
inline int globalRunit() const {
if (runit() == 0) {
// pre-V2: build a RU identifier from available information
return (module() - 1) / kModulePerTypeBarPhiFlat / kRUPerTypeV2 + 1;
} else if (runit() > 0 && modType() > 0) {
// V2/V3: build global RU identifier from RU per type and type
return (modType() - 1) * kRUPerTypeV2 + runit();
}
return 0;
}

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

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

/** create a Geographical DetId for Tracking **/
BTLDetId geographicalId(CrysLayout lay) const;

/** conversion from old to new BTLDetID**/
uint32_t newForm(const uint32_t& rawid) {
uint32_t fixedP = rawid & (0xFFFFFFFF - kBTLoldFieldMask); // unchanged part of id

// convert old tray number into new tray nymber
uint32_t oldTray = (rawid >> kBTLRodOffset) & kBTLRodMask;
uint32_t newTray = oldTray - 1;

// convert old module number into detector module + sensor module numbers
uint32_t oldModule = (rawid >> kBTLoldModuleOffset) & kBTLoldModuleMask;
uint32_t detModule = int((oldModule - 1) % (kDModulesInRUCol)) * kDModulesInRURow +
int((oldModule - 1) / (kDModulesInRUCol * kSModulesInDM));
uint32_t senModule = int((oldModule - 1) / kDModulesInRUCol) % kSModulesInDM;

// change detector module number if on the negative side
int zside = int(mtdSide());
if (zside < 1)
detModule = detModule - 2 * kDModulesInRURow * (int(detModule / kDModulesInRURow) - 1);

// convert old RU and type number into new RU number
uint32_t oldRU = (rawid >> kBTLoldRUOffset) & kBTLoldRUMask;
uint32_t oldType = (rawid >> kBTLoldModTypeOffset) & kBTLoldModTypeMask;
uint32_t newRU = ((oldType - 1) * kRUPerTypeV2) + (oldRU - 1);

// get crystal number
uint32_t crystal = (rawid & kBTLCrystalMask) >> kBTLCrystalOffset;

// return new BTLDetID for v3 geom
return (fixedP | (newTray & kBTLRodMask) << kBTLRodOffset | (newRU & kBTLRUMask) << kBTLRUOffset |
(detModule & kBTLdetectorModMask) << kBTLdetectorModOffset |
(senModule & kBTLsensorModMask) << kBTLsensorModOffset |
((crystal & kBTLCrystalMask) << kBTLCrystalOffset)) |
kBTLNewFormat;
}
};

std::ostream& operator<<(std::ostream&, const BTLDetId&);
Expand Down
31 changes: 14 additions & 17 deletions DataFormats/ForwardDetId/src/BTLDetId.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "DataFormats/ForwardDetId/interface/BTLDetId.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

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

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

return 0;
Expand All @@ -20,15 +20,12 @@ BTLDetId BTLDetId::geographicalId(CrysLayout lay) const {
std::ostream& operator<<(std::ostream& os, const BTLDetId& id) {
os << (MTDDetId&)id;
os << " BTL " << std::endl
<< " Side : " << id.mtdSide() << std::endl
<< " Rod : " << id.mtdRR() << std::endl
<< " Crystal type : " << id.modType() << std::endl // crystal type in v1 geometry scheme
<< " Runit by Type : " << id.runitByType() << std::endl
<< " Readout unit : " << id.runit() << std::endl
<< " Detector module: " << id.dmodule() << std::endl
<< " Sensor module : " << id.smodule() << std::endl
<< " Module : " << id.module() << std::endl
<< " Crystal : " << id.crystal() << std::endl
<< " Crystal in ConsDB: " << id.crystalConsDB() << std::endl;
<< " Side : " << id.mtdSide() << std::endl
<< " Rod : " << id.mtdRR() << std::endl
<< " Crystal type: " << id.modType() << std::endl
<< " Readout unit: " << id.runit() << std::endl
<< " Global RU : " << id.globalRunit() << std::endl
<< " Module : " << id.module() << std::endl
<< " Crystal : " << id.crystal() << std::endl;
return os;
}
9 changes: 1 addition & 8 deletions DataFormats/ForwardDetId/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@
<class name="MTDDetId" ClassVersion="3">
<version ClassVersion="3" checksum="1210976889"/>
</class>
<class name="BTLDetId" ClassVersion="4">
<version ClassVersion="4" checksum="1515591716"/>
<class name="BTLDetId" ClassVersion="3">
<version ClassVersion="3" checksum="1515591716"/>
<ioread sourceClass = "BTLDetId" version="[-3]" targetClass="BTLDetId" source="" target="">
<![CDATA[
BTLDetId tmp(newObj->newForm(newObj->rawId()));
*newObj=tmp;
]]>
</ioread>
</class>
<class name="ETLDetId" ClassVersion="4">
<version ClassVersion="4" checksum="1644731879"/>
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/TrackReco/src/HitPattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace {
MTDDetId mtdid(id);
switch (mtdid.mtdSubDetector()) {
case MTDDetId::BTL:
layer = BTLDetId(id).runit();
layer = BTLDetId(id).globalRunit();
break;
case MTDDetId::ETL:
layer = ETLDetId(id).mtdRR();
Expand Down
80 changes: 0 additions & 80 deletions Geometry/MTDCommonData/interface/BTLElectronicsMapping.h

This file was deleted.

Loading