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 //
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 //
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 }
std::vector< uint32_t >::const_iterator const_iterator
def copy(args, dbName)
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator iter_
sistrip classes
Provides dense hash map in place of DetId.
static std::string const input
Definition: EdmProvDump.cc:48
const_iterator begin() const
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:41
std::vector< uint32_t > detIds_
#define LogTrace(id)
Definition: DetId.h:18
const_iterator end() const
static const uint16_t invalid_
Definition: Constants.h:16
#define begin
Definition: vmac.h:32
void init(const std::vector< uint32_t > &)
std::ostream & operator<<(std::ostream &os, const SiStripHashedDetId &input)
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39