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;
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
38  TrackCollectionFP420::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_[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;
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  TrackCollectionFP420::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_[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
134  TrackCollectionFP420::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 }
TrackCollectionFP420::put
void put(Range input, unsigned int stationID)
Definition: TrackCollectionFP420.cc:13
input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TrackCollectionFP420::ContainerIterator
std::vector< TrackFP420 >::const_iterator ContainerIterator
Definition: TrackCollectionFP420.h:11
TrackCollectionFP420::clear
void clear()
Definition: TrackCollectionFP420.cc:97
pileupCalc.inputRange
inputRange
Definition: pileupCalc.py:218
mps_fire.end
end
Definition: mps_fire.py:242
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
TrackCollectionFP420.h
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TrackCollectionFP420::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: TrackCollectionFP420.h:12
TrackCollectionFP420::stationIDs
const std::vector< unsigned int > stationIDs() const
Definition: TrackCollectionFP420.cc:128
TrackCollectionFP420::IndexRange
std::pair< unsigned int, unsigned int > IndexRange
Definition: TrackCollectionFP420.h:13
TrackCollectionFP420::putclear
void putclear(Range input, unsigned int stationID)
Definition: TrackCollectionFP420.cc:98
TrackCollectionFP420::RegistryIterator
std::map< unsigned int, IndexRange >::const_iterator RegistryIterator
Definition: TrackCollectionFP420.h:15
std
Definition: JetResolutionObject.h:76
TrackCollectionFP420::get
const Range get(unsigned int stationID) const
Definition: TrackCollectionFP420.cc:69