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
HcalElectronicsMap Class Reference

#include <HcalElectronicsMap.h>

Classes

class  PrecisionItem
 
class  TriggerItem
 

Public Member Functions

std::vector< HcalElectronicsIdallElectronicsId () const
 
std::vector< HcalElectronicsIdallElectronicsIdPrecision () const
 
std::vector< HcalElectronicsIdallElectronicsIdTrigger () const
 
std::vector< HcalGenericDetIdallPrecisionId () const
 
std::vector< HcalTrigTowerDetIdallTriggerId () const
 
 HcalElectronicsMap ()
 
 HcalElectronicsMap (const HcalElectronicsMap &src)
 
 HcalElectronicsMap (HcalElectronicsMap &&other)
 
const DetId lookup (HcalElectronicsId fId) const
 lookup the logical detid associated with the given electronics id More...
 
const HcalElectronicsId lookup (DetId fId) const
 brief lookup the electronics detid associated with the given logical id More...
 
bool lookup (const HcalElectronicsId pId, HcalElectronicsId &eid, HcalGenericDetId &did) const
 brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/fiber/fiberchan) id More...
 
bool lookup (const HcalElectronicsId pId, HcalElectronicsId &eid, HcalTrigTowerDetId &did) const
 brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/slb/slbchan) id More...
 
const DetId lookupTrigger (HcalElectronicsId fId) const
 brief lookup the trigger logical detid associated with the given electronics id More...
 
const HcalElectronicsId lookupTrigger (DetId fId) const
 brief lookup the electronics detid associated with the given trigger logical id More...
 
bool mapEId2chId (HcalElectronicsId fElectronicsId, DetId fId)
 
bool mapEId2tId (HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
 
HcalElectronicsMapoperator= (const HcalElectronicsMap &rhs)
 
void sort ()
 
void sortById () const
 
void sortByTriggerId () const
 
void swap (HcalElectronicsMap &other)
 
 ~HcalElectronicsMap ()
 

Protected Member Functions

const PrecisionItemfindById (unsigned long fId) const
 
const TriggerItemfindByTrigId (unsigned long fTrigId) const
 
const PrecisionItemfindPByElId (unsigned long fElId) const
 
const TriggerItemfindTByElId (unsigned long fElId) const
 

Protected Attributes

std::vector< PrecisionItemmPItems
 
std::atomic< std::vector
< const PrecisionItem * > * > 
mPItemsById
 
std::vector< TriggerItemmTItems
 
std::atomic< std::vector
< const TriggerItem * > * > 
mTItemsByTrigId
 

Detailed Description

Author
Fedor Ratnikov (UMd) POOL object to store map between detector ID, electronics ID and trigger ID $Author: ratnikov
Date:
2007/12/10 18:36:43
Revision:
1.16
Author
Fedor Ratnikov (UMd) POOL object to store mapping for Hcal channels $Author: ratnikov
Date:
2007/09/18 06:48:38
Revision:
1.22

Definition at line 27 of file HcalElectronicsMap.h.

Constructor & Destructor Documentation

HcalElectronicsMap::HcalElectronicsMap ( )

Definition at line 16 of file HcalElectronicsMap.cc.

16  :
19  mPItemsById(nullptr), mTItemsByTrigId(nullptr)
20 {}
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::vector< TriggerItem > mTItems
static const int maxLinearIndex
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
HcalElectronicsMap::~HcalElectronicsMap ( )

Definition at line 27 of file HcalElectronicsMap.cc.

References mPItemsById, and mTItemsByTrigId.

27  {
28  delete mPItemsById;
29  mPItemsById = nullptr;
30  delete mTItemsByTrigId;
31  mTItemsByTrigId = nullptr;
32 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
HcalElectronicsMap::HcalElectronicsMap ( const HcalElectronicsMap src)

Definition at line 34 of file HcalElectronicsMap.cc.

35  : mPItems(src.mPItems), mTItems(src.mTItems),
36  mPItemsById(nullptr), mTItemsByTrigId(nullptr) {}
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::vector< TriggerItem > mTItems
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
HcalElectronicsMap::HcalElectronicsMap ( HcalElectronicsMap &&  other)

Definition at line 56 of file HcalElectronicsMap.cc.

References swap().

57  : HcalElectronicsMap() {
58  other.swap(*this);
59 }
void swap(HcalElectronicsMap &other)

Member Function Documentation

std::vector< HcalElectronicsId > HcalElectronicsMap::allElectronicsId ( ) const

Definition at line 145 of file HcalElectronicsMap.cc.

References mPItems, mTItems, and query::result.

Referenced by HcalLuttoDB::analyze().

145  {
146  std::vector <HcalElectronicsId> result;
147  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
148  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
149  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
150  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
151 
152  return result;
153 }
std::vector< PrecisionItem > mPItems
tuple result
Definition: query.py:137
std::vector< TriggerItem > mTItems
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
std::vector< HcalElectronicsId > HcalElectronicsMap::allElectronicsIdPrecision ( ) const

Definition at line 155 of file HcalElectronicsMap.cc.

References mPItems, and query::result.

Referenced by HcalRawDataClient::beginRun(), HcalRawDataMonitor::beginRun(), HcalDetDiagLEDMonitor::CheckStatus(), HcalDetDiagPedestalMonitor::CheckStatus(), EMap::EMap(), HcalDetDiagLEDMonitor::fillHistos(), HcalDetDiagLaserMonitor::fillProblems(), HcalDetDiagLEDMonitor::SaveReference(), HcalDetDiagPedestalMonitor::SaveReference(), and HcalDetDiagLaserMonitor::SaveReference().

155  {
156  std::vector <HcalElectronicsId> result;
157  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
158  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
159  return result;
160 }
std::vector< PrecisionItem > mPItems
tuple result
Definition: query.py:137
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
std::vector< HcalElectronicsId > HcalElectronicsMap::allElectronicsIdTrigger ( ) const

Definition at line 162 of file HcalElectronicsMap.cc.

References mTItems, and query::result.

Referenced by EMap::EMap().

162  {
163  std::vector <HcalElectronicsId> result;
164  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
165  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
166 
167  return result;
168 }
tuple result
Definition: query.py:137
std::vector< TriggerItem > mTItems
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
std::vector< HcalGenericDetId > HcalElectronicsMap::allPrecisionId ( ) const

Definition at line 170 of file HcalElectronicsMap.cc.

References mPItems, and query::result.

170  {
171  std::vector <HcalGenericDetId> result;
172  std::set <unsigned long> allIds;
173  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
174  if (item->mId) allIds.insert (item->mId);
175  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) {
176  result.push_back (HcalGenericDetId (*channel));
177  }
178  return result;
179 }
std::vector< PrecisionItem > mPItems
tuple result
Definition: query.py:137
std::vector< HcalTrigTowerDetId > HcalElectronicsMap::allTriggerId ( ) const

Definition at line 181 of file HcalElectronicsMap.cc.

References mTItems, and query::result.

181  {
182  std::vector <HcalTrigTowerDetId> result;
183  std::set <unsigned long> allIds;
184  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
185  if (item->mTrigId) allIds.insert (item->mTrigId);
186  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++)
187  result.push_back (HcalTrigTowerDetId (*channel));
188  return result;
189 }
tuple result
Definition: query.py:137
std::vector< TriggerItem > mTItems
const HcalElectronicsMap::PrecisionItem * HcalElectronicsMap::findById ( unsigned long  fId) const
protected

Definition at line 61 of file HcalElectronicsMap.cc.

References mPItemsById, sortById(), and filterCSVwithJSON::target.

Referenced by lookup().

61  {
62  PrecisionItem target (fId, 0);
63  std::vector<const HcalElectronicsMap::PrecisionItem*>::const_iterator item;
64 
65  sortById();
66 
67  auto ptr = (*mPItemsById.load(std::memory_order_acquire));
68  item = std::lower_bound (ptr.begin(), ptr.end(), &target, hcal_impl::LessById());
69  if (item == ptr.end() || (*item)->mId != fId)
70  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
71  return 0;
72  return *item;
73 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
const HcalElectronicsMap::TriggerItem * HcalElectronicsMap::findByTrigId ( unsigned long  fTrigId) const
protected

Definition at line 92 of file HcalElectronicsMap.cc.

References mTItemsByTrigId, sortByTriggerId(), and filterCSVwithJSON::target.

Referenced by lookupTrigger().

92  {
93  TriggerItem target (fTrigId,0);
94  std::vector<const HcalElectronicsMap::TriggerItem*>::const_iterator item;
95 
97 
98  auto ptr = (*mTItemsByTrigId.load(std::memory_order_acquire));
99  item = std::lower_bound (ptr.begin(), ptr.end(), &target, hcal_impl::LessByTrigId());
100  if (item == (*mTItemsByTrigId).end() || (*item)->mTrigId != fTrigId)
101  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
102  return 0;
103  return *item;
104 }
void sortByTriggerId() const
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
const HcalElectronicsMap::PrecisionItem * HcalElectronicsMap::findPByElId ( unsigned long  fElId) const
protected

Definition at line 75 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::PrecisionItem::mElId, and mPItems.

Referenced by lookup().

75  {
76  HcalElectronicsId eid(fElId);
77  const PrecisionItem* i=&(mPItems[eid.linearIndex()]);
78 
79  if (i!=0 && i->mElId!=fElId) i=0;
80  return i;
81 }
int i
Definition: DBlmapReader.cc:9
std::vector< PrecisionItem > mPItems
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const HcalElectronicsMap::TriggerItem * HcalElectronicsMap::findTByElId ( unsigned long  fElId) const
protected

Definition at line 83 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::TriggerItem::mElId, and mTItems.

Referenced by lookupTrigger().

83  {
84  HcalElectronicsId eid(fElId);
85  const TriggerItem* i=&(mTItems[eid.linearIndex()]);
86 
87  if (i!=0 && i->mElId!=fElId) i=0;
88  return i;
89 }
int i
Definition: DBlmapReader.cc:9
std::vector< TriggerItem > mTItems
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const DetId HcalElectronicsMap::lookup ( HcalElectronicsId  fId) const
const HcalElectronicsId HcalElectronicsMap::lookup ( DetId  fId) const

brief lookup the electronics detid associated with the given logical id

Definition at line 111 of file HcalElectronicsMap.cc.

References findById(), HcalElectronicsMap::PrecisionItem::mElId, and DetId::rawId().

111  {
112  const PrecisionItem* item = findById (fId.rawId ());
113  return HcalElectronicsId (item ? item->mElId : 0);
114 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const PrecisionItem * findById(unsigned long fId) const
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
bool HcalElectronicsMap::lookup ( const HcalElectronicsId  pId,
HcalElectronicsId eid,
HcalGenericDetId did 
) const

brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/fiber/fiberchan) id

Definition at line 126 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::PrecisionItem::mElId, HcalElectronicsMap::PrecisionItem::mId, and mPItems.

126  {
127  const PrecisionItem* i=&(mPItems[pid.linearIndex()]);
128  if (i!=0 && i->mId!=0) {
129  eid=HcalElectronicsId(i->mElId);
130  did=HcalGenericDetId(i->mId);
131  return true;
132  } else return false;
133 }
int i
Definition: DBlmapReader.cc:9
std::vector< PrecisionItem > mPItems
tuple pid
Definition: sysUtil.py:22
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
bool HcalElectronicsMap::lookup ( const HcalElectronicsId  pId,
HcalElectronicsId eid,
HcalTrigTowerDetId did 
) const

brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/slb/slbchan) id

Definition at line 135 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::TriggerItem::mElId, mTItems, and HcalElectronicsMap::TriggerItem::mTrigId.

135  {
136  const TriggerItem* i=&(mTItems[pid.linearIndex()]);
137  if (i!=0 && i->mTrigId!=0) {
138  eid=HcalElectronicsId(i->mElId);
139  did=HcalGenericDetId(i->mTrigId);
140  return true;
141  } else return false;
142 }
int i
Definition: DBlmapReader.cc:9
std::vector< TriggerItem > mTItems
tuple pid
Definition: sysUtil.py:22
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const DetId HcalElectronicsMap::lookupTrigger ( HcalElectronicsId  fId) const

brief lookup the trigger logical detid associated with the given electronics id

Definition at line 116 of file HcalElectronicsMap.cc.

References findTByElId(), HcalElectronicsMap::TriggerItem::mTrigId, and HcalElectronicsId::rawId().

Referenced by HcalLuttoDB::analyze(), EMap::EMap(), and HcalUnpacker::unpack().

116  {
117  const TriggerItem* item = findTByElId (fId.rawId ());
118  return DetId (item ? item->mTrigId : 0);
119 }
uint32_t rawId() const
Definition: DetId.h:18
const TriggerItem * findTByElId(unsigned long fElId) const
const HcalElectronicsId HcalElectronicsMap::lookupTrigger ( DetId  fId) const

brief lookup the electronics detid associated with the given trigger logical id

Definition at line 121 of file HcalElectronicsMap.cc.

References findByTrigId(), HcalElectronicsMap::TriggerItem::mElId, and DetId::rawId().

121  {
122  const TriggerItem* item = findByTrigId (fId.rawId ());
123  return HcalElectronicsId (item ? item->mElId : 0);
124 }
const TriggerItem * findByTrigId(unsigned long fTrigId) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
bool HcalElectronicsMap::mapEId2chId ( HcalElectronicsId  fElectronicsId,
DetId  fId 
)

Definition at line 211 of file HcalElectronicsMap.cc.

References HcalElectronicsId::linearIndex(), HcalElectronicsMap::PrecisionItem::mElId, HcalElectronicsMap::PrecisionItem::mId, mPItems, mPItemsById, HcalElectronicsId::rawId(), and DetId::rawId().

Referenced by HcalLogicalMap::generateHcalElectronicsMap(), and HcalDbOnline::getObject().

211  {
212  PrecisionItem& item = mPItems[fElectronicsId.linearIndex()];
213 
214  delete mPItemsById;
215  mPItemsById = nullptr;
216 
217  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
218  if (item.mId == 0) {
219  item.mId = fId.rawId ();
220  }
221  else if (item.mId != fId.rawId ()) {
222  edm::LogWarning("HCAL") << "HcalElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to channel "
223  << HcalGenericDetId(item.mId) << ". New value " << HcalGenericDetId(fId) << " is ignored" ;
224  return false;
225  }
226  return true;
227 }
uint32_t rawId() const
std::vector< PrecisionItem > mPItems
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
int linearIndex() const
get a fast, compact, unique index for linear lookups (maximum value = 16384)
bool HcalElectronicsMap::mapEId2tId ( HcalElectronicsId  fElectronicsId,
HcalTrigTowerDetId  fTriggerId 
)

Definition at line 191 of file HcalElectronicsMap.cc.

References HcalElectronicsId::linearIndex(), HcalElectronicsMap::TriggerItem::mElId, mTItems, mTItemsByTrigId, HcalElectronicsMap::TriggerItem::mTrigId, HcalElectronicsId::rawId(), and DetId::rawId().

Referenced by HcalLogicalMap::generateHcalElectronicsMap().

191  {
192  TriggerItem& item = mTItems[fElectronicsId.linearIndex()];
193 
194  if (mTItemsByTrigId) {
195  delete mTItemsByTrigId;
196  mTItemsByTrigId = nullptr;
197  }
198 
199  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
200  if (item.mTrigId == 0) {
201  item.mTrigId = fTriggerId.rawId (); // just cast avoiding long machinery
202  }
203  else if (item.mTrigId != fTriggerId.rawId ()) {
204  edm::LogWarning("HCAL") << "HcalElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to trigger channel "
205  << (HcalTrigTowerDetId(item.mTrigId)) << ". New value " << fTriggerId << " is ignored" ;
206  return false;
207  }
208  return true;
209 }
uint32_t rawId() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< TriggerItem > mTItems
int linearIndex() const
get a fast, compact, unique index for linear lookups (maximum value = 16384)
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
HcalElectronicsMap & HcalElectronicsMap::operator= ( const HcalElectronicsMap rhs)

Definition at line 39 of file HcalElectronicsMap.cc.

References swap(), and groupFilesInBlocks::temp.

39  {
41  temp.swap(*this);
42  return *this;
43 }
void HcalElectronicsMap::sort ( )
inline
void HcalElectronicsMap::sortById ( ) const

Definition at line 229 of file HcalElectronicsMap.cc.

References i, mPItems, mPItemsById, and python.multivaluedict::sort().

Referenced by findById().

229  {
230  if (!mPItemsById.load(std::memory_order_acquire)) {
231  auto ptr = new std::vector<const PrecisionItem*>;
232  for (auto i=mPItems.begin(); i!=mPItems.end(); ++i) {
233  if (i->mElId) (*ptr).push_back(&(*i));
234  }
235 
236  std::sort ((*ptr).begin(), (*ptr).end(), hcal_impl::LessById ());
237  //atomically try to swap this to become mPItemsById
238  std::vector<const PrecisionItem*>* expect = nullptr;
239  bool exchanged = mPItemsById.compare_exchange_strong(expect, ptr, std::memory_order_acq_rel);
240  if(!exchanged) {
241  delete ptr;
242  }
243  }
244 }
int i
Definition: DBlmapReader.cc:9
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
void HcalElectronicsMap::sortByTriggerId ( ) const

Definition at line 246 of file HcalElectronicsMap.cc.

References i, mTItems, mTItemsByTrigId, and python.multivaluedict::sort().

Referenced by findByTrigId().

246  {
247  if (!mTItemsByTrigId.load(std::memory_order_acquire)) {
248  auto ptr = new std::vector<const TriggerItem*>;
249  for (auto i=mTItems.begin(); i!=mTItems.end(); ++i) {
250  if (i->mElId) (*ptr).push_back(&(*i));
251  }
252 
253  std::sort ((*ptr).begin(), (*ptr).end(), hcal_impl::LessByTrigId ());
254  //atomically try to swap this to become mTItemsByTrigId
255  std::vector<const TriggerItem*>* expect = nullptr;
256  bool exchanged = mTItemsByTrigId.compare_exchange_strong(expect, ptr, std::memory_order_acq_rel);
257  if(!exchanged) {
258  delete ptr;
259  }
260  }
261 }
int i
Definition: DBlmapReader.cc:9
std::vector< TriggerItem > mTItems
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
void HcalElectronicsMap::swap ( HcalElectronicsMap other)

Definition at line 45 of file HcalElectronicsMap.cc.

References mPItems, mPItemsById, mTItems, mTItemsByTrigId, and std::swap().

Referenced by HcalElectronicsMap(), and operator=().

45  {
46  std::swap(mPItems, other.mPItems);
47  std::swap(mTItems, other.mTItems);
48  other.mTItemsByTrigId.exchange(
49  mTItemsByTrigId.exchange(other.mTItemsByTrigId.load(std::memory_order_acquire), std::memory_order_acq_rel),
50  std::memory_order_acq_rel);
51  other.mPItemsById.exchange(
52  mPItemsById.exchange(other.mPItemsById.load(std::memory_order_acquire), std::memory_order_acq_rel),
53  std::memory_order_acq_rel);
54 }
std::vector< PrecisionItem > mPItems
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::vector< TriggerItem > mTItems
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId

Member Data Documentation

std::vector<PrecisionItem> HcalElectronicsMap::mPItems
protected
std::atomic<std::vector<const PrecisionItem*>*> HcalElectronicsMap::mPItemsById
mutableprotected

Definition at line 103 of file HcalElectronicsMap.h.

Referenced by findById(), mapEId2chId(), sortById(), swap(), and ~HcalElectronicsMap().

std::vector<TriggerItem> HcalElectronicsMap::mTItems
protected
std::atomic<std::vector<const TriggerItem*>*> HcalElectronicsMap::mTItemsByTrigId
mutableprotected