CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHitMetaCollectionFast.cc
Go to the documentation of this file.
2 #include <algorithm>
3 
5  dirty_=false;
6 }
7 
9  hits_.push_back(hit);
10  dirty_=true;
11  size_++;
12 }
13 
14 class CRHMCVComp {
15 public:
16  typedef const CaloRecHit* T;
17  typedef const DetId& key_type;
18 
19  bool operator()(key_type a, T const& b) const { return a < b->detid(); }
20  bool operator()(T const& a, key_type b) const { return a->detid() < b; }
21  bool operator()(T const& a, T const& b) const { return a->detid() < b->detid(); }
22 };
23 
24 
26  if (dirty_) sort();
27 
28  CRHMCVComp comp;
29 
30  std::vector<const CaloRecHit*>::const_iterator last=hits_.end();
31  std::vector<const CaloRecHit*>::const_iterator first=hits_.begin();
32  std::vector<const CaloRecHit*>::const_iterator loc =std::lower_bound(first,
33  last,
34  id,
35  comp);
36  return loc == last || comp(id, *loc) ? end() : const_iterator(this,loc - hits_.begin());
37 }
38 
39 
41  if (dirty_) sort();
42  return ((i<0 || i>=(const_iterator::offset_type)size_)?(0):(hits_[i]));
43 }
44 
45 
47  if (dirty_) {
48  CRHMCVComp comp;
49  std::sort(hits_.begin(),hits_.end(),comp);
50  dirty_=false;
51  }
52 }
53 
bool operator()(key_type a, T const &b) const
int i
Definition: DBlmapReader.cc:9
const DetId & detid() const
Definition: CaloRecHit.h:22
std::vector< const CaloRecHit * > hits_
CaloRecHitMetaCollectionFast()
create an empty collection
void add(const CaloRecHit *hit)
add an item to the collection
const_iterator end() const
get the ending iterator
bool operator()(T const &a, T const &b) const
bool first
Definition: L1TdeRCT.cc:94
virtual const_iterator find(const DetId &id) const
find by id (default version is very slow unsorted find)
Definition: DetId.h:20
const CaloRecHit * T
double b
Definition: hdecay.h:120
CaloRecHitMetaCollectionV::Iterator const_iterator
double a
Definition: hdecay.h:121
virtual const CaloRecHit * at(const_iterator::offset_type i) const
get an item by index
bool operator()(T const &a, key_type b) const