Skip to content

Commit ab76956

Browse files
authored
Merge pull request #46911 from fabiocos/fc-mtdtopo20241202
MTD geometry: add BTL topology to MTDTopology, reorganize dependencies
2 parents c8d5f21 + 4193a38 commit ab76956

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+458
-261
lines changed

Geometry/MTDGeometryBuilder/interface/MTDGeomBuilderFromGeometricTimingDet.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
#include "Geometry/CommonDetUnit/interface/GeomDetType.h"
1010

1111
class MTDGeometry;
12-
class MTDTopology;
1312
class MTDGeomDetType;
1413
class PMTDParameters;
1514

1615
class MTDGeomBuilderFromGeometricTimingDet {
1716
public:
18-
MTDGeometry* build(const GeometricTimingDet* gd, const PMTDParameters& ptp, const MTDTopology* tTopo);
17+
MTDGeometry* build(const GeometricTimingDet* gd, const PMTDParameters& ptp);
1918

2019
private:
2120
void buildPixel(std::vector<const GeometricTimingDet*> const&,
@@ -28,7 +27,6 @@ class MTDGeomBuilderFromGeometricTimingDet {
2827
double scaleFactor = 1.) const;
2928

3029
std::map<std::string, const MTDGeomDetType*> theMTDDetTypeMap;
31-
const MTDTopology* theTopo;
3230
};
3331

3432
#endif

Geometry/MTDGeometryBuilder/interface/MTDGeomUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
1313
#include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h"
1414
#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h"
15-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
15+
#include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
1616

1717
namespace edm {
1818
class Event;

Geometry/MTDNumberingBuilder/interface/MTDTopology.h renamed to Geometry/MTDGeometryBuilder/interface/MTDTopology.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "DataFormats/DetId/interface/DetId.h"
55
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
6-
#include "DataFormats/ForwardDetId/interface/MTDDetId.h"
6+
#include "DataFormats/ForwardDetId/interface/BTLDetId.h"
77
#include "DataFormats/ForwardDetId/interface/ETLDetId.h"
88
#include <Geometry/CommonDetUnit/interface/GeomDet.h>
99

@@ -12,6 +12,20 @@
1212

1313
class MTDTopology {
1414
public:
15+
struct BTLLayout {
16+
// number of logical rods, i.e. rows of sensor modules along eta/z in phi, and of modules per rod
17+
static constexpr uint32_t nBTLphi_ = BTLDetId::HALF_ROD * BTLDetId::kModulesPerTrkV2;
18+
static constexpr uint32_t nBTLeta_ =
19+
2 * BTLDetId::kRUPerTypeV2 * BTLDetId::kCrystalTypes * BTLDetId::kModulesPerRUV2 / BTLDetId::kModulesPerTrkV2;
20+
static constexpr uint32_t nBTLmodules_ = nBTLphi_ * nBTLeta_;
21+
22+
std::array<uint32_t, nBTLmodules_> btlDetId_;
23+
std::array<uint32_t, nBTLmodules_> btlPhi_;
24+
std::array<uint32_t, nBTLmodules_> btlEta_;
25+
};
26+
27+
using BTLValues = BTLLayout;
28+
1529
struct ETLfaceLayout {
1630
uint32_t idDiscSide_; // disc face identifier
1731
uint32_t idDetType1_; // module type id identifier for first row
@@ -22,10 +36,24 @@ class MTDTopology {
2236

2337
using ETLValues = std::vector<ETLfaceLayout>;
2438

25-
MTDTopology(const int& topologyMode, const ETLValues& etl);
39+
MTDTopology(const int& topologyMode, const BTLValues& btl, const ETLValues& etl);
2640

2741
int getMTDTopologyMode() const { return mtdTopologyMode_; }
2842

43+
uint32_t btlRods() const { return btlVals_.nBTLphi_; }
44+
uint32_t btlModulesPerRod() const { return btlVals_.nBTLeta_; }
45+
uint32_t btlModules() const { return btlVals_.nBTLmodules_; }
46+
47+
// BTL topology navigation is based on a predefined order of dets in MTDGeometry, mapped onto phi/eta grid
48+
49+
std::pair<uint32_t, uint32_t> btlIndex(const uint32_t detId) const;
50+
uint32_t btlidFromIndex(const uint32_t iphi, const uint32_t ieta) const;
51+
52+
// BTL topology navigation methods, find index of closest module along eta or phi
53+
54+
uint32_t phishiftBTL(const uint32_t detid, const int phiShift) const;
55+
uint32_t etashiftBTL(const uint32_t detid, const int etaShift) const;
56+
2957
// ETL topology navigation is based on a predefined order of dets in sector
3058

3159
static bool orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2);
@@ -39,6 +67,8 @@ class MTDTopology {
3967
private:
4068
const int mtdTopologyMode_;
4169

70+
const BTLValues btlVals_;
71+
4272
const ETLValues etlVals_;
4373

4474
static constexpr size_t failIndex_ =

Geometry/MTDGeometryBuilder/plugins/MTDDigiGeometryESModule.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "Geometry/Records/interface/IdealGeometryRecord.h"
99
#include "Geometry/Records/interface/PMTDParametersRcd.h"
1010
#include "CondFormats/GeometryObjects/interface/PMTDParameters.h"
11-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
12-
#include "Geometry/Records/interface/MTDTopologyRcd.h"
1311

1412
// Alignments
1513
#include "CondFormats/Alignment/interface/Alignments.h"
@@ -45,7 +43,6 @@ class MTDDigiGeometryESModule : public edm::ESProducer {
4543
const std::string myLabel_;
4644

4745
edm::ESGetToken<GeometricTimingDet, IdealGeometryRecord> geomTimingDetToken_;
48-
edm::ESGetToken<MTDTopology, MTDTopologyRcd> mtdTopoToken_;
4946
edm::ESGetToken<PMTDParameters, PMTDParametersRcd> pmtdParamsToken_;
5047

5148
//alignment
@@ -69,7 +66,6 @@ MTDDigiGeometryESModule::MTDDigiGeometryESModule(const edm::ParameterSet& p)
6966
auto cc = setWhatProduced(this);
7067
const edm::ESInputTag kEmpty;
7168
geomTimingDetToken_ = cc.consumesFrom<GeometricTimingDet, IdealGeometryRecord>(kEmpty);
72-
mtdTopoToken_ = cc.consumesFrom<MTDTopology, MTDTopologyRcd>(kEmpty);
7369
pmtdParamsToken_ = cc.consumesFrom<PMTDParameters, PMTDParametersRcd>(kEmpty);
7470

7571
{
@@ -109,12 +105,10 @@ std::unique_ptr<MTDGeometry> MTDDigiGeometryESModule::produce(const MTDDigiGeome
109105
//
110106
GeometricTimingDet const& gD = iRecord.get(geomTimingDetToken_);
111107

112-
MTDTopology const& tTopo = iRecord.get(mtdTopoToken_);
113-
114108
PMTDParameters const& ptp = iRecord.get(pmtdParamsToken_);
115109

116110
MTDGeomBuilderFromGeometricTimingDet builder;
117-
std::unique_ptr<MTDGeometry> mtd(builder.build(&(gD), ptp, &tTopo));
111+
std::unique_ptr<MTDGeometry> mtd(builder.build(&(gD), ptp));
118112

119113
if (applyAlignment_) {
120114
// Since fake is fully working when checking for 'empty', we should get rid of applyAlignment_!

Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc renamed to Geometry/MTDGeometryBuilder/plugins/MTDTopologyEP.cc

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
#include "FWCore/Framework/interface/ModuleFactory.h"
77
#include "FWCore/Framework/interface/ESHandle.h"
88
#include "FWCore/Framework/interface/ESProducer.h"
9-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
9+
#include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
1010
#include "Geometry/MTDCommonData/interface/MTDTopologyMode.h"
1111
#include "Geometry/Records/interface/MTDTopologyRcd.h"
1212
#include "CondFormats/GeometryObjects/interface/PMTDParameters.h"
1313
#include "Geometry/Records/interface/PMTDParametersRcd.h"
14+
#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
15+
#include "Geometry/Records/interface/MTDDigiGeometryRecord.h"
1416

1517
#include <memory>
1618

@@ -25,13 +27,18 @@ class MTDTopologyEP : public edm::ESProducer {
2527
ReturnType produce(const MTDTopologyRcd&);
2628

2729
private:
28-
void fillParameters(const PMTDParameters&, int& mtdTopologyMode, MTDTopology::ETLValues&);
30+
void fillBTLtopology(const MTDGeometry&, MTDTopology::BTLValues&);
31+
void fillETLtopology(const PMTDParameters&, int& mtdTopologyMode, MTDTopology::ETLValues&);
2932

30-
const edm::ESGetToken<PMTDParameters, PMTDParametersRcd> token_;
33+
edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> mtdgeoToken_;
34+
edm::ESGetToken<PMTDParameters, PMTDParametersRcd> mtdparToken_;
3135
};
3236

33-
MTDTopologyEP::MTDTopologyEP(const edm::ParameterSet& conf)
34-
: token_{setWhatProduced(this).consumesFrom<PMTDParameters, PMTDParametersRcd>(edm::ESInputTag())} {}
37+
MTDTopologyEP::MTDTopologyEP(const edm::ParameterSet& conf) {
38+
auto cc = setWhatProduced(this);
39+
mtdgeoToken_ = cc.consumesFrom<MTDGeometry, MTDDigiGeometryRecord>(edm::ESInputTag());
40+
mtdparToken_ = cc.consumesFrom<PMTDParameters, PMTDParametersRcd>(edm::ESInputTag());
41+
}
3542

3643
void MTDTopologyEP::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
3744
edm::ParameterSetDescription ttc;
@@ -40,21 +47,47 @@ void MTDTopologyEP::fillDescriptions(edm::ConfigurationDescriptions& description
4047

4148
MTDTopologyEP::ReturnType MTDTopologyEP::produce(const MTDTopologyRcd& iRecord) {
4249
int mtdTopologyMode;
50+
MTDTopology::BTLValues btlVals;
4351
MTDTopology::ETLValues etlVals;
4452

45-
fillParameters(iRecord.get(token_), mtdTopologyMode, etlVals);
53+
// build BTL topology content from MTDGeometry
4654

47-
return std::make_unique<MTDTopology>(mtdTopologyMode, etlVals);
48-
}
55+
fillBTLtopology(iRecord.get(mtdgeoToken_), btlVals);
4956

50-
void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMode, MTDTopology::ETLValues& etlVals) {
51-
mtdTopologyMode = ptp.topologyMode_;
57+
// build ETL topology and topology mode information from PMTDParameters
5258

53-
// for legacy geometry scenarios no topology informastion is stored, only for newer ETL 2-discs layout
59+
fillETLtopology(iRecord.get(mtdparToken_), mtdTopologyMode, etlVals);
5460

55-
if (mtdTopologyMode <= static_cast<int>(MTDTopologyMode::Mode::barphiflat)) {
56-
return;
61+
return std::make_unique<MTDTopology>(mtdTopologyMode, btlVals, etlVals);
62+
}
63+
64+
void MTDTopologyEP::fillBTLtopology(const MTDGeometry& mtdgeo, MTDTopology::BTLValues& btlVals) {
65+
MTDTopology::BTLLayout tmpLayout;
66+
uint32_t index(0), iphi(1), ieta(0);
67+
if (mtdgeo.detsBTL().size() != tmpLayout.nBTLmodules_) {
68+
throw cms::Exception("MTDTopologyEP") << "Inconsistent size of BTL structure arrays";
5769
}
70+
for (const auto& det : mtdgeo.detsBTL()) {
71+
ieta++;
72+
73+
tmpLayout.btlDetId_[index] = det->geographicalId().rawId();
74+
tmpLayout.btlPhi_[index] = iphi;
75+
tmpLayout.btlEta_[index] = ieta;
76+
#ifdef EDM_ML_DEBUG
77+
edm::LogVerbatim("MTDTopologyEP") << "MTDTopology BTL# " << index << " id= " << det->geographicalId().rawId()
78+
<< " iphi/ieta= " << iphi << " / " << ieta;
79+
#endif
80+
if (ieta == tmpLayout.nBTLeta_) {
81+
iphi++;
82+
ieta = 0;
83+
}
84+
index++;
85+
}
86+
btlVals = tmpLayout;
87+
}
88+
89+
void MTDTopologyEP::fillETLtopology(const PMTDParameters& ptp, int& mtdTopologyMode, MTDTopology::ETLValues& etlVals) {
90+
mtdTopologyMode = ptp.topologyMode_;
5891

5992
// Check on the internal consistency of thr ETL layout information provided by parameters
6093

Geometry/MTDNumberingBuilder/src/ES_MTDTopology.cc renamed to Geometry/MTDGeometryBuilder/src/ES_MTDTopology.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
1+
#include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
22

33
#include "FWCore/Utilities/interface/typelookup.h"
44

Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "Geometry/MTDGeometryBuilder/interface/MTDGeomDetUnit.h"
66
#include "Geometry/MTDGeometryBuilder/interface/MTDPixelTopologyBuilder.h"
77
#include "DataFormats/DetId/interface/DetId.h"
8+
#include "DataFormats/ForwardDetId/interface/MTDDetId.h"
89
#include "CondFormats/GeometryObjects/interface/PMTDParameters.h"
9-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
1010
#include "DataFormats/GeometrySurface/interface/MediumProperties.h"
1111
#include "FWCore/MessageLogger/interface/MessageLogger.h"
1212
#include "FWCore/Utilities/interface/Exception.h"
@@ -33,18 +33,13 @@ namespace {
3333
}
3434
} // namespace
3535

36-
MTDGeometry* MTDGeomBuilderFromGeometricTimingDet::build(const GeometricTimingDet* gd,
37-
const PMTDParameters& ptp,
38-
const MTDTopology* tTopo) {
36+
MTDGeometry* MTDGeomBuilderFromGeometricTimingDet::build(const GeometricTimingDet* gd, const PMTDParameters& ptp) {
3937
theMTDDetTypeMap.clear();
4038

4139
MTDGeometry* tracker = new MTDGeometry(gd);
4240
std::vector<const GeometricTimingDet*> comp;
4341
gd->deepComponents(comp);
4442

45-
if (tTopo)
46-
theTopo = tTopo;
47-
4843
//define a vector which associate to the detid subdetector index -1 (from 0 to 5) the GeometridDet enumerator to be able to know which type of subdetector it is
4944

5045
std::vector<GeometricTimingDet::GTDEnumType> gdsubdetmap(

Geometry/MTDNumberingBuilder/src/MTDTopology.cc renamed to Geometry/MTDGeometryBuilder/src/MTDTopology.cc

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,101 @@
1-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
1+
#include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
22
#include "FWCore/MessageLogger/interface/MessageLogger.h"
33
#include "Geometry/MTDCommonData/interface/MTDTopologyMode.h"
44

5-
MTDTopology::MTDTopology(const int& topologyMode, const ETLValues& etl)
6-
: mtdTopologyMode_(topologyMode), etlVals_(etl) {}
5+
#include <utility>
6+
7+
MTDTopology::MTDTopology(const int& topologyMode, const BTLValues& btl, const ETLValues& etl)
8+
: mtdTopologyMode_(topologyMode), btlVals_(btl), etlVals_(etl) {}
9+
10+
std::pair<uint32_t, uint32_t> MTDTopology::btlIndex(const uint32_t detId) const {
11+
size_t index(0);
12+
bool found(false);
13+
for (const auto& theid : btlVals_.btlDetId_) {
14+
if (theid == detId) {
15+
found = true;
16+
break;
17+
}
18+
index++;
19+
}
20+
if (found) {
21+
return std::make_pair(btlVals_.btlPhi_[index], btlVals_.btlEta_[index]);
22+
} else {
23+
edm::LogWarning("MTDTopology") << "Searching BTL topology for BTLDetId " << detId
24+
<< " not in BTL geometry structure";
25+
return std::make_pair(std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max());
26+
}
27+
}
28+
29+
uint32_t MTDTopology::btlidFromIndex(const uint32_t iphi, const uint32_t ieta) const {
30+
uint32_t res(0);
31+
for (uint32_t index = 0; index < btlVals_.nBTLmodules_; index++) {
32+
if (iphi == btlVals_.btlPhi_[index] && ieta == btlVals_.btlEta_[index]) {
33+
res = btlVals_.btlDetId_[index];
34+
break;
35+
}
36+
}
37+
return res;
38+
}
39+
40+
uint32_t MTDTopology::phishiftBTL(const uint32_t detid, const int phiShift) const {
41+
if (phiShift == 0) {
42+
edm::LogWarning("MTDTopology") << "asking of a null phiShift in BTL";
43+
return failIndex_;
44+
}
45+
// search for the next detector, check only sign from input
46+
int sh = phiShift > 0 ? 1 : -1;
47+
size_t index(0);
48+
bool found(false);
49+
for (const auto& theid : btlVals_.btlDetId_) {
50+
if (theid == detid) {
51+
found = true;
52+
break;
53+
}
54+
index++;
55+
}
56+
if (found) {
57+
int newIndex = index + sh * btlVals_.nBTLeta_;
58+
if (newIndex >= static_cast<int>(btlVals_.nBTLmodules_)) {
59+
newIndex = newIndex - btlVals_.nBTLmodules_;
60+
} else if (newIndex < 0) {
61+
newIndex = newIndex + btlVals_.nBTLmodules_;
62+
}
63+
return newIndex;
64+
} else {
65+
edm::LogWarning("MTDTopology") << "Searching for non existent BTLDetId " << detid;
66+
return failIndex_;
67+
}
68+
}
69+
70+
uint32_t MTDTopology::etashiftBTL(const uint32_t detid, const int etaShift) const {
71+
if (etaShift == 0) {
72+
edm::LogWarning("MTDTopology") << "asking of a null etaShift in BTL";
73+
return failIndex_;
74+
}
75+
// search for the next detector, check only sign from input
76+
int sh = etaShift > 0 ? 1 : -1;
77+
size_t index(0);
78+
bool found(false);
79+
for (const auto& theid : btlVals_.btlDetId_) {
80+
if (theid == detid) {
81+
found = true;
82+
break;
83+
}
84+
index++;
85+
}
86+
if (found) {
87+
int newIndex = index + sh;
88+
if (newIndex < 0 || newIndex >= static_cast<int>(btlVals_.nBTLmodules_)) {
89+
return failIndex_;
90+
} else if (btlVals_.btlPhi_[newIndex] != btlVals_.btlPhi_[index]) {
91+
return failIndex_;
92+
}
93+
return newIndex;
94+
} else {
95+
edm::LogWarning("MTDTopology") << "Searching for non existent BTLDetId " << detid;
96+
return failIndex_;
97+
}
98+
}
799

8100
bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) {
9101
ETLDetId det1(gd1->geographicalId().rawId());

Geometry/MTDGeometryBuilder/test/DD4hep_TestPixelTopology.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
3434

3535
#include "Geometry/Records/interface/MTDTopologyRcd.h"
36-
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
36+
#include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
3737
#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
3838
#include "Geometry/MTDGeometryBuilder/interface/MTDGeomDetUnit.h"
3939
#include "Geometry/Records/interface/MTDDigiGeometryRecord.h"

0 commit comments

Comments
 (0)