CMS 3D CMS Logo

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

#include <CastorElectronicsMap.h>

Classes

class  PrecisionItem
 
class  TriggerItem
 

Public Member Functions

std::vector< CastorElectronicsIdallElectronicsId () const
 
std::vector< CastorElectronicsIdallElectronicsIdPrecision () const
 
std::vector< CastorElectronicsIdallElectronicsIdTrigger () const
 
std::vector< HcalGenericDetIdallPrecisionId () const
 
std::vector< HcalTrigTowerDetIdallTriggerId () const
 
 CastorElectronicsMap ()
 
 CastorElectronicsMap (const CastorElectronicsMap &src)
 
 CastorElectronicsMap (CastorElectronicsMap &&other)
 
const DetId lookup (CastorElectronicsId fId) const
 lookup the logical detid associated with the given electronics id More...
 
const CastorElectronicsId lookup (DetId fId) const
 brief lookup the electronics detid associated with the given logical id More...
 
bool lookup (const CastorElectronicsId pId, CastorElectronicsId &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 CastorElectronicsId pId, CastorElectronicsId &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 (CastorElectronicsId fId) const
 brief lookup the trigger logical detid associated with the given electronics id More...
 
const CastorElectronicsId lookupTrigger (DetId fId) const
 brief lookup the electronics detid associated with the given trigger logical id More...
 
bool mapEId2chId (CastorElectronicsId fElectronicsId, DetId fId)
 
bool mapEId2tId (CastorElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
 
CastorElectronicsMapoperator= (const CastorElectronicsMap &rhs)
 
void sort ()
 
void sortById () const
 
void sortByTriggerId () const
 
void swap (CastorElectronicsMap &other)
 
 ~CastorElectronicsMap ()
 

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
 

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

Author
Fedor Ratnikov (UMd) POOL object to store map between detector ID, electronics ID and trigger ID $Author: ratnikov
Date
2007/12/14 13:31:21
Revision
1.17

Modified for CASTOR by L. Mundim

Author
Fedor Ratnikov (UMd) POOL object to store mapping for Castor channels $Author: ratnikov
Date
2008/01/22 18:58:47
Revision
1.23

Adapted for CASTOR by L. Mundim

Definition at line 30 of file CastorElectronicsMap.h.

Constructor & Destructor Documentation

◆ CastorElectronicsMap() [1/3]

CastorElectronicsMap::CastorElectronicsMap ( )

Definition at line 17 of file CastorElectronicsMap.cc.

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

◆ ~CastorElectronicsMap()

CastorElectronicsMap::~CastorElectronicsMap ( )

Definition at line 38 of file CastorElectronicsMap.cc.

References mPItemsById, and mTItemsByTrigId.

38  {
39  delete mPItemsById.load();
40  delete mTItemsByTrigId.load();
41 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId

◆ CastorElectronicsMap() [2/3]

CastorElectronicsMap::CastorElectronicsMap ( const CastorElectronicsMap src)

Definition at line 43 of file CastorElectronicsMap.cc.

44  : mPItems(src.mPItems), mTItems(src.mTItems), mPItemsById(nullptr), mTItemsByTrigId(nullptr) {}
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
std::vector< TriggerItem > mTItems

◆ CastorElectronicsMap() [3/3]

CastorElectronicsMap::CastorElectronicsMap ( CastorElectronicsMap &&  other)

Definition at line 59 of file CastorElectronicsMap.cc.

References trackingPlots::other.

Member Function Documentation

◆ allElectronicsId()

std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsId ( ) const

Definition at line 149 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, mPItems, mTItems, and mps_fire::result.

Referenced by CastorDbASCIIIO::dumpObject().

149  {
150  std::vector<CastorElectronicsId> result;
151  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
152  if (item->mElId)
153  result.push_back(CastorElectronicsId(item->mElId));
154  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin(); item != mTItems.end(); item++)
155  if (item->mElId)
156  result.push_back(CastorElectronicsId(item->mElId));
157 
158  return result;
159 }
std::vector< PrecisionItem > mPItems
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ allElectronicsIdPrecision()

std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsIdPrecision ( ) const

Definition at line 161 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, mPItems, and mps_fire::result.

161  {
162  std::vector<CastorElectronicsId> result;
163  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
164  if (item->mElId)
165  result.push_back(CastorElectronicsId(item->mElId));
166  return result;
167 }
std::vector< PrecisionItem > mPItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ allElectronicsIdTrigger()

std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsIdTrigger ( ) const

Definition at line 169 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, mTItems, and mps_fire::result.

169  {
170  std::vector<CastorElectronicsId> result;
171  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin(); item != mTItems.end(); item++)
172  if (item->mElId)
173  result.push_back(CastorElectronicsId(item->mElId));
174 
175  return result;
176 }
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ allPrecisionId()

std::vector< HcalGenericDetId > CastorElectronicsMap::allPrecisionId ( ) const

Definition at line 178 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, mPItems, and mps_fire::result.

Referenced by CastorPedestalsAnalysis::analyze().

178  {
179  std::vector<HcalGenericDetId> result;
180  std::set<unsigned long> allIds;
181  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin(); item != mPItems.end(); item++)
182  if (item->mId)
183  allIds.insert(item->mId);
184  for (std::set<unsigned long>::const_iterator channel = allIds.begin(); channel != allIds.end(); channel++) {
185  result.push_back(HcalGenericDetId(*channel));
186  }
187  return result;
188 }
std::vector< PrecisionItem > mPItems

◆ allTriggerId()

std::vector< HcalTrigTowerDetId > CastorElectronicsMap::allTriggerId ( ) const

Definition at line 190 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, mTItems, and mps_fire::result.

190  {
191  std::vector<HcalTrigTowerDetId> result;
192  std::set<unsigned long> allIds;
193  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin(); item != mTItems.end(); item++)
194  if (item->mTrigId)
195  allIds.insert(item->mTrigId);
196  for (std::set<unsigned long>::const_iterator channel = allIds.begin(); channel != allIds.end(); channel++)
197  result.push_back(HcalTrigTowerDetId(*channel));
198  return result;
199 }
std::vector< TriggerItem > mTItems

◆ findById()

const CastorElectronicsMap::PrecisionItem * CastorElectronicsMap::findById ( unsigned long  fId) const
protected

Definition at line 61 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, sortById(), and filterCSVwithJSON::target.

Referenced by lookup().

61  {
62  PrecisionItem target(fId, 0);
63  std::vector<const CastorElectronicsMap::PrecisionItem*>::const_iterator item;
64 
65  sortById();
66 
67  item = std::lower_bound((*mPItemsById).begin(), (*mPItemsById).end(), &target, castor_impl::LessById());
68  if (item == (*mPItemsById).end() || (*item)->mId != fId)
69  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
70  return nullptr;
71  return *item;
72 }

◆ findByTrigId()

const CastorElectronicsMap::TriggerItem * CastorElectronicsMap::findByTrigId ( unsigned long  fTrigId) const
protected

Definition at line 92 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, sortByTriggerId(), and filterCSVwithJSON::target.

Referenced by lookupTrigger().

92  {
93  TriggerItem target(fTrigId, 0);
94  std::vector<const CastorElectronicsMap::TriggerItem*>::const_iterator item;
95 
97 
98  item = std::lower_bound((*mTItemsByTrigId).begin(), (*mTItemsByTrigId).end(), &target, castor_impl::LessByTrigId());
99  if (item == (*mTItemsByTrigId).end() || (*item)->mTrigId != fTrigId)
100  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
101  return nullptr;
102  return *item;
103 }

◆ findPByElId()

const CastorElectronicsMap::PrecisionItem * CastorElectronicsMap::findPByElId ( unsigned long  fElId) const
protected

Definition at line 74 of file CastorElectronicsMap.cc.

References runTauDisplay::eid, mps_fire::i, and mPItems.

Referenced by lookup().

74  {
75  CastorElectronicsId eid(fElId);
76  const PrecisionItem* i = &(mPItems[eid.linearIndex()]);
77 
78  if (i != nullptr && i->mElId != fElId)
79  i = nullptr;
80  return i;
81 }
std::vector< PrecisionItem > mPItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ findTByElId()

const CastorElectronicsMap::TriggerItem * CastorElectronicsMap::findTByElId ( unsigned long  fElId) const
protected

Definition at line 83 of file CastorElectronicsMap.cc.

References runTauDisplay::eid, mps_fire::i, and mTItems.

Referenced by lookupTrigger().

83  {
84  CastorElectronicsId eid(fElId);
85  const TriggerItem* i = &(mTItems[eid.linearIndex()]);
86 
87  if (i != nullptr && i->mElId != fElId)
88  i = nullptr;
89  return i;
90 }
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ lookup() [1/4]

const DetId CastorElectronicsMap::lookup ( CastorElectronicsId  fId) const

lookup the logical detid associated with the given electronics id

Definition at line 105 of file CastorElectronicsMap.cc.

References findPByElId(), B2GTnPMonitor_cfi::item, and CastorElectronicsId::rawId().

Referenced by CastorDbASCIIIO::dumpObject(), CastorCtdcPacker::pack(), CastorPacker::pack(), CastorCtdcUnpacker::unpack(), and CastorUnpacker::unpack().

105  {
106  const PrecisionItem* item = findPByElId(fId.rawId());
107  return DetId(item ? item->mId : 0);
108 }
const PrecisionItem * findPByElId(unsigned long fElId) const
Definition: DetId.h:17
uint32_t rawId() const

◆ lookup() [2/4]

const CastorElectronicsId CastorElectronicsMap::lookup ( DetId  fId) const

brief lookup the electronics detid associated with the given logical id

Definition at line 110 of file CastorElectronicsMap.cc.

References findById(), B2GTnPMonitor_cfi::item, and DetId::rawId().

110  {
111  const PrecisionItem* item = findById(fId.rawId());
112  return CastorElectronicsId(item ? item->mElId : 0);
113 }
const PrecisionItem * findById(unsigned long fId) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ lookup() [3/4]

bool CastorElectronicsMap::lookup ( const CastorElectronicsId  pId,
CastorElectronicsId eid,
HcalGenericDetId did 
) const

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

Definition at line 125 of file CastorElectronicsMap.cc.

References runTauDisplay::eid, mps_fire::i, CastorElectronicsId::linearIndex(), and mPItems.

127  {
128  const PrecisionItem* i = &(mPItems[pid.linearIndex()]);
129  if (i != nullptr && i->mId != 0) {
130  eid = CastorElectronicsId(i->mElId);
131  did = HcalGenericDetId(i->mId);
132  return true;
133  } else
134  return false;
135 }
std::vector< PrecisionItem > mPItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ lookup() [4/4]

bool CastorElectronicsMap::lookup ( const CastorElectronicsId  pId,
CastorElectronicsId eid,
HcalTrigTowerDetId did 
) const

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

Definition at line 137 of file CastorElectronicsMap.cc.

References runTauDisplay::eid, mps_fire::i, CastorElectronicsId::linearIndex(), and mTItems.

139  {
140  const TriggerItem* i = &(mTItems[pid.linearIndex()]);
141  if (i != nullptr && i->mTrigId != 0) {
142  eid = CastorElectronicsId(i->mElId);
143  did = HcalGenericDetId(i->mTrigId);
144  return true;
145  } else
146  return false;
147 }
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ lookupTrigger() [1/2]

const DetId CastorElectronicsMap::lookupTrigger ( CastorElectronicsId  fId) const

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

Definition at line 115 of file CastorElectronicsMap.cc.

References findTByElId(), B2GTnPMonitor_cfi::item, and CastorElectronicsId::rawId().

Referenced by CastorDbASCIIIO::dumpObject().

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

◆ lookupTrigger() [2/2]

const CastorElectronicsId CastorElectronicsMap::lookupTrigger ( DetId  fId) const

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

Definition at line 120 of file CastorElectronicsMap.cc.

References findByTrigId(), B2GTnPMonitor_cfi::item, and DetId::rawId().

120  {
121  const TriggerItem* item = findByTrigId(fId.rawId());
122  return CastorElectronicsId(item ? item->mElId : 0);
123 }
const TriggerItem * findByTrigId(unsigned long fTrigId) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...

◆ mapEId2chId()

bool CastorElectronicsMap::mapEId2chId ( CastorElectronicsId  fElectronicsId,
DetId  fId 
)

Definition at line 216 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, CastorElectronicsId::linearIndex(), mPItems, CastorElectronicsId::rawId(), and DetId::rawId().

Referenced by CastorDbASCIIIO::getObject(), and CastorDbHardcode::makeHardcodeMap().

216  {
217  PrecisionItem& item = mPItems[fElectronicsId.linearIndex()];
218 
219  if (item.mElId == 0)
220  item.mElId = fElectronicsId.rawId();
221  if (item.mId == 0) {
222  item.mId = fId.rawId();
223  } else if (item.mId != fId.rawId()) {
224  edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId
225  << " already mapped to channel " << HcalGenericDetId(item.mId) << ". New value "
226  << HcalGenericDetId(fId) << " is ignored";
227  return false;
228  }
229  return true;
230 }
std::vector< PrecisionItem > mPItems
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Log< level::Warning, false > LogWarning
uint32_t rawId() const

◆ mapEId2tId()

bool CastorElectronicsMap::mapEId2tId ( CastorElectronicsId  fElectronicsId,
HcalTrigTowerDetId  fTriggerId 
)

Definition at line 201 of file CastorElectronicsMap.cc.

References B2GTnPMonitor_cfi::item, CastorElectronicsId::linearIndex(), mTItems, CastorElectronicsId::rawId(), and DetId::rawId().

Referenced by CastorDbASCIIIO::getObject().

201  {
202  TriggerItem& item = mTItems[fElectronicsId.linearIndex()];
203  if (item.mElId == 0)
204  item.mElId = fElectronicsId.rawId();
205  if (item.mTrigId == 0) {
206  item.mTrigId = fTriggerId.rawId(); // just cast avoiding long machinery
207  } else if (item.mTrigId != fTriggerId.rawId()) {
208  edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId
209  << " already mapped to trigger channel " << (HcalTrigTowerDetId(item.mTrigId))
210  << ". New value " << fTriggerId << " is ignored";
211  return false;
212  }
213  return true;
214 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< TriggerItem > mTItems
Log< level::Warning, false > LogWarning
uint32_t rawId() const

◆ operator=()

CastorElectronicsMap & CastorElectronicsMap::operator= ( const CastorElectronicsMap rhs)

Definition at line 46 of file CastorElectronicsMap.cc.

References groupFilesInBlocks::temp.

46  {
48  temp.swap(*this);
49  return *this;
50 }

◆ serialize()

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

◆ sort()

void CastorElectronicsMap::sort ( )
inline

Definition at line 78 of file CastorElectronicsMap.h.

Referenced by CastorDbASCIIIO::getObject(), and CastorDbHardcode::makeHardcodeMap().

78 {}

◆ sortById()

void CastorElectronicsMap::sortById ( ) const

Definition at line 232 of file CastorElectronicsMap.cc.

References mps_fire::i, mPItems, mPItemsById, and jetUpdater_cfi::sort.

Referenced by findById().

232  {
233  if (!mPItemsById) {
234  auto ptr = new std::vector<const PrecisionItem*>;
235  for (auto i = mPItems.begin(); i != mPItems.end(); ++i) {
236  if (i->mElId)
237  (*ptr).push_back(&(*i));
238  }
239  std::sort((*ptr).begin(), (*ptr).end(), castor_impl::LessById());
240  //atomically try to swap this to become mPItemsById
241  std::vector<const PrecisionItem*>* expect = nullptr;
242  bool exchanged = mPItemsById.compare_exchange_strong(expect, ptr);
243  if (!exchanged) {
244  delete ptr;
245  }
246  }
247 }
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById

◆ sortByTriggerId()

void CastorElectronicsMap::sortByTriggerId ( ) const

Definition at line 249 of file CastorElectronicsMap.cc.

References mps_fire::i, mTItems, mTItemsByTrigId, and jetUpdater_cfi::sort.

Referenced by findByTrigId().

249  {
250  if (!mTItemsByTrigId) {
251  auto ptr = new std::vector<const TriggerItem*>;
252  for (auto i = mTItems.begin(); i != mTItems.end(); ++i) {
253  if (i->mElId)
254  (*ptr).push_back(&(*i));
255  }
256 
257  std::sort((*ptr).begin(), (*ptr).end(), castor_impl::LessByTrigId());
258  //atomically try to swap this to become mTItemsByTrigId
259  std::vector<const TriggerItem*>* expect = nullptr;
260  bool exchanged = mTItemsByTrigId.compare_exchange_strong(expect, ptr);
261  if (!exchanged) {
262  delete ptr;
263  }
264  }
265 }
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
std::vector< TriggerItem > mTItems

◆ swap()

void CastorElectronicsMap::swap ( CastorElectronicsMap other)

Definition at line 52 of file CastorElectronicsMap.cc.

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

52  {
53  std::swap(mPItems, other.mPItems);
54  std::swap(mTItems, other.mTItems);
55  other.mTItemsByTrigId.exchange(mTItemsByTrigId.exchange(other.mTItemsByTrigId));
56  other.mPItemsById.exchange(mPItemsById.exchange(other.mPItemsById));
57 }
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
std::vector< TriggerItem > mTItems

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 115 of file CastorElectronicsMap.h.

◆ cond::serialization::access

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

Definition at line 115 of file CastorElectronicsMap.h.

Member Data Documentation

◆ mPItems

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

◆ mPItemsById

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

Definition at line 108 of file CastorElectronicsMap.h.

Referenced by sortById(), swap(), and ~CastorElectronicsMap().

◆ mTItems

std::vector<TriggerItem> CastorElectronicsMap::mTItems
protected

◆ mTItemsByTrigId

std::atomic<std::vector<const TriggerItem*>*> CastorElectronicsMap::mTItemsByTrigId
mutableprotected

Definition at line 109 of file CastorElectronicsMap.h.

Referenced by sortByTriggerId(), swap(), and ~CastorElectronicsMap().