CMS 3D CMS Logo

Classes | Public Member Functions | Protected Member Functions | Protected Attributes

HcalElectronicsMap Class Reference

#include <HcalElectronicsMap.h>

List of all members.

Classes

class  PrecisionItem
class  TriggerItem

Public Member Functions

std::vector< HcalElectronicsIdallElectronicsId () const
std::vector< HcalElectronicsIdallElectronicsIdPrecision () const
std::vector< HcalElectronicsIdallElectronicsIdTrigger () const
std::vector< HcalGenericDetIdallPrecisionId () const
std::vector< HcalTrigTowerDetIdallTriggerId () const
 HcalElectronicsMap ()
const HcalElectronicsId lookup (DetId fId) const
 brief lookup the electronics detid associated with the given logical id
bool lookup (const HcalElectronicsId pId, HcalElectronicsId &eid, HcalTrigTowerDetId &did) const
 brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/slb/slbchan) id
const DetId lookup (HcalElectronicsId fId) const
 lookup the logical detid associated with the given electronics id
bool lookup (const HcalElectronicsId pId, HcalElectronicsId &eid, HcalGenericDetId &did) const
 brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/fiber/fiberchan) id
const DetId lookupTrigger (HcalElectronicsId fId) const
 brief lookup the trigger logical detid associated with the given electronics id
const HcalElectronicsId lookupTrigger (DetId fId) const
 brief lookup the electronics detid associated with the given trigger logical id
bool mapEId2chId (HcalElectronicsId fElectronicsId, DetId fId)
bool mapEId2tId (HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
void sort ()
void sortById () const
void sortByTriggerId () const
 ~HcalElectronicsMap ()

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:
2007/12/14 13:31:21
Revision:
1.17
Author:
Fedor Ratnikov (UMd) POOL object to store mapping for Hcal channels $Author: ratnikov
Date:
2008/01/22 18:58:47
Revision:
1.23

Definition at line 24 of file HcalElectronicsMap.h.


Constructor & Destructor Documentation

HcalElectronicsMap::HcalElectronicsMap ( )
HcalElectronicsMap::~HcalElectronicsMap ( )

Definition at line 28 of file HcalElectronicsMap.cc.

{}

Member Function Documentation

std::vector< HcalElectronicsId > HcalElectronicsMap::allElectronicsId ( ) const

Definition at line 112 of file HcalElectronicsMap.cc.

References mPItems, mTItems, and query::result.

Referenced by HcalLuttoDB::analyze().

                                                                          {
  std::vector <HcalElectronicsId> result;
  for (std::vector<PrecisionItem>::const_iterator item = mPItems.begin (); item != mPItems.end (); item++) 
    if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));
  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++) 
    if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));

  return result;
}
std::vector< HcalElectronicsId > HcalElectronicsMap::allElectronicsIdPrecision ( ) const
std::vector< HcalElectronicsId > HcalElectronicsMap::allElectronicsIdTrigger ( ) const

Definition at line 129 of file HcalElectronicsMap.cc.

References mTItems, and query::result.

Referenced by EMap::EMap().

                                                                                {
  std::vector <HcalElectronicsId> result;
  for (std::vector<TriggerItem>::const_iterator item = mTItems.begin (); item != mTItems.end (); item++) 
    if (item->mElId) result.push_back(HcalElectronicsId(item->mElId));

  return result;
}
std::vector< HcalGenericDetId > HcalElectronicsMap::allPrecisionId ( ) const

Definition at line 137 of file HcalElectronicsMap.cc.

References mPItems, and query::result.

Referenced by HcalPedestalMCWidths::analyze(), HcalCholeskyDecomp::analyze(), HcalPedestalsAnalysis::analyze(), and HcalPedestalWidthsValidation::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 > HcalElectronicsMap::allTriggerId ( ) const

Definition at line 148 of file HcalElectronicsMap.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 HcalElectronicsMap::PrecisionItem * HcalElectronicsMap::findById ( unsigned long  fId) const [protected]

Definition at line 30 of file HcalElectronicsMap.cc.

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

Referenced by lookup().

                                                                                            {
  PrecisionItem target (fId, 0);
  std::vector<const HcalElectronicsMap::PrecisionItem*>::const_iterator item;

  if (!sortedByPId) sortById();
  
  item = std::lower_bound (mPItemsById.begin(), mPItemsById.end(), &target, hcal_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 HcalElectronicsMap::TriggerItem * HcalElectronicsMap::findByTrigId ( unsigned long  fTrigId) const [protected]

Definition at line 60 of file HcalElectronicsMap.cc.

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

Referenced by lookupTrigger().

                                                                                                  {
  TriggerItem target (fTrigId,0);
  std::vector<const HcalElectronicsMap::TriggerItem*>::const_iterator item;

  if (!sortedByTId) sortByTriggerId();
  
  item = std::lower_bound (mTItemsByTrigId.begin(), mTItemsByTrigId.end(), &target, hcal_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 HcalElectronicsMap::PrecisionItem * HcalElectronicsMap::findPByElId ( unsigned long  fElId) const [protected]

Definition at line 43 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::PrecisionItem::mElId, and mPItems.

Referenced by lookup().

                                                                                                 {
  HcalElectronicsId eid(fElId);
  const PrecisionItem* i=&(mPItems[eid.linearIndex()]);
  
  if (i!=0 && i->mElId!=fElId) i=0;
  return i;
}
const HcalElectronicsMap::TriggerItem * HcalElectronicsMap::findTByElId ( unsigned long  fElId) const [protected]

Definition at line 51 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::TriggerItem::mElId, and mTItems.

Referenced by lookupTrigger().

                                                                                               {
  HcalElectronicsId eid(fElId);
  const TriggerItem* i=&(mTItems[eid.linearIndex()]);
  
  if (i!=0 && i->mElId!=fElId) i=0;
  return i;
}
bool HcalElectronicsMap::lookup ( const HcalElectronicsId  pId,
HcalElectronicsId eid,
HcalGenericDetId did 
) const

brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/fiber/fiberchan) id

Definition at line 93 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::PrecisionItem::mElId, HcalElectronicsMap::PrecisionItem::mId, and mPItems.

                                                                                                                {
  const PrecisionItem* i=&(mPItems[pid.linearIndex()]);
  if (i!=0 && i->mId!=0) {
    eid=HcalElectronicsId(i->mElId);
    did=HcalGenericDetId(i->mId);
    return true;
  } else return false;
}
const HcalElectronicsId HcalElectronicsMap::lookup ( DetId  fId) const

brief lookup the electronics detid associated with the given logical id

Definition at line 78 of file HcalElectronicsMap.cc.

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

                                                                  {
  const PrecisionItem* item = findById (fId.rawId ());
  return HcalElectronicsId (item ? item->mElId : 0);
}
const DetId HcalElectronicsMap::lookup ( HcalElectronicsId  fId) const
bool HcalElectronicsMap::lookup ( const HcalElectronicsId  pId,
HcalElectronicsId eid,
HcalTrigTowerDetId did 
) const

brief lookup the DetId and full electronics id associated with this partial (dcc/spigot/slb/slbchan) id

Definition at line 102 of file HcalElectronicsMap.cc.

References i, HcalElectronicsId::linearIndex(), HcalElectronicsMap::TriggerItem::mElId, mTItems, and HcalElectronicsMap::TriggerItem::mTrigId.

                                                                                                                  {
  const TriggerItem* i=&(mTItems[pid.linearIndex()]);
  if (i!=0 && i->mTrigId!=0) {
    eid=HcalElectronicsId(i->mElId);
    did=HcalGenericDetId(i->mTrigId);
    return true;
  } else return false;  
}
const HcalElectronicsId HcalElectronicsMap::lookupTrigger ( DetId  fId) const

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

Definition at line 88 of file HcalElectronicsMap.cc.

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

                                                                         {
  const TriggerItem* item = findByTrigId (fId.rawId ());
  return HcalElectronicsId (item ? item->mElId : 0);
}
const DetId HcalElectronicsMap::lookupTrigger ( HcalElectronicsId  fId) const

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

Definition at line 83 of file HcalElectronicsMap.cc.

References findTByElId(), HcalElectronicsMap::TriggerItem::mTrigId, and HcalElectronicsId::rawId().

Referenced by HcalLuttoDB::analyze(), EMap::EMap(), and HcalUnpacker::unpack().

                                                                         {
  const TriggerItem* item = findTByElId (fId.rawId ());
  return DetId (item ? item->mTrigId : 0);
}
bool HcalElectronicsMap::mapEId2chId ( HcalElectronicsId  fElectronicsId,
DetId  fId 
)

Definition at line 173 of file HcalElectronicsMap.cc.

References HcalElectronicsId::linearIndex(), HcalElectronicsMap::PrecisionItem::mElId, HcalElectronicsMap::PrecisionItem::mId, mPItems, HcalElectronicsId::rawId(), DetId::rawId(), and sortedByPId.

Referenced by HcalLogicalMap::generateHcalElectronicsMap(), and HcalDbOnline::getObject().

                                                                                 {
  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("HCAL") << "HcalElectronicsMap::mapEId2tId-> Electronics channel " <<  fElectronicsId << " already mapped to channel " 
                             << HcalGenericDetId(item.mId) << ". New value " << HcalGenericDetId(fId) << " is ignored" ;
       return false;
  }
  return true;
}
bool HcalElectronicsMap::mapEId2tId ( HcalElectronicsId  fElectronicsId,
HcalTrigTowerDetId  fTriggerId 
)

Definition at line 158 of file HcalElectronicsMap.cc.

References HcalElectronicsId::linearIndex(), HcalElectronicsMap::TriggerItem::mElId, mTItems, HcalElectronicsMap::TriggerItem::mTrigId, HcalElectronicsId::rawId(), DetId::rawId(), and sortedByTId.

Referenced by HcalLogicalMap::generateHcalElectronicsMap().

                                                                                                    {
  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("HCAL") << "HcalElectronicsMap::mapEId2tId-> Electronics channel " <<  fElectronicsId  << " already mapped to trigger channel " 
              << (HcalTrigTowerDetId(item.mTrigId)) << ". New value " << fTriggerId << " is ignored" ;
    return false;
  }
  return true;
}
void HcalElectronicsMap::sort ( ) [inline]
void HcalElectronicsMap::sortById ( ) const

Definition at line 189 of file HcalElectronicsMap.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(), hcal_impl::LessById ());
    sortedByPId=true;
  }
}
void HcalElectronicsMap::sortByTriggerId ( ) const

Definition at line 201 of file HcalElectronicsMap.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(), hcal_impl::LessByTrigId ());
    sortedByTId=true;
  }
}

Member Data Documentation

std::vector<PrecisionItem> HcalElectronicsMap::mPItems [protected]
std::vector<const PrecisionItem*> HcalElectronicsMap::mPItemsById [mutable, protected]

Definition at line 88 of file HcalElectronicsMap.h.

Referenced by findById(), and sortById().

std::vector<TriggerItem> HcalElectronicsMap::mTItems [protected]
std::vector<const TriggerItem*> HcalElectronicsMap::mTItemsByTrigId [mutable, protected]

Definition at line 90 of file HcalElectronicsMap.h.

Referenced by findByTrigId(), and sortByTriggerId().

bool HcalElectronicsMap::sortedByPId [mutable, protected]

Definition at line 89 of file HcalElectronicsMap.h.

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

bool HcalElectronicsMap::sortedByTId [mutable, protected]

Definition at line 91 of file HcalElectronicsMap.h.

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