CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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)
 
 SiStripHashedDetId ()
 
 SiStripHashedDetId (const SiStripHashedDetId &)
 
 SiStripHashedDetId (const std::vector< DetId > &)
 
 SiStripHashedDetId (const std::vector< uint32_t > &)
 
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 40 of file SiStripHashedDetId.h.

◆ iterator

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

Definition at line 42 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.

14  : detIds_(), id_(0), iter_(detIds_.begin()) {
15  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
16  << " Constructing object...";
17  init(raw_ids);
18 }

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

◆ SiStripHashedDetId() [2/4]

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

Constructor taking DetIds as input.

Definition at line 22 of file SiStripHashedDetId.cc.

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 }

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

◆ SiStripHashedDetId() [3/4]

SiStripHashedDetId::SiStripHashedDetId ( const SiStripHashedDetId input)

Copy constructor.

Definition at line 36 of file SiStripHashedDetId.cc.

36  : detIds_(), id_(0), iter_(detIds_.begin()) {
37  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
38  << " Constructing object...";
39  detIds_.reserve(input.end() - input.begin());
40  std::copy(input.begin(), input.end(), detIds_.begin());
41 }

References filterCSVwithJSON::copy, detIds_, input, LogTrace, and sistrip::mlCabling_.

◆ SiStripHashedDetId() [4/4]

SiStripHashedDetId::SiStripHashedDetId ( )

Public default constructor.

Definition at line 45 of file SiStripHashedDetId.cc.

45  : detIds_(), id_(0), iter_(detIds_.begin()) {
46  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
47  << " Constructing object...";
48 }

References LogTrace, and sistrip::mlCabling_.

◆ ~SiStripHashedDetId()

SiStripHashedDetId::~SiStripHashedDetId ( )

Default destructor.

Definition at line 52 of file SiStripHashedDetId.cc.

52  {
53  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
54  << " Destructing object...";
55  detIds_.clear();
56 }

References detIds_, LogTrace, and sistrip::mlCabling_.

Member Function Documentation

◆ begin()

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

Returns DetId object for given hashed index.

Definition at line 94 of file SiStripHashedDetId.h.

94 { return detIds_.begin(); }

References detIds_.

Referenced by hashedIndex(), and unhashIndex().

◆ end()

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

Definition at line 95 of file SiStripHashedDetId.h.

95 { return detIds_.end(); }

References detIds_.

Referenced by Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), hashedIndex(), and unhashIndex().

◆ hashedIndex()

uint32_t SiStripHashedDetId::hashedIndex ( uint32_t  det_id)
inline

Returns hashed index for given DetId.

Definition at line 70 of file SiStripHashedDetId.h.

70  {
71  const_iterator iter = end();
72  if (det_id > id_) {
73  iter = find(iter_, end(), det_id);
74  } else {
75  iter = find(begin(), iter_, det_id);
76  }
77  if (iter != end()) {
78  id_ = det_id;
79  iter_ = iter;
80  return iter - begin();
81  } else {
82  id_ = 0;
83  iter_ = begin();
84  return sistrip::invalid32_;
85  }
86 }

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

◆ init()

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

Definition at line 60 of file SiStripHashedDetId.cc.

60  {
61  detIds_.clear();
62  detIds_.reserve(16000);
63  const_iterator iter = raw_ids.begin();
64  for (; iter != raw_ids.end(); ++iter) {
65  DetId detectorId = DetId(*iter);
66  if (*iter != sistrip::invalid32_ && *iter != sistrip::invalid_ && detectorId.det() == DetId::Tracker &&
67  (detectorId.subdetId() == StripSubdetector::TID || detectorId.subdetId() == StripSubdetector::TIB ||
68  detectorId.subdetId() == StripSubdetector::TOB || detectorId.subdetId() == StripSubdetector::TEC)) {
69  detIds_.push_back(*iter);
70  } else {
71  edm::LogWarning(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
72  << " DetId 0x" << std::hex << std::setw(8) << std::setfill('0') << *iter
73  << " is not from the strip tracker!";
74  }
75  }
76  if (!detIds_.empty()) {
77  std::sort(detIds_.begin(), detIds_.end());
78  id_ = detIds_.front();
79  iter_ = detIds_.begin();
80  }
81 }

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 SiStripHashedDetId().

◆ unhashIndex()

uint32_t SiStripHashedDetId::unhashIndex ( uint32_t  hashed_index) const
inline

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

Definition at line 87 of file SiStripHashedDetId.h.

87  {
88  if (hashed_index < static_cast<uint32_t>(end() - begin())) {
89  return detIds_[hashed_index];
90  } else {
91  return sistrip::invalid32_;
92  }
93 }

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

Member Data Documentation

◆ detIds_

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

Sorted list of all silicon strip tracker DetIds.

Definition at line 63 of file SiStripHashedDetId.h.

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

◆ id_

uint32_t SiStripHashedDetId::id_
private

Definition at line 65 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), and init().

◆ iter_

const_iterator SiStripHashedDetId::iter_
private

Definition at line 67 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), and init().

input
static const std::string input
Definition: EdmProvDump.cc:48
sistrip::invalid32_
static const uint32_t invalid32_
Definition: Constants.h:15
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
SiStripHashedDetId::detIds_
std::vector< uint32_t > detIds_
Definition: SiStripHashedDetId.h:63
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
SiStripHashedDetId::const_iterator
std::vector< uint32_t >::const_iterator const_iterator
Definition: SiStripHashedDetId.h:40
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DetId
Definition: DetId.h:17
SiStripHashedDetId::iter_
const_iterator iter_
Definition: SiStripHashedDetId.h:67
SiStripHashedDetId::begin
const_iterator begin() const
Definition: SiStripHashedDetId.h:94
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
SiStripHashedDetId::id_
uint32_t id_
Definition: SiStripHashedDetId.h:65
sistrip::mlCabling_
static const char mlCabling_[]
Definition: ConstantsForLogger.h:14
DetId::Tracker
Definition: DetId.h:25
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
SiStripHashedDetId::end
const_iterator end() const
Definition: SiStripHashedDetId.h:95
SiStripHashedDetId::init
void init(const std::vector< uint32_t > &)
Definition: SiStripHashedDetId.cc:60
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17