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

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

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 29 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::vector< TriggerItem > mTItems
static const int maxLinearIndex
HcalElectronicsMap::~HcalElectronicsMap ( )

Definition at line 27 of file HcalElectronicsMap.cc.

27  {
28  delete mPItemsById.load();
29  delete mTItemsByTrigId.load();
30 }
HcalElectronicsMap::HcalElectronicsMap ( const HcalElectronicsMap src)

Definition at line 32 of file HcalElectronicsMap.cc.

33  : mPItems(src.mPItems), mTItems(src.mTItems),
34  mPItemsById(nullptr), mTItemsByTrigId(nullptr) {}
std::vector< PrecisionItem > mPItems
std::vector< TriggerItem > mTItems
HcalElectronicsMap::HcalElectronicsMap ( HcalElectronicsMap &&  other)

Definition at line 54 of file HcalElectronicsMap.cc.

References swap().

55  : HcalElectronicsMap() {
56  other.swap(*this);
57 }
void swap(HcalElectronicsMap &other)

Member Function Documentation

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

Definition at line 143 of file HcalElectronicsMap.cc.

References mPItems, mTItems, and query::result.

Referenced by HcalLuttoDB::analyze().

143  {
144  std::vector <HcalElectronicsId> result;
145  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
146  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
147  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
148  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
149 
150  return result;
151 }
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 153 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().

153  {
154  std::vector <HcalElectronicsId> result;
155  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
156  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
157  return result;
158 }
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 160 of file HcalElectronicsMap.cc.

References mTItems, and query::result.

Referenced by EMap::EMap().

160  {
161  std::vector <HcalElectronicsId> result;
162  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
163  if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
164 
165  return result;
166 }
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 168 of file HcalElectronicsMap.cc.

References mPItems, and query::result.

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

Definition at line 179 of file HcalElectronicsMap.cc.

References mTItems, and query::result.

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

Definition at line 59 of file HcalElectronicsMap.cc.

References sortById(), and filterCSVwithJSON::target.

Referenced by lookup().

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

Definition at line 90 of file HcalElectronicsMap.cc.

References sortByTriggerId(), and filterCSVwithJSON::target.

Referenced by lookupTrigger().

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

Definition at line 73 of file HcalElectronicsMap.cc.

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

Referenced by lookup().

73  {
74  HcalElectronicsId eid(fElId);
75  const PrecisionItem* i=&(mPItems[eid.linearIndex()]);
76 
77  if (i!=0 && i->mElId!=fElId) i=0;
78  return i;
79 }
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 81 of file HcalElectronicsMap.cc.

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

Referenced by lookupTrigger().

81  {
82  HcalElectronicsId eid(fElId);
83  const TriggerItem* i=&(mTItems[eid.linearIndex()]);
84 
85  if (i!=0 && i->mElId!=fElId) i=0;
86  return i;
87 }
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 109 of file HcalElectronicsMap.cc.

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

109  {
110  const PrecisionItem* item = findById (fId.rawId ());
111  return HcalElectronicsId (item ? item->mElId : 0);
112 }
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 124 of file HcalElectronicsMap.cc.

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

124  {
125  const PrecisionItem* i=&(mPItems[pid.linearIndex()]);
126  if (i!=0 && i->mId!=0) {
127  eid=HcalElectronicsId(i->mElId);
128  did=HcalGenericDetId(i->mId);
129  return true;
130  } else return false;
131 }
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 133 of file HcalElectronicsMap.cc.

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

133  {
134  const TriggerItem* i=&(mTItems[pid.linearIndex()]);
135  if (i!=0 && i->mTrigId!=0) {
136  eid=HcalElectronicsId(i->mElId);
137  did=HcalGenericDetId(i->mTrigId);
138  return true;
139  } else return false;
140 }
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 114 of file HcalElectronicsMap.cc.

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

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

114  {
115  const TriggerItem* item = findTByElId (fId.rawId ());
116  return DetId (item ? item->mTrigId : 0);
117 }
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 119 of file HcalElectronicsMap.cc.

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

119  {
120  const TriggerItem* item = findByTrigId (fId.rawId ());
121  return HcalElectronicsId (item ? item->mElId : 0);
122 }
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 209 of file HcalElectronicsMap.cc.

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

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

209  {
210  PrecisionItem& item = mPItems[fElectronicsId.linearIndex()];
211 
212  delete mPItemsById.load();
213  mPItemsById = nullptr;
214 
215  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
216  if (item.mId == 0) {
217  item.mId = fId.rawId ();
218  }
219  else if (item.mId != fId.rawId ()) {
220  edm::LogWarning("HCAL") << "HcalElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to channel "
221  << HcalGenericDetId(item.mId) << ". New value " << HcalGenericDetId(fId) << " is ignored" ;
222  return false;
223  }
224  return true;
225 }
uint32_t rawId() const
std::vector< PrecisionItem > mPItems
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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 189 of file HcalElectronicsMap.cc.

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

Referenced by HcalLogicalMap::generateHcalElectronicsMap().

189  {
190  TriggerItem& item = mTItems[fElectronicsId.linearIndex()];
191 
192  if (mTItemsByTrigId) {
193  delete mTItemsByTrigId.load();
194  mTItemsByTrigId = nullptr;
195  }
196 
197  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
198  if (item.mTrigId == 0) {
199  item.mTrigId = fTriggerId.rawId (); // just cast avoiding long machinery
200  }
201  else if (item.mTrigId != fTriggerId.rawId ()) {
202  edm::LogWarning("HCAL") << "HcalElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to trigger channel "
203  << (HcalTrigTowerDetId(item.mTrigId)) << ". New value " << fTriggerId << " is ignored" ;
204  return false;
205  }
206  return true;
207 }
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)
HcalElectronicsMap & HcalElectronicsMap::operator= ( const HcalElectronicsMap rhs)

Definition at line 37 of file HcalElectronicsMap.cc.

References swap(), and groupFilesInBlocks::temp.

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

Definition at line 227 of file HcalElectronicsMap.cc.

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

Referenced by findById().

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

Definition at line 244 of file HcalElectronicsMap.cc.

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

Referenced by findByTrigId().

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

Definition at line 43 of file HcalElectronicsMap.cc.

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

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

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

Member Data Documentation

HcalElectronicsMap::COND_SERIALIZABLE
protected

Definition at line 116 of file HcalElectronicsMap.h.

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

Definition at line 109 of file HcalElectronicsMap.h.

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

Definition at line 110 of file HcalElectronicsMap.h.

std::vector<PrecisionItem> HcalElectronicsMap::mPItems
protected
std::vector<TriggerItem> HcalElectronicsMap::mTItems
protected