test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecHitTools.cc
Go to the documentation of this file.
2 
10 
12 
15 
16 using namespace hgcal;
17 
18 namespace {
19  constexpr char hgcalee_sens[] = "HGCalEESensitive";
20  constexpr char hgcalfh_sens[] = "HGCalHESiliconSensitive";
21 
22  constexpr std::float_t idx_to_thickness = std::float_t(100.0);
23  // define layer offsets
24  // https://github.com/cms-sw/cmssw/blob/CMSSW_8_1_X/DataFormats/ForwardDetId/interface/ForwardSubdetector.h
25  // (EE) HGCEE=3, (FH) HGCHEF=4, BH is HcalEndcap = 2 encoded with HcalDetId
26  const unsigned int fhOffset = 28; // number of EE layers
27  const unsigned int bhOffset = fhOffset + 12; // number of EE+FH layers
28 
29  template<typename DDD>
30  inline void check_ddd(const DDD* ddd) {
31  if( nullptr == ddd ) {
32  throw cms::Exception("hgcal::RecHitTools")
33  << "DDDConstants not accessibl to hgcal::RecHitTools!";
34  }
35  }
36 
37  template<typename GEOM>
38  inline void check_geom(const GEOM* geom) {
39  if( nullptr == geom ) {
40  throw cms::Exception("hgcal::RecHitTools")
41  << "Geometry not provided yet to hgcal::RecHitTools!";
42  }
43  }
44 
45  inline const HcalDDDRecConstants* get_ddd(const CaloSubdetectorGeometry* geom,
46  const HcalDetId& detid) {
47  const HcalGeometry* hc = static_cast<const HcalGeometry*>(geom);
48  const HcalDDDRecConstants* ddd = hc->topology().dddConstants();
49  check_ddd(ddd);
50  return ddd;
51  }
52 
53  inline const HGCalDDDConstants* get_ddd(const CaloSubdetectorGeometry* geom,
54  const HGCalDetId& detid) {
55  const HGCalGeometry* hg = static_cast<const HGCalGeometry*>(geom);
56  const HGCalDDDConstants* ddd = &(hg->topology().dddConstants());
57  check_ddd(ddd);
58  return ddd;
59  }
60 
61 }
62 
64 }
65 
68  es.get<CaloGeometryRecord>().get(geom);
69 
70  geom_ = geom.product();
71 }
72 
74  auto geom = geom_->getSubdetectorGeometry(id);
75  check_geom(geom);
77  if( id.det() == DetId::Hcal ) {
78  position = geom->getGeometry(id)->getPosition();
79  } else {
80  const auto* hg = static_cast<const HGCalGeometry*>(geom);
81  position = hg->getPosition(id);
82  }
83  return position;
84 }
85 
86 std::float_t RecHitTools::getSiThickness(const DetId& id) const {
87  auto geom = geom_->getSubdetectorGeometry(id);
88  check_geom(geom);
89  if( id.det() != DetId::Forward ) {
90  edm::LogError("getSiThickness::InvalidSiliconDetid")
91  << "det id: " << id.rawId() << " is not HGCal silicon!";
92  }
93  const HGCalDetId hid(id);
94  auto ddd = get_ddd(geom,hid);
95  unsigned int wafer = hid.wafer();
96  int tidx = ddd->waferTypeL(wafer);
97  return idx_to_thickness*tidx;
98 }
99 
100 std::float_t RecHitTools::getRadiusToSide(const DetId& id) const {
101  auto geom = geom_->getSubdetectorGeometry(id);
102  check_geom(geom);
103  if( id.det() != DetId::Forward ) {
104  edm::LogError("getRadiusToSide::InvalidSiliconDetid")
105  << "det id: " << id.rawId() << " is not HGCal silicon!";
107  }
108  const HGCalDetId hid(id);
109  auto ddd = get_ddd(geom,hid);
110  std::float_t size = ddd->cellSizeHex(hid.waferType());
111  return size;
112 }
113 
114 unsigned int RecHitTools::getLayer(const DetId& id) const {
115  unsigned int layer = std::numeric_limits<unsigned int>::max();
116  if( id.det() == DetId::Forward) {
117  const HGCalDetId hid(id);
118  layer = hid.layer();
119  } else if( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) {
120  const HcalDetId hcid(id);
121  layer = hcid.depth();
122  }
123  return layer;
124 }
125 
126 unsigned int RecHitTools::getLayerWithOffset(const DetId& id) const {
127  unsigned int layer = getLayer(id);
128  if( id.det() == DetId::Forward && id.subdetId() == HGCHEF ) {
129  layer += fhOffset;
130  } else if( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) {
131  layer += bhOffset;
132  }
133  return layer;
134 }
135 
136 unsigned int RecHitTools::getWafer(const DetId& id) const {
137  if( id.det() != DetId::Forward ) {
138  edm::LogError("getWafer::InvalidSiliconDetid")
139  << "det id: " << id.rawId() << " is not HGCal silicon!";
141  }
142  const HGCalDetId hid(id);
143  unsigned int wafer = hid.wafer();
144  return wafer;
145 }
146 
147 unsigned int RecHitTools::getCell(const DetId& id) const {
148  if( id.det() != DetId::Forward ) {
149  edm::LogError("getCell::InvalidSiliconDetid")
150  << "det id: " << id.rawId() << " is not HGCal silicon!";
152  }
153  const HGCalDetId hid(id);
154  unsigned int cell = hid.cell();
155  return cell;
156 }
157 
158 bool RecHitTools::isHalfCell(const DetId& id) const {
159  if( id.det() != DetId::Forward ) {
160  return false;
161  }
162  auto geom = geom_->getSubdetectorGeometry(id);
163  check_geom(geom);
164  const HGCalDetId hid(id);
165  auto ddd = get_ddd(geom,hid);
166  const int waferType = ddd->waferTypeT(hid.waferType());
167  return ddd->isHalfCell(waferType,hid.cell());
168 }
169 
170 float RecHitTools::getEta(const GlobalPoint& position, const float& vertex_z) const {
171  GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z()-vertex_z);
172  return corrected_position.eta();
173 }
174 
175 float RecHitTools::getEta(const DetId& id, const float& vertex_z) const {
177  float eta = getEta(position, vertex_z);
178  return eta;
179 }
180 
182  float phi = atan2(position.y(),position.x());
183  return phi;
184 }
185 
186 float RecHitTools::getPhi(const DetId& id) const {
188  float phi = atan2(position.y(),position.x());
189  return phi;
190 }
191 
192 float RecHitTools::getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z) const {
193  float eta = getEta(position, vertex_z);
194  float pt = hitEnergy / cosh(eta);
195  return pt;
196 }
197 
198 float RecHitTools::getPt(const DetId& id, const float& hitEnergy, const float& vertex_z) const {
200  float eta = getEta(position, vertex_z);
201  float pt = hitEnergy / cosh(eta);
202  return pt;
203 }
bool isHalfCell(int waferType, int cell) const
bool isHalfCell(const DetId &) const
Definition: RecHitTools.cc:158
unsigned int getWafer(const DetId &) const
Definition: RecHitTools.cc:136
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
void getEvent(const edm::Event &)
Definition: RecHitTools.cc:63
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:150
unsigned int getCell(const DetId &) const
Definition: RecHitTools.cc:147
double cellSizeHex(int type) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
GlobalPoint getPosition(const DetId &id) const
bool ev
#define constexpr
float getEta(const GlobalPoint &position, const float &vertex_z=0.) const
Definition: RecHitTools.cc:170
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:66
const HcalTopology & topology() const
Definition: HcalGeometry.h:108
int depth() const
get the tower depth
Definition: HcalDetId.cc:108
float getPhi(const GlobalPoint &position) const
Definition: RecHitTools.cc:181
float getPt(const GlobalPoint &position, const float &hitEnergy, const float &vertex_z=0.) const
Definition: RecHitTools.cc:192
T z() const
Definition: PV3DBase.h:64
const HGCalTopology & topology() const
Definition: HGCalGeometry.h:96
std::float_t getRadiusToSide(const DetId &) const
Definition: RecHitTools.cc:100
const CaloGeometry * geom_
Definition: RecHitTools.h:48
int wafer() const
get the wafer #
Definition: HGCalDetId.h:42
int waferTypeL(int wafer) const
std::float_t getSiThickness(const DetId &) const
Definition: RecHitTools.cc:86
Definition: DetId.h:18
int cell() const
get the absolute value of the cell #&#39;s in x and y
Definition: HGCalDetId.h:39
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:126
const HGCalDDDConstants & dddConstants() const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:73
Geom::Phi< T > phi() const
T eta() const
Definition: PV3DBase.h:76
static int position[264][3]
Definition: ReadPGInfo.cc:509
susybsm::HSCParticleCollection hc
Definition: classes.h:25
int waferType() const
get the wafer type
Definition: HGCalDetId.h:45
unsigned int getLayer(const DetId &) const
Definition: RecHitTools.cc:114
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62
int waferTypeT(int wafer) const
tuple size
Write out results.
int layer() const
get the layer #
Definition: HGCalDetId.h:48