CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RecoCollectionFP420.cc
Go to the documentation of this file.
1 // File: RecoCollectionFP420.cc
3 // Date: 11.2007
4 // Description: RecoCollectionFP420 for FP420
5 // Modifications:
8 #include <algorithm>
9 #include <iostream>
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 RecoFP420s from input
20  bool first = true;
21 
22  // fill input in temporary vector for sorting
23  std::vector<RecoFP420> temporary;
24  RecoCollectionFP420::ContainerIterator sort_begin = input.first;
25  RecoCollectionFP420::ContainerIterator sort_end = input.second;
26 #ifdef mydigidebug
27  std::cout << " !!!!!!!!!!!!!!!! RecoCollectionFP420:: !!!! 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 
57  // inputRange.second = container_.size()-1;
58  // //inputRange.second = container_.size();
59 
60 #ifdef mydigidebug
61  std::cout << "put: container_.size() = " << container_.size() << std::endl;
62  std::cout << "put: inputRange.first = " << inputRange.first << std::endl;
63  std::cout << "put: inputRange.second = " << inputRange.second << std::endl;
64 #endif
65 
66  // fill map
67  map_[stationID] = inputRange;
68 }
69 
70 const RecoCollectionFP420::Range RecoCollectionFP420::get(unsigned int stationID) const {
71  // get RecHits of stationID
72 
73 #ifdef mydigidebug
74  std::cout << "RecoCollectionFP420::get:stationID= " << stationID << std::endl;
75 #endif
76  RecoCollectionFP420::RegistryIterator returnIndex = map_.find(stationID);
77  RecoCollectionFP420::IndexRange returnIndexRange = returnIndex->second;
78 #ifdef mydigidebug
79  std::cout << "RecoCollectionFP420::get1: returnIndexRange.first= " << returnIndexRange.first << std::endl;
80  std::cout << "RecoCollectionFP420::get1: returnIndexRange.second= " << returnIndexRange.second << std::endl;
81 #endif
82 
83  RecoCollectionFP420::Range returnRange;
84  returnRange.first = container_.begin() + returnIndexRange.first;
85  if (returnIndexRange.second != 0) {
86  returnRange.second = container_.begin() + returnIndexRange.second + 1;
87  } else {
88  returnRange.second = container_.begin() + returnIndexRange.second;
89  }
90 #ifdef mydigidebug
91  std::cout << "RecoCollectionFP420::get2: container_.size() = " << container_.size() << std::endl;
92  std::cout << "RecoCollectionFP420::get2: returnIndexRange.first= " << returnIndexRange.first << std::endl;
93  std::cout << "RecoCollectionFP420::get2: returnIndexRange.second= " << returnIndexRange.second << std::endl;
94 #endif
95  return returnRange;
96 }
97 
98 void RecoCollectionFP420::clear() { container_.clear(); }
101 
102  std::vector<RecoFP420> temporary;
103  RecoCollectionFP420::ContainerIterator sort_begin = input.first;
104  RecoCollectionFP420::ContainerIterator sort_end = input.second;
105  for (; sort_begin != sort_end; ++sort_begin) {
106  temporary.push_back(*sort_begin);
107  }
108  std::sort(temporary.begin(), temporary.end());
109 
110  // temporary.clear();
111  RecoCollectionFP420::ContainerIterator begin = temporary.begin();
113  for (; begin != end; ++begin) {
114  container_.push_back(*begin);
115  }
116  //container_.clear();
117  inputRange.first = container_.size() - container_.size();
118  inputRange.second = container_.size() - container_.size();
119 
120 #ifdef mydigidebug
121  std::cout << "putclear: container_.size() = " << container_.size() << std::endl;
122  std::cout << "putclear: inputRange.first = " << inputRange.first << std::endl;
123  std::cout << "putclear: inputRange.second = " << inputRange.second << std::endl;
124 #endif
125 
126  map_[stationID] = inputRange;
127 }
128 
129 const std::vector<unsigned int> RecoCollectionFP420::stationIDs() const {
130  // returns vector of stationIDs in map
131 
132 #ifdef mydigidebug
133  std::cout << "RecoCollectionFP420::stationIDs:start " << std::endl;
134 #endif
137 
138  std::vector<unsigned int> output;
139 
140  for (; begin != end; ++begin) {
141  output.push_back(begin->first);
142  }
143 
144  return output;
145 }
std::pair< ContainerIterator, ContainerIterator > Range
static std::string const input
Definition: EdmProvDump.cc:47
std::vector< RecoFP420 >::const_iterator ContainerIterator
const Range get(unsigned int stationID) const
const std::vector< unsigned int > stationIDs() const
void putclear(Range input, unsigned int stationID)
void put(Range input, unsigned int stationID)
std::pair< unsigned int, unsigned int > IndexRange
tuple inputRange
Definition: pileupCalc.py:168
string end
Definition: dataset.py:937
std::map< unsigned int, IndexRange >::const_iterator RegistryIterator
tuple cout
Definition: gather_cfg.py:144