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 ()
 
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)
 
void sort ()
 
void sortById () const
 
void sortByTriggerId () const
 
 ~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::vector< const
PrecisionItem * > 
mPItemsById
 
std::vector< TriggerItemmTItems
 
std::vector< const TriggerItem * > mTItemsByTrigId
 
bool sortedByPId
 
bool sortedByTId
 

Detailed Description

Author
Fedor Ratnikov (UMd) POOL object to store map between detector ID, electronics ID and trigger ID $Author: ratnikov
Date:
2009/03/26 18:03:15
Revision:
1.2

Modified for CASTOR by L. Mundim

Author
Fedor Ratnikov (UMd) POOL object to store mapping for Castor channels $Author: ratnikov
Date:
2009/03/26 18:03:15
Revision:
1.2

Adapted for CASTOR by L. Mundim

Definition at line 25 of file CastorElectronicsMap.h.

Constructor & Destructor Documentation

CastorElectronicsMap::CastorElectronicsMap ( )

Definition at line 17 of file CastorElectronicsMap.cc.

17  :
20  sortedByPId(false),
21  sortedByTId(false)
22 {}
std::vector< PrecisionItem > mPItems
static const int maxLinearIndex
std::vector< TriggerItem > mTItems
CastorElectronicsMap::~CastorElectronicsMap ( )

Definition at line 29 of file CastorElectronicsMap.cc.

29 {}

Member Function Documentation

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

Definition at line 113 of file CastorElectronicsMap.cc.

References mPItems, mTItems, and query::result.

113  {
114  std::vector <CastorElectronicsId> result;
115  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
116  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
117  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
118  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
119 
120  return result;
121 }
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 123 of file CastorElectronicsMap.cc.

References mPItems, and query::result.

123  {
124  std::vector <CastorElectronicsId> result;
125  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
126  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
127  return result;
128 }
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 130 of file CastorElectronicsMap.cc.

References mTItems, and query::result.

130  {
131  std::vector <CastorElectronicsId> result;
132  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
133  if (item->mElId) result.push_back(CastorElectronicsId(item->mElId));
134 
135  return result;
136 }
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 138 of file CastorElectronicsMap.cc.

References mPItems, and query::result.

Referenced by CastorPedestalsAnalysis::analyze().

138  {
139  std::vector <HcalGenericDetId> result;
140  std::set <unsigned long> allIds;
141  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++)
142  if (item->mId) allIds.insert (item->mId);
143  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) {
144  result.push_back (HcalGenericDetId (*channel));
145  }
146  return result;
147 }
std::vector< PrecisionItem > mPItems
tuple result
Definition: query.py:137
std::vector< HcalTrigTowerDetId > CastorElectronicsMap::allTriggerId ( ) const

Definition at line 149 of file CastorElectronicsMap.cc.

References mTItems, and query::result.

149  {
150  std::vector <HcalTrigTowerDetId> result;
151  std::set <unsigned long> allIds;
152  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++)
153  if (item->mTrigId) allIds.insert (item->mTrigId);
154  for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++)
155  result.push_back (HcalTrigTowerDetId (*channel));
156  return result;
157 }
tuple result
Definition: query.py:137
std::vector< TriggerItem > mTItems
const CastorElectronicsMap::PrecisionItem * CastorElectronicsMap::findById ( unsigned long  fId) const
protected

Definition at line 31 of file CastorElectronicsMap.cc.

References mPItemsById, sortById(), sortedByPId, and filterCSVwithJSON::target.

Referenced by lookup().

31  {
32  PrecisionItem target (fId, 0);
33  std::vector<const CastorElectronicsMap::PrecisionItem*>::const_iterator item;
34 
35  if (!sortedByPId) sortById();
36 
37  item = std::lower_bound (mPItemsById.begin(), mPItemsById.end(), &target, castor_impl::LessById());
38  if (item == mPItemsById.end() || (*item)->mId != fId)
39  // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId;
40  return 0;
41  return *item;
42 }
std::vector< const PrecisionItem * > mPItemsById
const CastorElectronicsMap::TriggerItem * CastorElectronicsMap::findByTrigId ( unsigned long  fTrigId) const
protected

Definition at line 61 of file CastorElectronicsMap.cc.

References mTItemsByTrigId, sortByTriggerId(), sortedByTId, and filterCSVwithJSON::target.

Referenced by lookupTrigger().

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

Definition at line 44 of file CastorElectronicsMap.cc.

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

Referenced by lookup().

44  {
45  CastorElectronicsId eid(fElId);
46  const PrecisionItem* i=&(mPItems[eid.linearIndex()]);
47 
48  if (i!=0 && i->mElId!=fElId) i=0;
49  return i;
50 }
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 52 of file CastorElectronicsMap.cc.

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

Referenced by lookupTrigger().

52  {
53  CastorElectronicsId eid(fElId);
54  const TriggerItem* i=&(mTItems[eid.linearIndex()]);
55 
56  if (i!=0 && i->mElId!=fElId) i=0;
57  return i;
58 }
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 74 of file CastorElectronicsMap.cc.

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

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

74  {
75  const PrecisionItem* item = findPByElId (fId.rawId ());
76  return DetId (item ? item->mId : 0);
77 }
uint32_t rawId() const
const PrecisionItem * findPByElId(unsigned long fElId) const
Definition: DetId.h:20
const CastorElectronicsId CastorElectronicsMap::lookup ( DetId  fId) const

brief lookup the electronics detid associated with the given logical id

Definition at line 79 of file CastorElectronicsMap.cc.

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

79  {
80  const PrecisionItem* item = findById (fId.rawId ());
81  return CastorElectronicsId (item ? item->mElId : 0);
82 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
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 94 of file CastorElectronicsMap.cc.

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

94  {
95  const PrecisionItem* i=&(mPItems[pid.linearIndex()]);
96  if (i!=0 && i->mId!=0) {
97  eid=CastorElectronicsId(i->mElId);
98  did=HcalGenericDetId(i->mId);
99  return true;
100  } else return false;
101 }
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] ...
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 103 of file CastorElectronicsMap.cc.

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

103  {
104  const TriggerItem* i=&(mTItems[pid.linearIndex()]);
105  if (i!=0 && i->mTrigId!=0) {
106  eid=CastorElectronicsId(i->mElId);
107  did=HcalGenericDetId(i->mTrigId);
108  return true;
109  } else return false;
110 }
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::lookupTrigger ( CastorElectronicsId  fId) const

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

Definition at line 84 of file CastorElectronicsMap.cc.

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

84  {
85  const TriggerItem* item = findTByElId (fId.rawId ());
86  return DetId (item ? item->mTrigId : 0);
87 }
const TriggerItem * findTByElId(unsigned long fElId) const
uint32_t rawId() const
Definition: DetId.h:20
const CastorElectronicsId CastorElectronicsMap::lookupTrigger ( DetId  fId) const

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

Definition at line 89 of file CastorElectronicsMap.cc.

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

89  {
90  const TriggerItem* item = findByTrigId (fId.rawId ());
91  return CastorElectronicsId (item ? item->mElId : 0);
92 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
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 174 of file CastorElectronicsMap.cc.

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

Referenced by CastorDbHardcode::makeHardcodeMap().

174  {
175  PrecisionItem& item = mPItems[fElectronicsId.linearIndex()];
176 
177  sortedByPId=false;
178  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
179  if (item.mId == 0) {
180  item.mId = fId.rawId ();
181  }
182  else if (item.mId != fId.rawId ()) {
183  edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to channel "
184  << HcalGenericDetId(item.mId) << ". New value " << HcalGenericDetId(fId) << " is ignored" ;
185  return false;
186  }
187  return true;
188 }
std::vector< PrecisionItem > mPItems
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
uint32_t rawId() const
bool CastorElectronicsMap::mapEId2tId ( CastorElectronicsId  fElectronicsId,
HcalTrigTowerDetId  fTriggerId 
)

Definition at line 159 of file CastorElectronicsMap.cc.

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

159  {
160  TriggerItem& item = mTItems[fElectronicsId.linearIndex()];
161  sortedByTId=false;
162  if (item.mElId==0) item.mElId=fElectronicsId.rawId();
163  if (item.mTrigId == 0) {
164  item.mTrigId = fTriggerId.rawId (); // just cast avoiding long machinery
165  }
166  else if (item.mTrigId != fTriggerId.rawId ()) {
167  edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to trigger channel "
168  << (HcalTrigTowerDetId(item.mTrigId)) << ". New value " << fTriggerId << " is ignored" ;
169  return false;
170  }
171  return true;
172 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
uint32_t rawId() const
std::vector< TriggerItem > mTItems
void CastorElectronicsMap::sort ( )
inline

Definition at line 63 of file CastorElectronicsMap.h.

Referenced by CastorDbHardcode::makeHardcodeMap().

63 {}
void CastorElectronicsMap::sortById ( ) const

Definition at line 190 of file CastorElectronicsMap.cc.

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

Referenced by findById().

190  {
191  if (!sortedByPId) {
192  mPItemsById.clear();
193  for (std::vector<PrecisionItem>::const_iterator i=mPItems.begin(); i!=mPItems.end(); ++i) {
194  if (i->mElId) mPItemsById.push_back(&(*i));
195  }
196 
198  sortedByPId=true;
199  }
200 }
int i
Definition: DBlmapReader.cc:9
std::vector< PrecisionItem > mPItems
std::vector< const PrecisionItem * > mPItemsById
void CastorElectronicsMap::sortByTriggerId ( ) const

Definition at line 202 of file CastorElectronicsMap.cc.

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

Referenced by findByTrigId().

202  {
203  if (!sortedByTId) {
204  mTItemsByTrigId.clear();
205  for (std::vector<TriggerItem>::const_iterator i=mTItems.begin(); i!=mTItems.end(); ++i) {
206  if (i->mElId) mTItemsByTrigId.push_back(&(*i));
207  }
208 
210  sortedByTId=true;
211  }
212 }
int i
Definition: DBlmapReader.cc:9
std::vector< const TriggerItem * > mTItemsByTrigId
std::vector< TriggerItem > mTItems

Member Data Documentation

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

Definition at line 89 of file CastorElectronicsMap.h.

Referenced by findById(), and sortById().

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

Definition at line 91 of file CastorElectronicsMap.h.

Referenced by findByTrigId(), and sortByTriggerId().

bool CastorElectronicsMap::sortedByPId
mutableprotected

Definition at line 90 of file CastorElectronicsMap.h.

Referenced by findById(), mapEId2chId(), and sortById().

bool CastorElectronicsMap::sortedByTId
mutableprotected

Definition at line 92 of file CastorElectronicsMap.h.

Referenced by findByTrigId(), mapEId2tId(), and sortByTriggerId().