CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Member Functions | Protected Attributes
HcalDcsMap Class Reference

#include <HcalDcsMap.h>

Classes

class  const_iterator
 
class  Item
 

Public Member Functions

const_iterator beginByDcsId (void) const
 
const_iterator beginById (void) const
 
const_iterator endByDcsId (void) const
 
const_iterator endById (void) const
 
 HcalDcsMap ()
 
const std::vector< HcalDetIdlookup (HcalDcsDetId fId) const
 
const std::vector< HcalDcsDetIdlookup (HcalDetId fId, HcalDcsDetId::DcsType type) const
 
bool mapGeomId2DcsId (HcalDetId fId, HcalDcsDetId fDcsId)
 
void sort ()
 
void sortByDcsId () const
 
void sortById () const
 
 ~HcalDcsMap ()
 

Protected Member Functions

std::vector< HcalDcsDetIdallHcalDcsDetId () const
 
std::vector< HcalGenericDetIdallHcalDetId () const
 
const std::vector< const Item * > findByDcsId (unsigned long fDcsId) const
 
const std::vector< const Item * > findById (unsigned long fId) const
 
const std::vector< const Item * > * getItemsByDcsId (void)
 
const std::vector< const Item * > * getItemsById (void)
 

Protected Attributes

std::vector< ItemmItems
 
std::vector< const Item * > mItemsByDcsId
 
std::vector< const Item * > mItemsById
 
bool sortedByDcsId
 
bool sortedById
 

Detailed Description

Author
Gena Kukartsev POOL object to store map between detector ID and DCS ID Inspired by HcalElectronicsMap $Author: kukartse
Date:
2010/02/22 21:08:07
Revision:
1.1
Author
Gena Kukartsev POOL object to store map between detector ID and DCS ID Inspired by HcalElectronicsMap $Author: kukartse
Date:
2010/02/23 00:48:25
Revision:
1.2

Definition at line 23 of file HcalDcsMap.h.

Constructor & Destructor Documentation

HcalDcsMap::HcalDcsMap ( )

Definition at line 17 of file HcalDcsMap.cc.

17  :
18  //FIXME mItems(HcalDcsDetId::maxLinearIndex+1),
19  //mItems(0x7FFF),
20  sortedById(false),
21  sortedByDcsId(false){
22 }
bool sortedById
Definition: HcalDcsMap.h:105
bool sortedByDcsId
Definition: HcalDcsMap.h:108
HcalDcsMap::~HcalDcsMap ( )

Definition at line 24 of file HcalDcsMap.cc.

24  {
25 }

Member Function Documentation

std::vector< HcalDcsDetId > HcalDcsMap::allHcalDcsDetId ( ) const
protected

Definition at line 185 of file HcalDcsMap.cc.

References mItems, and query::result.

185  {
186  std::vector <HcalDcsDetId> result;
187  for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++)
188  if (item->mDcsId) result.push_back(HcalDcsDetId(item->mDcsId));
189  return result;
190 }
tuple result
Definition: query.py:137
std::vector< Item > mItems
Definition: HcalDcsMap.h:103
std::vector< HcalGenericDetId > HcalDcsMap::allHcalDetId ( ) const
protected

Definition at line 193 of file HcalDcsMap.cc.

References mItems, and query::result.

193  {
194  std::vector <HcalGenericDetId> result;
195  std::set <unsigned long> allIds;
196  for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++)
197  if (item->mId) allIds.insert (item->mId);
198  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) {
199  result.push_back (HcalGenericDetId (*channel));
200  }
201  return result;
202 }
tuple result
Definition: query.py:137
std::vector< Item > mItems
Definition: HcalDcsMap.h:103
HcalDcsMap::const_iterator HcalDcsMap::beginByDcsId ( void  ) const

Definition at line 52 of file HcalDcsMap.cc.

References HcalDcsMap::const_iterator::fIter, mItemsByDcsId, sortByDcsId(), and sortedByDcsId.

52  {
53  const_iterator _iter;
54  if (!sortedByDcsId) sortByDcsId();
55  _iter.fIter = mItemsByDcsId.begin();
56  return _iter;
57 }
void sortByDcsId() const
Definition: HcalDcsMap.cc:243
bool sortedByDcsId
Definition: HcalDcsMap.h:108
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:107
HcalDcsMap::const_iterator HcalDcsMap::beginById ( void  ) const

Definition at line 45 of file HcalDcsMap.cc.

References HcalDcsMap::const_iterator::fIter, mItemsById, sortById(), and sortedById.

45  {
46  const_iterator _iter;
47  if (!sortedById) sortById();
48  _iter.fIter = mItemsById.begin();
49  return _iter;
50 }
bool sortedById
Definition: HcalDcsMap.h:105
void sortById() const
Definition: HcalDcsMap.cc:232
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:104
HcalDcsMap::const_iterator HcalDcsMap::endByDcsId ( void  ) const

Definition at line 66 of file HcalDcsMap.cc.

References HcalDcsMap::const_iterator::fIter, mItemsByDcsId, sortByDcsId(), and sortedByDcsId.

66  {
67  const_iterator _iter;
68  if (!sortedByDcsId) sortByDcsId();
69  _iter.fIter = mItemsByDcsId.end();
70  return _iter;
71 }
void sortByDcsId() const
Definition: HcalDcsMap.cc:243
bool sortedByDcsId
Definition: HcalDcsMap.h:108
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:107
HcalDcsMap::const_iterator HcalDcsMap::endById ( void  ) const

Definition at line 59 of file HcalDcsMap.cc.

References HcalDcsMap::const_iterator::fIter, mItemsById, sortById(), and sortedById.

59  {
60  const_iterator _iter;
61  if (!sortedById) sortById();
62  _iter.fIter = mItemsById.end();
63  return _iter;
64 }
bool sortedById
Definition: HcalDcsMap.h:105
void sortById() const
Definition: HcalDcsMap.cc:232
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:104
const std::vector< const HcalDcsMap::Item * > HcalDcsMap::findByDcsId ( unsigned long  fDcsId) const
protected

Definition at line 125 of file HcalDcsMap.cc.

References mItemsByDcsId, query::result, sortByDcsId(), sortedByDcsId, and filterCSVwithJSON::target.

Referenced by lookup(), and mapGeomId2DcsId().

125  {
126  Item target (0, fDcsId);
127  std::vector<const HcalDcsMap::Item*>::const_iterator item;
128  std::vector<const HcalDcsMap::Item *> result;
129 
130  if (!sortedByDcsId) sortByDcsId();
131 
132  hcal_impl::LessByDcsId lessByDcsId;
133  item = std::lower_bound (mItemsByDcsId.begin(), mItemsByDcsId.end(), &target, lessByDcsId);
134  if (item == mItemsByDcsId.end() || (*item)->mDcsId != fDcsId) {
135  // throw cms::Exception ("Conditions not found") << "Unavailable Dcs map for cell " << fDcsId;
136  return result;
137  }
138  else{
139  if(item != mItemsByDcsId.end() && !lessByDcsId(&target, *item)){
140  result.push_back( *item );
141  ++item;
142  }
143  }
144  return result;
145 }
void sortByDcsId() const
Definition: HcalDcsMap.cc:243
bool sortedByDcsId
Definition: HcalDcsMap.h:108
tuple result
Definition: query.py:137
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:107
const std::vector< const HcalDcsMap::Item * > HcalDcsMap::findById ( unsigned long  fId) const
protected

Definition at line 103 of file HcalDcsMap.cc.

References mItemsById, query::result, sortById(), sortedById, and filterCSVwithJSON::target.

Referenced by lookup().

103  {
104  Item target (fId, 0);
105  std::vector<const HcalDcsMap::Item*>::const_iterator item;
106  std::vector<const HcalDcsMap::Item *> result;
107 
108  if (!sortedById) sortById();
109 
110  hcal_impl::LessById lessById;
111  item = std::lower_bound (mItemsById.begin(), mItemsById.end(), &target, lessById);
112  if (item == mItemsById.end() || (*item)->mId != fId){
113  // throw cms::Exception ("Conditions not found") << "Unavailable Dcs map for cell " << fId;
114  return result;
115  }
116  else{
117  if(item != mItemsById.end() && !lessById(&target, *item)){
118  result.push_back( *item );
119  ++item;
120  }
121  }
122  return result;
123 }
bool sortedById
Definition: HcalDcsMap.h:105
tuple result
Definition: query.py:137
void sortById() const
Definition: HcalDcsMap.cc:232
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:104
const std::vector<const Item *>* HcalDcsMap::getItemsByDcsId ( void  )
inlineprotected

Definition at line 109 of file HcalDcsMap.h.

References mItemsByDcsId.

109 {return &mItemsByDcsId;}
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:107
const std::vector<const Item *>* HcalDcsMap::getItemsById ( void  )
inlineprotected

Definition at line 106 of file HcalDcsMap.h.

References mItemsById.

106 {return &mItemsById;}
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:104
const std::vector< HcalDetId > HcalDcsMap::lookup ( HcalDcsDetId  fId) const

Definition at line 147 of file HcalDcsMap.cc.

References HcalDcsDetId::DCSUNKNOWN, findByDcsId(), HcalDcsDetId::ring(), HcalDcsDetId::slice(), HcalDcsDetId::subchannel(), and HcalOtherDetId::subdet().

147  {
148  // DCS type is a part of DcsDetId but it does not make sense to keep
149  // duplicate records in the map for DCS channels where only type is different.
150  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
151  HcalDcsDetId fDcsId_notype(fId.subdet(),
152  fId.ring(), // side is already included
153  fId.slice(),
155  fId.subchannel());
156  const std::vector<const Item *> items = findByDcsId (fDcsId_notype.rawId ());
157  std::vector<HcalDetId> _ids;
158  for (std::vector<const Item *>::const_iterator item = items.begin();
159  item != items.end();
160  ++item){
161  _ids.push_back( DetId(*item ? (*item)->mId : 0) );
162  }
163  return _ids;
164 }
int subchannel() const
Definition: HcalDcsDetId.h:49
const std::vector< const Item * > findByDcsId(unsigned long fDcsId) const
Definition: HcalDcsMap.cc:125
Definition: DetId.h:20
HcalOtherSubdetector subdet() const
get the category
int slice() const
Definition: HcalDcsDetId.h:47
int ring() const
Definition: HcalDcsDetId.h:46
const std::vector< HcalDcsDetId > HcalDcsMap::lookup ( HcalDetId  fId,
HcalDcsDetId::DcsType  type 
) const

Definition at line 166 of file HcalDcsMap.cc.

References findById(), DetId::rawId(), HcalDcsDetId::ring(), HcalDcsDetId::slice(), HcalDcsDetId::subchannel(), HcalOtherDetId::subdet(), and HcalDcsDetId::zside().

166  {
167  const std::vector<const Item *> items = findById (fId.rawId ());
168  std::vector<HcalDcsDetId> _ids;
169  for (std::vector<const Item *>::const_iterator item = items.begin();
170  item != items.end();
171  ++item){
172  HcalDcsDetId _id(*item ? (*item)->mId : 0);
173  _ids.push_back( HcalDcsDetId(_id.subdet(),
174  _id.zside()*_id.ring(),
175  _id.slice(),
176  type,
177  _id.subchannel()
178  )
179  );
180  }
181  return _ids;
182 }
type
Definition: HCALResponse.h:22
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
const std::vector< const Item * > findById(unsigned long fId) const
Definition: HcalDcsMap.cc:103
bool HcalDcsMap::mapGeomId2DcsId ( HcalDetId  fId,
HcalDcsDetId  fDcsId 
)

Definition at line 205 of file HcalDcsMap.cc.

References HcalDcsDetId::DCSUNKNOWN, findByDcsId(), mItems, HcalDcsDetId::ring(), HcalDcsDetId::slice(), sortedByDcsId, sortedById, HcalDcsDetId::subchannel(), and HcalOtherDetId::subdet().

205  {
206  // DCS type is a part of DcsDetId but it does not make sense to keep
207  // duplicate records in the map for DCS channels where only type is different.
208  // Hence, the type in HcalDcsDetId is always forced to DCSUNKNOWN
209  HcalDcsDetId fDcsId_notype(fDcsId.subdet(),
210  fDcsId.ring(), // side is included
211  fDcsId.slice(),
213  fDcsId.subchannel());
214  const std::vector<const Item *> items = findByDcsId(fDcsId_notype);
215  for (std::vector<const Item *>::const_iterator item = items.begin();
216  item != items.end();
217  ++item){
218  if ((*item)->mId == fId){
219  edm::LogWarning("HCAL") << "HcalDcsMap::mapGeomId2DcsId-> Geom channel " << fId
220  << " already mapped to DCS channel " << fDcsId_notype;
221  return false; // element already exists
222  }
223  }
224  Item _item(fId, fDcsId_notype);
225  mItems.push_back(_item);
226  sortedById=false;
227  sortedByDcsId=false;
228  return true;
229 }
bool sortedById
Definition: HcalDcsMap.h:105
int subchannel() const
Definition: HcalDcsDetId.h:49
bool sortedByDcsId
Definition: HcalDcsMap.h:108
const std::vector< const Item * > findByDcsId(unsigned long fDcsId) const
Definition: HcalDcsMap.cc:125
HcalOtherSubdetector subdet() const
get the category
int slice() const
Definition: HcalDcsDetId.h:47
std::vector< Item > mItems
Definition: HcalDcsMap.h:103
int ring() const
Definition: HcalDcsDetId.h:46
void HcalDcsMap::sort ( )
inline

Definition at line 62 of file HcalDcsMap.h.

62 {}
void HcalDcsMap::sortByDcsId ( ) const

Definition at line 243 of file HcalDcsMap.cc.

References i, mItems, mItemsByDcsId, python.multivaluedict::sort(), and sortedByDcsId.

Referenced by beginByDcsId(), endByDcsId(), and findByDcsId().

243  {
244  if (!sortedByDcsId) {
245  mItemsByDcsId.clear();
246  for (std::vector<Item>::const_iterator i=mItems.begin(); i!=mItems.end(); ++i) {
247  if (i->mDcsId) mItemsByDcsId.push_back(&(*i));
248  }
249 
251  sortedByDcsId=true;
252  }
253 }
int i
Definition: DBlmapReader.cc:9
bool sortedByDcsId
Definition: HcalDcsMap.h:108
std::vector< const Item * > mItemsByDcsId
Definition: HcalDcsMap.h:107
std::vector< Item > mItems
Definition: HcalDcsMap.h:103
void HcalDcsMap::sortById ( ) const

Definition at line 232 of file HcalDcsMap.cc.

References i, mItems, mItemsById, python.multivaluedict::sort(), and sortedById.

Referenced by beginById(), endById(), and findById().

232  {
233  if (!sortedById) {
234  mItemsById.clear();
235  for (std::vector<Item>::const_iterator i=mItems.begin(); i!=mItems.end(); ++i) {
236  if (i->mDcsId) mItemsById.push_back(&(*i));
237  }
238  std::sort (mItemsById.begin(), mItemsById.end(), hcal_impl::LessById ());
239  sortedById=true;
240  }
241 }
int i
Definition: DBlmapReader.cc:9
bool sortedById
Definition: HcalDcsMap.h:105
std::vector< Item > mItems
Definition: HcalDcsMap.h:103
std::vector< const Item * > mItemsById
Definition: HcalDcsMap.h:104

Member Data Documentation

std::vector<Item> HcalDcsMap::mItems
protected

Definition at line 103 of file HcalDcsMap.h.

Referenced by allHcalDcsDetId(), allHcalDetId(), mapGeomId2DcsId(), sortByDcsId(), and sortById().

std::vector<const Item*> HcalDcsMap::mItemsByDcsId
mutableprotected

Definition at line 107 of file HcalDcsMap.h.

Referenced by beginByDcsId(), endByDcsId(), findByDcsId(), getItemsByDcsId(), and sortByDcsId().

std::vector<const Item*> HcalDcsMap::mItemsById
mutableprotected

Definition at line 104 of file HcalDcsMap.h.

Referenced by beginById(), endById(), findById(), getItemsById(), and sortById().

bool HcalDcsMap::sortedByDcsId
mutableprotected

Definition at line 108 of file HcalDcsMap.h.

Referenced by beginByDcsId(), endByDcsId(), findByDcsId(), mapGeomId2DcsId(), and sortByDcsId().

bool HcalDcsMap::sortedById
mutableprotected

Definition at line 105 of file HcalDcsMap.h.

Referenced by beginById(), endById(), findById(), mapGeomId2DcsId(), and sortById().