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.pixel(local_point);
139  uint8_t row(thepixel.first), col(thepixel.second);
140  return std::pair<uint8_t, uint8_t>(row, col);
141  } else {
142  BTLDetId detId(id);
144  const MTDGeomDet* thedet = geom_->idToDet(geoId);
145  if (thedet == nullptr)
146  throw cms::Exception("mtd::MTDGeomUtil") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
147  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
148  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
149  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
150  auto topo_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
151  const auto& thepixel = topo.pixel(topo_point);
152  uint8_t row(thepixel.first), col(thepixel.second);
153  return std::pair<uint8_t, uint8_t>(row, col);
154  }
155 }
156 
157 int MTDGeomUtil::crystalInModule(const DetId& id) const {
158  BTLDetId hid(id);
159  return hid.crystal();
160 }
161 
162 float MTDGeomUtil::eta(const GlobalPoint& position, const float& vertex_z) const {
163  GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z() - vertex_z);
164  return corrected_position.eta();
165 }
166 
167 float MTDGeomUtil::eta(const DetId& id, const LocalPoint& local_point, const float& vertex_z) const {
168  GlobalPoint position = globalPosition(id, local_point);
169  float Eta = eta(position, vertex_z);
170  return Eta;
171 }
172 
173 float MTDGeomUtil::phi(const GlobalPoint& position) const {
174  float phi = (position.x() == 0 && position.y() == 0) ? 0 : atan2(position.y(), position.x());
175  return phi;
176 }
177 
178 float MTDGeomUtil::phi(const DetId& id, const LocalPoint& local_point) const {
179  GlobalPoint position = globalPosition(id, local_point);
180  float phi = (position.x() == 0 && position.y() == 0) ? 0 : atan2(position.y(), position.x());
181  return phi;
182 }
183 
184 float MTDGeomUtil::pt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z) const {
185  float Eta = eta(position, vertex_z);
186  float pt = hitEnergy / cosh(Eta);
187  return pt;
188 }
189 
190 float MTDGeomUtil::pt(const DetId& id,
191  const LocalPoint& local_point,
192  const float& hitEnergy,
193  const float& vertex_z) const {
194  GlobalPoint position = globalPosition(id, local_point);
195  float Eta = eta(position, vertex_z);
196  float pt = hitEnergy / cosh(Eta);
197  return pt;
198 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
int crystalInModule(const DetId &) const
Definition: MTDGeomUtil.cc:157
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:173
int module() const
Definition: ETLDetId.h:133
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
int nrows() const override
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:61
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:155
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:57
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
int module(const DetId &) const
Definition: MTDGeomUtil.cc:98
int crystal() const
Definition: BTLDetId.h:87