CMS 3D CMS Logo

MTDGeomUtil.cc
Go to the documentation of this file.
2 
4 
7 
8 using namespace mtd;
9 
11 
12 void MTDGeomUtil::setTopology(const MTDTopology* topo) { topology_ = topo; }
13 
14 bool MTDGeomUtil::isETL(const DetId& id) const {
15  MTDDetId hid{id};
16  const auto& subDet = hid.mtdSubDetector();
17  if (subDet == 0)
18  throw cms::Exception("mtd::MTDGeomUtil") << "DetId " << hid.rawId() << " not in MTD!" << std::endl;
19  if (subDet == MTDDetId::MTDType::ETL)
20  return true;
21  return false;
22 }
23 
24 bool MTDGeomUtil::isBTL(const DetId& id) const { return !(isETL(id)); }
25 
26 // row and column set to 0 by default since they are not needed for BTL
27 std::pair<LocalPoint, GlobalPoint> MTDGeomUtil::position(const DetId& id, int row, int column) const {
28  LocalPoint local_point(0., 0., 0.);
29  GlobalPoint global_point(0., 0., 0.);
30  if (isBTL(id)) {
31  BTLDetId detId{id};
33  const MTDGeomDet* thedet = geom_->idToDet(geoId);
34  if (thedet == nullptr)
35  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
36  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
37  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
38  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
39 
40  local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
41  global_point = thedet->toGlobal(local_point);
42  } else {
43  ETLDetId detId{id};
44  DetId geoId = detId.geographicalId();
45  const MTDGeomDet* thedet = geom_->idToDet(geoId);
46  if (thedet == nullptr)
47  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
48  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
49  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
50  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
51 
52  local_point = LocalPoint(topo.localX(row), topo.localY(column), 0.);
53  global_point = thedet->toGlobal(local_point);
54  }
55  return {local_point, global_point};
56 }
57 
58 GlobalPoint MTDGeomUtil::globalPosition(const DetId& id, const LocalPoint& local_point) const {
59  auto global_point = GlobalPoint(0., 0., 0.);
60  if (isBTL(id)) {
61  BTLDetId detId{id};
63  const MTDGeomDet* thedet = geom_->idToDet(geoId);
64  if (thedet == nullptr)
65  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
66  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
67  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
68  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
69  auto local_point_sim =
70  topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
71  global_point = thedet->toGlobal(local_point_sim);
72  } else {
73  ETLDetId detId{id};
74  DetId geoId = detId.geographicalId();
75  const MTDGeomDet* thedet = geom_->idToDet(geoId);
76  if (thedet == nullptr)
77  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
78  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
79  global_point = thedet->toGlobal(local_point);
80  }
81  return global_point;
82 }
83 
84 int MTDGeomUtil::zside(const DetId& id) const {
85  const MTDDetId hid(id);
86  return hid.zside();
87 }
88 
89 unsigned int MTDGeomUtil::layer(const DetId& id) const {
90  unsigned int layer(0);
91  if (isETL(id)) {
92  ETLDetId hid(id);
93  layer = hid.nDisc();
94  }
95  return layer;
96 }
97 
98 int MTDGeomUtil::module(const DetId& id) const {
99  int module = -1;
100  if (isETL(id)) {
101  ETLDetId hid(id);
102  module = hid.module();
103  } else {
104  BTLDetId hid(id);
105  module = hid.module();
106  }
107  return module;
108 }
109 
110 // returns the local position as a pair (x, y) - for ETL
111 std::pair<float, float> MTDGeomUtil::pixelInModule(const DetId& id, const int row, const int column) const {
112  if (isBTL(id))
113  throw cms::Exception("mtd::MTDGeomUtil")
114  << "ID: " << std::hex << id.rawId() << " from BTL. This method is for ETL only." << std::endl;
115  ETLDetId detId(id);
116  DetId geoId = detId.geographicalId();
117  const MTDGeomDet* thedet = geom_->idToDet(geoId);
118  if (thedet == nullptr)
119  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()
120  << ") is invalid!" << std::dec << std::endl;
121  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
122  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
123  const Local3DPoint local_point(topo.localX(row), topo.localY(column), 0.);
124  return topo.pixel(local_point);
125 }
126 
127 // returns row and column as a pair (row, col)
128 std::pair<uint8_t, uint8_t> MTDGeomUtil::pixelInModule(const DetId& id, const LocalPoint& local_point) const {
129  if (isETL(id)) {
130  ETLDetId detId(id);
131  DetId geoId = detId.geographicalId();
132  const MTDGeomDet* thedet = geom_->idToDet(geoId);
133  if (thedet == nullptr)
134  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
135  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
136  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
137  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
138  const auto& thepixel = topo.pixelIndex(local_point);
139  uint8_t row = static_cast<uint8_t>(thepixel.first);
140  uint8_t col = static_cast<uint8_t>(thepixel.second);
141  return std::pair<uint8_t, uint8_t>(row, col);
142  } else {
143  BTLDetId detId(id);
145  const MTDGeomDet* thedet = geom_->idToDet(geoId);
146  if (thedet == nullptr)
147  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
148  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
149  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
150  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
151  auto topo_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
152  const auto& thepixel = topo.pixelIndex(topo_point);
153  uint8_t row = static_cast<uint8_t>(thepixel.first);
154  uint8_t col = static_cast<uint8_t>(thepixel.second);
155  return std::pair<uint8_t, uint8_t>(row, col);
156  }
157 }
158 
159 int MTDGeomUtil::crystalInModule(const DetId& id) const {
160  BTLDetId hid(id);
161  return hid.crystal();
162 }
163 
164 // returns the sensor module id
165 uint32_t MTDGeomUtil::sensorModuleId(const DetId& id) const {
166  if (isBTL(id)) {
167  BTLDetId detId(id);
169  return (geoId.rawId());
170  } else {
171  ETLDetId detId(id);
172  DetId geoId = detId.geographicalId();
173  return (geoId.rawId());
174  }
175 }
176 
177 float MTDGeomUtil::eta(const GlobalPoint& position, const float& vertex_z) const {
178  GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z() - vertex_z);
179  return corrected_position.eta();
180 }
181 
182 float MTDGeomUtil::eta(const DetId& id, const LocalPoint& local_point, const float& vertex_z) const {
183  GlobalPoint position = globalPosition(id, local_point);
184  float Eta = eta(position, vertex_z);
185  return Eta;
186 }
187 
188 float MTDGeomUtil::phi(const GlobalPoint& position) const {
189  float phi = (position.x() == 0 && position.y() == 0) ? 0 : atan2(position.y(), position.x());
190  return phi;
191 }
192 
193 float MTDGeomUtil::phi(const DetId& id, const LocalPoint& local_point) const {
194  GlobalPoint position = globalPosition(id, local_point);
195  float phi = (position.x() == 0 && position.y() == 0) ? 0 : atan2(position.y(), position.x());
196  return phi;
197 }
198 
199 float MTDGeomUtil::pt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z) const {
200  float Eta = eta(position, vertex_z);
201  float pt = hitEnergy / cosh(Eta);
202  return pt;
203 }
204 
205 float MTDGeomUtil::pt(const DetId& id,
206  const LocalPoint& local_point,
207  const float& hitEnergy,
208  const float& vertex_z) const {
209  GlobalPoint position = globalPosition(id, local_point);
210  float Eta = eta(position, vertex_z);
211  float pt = hitEnergy / cosh(Eta);
212  return pt;
213 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
int crystalInModule(const DetId &) const
Definition: MTDGeomUtil.cc:159
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
GlobalPoint globalPosition(const DetId &id, const LocalPoint &local_point) const
Definition: MTDGeomUtil.cc:58
std::pair< float, float > pixelInModule(const DetId &id, const int row, const int column) const
Definition: MTDGeomUtil.cc:111
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
T eta() const
Definition: PV3DBase.h:73
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
int mtdSubDetector() const
Definition: MTDDetId.h:56
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
void setTopology(MTDTopology const *topo)
Definition: MTDGeomUtil.cc:12
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
std::pair< float, float > pixel(const LocalPoint &p) const override
float localX(const float mpX) const override
unsigned int layer(const DetId &) const
Definition: MTDGeomUtil.cc:89
bool isBTL(const DetId &) const
Definition: MTDGeomUtil.cc:24
float phi(const GlobalPoint &position) const
Definition: MTDGeomUtil.cc:188
int module() const
Definition: ETLDetId.h:142
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
int nrows() const override
uint32_t sensorModuleId(const DetId &id) const
Definition: MTDGeomUtil.cc:165
std::pair< LocalPoint, GlobalPoint > position(const DetId &id, int row=0, int column=0) const
Definition: MTDGeomUtil.cc:27
int module() const
Definition: BTLDetId.h:81
void setGeometry(MTDGeometry const *geom)
Definition: MTDGeomUtil.cc:10
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63
float localY(const float mpY) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Definition: DetId.h:17
int zside(const DetId &id) const
Definition: MTDGeomUtil.cc:84
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool isETL(const DetId &) const
Definition: MTDGeomUtil.cc:14
int zside() const
Definition: MTDDetId.h:61
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
float pt(const GlobalPoint &position, const float &hitEnergy, const float &vertex_z=0.) const
float eta(const GlobalPoint &position, const float &vertex_z=0.) const
int nDisc() const
Definition: ETLDetId.h:164
static int position[264][3]
Definition: ReadPGInfo.cc:289
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
col
Definition: cuy.py:1009
const MTDGeometry * geom_
Definition: MTDGeomUtil.h:59
std::pair< int, int > pixelIndex(const LocalPoint &p) const
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
int module(const DetId &) const
Definition: MTDGeomUtil.cc:98
int crystal() const
Definition: BTLDetId.h:87