CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripHashedDetId.cc
Go to the documentation of this file.
5 #include <iostream>
6 #include <iomanip>
7 #include <sstream>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
12 //
13 SiStripHashedDetId::SiStripHashedDetId( const std::vector<uint32_t>& raw_ids )
14  : detIds_(),
15  id_(0),
16  iter_(detIds_.begin())
17 {
19  << "[SiStripHashedDetId::" << __func__ << "]"
20  << " Constructing object...";
21  init(raw_ids);
22 }
23 
24 // -----------------------------------------------------------------------------
25 //
26 SiStripHashedDetId::SiStripHashedDetId( const std::vector<DetId>& det_ids )
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 }
42 
43 // -----------------------------------------------------------------------------
44 //
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 }
56 
57 // -----------------------------------------------------------------------------
58 //
60  : detIds_(),
61  id_(0),
62  iter_(detIds_.begin())
63 {
65  << "[SiStripHashedDetId::" << __func__ << "]"
66  << " Constructing object...";
67 }
68 
69 // -----------------------------------------------------------------------------
70 //
73  << "[SiStripHashedDetId::" << __func__ << "]"
74  << " Destructing object...";
75  detIds_.clear();
76 }
77 
78 // -----------------------------------------------------------------------------
79 //
80 void SiStripHashedDetId::init( const std::vector<uint32_t>& raw_ids ) {
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 }
108 
109 // -----------------------------------------------------------------------------
110 //
111 std::ostream& operator<< ( std::ostream& os, const SiStripHashedDetId& input ) {
112  std::stringstream ss;
113  ss << "[SiStripHashedDetId::" << __func__ << "]"
114  << " Found " << input.end() - input.begin()
115  << " entries in DetId hash map:"
116  << std::endl;
118  for ( ; iter != input.end(); ++iter ) {
119  ss << " Index: "
120  << std::dec << std::setw(5) << std::setfill(' ')
121  << iter - input.begin()
122  << " DetId: 0x"
123  << std::hex << std::setw(8) << std::setfill('0')
124  << *iter << std::endl;
125  }
126  os << ss.str();
127  return os;
128 }
std::vector< uint32_t >::const_iterator const_iterator
static const uint32_t invalid32_
Definition: Constants.h:15
const_iterator iter_
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
Provides dense hash map in place of DetId.
static std::string const input
Definition: EdmProvDump.cc:43
const_iterator begin() const
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
#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:30
void init(const std::vector< uint32_t > &)
Detector det() const
get the detector field from this detid
Definition: DetId.h:35