CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 (const std::vector< uint32_t > &)
 
 SiStripHashedDetId (const std::vector< DetId > &)
 
 SiStripHashedDetId (const SiStripHashedDetId &)
 
 SiStripHashedDetId ()
 
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

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

Definition at line 40 of file SiStripHashedDetId.h.

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

Definition at line 42 of file SiStripHashedDetId.h.

Constructor & Destructor Documentation

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::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::SiStripHashedDetId ( const SiStripHashedDetId input)

Copy constructor.

Definition at line 36 of file SiStripHashedDetId.cc.

References begin(), filterCSVwithJSON::copy, detIds_, end(), LogTrace, and sistrip::mlCabling_.

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 }
const_iterator iter_
#define LogTrace(id)
const_iterator begin() const
static const char mlCabling_[]
std::vector< uint32_t > detIds_
const_iterator end() const
SiStripHashedDetId::SiStripHashedDetId ( )

Public default constructor.

Definition at line 45 of file SiStripHashedDetId.cc.

References LogTrace, and sistrip::mlCabling_.

45  : detIds_(), id_(0), iter_(detIds_.begin()) {
46  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
47  << " Constructing object...";
48 }
const_iterator iter_
#define LogTrace(id)
static const char mlCabling_[]
std::vector< uint32_t > detIds_
SiStripHashedDetId::~SiStripHashedDetId ( )

Default destructor.

Definition at line 52 of file SiStripHashedDetId.cc.

References detIds_, LogTrace, and sistrip::mlCabling_.

52  {
53  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
54  << " Destructing object...";
55  detIds_.clear();
56 }
#define LogTrace(id)
static const char mlCabling_[]
std::vector< uint32_t > detIds_

Member Function Documentation

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

Returns DetId object for given hashed index.

Definition at line 94 of file SiStripHashedDetId.h.

References detIds_.

Referenced by hashedIndex(), operator<<(), SiStripHashedDetId(), and unhashIndex().

94 { return detIds_.begin(); }
std::vector< uint32_t > detIds_
SiStripHashedDetId::const_iterator SiStripHashedDetId::end ( ) const
inline

Definition at line 95 of file SiStripHashedDetId.h.

References detIds_.

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

95 { return detIds_.end(); }
std::vector< uint32_t > detIds_
uint32_t SiStripHashedDetId::hashedIndex ( uint32_t  det_id)
inline

Returns hashed index for given DetId.

Definition at line 70 of file SiStripHashedDetId.h.

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

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 }
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 begin() const
const_iterator end() const
void SiStripHashedDetId::init ( const std::vector< uint32_t > &  raw_ids)
private

Definition at line 60 of file SiStripHashedDetId.cc.

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

Referenced by SiStripHashedDetId().

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 }
static constexpr auto TEC
std::vector< uint32_t >::const_iterator const_iterator
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator iter_
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
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
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.

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

87  {
88  if (hashed_index < static_cast<uint32_t>(end() - begin())) {
89  return detIds_[hashed_index];
90  } else {
91  return sistrip::invalid32_;
92  }
93 }
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator begin() const
std::vector< uint32_t > detIds_
const_iterator end() const

Member Data Documentation

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

uint32_t SiStripHashedDetId::id_
private

Definition at line 65 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), and init().

const_iterator SiStripHashedDetId::iter_
private

Definition at line 67 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), and init().