Skip to content

Commit c32dd11

Browse files
committed
Add test for BTL topology navigation in parallel to tracking geometry
1 parent 24b649f commit c32dd11

File tree

6 files changed

+193
-13
lines changed

6 files changed

+193
-13
lines changed

Geometry/MTDGeometryBuilder/interface/MTDTopology.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class MTDTopology {
4242

4343
// BTL topology navigation is based on a predefined order of dets in MTDGeometry, mapped onto phi/eta grid
4444

45-
std::pair<uint32_t, uint32_t> btlIndex(const uint32_t detId);
46-
uint32_t btlidFromIndex(const uint32_t iphi, const uint32_t ieta);
45+
std::pair<uint32_t, uint32_t> btlIndex(const uint32_t detId) const;
46+
uint32_t btlidFromIndex(const uint32_t iphi, const uint32_t ieta) const;
4747

4848
// BTL topology navigation methods, find index of closest module along eta or phi
4949

50-
uint32_t phishiftBTL(const uint32_t detid, const int phiShift);
51-
uint32_t etashiftBTL(const uint32_t detid, const int etaShift);
50+
uint32_t phishiftBTL(const uint32_t detid, const int phiShift) const;
51+
uint32_t etashiftBTL(const uint32_t detid, const int etaShift) const;
5252

5353
// ETL topology navigation is based on a predefined order of dets in sector
5454

Geometry/MTDGeometryBuilder/src/MTDTopology.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
MTDTopology::MTDTopology(const int& topologyMode, const BTLValues& btl, const ETLValues& etl)
88
: mtdTopologyMode_(topologyMode), btlVals_(btl), etlVals_(etl) {}
99

10-
std::pair<uint32_t, uint32_t> MTDTopology::btlIndex(const uint32_t detId) {
10+
std::pair<uint32_t, uint32_t> MTDTopology::btlIndex(const uint32_t detId) const {
1111
size_t index(0);
1212
bool found(false);
1313
for (const auto& theid : btlVals_.btlDetId_) {
@@ -26,7 +26,7 @@ std::pair<uint32_t, uint32_t> MTDTopology::btlIndex(const uint32_t detId) {
2626
}
2727
}
2828

29-
uint32_t MTDTopology::btlidFromIndex(const uint32_t iphi, const uint32_t ieta) {
29+
uint32_t MTDTopology::btlidFromIndex(const uint32_t iphi, const uint32_t ieta) const {
3030
uint32_t res(0);
3131
for (uint32_t index = 0; index < btlVals_.nBTLmodules_; index++) {
3232
if (iphi == btlVals_.btlPhi_[index] && ieta == btlVals_.btlEta_[index]) {
@@ -38,7 +38,7 @@ uint32_t MTDTopology::btlidFromIndex(const uint32_t iphi, const uint32_t ieta) {
3838
return res;
3939
}
4040

41-
uint32_t MTDTopology::phishiftBTL(const uint32_t detid, const int phiShift) {
41+
uint32_t MTDTopology::phishiftBTL(const uint32_t detid, const int phiShift) const {
4242
if (phiShift == 0) {
4343
edm::LogWarning("MTDTopology") << "asking of a null phiShift in BTL";
4444
return failIndex_;
@@ -68,7 +68,7 @@ uint32_t MTDTopology::phishiftBTL(const uint32_t detid, const int phiShift) {
6868
}
6969
}
7070

71-
uint32_t MTDTopology::etashiftBTL(const uint32_t detid, const int etaShift) {
71+
uint32_t MTDTopology::etashiftBTL(const uint32_t detid, const int etaShift) const {
7272
if (etaShift == 0) {
7373
edm::LogWarning("MTDTopology") << "asking of a null etaShift in BTL";
7474
return failIndex_;

RecoMTD/DetLayers/interface/MTDDetTray.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "TrackingTools/DetLayers/interface/DetRodOneR.h"
1313
#include "TrackingTools/DetLayers/interface/PeriodicBinFinderInZ.h"
1414
#include "Utilities/BinningTools/interface/GenericBinFinderInZ.h"
15+
16+
#include <ostream>
17+
1518
class GeomDet;
1619

1720
class MTDDetTray : public DetRodOneR {

RecoMTD/DetLayers/src/MTDDetTray.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
#include <iostream>
1515

16+
#include "DataFormats/Math/interface/Rounding.h"
17+
1618
using namespace std;
19+
using namespace cms_rounding;
1720

1821
MTDDetTray::MTDDetTray(vector<const GeomDet*>::const_iterator first, vector<const GeomDet*>::const_iterator last)
1922
: DetRodOneR(first, last) {

RecoMTD/DetLayers/test/BuildFile.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
<use name="RecoMTD/Records"/>
33
<use name="FWCore/Framework"/>
44
<flags EDM_PLUGIN="1"/>
5-
<library file="MTDRecoGeometryAnalyzer.cc" name="testMTDRecoGeometry">
5+
<library file="*.cc" name="testMTDRecoGeometry">
66
<use name="clhep"/>
77
<use name="TrackingTools/KalmanUpdators"/>
88
<use name="TrackPropagation/SteppingHelixPropagator"/>
99
<use name="MagneticField/Records"/>
1010
<use name="MagneticField/Engine"/>
11-
<use name="Geometry/MTDNumberingBuilder"/>
11+
<use name="Geometry/MTDGeometryBuilder"/>
1212
<use name="Geometry/Records"/>
1313
<flags EDM_PLUGIN="1"/>
1414
</library>
15-
<library file="TestETLNavigation.cc" name="testETLNavigation">
16-
<flags EDM_PLUGIN="1"/>
17-
</library>
1815

1916
<test name="RecoMTDDetLayersTestDriver" command="runTest.sh"/>
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#include "FWCore/Framework/interface/Frameworkfwd.h"
2+
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
3+
#include "FWCore/Framework/interface/Event.h"
4+
#include "FWCore/Framework/interface/EventSetup.h"
5+
#include "FWCore/Framework/interface/ESTransientHandle.h"
6+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
7+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
8+
#include "FWCore/Utilities/interface/StreamID.h"
9+
10+
#include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
11+
#include "Geometry/Records/interface/MTDTopologyRcd.h"
12+
13+
#include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h"
14+
#include "RecoMTD/Records/interface/MTDRecoGeometryRecord.h"
15+
16+
#include "RecoMTD/DetLayers/interface/MTDTrayBarrelLayer.h"
17+
#include "RecoMTD/DetLayers/interface/MTDDetTray.h"
18+
19+
#include <DataFormats/ForwardDetId/interface/BTLDetId.h>
20+
21+
#include <sstream>
22+
23+
#include "DataFormats/Math/interface/Rounding.h"
24+
25+
using namespace std;
26+
using namespace edm;
27+
using namespace cms_rounding;
28+
29+
class TestBTLNavigation : public global::EDAnalyzer<> {
30+
public:
31+
TestBTLNavigation(const ParameterSet& pset);
32+
33+
void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
34+
35+
private:
36+
inline std::string fround(const double in, const size_t prec) const {
37+
std::stringstream ss;
38+
ss << std::setprecision(prec) << std::fixed << std::setw(14) << roundIfNear0(in);
39+
return ss.str();
40+
}
41+
42+
inline std::string fvecround(const GlobalPoint vecin, const size_t prec) const {
43+
std::stringstream ss;
44+
ss << std::setprecision(prec) << std::fixed << std::setw(14) << roundVecIfNear0(vecin);
45+
return ss.str();
46+
}
47+
48+
const edm::ESInputTag tag_;
49+
edm::ESGetToken<MTDDetLayerGeometry, MTDRecoGeometryRecord> geomToken_;
50+
edm::ESGetToken<MTDTopology, MTDTopologyRcd> topoToken_;
51+
};
52+
53+
TestBTLNavigation::TestBTLNavigation(const ParameterSet& iConfig) : tag_(edm::ESInputTag{"", ""}) {
54+
geomToken_ = esConsumes<MTDDetLayerGeometry, MTDRecoGeometryRecord>(tag_);
55+
topoToken_ = esConsumes<MTDTopology, MTDTopologyRcd>(tag_);
56+
}
57+
58+
void TestBTLNavigation::analyze(edm::StreamID, edm::Event const&, edm::EventSetup const& es) const {
59+
auto geo = es.getTransientHandle(geomToken_);
60+
auto topo = es.getTransientHandle(topoToken_);
61+
62+
const vector<const DetLayer*>& layers = geo->allBTLLayers();
63+
64+
// dump of BTL layers structure
65+
66+
LogVerbatim("MTDLayerDumpFull") << "\n\nTest of BTL navigation \n\n";
67+
LogVerbatim("MTDLayerDump") << "\n\nTest of BTL navigation \n\n";
68+
69+
for (const auto& ilay : layers) {
70+
const MTDTrayBarrelLayer* layer = static_cast<const MTDTrayBarrelLayer*>(ilay);
71+
72+
LogVerbatim("MTDLayerDumpFull") << std::fixed << "\nBTL layer " << std::setw(4) << layer->subDetector()
73+
<< " at z = " << fround(layer->surface().position().z(), 4)
74+
<< " rods = " << std::setw(14) << layer->rods().size()
75+
<< " dets = " << std::setw(14) << layer->basicComponents().size();
76+
LogVerbatim("MTDLayerDump") << std::fixed << "\nBTL layer " << std::setw(4) << layer->subDetector()
77+
<< " at z = " << fround(layer->surface().position().z(), 2)
78+
<< " rods = " << std::setw(14) << layer->rods().size() << " dets = " << std::setw(14)
79+
<< layer->basicComponents().size();
80+
81+
unsigned int irodInd(0);
82+
for (const auto& irod : layer->rods()) {
83+
irodInd++;
84+
LogVerbatim("MTDLayerDumpFull") << std::fixed << "\nTray " << std::setw(4) << irodInd << "\n"
85+
<< " MTDDetTray at " << std::fixed << std::setprecision(3)
86+
<< roundVecIfNear0(irod->specificSurface().position()) << std::endl
87+
<< " L/W/T : " << fround(irod->specificSurface().bounds().length(), 2) << " / "
88+
<< fround(irod->specificSurface().bounds().width(), 2) << " / "
89+
<< fround(irod->specificSurface().bounds().thickness(), 2)
90+
<< " normal phi = " << fround(irod->specificSurface().normalVector().phi(), 2)
91+
<< std::endl;
92+
LogVerbatim("MTDLayerDump") << std::fixed << "\nTray " << std::setw(4) << irodInd << "\n"
93+
<< " MTDDetTray at " << std::fixed << std::setprecision(3)
94+
<< roundVecIfNear0(irod->specificSurface().position()) << std::endl
95+
<< " L/W/T : " << fround(irod->specificSurface().bounds().length(), 2) << " / "
96+
<< fround(irod->specificSurface().bounds().width(), 2) << " / "
97+
<< fround(irod->specificSurface().bounds().thickness(), 2)
98+
<< " normal phi = " << fround(irod->specificSurface().normalVector().phi(), 2)
99+
<< std::endl;
100+
unsigned int imodInd(0);
101+
for (const auto& imod : irod->basicComponents()) {
102+
imodInd++;
103+
BTLDetId modId(imod->geographicalId().rawId());
104+
auto topoId = topo.product()->btlIndex(modId.rawId());
105+
auto topoDetId = topo.product()->btlidFromIndex(topoId.first, topoId.second);
106+
LogVerbatim("MTDLayerDumpFull") << std::fixed << std::setw(5) << imodInd << " BTLDetId " << modId.rawId()
107+
<< " iphi/ieta = " << std::setw(4) << topoId.first << " / " << std::setw(4)
108+
<< topoId.second << " side = " << std::setw(4) << modId.mtdSide()
109+
<< " RU = " << std::setw(4) << modId.runit() << " mod = " << std::setw(4)
110+
<< modId.module() << " pos = " << fvecround(imod->position(), 4);
111+
LogVerbatim("MTDLayerDump") << std::fixed << std::setw(5) << imodInd << " BTLDetId " << modId.rawId()
112+
<< " iphi/ieta = " << std::setw(4) << topoId.first << " / " << std::setw(4)
113+
<< topoId.second << " side = " << std::setw(4) << modId.mtdSide()
114+
<< " RU = " << std::setw(4) << modId.runit() << " mod = " << std::setw(4)
115+
<< modId.module() << " pos = " << fvecround(imod->position(), 2);
116+
if (topoDetId != modId.rawId()) {
117+
LogVerbatim("MTDLayerDumpFull")
118+
<< "DIFFERENCE BtlDetId " << modId.rawId() << " not equal to MTDTopology " << topoDetId;
119+
LogVerbatim("MTDLayerDump") << "DIFFERENCE BtlDetId " << modId.rawId() << " not equal to MTDTopology "
120+
<< topoDetId;
121+
}
122+
for (int iside = -1; iside <= 1; iside += 2) {
123+
size_t idetNew = topo.product()->phishiftBTL(modId.rawId(), iside);
124+
if (idetNew > irod->basicComponents().size()) {
125+
LogVerbatim("MTDLayerDumpFull")
126+
<< "...............phishift= " << std::fixed << std::setw(2) << iside << " out of range";
127+
LogVerbatim("MTDLayerDump") << "...............phishift= " << std::fixed << std::setw(2) << iside
128+
<< " out of range";
129+
} else {
130+
BTLDetId newId(irod->basicComponents()[idetNew]->geographicalId().rawId());
131+
auto newTopoId = topo.product()->btlIndex(newId.rawId());
132+
LogVerbatim("MTDLayerDumpFull")
133+
<< std::fixed << "...............phishift= "
134+
<< " iphi/ieta = " << std::setw(4) << newTopoId.first << " / " << std::setw(4) << newTopoId.second
135+
<< std::setw(2) << iside << " side = " << std::setw(4) << newId.mtdSide() << " RU = " << std::setw(4)
136+
<< newId.runit() << " mod = " << std::setw(4) << newId.module()
137+
<< " pos = " << fvecround(irod->basicComponents()[idetNew]->position(), 4);
138+
LogVerbatim("MTDLayerDump") << std::fixed << "...............phishift= "
139+
<< " iphi/ieta = " << std::setw(4) << newTopoId.first << " / " << std::setw(4)
140+
<< newTopoId.second << std::setw(2) << iside << " side = " << std::setw(4)
141+
<< newId.mtdSide() << " RU = " << std::setw(4) << newId.runit()
142+
<< " mod = " << std::setw(4) << newId.module()
143+
<< " pos = " << fvecround(irod->basicComponents()[idetNew]->position(), 2);
144+
}
145+
}
146+
for (int iside = -1; iside <= 1; iside += 2) {
147+
auto idetNew = topo.product()->etashiftBTL(modId, iside);
148+
if (idetNew > irod->basicComponents().size()) {
149+
LogVerbatim("MTDLayerDumpFull")
150+
<< "...............etashift= " << std::fixed << std::setw(2) << iside << " out of range";
151+
LogVerbatim("MTDLayerDump") << "...............etashift= " << std::fixed << std::setw(2) << iside
152+
<< " out of range";
153+
} else {
154+
BTLDetId newId(irod->basicComponents()[idetNew]->geographicalId().rawId());
155+
auto const& newTopoId = topo.product()->btlIndex(newId.rawId());
156+
LogVerbatim("MTDLayerDumpFull")
157+
<< std::fixed << "...............etashift= "
158+
<< " iphi/ieta = " << std::setw(4) << newTopoId.first << " / " << std::setw(4) << newTopoId.second
159+
<< std::setw(2) << iside << " side = " << std::setw(4) << newId.mtdSide() << " RU = " << std::setw(4)
160+
<< newId.runit() << " mod = " << std::setw(4) << newId.module()
161+
<< " pos = " << fvecround(irod->basicComponents()[idetNew]->position(), 4);
162+
LogVerbatim("MTDLayerDump") << std::fixed << "...............etashift= "
163+
<< " iphi/ieta = " << std::setw(4) << newTopoId.first << " / " << std::setw(4)
164+
<< newTopoId.second << std::setw(2) << iside << " side = " << std::setw(4)
165+
<< newId.mtdSide() << " RU = " << std::setw(4) << newId.runit()
166+
<< " mod = " << std::setw(4) << newId.module()
167+
<< " pos = " << fvecround(irod->basicComponents()[idetNew]->position(), 2);
168+
}
169+
}
170+
}
171+
}
172+
}
173+
}
174+
175+
//define this as a plug-in
176+
#include <FWCore/Framework/interface/MakerMacros.h>
177+
DEFINE_FWK_MODULE(TestBTLNavigation);

0 commit comments

Comments
 (0)