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 (CastorElectronicsMap &&other)
 
 CastorElectronicsMap (const CastorElectronicsMap &src)
 
const DetId lookup (CastorElectronicsId fId) const
 lookup the logical detid associated with the given electronics 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 CastorElectronicsId lookup (DetId fId) const
 brief lookup the electronics detid associated with the given logical 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.

◆ ~CastorElectronicsMap()

CastorElectronicsMap::~CastorElectronicsMap ( )

Definition at line 38 of file CastorElectronicsMap.cc.

38  {
39  delete mPItemsById.load();
40  delete mTItemsByTrigId.load();
41 }

References mPItemsById, and 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) {}

◆ CastorElectronicsMap() [3/3]

CastorElectronicsMap::CastorElectronicsMap ( CastorElectronicsMap &&  other)

Definition at line 59 of file CastorElectronicsMap.cc.

59 : CastorElectronicsMap() { other.swap(*this); }

References trackingPlots::other.

Member Function Documentation

◆ allElectronicsId()

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

Definition at line 149 of file CastorElectronicsMap.cc.

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 }

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

Referenced by CastorDbASCIIIO::dumpObject().

◆ allElectronicsIdPrecision()

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

Definition at line 161 of file CastorElectronicsMap.cc.

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 }

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

◆ allElectronicsIdTrigger()

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

Definition at line 169 of file CastorElectronicsMap.cc.

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 }

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

◆ allPrecisionId()

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

Definition at line 178 of file CastorElectronicsMap.cc.

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 }

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

Referenced by CastorPedestalsAnalysis::analyze().

◆ allTriggerId()

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

Definition at line 190 of file CastorElectronicsMap.cc.

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 }

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

◆ findById()

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

Definition at line 61 of file CastorElectronicsMap.cc.

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 }

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

Referenced by lookup().

◆ findByTrigId()

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

Definition at line 92 of file CastorElectronicsMap.cc.

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 }

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

Referenced by lookupTrigger().

◆ findPByElId()

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

Definition at line 74 of file CastorElectronicsMap.cc.

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 }

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

Referenced by lookup().

◆ findTByElId()

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

Definition at line 83 of file CastorElectronicsMap.cc.

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 }

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

Referenced by lookupTrigger().

◆ 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.

105  {
106  const PrecisionItem* item = findPByElId(fId.rawId());
107  return DetId(item ? item->mId : 0);
108 }

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

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

◆ lookup() [2/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.

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 }

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

◆ lookup() [3/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.

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 }

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

◆ lookup() [4/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.

110  {
111  const PrecisionItem* item = findById(fId.rawId());
112  return CastorElectronicsId(item ? item->mElId : 0);
113 }

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

◆ 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.

115  {
116  const TriggerItem* item = findTByElId(fId.rawId());
117  return DetId(item ? item->mTrigId : 0);
118 }

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

Referenced by CastorDbASCIIIO::dumpObject().

◆ 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.

120  {
121  const TriggerItem* item = findByTrigId(fId.rawId());
122  return CastorElectronicsId(item ? item->mElId : 0);
123 }

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

◆ mapEId2chId()

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

Definition at line 216 of file CastorElectronicsMap.cc.

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 }

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

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

◆ mapEId2tId()

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

Definition at line 201 of file CastorElectronicsMap.cc.

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 }

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

Referenced by CastorDbASCIIIO::getObject().

◆ operator=()

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

Definition at line 46 of file CastorElectronicsMap.cc.

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

References groupFilesInBlocks::temp.

◆ 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.

78 {}

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

◆ sortById()

void CastorElectronicsMap::sortById ( ) const

Definition at line 232 of file CastorElectronicsMap.cc.

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 }

References mps_fire::i, mPItems, and mPItemsById.

Referenced by findById().

◆ sortByTriggerId()

void CastorElectronicsMap::sortByTriggerId ( ) const

Definition at line 249 of file CastorElectronicsMap.cc.

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 }

References mps_fire::i, mTItems, and mTItemsByTrigId.

Referenced by findByTrigId().

◆ swap()

void CastorElectronicsMap::swap ( CastorElectronicsMap other)

Definition at line 52 of file CastorElectronicsMap.cc.

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 }

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

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().

mps_fire.i
i
Definition: mps_fire.py:428
HcalGenericDetId
Definition: HcalGenericDetId.h:15
CastorElectronicsId::linearIndex
int linearIndex() const
Definition: CastorElectronicsId.h:47
CastorElectronicsMap::sortById
void sortById() const
Definition: CastorElectronicsMap.cc:232
CastorElectronicsMap::findByTrigId
const TriggerItem * findByTrigId(unsigned long fTrigId) const
Definition: CastorElectronicsMap.cc:92
castor_impl::LessById
Definition: CastorElectronicsMap.cc:24
CastorElectronicsMap::findById
const PrecisionItem * findById(unsigned long fId) const
Definition: CastorElectronicsMap.cc:61
CastorElectronicsId::maxLinearIndex
static const int maxLinearIndex
Definition: CastorElectronicsId.h:49
CastorElectronicsMap::findPByElId
const PrecisionItem * findPByElId(unsigned long fElId) const
Definition: CastorElectronicsMap.cc:74
CastorElectronicsId
Readout chain identification for Castor Bits for the readout chain : some names need change!...
Definition: CastorElectronicsId.h:20
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CastorElectronicsMap::CastorElectronicsMap
CastorElectronicsMap()
Definition: CastorElectronicsMap.cc:17
DetId
Definition: DetId.h:17
castor_impl::LessByTrigId
Definition: CastorElectronicsMap.cc:30
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
trackingPlots.other
other
Definition: trackingPlots.py:1467
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
CastorElectronicsMap::mTItems
std::vector< TriggerItem > mTItems
Definition: CastorElectronicsMap.h:106
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
CastorElectronicsId::rawId
uint32_t rawId() const
Definition: CastorElectronicsId.h:29
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
CastorElectronicsMap::findTByElId
const TriggerItem * findTByElId(unsigned long fElId) const
Definition: CastorElectronicsMap.cc:83
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
CastorElectronicsMap
Definition: CastorElectronicsMap.h:30
mps_fire.result
result
Definition: mps_fire.py:311
CastorElectronicsMap::mPItemsById
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
Definition: CastorElectronicsMap.h:108
CastorElectronicsMap::sortByTriggerId
void sortByTriggerId() const
Definition: CastorElectronicsMap.cc:249
CastorElectronicsMap::mPItems
std::vector< PrecisionItem > mPItems
Definition: CastorElectronicsMap.h:105
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14
CastorElectronicsMap::mTItemsByTrigId
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
Definition: CastorElectronicsMap.h:109