CMS 3D CMS Logo

ClusterCollectionFP420.cc
Go to the documentation of this file.
1 // File: ClusterCollectionFP420.cc
3 // Date: 12.2006
4 // Description: ClusterCollectionFP420 for FP420
5 // Modifications:
8 #include <iostream>
9 #include <algorithm>
10 using namespace std;
11 //#define mydigidebug
12 
14  // put in RecHits of detID
15 
16  // store size of vector before put
18 
19  // put in ClusterFP420s from input
20  bool first = true;
21 
22  // fill input in temporary vector for sorting
23  std::vector<ClusterFP420> temporary;
26 #ifdef mydigidebug
27  std::cout << " !!!!!!!!!!!!!!!! ClusterCollectionFP420:: !!!! put !!!! start " << std::endl;
28 #endif
29  for (; sort_begin != sort_end; ++sort_begin) {
30 #ifdef mydigidebug
31  std::cout << "put: temporary.push_back " << std::endl;
32 #endif
33  temporary.push_back(*sort_begin);
34  }
35  std::sort(temporary.begin(), temporary.end());
36 
37  // iterators over input
38  ClusterCollectionFP420::ContainerIterator begin = temporary.begin();
40  for (; begin != end; ++begin) {
41  container_.push_back(*begin);
42  if (first) {
43  inputRange.first = container_.size() - 1;
44  // inputRange.first = container_.size();
45  first = false;
46  }
47  }
48 
49  // since we start from 0, then the last element will be size-1
50  if (!container_.empty()) {
51  inputRange.second = container_.size() - 1;
52  } else {
53  inputRange.first = container_.size();
54  inputRange.second = container_.size();
55  }
56  //inputRange.second = container_.size()-1;
58 
59 #ifdef mydigidebug
60  std::cout << "put: container_.size() = " << container_.size() << std::endl;
61  std::cout << "put: inputRange.first = " << inputRange.first << std::endl;
62  std::cout << "put: inputRange.second = " << inputRange.second << std::endl;
63 #endif
64 
65  // fill map
66  map_[detID] = inputRange;
67 }
68 
70  // get RecHits of detID
71 
72 #ifdef mydigidebug
73  std::cout << "ClusterCollectionFP420::get:detID= " << detID << std::endl;
74 #endif
75  ClusterCollectionFP420::RegistryIterator returnIndex = map_.find(detID);
76  ClusterCollectionFP420::IndexRange returnIndexRange = returnIndex->second;
77 #ifdef mydigidebug
78  std::cout << "ClusterCollectionFP420::get1: returnIndexRange.first= " << returnIndexRange.first << std::endl;
79  std::cout << "ClusterCollectionFP420::get1: returnIndexRange.second= " << returnIndexRange.second << std::endl;
80 #endif
81 
83  returnRange.first = container_.begin() + returnIndexRange.first;
84  if (returnIndexRange.second != 0) {
85  returnRange.second = container_.begin() + returnIndexRange.second + 1;
86  } else {
87  returnRange.second = container_.begin() + returnIndexRange.second;
88  }
89 #ifdef mydigidebug
90  std::cout << "ClusterCollectionFP420::get2: container_.size() = " << container_.size() << std::endl;
91  std::cout << "ClusterCollectionFP420::get2: returnIndexRange.first= " << returnIndexRange.first << std::endl;
92  std::cout << "ClusterCollectionFP420::get2: returnIndexRange.second= " << returnIndexRange.second << std::endl;
93 #endif
94  return returnRange;
95 }
96 
97 void ClusterCollectionFP420::clear() { container_.clear(); }
100 
101  std::vector<ClusterFP420> temporary;
104  for (; sort_begin != sort_end; ++sort_begin) {
105  temporary.push_back(*sort_begin);
106  }
107  std::sort(temporary.begin(), temporary.end());
108 
109  // temporary.clear();
110  ClusterCollectionFP420::ContainerIterator begin = temporary.begin();
112  for (; begin != end; ++begin) {
113  container_.push_back(*begin);
114  }
115  //container_.clear();
116  inputRange.first = container_.size() - container_.size();
117  inputRange.second = container_.size() - container_.size();
118 
119 #ifdef mydigidebug
120  std::cout << "putclear: container_.size() = " << container_.size() << std::endl;
121  std::cout << "putclear: inputRange.first = " << inputRange.first << std::endl;
122  std::cout << "putclear: inputRange.second = " << inputRange.second << std::endl;
123 #endif
124 
125  map_[detID] = inputRange;
126 }
127 
128 const std::vector<unsigned int> ClusterCollectionFP420::detIDs() const {
129  // returns vector of detIDs in map
130 
131 #ifdef mydigidebug
132  std::cout << "ClusterCollectionFP420::detIDs:start " << std::endl;
133 #endif
134  ClusterCollectionFP420::RegistryIterator begin = map_.begin();
136 
137  std::vector<unsigned int> output;
138 
139  for (; begin != end; ++begin) {
140  output.push_back(begin->first);
141  }
142 
143  return output;
144 }
std::pair< unsigned int, unsigned int > IndexRange
std::vector< ClusterFP420 >::const_iterator ContainerIterator
void put(Range input, unsigned int detID)
static std::string const input
Definition: EdmProvDump.cc:47
std::map< unsigned int, IndexRange >::const_iterator RegistryIterator
const Range get(unsigned int detID) const
void putclear(Range input, unsigned int detID)
std::pair< ContainerIterator, ContainerIterator > Range
const std::vector< unsigned int > detIDs() const