CMS 3D CMS Logo

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

Provides dense hash map in place of DetId. More...

#include <SiStripHashedDetId.h>

Public Types

typedef std::vector< uint32_t >::const_iterator const_iterator
 
typedef std::vector< uint32_t >::iterator iterator
 

Public Member Functions

const_iterator begin () const
 
const_iterator end () const
 
uint32_t hashedIndex (uint32_t det_id)
 
SiStripHashedDetIdoperator= (const SiStripHashedDetId &other)
 
 SiStripHashedDetId (const std::vector< uint32_t > &)
 
 SiStripHashedDetId (const std::vector< DetId > &)
 
 SiStripHashedDetId (const SiStripHashedDetId &)
 
 SiStripHashedDetId ()
 
const size_t size () const
 
uint32_t unhashIndex (uint32_t hashed_index) const
 
 ~SiStripHashedDetId ()
 

Private Member Functions

void init (const std::vector< uint32_t > &)
 

Private Attributes

std::vector< uint32_t > detIds_
 
uint32_t id_
 
const_iterator iter_
 

Detailed Description

Provides dense hash map in place of DetId.

Author
R.Bainbridge

Definition at line 19 of file SiStripHashedDetId.h.

Member Typedef Documentation

◆ const_iterator

typedef std::vector<uint32_t>::const_iterator SiStripHashedDetId::const_iterator

Definition at line 57 of file SiStripHashedDetId.h.

◆ iterator

typedef std::vector<uint32_t>::iterator SiStripHashedDetId::iterator

Definition at line 59 of file SiStripHashedDetId.h.

Constructor & Destructor Documentation

◆ SiStripHashedDetId() [1/4]

SiStripHashedDetId::SiStripHashedDetId ( const std::vector< uint32_t > &  raw_ids)

Constructor taking raw DetIds as input.

Definition at line 13 of file SiStripHashedDetId.cc.

References init(), LogTrace, and sistrip::mlCabling_.

14  : detIds_(), id_(0), iter_(detIds_.begin()) {
15  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
16  << " Constructing object...";
17  init(raw_ids);
18 }
const_iterator iter_
#define LogTrace(id)
static const char mlCabling_[]
std::vector< uint32_t > detIds_
void init(const std::vector< uint32_t > &)

◆ SiStripHashedDetId() [2/4]

SiStripHashedDetId::SiStripHashedDetId ( const std::vector< DetId > &  det_ids)

Constructor taking DetIds as input.

Definition at line 22 of file SiStripHashedDetId.cc.

References detIds_, init(), LogTrace, and sistrip::mlCabling_.

22  : detIds_(), id_(0), iter_(detIds_.begin()) {
23  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
24  << " Constructing object...";
25  detIds_.clear();
26  detIds_.reserve(16000);
27  std::vector<DetId>::const_iterator iter = det_ids.begin();
28  for (; iter != det_ids.end(); ++iter) {
29  detIds_.push_back(iter->rawId());
30  }
31  init(detIds_);
32 }
const_iterator iter_
#define LogTrace(id)
static const char mlCabling_[]
std::vector< uint32_t > detIds_
void init(const std::vector< uint32_t > &)

◆ SiStripHashedDetId() [3/4]

SiStripHashedDetId::SiStripHashedDetId ( const SiStripHashedDetId input)

Copy constructor.

Definition at line 36 of file SiStripHashedDetId.cc.

References filterCSVwithJSON::copy, init(), input, LogTrace, and sistrip::mlCabling_.

36  : detIds_(), id_(0), iter_(detIds_.begin()) {
37  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
38  << " Constructing object...";
39 
40  // auxilliary vector to store the list of raw IDs
41  std::vector<uint32_t> raw_ids;
42  raw_ids.reserve(input.size());
43 
44  // Copy elements from input vector to detIds_ vector
45  std::copy(input.begin(), input.end(), std::back_inserter(raw_ids));
46 
47  init(raw_ids);
48 }
const_iterator iter_
#define LogTrace(id)
static std::string const input
Definition: EdmProvDump.cc:50
static const char mlCabling_[]
std::vector< uint32_t > detIds_
void init(const std::vector< uint32_t > &)

◆ SiStripHashedDetId() [4/4]

SiStripHashedDetId::SiStripHashedDetId ( )

Public default constructor.

Definition at line 52 of file SiStripHashedDetId.cc.

References LogTrace, and sistrip::mlCabling_.

52  : detIds_(), id_(0), iter_(detIds_.begin()) {
53  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
54  << " Constructing object...";
55 }
const_iterator iter_
#define LogTrace(id)
static const char mlCabling_[]
std::vector< uint32_t > detIds_

◆ ~SiStripHashedDetId()

SiStripHashedDetId::~SiStripHashedDetId ( )

Default destructor.

Definition at line 59 of file SiStripHashedDetId.cc.

References detIds_, LogTrace, and sistrip::mlCabling_.

59  {
60  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
61  << " Destructing object...";
62  detIds_.clear();
63 }
#define LogTrace(id)
static const char mlCabling_[]
std::vector< uint32_t > detIds_

Member Function Documentation

◆ begin()

SiStripHashedDetId::const_iterator SiStripHashedDetId::begin ( ) const
inline

Returns DetId object for given hashed index.

Definition at line 113 of file SiStripHashedDetId.h.

References detIds_.

Referenced by SiStripLorentzAnglePCLMonitor::bookHistograms(), hashedIndex(), operator=(), and unhashIndex().

113 { return detIds_.begin(); }
std::vector< uint32_t > detIds_

◆ end()

SiStripHashedDetId::const_iterator SiStripHashedDetId::end ( ) const
inline

◆ hashedIndex()

uint32_t SiStripHashedDetId::hashedIndex ( uint32_t  det_id)
inline

Returns hashed index for given DetId.

Definition at line 89 of file SiStripHashedDetId.h.

References begin(), end(), spr::find(), id_, sistrip::invalid32_, and iter_.

Referenced by SiStripLorentzAnglePCLMonitor::analyze(), and SiStripLorentzAnglePCLMonitor::bookHistograms().

89  {
90  const_iterator iter = end();
91  if (det_id > id_) {
92  iter = find(iter_, end(), det_id);
93  } else {
94  iter = find(begin(), iter_, det_id);
95  }
96  if (iter != end()) {
97  id_ = det_id;
98  iter_ = iter;
99  return iter - begin();
100  } else {
101  id_ = 0;
102  iter_ = begin();
103  return sistrip::invalid32_;
104  }
105 }
std::vector< uint32_t >::const_iterator const_iterator
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator iter_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator end() const
const_iterator begin() const

◆ init()

void SiStripHashedDetId::init ( const std::vector< uint32_t > &  raw_ids)
private

Definition at line 67 of file SiStripHashedDetId.cc.

References DetId::det(), detIds_, id_, sistrip::invalid32_, sistrip::invalid_, iter_, sistrip::mlCabling_, jetUpdater_cfi::sort, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, and DetId::Tracker.

Referenced by operator=(), and SiStripHashedDetId().

67  {
68  detIds_.clear();
69  detIds_.reserve(16000);
70  const_iterator iter = raw_ids.begin();
71  for (; iter != raw_ids.end(); ++iter) {
72  DetId detectorId = DetId(*iter);
73  if (*iter != sistrip::invalid32_ && *iter != sistrip::invalid_ && detectorId.det() == DetId::Tracker &&
74  (detectorId.subdetId() == StripSubdetector::TID || detectorId.subdetId() == StripSubdetector::TIB ||
75  detectorId.subdetId() == StripSubdetector::TOB || detectorId.subdetId() == StripSubdetector::TEC)) {
76  detIds_.push_back(*iter);
77  } else {
78  edm::LogWarning(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
79  << " DetId 0x" << std::hex << std::setw(8) << std::setfill('0') << *iter
80  << " is not from the strip tracker!";
81  }
82  }
83  if (!detIds_.empty()) {
84  std::sort(detIds_.begin(), detIds_.end());
85  id_ = detIds_.front();
86  iter_ = detIds_.begin();
87  }
88 }
static constexpr auto TEC
std::vector< uint32_t >::const_iterator const_iterator
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator iter_
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
static const char mlCabling_[]
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
std::vector< uint32_t > detIds_
Definition: DetId.h:17
static constexpr auto TIB
static const uint16_t invalid_
Definition: Constants.h:16
Log< level::Warning, false > LogWarning
static constexpr auto TID

◆ operator=()

SiStripHashedDetId& SiStripHashedDetId::operator= ( const SiStripHashedDetId other)
inline

Assignment operator.

Definition at line 33 of file SiStripHashedDetId.h.

References begin(), filterCSVwithJSON::copy, id_, init(), iter_, and trackingPlots::other.

33  {
34  if (this != &other) { // Self-assignment check
35  this->id_ = 0;
36  this->iter_ = other.begin();
37  // auxilliary vector to store the list of raw IDs
38  std::vector<uint32_t> raw_ids;
39  raw_ids.reserve(other.size());
40 
41  // Copy elements from input vector to detIds_ vector
42  std::copy(other.begin(), other.end(), std::back_inserter(raw_ids));
43 
44  this->init(raw_ids);
45  }
46  return *this;
47  }
const_iterator iter_
void init(const std::vector< uint32_t > &)
const_iterator begin() const

◆ size()

const size_t SiStripHashedDetId::size ( void  ) const
inline

◆ unhashIndex()

uint32_t SiStripHashedDetId::unhashIndex ( uint32_t  hashed_index) const
inline

Returns raw (32-bit) DetId for given hashed index.

Definition at line 106 of file SiStripHashedDetId.h.

References begin(), detIds_, end(), and sistrip::invalid32_.

106  {
107  if (hashed_index < static_cast<uint32_t>(end() - begin())) {
108  return detIds_[hashed_index];
109  } else {
110  return sistrip::invalid32_;
111  }
112 }
static const uint32_t invalid32_
Definition: Constants.h:15
std::vector< uint32_t > detIds_
const_iterator end() const
const_iterator begin() const

Member Data Documentation

◆ detIds_

std::vector<uint32_t> SiStripHashedDetId::detIds_
private

Sorted list of all silicon strip tracker DetIds.

Definition at line 82 of file SiStripHashedDetId.h.

Referenced by begin(), end(), init(), SiStripHashedDetId(), size(), unhashIndex(), and ~SiStripHashedDetId().

◆ id_

uint32_t SiStripHashedDetId::id_
private

Definition at line 84 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), init(), and operator=().

◆ iter_

const_iterator SiStripHashedDetId::iter_
private

Definition at line 86 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), init(), and operator=().