CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 42 of file SiStripHashedDetId.h.

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

Definition at line 44 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_(),
15  id_(0),
16  iter_(detIds_.begin())
17 {
19  << "[SiStripHashedDetId::" << __func__ << "]"
20  << " Constructing object...";
21  init(raw_ids);
22 }
const_iterator iter_
static const char mlCabling_[]
std::vector< uint32_t > detIds_
#define LogTrace(id)
void init(const std::vector< uint32_t > &)
SiStripHashedDetId::SiStripHashedDetId ( const std::vector< DetId > &  det_ids)

Constructor taking DetIds as input.

Definition at line 26 of file SiStripHashedDetId.cc.

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

27  : detIds_(),
28  id_(0),
29  iter_(detIds_.begin())
30 {
32  << "[SiStripHashedDetId::" << __func__ << "]"
33  << " Constructing object...";
34  detIds_.clear();
35  detIds_.reserve(16000);
36  std::vector<DetId>::const_iterator iter = det_ids.begin();
37  for ( ; iter != det_ids.end(); ++iter ) {
38  detIds_.push_back( iter->rawId() );
39  }
40  init(detIds_);
41 }
const_iterator iter_
static const char mlCabling_[]
std::vector< uint32_t > detIds_
#define LogTrace(id)
void init(const std::vector< uint32_t > &)
SiStripHashedDetId::SiStripHashedDetId ( const SiStripHashedDetId input)

Copy constructor.

Definition at line 45 of file SiStripHashedDetId.cc.

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

46  : detIds_(),
47  id_(0),
48  iter_(detIds_.begin())
49 {
51  << "[SiStripHashedDetId::" << __func__ << "]"
52  << " Constructing object...";
53  detIds_.reserve( input.end() - input.begin() );
54  std::copy( input.begin(), input.end(), detIds_.begin() );
55 }
const_iterator iter_
const_iterator begin() const
static const char mlCabling_[]
std::vector< uint32_t > detIds_
#define LogTrace(id)
const_iterator end() const
SiStripHashedDetId::SiStripHashedDetId ( )

Public default constructor.

Definition at line 59 of file SiStripHashedDetId.cc.

References LogTrace, and sistrip::mlCabling_.

60  : detIds_(),
61  id_(0),
62  iter_(detIds_.begin())
63 {
65  << "[SiStripHashedDetId::" << __func__ << "]"
66  << " Constructing object...";
67 }
const_iterator iter_
static const char mlCabling_[]
std::vector< uint32_t > detIds_
#define LogTrace(id)
SiStripHashedDetId::~SiStripHashedDetId ( )

Default destructor.

Definition at line 71 of file SiStripHashedDetId.cc.

References detIds_, LogTrace, and sistrip::mlCabling_.

71  {
73  << "[SiStripHashedDetId::" << __func__ << "]"
74  << " Destructing object...";
75  detIds_.clear();
76 }
static const char mlCabling_[]
std::vector< uint32_t > detIds_
#define LogTrace(id)

Member Function Documentation

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

Returns DetId object for given hashed index.

Definition at line 92 of file SiStripHashedDetId.h.

References detIds_.

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

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

Definition at line 93 of file SiStripHashedDetId.h.

References detIds_.

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

93 { 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 74 of file SiStripHashedDetId.h.

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

74  {
75  const_iterator iter = end();
76  if ( det_id > id_ ) { iter = find( iter_, end(), det_id ); }
77  else { iter = find( begin(), iter_, det_id ); }
78  if ( iter != end() ) {
79  id_ = det_id;
80  iter_ = iter;
81  return iter-begin();
82  } else {
83  id_ = 0;
84  iter_ = begin();
85  return sistrip::invalid32_;
86  }
87 }
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:7
const_iterator begin() const
const_iterator end() const
void SiStripHashedDetId::init ( const std::vector< uint32_t > &  raw_ids)
private

Definition at line 80 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().

80  {
81  detIds_.clear();
82  detIds_.reserve(16000);
83  const_iterator iter = raw_ids.begin();
84  for ( ; iter != raw_ids.end(); ++iter ) {
85  DetId detectorId=DetId(*iter);
86  if ( *iter != sistrip::invalid32_ &&
87  *iter != sistrip::invalid_ &&
88  detectorId.det() == DetId::Tracker &&
89  ( detectorId.subdetId() == StripSubdetector::TID ||
90  detectorId.subdetId() == StripSubdetector::TIB ||
91  detectorId.subdetId() == StripSubdetector::TOB ||
92  detectorId.subdetId() == StripSubdetector::TEC ) ) {
93  detIds_.push_back(*iter);
94  } else {
96  << "[SiStripHashedDetId::" << __func__ << "]"
97  << " DetId 0x"
98  << std::hex << std::setw(8) << std::setfill('0') << *iter
99  << " is not from the strip tracker!";
100  }
101  }
102  if ( !detIds_.empty() ) {
103  std::sort( detIds_.begin(), detIds_.end() );
104  id_ = detIds_.front();
105  iter_ = detIds_.begin();
106  }
107 }
std::vector< uint32_t >::const_iterator const_iterator
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator iter_
static const char mlCabling_[]
std::vector< uint32_t > detIds_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
static const uint16_t invalid_
Definition: Constants.h:16
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
uint32_t SiStripHashedDetId::unhashIndex ( uint32_t  hashed_index) const
inline

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

Definition at line 88 of file SiStripHashedDetId.h.

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

88  {
89  if ( hashed_index < static_cast<uint32_t>(end()-begin()) ) { return detIds_[hashed_index]; }
90  else { return sistrip::invalid32_; }
91 }
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 66 of file SiStripHashedDetId.h.

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

uint32_t SiStripHashedDetId::id_
private

Definition at line 68 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), and init().

const_iterator SiStripHashedDetId::iter_
private

Definition at line 70 of file SiStripHashedDetId.h.

Referenced by hashedIndex(), and init().