CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
mtd::MTDGeomUtil Class Reference

#include <MTDGeomUtil.h>

Public Member Functions

int crystalInModule (const DetId &) const
 
float eta (const GlobalPoint &position, const float &vertex_z=0.) const
 
float eta (const DetId &id, const LocalPoint &local_point, const float &vertex_z=0.) const
 
const MTDGeometrygeometry () const
 
GlobalPoint globalPosition (const DetId &id, const LocalPoint &local_point) const
 
bool isBTL (const DetId &) const
 
bool isETL (const DetId &) const
 
unsigned int layer (const DetId &) const
 
int module (const DetId &) const
 
 MTDGeomUtil ()
 
float phi (const GlobalPoint &position) const
 
float phi (const DetId &id, const LocalPoint &local_point) const
 
std::pair< float, float > pixelInModule (const DetId &id, const int row, const int column) const
 
std::pair< uint8_t, uint8_t > pixelInModule (const DetId &id, const LocalPoint &local_point) const
 
std::pair< LocalPoint, GlobalPointposition (const DetId &id, int row=0, int column=0) const
 
float pt (const GlobalPoint &position, const float &hitEnergy, const float &vertex_z=0.) const
 
float pt (const DetId &id, const LocalPoint &local_point, const float &hitEnergy, const float &vertex_z=0.) const
 
uint32_t sensorModuleId (const DetId &id) const
 
void setGeometry (MTDGeometry const *geom)
 
void setTopology (MTDTopology const *topo)
 
const MTDTopologytopology () const
 
int zside (const DetId &id) const
 
 ~MTDGeomUtil ()
 

Private Attributes

const MTDGeometrygeom_
 
const MTDTopologytopology_
 

Detailed Description

Definition at line 23 of file MTDGeomUtil.h.

Constructor & Destructor Documentation

◆ MTDGeomUtil()

mtd::MTDGeomUtil::MTDGeomUtil ( )
inline

Definition at line 25 of file MTDGeomUtil.h.

25 : geom_(nullptr), topology_(nullptr) {}
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63
const MTDGeometry * geom_
Definition: MTDGeomUtil.h:59

◆ ~MTDGeomUtil()

mtd::MTDGeomUtil::~MTDGeomUtil ( )
inline

Definition at line 26 of file MTDGeomUtil.h.

26 {}

Member Function Documentation

◆ crystalInModule()

int MTDGeomUtil::crystalInModule ( const DetId id) const

Definition at line 159 of file MTDGeomUtil.cc.

References BTLDetId::crystal().

159  {
160  BTLDetId hid(id);
161  return hid.crystal();
162 }
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19

◆ eta() [1/2]

float mtd::MTDGeomUtil::eta ( const GlobalPoint position,
const float &  vertex_z = 0. 
) const

◆ eta() [2/2]

float mtd::MTDGeomUtil::eta ( const DetId id,
const LocalPoint local_point,
const float &  vertex_z = 0. 
) const

◆ geometry()

const MTDGeometry* mtd::MTDGeomUtil::geometry ( ) const
inline

Definition at line 58 of file MTDGeomUtil.h.

References geom_.

58 { return geom_; };
const MTDGeometry * geom_
Definition: MTDGeomUtil.h:59

◆ globalPosition()

GlobalPoint MTDGeomUtil::globalPosition ( const DetId id,
const LocalPoint local_point 
) const

Definition at line 58 of file MTDGeomUtil.cc.

References MTDTopologyMode::crysLayoutFromTopoMode(), TauDecayModes::dec, hcalRecHitTable_cff::detId, Exception, geom_, MTDTopology::getMTDTopologyMode(), MTDGeometry::idToDet(), isBTL(), RectangularMTDTopology::nrows(), RectangularMTDTopology::pixelToModuleLocalPoint(), DetId::rawId(), ProxyMTDTopology::specificTopology(), GeomDet::toGlobal(), GeomDet::topology(), and topology_.

Referenced by MtdTruthAccumulator::fillSimHits(), and phi().

58  {
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 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
bool isBTL(const DetId &) const
Definition: MTDGeomUtil.cc:24
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
int nrows() const override
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63
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
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
const MTDGeometry * geom_
Definition: MTDGeomUtil.h:59
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)

◆ isBTL()

bool MTDGeomUtil::isBTL ( const DetId id) const

Definition at line 24 of file MTDGeomUtil.cc.

References isETL().

Referenced by MtdTruthAccumulator::finalizeEvent(), globalPosition(), pixelInModule(), position(), and sensorModuleId().

24 { return !(isETL(id)); }
bool isETL(const DetId &) const
Definition: MTDGeomUtil.cc:14

◆ isETL()

bool MTDGeomUtil::isETL ( const DetId id) const

Definition at line 14 of file MTDGeomUtil.cc.

References Exception, and MTDDetId::mtdSubDetector().

Referenced by MtdTruthAccumulator::finalizeEvent(), isBTL(), layer(), module(), and pixelInModule().

14  {
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 }
int mtdSubDetector() const
Definition: MTDDetId.h:56
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21

◆ layer()

unsigned int MTDGeomUtil::layer ( const DetId id) const

Definition at line 89 of file MTDGeomUtil.cc.

References isETL(), and ETLDetId::nDisc().

Referenced by MtdTruthAccumulator::fillSimHits(), MtdTruthAccumulator::finalizeEvent(), geometryXMLparser.DTAlignable::index(), and geometryXMLparser.CSCAlignable::index().

89  {
90  unsigned int layer(0);
91  if (isETL(id)) {
92  ETLDetId hid(id);
93  layer = hid.nDisc();
94  }
95  return layer;
96 }
unsigned int layer(const DetId &) const
Definition: MTDGeomUtil.cc:89
bool isETL(const DetId &) const
Definition: MTDGeomUtil.cc:14
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16

◆ module()

int MTDGeomUtil::module ( const DetId id) const

Definition at line 98 of file MTDGeomUtil.cc.

References isETL(), BTLDetId::module(), and ETLDetId::module().

Referenced by MtdTruthAccumulator::fillSimHits(), and MtdTruthAccumulator::finalizeEvent().

98  {
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 }
bool isETL(const DetId &) const
Definition: MTDGeomUtil.cc:14
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
int module(const DetId &) const
Definition: MTDGeomUtil.cc:98

◆ phi() [1/2]

float MTDGeomUtil::phi ( const GlobalPoint position) const

Definition at line 188 of file MTDGeomUtil.cc.

References position().

Referenced by Particle.Particle::__str__(), datamodel.Object::DeltaR(), datamodel.Object::p4(), phi(), and ntupleDataFormat.Track::phiPull().

188  {
189  float phi = (position.x() == 0 && position.y() == 0) ? 0 : atan2(position.y(), position.x());
190  return phi;
191 }
float phi(const GlobalPoint &position) const
Definition: MTDGeomUtil.cc:188
std::pair< LocalPoint, GlobalPoint > position(const DetId &id, int row=0, int column=0) const
Definition: MTDGeomUtil.cc:27

◆ phi() [2/2]

float MTDGeomUtil::phi ( const DetId id,
const LocalPoint local_point 
) const

Definition at line 193 of file MTDGeomUtil.cc.

References globalPosition(), phi(), and position().

Referenced by Particle.Particle::__str__(), datamodel.Object::DeltaR(), datamodel.Object::p4(), and ntupleDataFormat.Track::phiPull().

193  {
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 }
GlobalPoint globalPosition(const DetId &id, const LocalPoint &local_point) const
Definition: MTDGeomUtil.cc:58
float phi(const GlobalPoint &position) const
Definition: MTDGeomUtil.cc:188
std::pair< LocalPoint, GlobalPoint > position(const DetId &id, int row=0, int column=0) const
Definition: MTDGeomUtil.cc:27

◆ pixelInModule() [1/2]

std::pair< float, float > MTDGeomUtil::pixelInModule ( const DetId id,
const int  row,
const int  column 
) const

Definition at line 111 of file MTDGeomUtil.cc.

References TauDecayModes::dec, hcalRecHitTable_cff::detId, Exception, geom_, MTDGeometry::idToDet(), isBTL(), RectangularMTDTopology::localX(), RectangularMTDTopology::localY(), RectangularMTDTopology::pixel(), DetId::rawId(), ProxyMTDTopology::specificTopology(), and GeomDet::topology().

Referenced by EtlSimHitsValidation::analyze(), EtlLocalRecoValidation::analyze(), and MtdTruthAccumulator::fillSimHits().

111  {
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 }
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
std::pair< float, float > pixel(const LocalPoint &p) const override
float localX(const float mpX) const override
bool isBTL(const DetId &) const
Definition: MTDGeomUtil.cc:24
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
float localY(const float mpY) const override
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
const MTDGeometry * geom_
Definition: MTDGeomUtil.h:59

◆ pixelInModule() [2/2]

std::pair< uint8_t, uint8_t > MTDGeomUtil::pixelInModule ( const DetId id,
const LocalPoint local_point 
) const

Definition at line 128 of file MTDGeomUtil.cc.

References cuy::col, MTDTopologyMode::crysLayoutFromTopoMode(), TauDecayModes::dec, hcalRecHitTable_cff::detId, Exception, geom_, MTDTopology::getMTDTopologyMode(), MTDGeometry::idToDet(), isETL(), RectangularMTDTopology::nrows(), RectangularMTDTopology::pixelIndex(), RectangularMTDTopology::pixelToModuleLocalPoint(), DetId::rawId(), ProxyMTDTopology::specificTopology(), GeomDet::topology(), and topology_.

128  {
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 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
int nrows() const override
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool isETL(const DetId &) const
Definition: MTDGeomUtil.cc:14
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
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)

◆ position()

std::pair< LocalPoint, GlobalPoint > MTDGeomUtil::position ( const DetId id,
int  row = 0,
int  column = 0 
) const

Definition at line 27 of file MTDGeomUtil.cc.

References MTDTopologyMode::crysLayoutFromTopoMode(), TauDecayModes::dec, hcalRecHitTable_cff::detId, Exception, geom_, MTDTopology::getMTDTopologyMode(), MTDGeometry::idToDet(), isBTL(), RectangularMTDTopology::localX(), RectangularMTDTopology::localY(), RectangularMTDTopology::nrows(), RectangularMTDTopology::pixelToModuleLocalPoint(), DetId::rawId(), ProxyMTDTopology::specificTopology(), GeomDet::toGlobal(), GeomDet::topology(), and topology_.

Referenced by MtdTruthAccumulator::finalizeEvent(), and phi().

27  {
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 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
float localX(const float mpX) const override
bool isBTL(const DetId &) const
Definition: MTDGeomUtil.cc:24
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
int nrows() const override
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
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
const MTDGeometry * geom_
Definition: MTDGeomUtil.h:59
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)

◆ pt() [1/2]

float mtd::MTDGeomUtil::pt ( const GlobalPoint position,
const float &  hitEnergy,
const float &  vertex_z = 0. 
) const

◆ pt() [2/2]

float mtd::MTDGeomUtil::pt ( const DetId id,
const LocalPoint local_point,
const float &  hitEnergy,
const float &  vertex_z = 0. 
) const

◆ sensorModuleId()

uint32_t MTDGeomUtil::sensorModuleId ( const DetId id) const

Definition at line 165 of file MTDGeomUtil.cc.

References MTDTopologyMode::crysLayoutFromTopoMode(), hcalRecHitTable_cff::detId, MTDTopology::getMTDTopologyMode(), isBTL(), DetId::rawId(), and topology_.

Referenced by MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl::associateRecoToSim(), and MtdRecoClusterToSimLayerClusterAssociatorByHitsImpl::associateSimToReco().

165  {
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 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
bool isBTL(const DetId &) const
Definition: MTDGeomUtil.cc:24
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)

◆ setGeometry()

void MTDGeomUtil::setGeometry ( MTDGeometry const *  geom)

◆ setTopology()

void MTDGeomUtil::setTopology ( MTDTopology const *  topo)

Definition at line 12 of file MTDGeomUtil.cc.

References topology_.

Referenced by MtdTruthAccumulator::initializeEvent(), and MtdRecoClusterToSimLayerClusterAssociatorByHitsProducer::produce().

12 { topology_ = topo; }
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63

◆ topology()

const MTDTopology* mtd::MTDGeomUtil::topology ( ) const
inline

Definition at line 59 of file MTDGeomUtil.h.

References topology_.

59 { return topology_; };
const MTDTopology * topology_
Definition: MTDGeomUtil.h:63

◆ zside()

int MTDGeomUtil::zside ( const DetId id) const

Definition at line 84 of file MTDGeomUtil.cc.

References MTDDetId::zside().

84  {
85  const MTDDetId hid(id);
86  return hid.zside();
87 }
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21

Member Data Documentation

◆ geom_

const MTDGeometry* mtd::MTDGeomUtil::geom_
private

Definition at line 59 of file MTDGeomUtil.h.

Referenced by geometry(), globalPosition(), pixelInModule(), position(), and setGeometry().

◆ topology_

const MTDTopology* mtd::MTDGeomUtil::topology_
private