CMS 3D CMS Logo

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;
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
38  RecoCollectionFP420::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 
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;
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
135  RecoCollectionFP420::RegistryIterator begin = map_.begin();
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 }
RecoCollectionFP420::put
void put(Range input, unsigned int stationID)
Definition: RecoCollectionFP420.cc:13
input
static const std::string input
Definition: EdmProvDump.cc:48
RecoCollectionFP420::clear
void clear()
Definition: RecoCollectionFP420.cc:98
RecoCollectionFP420::RegistryIterator
std::map< unsigned int, IndexRange >::const_iterator RegistryIterator
Definition: RecoCollectionFP420.h:15
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RecoCollectionFP420::ContainerIterator
std::vector< RecoFP420 >::const_iterator ContainerIterator
Definition: RecoCollectionFP420.h:11
pileupCalc.inputRange
inputRange
Definition: pileupCalc.py:217
RecoCollectionFP420::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: RecoCollectionFP420.h:12
mps_fire.end
end
Definition: mps_fire.py:242
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
RecoCollectionFP420::IndexRange
std::pair< unsigned int, unsigned int > IndexRange
Definition: RecoCollectionFP420.h:13
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
RecoCollectionFP420::putclear
void putclear(Range input, unsigned int stationID)
Definition: RecoCollectionFP420.cc:99
RecoCollectionFP420::get
const Range get(unsigned int stationID) const
Definition: RecoCollectionFP420.cc:70
std
Definition: JetResolutionObject.h:76
RecoCollectionFP420::stationIDs
const std::vector< unsigned int > stationIDs() const
Definition: RecoCollectionFP420.cc:129
RecoCollectionFP420.h