CMS 3D CMS Logo

SiStripHashedDetId.cc
Go to the documentation of this file.
5 #include <iomanip>
6 #include <iostream>
7 #include <sstream>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
12 //
13 SiStripHashedDetId::SiStripHashedDetId(const std::vector<uint32_t> &raw_ids)
14  : detIds_(), id_(0), iter_(detIds_.begin()) {
15  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
16  << " Constructing object...";
17  init(raw_ids);
18 }
19 
20 // -----------------------------------------------------------------------------
21 //
22 SiStripHashedDetId::SiStripHashedDetId(const std::vector<DetId> &det_ids) : 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 }
33 
34 // -----------------------------------------------------------------------------
35 //
36 SiStripHashedDetId::SiStripHashedDetId(const SiStripHashedDetId &input) : 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 }
42 
43 // -----------------------------------------------------------------------------
44 //
45 SiStripHashedDetId::SiStripHashedDetId() : detIds_(), id_(0), iter_(detIds_.begin()) {
46  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
47  << " Constructing object...";
48 }
49 
50 // -----------------------------------------------------------------------------
51 //
53  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
54  << " Destructing object...";
55  detIds_.clear();
56 }
57 
58 // -----------------------------------------------------------------------------
59 //
60 void SiStripHashedDetId::init(const std::vector<uint32_t> &raw_ids) {
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 }
82 
83 // -----------------------------------------------------------------------------
84 //
85 std::ostream &operator<<(std::ostream &os, const SiStripHashedDetId &input) {
86  std::stringstream ss;
87  ss << "[SiStripHashedDetId::" << __func__ << "]"
88  << " Found " << input.end() - input.begin() << " entries in DetId hash map:" << std::endl;
90  for (; iter != input.end(); ++iter) {
91  ss << " Index: " << std::dec << std::setw(5) << std::setfill(' ') << iter - input.begin() << " DetId: 0x"
92  << std::hex << std::setw(8) << std::setfill('0') << *iter << std::endl;
93  }
94  os << ss.str();
95  return os;
96 }
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
sistrip::invalid32_
static const uint32_t invalid32_
Definition: Constants.h:15
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
SiStripHashedDetId::~SiStripHashedDetId
~SiStripHashedDetId()
Definition: SiStripHashedDetId.cc:52
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
SiStripHashedDetId::iter_
const_iterator iter_
Definition: SiStripHashedDetId.h:67
SiStripHashedDetId.h
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
SiStripHashedDetId
Provides dense hash map in place of DetId.
Definition: SiStripHashedDetId.h:19
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
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
SiStripHashedDetId::init
void init(const std::vector< uint32_t > &)
Definition: SiStripHashedDetId.cc:60
SiStripHashedDetId::SiStripHashedDetId
SiStripHashedDetId()
Definition: SiStripHashedDetId.cc:45
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
DetId.h
operator<<
std::ostream & operator<<(std::ostream &os, const SiStripHashedDetId &input)
Definition: SiStripHashedDetId.cc:85
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
StripSubdetector.h
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17