CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
HcalFrontEndMap Class Reference

#include <HcalFrontEndMap.h>

Classes

class  PrecisionItem
 

Public Member Functions

std::vector< DetIdallDetIds () const
 
std::vector< std::string > allRBXs () const
 
std::vector< int > allRMs () const
 
 HcalFrontEndMap ()
 
 HcalFrontEndMap (const HcalFrontEndMap &src)
 
 HcalFrontEndMap (HcalFrontEndMap &&other)
 
bool loadObject (DetId fId, int rm, std::string rbx)
 load a new entry More...
 
const std::string lookupRBX (DetId fId) const
 brief lookup the RBX associated with the given logical id More...
 
const int lookupRBXIndex (DetId fId) const
 
const int lookupRM (DetId fId) const
 brief lookup the RM associated with the given logical id More...
 
const int lookupRMIndex (DetId fId) const
 
const int maxRMIndex () const
 
HcalFrontEndMapoperator= (const HcalFrontEndMap &rhs)
 
void sort ()
 
void sortById () const
 
void swap (HcalFrontEndMap &other)
 
 ~HcalFrontEndMap ()
 

Protected Member Functions

const PrecisionItemfindById (uint32_t fId) const
 

Protected Attributes

std::vector< PrecisionItemmPItems
 
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 17 of file HcalFrontEndMap.h.

Constructor & Destructor Documentation

HcalFrontEndMap::HcalFrontEndMap ( )

Definition at line 10 of file HcalFrontEndMap.cc.

10 : mPItemsById(nullptr) {}
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
HcalFrontEndMap::~HcalFrontEndMap ( )

Definition at line 16 of file HcalFrontEndMap.cc.

References mPItemsById.

16  {
17  delete mPItemsById.load();
18 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
HcalFrontEndMap::HcalFrontEndMap ( const HcalFrontEndMap src)

Definition at line 21 of file HcalFrontEndMap.cc.

22  : mPItems(src.mPItems), mPItemsById(nullptr) {}
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::vector< PrecisionItem > mPItems
HcalFrontEndMap::HcalFrontEndMap ( HcalFrontEndMap &&  other)

Definition at line 40 of file HcalFrontEndMap.cc.

References trackingPlots::other.

40  : HcalFrontEndMap() {
41  other.swap(*this);
42 }
void swap(HcalFrontEndMap &other)

Member Function Documentation

std::vector< DetId > HcalFrontEndMap::allDetIds ( ) const

Definition at line 97 of file HcalFrontEndMap.cc.

References mPItems, and mps_fire::result.

Referenced by dumpHcalMatrixObject(), and maxRMIndex().

97  {
98  std::vector <DetId> result;
99  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin ();
100  item != mPItems.end (); item++)
101  if (item->mId) result.push_back(DetId(item->mId));
102  return result;
103 }
Definition: DetId.h:18
std::vector< PrecisionItem > mPItems
std::vector< std::string > HcalFrontEndMap::allRBXs ( ) const

Definition at line 115 of file HcalFrontEndMap.cc.

References spr::find(), mPItems, and mps_fire::result.

Referenced by maxRMIndex().

115  {
116  std::vector <std::string> result;
117  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin ();
118  item != mPItems.end (); item++) {
119  if (std::find(result.begin(),result.end(),item->mRBX) == result.end())
120  result.push_back(item->mRBX);
121  }
122  return result;
123 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< PrecisionItem > mPItems
std::vector< int > HcalFrontEndMap::allRMs ( ) const

Definition at line 105 of file HcalFrontEndMap.cc.

References spr::find(), mPItems, and mps_fire::result.

Referenced by maxRMIndex().

105  {
106  std::vector <int> result;
107  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin ();
108  item != mPItems.end (); item++) {
109  if (std::find(result.begin(),result.end(),item->mRM) == result.end())
110  result.push_back(item->mRM);
111  }
112  return result;
113 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< PrecisionItem > mPItems
const HcalFrontEndMap::PrecisionItem * HcalFrontEndMap::findById ( uint32_t  fId) const
protected

Definition at line 44 of file HcalFrontEndMap.cc.

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

Referenced by loadObject(), lookupRBX(), lookupRBXIndex(), lookupRM(), and lookupRMIndex().

44  {
45  PrecisionItem target (fId, 0, "");
46  std::vector<const HcalFrontEndMap::PrecisionItem*>::const_iterator item;
47 
48  sortById();
49  auto const& ptr = (*mPItemsById.load(std::memory_order_acquire));
50  item = std::lower_bound (ptr.begin(), ptr.end(), &target, hcal_impl::LessById());
51  if (item == ptr.end() || (*item)->mId != fId)
52  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
53  return 0;
54  return *item;
55 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
void sortById() const
bool HcalFrontEndMap::loadObject ( DetId  fId,
int  rm,
std::string  rbx 
)

load a new entry

Definition at line 57 of file HcalFrontEndMap.cc.

References findById(), mPItems, HcalFrontEndMap::PrecisionItem::mRBX, HcalFrontEndMap::PrecisionItem::mRM, DetId::rawId(), submit::rm, and edmPickEvents::target.

Referenced by dumpHcalMatrixObject(), and HcalDbHardcode::makeHardcodeFrontEndMap().

57  {
58  const PrecisionItem* item = findById (fId.rawId ());
59  if (item) {
60  edm::LogWarning("HCAL") << "HcalFrontEndMap::loadObject DetId "
61  << HcalDetId(fId) << " already exists with RM "
62  << item->mRM << " RBX " << item->mRBX
63  << " new values " << rm << " and " << rbx
64  << " are ignored";
65  return false;
66  } else {
67  PrecisionItem target (fId.rawId(), rm, rbx);
68  mPItems.push_back(target);
69  return true;
70  }
71 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const PrecisionItem * findById(uint32_t fId) const
rm
Definition: submit.py:76
std::vector< PrecisionItem > mPItems
const std::string HcalFrontEndMap::lookupRBX ( DetId  fId) const

brief lookup the RBX associated with the given logical id

Definition at line 85 of file HcalFrontEndMap.cc.

References findById(), HcalFrontEndMap::PrecisionItem::mRBX, and DetId::rawId().

Referenced by HBHEIsolatedNoiseReflagger::DumpHBHEHitMap(), dumpHcalMatrixObject(), and maxRMIndex().

85  {
86  const PrecisionItem* item = findById (fId.rawId ());
87  return (item ? item->mRBX : "");
88 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const PrecisionItem * findById(uint32_t fId) const
const int HcalFrontEndMap::lookupRBXIndex ( DetId  fId) const

Definition at line 90 of file HcalFrontEndMap.cc.

References findById(), hcalTTPDigis_cfi::id, HcalFrontEndMap::PrecisionItem::mRBX, HcalFrontEndMap::PrecisionItem::mRM, and DetId::rawId().

Referenced by HBHEHitMapOrganizer::HBHEHitMapOrganizer(), and maxRMIndex().

90  {
91  const PrecisionItem* item = findById (fId.rawId ());
93  if (item) id = HcalFrontEndId(item->mRBX,item->mRM,0,1,0,1,0);
94  return id.rbxIndex();
95 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const PrecisionItem * findById(uint32_t fId) const
const int HcalFrontEndMap::lookupRM ( DetId  fId) const

brief lookup the RM associated with the given logical id

Definition at line 73 of file HcalFrontEndMap.cc.

References findById(), HcalFrontEndMap::PrecisionItem::mRM, and DetId::rawId().

Referenced by dumpHcalMatrixObject().

73  {
74  const PrecisionItem* item = findById (fId.rawId ());
75  return (item ? item->mRM : 0);
76 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const PrecisionItem * findById(uint32_t fId) const
const int HcalFrontEndMap::lookupRMIndex ( DetId  fId) const

Definition at line 78 of file HcalFrontEndMap.cc.

References findById(), hcalTTPDigis_cfi::id, HcalFrontEndMap::PrecisionItem::mRBX, HcalFrontEndMap::PrecisionItem::mRM, and DetId::rawId().

Referenced by HBHEIsolatedNoiseReflagger::DumpHBHEHitMap(), HBHEHitMapOrganizer::getHPDNeighbors(), HBHEHitMapOrganizer::HBHEHitMapOrganizer(), HBHEStatusBitSetter::rememberHit(), and HBHEStatusBitSetter::SetFlagsFromRecHits().

78  {
79  const PrecisionItem* item = findById (fId.rawId ());
81  if (item) id = HcalFrontEndId(item->mRBX,item->mRM,0,1,0,1,0);
82  return id.rmIndex();
83 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const PrecisionItem * findById(uint32_t fId) const
const int HcalFrontEndMap::maxRMIndex ( ) const
inline
HcalFrontEndMap & HcalFrontEndMap::operator= ( const HcalFrontEndMap rhs)

Definition at line 25 of file HcalFrontEndMap.cc.

References swap(), and groupFilesInBlocks::temp.

25  {
26  HcalFrontEndMap temp(rhs);
27  temp.swap(*this);
28  return *this;
29 }
template<class Archive >
void HcalFrontEndMap::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void HcalFrontEndMap::sort ( )
inline

Definition at line 53 of file HcalFrontEndMap.h.

Referenced by dumpHcalMatrixObject(), and HcalDbHardcode::makeHardcodeFrontEndMap().

53 {}
void HcalFrontEndMap::sortById ( ) const

Definition at line 125 of file HcalFrontEndMap.cc.

References mps_fire::i, mPItems, and mPItemsById.

Referenced by findById(), and maxRMIndex().

125  {
126  if (!mPItemsById.load(std::memory_order_acquire)) {
127  auto ptr = new std::vector<const PrecisionItem*>;
128  for (auto i=mPItems.begin(); i!=mPItems.end(); ++i) {
129  if (i->mId) (*ptr).push_back(&(*i));
130  }
131 
132  std::sort ((*ptr).begin(), (*ptr).end(), hcal_impl::LessById ());
133  //atomically try to swap this to become mPItemsById
134  std::vector<const PrecisionItem*>* expect = nullptr;
135  bool exchanged = mPItemsById.compare_exchange_strong(expect, ptr, std::memory_order_acq_rel);
136  if(!exchanged) {
137  delete ptr;
138  }
139  }
140 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::vector< PrecisionItem > mPItems
void HcalFrontEndMap::swap ( HcalFrontEndMap other)

Definition at line 32 of file HcalFrontEndMap.cc.

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

Referenced by operator=().

32  {
33  std::swap(mPItems, other.mPItems);
34  other.mPItemsById.exchange(mPItemsById.exchange(other.mPItemsById.load(std::memory_order_acquire),
35  std::memory_order_acq_rel),
36  std::memory_order_acq_rel);
37 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< PrecisionItem > mPItems

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 76 of file HcalFrontEndMap.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 76 of file HcalFrontEndMap.h.

Member Data Documentation

std::vector<PrecisionItem> HcalFrontEndMap::mPItems
protected

Definition at line 69 of file HcalFrontEndMap.h.

Referenced by allDetIds(), allRBXs(), allRMs(), loadObject(), sortById(), and swap().

std::atomic<std::vector<const PrecisionItem*>*> HcalFrontEndMap::mPItemsById
mutableprotected

Definition at line 71 of file HcalFrontEndMap.h.

Referenced by findById(), sortById(), swap(), and ~HcalFrontEndMap().