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 
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 }
49 
50 // -----------------------------------------------------------------------------
51 //
52 SiStripHashedDetId::SiStripHashedDetId() : detIds_(), id_(0), iter_(detIds_.begin()) {
53  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
54  << " Constructing object...";
55 }
56 
57 // -----------------------------------------------------------------------------
58 //
60  LogTrace(mlCabling_) << "[SiStripHashedDetId::" << __func__ << "]"
61  << " Destructing object...";
62  detIds_.clear();
63 }
64 
65 // -----------------------------------------------------------------------------
66 //
67 void SiStripHashedDetId::init(const std::vector<uint32_t> &raw_ids) {
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 }
89 
90 // -----------------------------------------------------------------------------
91 //
92 std::ostream &operator<<(std::ostream &os, const SiStripHashedDetId &input) {
93  std::stringstream ss;
94  ss << "[SiStripHashedDetId::" << __func__ << "]"
95  << " Found " << input.end() - input.begin() << " entries in DetId hash map:" << std::endl;
97  for (; iter != input.end(); ++iter) {
98  ss << " Index: " << std::dec << std::setw(5) << std::setfill(' ') << iter - input.begin() << " DetId: 0x"
99  << std::hex << std::setw(8) << std::setfill('0') << *iter << std::endl;
100  }
101  os << ss.str();
102  return os;
103 }
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
sistrip classes
#define LogTrace(id)
Provides dense hash map in place of DetId.
static std::string const input
Definition: EdmProvDump.cc:50
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
void init(const std::vector< uint32_t > &)
static constexpr auto TID
std::ostream & operator<<(std::ostream &os, const SiStripHashedDetId &input)