CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHitMetaCollection.cc
Go to the documentation of this file.
3 
5 public:
6  virtual int find(const DetId& id) const = 0;
7  virtual const CaloRecHit* at(int index) const = 0;
8 };
9 
10 template <class T>
12 public:
15  virtual int find(const DetId& id) const {
16  typename T::const_iterator i;
17  i=m_collection->find(id);
18  return (i==m_collection->end())?(-1):(i-m_collection->begin()+m_start);
19  }
20  virtual const CaloRecHit* at(int index) const {
21  return &((*m_collection)[index-m_start]);
22  }
23 private:
24  const T* m_collection;
25  int m_start;
26 };
27 
28 typedef std::multimap<int, CaloRecHitMetaCollectionItem*>::const_iterator find_iterator;
29 
31  return id.rawId()>>25;
32 }
33 
35  std::pair<find_iterator,find_iterator> options=m_findTool.equal_range(findIndex(id));
36  int pos=-1;
37  for (find_iterator i=options.first; i!=options.second; i++) {
38  pos=i->second->find(id);
39  if (pos>=0) break;
40  }
41  return (pos<0)?(end()):(const_iterator(this,pos));
42 }
43 
45  std::map<int, CaloRecHitMetaCollectionItem*>::const_iterator q=m_items.lower_bound(i);
46  return (q==m_items.end())?(0):(q->second->at(i));
47 }
48 
50  for (std::map<int, CaloRecHitMetaCollectionItem*>::iterator i=m_items.begin(); i!=m_items.end(); i++)
51  delete i->second;
52 }
53 
54 
56  if (hbhe->size()==0) return; // do not add empty collections (can cause problems)
58  size_+=hbhe->size();
59  m_items.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(size_-1,i));
60  m_findTool.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(findIndex(DetId(DetId::Hcal,HcalBarrel)),i));
61  m_findTool.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(findIndex(DetId(DetId::Hcal,HcalEndcap)),i));
62 }
63 
65  if (ho->size()==0) return; // do not add empty collections (can cause problems)
67  size_+=ho->size();
68  m_items.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(size_-1,i));
69  m_findTool.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(findIndex(DetId(DetId::Hcal,HcalOuter)),i));
70 }
71 
73  if (hf->size()==0) return; // do not add empty collections (can cause problems)
75  size_+=hf->size();
76  m_items.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(size_-1,i));
77  m_findTool.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(findIndex(DetId(DetId::Hcal,HcalForward)),i));
78 }
79 
80 
82  if (ecal->size()==0) return; // do not add empty collections (can cause problems)
84  size_+=ecal->size();
85  m_items.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(size_-1,i));
86  m_findTool.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(findIndex(DetId(DetId::Ecal,EcalBarrel)),i));
87  m_findTool.insert(std::pair<int,CaloRecHitMetaCollectionItem*>(findIndex(DetId(DetId::Ecal,EcalEndcap)),i));
88 }
89 
std::multimap< int, CaloRecHitMetaCollectionItem * >::const_iterator find_iterator
int i
Definition: DBlmapReader.cc:9
virtual int find(const DetId &id) const
std::map< int, CaloRecHitMetaCollectionItem * > m_items
virtual const CaloRecHit * at(const_iterator::offset_type i) const
get an item by index
CaloRecHitMetaCollectionItemT(const T *coll, int start)
virtual const_iterator find(const DetId &id) const
find by id (default version is very slow unsorted find)
const_iterator end() const
get the ending iterator
virtual int find(const DetId &id) const =0
void add(const HBHERecHitCollection *hbhe)
Definition: DetId.h:20
virtual const CaloRecHit * at(int index) const
JetCorrectorParametersCollection coll
Definition: classes.h:14
int findIndex(const DetId &id) const
std::multimap< int, CaloRecHitMetaCollectionItem * > m_findTool
virtual const CaloRecHit * at(int index) const =0
size_type size() const
CaloRecHitMetaCollectionV::Iterator const_iterator
long double T