#include <CastorElectronicsMap.h>
Classes | |
class | PrecisionItem |
class | TriggerItem |
Public Member Functions | |
std::vector< CastorElectronicsId > | allElectronicsId () const |
std::vector< CastorElectronicsId > | allElectronicsIdPrecision () const |
std::vector< CastorElectronicsId > | allElectronicsIdTrigger () const |
std::vector< HcalGenericDetId > | allPrecisionId () const |
std::vector< HcalTrigTowerDetId > | allTriggerId () const |
CastorElectronicsMap () | |
const CastorElectronicsId | lookup (DetId fId) const |
brief lookup the electronics detid associated with the given logical id | |
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 | |
const DetId | lookup (CastorElectronicsId fId) const |
lookup the logical detid associated with the given electronics id | |
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 | |
const DetId | lookupTrigger (CastorElectronicsId fId) const |
brief lookup the trigger logical detid associated with the given electronics id | |
const CastorElectronicsId | lookupTrigger (DetId fId) const |
brief lookup the electronics detid associated with the given trigger logical id | |
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 PrecisionItem * | findById (unsigned long fId) const |
const TriggerItem * | findByTrigId (unsigned long fTrigId) const |
const PrecisionItem * | findPByElId (unsigned long fElId) const |
const TriggerItem * | findTByElId (unsigned long fElId) const |
Protected Attributes | |
std::vector< PrecisionItem > | mPItems |
std::vector< const PrecisionItem * > | mPItemsById |
std::vector< TriggerItem > | mTItems |
std::vector< const TriggerItem * > | mTItemsByTrigId |
bool | sortedByPId |
bool | sortedByTId |
Modified for CASTOR by L. Mundim
Adapted for CASTOR by L. Mundim
Definition at line 25 of file CastorElectronicsMap.h.
CastorElectronicsMap::CastorElectronicsMap | ( | ) |
Definition at line 17 of file CastorElectronicsMap.cc.
: mPItems(CastorElectronicsId::maxLinearIndex+1), mTItems(CastorElectronicsId::maxLinearIndex+1), sortedByPId(false), sortedByTId(false) {}
CastorElectronicsMap::~CastorElectronicsMap | ( | ) |
Definition at line 29 of file CastorElectronicsMap.cc.
{}
std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsId | ( | ) | const |
Definition at line 113 of file CastorElectronicsMap.cc.
References mPItems, mTItems, and query::result.
{ std::vector <CastorElectronicsId> result; for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++) if (item->mElId) result.push_back(CastorElectronicsId(item->mElId)); for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++) if (item->mElId) result.push_back(CastorElectronicsId(item->mElId)); return result; }
std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsIdPrecision | ( | ) | const |
Definition at line 123 of file CastorElectronicsMap.cc.
References mPItems, and query::result.
{ std::vector <CastorElectronicsId> result; for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++) if (item->mElId) result.push_back(CastorElectronicsId(item->mElId)); return result; }
std::vector< CastorElectronicsId > CastorElectronicsMap::allElectronicsIdTrigger | ( | ) | const |
Definition at line 130 of file CastorElectronicsMap.cc.
References mTItems, and query::result.
{ std::vector <CastorElectronicsId> result; for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++) if (item->mElId) result.push_back(CastorElectronicsId(item->mElId)); return result; }
std::vector< HcalGenericDetId > CastorElectronicsMap::allPrecisionId | ( | ) | const |
Definition at line 138 of file CastorElectronicsMap.cc.
References mPItems, and query::result.
Referenced by CastorPedestalsAnalysis::analyze().
{ std::vector <HcalGenericDetId> result; std::set <unsigned long> allIds; for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++) if (item->mId) allIds.insert (item->mId); for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) { result.push_back (HcalGenericDetId (*channel)); } return result; }
std::vector< HcalTrigTowerDetId > CastorElectronicsMap::allTriggerId | ( | ) | const |
Definition at line 149 of file CastorElectronicsMap.cc.
References mTItems, and query::result.
{ std::vector <HcalTrigTowerDetId> result; std::set <unsigned long> allIds; for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++) if (item->mTrigId) allIds.insert (item->mTrigId); for (std::set <unsigned long>::const_iterator channel = allIds.begin (); channel != allIds.end (); channel++) result.push_back (HcalTrigTowerDetId (*channel)); return result; }
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().
{ PrecisionItem target (fId, 0); std::vector<const CastorElectronicsMap::PrecisionItem*>::const_iterator item; if (!sortedByPId) sortById(); item = std::lower_bound (mPItemsById.begin(), mPItemsById.end(), &target, castor_impl::LessById()); if (item == mPItemsById.end() || (*item)->mId != fId) // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId; return 0; return *item; }
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().
{ TriggerItem target (fTrigId,0); std::vector<const CastorElectronicsMap::TriggerItem*>::const_iterator item; if (!sortedByTId) sortByTriggerId(); item = std::lower_bound (mTItemsByTrigId.begin(), mTItemsByTrigId.end(), &target, castor_impl::LessByTrigId()); if (item == mTItemsByTrigId.end() || (*item)->mTrigId != fTrigId) // throw cms::Exception ("Conditions not found") << "Unavailable Electronics map for cell " << fId; return 0; return *item; }
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().
{ CastorElectronicsId eid(fElId); const PrecisionItem* i=&(mPItems[eid.linearIndex()]); if (i!=0 && i->mElId!=fElId) i=0; return i; }
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().
{ CastorElectronicsId eid(fElId); const TriggerItem* i=&(mTItems[eid.linearIndex()]); if (i!=0 && i->mElId!=fElId) i=0; return i; }
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.
{ const PrecisionItem* i=&(mPItems[pid.linearIndex()]); if (i!=0 && i->mId!=0) { eid=CastorElectronicsId(i->mElId); did=HcalGenericDetId(i->mId); return true; } else return false; }
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().
{ const PrecisionItem* item = findById (fId.rawId ()); return CastorElectronicsId (item ? item->mElId : 0); }
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(), CastorUnpacker::unpack(), and CastorCtdcUnpacker::unpack().
{ const PrecisionItem* item = findPByElId (fId.rawId ()); return DetId (item ? item->mId : 0); }
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.
{ const TriggerItem* i=&(mTItems[pid.linearIndex()]); if (i!=0 && i->mTrigId!=0) { eid=CastorElectronicsId(i->mElId); did=HcalGenericDetId(i->mTrigId); return true; } else return false; }
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().
{ const TriggerItem* item = findByTrigId (fId.rawId ()); return CastorElectronicsId (item ? item->mElId : 0); }
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().
{ const TriggerItem* item = findTByElId (fId.rawId ()); return DetId (item ? item->mTrigId : 0); }
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().
{ PrecisionItem& item = mPItems[fElectronicsId.linearIndex()]; sortedByPId=false; if (item.mElId==0) item.mElId=fElectronicsId.rawId(); if (item.mId == 0) { item.mId = fId.rawId (); } else if (item.mId != fId.rawId ()) { edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to channel " << HcalGenericDetId(item.mId) << ". New value " << HcalGenericDetId(fId) << " is ignored" ; return false; } return true; }
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.
{ TriggerItem& item = mTItems[fElectronicsId.linearIndex()]; sortedByTId=false; if (item.mElId==0) item.mElId=fElectronicsId.rawId(); if (item.mTrigId == 0) { item.mTrigId = fTriggerId.rawId (); // just cast avoiding long machinery } else if (item.mTrigId != fTriggerId.rawId ()) { edm::LogWarning("CASTOR") << "CastorElectronicsMap::mapEId2tId-> Electronics channel " << fElectronicsId << " already mapped to trigger channel " << (HcalTrigTowerDetId(item.mTrigId)) << ". New value " << fTriggerId << " is ignored" ; return false; } return true; }
void CastorElectronicsMap::sort | ( | ) | [inline] |
Definition at line 63 of file CastorElectronicsMap.h.
Referenced by CastorDbHardcode::makeHardcodeMap(), sortById(), and sortByTriggerId().
{}
void CastorElectronicsMap::sortById | ( | ) | const |
Definition at line 190 of file CastorElectronicsMap.cc.
References i, mPItems, mPItemsById, sort(), and sortedByPId.
Referenced by findById().
{ if (!sortedByPId) { mPItemsById.clear(); for (std::vector<PrecisionItem>::const_iterator i=mPItems.begin(); i!=mPItems.end(); ++i) { if (i->mElId) mPItemsById.push_back(&(*i)); } std::sort (mPItemsById.begin(), mPItemsById.end(), castor_impl::LessById ()); sortedByPId=true; } }
void CastorElectronicsMap::sortByTriggerId | ( | ) | const |
Definition at line 202 of file CastorElectronicsMap.cc.
References i, mTItems, mTItemsByTrigId, sort(), and sortedByTId.
Referenced by findByTrigId().
{ if (!sortedByTId) { mTItemsByTrigId.clear(); for (std::vector<TriggerItem>::const_iterator i=mTItems.begin(); i!=mTItems.end(); ++i) { if (i->mElId) mTItemsByTrigId.push_back(&(*i)); } std::sort (mTItemsByTrigId.begin(), mTItemsByTrigId.end(), castor_impl::LessByTrigId ()); sortedByTId=true; } }
std::vector<PrecisionItem> CastorElectronicsMap::mPItems [protected] |
Definition at line 87 of file CastorElectronicsMap.h.
Referenced by allElectronicsId(), allElectronicsIdPrecision(), allPrecisionId(), findPByElId(), lookup(), mapEId2chId(), and sortById().
std::vector<const PrecisionItem*> CastorElectronicsMap::mPItemsById [mutable, protected] |
Definition at line 89 of file CastorElectronicsMap.h.
Referenced by findById(), and sortById().
std::vector<TriggerItem> CastorElectronicsMap::mTItems [protected] |
Definition at line 88 of file CastorElectronicsMap.h.
Referenced by allElectronicsId(), allElectronicsIdTrigger(), allTriggerId(), findTByElId(), lookup(), mapEId2tId(), and sortByTriggerId().
std::vector<const TriggerItem*> CastorElectronicsMap::mTItemsByTrigId [mutable, protected] |
Definition at line 91 of file CastorElectronicsMap.h.
Referenced by findByTrigId(), and sortByTriggerId().
bool CastorElectronicsMap::sortedByPId [mutable, protected] |
Definition at line 90 of file CastorElectronicsMap.h.
Referenced by findById(), mapEId2chId(), and sortById().
bool CastorElectronicsMap::sortedByTId [mutable, protected] |
Definition at line 92 of file CastorElectronicsMap.h.
Referenced by findByTrigId(), mapEId2tId(), and sortByTriggerId().