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::CastorElectronicsMap ( )

Definition at line 17 of file CastorElectronicsMap.cc.

17  :
20  mPItemsById(nullptr), mTItemsByTrigId(nullptr)
21 {}
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 ( )

Definition at line 28 of file CastorElectronicsMap.cc.

References mPItemsById, and mTItemsByTrigId.

28  {
29  delete mPItemsById.load();
30  delete mTItemsByTrigId.load();
31 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
CastorElectronicsMap::CastorElectronicsMap ( const CastorElectronicsMap src)

Definition at line 33 of file CastorElectronicsMap.cc.

34  : mPItems(src.mPItems), mTItems(src.mTItems),
35  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::CastorElectronicsMap ( CastorElectronicsMap &&  other)

Definition at line 51 of file CastorElectronicsMap.cc.

References trackingPlots::other.

53  other.swap(*this);
54 }
void swap(CastorElectronicsMap &other)

Member Function Documentation

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

Definition at line 138 of file CastorElectronicsMap.cc.

References mPItems, mTItems, and mps_fire::result.

Referenced by CastorDbASCIIIO::dumpObject().

138  {
139  std::vector <CastorElectronicsId> result;
140  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
141  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
142  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
143  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
144 
145  return result;
146 }
std::vector< PrecisionItem > mPItems
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsIdPrecision ( ) const

Definition at line 148 of file CastorElectronicsMap.cc.

References mPItems, and mps_fire::result.

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

Definition at line 155 of file CastorElectronicsMap.cc.

References mTItems, and mps_fire::result.

155  {
156  std::vector <CastorElectronicsId> result;
157  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
158  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
159 
160  return result;
161 }
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
std::vector< HcalGenericDetId > CastorElectronicsMap::allPrecisionId ( ) const

Definition at line 163 of file CastorElectronicsMap.cc.

References mPItems, and mps_fire::result.

Referenced by CastorPedestalsAnalysis::analyze().

163  {
164  std::vector <HcalGenericDetId> result;
165  std::set <unsigned long> allIds;
166  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
167  if (item->mId) allIds.insert (item->mId);
168  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) {
169  result.push_back (HcalGenericDetId (*channel));
170  }
171  return result;
172 }
std::vector< PrecisionItem > mPItems
std::vector< HcalTrigTowerDetId > CastorElectronicsMap::allTriggerId ( ) const

Definition at line 174 of file CastorElectronicsMap.cc.

References mTItems, and mps_fire::result.

174  {
175  std::vector <HcalTrigTowerDetId> result;
176  std::set <unsigned long> allIds;
177  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
178  if (item->mTrigId) allIds.insert (item->mTrigId);
179  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++)
180  result.push_back (HcalTrigTowerDetId (*channel));
181  return result;
182 }
std::vector< TriggerItem > mTItems
const CastorElectronicsMap::PrecisionItem * CastorElectronicsMap::findById ( unsigned long  fId) const
protected

Definition at line 56 of file CastorElectronicsMap.cc.

References sortById(), and edmPickEvents::target.

Referenced by lookup().

56  {
57  PrecisionItem target (fId, 0);
58  std::vector<const CastorElectronicsMap::PrecisionItem*>::const_iterator item;
59 
60  sortById();
61 
62  item = std::lower_bound ((*mPItemsById).begin(), (*mPItemsById).end(), &target, castor_impl::LessById());
63  if (item == (*mPItemsById).end() || (*item)->mId != fId)
64  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
65  return nullptr;
66  return *item;
67 }
const CastorElectronicsMap::TriggerItem * CastorElectronicsMap::findByTrigId ( unsigned long  fTrigId) const
protected

Definition at line 86 of file CastorElectronicsMap.cc.

References sortByTriggerId(), and edmPickEvents::target.

Referenced by lookupTrigger().

86  {
87  TriggerItem target (fTrigId,0);
88  std::vector<const CastorElectronicsMap::TriggerItem*>::const_iterator item;
89 
91 
92  item = std::lower_bound ((*mTItemsByTrigId).begin(), (*mTItemsByTrigId).end(), &target, castor_impl::LessByTrigId());
93  if (item == (*mTItemsByTrigId).end() || (*item)->mTrigId != fTrigId)
94  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
95  return nullptr;
96  return *item;
97 }
const CastorElectronicsMap::PrecisionItem * CastorElectronicsMap::findPByElId ( unsigned long  fElId) const
protected

Definition at line 69 of file CastorElectronicsMap.cc.

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

Referenced by lookup().

69  {
70  CastorElectronicsId eid(fElId);
71  const PrecisionItem* i=&(mPItems[eid.linearIndex()]);
72 
73  if (i!=nullptr && i->mElId!=fElId) i=nullptr;
74  return i;
75 }
std::vector< PrecisionItem > mPItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
const CastorElectronicsMap::TriggerItem * CastorElectronicsMap::findTByElId ( unsigned long  fElId) const
protected

Definition at line 77 of file CastorElectronicsMap.cc.

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

Referenced by lookupTrigger().

77  {
78  CastorElectronicsId eid(fElId);
79  const TriggerItem* i=&(mTItems[eid.linearIndex()]);
80 
81  if (i!=nullptr && i->mElId!=fElId) i=nullptr;
82  return i;
83 }
std::vector< TriggerItem > mTItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
const DetId CastorElectronicsMap::lookup ( CastorElectronicsId  fId) const

lookup the logical detid associated with the given electronics id

Definition at line 99 of file CastorElectronicsMap.cc.

References findPByElId(), CastorElectronicsMap::PrecisionItem::mId, and CastorElectronicsId::rawId().

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

99  {
100  const PrecisionItem* item = findPByElId (fId.rawId ());
101  return DetId (item ? item->mId : 0);
102 }
uint32_t rawId() const
const PrecisionItem * findPByElId(unsigned long fElId) const
Definition: DetId.h:18
const CastorElectronicsId CastorElectronicsMap::lookup ( DetId  fId) const

brief lookup the electronics detid associated with the given logical id

Definition at line 104 of file CastorElectronicsMap.cc.

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

104  {
105  const PrecisionItem* item = findById (fId.rawId ());
106  return CastorElectronicsId (item ? item->mElId : 0);
107 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
const PrecisionItem * findById(unsigned long fId) const
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
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 119 of file CastorElectronicsMap.cc.

References mps_fire::i, CastorElectronicsId::linearIndex(), CastorElectronicsMap::PrecisionItem::mElId, CastorElectronicsMap::PrecisionItem::mId, and mPItems.

119  {
120  const PrecisionItem* i=&(mPItems[pid.linearIndex()]);
121  if (i!=nullptr && i->mId!=0) {
122  eid=CastorElectronicsId(i->mElId);
123  did=HcalGenericDetId(i->mId);
124  return true;
125  } else return false;
126 }
std::vector< PrecisionItem > mPItems
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
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 128 of file CastorElectronicsMap.cc.

References mps_fire::i, CastorElectronicsId::linearIndex(), CastorElectronicsMap::TriggerItem::mElId, mTItems, and CastorElectronicsMap::TriggerItem::mTrigId.

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

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

Definition at line 109 of file CastorElectronicsMap.cc.

References findTByElId(), CastorElectronicsMap::TriggerItem::mTrigId, and CastorElectronicsId::rawId().

Referenced by CastorDbASCIIIO::dumpObject().

109  {
110  const TriggerItem* item = findTByElId (fId.rawId ());
111  return DetId (item ? item->mTrigId : 0);
112 }
const TriggerItem * findTByElId(unsigned long fElId) const
uint32_t rawId() const
Definition: DetId.h:18
const CastorElectronicsId CastorElectronicsMap::lookupTrigger ( DetId  fId) const

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

Definition at line 114 of file CastorElectronicsMap.cc.

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

114  {
115  const TriggerItem* item = findByTrigId (fId.rawId ());
116  return CastorElectronicsId (item ? item->mElId : 0);
117 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
const TriggerItem * findByTrigId(unsigned long fTrigId) const
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
bool CastorElectronicsMap::mapEId2chId ( CastorElectronicsId  fElectronicsId,
DetId  fId 
)

Definition at line 198 of file CastorElectronicsMap.cc.

References CastorElectronicsId::linearIndex(), CastorElectronicsMap::PrecisionItem::mElId, CastorElectronicsMap::PrecisionItem::mId, mPItems, CastorElectronicsId::rawId(), and DetId::rawId().

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

198  {
199  PrecisionItem& item = mPItems[fElectronicsId.linearIndex()];
200 
201  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
202  if (item.mId == 0) {
203  item.mId = fId.rawId ();
204  }
205  else if (item.mId != fId.rawId ()) {
206  edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to channel "
207  << HcalGenericDetId(item.mId) << ". New value " << HcalGenericDetId(fId) << " is ignored" ;
208  return false;
209  }
210  return true;
211 }
std::vector< PrecisionItem > mPItems
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
uint32_t rawId() const
bool CastorElectronicsMap::mapEId2tId ( CastorElectronicsId  fElectronicsId,
HcalTrigTowerDetId  fTriggerId 
)

Definition at line 184 of file CastorElectronicsMap.cc.

References CastorElectronicsId::linearIndex(), CastorElectronicsMap::TriggerItem::mElId, mTItems, CastorElectronicsMap::TriggerItem::mTrigId, CastorElectronicsId::rawId(), and DetId::rawId().

Referenced by CastorDbASCIIIO::getObject().

184  {
185  TriggerItem& item = mTItems[fElectronicsId.linearIndex()];
186  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
187  if (item.mTrigId == 0) {
188  item.mTrigId = fTriggerId.rawId (); // just cast avoiding long machinery
189  }
190  else if (item.mTrigId != fTriggerId.rawId ()) {
191  edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to trigger channel "
192  << (HcalTrigTowerDetId(item.mTrigId)) << ". New value " << fTriggerId << " is ignored" ;
193  return false;
194  }
195  return true;
196 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
uint32_t rawId() const
std::vector< TriggerItem > mTItems
CastorElectronicsMap & CastorElectronicsMap::operator= ( const CastorElectronicsMap rhs)

Definition at line 38 of file CastorElectronicsMap.cc.

References swap(), and groupFilesInBlocks::temp.

38  {
40  temp.swap(*this);
41  return *this;
42 }
template<class Archive >
void CastorElectronicsMap::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void CastorElectronicsMap::sort ( )
inline

Definition at line 78 of file CastorElectronicsMap.h.

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

78 {}
void CastorElectronicsMap::sortById ( ) const

Definition at line 213 of file CastorElectronicsMap.cc.

References mps_fire::i, mPItems, and mPItemsById.

Referenced by findById().

213  {
214  if (!mPItemsById) {
215  auto ptr = new std::vector<const PrecisionItem*>;
216  for (auto i=mPItems.begin(); i!=mPItems.end(); ++i) {
217  if (i->mElId) (*ptr).push_back(&(*i));
218  }
219  std::sort ((*ptr).begin(), (*ptr).end(), castor_impl::LessById ());
220  //atomically try to swap this to become mPItemsById
221  std::vector<const PrecisionItem*>* expect = nullptr;
222  bool exchanged = mPItemsById.compare_exchange_strong(expect, ptr);
223  if(!exchanged) {
224  delete ptr;
225  }
226  }
227 }
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
void CastorElectronicsMap::sortByTriggerId ( ) const

Definition at line 229 of file CastorElectronicsMap.cc.

References mps_fire::i, mTItems, and mTItemsByTrigId.

Referenced by findByTrigId().

229  {
230  if (!mTItemsByTrigId) {
231  auto ptr = new std::vector<const TriggerItem*>;
232  for (auto i=mTItems.begin(); i!=mTItems.end(); ++i) {
233  if (i->mElId) (*ptr).push_back(&(*i));
234  }
235 
236  std::sort ((*ptr).begin(), (*ptr).end(), castor_impl::LessByTrigId ());
237  //atomically try to swap this to become mTItemsByTrigId
238  std::vector<const TriggerItem*>* expect = nullptr;
239  bool exchanged = mTItemsByTrigId.compare_exchange_strong(expect, ptr);
240  if(!exchanged) {
241  delete ptr;
242  }
243  }
244 }
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
std::vector< TriggerItem > mTItems
void CastorElectronicsMap::swap ( CastorElectronicsMap other)

Definition at line 44 of file CastorElectronicsMap.cc.

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

Referenced by operator=().

44  {
45  std::swap(mPItems, other.mPItems);
46  std::swap(mTItems, other.mTItems);
47  other.mTItemsByTrigId.exchange(mTItemsByTrigId.exchange(other.mTItemsByTrigId));
48  other.mPItemsById.exchange(mPItemsById.exchange(other.mPItemsById));
49 }
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

friend class boost::serialization::access
friend

Definition at line 116 of file CastorElectronicsMap.h.

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

Definition at line 116 of file CastorElectronicsMap.h.

Member Data Documentation

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

Definition at line 109 of file CastorElectronicsMap.h.

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

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

Definition at line 110 of file CastorElectronicsMap.h.

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