CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TotemT2Segmentation Class Reference

#include <TotemT2Segmentation.h>

Public Member Functions

void fill (TH2D *, const TotemT2DetId &, double value=1.)
 
 TotemT2Segmentation (const TotemGeometry &, size_t, size_t)
 

Private Member Functions

std::vector< std::pair< short, short > > computeBins (const TotemT2DetId &detid) const
 

Private Attributes

std::unordered_map< TotemT2DetId, std::vector< std::pair< short, short > > > bins_map_
 
const TotemGeometry geom_
 
const size_t nbinsx_
 
const size_t nbinsy_
 

Detailed Description

Definition at line 21 of file TotemT2Segmentation.h.

Constructor & Destructor Documentation

◆ TotemT2Segmentation()

TotemT2Segmentation::TotemT2Segmentation ( const TotemGeometry geom,
size_t  nbinsx,
size_t  nbinsy 
)
explicit

Definition at line 16 of file TotemT2Segmentation.cc.

References protons_cff::arm, bins_map_, computeBins(), l1ctLayer2EG_cff::id, CTPPSDetId::maxArm, TotemT2DetId::maxChannel, and TotemT2DetId::maxPlane.

18  for (unsigned short arm = 0; arm <= CTPPSDetId::maxArm; ++arm)
19  for (unsigned short plane = 0; plane <= TotemT2DetId::maxPlane; ++plane)
20  for (unsigned short id = 0; id <= TotemT2DetId::maxChannel; ++id) {
21  const TotemT2DetId detid(arm, plane, id);
22  bins_map_[detid] = computeBins(detid);
23  }
24 }
Detector ID class for Totem T2 detectors. Bits [19:31] : Base CTPPSDetId class attributes Bits [16:18...
Definition: TotemT2DetId.h:25
const TotemGeometry geom_
static constexpr uint32_t maxChannel
Definition: TotemT2DetId.h:35
static constexpr uint32_t maxPlane
Definition: TotemT2DetId.h:34
static const uint32_t maxArm
Definition: CTPPSDetId.h:51
std::unordered_map< TotemT2DetId, std::vector< std::pair< short, short > > > bins_map_
std::vector< std::pair< short, short > > computeBins(const TotemT2DetId &detid) const

Member Function Documentation

◆ computeBins()

std::vector< std::pair< short, short > > TotemT2Segmentation::computeBins ( const TotemT2DetId detid) const
private

Definition at line 39 of file TotemT2Segmentation.cc.

References trigObjTnPSource_cfi::bins, reco::ceil(), TotemT2Tile::centre(), geom_, nbinsx_, nbinsy_, funct::pow(), and TotemGeometry::tile().

Referenced by TotemT2Segmentation().

39  {
40  std::vector<std::pair<short, short> > bins;
41  // find the histogram centre
42  const auto ox = floor(nbinsx_ * 0.5), oy = floor(nbinsy_ * 0.5);
43  // compute the ellipse parameters
44  const auto ax = ceil(nbinsx_ * 0.5), by = ceil(nbinsy_ * 0.5);
45 
46  const float max_half_angle_rad = 0.3;
47  // find the coordinates of the tile centre to extract its angle
48  const auto tile_centre = geom_.tile(detid).centre();
49  const auto tile_angle_rad = std::atan2(tile_centre.y(), tile_centre.x());
50  // Geometric way of associating a DetId to a vector<ix, iy> of bins given the size (nx_, ny_) of
51  // the TH2D('s) to be filled
52  for (size_t ix = 0; ix < nbinsx_; ++ix)
53  for (size_t iy = 0; iy < nbinsy_; ++iy) {
54  const auto ell_rad_norm = std::pow((ix - ox) / ax, 2) + std::pow((iy - oy) / by, 2);
55  if (ell_rad_norm < 1. && ell_rad_norm >= 0.1 &&
56  fabs(std::atan2(iy - oy, ix - ox) - tile_angle_rad) < max_half_angle_rad)
57  bins.emplace_back(ix, iy);
58  }
59 
60  return bins;
61 }
constexpr int32_t ceil(float num)
const TotemGeometry geom_
const GlobalPoint & centre() const
Definition: TotemT2Tile.h:21
const TotemT2Tile & tile(const TotemT2DetId &) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ fill()

void TotemT2Segmentation::fill ( TH2D *  hist,
const TotemT2DetId detid,
double  value = 1. 
)

Definition at line 26 of file TotemT2Segmentation.cc.

References newFWLiteAna::bin, bins_map_, Exception, gpuVertexFinder::hist, nbinsx_, and nbinsy_.

26  {
27  if (bins_map_.count(detid) == 0)
28  throw cms::Exception("TotemT2Segmentation") << "Failed to retrieve list of bins for TotemT2DetId " << detid << ".";
29  if (static_cast<size_t>(hist->GetXaxis()->GetNbins()) != nbinsx_ ||
30  static_cast<size_t>(hist->GetYaxis()->GetNbins()) != nbinsy_)
31  throw cms::Exception("TotemT2Segmentation")
32  << "Trying to fill a summary plot with invalid number of bins. "
33  << "Should be of dimension (" << nbinsx_ << ", " << nbinsy_ << "), but has dimension ("
34  << hist->GetXaxis()->GetNbins() << ", " << hist->GetYaxis()->GetNbins() << ").";
35  for (const auto& bin : bins_map_.at(detid))
36  hist->Fill(bin.first, bin.second, value);
37 }
Definition: value.py:1
std::unordered_map< TotemT2DetId, std::vector< std::pair< short, short > > > bins_map_

Member Data Documentation

◆ bins_map_

std::unordered_map<TotemT2DetId, std::vector<std::pair<short, short> > > TotemT2Segmentation::bins_map_
private

Definition at line 34 of file TotemT2Segmentation.h.

Referenced by fill(), and TotemT2Segmentation().

◆ geom_

const TotemGeometry TotemT2Segmentation::geom_
private

Definition at line 30 of file TotemT2Segmentation.h.

Referenced by computeBins().

◆ nbinsx_

const size_t TotemT2Segmentation::nbinsx_
private

Definition at line 31 of file TotemT2Segmentation.h.

Referenced by computeBins(), and fill().

◆ nbinsy_

const size_t TotemT2Segmentation::nbinsy_
private

Definition at line 32 of file TotemT2Segmentation.h.

Referenced by computeBins(), and fill().