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

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 28 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  if (mPItemsById) {
30  delete mPItemsById;
31  mPItemsById = nullptr;
32  }
33  if (mTItemsByTrigId) {
34  delete mTItemsByTrigId;
35  mTItemsByTrigId = nullptr;
36  }
37 }
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
CastorElectronicsMap::CastorElectronicsMap ( const CastorElectronicsMap src)

Definition at line 39 of file CastorElectronicsMap.cc.

40  : mPItems(src.mPItems), mTItems(src.mTItems),
41  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 57 of file CastorElectronicsMap.cc.

References swap().

59  other.swap(*this);
60 }
void swap(CastorElectronicsMap &other)

Member Function Documentation

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

Definition at line 144 of file CastorElectronicsMap.cc.

References mPItems, mTItems, and query::result.

144  {
145  std::vector <CastorElectronicsId> result;
146  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
147  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
148  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
149  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
150 
151  return result;
152 }
std::vector< PrecisionItem > mPItems
tuple result
Definition: query.py:137
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 154 of file CastorElectronicsMap.cc.

References mPItems, and query::result.

154  {
155  std::vector <CastorElectronicsId> result;
156  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
157  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
158  return result;
159 }
std::vector< PrecisionItem > mPItems
tuple result
Definition: query.py:137
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 161 of file CastorElectronicsMap.cc.

References mTItems, and query::result.

161  {
162  std::vector <CastorElectronicsId> result;
163  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
164  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
165 
166  return result;
167 }
tuple result
Definition: query.py:137
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 169 of file CastorElectronicsMap.cc.

References mPItems, and query::result.

Referenced by CastorPedestalsAnalysis::analyze().

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

Definition at line 180 of file CastorElectronicsMap.cc.

References mTItems, and query::result.

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

Definition at line 62 of file CastorElectronicsMap.cc.

References sortById(), and filterCSVwithJSON::target.

Referenced by lookup().

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

Definition at line 92 of file CastorElectronicsMap.cc.

References 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 0;
102  return *item;
103 }
const CastorElectronicsMap::PrecisionItem * CastorElectronicsMap::findPByElId ( unsigned long  fElId) const
protected

Definition at line 75 of file CastorElectronicsMap.cc.

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

Referenced by lookup().

75  {
76  CastorElectronicsId eid(fElId);
77  const PrecisionItem* i=&(mPItems[eid.linearIndex()]);
78 
79  if (i!=0 && i->mElId!=fElId) i=0;
80  return i;
81 }
int i
Definition: DBlmapReader.cc:9
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 83 of file CastorElectronicsMap.cc.

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

Referenced by lookupTrigger().

83  {
84  CastorElectronicsId eid(fElId);
85  const TriggerItem* i=&(mTItems[eid.linearIndex()]);
86 
87  if (i!=0 && i->mElId!=fElId) i=0;
88  return i;
89 }
int i
Definition: DBlmapReader.cc:9
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 105 of file CastorElectronicsMap.cc.

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

Referenced by 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 }
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 110 of file CastorElectronicsMap.cc.

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

110  {
111  const PrecisionItem* item = findById (fId.rawId ());
112  return CastorElectronicsId (item ? item->mElId : 0);
113 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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 125 of file CastorElectronicsMap.cc.

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

125  {
126  const PrecisionItem* i=&(mPItems[pid.linearIndex()]);
127  if (i!=0 && i->mId!=0) {
128  eid=CastorElectronicsId(i->mElId);
129  did=HcalGenericDetId(i->mId);
130  return true;
131  } else return false;
132 }
int i
Definition: DBlmapReader.cc:9
std::vector< PrecisionItem > mPItems
tuple pid
Definition: sysUtil.py:22
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 134 of file CastorElectronicsMap.cc.

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

134  {
135  const TriggerItem* i=&(mTItems[pid.linearIndex()]);
136  if (i!=0 && i->mTrigId!=0) {
137  eid=CastorElectronicsId(i->mElId);
138  did=HcalGenericDetId(i->mTrigId);
139  return true;
140  } else return false;
141 }
int i
Definition: DBlmapReader.cc:9
tuple pid
Definition: sysUtil.py:22
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 115 of file CastorElectronicsMap.cc.

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

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

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

120  {
121  const TriggerItem* item = findByTrigId (fId.rawId ());
122  return CastorElectronicsId (item ? item->mElId : 0);
123 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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 204 of file CastorElectronicsMap.cc.

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

Referenced by CastorDbHardcode::makeHardcodeMap().

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

Definition at line 190 of file CastorElectronicsMap.cc.

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

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

Definition at line 44 of file CastorElectronicsMap.cc.

References swap(), and groupFilesInBlocks::temp.

44  {
46  temp.swap(*this);
47  return *this;
48 }
void CastorElectronicsMap::sort ( )
inline

Definition at line 76 of file CastorElectronicsMap.h.

Referenced by CastorDbHardcode::makeHardcodeMap().

76 {}
void CastorElectronicsMap::sortById ( ) const

Definition at line 219 of file CastorElectronicsMap.cc.

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

Referenced by findById().

219  {
220  if (!mPItemsById) {
221  auto ptr = new std::vector<const PrecisionItem*>;
222  for (auto i=mPItems.begin(); i!=mPItems.end(); ++i) {
223  if (i->mElId) (*ptr).push_back(&(*i));
224  }
225  std::sort ((*ptr).begin(), (*ptr).end(), castor_impl::LessById ());
226  //atomically try to swap this to become mPItemsById
227  std::vector<const PrecisionItem*>* expect = nullptr;
228  bool exchanged = mPItemsById.compare_exchange_strong(expect, ptr);
229  if(!exchanged) {
230  delete ptr;
231  }
232  }
233 }
int i
Definition: DBlmapReader.cc:9
std::vector< PrecisionItem > mPItems
std::atomic< std::vector< const PrecisionItem * > * > mPItemsById
void CastorElectronicsMap::sortByTriggerId ( ) const

Definition at line 235 of file CastorElectronicsMap.cc.

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

Referenced by findByTrigId().

235  {
236  if (!mTItemsByTrigId) {
237  auto ptr = new std::vector<const TriggerItem*>;
238  for (auto i=mTItems.begin(); i!=mTItems.end(); ++i) {
239  if (i->mElId) (*ptr).push_back(&(*i));
240  }
241 
242  std::sort ((*ptr).begin(), (*ptr).end(), castor_impl::LessByTrigId ());
243  //atomically try to swap this to become mTItemsByTrigId
244  std::vector<const TriggerItem*>* expect = nullptr;
245  bool exchanged = mTItemsByTrigId.compare_exchange_strong(expect, ptr);
246  if(!exchanged) {
247  delete ptr;
248  }
249  }
250 }
int i
Definition: DBlmapReader.cc:9
std::atomic< std::vector< const TriggerItem * > * > mTItemsByTrigId
std::vector< TriggerItem > mTItems
void CastorElectronicsMap::swap ( CastorElectronicsMap other)

Definition at line 50 of file CastorElectronicsMap.cc.

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

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

50  {
51  std::swap(mPItems, other.mPItems);
52  std::swap(mTItems, other.mTItems);
53  other.mTItemsByTrigId.exchange(mTItemsByTrigId.exchange(other.mTItemsByTrigId));
54  other.mPItemsById.exchange(mPItemsById.exchange(other.mPItemsById));
55 }
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

Member Data Documentation

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

Definition at line 103 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 104 of file CastorElectronicsMap.h.

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