CMS 3D CMS Logo

TrackCollectionFP420.cc
Go to the documentation of this file.
1 // File: TrackCollectionFP420.cc
3 // Date: 12.2006
4 // Description: TrackCollectionFP420 for FP420
5 // Modifications:
8 #include <iostream>
9 #include <algorithm>
10 using namespace std;
11 //#define mydigidebug
12 
14  // put in RecHits of stationID
15 
16  // store size of vector before put
18 
19  // put in TrackFP420s from input
20  bool first = true;
21 
22  // fill input in temporary vector for sorting
23  std::vector<TrackFP420> temporary;
24  TrackCollectionFP420::ContainerIterator sort_begin = input.first;
25  TrackCollectionFP420::ContainerIterator sort_end = input.second;
26 #ifdef mydigidebug
27  std::cout << " !!!!!!!!!!!!!!!! TrackCollectionFP420:: !!!! 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
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_[stationID] = inputRange;
67 }
68 
69 const TrackCollectionFP420::Range TrackCollectionFP420::get(unsigned int stationID) const {
70  // get RecHits of stationID
71 
72 #ifdef mydigidebug
73  std::cout << "TrackCollectionFP420::get:stationID= " << stationID << std::endl;
74 #endif
75  TrackCollectionFP420::RegistryIterator returnIndex = map_.find(stationID);
76  TrackCollectionFP420::IndexRange returnIndexRange = returnIndex->second;
77 #ifdef mydigidebug
78  std::cout << "TrackCollectionFP420::get1: returnIndexRange.first= " << returnIndexRange.first << std::endl;
79  std::cout << "TrackCollectionFP420::get1: returnIndexRange.second= " << returnIndexRange.second << std::endl;
80 #endif
81 
82  TrackCollectionFP420::Range returnRange;
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 << "TrackCollectionFP420::get2: container_.size() = " << container_.size() << std::endl;
91  std::cout << "TrackCollectionFP420::get2: returnIndexRange.first= " << returnIndexRange.first << std::endl;
92  std::cout << "TrackCollectionFP420::get2: returnIndexRange.second= " << returnIndexRange.second << std::endl;
93 #endif
94  return returnRange;
95 }
96 
97 void TrackCollectionFP420::clear() { container_.clear(); }
100 
101  std::vector<TrackFP420> temporary;
102  TrackCollectionFP420::ContainerIterator sort_begin = input.first;
103  TrackCollectionFP420::ContainerIterator sort_end = input.second;
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();
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_[stationID] = inputRange;
126 }
127 
128 const std::vector<unsigned int> TrackCollectionFP420::stationIDs() const {
129  // returns vector of stationIDs in map
130 
131 #ifdef mydigidebug
132  std::cout << "TrackCollectionFP420::stationIDs:start " << std::endl;
133 #endif
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 }
void putclear(Range input, unsigned int stationID)
std::pair< unsigned int, unsigned int > IndexRange
const std::vector< unsigned int > stationIDs() const
std::pair< ContainerIterator, ContainerIterator > Range
static std::string const input
Definition: EdmProvDump.cc:48
std::map< unsigned int, IndexRange >::const_iterator RegistryIterator
std::vector< TrackFP420 >::const_iterator ContainerIterator
const Range get(unsigned int stationID) const
#define end
Definition: vmac.h:39
void put(Range input, unsigned int stationID)
#define begin
Definition: vmac.h:32